From 25291030902678fe8987e6cd97cd27cb4121ba06 Mon Sep 17 00:00:00 2001 From: josuah Date: Fri, 21 Oct 2016 11:27:10 -0400 Subject: [PATCH] Started to put branches for different modes --- iomenu.c | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/iomenu.c b/iomenu.c index 491eceb..c1bec30 100644 --- a/iomenu.c +++ b/iomenu.c @@ -146,29 +146,29 @@ filter_lines(Buffer *buffer) int line_match_input(Line *line, char *input) { - size_t /*i, j,*/ len_input/*, len_content*/; + size_t i, j, len_input, len_content; len_input = strlen(input); - /*len_content = strlen(line->content);*/ + len_content = strlen(line->content); - if (!strncmp(input, line->content, len_input)) { - return TRUE; - } else { - return FALSE; - } - - /* - for (i = 0; i < len_content - len_input; i++) { - for (j = 0; - j < len_input && i + j < len_content - && tolower(input[j]) == tolower(line->content[i + j]); - j++) - ; - - if (j == len_input) { + if (TRUE /* complete-mode */) { + if (!strncmp(input, line->content, len_input)) { return TRUE; + } else { + return FALSE; + } + } else { + for (i = 0; i < len_content - len_input; i++) { + for (j = 0; + j < len_input && i + j < len_content + && tolower(input[j]) == tolower(line->content[i + j]); + j++) + ; + + if (j == len_input) { + return TRUE; + } } } - */ return FALSE; } @@ -436,15 +436,23 @@ do_key(char key, Buffer *buffer) break; case CONTROL('I'): /* tab */ - strcpy(buffer->input, buffer->current->content); - - filter_lines(buffer); + if (TRUE /* complete-mode */) { + strcpy(buffer->input, buffer->current->content); + filter_lines(buffer); + } else { + do_next_line(buffer); + } break; case CONTROL('M'): case CONTROL('J'): /* enter */ fputs("\r\033[K", stderr); - puts(buffer->current->content); + + if (TRUE /* complete-mode */) { + puts(buffer->input); + } else { + puts(buffer->current->content); + } return FALSE; default: @@ -579,7 +587,7 @@ main(int argc, char *argv[]) { int i; Buffer *buffer = NULL; - char *separator = ""; + char *separator = "separator"; int count = 30; int offset = 3; int tty = open("/dev/tty", O_RDWR); -- 2.11.4.GIT