X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=selector.cc;h=d8092878269827c51ec887dac996f3165f7e1e3f;hb=edbfa69ea4c14c890230182b4e9a3bd20635deff;hp=34ed86bbecc9ea42b511a22908758926ffbef8f9;hpb=35f5674e21b17ae2eaf8f0f8036d27477ef75dc1;p=selector.git diff --git a/selector.cc b/selector.cc index 34ed86b..d809287 100644 --- a/selector.cc +++ b/selector.cc @@ -31,16 +31,20 @@ using namespace std; const int buffer_size = 1024; const int nb_lines_max = 100000; -void build_display(int key, int nb_lines, char **lines, char *regexp) { +void build_display(int line, int nb_lines, char **lines, char *regexp) { char buffer[buffer_size]; - clear(); // Cleaning the window - refresh(); // After doing something on the display, we refresh it + int maxx = getmaxx(stdscr); int maxy = getmaxy(stdscr); + + clear(); // Cleaning the window + refresh(); // After doing something on the display, we refresh it + use_default_colors(); - // printw("maxx %d maxy %d key %d\n", maxx, maxy, key); + printw("\n"); printw("\n"); + int nb_printed_lines = 2; for(int y = 0; nb_printed_lines < maxy && y < nb_lines; y++) { if(strstr(lines[y], regexp)) { @@ -55,14 +59,15 @@ void build_display(int key, int nb_lines, char **lines, char *regexp) { nb_printed_lines++; } } + + // Draw the modeline + move(0, 0); attron(COLOR_PAIR(1)); // Let's print something in red on black printw("%d/%d pattern: %s\n", nb_printed_lines, nb_lines - 2, regexp); attroff(COLOR_PAIR(1)); // Let's get back to default colors! } -// I should find were this is defined ... - int main(int argc, char **argv) { int dummy, xpos, ypos; @@ -115,7 +120,7 @@ int main(int argc, char **argv) { printw("Press a key to contine\n"); int key; - build_display(-1, nb_lines, lines, regexp); + build_display(0, nb_lines, lines, regexp); do { key = getch(); @@ -128,7 +133,7 @@ int main(int argc, char **argv) { regexp[regexp_point] = '\0'; } } - build_display(key, nb_lines, lines, regexp); + build_display(0, nb_lines, lines, regexp); } while(key != '\n' && key != KEY_ENTER); echo(); // We want to have echo