From 7c55e09ac9549d3de60e80471b440260a54c0739 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Sun, 24 Mar 2013 18:57:10 +0100 Subject: [PATCH] Show first part of inputbox if history items it too long. 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 | 4 +++- src/config.h | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/command.c b/src/command.c index 326ebf4..0b28043 100644 --- a/src/command.c +++ b/src/command.c @@ -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); } diff --git a/src/config.h b/src/config.h index 1467e0b..7341f9b 100644 --- a/src/config.h +++ b/src/config.h @@ -28,6 +28,10 @@ #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 { -- 2.20.1