>From bug 1384 description:

=====================================================
I like a new feature of specially displayed tabs
and trailing spaces, but sometimes they are getting
in the way. For example, when I want to cut-and-paste
with the mouse, I usually do not want it.

Also, inevitably there will be users which actively
dislike this feature. It's better for the project
if it supports those users too.

The most comprehensive solution would be two-fold:

Add a config option for it in F9->Options->General
(takes care of those users who hate whitespace
highlighting and want it off by default), and

Add a menu item to F9->Edit to toggle whitespace
highlighting temporarily with a key combination.
=====================================================

I discovered that this is already conditionalzed in the code,
just not tweakable by config dialog.

6.patch fixes it, and also it makes _trailing_ tabs
to show up as tabs if visible_tabs = 0 but visible_tws = 1.

Please apply.

7.patch is follow-up whitespace and formatting cleanup,
no code changes. Apply it if it looks ok to you.
It does not relate to the fix per se, just catering to my
perfectionist itch.

Signed-off-by: Denys Vlasenko <vda.li...@googlemail.com>
--
vda
diff -d -urpN mc.5/edit/editdraw.c mc.6/edit/editdraw.c
--- mc.5/edit/editdraw.c	2009-06-29 14:06:35.000000000 +0200
+++ mc.6/edit/editdraw.c	2009-07-01 15:21:53.000000000 +0200
@@ -442,7 +442,7 @@ edit_draw_this_line (WEdit *edit, long b
 		case '\t':
 		    i = TAB_SIZE - ((int) col % TAB_SIZE);
 		    col += i;
-		    if (use_colors && visible_tabs) {
+		    if (use_colors && (visible_tabs || (visible_tws && q >= tws))) {
 			if (p->style & MOD_MARKED)
 			    c = (p->style);
 			else
diff -d -urpN mc.5/edit/editoptions.c mc.6/edit/editoptions.c
--- mc.5/edit/editoptions.c	2009-06-29 14:06:35.000000000 +0200
+++ mc.6/edit/editoptions.c	2009-07-01 15:21:53.000000000 +0200
@@ -38,7 +38,7 @@
 #include "../src/dialog.h"	/* B_CANCEL */
 #include "../src/wtools.h"	/* QuickDialog */
 
-#define OPT_DLG_H 19
+#define OPT_DLG_H 21
 #define OPT_DLG_W 72
 
 static const char *key_emu_str[] =
@@ -67,6 +67,8 @@ edit_options_dialog (void)
     int toption_save_position = option_save_position;
     int tedit_confirm_save = edit_confirm_save;
     int tedit_syntax_highlighting = option_syntax_highlighting;
+    int tedit_visible_tabs = visible_tabs;
+    int tedit_visible_tws = visible_tws;
     int tedit_persistent_selections = option_persistent_selections;
     int toption_return_does_auto_indent = option_return_does_auto_indent;
     int toption_backspace_through_tabs = option_backspace_through_tabs;
@@ -81,16 +83,16 @@ 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 - 7, OPT_DLG_H,
+	{quick_label, OPT_DLG_W / 2, OPT_DLG_W, OPT_DLG_H - 6, 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 - 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-word-wrap", NULL, NULL},
 	/* 4 */
-	{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 - 7, 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 - 6,
+	{quick_input, OPT_DLG_W / 2 + 24, OPT_DLG_W, OPT_DLG_H - 7,
 	 OPT_DLG_H, "", OPT_DLG_W / 2 - 4 - 24, 0, 0, 0,
 	 "edit-tab-spacing", NULL, NULL},
 	/* 6 */
@@ -99,36 +101,41 @@ edit_options_dialog (void)
 	/* 7 */
 	{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},
-	/* 7 */
+	/* 8 */
 	{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 11,
-	 OPT_DLG_H, N_("Save file &position"), 0, 0, 0, 0, NULL, NULL, NULL},
+	 OPT_DLG_H, N_("Visible tabs"), 8, 0, 0, 0, NULL, NULL, NULL},
 	/* 9 */
 	{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 12,
-	 OPT_DLG_H, N_("Confir&m before saving"), 6, 0, 0, 0, NULL, NULL, NULL},
+	 OPT_DLG_H, N_("Visible trailing spaces"), 8, 0, 0, 0, NULL, NULL, NULL},
 	/* 10 */
 	{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 13,
-	 OPT_DLG_H, N_("Fill tabs with &spaces"), 0, 0, 0, 0, NULL, NULL, NULL},
+	 OPT_DLG_H, N_("Save file &position"), 0, 0, 0, 0, NULL, NULL, NULL},
 	/* 11 */
 	{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 14,
-	 OPT_DLG_H, N_("&Return does autoindent"), 0, 0, 0, 0, NULL, NULL, NULL},
+	 OPT_DLG_H, N_("Confir&m before saving"), 6, 0, 0, 0, NULL, NULL, NULL},
 	/* 12 */
 	{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 15,
-	 OPT_DLG_H, N_("&Backspace through tabs"), 0, 0, 0, 0, NULL, NULL, NULL},
+	 OPT_DLG_H, N_("Fill tabs with &spaces"), 0, 0, 0, 0, NULL, NULL, NULL},
 	/* 13 */
 	{quick_checkbox, OPT_DLG_W / 2 + 1, OPT_DLG_W, OPT_DLG_H - 16,
-	 OPT_DLG_H, N_("&Fake half tabs"), 0, 0, 0, 0, NULL, NULL, NULL},
+	 OPT_DLG_H, N_("&Return does autoindent"), 0, 0, 0, 0, NULL, NULL, NULL},
 	/* 14 */
