diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2018-04-26 14:24:55 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2018-05-16 13:24:01 +0200 |
| commit | 62ea7dcff1df815628e8d4a796c401056c7766f7 (patch) | |
| tree | e6527c32155d8ee85324aea039d88bbcccd59b10 /vis-operators.c | |
| parent | f9d0d91f5160a69ce6977395ba19c6d20cb8af4d (diff) | |
| download | vis-62ea7dcff1df815628e8d4a796c401056c7766f7.tar.gz vis-62ea7dcff1df815628e8d4a796c401056c7766f7.tar.xz | |
vis: implement g~ using tr(1)
Diffstat (limited to 'vis-operators.c')
| -rw-r--r-- | vis-operators.c | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/vis-operators.c b/vis-operators.c index 2a0329b..4a0ba42 100644 --- a/vis-operators.c +++ b/vis-operators.c @@ -160,27 +160,6 @@ static size_t op_shift_left(Vis *vis, Text *txt, OperatorContext *c) { return newpos; } -static size_t op_case_change(Vis *vis, Text *txt, OperatorContext *c) { - size_t len = text_range_size(&c->range); - char *buf = malloc(len); - if (!buf) - return c->pos; - len = text_bytes_get(txt, c->range.start, len, buf); - size_t rem = len; - for (char *cur = buf; rem > 0; cur++, rem--) { - int ch = (unsigned char)*cur; - if (isascii(ch)) { - if (c->arg->i == VIS_OP_CASE_SWAP) - *cur = islower(ch) ? toupper(ch) : tolower(ch); - } - } - - text_delete(txt, c->range.start, len); - text_insert(txt, c->range.start, buf, len); - free(buf); - return c->pos; -} - static size_t op_cursor(Vis *vis, Text *txt, OperatorContext *c) { View *view = vis->win->view; Filerange r = text_range_linewise(txt, &c->range); @@ -264,10 +243,6 @@ bool vis_operator(Vis *vis, enum VisOperator id, ...) { case VIS_OP_MODESWITCH: vis->action.mode = va_arg(ap, int); break; - case VIS_OP_CASE_SWAP: - vis->action.arg.i = id; - id = VIS_OP_CASE_SWAP; - break; case VIS_OP_CURSOR_SOL: case VIS_OP_CURSOR_EOL: vis->action.arg.i = id; @@ -353,7 +328,6 @@ const Operator vis_operators[] = { [VIS_OP_PUT_AFTER] = { op_put }, [VIS_OP_SHIFT_RIGHT] = { op_shift_right }, [VIS_OP_SHIFT_LEFT] = { op_shift_left }, - [VIS_OP_CASE_SWAP] = { op_case_change }, [VIS_OP_JOIN] = { op_join }, [VIS_OP_MODESWITCH] = { op_modeswitch }, [VIS_OP_REPLACE] = { op_replace }, |
