implement scrollup
This commit is contained in:
		@@ -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<length; i++){
 | 
			
		||||
        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'){
 | 
			
		||||
            x_now = 0;
 | 
			
		||||
            if(from_row + y_now >= to_row-1){
 | 
			
		||||
                //TODO scrollUp()
 | 
			
		||||
                scrollUp();
 | 
			
		||||
            }
 | 
			
		||||
            else{
 | 
			
		||||
                y_now++;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user