From 44997a034be16075806a39e65cf0a78766be06ee Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Fri, 29 Jul 2011 11:55:03 +0400 Subject: [PATCH] editor: add option to show EOL Signed-off-by: Ilia Maslakov --- lib/widget/dialog.c | 6 ++++++ lib/widget/dialog.h | 1 + misc/skins/default.ini | 1 + src/editor/edit.h | 1 + src/editor/editdraw.c | 8 +++++++- src/editor/editoptions.c | 30 ++++++++++++++++-------------- src/main.c | 2 +- src/setup.c | 1 + 8 files changed, 34 insertions(+), 16 deletions(-) diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 5952cf74d..4611b6e19 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -832,6 +832,12 @@ dlg_load_skin_decor (void) widget_edit_tab_last = res; g_free (tmp_str); + tmp_str = mc_skin_get ("widget-edit", "eol-char", " "); + res = g_utf8_get_char_validated (tmp_str, -1); + if (res > 0) + widget_edit_eol_char = res; + g_free (tmp_str); + } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/dialog.h b/lib/widget/dialog.h index 3bbadf34a..68404a662 100644 --- a/lib/widget/dialog.h +++ b/lib/widget/dialog.h @@ -163,6 +163,7 @@ extern char *widget_btn_right_default_sign; extern int widget_edit_tab_first; extern int widget_edit_tab_middle; extern int widget_edit_tab_last; +extern int widget_edit_eol_char; extern GList *top_dlg; diff --git a/misc/skins/default.ini b/misc/skins/default.ini index 9bb7b05ae..c1090b81a 100644 --- a/misc/skins/default.ini +++ b/misc/skins/default.ini @@ -137,3 +137,4 @@ tab-first-char=< tab-middle-char=- tab-last-char=> + eol-char = ยท diff --git a/src/editor/edit.h b/src/editor/edit.h index d6b834425..bf539a3ae 100644 --- a/src/editor/edit.h +++ b/src/editor/edit.h @@ -69,6 +69,7 @@ extern int edit_confirm_save; extern int visible_tabs; extern int visible_tws; +extern int visible_eol; extern int simple_statusbar; extern int option_check_nl_at_eof; diff --git a/src/editor/editdraw.c b/src/editor/editdraw.c index 0a47ee8ce..da09e95cc 100644 --- a/src/editor/editdraw.c +++ b/src/editor/editdraw.c @@ -57,7 +57,7 @@ /* Toggles statusbar draw style */ int simple_statusbar = 0; -int visible_tabs = 1, visible_tws = 1; +int visible_tabs = 1, visible_tws = 1, visible_eol = 0; /*** file scope macro definitions ****************************************************************/ @@ -419,6 +419,12 @@ edit_draw_this_line (WEdit * edit, long b, long row, long start_col, long end_co { case '\n': col = (end_col + utf8lag) - edit->start_col + 1; /* quit */ + if (tty_use_colors() && visible_eol) { + p->ch = widget_edit_eol_char; + p->style |= MOD_WHITESPACE; + ++p; + ++col; + } break; case '\t': i = TAB_SIZE - ((int) col % TAB_SIZE); diff --git a/src/editor/editoptions.c b/src/editor/editoptions.c index ece015c0d..689285ffb 100644 --- a/src/editor/editoptions.c +++ b/src/editor/editoptions.c @@ -42,7 +42,7 @@ /*** file scope macro definitions ****************************************************************/ -#define OPT_DLG_H 17 +#define OPT_DLG_H 19 #define OPT_DLG_W 74 /*** file scope type declarations ****************************************************************/ @@ -85,18 +85,18 @@ edit_options_dialog (WEdit * edit) QuickWidget quick_widgets[] = { /* 0 */ QUICK_BUTTON (6, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&Cancel"), B_CANCEL, NULL), /* 1 */ QUICK_BUTTON (2, 10, OPT_DLG_H - 3, OPT_DLG_H, N_("&OK"), B_ENTER, NULL), - /* 2 */ QUICK_LABEL (OPT_DLG_W / 2 + 1, OPT_DLG_W, 12, OPT_DLG_H, + /* 2 */ QUICK_LABEL (OPT_DLG_W / 2 + 1, OPT_DLG_W, 14, OPT_DLG_H, N_("Word wrap line length:")), - /* 3 */ QUICK_INPUT (OPT_DLG_W / 2 + 25, OPT_DLG_W, 12, OPT_DLG_H, + /* 3 */ QUICK_INPUT (OPT_DLG_W / 2 + 25, OPT_DLG_W, 14, OPT_DLG_H, wrap_length, OPT_DLG_W / 2 - 4 - 24, 0, "edit-word-wrap", &p), /* 4 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 11, OPT_DLG_H, - N_("&Group undo"), &option_group_undo), - /* 5 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 10, OPT_DLG_H, N_("Cursor beyond end of line"), &option_cursor_beyond_eol), - /* 6 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 9, OPT_DLG_H, + /* 5 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 10, OPT_DLG_H, N_("Pers&istent selection"), &option_persistent_selections), - /* 7 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 8, OPT_DLG_H, + /* 6 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 9, OPT_DLG_H, N_("Synta&x highlighting"), &option_syntax_highlighting), + /* 7 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 8, OPT_DLG_H, + N_("Visible EOL"), &visible_eol), /* 8 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 7, OPT_DLG_H, N_("Visible tabs"), &visible_tabs), /* 9 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 6, OPT_DLG_H, @@ -107,17 +107,19 @@ edit_options_dialog (WEdit * edit) N_("Confir&m before saving"), &edit_confirm_save), /* 12 */ QUICK_CHECKBOX (OPT_DLG_W / 2 + 1, OPT_DLG_W, 3, OPT_DLG_H, N_("&Return does autoindent"), &option_return_does_auto_indent), - /* 13 */ QUICK_LABEL (3, OPT_DLG_W, 11, OPT_DLG_H, N_("Tab spacing:")), - /* 14 */ QUICK_INPUT (3 + 24, OPT_DLG_W, 11, OPT_DLG_H, + /* 13 */ QUICK_LABEL (3, OPT_DLG_W, 14, OPT_DLG_H, N_("Tab spacing:")), + /* 14 */ QUICK_INPUT (3 + 24, OPT_DLG_W, 14, OPT_DLG_H, tab_spacing, OPT_DLG_W / 2 - 4 - 24, 0, "edit-tab-spacing", &q), - /* 15 */ QUICK_CHECKBOX (3, OPT_DLG_W, 10, OPT_DLG_H, + /* 15 */ QUICK_CHECKBOX (3, OPT_DLG_W, 11, OPT_DLG_H, + N_("&Group undo"), &option_group_undo), + /* 16 */ QUICK_CHECKBOX (3, OPT_DLG_W, 10, OPT_DLG_H, N_("Fill tabs with &spaces"), &option_fill_tabs_with_spaces), - /* 16 */ QUICK_CHECKBOX (3, OPT_DLG_W, 9, OPT_DLG_H, + /* 17 */ QUICK_CHECKBOX (3, OPT_DLG_W, 9, OPT_DLG_H, N_("&Backspace through tabs"), &option_backspace_through_tabs), - /* 17 */ QUICK_CHECKBOX (3, OPT_DLG_W, 8, OPT_DLG_H, + /* 18 */ QUICK_CHECKBOX (3, OPT_DLG_W, 8, OPT_DLG_H, N_("&Fake half tabs"), &option_fake_half_tabs), - /* 18 */ QUICK_RADIO (4, OPT_DLG_W, 4, OPT_DLG_H, 3, wrap_str, &wrap_mode), - /* 19 */ QUICK_LABEL (3, OPT_DLG_W, 3, OPT_DLG_H, N_("Wrap mode")), + /* 19 */ QUICK_RADIO (4, OPT_DLG_W, 4, OPT_DLG_H, 3, wrap_str, &wrap_mode), + /* 20 */ QUICK_LABEL (3, OPT_DLG_W, 3, OPT_DLG_H, N_("Wrap mode")), QUICK_END }; diff --git a/src/main.c b/src/main.c index 4af4b9d68..77b41f920 100644 --- a/src/main.c +++ b/src/main.c @@ -117,7 +117,7 @@ char *widget_btn_right_default_sign = NULL; int widget_edit_tab_first = '<'; int widget_edit_tab_middle = '-'; int widget_edit_tab_last = '>'; - +int widget_edit_eol_char = ' '; /* index to record_macro_buf[], -1 if not recording a macro */ int macro_index = -1; diff --git a/src/setup.c b/src/setup.c index 41f431758..c8cfcab3d 100644 --- a/src/setup.c +++ b/src/setup.c @@ -304,6 +304,7 @@ static const struct { "editor_cursor_beyond_eol", &option_cursor_beyond_eol }, { "editor_visible_tabs", &visible_tabs }, { "editor_visible_spaces", &visible_tws }, + { "editor_visible_eol", &visible_eol }, { "editor_line_state", &option_line_state }, { "editor_simple_statusbar", &simple_statusbar }, { "editor_check_new_line", &option_check_nl_at_eof }, -- 2.11.4.GIT