mirror of https://github.com/MidnightCommander/mc
Ticket #1384 (Whitespace highlighting should be optional)
Add Denis Vlasenko patch for draw options in dialog Add hotkey M-S-<minus> as swicher for show tabs and tws
This commit is contained in:
parent
d090be917a
commit
348ab7303f
|
@ -132,6 +132,8 @@ typedef enum {
|
|||
} edit_current_file_t;
|
||||
|
||||
extern const char VERTICAL_MAGIC[5];
|
||||
/* if enable_show_tabs_tws ==1 then use visible_tab visible_tws */
|
||||
extern int enable_show_tabs_tws;
|
||||
int edit_drop_hotkey_menu (WEdit *e, int key);
|
||||
void edit_menu_cmd (WEdit *e);
|
||||
struct WMenu *edit_create_menu (void);
|
||||
|
|
|
@ -80,6 +80,7 @@ int option_edit_right_extreme = 0;
|
|||
int option_edit_left_extreme = 0;
|
||||
int option_edit_top_extreme = 0;
|
||||
int option_edit_bottom_extreme = 0;
|
||||
int enable_show_tabs_tws = 1;
|
||||
|
||||
const char *option_whole_chars_search = "0123456789abcdefghijklmnopqrstuvwxyz_";
|
||||
char *option_backup_ext = NULL;
|
||||
|
@ -2871,6 +2872,11 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion)
|
|||
edit->force |= REDRAW_PAGE;
|
||||
break;
|
||||
|
||||
case CK_Toggle_Tab_TWS:
|
||||
enable_show_tabs_tws ^= 1;
|
||||
edit->force |= REDRAW_PAGE;
|
||||
break;
|
||||
|
||||
case CK_Find:
|
||||
edit_search_cmd (edit, 0);
|
||||
break;
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
#define CK_Check_Save_And_Quit 457
|
||||
#define CK_Maximize 458
|
||||
|
||||
#define CK_Toggle_Tab_TWS 470
|
||||
#define CK_Toggle_Syntax 480
|
||||
#define CK_Toggle_Line_State 490
|
||||
|
||||
|
|
|
@ -442,7 +442,8 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
|
|||
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)) && enable_show_tabs_tws)) {
|
||||
if (p->style & MOD_MARKED)
|
||||
c = (p->style);
|
||||
else
|
||||
|
@ -471,7 +472,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
|
|||
p->style = c;
|
||||
p++;
|
||||
}
|
||||
} else if (use_colors && visible_tws && q >= tws) {
|
||||
} else if (use_colors && visible_tws && q >= tws && enable_show_tabs_tws) {
|
||||
p->ch = '.';
|
||||
p->style |= MOD_WHITESPACE;
|
||||
c = p->style & ~MOD_CURSOR;
|
||||
|
@ -493,7 +494,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
|
|||
}
|
||||
break;
|
||||
case ' ':
|
||||
if (use_colors && visible_tws && q >= tws) {
|
||||
if (use_colors && visible_tws && q >= tws && enable_show_tabs_tws) {
|
||||
p->ch = '.';
|
||||
p->style |= MOD_WHITESPACE;
|
||||
p++;
|
||||
|
|
|
@ -118,6 +118,7 @@ static const edit_key_map_type common_key_map[] = {
|
|||
{ ALT ('='), CK_Load_Next_File },
|
||||
{ ALT (KEY_BACKSPACE), CK_Delete_Word_Left },
|
||||
{ ALT ('n'), CK_Toggle_Line_State },
|
||||
{ ALT ('_'), CK_Toggle_Tab_TWS },
|
||||
|
||||
{ XCTRL ('k'), CK_Delete_To_Line_End },
|
||||
{ XCTRL ('l'), CK_Refresh },
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue