add bottom line
This commit is contained in:
parent
c28bd0ec7b
commit
c8584cd8a1
@ -68,7 +68,8 @@ typedef struct vga_buf
|
||||
void *buf; // 2d array, screen size, for text mode it's [maxline][80]
|
||||
int max_line; // to support scroll, max line should be a lot more than screen
|
||||
int scr_top_line; // the index in buf of top line on screen;
|
||||
int scr_cur_line; // the index in buf of the cursor's line
|
||||
int scr_cur_line; // the index in buf of the cursor's line;
|
||||
int scr_bot_line; // the index in buf of the most-bottom printed line
|
||||
int head_line; // for circular buffer use
|
||||
int cur_row;
|
||||
int cur_col; // cursor position, on screen
|
||||
|
||||
@ -132,7 +132,7 @@ void vga_tty_init(NTTY *tty)
|
||||
// kprintf("malloced %p %p %p\n", vga->buf, &vga->buf, &vga->scr_top_line);
|
||||
vga->cur_col = vga->cur_row = 0;
|
||||
// buf->max_line = SCR_BUFSIZE / SCR_WIDTH;
|
||||
vga->scr_top_line = vga->scr_cur_line = 0;
|
||||
vga->scr_top_line = vga->scr_cur_line = vga->scr_bot_line = 0;
|
||||
vga->head_line = 0;
|
||||
u32 *ptr_buf = (u32 *)vga->buf;
|
||||
for (int i = 0; i < SCR_BUFSIZE * sizeof(u16) / sizeof(u32); ++i)
|
||||
@ -551,6 +551,9 @@ void vga_tty_write(NTTY *tty, char ch)
|
||||
}
|
||||
}
|
||||
vga->cur_row = CYCLE_SUB(vga->scr_top_line, vga->scr_cur_line, SCR_MAXLINE);
|
||||
if (CYCLE_SUB(vga->head_line, vga->scr_cur_line, SCR_MAXLINE) >= CYCLE_SUB(vga->head_line, vga->scr_bot_line, SCR_MAXLINE)){
|
||||
vga->scr_bot_line = vga->scr_cur_line;
|
||||
}
|
||||
// kprintf("row: %d; ", vga->cur_row);
|
||||
}
|
||||
|
||||
@ -577,6 +580,8 @@ void vga_tty_flush(NTTY *tty)
|
||||
u16 *buf = vga->buf;
|
||||
int i, cur_line;
|
||||
vga_set_cursor(INDEX(vga->cur_row, vga->cur_col));
|
||||
vga->cur_row = CYCLE_SUB(vga->scr_top_line, vga->scr_cur_line, SCR_MAXLINE);
|
||||
int bottom = min(max(vga->cur_row, CYCLE_SUB(vga->scr_top_line, vga->scr_bot_line, SCR_MAXLINE)), SCR_HEIGHT);
|
||||
// if (vga->cur_row == SCR_HEIGHT - 1)
|
||||
// {
|
||||
// vga_flush_screen(&buf[INDEX(vga->scr_top_line, 0)]);
|
||||
@ -585,7 +590,7 @@ void vga_tty_flush(NTTY *tty)
|
||||
// else
|
||||
// {
|
||||
cur_line = vga->scr_top_line;
|
||||
for (i = 0; i <= vga->cur_row; ++i)
|
||||
for (i = 0; i <= bottom; ++i)
|
||||
{
|
||||
vga_flush_line(&buf[INDEX(cur_line, 0)], i);
|
||||
cur_line = NEXTLINE(cur_line);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user