Browse Source

Add '+' ruler markers to tui

master
cancel 6 years ago
parent
commit
61445124c3
  1. 19
      tui_main.c

19
tui_main.c

@ -37,17 +37,27 @@ void draw_ui_bar(WINDOW* win, int win_y, int win_x, const char* filename,
} }
void draw_debug_field(WINDOW* win, int win_y, int win_x, Glyph const* gbuffer, void draw_debug_field(WINDOW* win, int win_y, int win_x, Glyph const* gbuffer,
Usz height, Usz width) { Usz height, Usz width, Usz ruler_spacing_y,
Usz ruler_spacing_x) {
enum { Bufcount = 4096 }; enum { Bufcount = 4096 };
if (width > Bufcount) if (width > Bufcount)
return; return;
chtype buffer[Bufcount]; chtype buffer[Bufcount];
bool use_rulers = ruler_spacing_y != 0 && ruler_spacing_x != 0;
for (Usz y = 0; y < height; ++y) { for (Usz y = 0; y < height; ++y) {
Glyph const* gline = gbuffer + y * width; Glyph const* gline = gbuffer + y * width;
bool use_y_ruler = use_rulers && y % ruler_spacing_y == 0;
for (Usz x = 0; x < width; ++x) { for (Usz x = 0; x < width; ++x) {
Glyph g = gline[x]; Glyph g = gline[x];
int attr = g == '.' ? Tattr_boring_glyph : Tattr_default_bold; int attr;
buffer[x] = (chtype)(gline[x] | attr); if (g == '.') {
attr = Tattr_boring_glyph;
if (use_y_ruler && x % ruler_spacing_x == 0)
g = '+';
} else {
attr = Tattr_default_bold;
}
buffer[x] = (chtype)(g | attr);
} }
wmove(win, win_y + (int)y, (int)win_x); wmove(win, win_y + (int)y, (int)win_x);
waddchnstr(win, buffer, (int)width); waddchnstr(win, buffer, (int)width);
@ -159,7 +169,8 @@ int main(int argc, char** argv) {
(void)term_height; (void)term_height;
(void)term_width; (void)term_width;
// clear(); // clear();
draw_debug_field(stdscr, 0, 0, field.buffer, field.height, field.width); draw_debug_field(stdscr, 0, 0, field.buffer, field.height, field.width, 8,
8);
draw_ui_bar(stdscr, term_height - 1, 0, input_file, tick_num); draw_ui_bar(stdscr, term_height - 1, 0, input_file, tick_num);
//refresh(); //refresh();

Loading…
Cancel
Save