Ticket #2421: mc_ho.patch
File mc_ho.patch, 6.3 KB (added by myehorov, 14 years ago) |
---|
-
src/cmddef.h
diff -Naur mc-4.7.0.10/src/cmddef.h mc-4.7.0.10_ho/src/cmddef.h
old new 117 117 #define CK_Edit_Save_Mode 428 118 118 #define CK_Choose_Syntax 429 119 119 #define CK_About 430 120 #define CK_Highlight_Occurences 431 121 #define CK_Unhighlight_Occurences 432 120 122 121 123 #if 0 122 124 /* application control */ -
src/editor/edit.c
diff -Naur mc-4.7.0.10/src/editor/edit.c mc-4.7.0.10_ho/src/editor/edit.c
old new 969 969 970 970 edit_set_keymap (); 971 971 972 edit->hword_symbols_left = 0; 973 memset(edit->highlight_word, 0, HW_LEN * sizeof(char)); 974 edit->highlight_word_length = 0; 975 972 976 return edit; 973 977 } 974 978 … … 3043 3047 3044 3048 switch (command) 3045 3049 { 3050 case CK_Highlight_Occurences: 3051 exec_highlight_occurences(edit); 3052 break; 3053 3054 case CK_Unhighlight_Occurences: 3055 exec_unhighlight_occurences(edit); 3056 break; 3046 3057 case CK_Begin_Page: 3047 3058 case CK_End_Page: 3048 3059 case CK_Begin_Page_Highlight: -
src/editor/edit.h
diff -Naur mc-4.7.0.10/src/editor/edit.h mc-4.7.0.10_ho/src/editor/edit.h
old new 63 63 64 64 extern int simple_statusbar; 65 65 extern int option_check_nl_at_eof; 66 extern int option_highlight_occurences; 66 67 67 68 /* used in main() */ 68 69 void edit_stack_init (void); … … 74 75 int edit_get_curs_col (const WEdit *edit); 75 76 const char *edit_get_syntax_type (const WEdit *edit); 76 77 78 extern int need_highlighing(WEdit* edit, long byte_index); 79 extern void exec_highlight_occurences(WEdit *edit); 80 extern void exec_unhighlight_occurences(WEdit *edit); 81 77 82 #endif /* MC_EDIT_H */ -
src/editor/editmenu.c
diff -Naur mc-4.7.0.10/src/editor/editmenu.c mc-4.7.0.10_ho/src/editor/editmenu.c
old new 116 116 entries = g_list_append (entries, menu_entry_create (_("&Next bookmark"), CK_Next_Bookmark)); 117 117 entries = g_list_append (entries, menu_entry_create (_("&Prev bookmark"), CK_Prev_Bookmark)); 118 118 entries = g_list_append (entries, menu_entry_create (_("&Flush bookmark"), CK_Flush_Bookmarks)); 119 entries = g_list_append (entries, menu_entry_create (_("Highlight occurences"), CK_Highlight_Occurences)); 120 entries = g_list_append (entries, menu_entry_create (_("Unhighlight occurences"), CK_Unhighlight_Occurences)); 119 121 120 122 return entries; 121 123 } -
src/editor/edit-widget.h
diff -Naur mc-4.7.0.10/src/editor/edit-widget.h mc-4.7.0.10_ho/src/editor/edit-widget.h
old new 14 14 15 15 #define MAX_MACRO_LENGTH 1024 16 16 #define N_LINE_CACHES 32 17 /* HW_LEN max length of word to highlight */ 18 #define HW_LEN 512 17 19 18 20 struct _book_mark { 19 21 int line; /* line number */ … … 127 129 128 130 char *labels[10]; 129 131 132 int hword_symbols_left; 133 134 char highlight_word[HW_LEN]; 135 int highlight_word_length; 130 136 }; 131 137 132 138 #endif /* MC_EDIT_WIDGET_H */ -
src/editor/syntax.c
diff -Naur mc-4.7.0.10/src/editor/syntax.c mc-4.7.0.10_ho/src/editor/syntax.c
old new 56 56 57 57 #include "edit-impl.h" 58 58 #include "edit-widget.h" 59 //#include "../src/myslang.h" 59 60 60 61 /* bytes */ 61 62 #define SYNTAX_MARKER_DENSITY 512 … … 75 76 #define SYNTAX_TOKEN_BRACKET '\003' 76 77 #define SYNTAX_TOKEN_BRACE '\004' 77 78 79 /** 80 Section related to highlighting of occurences 81 */ 82 83 #define HIGHLIGHT_DLG_WIDTH 58 84 #define HIGHLIGHT_DLG_HEIGHT 8 85 #define B_REPLACE_ALL (B_USER+1) 86 #define B_REPLACE_ONE (B_USER+2) 87 #define B_SKIP_REPLACE (B_USER+3) 88 89 int option_highlight_occurences = 0; 90 91 int need_highlighing(WEdit* edit, long byte_index) 92 { 93 int ret = 0; 94 int i = 0; 95 char token[edit->highlight_word_length+1]; 96 97 token[edit->highlight_word_length] = 0; 98 for ( ; i < edit->highlight_word_length; i++) 99 token[i] = edit_get_byte(edit, byte_index++); 100 101 ret = !strncmp(token, edit->highlight_word, edit->highlight_word_length); 102 103 if ( ret ) 104 ret = edit->highlight_word_length; 105 106 return ret; 107 } 108 109 void exec_highlight_occurences(WEdit *edit) 110 { 111 char *text = input_expand_dialog (_("Highlight occurences"), _(" Text:"), "", ""); 112 113 if ( text ) 114 { 115 option_highlight_occurences = 1; 116 edit->highlight_word_length = strlen(text); 117 strcpy(edit->highlight_word, text); // TODO: Check for Unicode 118 g_free(text); 119 edit_refresh_cmd(edit); 120 } 121 } 122 123 void exec_unhighlight_occurences(WEdit *edit) 124 { 125 option_highlight_occurences = 0; 126 edit->highlight_word_length = 0; 127 memset(edit->highlight_word, 0, HW_LEN); 128 edit_refresh_cmd(edit); 129 } 130 131 /*---------------------*/ 132 78 133 struct key_word { 79 134 char *keyword; 80 135 unsigned char first; … … 494 549 void 495 550 edit_get_syntax_color (WEdit * edit, long byte_index, int *color) 496 551 { 552 497 553 if (!tty_use_colors ()) 498 *color = 0; 499 else if (edit->rules && byte_index < edit->last_byte && 500 option_syntax_highlighting) 501 translate_rule_to_color (edit, edit_get_rule (edit, byte_index), color); 554 *color = 0; 502 555 else 503 *color = EDITOR_NORMAL_COLOR; 556 { 557 if (edit->rules && byte_index < edit->last_byte && option_syntax_highlighting) 558 translate_rule_to_color (edit, edit_get_rule (edit, byte_index), color); 559 else 560 *color = EDITOR_NORMAL_COLOR; 561 562 if ( option_highlight_occurences ) 563 { 564 if ( edit->hword_symbols_left ) 565 { 566 --edit->hword_symbols_left; 567 *color = SELECTED_COLOR; 568 return; 569 } 570 else if (( edit->hword_symbols_left = need_highlighing(edit, byte_index) )) 571 { 572 --edit->hword_symbols_left; 573 *color = SELECTED_COLOR; 574 return; 575 } 576 } 577 } 504 578 } 505 579 506 580 … … 1253 1327 { 1254 1328 return edit->syntax_type; 1255 1329 } 1330 1331 1332 1333