mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
Ticket #319: place cursor after inserted chars
* Added 'editor_cursor_after_inserted_block' config option (default value is: FALSE) * Cursor placed at end of inserted chars when extern file is inserted under cursor Signed-off-by: Slava Zanko <slavazanko@gmail.com> Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
This commit is contained in:
parent
a1dd199723
commit
027cc24f28
@ -559,6 +559,9 @@ Do not remove block selection after moving the cursor.
|
|||||||
.I editor_cursor_beyond_eol
|
.I editor_cursor_beyond_eol
|
||||||
Allow moving cursor beyond the end of line.
|
Allow moving cursor beyond the end of line.
|
||||||
.TP
|
.TP
|
||||||
|
.I editor_cursor_after_inserted_block
|
||||||
|
Allow moving cursor after inserted block.
|
||||||
|
.TP
|
||||||
.I editor_syntax_highlighting
|
.I editor_syntax_highlighting
|
||||||
enable syntax highlighting.
|
enable syntax highlighting.
|
||||||
.TP
|
.TP
|
||||||
|
@ -89,6 +89,7 @@ int option_persistent_selections = 1;
|
|||||||
int option_cursor_beyond_eol = 0;
|
int option_cursor_beyond_eol = 0;
|
||||||
int option_line_state = 0;
|
int option_line_state = 0;
|
||||||
int option_line_state_width = 0;
|
int option_line_state_width = 0;
|
||||||
|
gboolean option_cursor_after_inserted_block = FALSE;
|
||||||
|
|
||||||
int option_edit_right_extreme = 0;
|
int option_edit_right_extreme = 0;
|
||||||
int option_edit_left_extreme = 0;
|
int option_edit_left_extreme = 0;
|
||||||
@ -2069,20 +2070,27 @@ long
|
|||||||
edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
off_t current;
|
||||||
off_t ins_len = 0;
|
off_t ins_len = 0;
|
||||||
|
|
||||||
p = edit_get_filter (filename_vpath);
|
p = edit_get_filter (filename_vpath);
|
||||||
|
current = edit->curs1;
|
||||||
|
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
off_t current = edit->curs1;
|
|
||||||
|
|
||||||
f = (FILE *) popen (p, "r");
|
f = (FILE *) popen (p, "r");
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
{
|
{
|
||||||
edit_insert_stream (edit, f);
|
edit_insert_stream (edit, f);
|
||||||
ins_len = edit->curs1 - current;
|
|
||||||
edit_cursor_move (edit, -ins_len);
|
/* Place cursor at the end of text selection */
|
||||||
|
if (!option_cursor_after_inserted_block)
|
||||||
|
{
|
||||||
|
ins_len = edit->curs1 - current;
|
||||||
|
edit_cursor_move (edit, -ins_len);
|
||||||
|
}
|
||||||
if (pclose (f) > 0)
|
if (pclose (f) > 0)
|
||||||
{
|
{
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
@ -2108,7 +2116,6 @@ edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
|||||||
{
|
{
|
||||||
int file;
|
int file;
|
||||||
off_t blocklen;
|
off_t blocklen;
|
||||||
off_t current = edit->curs1;
|
|
||||||
int vertical_insertion = 0;
|
int vertical_insertion = 0;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
@ -2134,8 +2141,9 @@ edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
|||||||
|
|
||||||
blocklen = edit_insert_column_of_text_from_file (edit, file, &mark1, &mark2, &c1, &c2);
|
blocklen = edit_insert_column_of_text_from_file (edit, file, &mark1, &mark2, &c1, &c2);
|
||||||
edit_set_markers (edit, edit->curs1, mark2, c1, c2);
|
edit_set_markers (edit, edit->curs1, mark2, c1, c2);
|
||||||
|
|
||||||
/* highlight inserted text then not persistent blocks */
|
/* highlight inserted text then not persistent blocks */
|
||||||
if (!option_persistent_selections)
|
if (!option_persistent_selections && edit->modified)
|
||||||
{
|
{
|
||||||
if (!edit->column_highlight)
|
if (!edit->column_highlight)
|
||||||
edit_push_undo_action (edit, COLUMN_OFF);
|
edit_push_undo_action (edit, COLUMN_OFF);
|
||||||
@ -2159,11 +2167,16 @@ edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath)
|
|||||||
edit_push_undo_action (edit, COLUMN_ON);
|
edit_push_undo_action (edit, COLUMN_ON);
|
||||||
edit->column_highlight = 0;
|
edit->column_highlight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Place cursor at the end of text selection */
|
||||||
|
if (!option_cursor_after_inserted_block)
|
||||||
|
{
|
||||||
|
ins_len = edit->curs1 - current;
|
||||||
|
edit_cursor_move (edit, -ins_len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
edit->force |= REDRAW_PAGE;
|
edit->force |= REDRAW_PAGE;
|
||||||
ins_len = edit->curs1 - current;
|
|
||||||
edit_cursor_move (edit, -ins_len);
|
|
||||||
g_free (buf);
|
g_free (buf);
|
||||||
mc_close (file);
|
mc_close (file);
|
||||||
if (blocklen != 0)
|
if (blocklen != 0)
|
||||||
|
@ -40,6 +40,7 @@ extern int option_backspace_through_tabs;
|
|||||||
extern int option_fake_half_tabs;
|
extern int option_fake_half_tabs;
|
||||||
extern int option_persistent_selections;
|
extern int option_persistent_selections;
|
||||||
extern int option_cursor_beyond_eol;
|
extern int option_cursor_beyond_eol;
|
||||||
|
extern gboolean option_cursor_after_inserted_block;
|
||||||
extern int option_line_state;
|
extern int option_line_state;
|
||||||
extern int option_save_mode;
|
extern int option_save_mode;
|
||||||
extern int option_save_position;
|
extern int option_save_position;
|
||||||
|
@ -346,6 +346,7 @@ static const struct
|
|||||||
{ "editor_syntax_highlighting", &option_syntax_highlighting },
|
{ "editor_syntax_highlighting", &option_syntax_highlighting },
|
||||||
{ "editor_persistent_selections", &option_persistent_selections },
|
{ "editor_persistent_selections", &option_persistent_selections },
|
||||||
{ "editor_cursor_beyond_eol", &option_cursor_beyond_eol },
|
{ "editor_cursor_beyond_eol", &option_cursor_beyond_eol },
|
||||||
|
{ "editor_cursor_after_inserted_block", &option_cursor_after_inserted_block },
|
||||||
{ "editor_visible_tabs", &visible_tabs },
|
{ "editor_visible_tabs", &visible_tabs },
|
||||||
{ "editor_visible_spaces", &visible_tws },
|
{ "editor_visible_spaces", &visible_tws },
|
||||||
{ "editor_line_state", &option_line_state },
|
{ "editor_line_state", &option_line_state },
|
||||||
|
Loading…
Reference in New Issue
Block a user