summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-10 11:16:24 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-11 14:50:02 -0500
commit90b4b08717730733402df25190bba0cc5d2fd952 (patch)
treefe85f6fa7d8128e6195a313f428fb3bf6b446929 /command.c
parent5bffb50207f8d8ba873f4c40dde4859179153001 (diff)
indent/dedent selection
Diffstat (limited to 'command.c')
-rw-r--r--command.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/command.c b/command.c
index 1d628b0..9cc7ad7 100644
--- a/command.c
+++ b/command.c
@@ -98,17 +98,23 @@ void command_execute(Ted *ted, Command c, i64 argument) {
break;
case CMD_TAB:
- if (ted->replace && ted->active_buffer == &ted->find_buffer) {
+ if (ted->replace && buffer == &ted->find_buffer) {
ted->active_buffer = &ted->replace_buffer;
- buffer_select_all(ted->active_buffer);
- } else {
- buffer_insert_char_at_cursor(buffer, '\t');
+ buffer_select_all(buffer);
+ } else if (buffer) {
+ if (buffer->selection)
+ buffer_indent_selection(buffer);
+ else
+ buffer_insert_char_at_cursor(buffer, '\t');
}
break;
case CMD_BACKTAB:
if (ted->replace && ted->active_buffer == &ted->replace_buffer) {
ted->active_buffer = &ted->find_buffer;
buffer_select_all(ted->active_buffer);
+ } else if (buffer) {
+ if (buffer->selection)
+ buffer_dedent_selection(buffer);
}
break;
case CMD_NEWLINE: