Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1105 from techee/vim_more_ex_commands
vimode: add some more ex commands
- Loading branch information
Showing
8 changed files
with
224 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
/* | ||
* Copyright 2018 Jiri Techet <techet@gmail.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "cmds/excmds.h" | ||
#include "cmds/edit.h" | ||
#include "utils.h" | ||
|
||
void excmd_save(CmdContext *c, ExCmdParams *p) | ||
{ | ||
c->cb->on_save(p->force); | ||
} | ||
|
||
|
||
void excmd_save_all(CmdContext *c, ExCmdParams *p) | ||
{ | ||
c->cb->on_save_all(p->force); | ||
} | ||
|
||
|
||
void excmd_quit(CmdContext *c, ExCmdParams *p) | ||
{ | ||
c->cb->on_quit(p->force); | ||
} | ||
|
||
|
||
void excmd_save_quit(CmdContext *c, ExCmdParams *p) | ||
{ | ||
if (c->cb->on_save(p->force)) | ||
c->cb->on_quit(p->force); | ||
} | ||
|
||
|
||
void excmd_save_all_quit(CmdContext *c, ExCmdParams *p) | ||
{ | ||
if (c->cb->on_save_all(p->force)) | ||
c->cb->on_quit(p->force); | ||
} | ||
|
||
|
||
void excmd_repeat_subst(CmdContext *c, ExCmdParams *p) | ||
{ | ||
const gchar *flags = p->param1; | ||
if (!flags) | ||
flags = "g"; | ||
perform_substitute(c->sci, c->substitute_text, p->range_from, p->range_to, flags); | ||
} | ||
|
||
|
||
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); | ||
} | ||
|
||
|
||
void excmd_copy(CmdContext *c, ExCmdParams *p) | ||
{ | ||
CmdParams params; | ||
gint dest = SSM(c->sci, SCI_POSITIONFROMLINE, p->dest, 0); | ||
excmd_yank(c, p); | ||
SET_POS(c->sci, dest, TRUE); | ||
cmd_params_init(¶ms, c->sci, 1, FALSE, NULL, FALSE, 0, 0); | ||
cmd_paste_after(c, ¶ms); | ||
} | ||
|
||
|
||
void excmd_move(CmdContext *c, ExCmdParams *p) | ||
{ | ||
CmdParams params; | ||
gint dest; | ||
|
||
if (p->dest >= p->range_from && p->dest <= p->range_to) | ||
return; | ||
|
||
excmd_delete(c, p); | ||
if (p->dest > p->range_to) | ||
p->dest -= p->range_to - p->range_from + 1; | ||
dest = SSM(c->sci, SCI_POSITIONFROMLINE, p->dest, 0); | ||
SET_POS(c->sci, dest, TRUE); | ||
cmd_params_init(¶ms, c->sci, 1, FALSE, NULL, FALSE, 0, 0); | ||
cmd_paste_after(c, ¶ms); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.