console: add tab-ruler support
The tab-ruler is used to set console tab-stops. We use an array with one cell per column that is set to true if it is a tab-stop and false if it is not. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
2543f13630
commit
e1095b5ef2
@ -81,6 +81,9 @@ struct kmscon_console {
|
||||
/* cursor */
|
||||
unsigned int cursor_x;
|
||||
unsigned int cursor_y;
|
||||
|
||||
/* tab ruler */
|
||||
bool *tab_ruler;
|
||||
};
|
||||
|
||||
static void cell_init(struct kmscon_console *con, struct cell *cell)
|
||||
@ -432,6 +435,7 @@ void kmscon_console_unref(struct kmscon_console *con)
|
||||
for (i = 0; i < con->line_num; ++i)
|
||||
line_free(con->lines[i]);
|
||||
free(con->lines);
|
||||
free(con->tab_ruler);
|
||||
free(con);
|
||||
}
|
||||
|
||||
@ -457,6 +461,7 @@ int kmscon_console_resize(struct kmscon_console *con, unsigned int x,
|
||||
struct line **cache;
|
||||
unsigned int i, j, width;
|
||||
int ret;
|
||||
bool *tab_ruler;
|
||||
|
||||
if (!con || !x || !y)
|
||||
return -EINVAL;
|
||||
@ -472,6 +477,11 @@ int kmscon_console_resize(struct kmscon_console *con, unsigned int x,
|
||||
* lines. Otherwise, if this function fails in later turns, we will have
|
||||
* invalid lines in the buffer. */
|
||||
if (y > con->line_num) {
|
||||
tab_ruler = realloc(con->tab_ruler, sizeof(bool) * y);
|
||||
if (!tab_ruler)
|
||||
return -ENOMEM;
|
||||
con->tab_ruler = tab_ruler;
|
||||
|
||||
cache = realloc(con->lines, sizeof(struct line*) * y);
|
||||
if (!cache)
|
||||
return -ENOMEM;
|
||||
@ -516,6 +526,14 @@ int kmscon_console_resize(struct kmscon_console *con, unsigned int x,
|
||||
if (con->size_y != 0 && y < con->size_y)
|
||||
console_scroll_up(con, con->size_y - y);
|
||||
|
||||
/* reset tabs */
|
||||
for (i = 0; i < y; ++i) {
|
||||
if (i % 8 == 0)
|
||||
con->tab_ruler[i] = true;
|
||||
else
|
||||
con->tab_ruler[i] = false;
|
||||
}
|
||||
|
||||
con->size_x = x;
|
||||
con->size_y = y;
|
||||
con->margin_top = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user