diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-18 19:34:11 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-10-18 20:46:38 +0200 |
commit | e06d9c9f71d8b00fb442a7ab2a6cc9fd459a2ae6 (patch) | |
tree | d1e7dd57888b5a5995420e4b833aeb43f957a6fa | |
parent | 6f91f8131a26c5315a238314fc282a1cdc1d4a7e (diff) | |
download | tdv-e06d9c9f71d8b00fb442a7ab2a6cc9fd459a2ae6.tar.gz tdv-e06d9c9f71d8b00fb442a7ab2a6cc9fd459a2ae6.tar.xz tdv-e06d9c9f71d8b00fb442a7ab2a6cc9fd459a2ae6.zip |
Tiny enhancements and cleanups
-rw-r--r-- | src/sdtui.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/sdtui.c b/src/sdtui.c index 54faa7c..00eb163 100644 --- a/src/sdtui.c +++ b/src/sdtui.c @@ -1107,8 +1107,7 @@ static ViewEntry * append_entry (Application *self, guint32 position) { ViewEntry *ve = NULL; - StardictIterator *iterator = stardict_iterator_new - (self->dict, position); + StardictIterator *iterator = stardict_iterator_new (self->dict, position); if (stardict_iterator_is_valid (iterator)) { ve = view_entry_new (iterator); @@ -1184,10 +1183,9 @@ app_scroll_down (Application *self, guint n) break; } + // TODO: try to disallow scrolling past the end ViewEntry *first_entry = g_ptr_array_index (self->entries, 0); - if (self->top_offset < first_entry->definitions_length - 1) - self->top_offset++; - else + if (++self->top_offset >= first_entry->definitions_length) { n_definitions -= first_entry->definitions_length; g_ptr_array_remove_index (self->entries, 0); @@ -1260,7 +1258,8 @@ app_one_entry_down (Application *self) break; } - if (first > LINES - TOP_BAR_CUTOFF - 1) + // FIXME: selection can still get past the end + if (first >= LINES - TOP_BAR_CUTOFF) { self->selected = LINES - TOP_BAR_CUTOFF - 1; app_scroll_down (self, first - (LINES - TOP_BAR_CUTOFF - 1)); @@ -1299,6 +1298,10 @@ app_search_for_entry (Application *self) self->show_help = FALSE; app_reload_view (self); + // Don't let the iterator get past the end of the dictionary + if (!self->entries->len) + (void) app_scroll_up (self, 1); + // If the user wants it centered, just move the view up half a screen; // actually, one third seems to be a better guess if (self->center_search) @@ -1451,13 +1454,11 @@ app_process_user_action (Application *self, UserAction action) case USER_ACTION_GOTO_PAGE_PREVIOUS: app_scroll_up (self, LINES - TOP_BAR_CUTOFF); - // FIXME: selection app_redraw_view (self); RESTORE_CURSOR return TRUE; case USER_ACTION_GOTO_PAGE_NEXT: app_scroll_down (self, LINES - TOP_BAR_CUTOFF); - // FIXME: selection app_redraw_view (self); RESTORE_CURSOR return TRUE; |