Slightly optimized column rendering by using the sequence for moving
column position instead of row,col
This commit is contained in:
parent
8eedc8b726
commit
69bc783ff9
7
bb.c
7
bb.c
@ -784,7 +784,7 @@ void render(bb_t *bb)
|
|||||||
if (!col.name) continue;
|
if (!col.name) continue;
|
||||||
const char *title = col.name;
|
const char *title = col.name;
|
||||||
if (!title) title = "";
|
if (!title) title = "";
|
||||||
move_cursor(tty_out, x, 1);
|
move_cursor_col(tty_out, x);
|
||||||
if (c > 0) {
|
if (c > 0) {
|
||||||
fputs("┃\033[K", tty_out);
|
fputs("┃\033[K", tty_out);
|
||||||
x += 1;
|
x += 1;
|
||||||
@ -792,7 +792,7 @@ void render(bb_t *bb)
|
|||||||
const char *indicator = " ";
|
const char *indicator = " ";
|
||||||
if (bb->columns[c] == bb->sort[1])
|
if (bb->columns[c] == bb->sort[1])
|
||||||
indicator = bb->sort[0] == '-' ? RSORT_INDICATOR : SORT_INDICATOR;
|
indicator = bb->sort[0] == '-' ? RSORT_INDICATOR : SORT_INDICATOR;
|
||||||
move_cursor(tty_out, x, 1);
|
move_cursor_col(tty_out, x);
|
||||||
fputs(indicator, tty_out);
|
fputs(indicator, tty_out);
|
||||||
fputs(title, tty_out);
|
fputs(title, tty_out);
|
||||||
x += colwidths[c];
|
x += colwidths[c];
|
||||||
@ -816,10 +816,11 @@ void render(bb_t *bb)
|
|||||||
CURSOR_COLOR : color_of(entry->info.st_mode);
|
CURSOR_COLOR : color_of(entry->info.st_mode);
|
||||||
fputs(color, tty_out);
|
fputs(color, tty_out);
|
||||||
int x = 0, y = i - bb->scroll + 2;
|
int x = 0, y = i - bb->scroll + 2;
|
||||||
|
move_cursor(tty_out, x, y);
|
||||||
for (int c = 0; bb->columns[c]; c++) {
|
for (int c = 0; bb->columns[c]; c++) {
|
||||||
column_t col = columns[(int)bb->columns[c]];
|
column_t col = columns[(int)bb->columns[c]];
|
||||||
if (!col.name) continue;
|
if (!col.name) continue;
|
||||||
move_cursor(tty_out, x, y);
|
move_cursor_col(tty_out, x);
|
||||||
if (c > 0) { // Separator |
|
if (c > 0) { // Separator |
|
||||||
if (i == bb->cursor) fprintf(tty_out, "\033[2m┃\033[22m");
|
if (i == bb->cursor) fprintf(tty_out, "\033[2m┃\033[22m");
|
||||||
else fprintf(tty_out, "\033[37;2m┃\033[22m%s", color);
|
else fprintf(tty_out, "\033[37;2m┃\033[22m%s", color);
|
||||||
|
1
bterm.h
1
bterm.h
@ -76,6 +76,7 @@ typedef enum {
|
|||||||
#define T_OFF(opt) "\033[?" opt "l"
|
#define T_OFF(opt) "\033[?" opt "l"
|
||||||
|
|
||||||
#define move_cursor(f, x, y) fprintf((f), "\033[%d;%dH", (int)(y)+1, (int)(x)+1)
|
#define move_cursor(f, x, y) fprintf((f), "\033[%d;%dH", (int)(y)+1, (int)(x)+1)
|
||||||
|
#define move_cursor_col(f, x) fprintf((f), "\033[%d`", (int)(x)+1)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int key;
|
int key;
|
||||||
|
Loading…
Reference in New Issue
Block a user