add option "Cursor beyond end of line" into "Options\General..." dialog (editor_beyond_eol in ini)

Signed-off-by: Ilia Maslakov <il.smind@google.com>
This commit is contained in:
Ilia Maslakov 2009-08-17 15:52:43 +00:00 committed by Ilia Maslakov
parent f4fc6ad79d
commit b536c3e487
5 changed files with 83 additions and 54 deletions

View File

@ -78,6 +78,7 @@ int option_save_mode = EDIT_QUICK_SAVE;
int option_save_position = 1;
int option_max_undo = 32768;
int option_persistent_selections = 1;
int option_cursor_beyond_eol = 1;
int option_line_state = 0;
int option_line_state_width = 0;
@ -1627,16 +1628,31 @@ edit_move_to_prev_col (WEdit * edit, long p)
edit_cursor_move (edit, edit_move_forward3 (edit, p, prev + edit->over_col, 0) - edit->curs1);
long line_len = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0, edit_eol(edit, edit->curs1));
if (option_cursor_beyond_eol) {
long line_len = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0, edit_eol(edit, edit->curs1));
if (line_len < prev + edit->over_col) {
edit->over_col = prev + over - line_len;
edit->prev_col = line_len;
edit->curs_col = line_len;
if (line_len < prev + edit->over_col) {
edit->over_col = prev + over - line_len;
edit->prev_col = line_len;
edit->curs_col = line_len;
} else {
edit->curs_col = prev + over;
edit->prev_col = edit->curs_col;
edit->over_col = 0;
}
} else {
edit->curs_col = prev + over;
edit->prev_col = edit->curs_col;
edit->over_col = 0;
if (is_in_indent (edit) && option_fake_half_tabs) {
edit_update_curs_col (edit);
if (space_width)
if (edit->curs_col % (HALF_TAB_SIZE * space_width)) {
int q = edit->curs_col;
edit->curs_col -= (edit->curs_col % (HALF_TAB_SIZE * space_width));
p = edit_bol (edit, edit->curs1);
edit_cursor_move (edit, edit_move_forward3 (edit, p, edit->curs_col, 0) - edit->curs1);
if (!left_of_four_spaces (edit))
edit_cursor_move (edit, edit_move_forward3 (edit, p, q, 0) - edit->curs1);
}
}
}
}
@ -2013,7 +2029,7 @@ static void edit_right_char_move_cmd (WEdit * edit)
} else {
c = edit_get_byte (edit, edit->curs1);
}
if (c == '\n') {
if (option_cursor_beyond_eol && c == '\n') {
edit->over_col++;
} else {
edit_cursor_move (edit, cw);
@ -2028,7 +2044,7 @@ static void edit_left_char_move_cmd (WEdit * edit)
if ( cw < 1 )
cw = 1;
}
if (edit->over_col > 0) {
if (option_cursor_beyond_eol && edit->over_col > 0) {
edit->over_col--;
} else {
edit_cursor_move (edit, -cw);
@ -2477,7 +2493,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
if (edit_get_byte (edit, edit->curs1) != '\n')
edit_delete (edit, 0);
}
if ( edit->over_col > 0 )
if ( option_cursor_beyond_eol && edit->over_col > 0 )
edit_insert_over (edit);
#ifdef HAVE_CHARSET
if ( char_for_insertion > 255 && utf8_display == 0 ) {
@ -2568,7 +2584,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
break;
}
}
if ( edit->over_col > 0 ) {
if ( option_cursor_beyond_eol && edit->over_col > 0 ) {
edit->over_col--;
break;
}
@ -2598,7 +2614,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
}
}
if ( edit->over_col > 0 )
if ( option_cursor_beyond_eol && edit->over_col > 0 )
edit_insert_over (edit);
if (option_fake_half_tabs) {
@ -2661,7 +2677,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
case CK_Left_Highlight:
if (option_fake_half_tabs) {
if (is_in_indent (edit) && right_of_four_spaces (edit)) {
if ( edit->over_col > 0)
if ( option_cursor_beyond_eol && edit->over_col > 0)
edit->over_col--;
else
edit_cursor_move (edit, -HALF_TAB_SIZE);
@ -2749,7 +2765,8 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
if ( edit->mark1 != edit->mark2 && !option_persistent_selections ) {
edit_move_block_to_right (edit);
} else {
edit_insert_over (edit);
if ( option_cursor_beyond_eol )
edit_insert_over (edit);
edit_tab_cmd (edit);
if (option_auto_para_formatting) {
format_paragraph (edit, 0);
@ -2868,7 +2885,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
edit_cut_to_X_buf_cmd (edit);
break;
case CK_XPaste:
if ( edit->over_col > 0 )
if ( option_cursor_beyond_eol && edit->over_col > 0 )
edit_insert_over (edit);
edit_paste_from_X_buf_cmd (edit);
break;

View File

@ -51,6 +51,7 @@ extern int option_return_does_auto_indent;
extern int option_backspace_through_tabs;
extern int option_fake_half_tabs;
extern int option_persistent_selections;
extern int option_cursor_beyond_eol;
extern int option_line_state;
extern int option_save_mode;
extern int option_save_position;

View File

@ -70,6 +70,7 @@ edit_options_dialog (void)
int tedit_visible_tabs = visible_tabs;
int tedit_visible_tws = visible_tws;
int tedit_persistent_selections = option_persistent_selections;
int tedit_cursor_beyond_eol = option_cursor_beyond_eol;
int toption_return_does_auto_indent = option_return_does_auto_indent;
int toption_backspace_through_tabs = option_backspace_through_tabs;
int toption_fake_half_tabs = option_fake_half_tabs;
@ -83,58 +84,61 @@ edit_options_dialog (void)
{quick_button, 2, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&OK"), 0,
B_ENTER, 0, 0, NULL, NULL, NULL},
/* 2 */
{quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H,
{quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 5, OPT_DLG_H,
N_("Word wrap line length: "), 0, 0, 0, 0, NULL, NULL, NULL},
/* 3 */
{quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 6,
{quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 5,
OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0, "edit-word-wrap", NULL, NULL},
/* 4 */
{quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H,
{quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 6, OPT_DLG_H,
N_("Tab spacing: "), 0, 0, 0, 0, NULL, NULL, NULL},
/* 5 */
{quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 7,
{quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 6,
OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0,
"edit-tab-spacing", NULL, NULL},
/* 6 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 8,
OPT_DLG_H, N_("Cursor beyond end of line"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 7 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 9,
OPT_DLG_H, N_("Pers&istent selection"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 7 */
/* 8 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 10,
OPT_DLG_H, N_("Synta&x highlighting"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 8 */
/* 9 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11,
OPT_DLG_H, N_("Visible tabs"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 9 */
/* 10 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12,
OPT_DLG_H, N_("Visible trailing spaces"), 8, 0, 0, 0, NULL, NULL, NULL},
/* 10 */
/* 11 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 13,
OPT_DLG_H, N_("Save file &position"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 11 */
/* 12 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 14,
OPT_DLG_H, N_("Confir&m before saving"), 6, 0, 0, 0, NULL, NULL, NULL},
/* 12 */
/* 13 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 15,
OPT_DLG_H, N_("Fill tabs with &spaces"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 13 */
/* 14 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 16,
OPT_DLG_H, N_("&Return does autoindent"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 14 */
/* 15 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 17,
OPT_DLG_H, N_("&Backspace through tabs"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 15 */
/* 16 */
{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 18,
OPT_DLG_H, N_("&Fake half tabs"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 16 */
/* 17 */
{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 11, OPT_DLG_H, "", 3, 0, 0,
const_cast(char **, wrap_str), "wrapm", NULL, NULL},
/* 17 */
/* 18 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H,
N_("Wrap mode"), 0, 0, 0, 0, NULL, NULL, NULL},
/* 18 */
/* 19 */
{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 17, OPT_DLG_H, "", 3, 0, 0,
const_cast(char **, key_emu_str), "keyemu", NULL, NULL},
/* 19 */
/* 20 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 18, OPT_DLG_H,
N_("Key emulation"), 0, 0, 0, 0, NULL, NULL, NULL},
NULL_QuickWidget
@ -158,16 +162,17 @@ edit_options_dialog (void)
quick_widgets[3].str_result = &p;
quick_widgets[5].text = tab_spacing;
quick_widgets[5].str_result = &q;
quick_widgets[6].result = &tedit_persistent_selections;
quick_widgets[7].result = &tedit_syntax_highlighting;
quick_widgets[8].result = &tedit_visible_tabs;
quick_widgets[9].result = &tedit_visible_tws;
quick_widgets[10].result = &toption_save_position;
quick_widgets[11].result = &tedit_confirm_save;
quick_widgets[12].result = &toption_fill_tabs_with_spaces;
quick_widgets[13].result = &toption_return_does_auto_indent;
quick_widgets[14].result = &toption_backspace_through_tabs;
quick_widgets[15].result = &toption_fake_half_tabs;
quick_widgets[6].result = &tedit_cursor_beyond_eol;
quick_widgets[7].result = &tedit_persistent_selections;
quick_widgets[8].result = &tedit_syntax_highlighting;
quick_widgets[9].result = &tedit_visible_tabs;
quick_widgets[10].result = &tedit_visible_tws;
quick_widgets[11].result = &toption_save_position;
quick_widgets[12].result = &tedit_confirm_save;
quick_widgets[13].result = &toption_fill_tabs_with_spaces;
quick_widgets[14].result = &toption_return_does_auto_indent;
quick_widgets[15].result = &toption_backspace_through_tabs;
quick_widgets[16].result = &toption_fake_half_tabs;
if (option_auto_para_formatting)
wrap_mode = 1;
@ -176,11 +181,11 @@ edit_options_dialog (void)
else
wrap_mode = 0;
quick_widgets[16].result = &wrap_mode;
quick_widgets[16].value = wrap_mode;
quick_widgets[17].result = &wrap_mode;
quick_widgets[17].value = wrap_mode;
quick_widgets[18].result = &tedit_key_emulation;
quick_widgets[18].value = tedit_key_emulation;
quick_widgets[19].result = &tedit_key_emulation;
quick_widgets[19].value = tedit_key_emulation;
Quick_options.widgets = quick_widgets;
@ -200,6 +205,7 @@ edit_options_dialog (void)
g_free (q);
}
option_cursor_beyond_eol = tedit_cursor_beyond_eol;
option_persistent_selections = tedit_persistent_selections;
option_syntax_highlighting = tedit_syntax_highlighting;
visible_tabs = tedit_visible_tabs;

View File

@ -91,14 +91,18 @@ edit_event (WEdit * edit, Gpm_Event * event, int *result)
if (event->type & (GPM_DOWN | GPM_UP))
edit_push_key_press (edit);
long line_len = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
edit_eol(edit, edit->curs1));
if ( event->x > line_len ) {
edit->over_col = event->x - line_len;
edit->prev_col = line_len;
if (option_cursor_beyond_eol) {
long line_len = edit_move_forward3 (edit, edit_bol (edit, edit->curs1), 0,
edit_eol(edit, edit->curs1));
if ( event->x > line_len ) {
edit->over_col = event->x - line_len;
edit->prev_col = line_len;
} else {
edit->over_col = 0;
edit->prev_col = event->x;
}
} else {
edit->over_col = 0;
edit->prev_col = event->x;
edit->prev_col = event->x - edit->start_col - 1 - option_line_state_width;
}
if (--event->y > (edit->curs_row + 1))

View File

@ -225,6 +225,7 @@ static const struct {
{ "editor_edit_confirm_save", &edit_confirm_save },
{ "editor_syntax_highlighting", &option_syntax_highlighting },
{ "editor_persistent_selections", &option_persistent_selections },
{ "editor_cursor_beyond_eol", &option_cursor_beyond_eol },
{ "editor_visible_tabs", &visible_tabs },
{ "editor_visible_spaces", &visible_tws },
{ "editor_line_state", &option_line_state },