summaryrefslogtreecommitdiff
path: root/misc_gui.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-05-30 16:03:21 +0000
committerDarkvater <darkvater@openttd.org>2005-05-30 16:03:21 +0000
commitd0a0d6fcb5193c2b0a3b744147332ec2b24f213e (patch)
treeb3abbef3ec0c78027bf6b01ef5ca1b7b224c77fe /misc_gui.c
parent0cd53574ec659e283a0029f6cd037ffd66999e60 (diff)
downloadopenttd-d0a0d6fcb5193c2b0a3b744147332ec2b24f213e.tar.xz
(svn r2385) - Feature: shortcut CTRL + U that clears the commandline of the current input-box. As requested by Tron.
Diffstat (limited to 'misc_gui.c')
-rw-r--r--misc_gui.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/misc_gui.c b/misc_gui.c
index 37d7c2509..63fb1b6ef 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -784,6 +784,17 @@ bool DeleteTextBufferChar(Textbuf *tb, int delmode)
}
/**
+ * Delete every character in the textbuffer
+ * @param tb @Textbuf buffer to be emptied
+ */
+void DeleteTextBufferAll(Textbuf *tb)
+{
+ memset(tb->buf, 0, tb->maxlength);
+ tb->length = tb->width = 0;
+ tb->caretpos = tb->caretxoffs = 0;
+}
+
+/**
* Insert a character to a textbuffer. If maxlength is zero, we don't care about
* the screenlength but only about the physical length of the string
* @param tb @Textbuf type to be changed
@@ -875,6 +886,10 @@ int HandleEditBoxKey(Window *w, int wid, WindowEvent *we)
if (InsertTextBufferClipboard(&WP(w, querystr_d).text))
InvalidateWidget(w, wid);
break;
+ case (WKC_CTRL | 'U'):
+ DeleteTextBufferAll(&WP(w, querystr_d).text);
+ InvalidateWidget(w, wid);
+ break;
case WKC_BACKSPACE: case WKC_DELETE:
if (DeleteTextBufferChar(&WP(w, querystr_d).text, we->keypress.keycode))
InvalidateWidget(w, wid);