Ticket #1832: 1832-F2_MultiComment__Del-Uncomm__C-s_Save__M-y_TSyntax.patch
File 1832-F2_MultiComment__Del-Uncomm__C-s_Save__M-y_TSyntax.patch, 9.4 KB (added by vit_r, 15 years ago) |
---|
-
edit/edit.c
From ba30d9da31e1d69fcb4b13ec47364a330f728dcf Mon Sep 17 00:00:00 2001 From: Vit Rosin <vit_r@list.ru> Date: Tue, 17 Nov 2009 05:04:43 +0000 Subject: [PATCH] F2_MultiComment__Del-Uncomm__C-s_Save__M-y_TSyntax --- edit/edit.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++- edit/edit.h | 7 +++ misc/mc.keymap.default | 5 +- misc/mc.keymap.emacs | 5 +- src/cmddef.h | 13 +++-- src/keybind.c | 6 ++- 6 files changed, 160 insertions(+), 11 deletions(-) diff --git a/edit/edit.c b/edit/edit.c index 9a51b79..6a4c947 100644
a b edit_execute_cmd (WEdit *edit, int command, int char_for_insertion) 2732 2732 break; 2733 2733 } 2734 2734 } 2735 edit_delete (edit, 0);2735 case_CK_Delete (edit); 2736 2736 break; 2737 2737 case CK_Delete_Word_Left: 2738 2738 edit->over_col = 0; … … edit_execute_cmd (WEdit *edit, int command, int char_for_insertion) 3177 3177 case CK_Ext_Mode: 3178 3178 edit->extmod = 1; 3179 3179 break; 3180 case CK_MultiComment: 3181 case_CK_MultiComment (edit); 3182 return; 3180 3183 default: 3181 3184 break; 3182 3185 } … … edit_stack_free (void) 3336 3339 edit_stack_iterator++) 3337 3340 g_free (edit_history_moveto[edit_stack_iterator].filename); 3338 3341 } 3342 3343 void edit_show_bottom (WEdit * edit) 3344 { 3345 edit_cursor_to_bol (edit); 3346 if (edit->curs_line >= (edit->total_lines - 1)) { 3347 edit->force |= REDRAW_PAGE; 3348 return; 3349 } 3350 edit_move_down (edit, 1, 0); 3351 edit_cursor_to_bol (edit); 3352 edit->force |= REDRAW_PAGE; 3353 if (edit->curs_line > (edit->start_line + edit->num_widget_lines - 3)) { 3354 edit_update_screen (edit); 3355 edit_move_display (edit, edit->start_line + 1); 3356 edit->force |= REDRAW_PAGE; 3357 } 3358 } 3359 3360 int it_is_ELF (WEdit * edit) 3361 { 3362 if ('E' == edit_get_byte (edit, 1)) { 3363 if ('L' == edit_get_byte (edit, 2)) { 3364 if ('F' == edit_get_byte (edit, 3)) { 3365 return 1; 3366 } 3367 } 3368 } 3369 return 0; 3370 } 3371 3372 /* for "*.[s,S]" filenames */ 3373 int it_is_ASM (WEdit * edit) 3374 { 3375 int fn_len = (int) strlen ((char *) edit->filename); 3376 if (fn_len > 2 && '.' == edit->filename[fn_len - 2]) { 3377 if ('s' == edit->filename[fn_len - 1] 3378 || 'S' == edit->filename[fn_len - 1]) { 3379 edit_cursor_to_bol (edit); 3380 return 1; 3381 } 3382 } 3383 return 0; 3384 } 3385 3386 /* for "*.[h,H,c,C]" | "*.[c,C]??" filenames */ 3387 int it_is_C (WEdit * edit) 3388 { 3389 int fn_len = (int) strlen ((char *) edit->filename); 3390 3391 if (fn_len < 3) 3392 return 0; 3393 3394 if ('.' == edit->filename[fn_len - 2]) { 3395 if ('h' == edit->filename[fn_len - 1] 3396 || 'H' == edit->filename[fn_len - 1] 3397 || 'c' == edit->filename[fn_len - 1] 3398 || 'C' == edit->filename[fn_len - 1]) { 3399 edit_cursor_to_bol (edit); 3400 return 1; 3401 } 3402 } 3403 3404 if ((fn_len = (fn_len - 2)) < 3) 3405 return 0; 3406 3407 if ('.' == edit->filename[fn_len - 2]) { 3408 if ('h' == edit->filename[fn_len - 1] 3409 || 'H' == edit->filename[fn_len - 1] 3410 || 'c' == edit->filename[fn_len - 1] 3411 || 'C' == edit->filename[fn_len - 1]) { 3412 edit_cursor_to_bol (edit); 3413 return 1; 3414 } 3415 } 3416 return 0; 3417 } 3418 3419 void case_CK_Delete (WEdit * edit) 3420 { 3421 int c1; 3422 3423 if (edit->curs_col) { 3424 edit_delete (edit, 0); 3425 return; 3426 } 3427 c1 = edit_get_byte (edit, edit->curs1); 3428 edit_delete (edit, 0); 3429 3430 if ('/' == c1) { 3431 if (it_is_C (edit)) { 3432 if ('/' == edit_get_byte (edit, edit->curs1)) 3433 edit_delete (edit, 1); 3434 else 3435 return; 3436 } 3437 } else if (!( '#' == c1 || ';' == c1 )) { 3438 return; 3439 } 3440 edit_show_bottom (edit); 3441 } 3442 3443 void case_CK_MultiComment (WEdit * edit) 3444 { 3445 if (edit->curs_line >= edit->total_lines) { 3446 return; 3447 } else if (it_is_ELF (edit)) { 3448 return; 3449 } else if (it_is_ASM (edit)) { /* for "*.[s,S]" filenames */ 3450 if ((edit->total_lines - 1) == edit->curs_line) { 3451 if (';' == edit_get_byte (edit, edit->curs1)) 3452 return; 3453 } 3454 edit_insert (edit, ';'); 3455 } else if (it_is_C (edit)) { /* for "*.[h,H,c,C]" | "*.[c,C]??" filenames */ 3456 if ((edit->total_lines - 1) == edit->curs_line) { 3457 if ('/' == edit_get_byte (edit, edit->curs1)) 3458 return; 3459 } 3460 edit_insert (edit, '/'); 3461 edit_insert (edit, '/'); 3462 } else { 3463 edit_cursor_to_bol (edit); 3464 if ((edit->total_lines - 1) == edit->curs_line) { 3465 if ('#' == edit_get_byte (edit, edit->curs1)) 3466 return; 3467 } 3468 edit_insert (edit, '#'); 3469 } 3470 edit_show_bottom (edit); 3471 } -
edit/edit.h
diff --git a/edit/edit.h b/edit/edit.h index 0891801..01fa4e0 100644
a b const char *edit_get_file_name (const WEdit *edit); 72 72 int edit_get_curs_col (const WEdit *edit); 73 73 const char *edit_get_syntax_type (const WEdit *edit); 74 74 75 int it_is_C (WEdit * edit); 76 int it_is_ELF (WEdit * edit); 77 int it_is_ASM (WEdit * edit); 78 void case_CK_Delete (WEdit * edit); 79 void edit_show_bottom (WEdit * edit); 80 void case_CK_MultiComment (WEdit * edit); 81 75 82 #endif /* MC_EDIT_H */ -
misc/mc.keymap.default
diff --git a/misc/mc.keymap.default b/misc/mc.keymap.default index f571d0d..d7885cd 100644
a b EditDeleteWordLeft = alt-backspace 33 33 EditDeleteWordRight = alt-d 34 34 EditParagraphUp = 35 35 EditParagraphDown = 36 EditSave = f237 36 EditLoad = 38 37 EditNew = ctrl-n 38 EditSave = ctrl-s 39 39 EditSaveas = f12 40 40 EditMark = f3 41 41 EditCopy = f5 … … EditDeleteMacro = 149 149 150 150 EditToggleLineState = alt-n 151 151 EditToggleTabTWS = alt-underline 152 EditToggleSyntax = ctrl-s152 EditToggleSyntax = alt-y 153 153 154 154 EditFindDefinition = alt-enter 155 155 EditLoadPrevFile = alt-minus 156 156 EditLoadNextFile = alt-plus 157 EditMultiComment = f2 157 158 158 159 SelectCodepage = alt-e 159 160 -
misc/mc.keymap.emacs
diff --git a/misc/mc.keymap.emacs b/misc/mc.keymap.emacs index 1acb5cd..6c1ac38 100644
a b EditDeleteWordLeft = alt-backspace 33 33 EditDeleteWordRight = alt-d 34 34 EditParagraphUp = 35 35 EditParagraphDown = 36 EditSave = f237 36 EditLoad = 37 EditSave = ctrl-s 38 38 EditSaveas = f12 39 39 EditMark = f3 40 40 EditCopy = f5 … … EditDeleteMacro = 147 147 148 148 EditToggleLineState = alt-n 149 149 EditToggleTabTWS = alt-underline 150 EditToggleSyntax = ctrl-s150 EditToggleSyntax = alt-y 151 151 152 152 EditFindDefinition = alt-enter 153 153 EditLoadPrevFile = alt-minus 154 154 EditLoadNextFile = alt-plus 155 EditMultiComment = f2 155 156 156 157 SelectCodepage = alt-e 157 158 -
src/cmddef.h
diff --git a/src/cmddef.h b/src/cmddef.h index 2644130..55ef6a9 100644
a b 109 109 #define CK_ExtCmd 424 110 110 #define CK_User_Menu 425 111 111 #define CK_Find_Definition 426 112 #define CK_Edit_Options 427 113 #define CK_Edit_Save_Mode 428 114 #define CK_Choose_Syntax 429 115 #define CK_About 430 112 #define CK_Edit_Options 427 113 #define CK_Edit_Save_Mode 428 114 #define CK_Choose_Syntax 429 115 #define CK_About 430 116 117 /* to comment lines: F2 (while pressing) 118 to uncomment first Home (if needed) 119 then Delete (while pressing) */ 120 #define CK_MultiComment 431 116 121 117 122 #if 0 118 123 /* application control */ -
src/keybind.c
diff --git a/src/keybind.c b/src/keybind.c index c898e8c..7d2df7f 100644
a b static const name_keymap_t command_names[] = { 192 192 { "EditOptions", CK_Edit_Options }, 193 193 { "EditSaveMode", CK_Edit_Save_Mode }, 194 194 { "EditChooseSyntax", CK_Choose_Syntax }, 195 { "EditMultiComment", CK_MultiComment }, 195 196 { "EditAbout", CK_About }, 196 197 197 198 #if 0 … … const global_keymap_t default_editor_keymap[] = { 518 519 { ALT ('i'), CK_Prev_Bookmark, "M-i" }, 519 520 { ALT ('j'), CK_Next_Bookmark, "M-j" }, 520 521 { ALT ('o'), CK_Flush_Bookmarks, "M-o" }, 522 { ALT ('y'), CK_Toggle_Syntax, "M-y" }, 521 523 522 524 { XCTRL ('n'), CK_New, "C-n" }, 523 525 { XCTRL ('k'), CK_Delete_To_Line_End, "C-k" }, 524 526 { XCTRL ('l'), CK_Refresh, "C-l" }, 525 527 { XCTRL ('o'), CK_Shell, "C-o" }, 526 { XCTRL ('s'), CK_ Toggle_Syntax,"C-s" },528 { XCTRL ('s'), CK_Save, "C-s" }, 527 529 { XCTRL ('u'), CK_Undo, "C-u" }, 528 530 { ALT ('e'), CK_SelectCodepage, "M-e" }, 529 531 { XCTRL ('q'), CK_Insert_Literal, "C-q" }, … … const global_keymap_t default_editor_keymap[] = { 533 535 { XCTRL ('a'), CK_Execute_Macro, "C-a" }, 534 536 535 537 { KEY_F (1), CK_Help, "F1" }, 536 { KEY_F (2), CK_ Save,"F2" },538 { KEY_F (2), CK_MultiComment, "F2" }, 537 539 { KEY_F (3), CK_Mark, "F3" }, 538 540 { KEY_F (4), CK_Replace, "F4" }, 539 541 { KEY_F (5), CK_Copy, "F5" },