page up/down works; long entries are truncated

This commit is contained in:
anon
2024-08-06 18:06:01 +02:00
parent cc13c821aa
commit 733d8580dd
2 changed files with 28 additions and 3 deletions

View File

@ -1,3 +1,5 @@
+ make (potentially slow) queries cancel using multi threading + make (potentially slow) queries cancel using multi threading
+ levenstein seems horribly buggy with single character results + instant run mode
+ rebinding queries should be faster than repreparing them + scroll lags
+ technical dept in tui.cpp
+ migrate to C

View File

@ -87,14 +87,16 @@ void tui_append_back(const entry_t entry) {
struct tm *tm_info = localtime((time_t*)&entry.timestamp); struct tm *tm_info = localtime((time_t*)&entry.timestamp);
const int TIME_BUFFER_SIZE = 30; const int TIME_BUFFER_SIZE = 30;
char time_buffer[TIME_BUFFER_SIZE]; char time_buffer[TIME_BUFFER_SIZE];
const int time_len = 19;
strftime(time_buffer, TIME_BUFFER_SIZE, "%Y-%m-%d %H:%M:%S", tm_info); strftime(time_buffer, TIME_BUFFER_SIZE, "%Y-%m-%d %H:%M:%S", tm_info);
if (entry_line_index == selection_relative) { if (entry_line_index == selection_relative) {
wattron(entry_window, A_REVERSE); wattron(entry_window, A_REVERSE);
} }
mvwprintw(entry_window, (entry_lines-1)-entry_line_index, 0, mvwprintw(entry_window, (entry_lines-1)-entry_line_index, 0,
"%s %s\n", "%s %.*s",
time_buffer, time_buffer,
COLS-2-time_len-2, // XXX: this is horrible
entry.command entry.command
); );
if (entry_line_index == selection_relative) { if (entry_line_index == selection_relative) {
@ -119,10 +121,14 @@ void tui_refresh(void) {
wrefresh(entry_window); wrefresh(entry_window);
wrefresh(main_window); wrefresh(main_window);
refresh_input(); refresh_input();
wclear(entry_window);
} }
void tui_take_input(void) { void tui_take_input(void) {
const size_t paging_size = entry_lines / 2;
input = wgetch(stdscr); input = wgetch(stdscr);
switch (input) { switch (input) {
case KEY_UP: case KEY_UP:
@ -147,6 +153,23 @@ void tui_take_input(void) {
} }
} }
} break; } break;
case KEY_PPAGE:
case CTRL('u'): {
selection_offset += paging_size;
is_input_changed = true;
} break;
case KEY_NPAGE:
case CTRL('d'): {
if (selection_offset == 0) {
selection_relative = 0;
} else
if (selection_offset > paging_size) {
selection_offset -= paging_size;
} else {
selection_offset = 0;
}
is_input_changed = true;
} break;
case '\r': { case '\r': {
do_run = false; do_run = false;
} break; } break;