diff --git a/interactions.c b/interactions.c index ef6ad9b..01fbe93 100644 --- a/interactions.c +++ b/interactions.c @@ -664,5 +664,55 @@ void search_previous(){ status |= (STATUS_RUN_BACKEND); } void jmp_file_index(){ - TODO; + echo(); + unsigned long i; + for (i = 0; i < terminal_width -1; i++) { + mvwaddch(win_b, 0, i, ' '); + } + mvwaddch(win_b, 0, 0, ':'); + memset(search_buffer, 0, INPUT_BUFFER_SIZE); + + curs_set(1); + echo(); + + timeout(-1); /* negative numbers block until enter is pressed */ + + unsigned int pass = 0; + char ch; + char err = 0; + char number_buffer[INPUT_BUFFER_SIZE]; + char *num = number_buffer; + + wmove(win_b, 0, 1); + while(1) { + ch = wgetch(win_b); + + if (ch >= '0' && ch <= '9') { + *num = ch; + num++; + } else if (ch == '\n') { + break; + } else if (ch == 27) { /* esc key */ + break; + } else if (ch == 127) { /* backspace */ + num--; + if (num < number_buffer) { + num = number_buffer; + } + } + } + *num = 0; + num = number_buffer; + + unsigned long parsed_number = 0; + while(*num) { + parsed_number = (parsed_number * 10) + (*num - '0'); + num++; + } + mid_dir.current_file = &mid_dir.file_list[parsed_number]; + + noecho(); + curs_set(0); + + status |= (STATUS_RUN_BACKEND); }