aboutsummaryrefslogtreecommitdiffhomepage
path: root/reader.cpp
diff options
context:
space:
mode:
authorGravatar Christian Rishøj <christian@rishoj.net>2013-05-20 21:42:34 +0200
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-05-24 23:56:12 -0700
commitf32dfe2da60e7da56a15d9ceea1145f4905b777f (patch)
tree1a6dc6465107ac3af80cc754889c732aa4e8fc0f /reader.cpp
parent9f0775c87352d2c1fd79f31bcd97a2e55301a7d0 (diff)
command and binding for transpose-chars
Diffstat (limited to 'reader.cpp')
-rw-r--r--reader.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/reader.cpp b/reader.cpp
index c3e1e5b0..2a26b050 100644
--- a/reader.cpp
+++ b/reader.cpp
@@ -3542,6 +3542,33 @@ const wchar_t *reader_readline(void)
break;
}
+ case R_TRANSPOSE_CHARS:
+ {
+ if (data->command_length() < 2) {
+ break;
+ }
+
+ /* If the cursor is at the end, transpose the last two characters of the line */
+ if (data->buff_pos == data->command_length())
+ {
+ data->buff_pos--;
+ }
+
+ /*
+ Drag the character before the cursor forward over the character at the cursor, moving
+ the cursor forward as well.
+ */
+ if (data->buff_pos > 0)
+ {
+ wchar_t tmp = data->command_line[data->buff_pos];
+ data->command_line[data->buff_pos] = data->command_line[data->buff_pos-1];
+ data->command_line[data->buff_pos-1] = tmp;
+ data->buff_pos++;
+ reader_repaint();
+ }
+ break;
+ }
+
/* Other, if a normal character, we add it to the command */
default:
{