sandy

text editor
git clone git://git.suckless.org/sandy
Log | Files | Refs | README | LICENSE

commit 05882e5c2e043923bb056c3958ba1c4ee6bdcfb0
parent 285d9c79a4aa2e20012fd7c7bccf5b18e1f12f7a
Author: Dimitris Zervas <dzervas@dzervas.gr>
Date:   Sat, 19 Jul 2014 11:23:02 +0300

Fixed multi-command verb

Diffstat:
config.h | 4+++-
sandy.c | 21+++++++++------------
2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/config.h b/config.h @@ -174,7 +174,9 @@ static const Key commkeys[] = { /* Command mode keys here */ { .keyv.c = { 'a' }, { 0, 0, 0, 0 }, f_toggle, { .i = S_Command } }, { .keyv.c = { 'b' }, { t_sent,0, 0, 0 }, f_adjective, { .m = m_prevword } }, { .keyv.c = { 'b' }, { 0, 0, 0, 0 }, f_move, { .m = m_prevword } }, -{ .keyv.c = { 'c' }, { t_sel, t_rw, 0, 0 }, f_delete, { .m = m_tosel } }, +/*{ .keyv.c = { 'c' }, { t_sel, t_rw, 0, 0 }, f_delete, { .m = m_tosel } }, +{ .keyv.c = { 'c' }, { t_sel, t_rw, 0, 0 }, f_toggle, { .i = S_Visual } }, +{ .keyv.c = { 'c' }, { t_sel, t_rw, 0, 0 }, f_toggle, { .i = S_Command } },*/ { .keyv.c = { 'c' }, { t_rw, 0, 0, 0 }, f_delete, { .m = m_sentence } }, /* TODO: queue insert mode, similar to 'y' */ { .keyv.c = { 'c' }, { t_rw, 0, 0, 0 }, f_toggle, { .i = S_Command } }, { .keyv.c = { 'C' }, { t_rw, 0, 0, 0 }, f_delete, { .m = m_eol } }, diff --git a/sandy.c b/sandy.c @@ -799,9 +799,8 @@ i_dokeys(const Key bindings[], int length_bindings) { if(bindings[index].func == verb) { varg.m = m_nextline; i_multiply(verb, varg); - } - - if(bindings[index].func != f_adjective) { + statusflags&=~S_Sentence; + } else if(bindings[index].func != f_adjective) { statusflags&=~S_Sentence; break; } @@ -825,19 +824,17 @@ i_dokeys(const Key bindings[], int length_bindings) { } i_multiply(bindings[index].func, bindings[index].arg); - i=(t_sent() && bindings[index].func == f_adjective)?vi:index; + if(t_sent() && bindings[index].func == f_adjective) i=vi; + else i=index; /* Handle multi-function commands */ - if(i+1<LENGTH(bindings)) { - if(memcmp(bindings[i+1].keyv.c, bindings[i].keyv.c, sizeof bindings[i].keyv.c) == 0) { - j=-1; - - while(1) { - if(bindings[i].test[++j]) - if(bindings[index].test[j] != bindings[i+1].test[j]) break; + if(i+1<length_bindings) { + if((bindings[i+1].keyv.c && memcmp(bindings[i+1].keyv.c, bindings[i].keyv.c, sizeof bindings[i].keyv.c) == 0) || (bindings[i+1].keyv.i && bindings[i+1].keyv.i == bindings[index].keyv.i)) { + for(j=0; j < LENGTH(bindings[i].test); j++) { + if(bindings[i].test[j] != bindings[i+1].test[j]) break; } - if(!bindings[i].test[j]) continue; + if(j == LENGTH(bindings[i].test)) continue; } }