implement scrollup

main
Eggert Jung 6 months ago
parent 0666fc30c7
commit 0b8c00ab19

@ -1,5 +1,6 @@
#include "textwindow.h" #include "textwindow.h"
#include "cga.h" #include "cga.h"
#include "../utils/string.h"
TextWindow::TextWindow(unsigned from_col, unsigned to_col, unsigned from_row, TextWindow::TextWindow(unsigned from_col, unsigned to_col, unsigned from_row,
unsigned to_row, bool use_cursor) { unsigned to_row, bool use_cursor) {
@ -49,6 +50,12 @@ void TextWindow::getPos(int& rel_x, int& rel_y) const {
rel_y = y; 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) { void TextWindow::print(const char* str, size_t length, CGA::Attribute attrib) {
for(unsigned i=0; i<length; i++){ for(unsigned i=0; i<length; i++){
unsigned x_now, y_now; unsigned x_now, y_now;
@ -56,7 +63,7 @@ void TextWindow::print(const char* str, size_t length, CGA::Attribute attrib) {
if(str[i] == '\n'){ if(str[i] == '\n'){
x_now = 0; x_now = 0;
if(from_row + y_now >= to_row-1){ if(from_row + y_now >= to_row-1){
//TODO scrollUp() scrollUp();
} }
else{ else{
y_now++; y_now++;

@ -29,6 +29,8 @@ class TextWindow {
unsigned pos_x; unsigned pos_x;
unsigned pos_y; unsigned pos_y;
void scrollUp();
public: public:
/*! \brief Constructor of a text window /*! \brief Constructor of a text window
* *

Loading…
Cancel
Save