[geany/geany-plugins] 4828bc: vimode: add a few extra excmd commands
Jiří Techet
git-noreply at xxxxx
Wed Sep 29 17:10:42 UTC 2021
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Thu, 02 Sep 2021 15:23:17 UTC
Commit: 4828bc329500a1f59fe669a8fe023a009d7e5a98
https://github.com/geany/geany-plugins/commit/4828bc329500a1f59fe669a8fe023a009d7e5a98
Log Message:
-----------
vimode: add a few extra excmd commands
This patch adds the following commands:
:y[ank]
:pu[t]
:u[ndo]
:red[o]
:<
:>
:d[elete]
:j[oin]
Modified Paths:
--------------
vimode/src/cmd-params.c
vimode/src/cmds/excmds.c
vimode/src/cmds/excmds.h
vimode/src/excmd-runner.c
Modified: vimode/src/cmd-params.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -26,7 +26,7 @@ void cmd_params_init(CmdParams *param, ScintillaObject *sci,
param->num = num;
param->num_present = num_present;
- param->last_kp = g_slist_nth_data(kpl, 0);
+ param->last_kp = kpl != NULL ? g_slist_nth_data(kpl, 0) : NULL;
param->is_operator_cmd = is_operator_cmd;
param->sel_start = sel_start;
Modified: vimode/src/cmds/excmds.c
69 lines changed, 69 insertions(+), 0 deletions(-)
===================================================================
@@ -17,6 +17,7 @@
*/
#include "cmds/excmds.h"
+#include "cmds/edit.h"
#include "utils.h"
void excmd_save(CmdContext *c, ExCmdParams *p)
@@ -64,3 +65,71 @@ void excmd_repeat_subst_orig_flags(CmdContext *c, ExCmdParams *p)
{
perform_substitute(c->sci, c->substitute_text, p->range_from, p->range_to, NULL);
}
+
+
+static void prepare_cmd_params(CmdParams *params, CmdContext *c, ExCmdParams *p)
+{
+ gint start = SSM(c->sci, SCI_POSITIONFROMLINE, p->range_from, 0);
+ SET_POS(c->sci, start, TRUE);
+ cmd_params_init(params, c->sci, p->range_to - p->range_from + 1, FALSE, NULL, FALSE, 0, 0);
+}
+
+
+void excmd_yank(CmdContext *c, ExCmdParams *p)
+{
+ CmdParams params;
+ prepare_cmd_params(¶ms, c, p);
+ cmd_copy_line(c, ¶ms);
+}
+
+
+void excmd_put(CmdContext *c, ExCmdParams *p)
+{
+ CmdParams params;
+ prepare_cmd_params(¶ms, c, p);
+ cmd_paste_after(c, ¶ms);
+}
+
+
+void excmd_undo(CmdContext *c, ExCmdParams *p)
+{
+ SSM(c->sci, SCI_UNDO, 0, 0);
+}
+
+
+void excmd_redo(CmdContext *c, ExCmdParams *p)
+{
+ SSM(c->sci, SCI_REDO, 0, 0);
+}
+
+
+void excmd_shift_left(CmdContext *c, ExCmdParams *p)
+{
+ CmdParams params;
+ prepare_cmd_params(¶ms, c, p);
+ cmd_unindent(c, ¶ms);
+}
+
+
+void excmd_shift_right(CmdContext *c, ExCmdParams *p)
+{
+ CmdParams params;
+ prepare_cmd_params(¶ms, c, p);
+ cmd_indent(c, ¶ms);
+}
+
+
+void excmd_delete(CmdContext *c, ExCmdParams *p)
+{
+ CmdParams params;
+ prepare_cmd_params(¶ms, c, p);
+ cmd_delete_line(c, ¶ms);
+}
+
+void excmd_join(CmdContext *c, ExCmdParams *p)
+{
+ CmdParams params;
+ prepare_cmd_params(¶ms, c, p);
+ cmd_join_lines(c, ¶ms);
+}
+
Modified: vimode/src/cmds/excmds.h
8 lines changed, 8 insertions(+), 0 deletions(-)
===================================================================
@@ -29,5 +29,13 @@ void excmd_save_quit(CmdContext *c, ExCmdParams *p);
void excmd_save_all_quit(CmdContext *c, ExCmdParams *p);
void excmd_repeat_subst(CmdContext *c, ExCmdParams *p);
void excmd_repeat_subst_orig_flags(CmdContext *c, ExCmdParams *p);
+void excmd_yank(CmdContext *c, ExCmdParams *p);
+void excmd_put(CmdContext *c, ExCmdParams *p);
+void excmd_undo(CmdContext *c, ExCmdParams *p);
+void excmd_redo(CmdContext *c, ExCmdParams *p);
+void excmd_shift_left(CmdContext *c, ExCmdParams *p);
+void excmd_shift_right(CmdContext *c, ExCmdParams *p);
+void excmd_delete(CmdContext *c, ExCmdParams *p);
+void excmd_join(CmdContext *c, ExCmdParams *p);
#endif
Modified: vimode/src/excmd-runner.c
22 lines changed, 21 insertions(+), 1 deletions(-)
===================================================================
@@ -18,7 +18,7 @@
#include "excmd-runner.h"
#include "excmd-params.h"
-#include "excmds/excmds.h"
+#include "cmds/excmds.h"
#include "utils.h"
#include <string.h>
@@ -64,8 +64,28 @@ ExCmdDef ex_cmds[] = {
{excmd_repeat_subst, "s"},
{excmd_repeat_subst, "substitute"},
{excmd_repeat_subst, "&"},
+ {excmd_repeat_subst, "~"},
{excmd_repeat_subst_orig_flags, "&&"},
+ {excmd_yank, "yank"},
+ {excmd_yank, "y"},
+ {excmd_put, "put"},
+ {excmd_put, "pu"},
+
+ {excmd_undo, "undo"},
+ {excmd_undo, "u"},
+ {excmd_redo, "redo"},
+ {excmd_redo, "red"},
+
+ {excmd_shift_left, "<"},
+ {excmd_shift_right, ">"},
+
+ {excmd_delete, "delete"},
+ {excmd_delete, "d"},
+
+ {excmd_join, "join"},
+ {excmd_join, "j"},
+
{NULL, NULL}
};
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list