vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 7c47b3bc6555487f55a65cb03e4385f19b607dde parent 48bc4145b3c24d0c19b4dd8a0a330130604a19f8 Author: Marc André Tanner <mat@brain-dump.org> Date: Sat, 28 Apr 2018 11:34:26 +0200 vis: remove v and V in operator pending mode Diffstat:
| M | config.def.h | | | 7 | ------- |
| M | main.c | | | 19 | ------------------- |
| M | vis-lua.c | | | 2 | +- |
| M | vis-motions.c | | | 3 | +-- |
| M | vis.c | | | 2 | +- |
| M | vis.h | | | 2 | +- |
6 files changed, 4 insertions(+), 31 deletions(-)
diff --git a/config.def.h b/config.def.h @@ -188,12 +188,6 @@ static const KeyBinding bindings_operators[] = { { 0 /* empty last element, array terminator */ }, }; -static const KeyBinding bindings_operator_options[] = { - { "v", ACTION(MOTION_CHARWISE) }, - { "V", ACTION(MOTION_LINEWISE) }, - { 0 /* empty last element, array terminator */ }, -}; - static const KeyBinding bindings_normal[] = { { "a", ACTION(APPEND_CHAR_NEXT) }, { "A", ACTION(APPEND_LINE_END) }, @@ -347,7 +341,6 @@ static const KeyBinding bindings_replace[] = { * one array the first definition is used and further ones are ignored. */ static const KeyBinding **default_bindings[] = { [VIS_MODE_OPERATOR_PENDING] = (const KeyBinding*[]){ - bindings_operator_options, bindings_operators, bindings_textobjects, bindings_motions, diff --git a/main.c b/main.c @@ -97,8 +97,6 @@ static const char *count(Vis*, const char *keys, const Arg *arg); /* move to the count-th line or if not given either to the first (arg->i < 0) * or last (arg->i > 0) line of file */ static const char *gotoline(Vis*, const char *keys, const Arg *arg); -/* set motion type either LINEWISE or CHARWISE via arg->i */ -static const char *motiontype(Vis*, const char *keys, const Arg *arg); /* make the current action use the operator indicated by arg->i */ static const char *operator(Vis*, const char *keys, const Arg *arg); /* blocks to read a key and performs movement indicated by arg->i which @@ -321,8 +319,6 @@ enum { VIS_ACTION_TEXT_OBJECT_INDENTATION, VIS_ACTION_TEXT_OBJECT_SEARCH_FORWARD, VIS_ACTION_TEXT_OBJECT_SEARCH_BACKWARD, - VIS_ACTION_MOTION_CHARWISE, - VIS_ACTION_MOTION_LINEWISE, VIS_ACTION_UNICODE_INFO, VIS_ACTION_UTF8_INFO, VIS_ACTION_NOP, @@ -1199,16 +1195,6 @@ static const KeyAction vis_action[] = { VIS_HELP("The next search match in backward direction") textobj, { .i = VIS_TEXTOBJECT_SEARCH_BACKWARD } }, - [VIS_ACTION_MOTION_CHARWISE] = { - "vis-motion-charwise", - VIS_HELP("Force motion to be charwise") - motiontype, { .i = VIS_MOTIONTYPE_CHARWISE } - }, - [VIS_ACTION_MOTION_LINEWISE] = { - "vis-motion-linewise", - VIS_HELP("Force motion to be linewise") - motiontype, { .i = VIS_MOTIONTYPE_LINEWISE } - }, [VIS_ACTION_UNICODE_INFO] = { "vis-unicode-info", VIS_HELP("Show Unicode codepoint(s) of character under cursor") @@ -1909,11 +1895,6 @@ static const char *gotoline(Vis *vis, const char *keys, const Arg *arg) { return keys; } -static const char *motiontype(Vis *vis, const char *keys, const Arg *arg) { - vis_motion_type(vis, arg->i); - return keys; -} - static const char *operator(Vis *vis, const char *keys, const Arg *arg) { vis_operator(vis, arg->i); return keys; diff --git a/vis-lua.c b/vis-lua.c @@ -1016,7 +1016,7 @@ static size_t motion_lua(Vis *vis, Win *win, void *data, size_t pos) { static int motion_register(lua_State *L) { Vis *vis = obj_ref_check(L, 1, "vis"); const void *func = func_ref_new(L, 2); - int id = vis_motion_register(vis, 0, (void*)func, motion_lua); + int id = vis_motion_register(vis, (void*)func, motion_lua); lua_pushinteger(L, id); return 1; } diff --git a/vis-motions.c b/vis-motions.c @@ -232,14 +232,13 @@ void vis_motion_type(Vis *vis, enum VisMotionType type) { vis->action.type = type; } -int vis_motion_register(Vis *vis, enum VisMotionType type, void *data, VisMotionFunction *motion) { +int vis_motion_register(Vis *vis, void *data, VisMotionFunction *motion) { Movement *move = calloc(1, sizeof *move); if (!move) return -1; move->user = motion; - move->type = type; move->data = data; if (array_add_ptr(&vis->motions, move)) diff --git a/vis.c b/vis.c @@ -822,11 +822,11 @@ void vis_do(Vis *vis) { count = 1; /* count should apply to inserted text not motion */ bool repeatable = a->op && !vis->macro_operator && !vis->win->parent; bool multiple_cursors = view_selections_count(view) > 1; + bool linewise = !(a->type & CHARWISE) && ( a->type & LINEWISE || (a->movement && a->movement->type & LINEWISE) || vis->mode == &vis_modes[VIS_MODE_VISUAL_LINE]); - Register *reg = a->reg; size_t reg_slot = multiple_cursors ? EPOS : 0; size_t last_reg_slot = reg_slot; diff --git a/vis.h b/vis.h @@ -562,7 +562,7 @@ typedef size_t (VisMotionFunction)(Vis*, Win*, void *context, size_t pos); * @return Motion ID. Negative values indicate an error, positive ones can be * used with `vis_motion`. */ -int vis_motion_register(Vis*, enum VisMotionType, void *context, VisMotionFunction*); +int vis_motion_register(Vis*, void *context, VisMotionFunction*); /** * @}