From b65eee089f048e04217009e5dbe70aef3f463230 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 29 May 2015 15:25:21 +0200 Subject: support specialized ^W immediate editing command in file name arguments * the rubout/reinsert-word behaviour of misc. string arguments is suboptimal for file name arguments as it depends on Scintilla's word characters. By default, the directory separators are not considered word characters, but this could be changed by the user. * The behaviour of ^W in file name arguments is now fixed and independant from the Scintilla configuration: It always rubs out or re-inserts one hierarchy level of the file name. --- src/cmdline.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/cmdline.cpp') diff --git a/src/cmdline.cpp b/src/cmdline.cpp index 518c28c..a398b27 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -290,7 +290,29 @@ Cmdline::process_edit_cmd(gchar key) case CTL_KEY('W'): /* rubout/reinsert word/command */ interface.popup_clear(); - if (States::is_string()) { + if (States::is_file()) { + if (modifier_enabled) { + /* reinsert one level of file name */ + while (States::is_file() && rubout_len && + !G_IS_DIR_SEPARATOR(str[len])) + insert(); + + /* reinsert final directory separator */ + if (States::is_file() && rubout_len && + G_IS_DIR_SEPARATOR(str[len])) + insert(); + } else { + /* rubout directory separator */ + if (strings[0] && *strings[0] && + G_IS_DIR_SEPARATOR(str[len-1])) + rubout(); + + /* rubout one level of file name */ + while (strings[0] && *strings[0] && + !G_IS_DIR_SEPARATOR(str[len-1])) + rubout(); + } + } else if (States::is_string()) { gchar wchars[interface.ssm(SCI_GETWORDCHARS)]; interface.ssm(SCI_GETWORDCHARS, 0, (sptr_t)wchars); @@ -306,12 +328,12 @@ Cmdline::process_edit_cmd(gchar key) insert(); } else { /* rubout non-word chars */ - while (strings[0] && strlen(strings[0]) > 0 && + while (strings[0] && *strings[0] && !strchr(wchars, str[len-1])) rubout(); /* rubout word chars */ - while (strings[0] && strlen(strings[0]) > 0 && + while (strings[0] && *strings[0] && strchr(wchars, str[len-1])) rubout(); } @@ -338,7 +360,7 @@ Cmdline::process_edit_cmd(gchar key) insert(); } else { /* rubout string */ - while (strings[0] && strlen(strings[0]) > 0) + while (strings[0] && *strings[0]) rubout(); } } else { -- cgit v1.2.3