Show first part of inputbox if history items it too long.
authorDaniel Carl <danielcarl@gmx.de>
Sun, 24 Mar 2013 17:57:10 +0000 (18:57 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sun, 24 Mar 2013 17:57:10 +0000 (18:57 +0100)
If a too long history items was displayed we put also the cursor to the end of
the value. But this causes that the first, and potentially more interesting
part was hidden. Now we place the cursor to the beginning, if the printed
content in inputbox is too long.

src/command.c
src/config.h

index 326ebf4..0b28043 100644 (file)
@@ -28,6 +28,8 @@
 #include "history.h"
 
 extern VbCore vb;
+extern const unsigned int INPUT_LENGTH;
+
 static CommandInfo cmd_list[] = {
     /* command              function             arg                                                                                 mode */
     {"open",                command_open,        {VB_TARGET_CURRENT, ""}},
@@ -573,5 +575,5 @@ static void command_write_input(const char* str)
 
     /* insert string from arg */
     gtk_editable_insert_text(box, str, -1, &pos);
-    gtk_editable_set_position(box, -1);
+    gtk_editable_set_position(box, strlen(str) > INPUT_LENGTH ? 0 : -1);
 }
index 1467e0b..7341f9b 100644 (file)
 #define SETTING_MAX_CONNS           25
 #define SETTING_MAX_CONNS_PER_HOST  5
 
+/* number of chars in inputbox - if completion or stepping through history
+ * print values longer this value, the cursor will be placed to the beginning
+ * so that the command part will be visible */
+const unsigned int INPUT_LENGTH  = 120;
 const unsigned int MAXIMUM_HINTS = 500;
 
 const struct {