aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-02-24 23:52:36 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2015-02-24 23:52:36 +0100
commit2f0852ec05a80fffebb40146949012441695be49 (patch)
tree08c5eb56d17f5f3b3c306e518abed83d034e8a42
parentf4b29a980cbb5366f80ad3c4d297259f7b590834 (diff)
downloadtdv-2f0852ec05a80fffebb40146949012441695be49.tar.gz
tdv-2f0852ec05a80fffebb40146949012441695be49.tar.xz
tdv-2f0852ec05a80fffebb40146949012441695be49.zip
Handle search field overflow a bit better
Make sure the cursor doesn't overflow where it doesn't belong.
-rw-r--r--src/sdtui.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/sdtui.c b/src/sdtui.c
index f2413a9..e05d889 100644
--- a/src/sdtui.c
+++ b/src/sdtui.c
@@ -416,14 +416,14 @@ app_add_utf8_string (Application *self, const gchar *str, int attrs, int n)
static void
app_redraw_top (Application *self)
{
- mvwhline (stdscr, 0, 0, A_REVERSE, COLS);
attrset (A_REVERSE);
+ mvwhline (stdscr, 0, 0, A_REVERSE, COLS);
gsize indent = app_add_utf8_string (self, PROJECT_NAME " ", A_BOLD, -1);
app_add_utf8_string (self, stardict_info_get_book_name
(stardict_dict_get_info (self->dict)), 0, COLS - indent);
- mvwhline (stdscr, 1, 0, A_UNDERLINE, COLS);
attrset (A_UNDERLINE);
+ mvwhline (stdscr, 1, 0, A_UNDERLINE, COLS);
indent = app_add_utf8_string (self, self->search_label, 0, -1);
gchar *input_utf8 = g_ucs4_to_utf8
@@ -433,7 +433,7 @@ app_redraw_top (Application *self)
int word_attrs = 0;
if (self->input_confirmed)
word_attrs |= A_BOLD;
- app_add_utf8_string (self, input_utf8, word_attrs, COLS - indent);
+ app_add_utf8_string (self, input_utf8, word_attrs, COLS - indent - 1);
g_free (input_utf8);
guint offset, i;
@@ -441,7 +441,7 @@ app_redraw_top (Application *self)
// This may be inconsistent with the output of app_add_utf8_string()
offset += unichar_width (g_array_index (self->input, gunichar, i));
- move (1, indent + offset);
+ move (1, MIN ((gint) (indent + offset), COLS - 1));
refresh ();
}