From 0b8c00ab195d7d67e3aeaae54b6010296a0bd09a Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Sun, 27 Apr 2025 21:09:43 +0200 Subject: [PATCH] implement scrollup --- arch/textwindow.cc | 9 ++++++++- arch/textwindow.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/textwindow.cc b/arch/textwindow.cc index b9562b9..de030de 100644 --- a/arch/textwindow.cc +++ b/arch/textwindow.cc @@ -1,5 +1,6 @@ #include "textwindow.h" #include "cga.h" +#include "../utils/string.h" TextWindow::TextWindow(unsigned from_col, unsigned to_col, unsigned from_row, unsigned to_row, bool use_cursor) { @@ -49,6 +50,12 @@ void TextWindow::getPos(int& rel_x, int& rel_y) const { rel_y = y; } +void TextWindow::scrollUp(){ + for(uint8_t row = from_row; row < to_row; row++){ + memmove(&CGA::TEXT_BUFFER_BASE[row*CGA::COLUMNS + from_col], &CGA::TEXT_BUFFER_BASE[(row+1)*CGA::COLUMNS + from_col], 2*(to_col-from_col)); + } +} + void TextWindow::print(const char* str, size_t length, CGA::Attribute attrib) { for(unsigned i=0; i= to_row-1){ - //TODO scrollUp() + scrollUp(); } else{ y_now++; diff --git a/arch/textwindow.h b/arch/textwindow.h index c7eb786..85b5cc1 100644 --- a/arch/textwindow.h +++ b/arch/textwindow.h @@ -29,6 +29,8 @@ class TextWindow { unsigned pos_x; unsigned pos_y; + void scrollUp(); + public: /*! \brief Constructor of a text window *