-	{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 9, OPT_DLG_H, "", 3, 0, 0,
-	 const_cast(char **, wrap_str), "wrapm", NULL, NULL},
+	{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 */
-	{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 10, OPT_DLG_H,
-	 N_("Wrap mode"), 0, 0,
-	 0, 0, NULL, NULL, NULL},
+	{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 */
-	{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 15, OPT_DLG_H, "", 3, 0, 0,
-	 const_cast(char **, key_emu_str), "keyemu", NULL, NULL},
+	{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 */
-	{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 16, OPT_DLG_H,
+	{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 12, OPT_DLG_H,
+	 N_("Wrap mode"), 0, 0, 0, 0, NULL, NULL, NULL},
+	/* 18 */
+	{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 */
+	{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
     };
@@ -153,12 +160,14 @@ edit_options_dialog (void)
     quick_widgets[5].str_result = &q;
     quick_widgets[6].result = &tedit_persistent_selections;
     quick_widgets[7].result = &tedit_syntax_highlighting;
-    quick_widgets[8].result = &toption_save_position;
-    quick_widgets[9].result = &tedit_confirm_save;
-    quick_widgets[10].result = &toption_fill_tabs_with_spaces;
-    quick_widgets[11].result = &toption_return_does_auto_indent;
-    quick_widgets[12].result = &toption_backspace_through_tabs;
-    quick_widgets[13].result = &toption_fake_half_tabs;
+    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;
 
     if (option_auto_para_formatting)
 	wrap_mode = 1;
@@ -167,11 +176,11 @@ edit_options_dialog (void)
     else
 	wrap_mode = 0;
 
-    quick_widgets[14].result = &wrap_mode;
-    quick_widgets[14].value = wrap_mode;
+    quick_widgets[16].result = &wrap_mode;
+    quick_widgets[16].value = wrap_mode;
 
-    quick_widgets[16].result = &tedit_key_emulation;
-    quick_widgets[16].value = tedit_key_emulation;
+    quick_widgets[18].result = &tedit_key_emulation;
+    quick_widgets[18].value = tedit_key_emulation;
 
     Quick_options.widgets = quick_widgets;
 
@@ -193,6 +202,8 @@ edit_options_dialog (void)
 
     option_persistent_selections = tedit_persistent_selections;
     option_syntax_highlighting = tedit_syntax_highlighting;
+    visible_tabs = tedit_visible_tabs;
+    visible_tws = tedit_visible_tws;
     edit_confirm_save = tedit_confirm_save;
     option_save_position = toption_save_position;
     option_fill_tabs_with_spaces = toption_fill_tabs_with_spaces;
@@ -219,7 +230,7 @@ edit_options_dialog (void)
 
     /* Load or unload syntax rules if the option has changed */
     if (option_syntax_highlighting != old_syntax_hl)
- 	edit_load_syntax (wedit, NULL, option_syntax_type);
+	edit_load_syntax (wedit, NULL, option_syntax_type);
     /* Load usermap if it's needed */
     edit_load_user_map (wedit);
 }
diff -d -urpN mc.6/edit/editdraw.c mc.7/edit/editdraw.c
--- mc.6/edit/editdraw.c	2009-07-01 15:21:53.000000000 +0200
+++ mc.7/edit/editdraw.c	2009-07-01 15:20:54.000000000 +0200
@@ -330,27 +330,25 @@ print_to_widget (WEdit *edit, long row, 
 #endif
 		    set_color (EDITOR_WHITESPACE_COLOR);
 	    }
+	} else if (style & MOD_BOLD) {
+	    set_color (EDITOR_BOLD_COLOR);
+	} else if (style & MOD_MARKED) {
+	    set_color (EDITOR_MARKED_COLOR);
 	} else {
-	    if (style & MOD_BOLD) {
-		set_color (EDITOR_BOLD_COLOR);
-	    } else if (style & MOD_MARKED) {
-		set_color (EDITOR_MARKED_COLOR);
+	    lowlevel_set_color (color);
+	}
+	if ( textchar > 255 ) {
+	    int res = g_unichar_to_utf8 (textchar, (char *)str);
+	    if ( res == 0 ) {
+		str[0] = '.';
+		str[1] = '\0';
 	    } else {
-		lowlevel_set_color (color);
+		str[res] = '\0';
 	    }
+	    addstr ((char *)str);
+	} else {
+	    addch(textchar);
 	}
-	if ( textchar > 255 ) {
-            int res = g_unichar_to_utf8 (textchar, (char *)str);
-            if ( res == 0 ) {
-                str[0] = '.';
-                str[1] = '\0';
-            } else {
-                str[res] = '\0';
-            }
-            addstr ((char *)str);
-        } else {
-            addch(textchar);
-        }
 	p++;
     }
 }
@@ -384,20 +382,20 @@ edit_draw_this_line (WEdit *edit, long b
     c2 = max (edit->column1, edit->column2);
 
     if ( option_line_state ) {
-        cur_line = edit->start_line + row;
-        if ( cur_line <= edit->total_lines ) {
-            g_snprintf (line_stat, LINE_STATE_WIDTH + 1, "%7i ", cur_line + 1);
-        } else {
-            memset(line_stat, ' ', LINE_STATE_WIDTH);
-            line_stat[LINE_STATE_WIDTH] = '\0';
-        }
+	cur_line = edit->start_line + row;
+	if ( cur_line <= edit->total_lines ) {
+	    g_snprintf (line_stat, LINE_STATE_WIDTH + 1, "%7i ", cur_line + 1);
+	} else {
+	    memset(line_stat, ' ', LINE_STATE_WIDTH);
+	    line_stat[LINE_STATE_WIDTH] = '\0';
+	}
     }
 
     if (col + 16 > -edit->start_col) {
 	eval_marks (edit, &m1, &m2);
 
 	if (row <= edit->total_lines - edit->start_line) {
-		long tws = 0;
+	    long tws = 0;
 	    if (use_colors && visible_tws) {
 		tws = edit_eol (edit, b);
 		while (tws > b && ((c = edit_get_byte (edit, tws - 1)) == ' '
_______________________________________________
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel

Reply via email to