/* Multi line low level line refresh. * * Rewrite the currently edited line accordingly to the buffer content, * cursor position, and number of columns of the terminal. */ static void refreshMultiLine(struct linenoiseState *l) { int plen = wcslen(l->prompt); int rows = (plen+l->len+l->cols-1)/l->cols; /* rows used by current buf. */ int rpos = (plen+l->oldpos+l->cols)/l->cols; /* cursor relative row. */ int rpos2; /* rpos after refresh. */ int old_rows = l->maxrows; int j; /* Update maxrows if needed. */ if (rows > (int)l->maxrows) l->maxrows = rows; /* First step: clear all the lines used before. To do so start by * going to the last row. */ if (old_rows-rpos > 0) { console_move_down(old_rows - rpos); } /* Now for every row clear it, go up. */ for (j = 0; j < old_rows-1; j++) { console_move_to_column(0); console_erase_to_end_of_line(); console_move_up(1); } /* Clean the top line. */ console_move_to_column(0); console_erase_to_end_of_line(); /* Write the prompt and the current buffer content */ console_write_wchar_string(l->prompt, plen); console_write_wchar_string(l->buf, l->len); /* If we are at the very end of the screen with our prompt, we need to * emit a newline and move the prompt to the first column. */ if (l->pos && l->pos == l->len && (l->pos+plen) % l->cols == 0) { console_scroll_up(1); console_move_to_column(0); rows++; if (rows > (int)l->maxrows) l->maxrows = rows; } /* Move cursor to right position. */ rpos2 = (plen+l->pos+l->cols)/l->cols; /* current cursor relative row. */ /* Go up till we reach the expected positon. */ if (rows-rpos2 > 0) { console_move_up(rows - rpos2); } /* Set column. */ console_move_to_column(((plen+(int)l->pos) % (int)l->cols)); // console_move_down(1); l->oldpos = l->pos; }
void console_move_page_up() { int max_lines; int i; max_lines=(window_height-hud_y)/18-3; for(i=0;i<max_lines;i++) { console_move_up(); } }