diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2017-01-10 20:57:55 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-01-10 22:18:24 +0100 |
| commit | 68a899b8faf83cc7c0f00def991acb28dc6d7135 (patch) | |
| tree | 136912a0dbe8338c1e7a93af565b0940a5d49e20 | |
| parent | 329d0980c79b14987cee43c70b489a5a6a09c6aa (diff) | |
| download | vis-68a899b8faf83cc7c0f00def991acb28dc6d7135.tar.gz vis-68a899b8faf83cc7c0f00def991acb28dc6d7135.tar.xz | |
vis: add valid marks to :help output
| -rw-r--r-- | vis-cmds.c | 5 | ||||
| -rw-r--r-- | vis-core.h | 6 | ||||
| -rw-r--r-- | vis.c | 13 | ||||
| -rw-r--r-- | vis.h | 4 |
4 files changed, 22 insertions, 6 deletions
@@ -683,6 +683,11 @@ static bool cmd_help(Vis *vis, Win *win, Command *cmd, const char *argv[], Curso text_appendf(txt, "\n :-Commands\n\n"); map_iterate(vis->cmds, print_cmd, txt); + text_appendf(txt, "\n Marks\n\n"); + text_appendf(txt, " a-z General purpose marks\n"); + for (size_t i = 0; i < LENGTH(vis_marks); i++) + text_appendf(txt, " %c %s\n", vis_marks[i].name, vis_marks[i].help); + text_appendf(txt, "\n :set command options\n\n"); for (int i = 0; i < LENGTH(options); i++) { char names[256]; @@ -209,12 +209,18 @@ enum VisEvents { bool vis_event_emit(Vis*, enum VisEvents, ...); +typedef struct { + char name; + const char *help; +} MarkDef; + /** stuff used by multiple of the vis-* files */ extern Mode vis_modes[VIS_MODE_INVALID]; extern const Movement vis_motions[VIS_MOVE_INVALID]; extern const Operator vis_operators[VIS_OP_INVALID]; extern const TextObject vis_textobjects[VIS_TEXTOBJECT_INVALID]; +extern const MarkDef vis_marks[VIS_MARK_a]; void macro_operator_stop(Vis *vis); void macro_operator_record(Vis *vis); @@ -29,6 +29,11 @@ #include "vis-core.h" #include "sam.h" +const MarkDef vis_marks[] = { + [VIS_MARK_SELECTION_START] = { '<', "Last selection start" }, + [VIS_MARK_SELECTION_END] = { '>', "Last selection end" }, +}; + static Macro *macro_get(Vis *vis, enum VisRegister); static void macro_replay(Vis *vis, const Macro *macro); static void vis_keys_push(Vis *vis, const char *input, size_t pos, bool record); @@ -1262,10 +1267,10 @@ void vis_repeat(Vis *vis) { enum VisMark vis_mark_from(Vis *vis, char mark) { if (mark >= 'a' && mark <= 'z') return VIS_MARK_a + mark - 'a'; - else if (mark == '<') - return VIS_MARK_SELECTION_START; - else if (mark == '>') - return VIS_MARK_SELECTION_END; + for (size_t i = 0; i < LENGTH(vis_marks); i++) { + if (vis_marks[i].name == mark) + return i; + } return VIS_MARK_INVALID; } @@ -383,14 +383,14 @@ int vis_textobject_register(Vis*, int type, void *data, enum VisMark { + VIS_MARK_SELECTION_START, /* '< */ + VIS_MARK_SELECTION_END, /* '> */ VIS_MARK_a, VIS_MARK_b, VIS_MARK_c, VIS_MARK_d, VIS_MARK_e, VIS_MARK_f, VIS_MARK_g, VIS_MARK_h, VIS_MARK_i, VIS_MARK_j, VIS_MARK_k, VIS_MARK_l, VIS_MARK_m, VIS_MARK_n, VIS_MARK_o, VIS_MARK_p, VIS_MARK_q, VIS_MARK_r, VIS_MARK_s, VIS_MARK_t, VIS_MARK_u, VIS_MARK_v, VIS_MARK_w, VIS_MARK_x, VIS_MARK_y, VIS_MARK_z, - VIS_MARK_SELECTION_START, /* '< */ - VIS_MARK_SELECTION_END, /* '> */ VIS_MARK_INVALID, /* has to be the last enum member */ }; |
