circo

claudio's IRC oasis
git clone git://git.bitsmanent.org/circo
Log | Files | Refs | README | LICENSE

commit 26f1a62b5f73ebeee6076dfa2ab2b7d162fc4936
parent ed9085917757edce4f15fe54b2aad1a79322b583
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sun, 23 Jul 2017 16:26:17 +0200

Add ^d to delete command line current character.

Diffstat:
Mcirco.c | 17+++++++++++++++--
Mconfig.def.h | 3++-
2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/circo.c b/circo.c @@ -82,7 +82,8 @@ void cleanup(void); void cmd_msg(char *cmd, char *s); void cmd_quit(char *cmd, char *s); void cmd_server(char *cmd, char *s); -void cmdln_chdel(const Arg *arg); +void cmdln_chldel(const Arg *arg); +void cmdln_chrdel(const Arg *arg); void cmdln_clear(const Arg *arg); void cmdln_cursor(const Arg *arg); void cmdln_wdel(const Arg *arg); @@ -248,7 +249,7 @@ cmd_server(char *cmd, char *s) { } void -cmdln_chdel(const Arg *arg) { +cmdln_chldel(const Arg *arg) { if(!sel->cmdoff) return; if(sel->cmdoff < sel->cmdlen) @@ -260,6 +261,18 @@ cmdln_chdel(const Arg *arg) { } void +cmdln_chrdel(const Arg *arg) { + if(!sel->cmdoff) + return; + if(sel->cmdoff >= sel->cmdlen) + return; + memmove(&sel->cmd[sel->cmdoff], &sel->cmd[sel->cmdoff + 1], + sel->cmdlen - sel->cmdoff - 1); + sel->cmd[--sel->cmdlen] = '\0'; + drawcmdln(); +} + +void cmdln_clear(const Arg *arg) { if(!sel->cmdoff) return; diff --git a/config.def.h b/config.def.h @@ -12,7 +12,8 @@ Command commands[] = { static Key keys[] = { /* key function argument */ { CTRL('u'), cmdln_clear, {0} }, - { KeyBackspace, cmdln_chdel, {.i = -1} }, + { KeyBackspace, cmdln_chldel, {0} }, + { CTRL('d'), cmdln_chrdel, {0} }, { CTRL('w'), cmdln_wdel, {0} }, { CTRL('a'), cmdln_cursor, {.i = 0}}, { CTRL('e'), cmdln_cursor, {.i = 999}},