From 46c00136c5a8684c50f0a518f53fa8af85d18d92 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sat, 28 Feb 2009 00:53:00 +0100 Subject: [PATCH] Automatic commit --- Makefile | 3 +++ selector.cc | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index f3918de..476a8db 100644 --- a/Makefile +++ b/Makefile @@ -34,3 +34,6 @@ all: selector selector: selector.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) + +clean: + rm -f *.o selector diff --git a/selector.cc b/selector.cc index 7a79979..7d59b2f 100644 --- a/selector.cc +++ b/selector.cc @@ -31,13 +31,15 @@ using namespace std; const int buffer_size = 1024; const int nb_lines_max = 100000; -void build_display(int *screen_line, int *line, int nb_lines, char **lines, char *regexp) { +void refresh_screen(int *screen_line, int *line, int nb_lines, char **lines, char *regexp, int noblink) { char buffer[buffer_size]; int maxx = getmaxx(stdscr); int maxy = min(buffer_size-2, getmaxy(stdscr)); - // clear(); // Cleaning the window + if(!noblink) { + clear(); + } use_default_colors(); @@ -56,8 +58,10 @@ void build_display(int *screen_line, int *line, int nb_lines, char **lines, char k++; } - while(k < maxx - 1) { - buffer[k++] = ' '; + if(noblink) { + while(k < maxx - 1) { + buffer[k++] = ' '; + } } buffer[k++] = '\n'; buffer[k++] = '\0'; @@ -76,7 +80,7 @@ void build_display(int *screen_line, int *line, int nb_lines, char **lines, char y++; } - { // Erase the rest of the window. That's slightly ugly. + if(noblink) { // Erase the rest of the window. That's slightly ugly. int k = 0; while(k < maxx - 1) { buffer[k++] = ' '; @@ -104,6 +108,7 @@ void build_display(int *screen_line, int *line, int nb_lines, char **lines, char int main(int argc, char **argv) { char buffer[buffer_size]; char *lines[nb_lines_max]; + int noblink = 1; char *file_name; char stdin_name[] = "/dev/stdin"; @@ -152,7 +157,7 @@ int main(int argc, char **argv) { int line = 0, screen_line = 0; - build_display(&screen_line, &line, nb_lines, lines, regexp); + refresh_screen(&screen_line, &line, nb_lines, lines, regexp, noblink); do { @@ -180,7 +185,7 @@ int main(int argc, char **argv) { line++; } - build_display(&screen_line, &line, nb_lines, lines, regexp); + refresh_screen(&screen_line, &line, nb_lines, lines, regexp, noblink); } while(key != '\n' && key != KEY_ENTER && key != ''); echo(); @@ -193,3 +198,4 @@ int main(int argc, char **argv) { return 0; } + -- 2.20.1