commit a77c495e8f799f68e1016c84b651eb5c99f47c21
parent 0bee4b25bcfae98b03fd14c235e418901898259b
Author: Claudio Alessi <smoppy@gmail.com>
Date: Sat, 22 Jul 2017 17:44:48 +0200
s/editor_/cmdln_/g
Diffstat:
M | circo.c | | | 83 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
M | config.def.h | | | 28 | ++++++++++++++-------------- |
2 files changed, 56 insertions(+), 55 deletions(-)
diff --git a/circo.c b/circo.c
@@ -82,6 +82,9 @@ void cleanup(void);
void cmd_msg(char *s);
void cmd_quit(char *s);
void cmd_server(char *s);
+void cmdln_chdel(const Arg *arg);
+void cmdln_clear(const Arg *arg);
+void cmdln_cursor(const Arg *arg);
void detach(Buffer *b);
int dial(char *host, char *port);
void die(const char *errstr, ...);
@@ -90,9 +93,6 @@ void drawbar(void);
void drawbuf(void);
void drawcmdln(void);
void *ecalloc(size_t nmemb, size_t size);
-void editor_chdel(const Arg *arg);
-void editor_clear(const Arg *arg);
-void editor_cursor(const Arg *arg);
Buffer *getbuf(char *name);
void focusnext(const Arg *arg);
void focusprev(const Arg *arg);
@@ -231,6 +231,45 @@ cmd_server(char *s) {
}
void
+cmdln_chdel(const Arg *arg) {
+ if(!sel->cmdoff)
+ return;
+ if(sel->cmdoff < sel->cmdlen)
+ memmove(&sel->cmd[sel->cmdoff - 1], &sel->cmd[sel->cmdoff],
+ sel->cmdlen - sel->cmdoff);
+ sel->cmd[--sel->cmdlen] = '\0';
+ --sel->cmdoff;
+ drawcmdln();
+}
+
+void
+cmdln_clear(const Arg *arg) {
+ if(!sel->cmdoff)
+ return;
+ memmove(sel->cmd, &sel->cmd[sel->cmdoff], sel->cmdlen - sel->cmdoff);
+ sel->cmdlen -= sel->cmdoff;
+ sel->cmd[sel->cmdlen] = '\0';
+ sel->cmdoff = 0;
+ drawcmdln();
+}
+
+void
+cmdln_cursor(const Arg *arg) {
+ if(!arg->i) {
+ sel->cmdoff = 0;
+ }
+ else {
+ sel->cmdoff += arg->i;
+ if(sel->cmdoff < 0)
+ sel->cmdoff = 0;
+ else if(sel->cmdoff > sel->cmdlen)
+ sel->cmdoff = sel->cmdlen;
+ }
+ drawcmdln();
+}
+
+
+void
detach(Buffer *b) {
Buffer **tb;
@@ -343,44 +382,6 @@ ecalloc(size_t nmemb, size_t size) {
}
void
-editor_chdel(const Arg *arg) {
- if(!sel->cmdoff)
- return;
- if(sel->cmdoff < sel->cmdlen)
- memmove(&sel->cmd[sel->cmdoff - 1], &sel->cmd[sel->cmdoff],
- sel->cmdlen - sel->cmdoff);
- sel->cmd[--sel->cmdlen] = '\0';
- --sel->cmdoff;
- drawcmdln();
-}
-
-void
-editor_clear(const Arg *arg) {
- if(!sel->cmdoff)
- return;
- memmove(sel->cmd, &sel->cmd[sel->cmdoff], sel->cmdlen - sel->cmdoff);
- sel->cmdlen -= sel->cmdoff;
- sel->cmd[sel->cmdlen] = '\0';
- sel->cmdoff = 0;
- drawcmdln();
-}
-
-void
-editor_cursor(const Arg *arg) {
- if(!arg->i) {
- sel->cmdoff = 0;
- }
- else {
- sel->cmdoff += arg->i;
- if(sel->cmdoff < 0)
- sel->cmdoff = 0;
- else if(sel->cmdoff > sel->cmdlen)
- sel->cmdoff = sel->cmdlen;
- }
- drawcmdln();
-}
-
-void
focusnext(const Arg *arg) {
sel = sel->next ? sel->next : buffers;
draw();
diff --git a/config.def.h b/config.def.h
@@ -10,18 +10,18 @@ Command commands[] = {
/* key definitions */
static Key keys[] = {
- /* key function argument */
- { CTRL('u'), editor_clear, {0} },
- { KeyBackspace,editor_chdel, {.i = -1} },
- { CTRL('a'), editor_cursor, {.i = 0}},
- { CTRL('e'), editor_cursor, {.i = 999}},
- { CTRL('h'), editor_cursor, {.i = -1}},
- { KeyLeft, editor_cursor, {.i = -1}},
- { CTRL('l'), editor_cursor, {.i = +1}},
- { KeyRight, editor_cursor, {.i = +1}},
- { CTRL('n'), focusnext, {0} },
- { CTRL('p'), focusprev, {0} },
- { KeyPgUp, scroll, {.i = -1} },
- { KeyPgDw, scroll, {.i = +1} },
- { KeyEnd, scroll, {.i = 0} },
+ /* key function argument */
+ { CTRL('u'), cmdln_clear, {0} },
+ { CTRL('h'), cmdln_chdel, {.i = -1} },
+ { CTRL('a'), cmdln_cursor, {.i = 0}},
+ { CTRL('e'), cmdln_cursor, {.i = 999}},
+ { CTRL('l'), cmdln_cursor, {.i = -1}},
+ { KeyLeft, cmdln_cursor, {.i = -1}},
+ { CTRL('l'), cmdln_cursor, {.i = +1}},
+ { KeyRight, cmdln_cursor, {.i = +1}},
+ { CTRL('n'), focusnext, {0} },
+ { CTRL('p'), focusprev, {0} },
+ { KeyPgUp, scroll, {.i = -1} },
+ { KeyPgDw, scroll, {.i = +1} },
+ { KeyEnd, scroll, {.i = 0} },
};