Ticket #2644: mc.patch
File mc.patch, 8.9 KB (added by gvy, 13 years ago) |
---|
-
src/editor/edit-impl.h
diff --git a/src/editor/edit-impl.h b/src/editor/edit-impl.h index f9d3efe..753d8f5 100644
a b void edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_inserti 313 313 314 314 /*** inline functions ****************************************************************************/ 315 315 316 317 318 enum { 319 WS_CK_FirstCommand = 103666, 320 WS_CK_BlockStart, 321 WS_CK_BlockEnd, 322 WS_CK_BlockToggleVis, 323 WS_CK_GoToBlockStart, 324 WS_CK_GoToBlockEnd, 325 WS_CK_LastCommand 326 }; 327 328 316 329 #endif /* MC__EDIT_IMPL_H */ -
src/editor/edit-widget.h
diff --git a/src/editor/edit-widget.h b/src/editor/edit-widget.h index fa866b4..bd23f5f 100644
a b struct WEdit 133 133 /* line break */ 134 134 LineBreaks lb; 135 135 gboolean extmod; 136 gchar wsextmod; /* wordstar mode cmd type */ 137 gboolean wsmarkshidden; 138 gboolean wsblock; 136 139 137 140 char *labels[10]; 138 141 -
src/editor/edit.c
diff --git a/src/editor/edit.c b/src/editor/edit.c index 0da86a6..81b7893 100644
a b edit_init (WEdit * edit, int y, int x, int lines, int cols, const char *filename 2269 2269 edit->stat1.st_gid = getgid (); 2270 2270 edit->stat1.st_mtime = 0; 2271 2271 2272 edit->extmod = FALSE; 2273 edit->wsextmod = 0; 2274 edit->wsmarkshidden = FALSE; 2275 edit->wsblock = FALSE; 2276 2272 2277 edit->over_col = 0; 2273 2278 edit->bracket = -1; 2274 2279 edit->force |= REDRAW_PAGE; … … edit_push_markers (WEdit * edit) 3299 3304 void 3300 3305 edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2) 3301 3306 { 3307 /* 3308 if (m1 > m2 || (m1 == m2 && c1 > c2)) { 3309 int ti = m1; 3310 long tl = c1; 3311 m1 = m2; m2 = ti; 3312 c1 = c2; c2 = tl; 3313 } 3314 */ 3302 3315 edit->mark1 = m1; 3303 3316 edit->mark2 = m2; 3304 3317 edit->column1 = c1; … … edit_set_markers (WEdit * edit, long m1, long m2, int c1, int c2) 3312 3325 void 3313 3326 edit_mark_cmd (WEdit * edit, int unmark) 3314 3327 { 3328 edit->wsmarkshidden = FALSE; 3329 edit->wsblock = FALSE; 3315 3330 edit_push_markers (edit); 3316 3331 if (unmark) 3317 3332 { … … edit_execute_key_command (WEdit * edit, unsigned long command, int char_for_inse 3523 3538 edit->force |= REDRAW_PAGE; 3524 3539 } 3525 3540 3541 3542 static void edit_goto_line_pos (WEdit *edit, int line, int pos) { 3543 edit->force |= REDRAW_PAGE; /*FIXME: determine what to redraw?*/ 3544 if (line < 0) line = 0; 3545 if (line > edit->total_lines-1) line = edit->total_lines-1; 3546 if (line >= edit->start_line+edit->widget.lines || line < edit->start_line) { 3547 edit_move_display(edit, line-edit->widget.lines/2); 3548 } 3549 edit_move_to_line(edit, line); 3550 edit_cursor_to_bol(edit); 3551 if (pos > 0) { 3552 int len = edit_eol(edit, edit->curs1)-edit->curs1; 3553 if (pos > len) pos = len; 3554 edit_cursor_move(edit, pos); 3555 } 3556 edit->search_start = edit->curs1; 3557 edit->prev_col = edit_get_col(edit); 3558 edit->over_col = 0; 3559 } 3560 3561 3562 static void edit_goto_pos (WEdit *edit, int pos) { 3563 int line, cp, linebol; 3564 // 3565 if (pos > edit->last_byte) pos = edit->last_byte; 3566 for (line = linebol = cp = 0; cp < pos; ++cp) { 3567 if (edit_get_byte(edit, cp) == '\n') { 3568 ++line; 3569 linebol = cp+1; 3570 } 3571 } 3572 edit_goto_line_pos(edit, line, pos-linebol); 3573 } 3574 3575 3526 3576 /* --------------------------------------------------------------------------------------------- */ 3527 3577 /** 3528 3578 This executes a command at a lower level than macro recording. … … edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion) 3671 3721 3672 3722 switch (command) 3673 3723 { 3724 case WS_CK_BlockStart: 3725 edit->force |= REDRAW_PAGE; /*FIXME: determine what to redraw?*/ 3726 if (edit->wsblock && !edit->wsmarkshidden && edit->mark2 >= 0) { 3727 /* we have 'endmark' */ 3728 edit->end_mark_curs = edit->curs1; 3729 edit_set_markers(edit, edit->curs1, edit->mark2, edit->curs_col+edit->over_col, edit->column2); 3730 } else { 3731 /* we have no 'endmark' or block was hidden */ 3732 edit->end_mark_curs = edit->curs1; 3733 edit_set_markers(edit, edit->curs1, edit->curs1, edit->curs_col+edit->over_col, edit->curs_col+edit->over_col); 3734 } 3735 edit->wsmarkshidden = FALSE; 3736 edit->wsblock = TRUE; 3737 edit->column_highlight = 0; 3738 break; 3739 3740 case WS_CK_BlockEnd: 3741 edit->force |= REDRAW_PAGE; /*FIXME: determine what to redraw?*/ 3742 if (edit->wsblock && !edit->wsmarkshidden && edit->mark2 >= 0) { 3743 /* we have 'endmark' */ 3744 edit_set_markers(edit, edit->mark1, edit->curs1, edit->column1, edit->curs_col+edit->over_col); 3745 } else { 3746 /* we have no 'endmark' or block was hidden */ 3747 edit->wsmarkshidden = FALSE; 3748 edit_set_markers(edit, edit->curs1, edit->curs1, edit->curs_col+edit->over_col, edit->curs_col+edit->over_col); 3749 } 3750 edit->wsmarkshidden = FALSE; 3751 edit->wsblock = TRUE; 3752 edit->column_highlight = 0; 3753 break; 3754 3755 case WS_CK_BlockToggleVis: 3756 if (edit->wsblock) { 3757 edit->force |= REDRAW_PAGE; 3758 edit->wsmarkshidden = !edit->wsmarkshidden; 3759 } 3760 break; 3761 3762 case WS_CK_GoToBlockStart: 3763 if (!edit->wsmarkshidden && edit->mark1 >= 0) { 3764 edit_goto_pos(edit, edit->mark1); 3765 } 3766 break; 3767 3768 case WS_CK_GoToBlockEnd: 3769 if (!edit->wsmarkshidden && edit->mark2 >= 0) { 3770 edit_goto_pos(edit, edit->mark2); 3771 } 3772 break; 3773 3674 3774 case CK_TopOnScreen: 3675 3775 case CK_BottomOnScreen: 3676 3776 case CK_MarkToPageBegin: … … edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion) 3961 4061 break; 3962 4062 3963 4063 case CK_Mark: 4064 if (edit->wsblock) { 4065 edit->wsblock = FALSE; 4066 edit->wsmarkshidden = FALSE; 4067 edit->mark1 = edit->mark2 = 1; 4068 edit->column_highlight = 0; 4069 } else 3964 4070 if (edit->mark2 >= 0) 3965 4071 { 3966 4072 if (edit->column_highlight) -
src/editor/editcmd.c
diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index a852ea5..e393350 100644
a b pipe_mail (WEdit * edit, char *to, char *subject, char *cc) 979 979 static gboolean 980 980 is_break_char (char c) 981 981 { 982 return (isspace (c) || strchr ("{}[]()<>=|/\\!?~'\",.;:#$%^&*", c)); 982 /*return (isspace (c) || strchr ("{}[]()<>=|/\\!?~'\",.;:#$%^&*", c));*/ 983 /*k8:*/ 984 return (isspace (c) || strchr ("{}[]()<>=|/\\!?~'\",.;:#$%^&*+-@#", c)); 983 985 } 984 986 985 987 /* --------------------------------------------------------------------------------------------- */ … … edit_load_cmd (WEdit * edit, edit_current_file_t what) 1888 1890 int 1889 1891 eval_marks (WEdit * edit, long *start_mark, long *end_mark) 1890 1892 { 1893 if (edit->wsmarkshidden) { 1894 *start_mark = *end_mark = 0; 1895 edit->column2 = edit->column1 = 0; 1896 return 1; 1897 } 1898 1891 1899 if (edit->mark1 != edit->mark2) 1892 1900 { 1893 1901 long start_bol, start_eol; -
src/editor/editkeys.c
diff --git a/src/editor/editkeys.c b/src/editor/editkeys.c index f4c34a8..2f7ec80 100644
a b 70 70 /*** public functions ****************************************************************************/ 71 71 /* --------------------------------------------------------------------------------------------- */ 72 72 73 typedef struct { 74 long key; 75 long key1; 76 unsigned long cmd; 77 } WSCommandDef; 78 79 80 static const WSCommandDef wsQCommands[] = { 81 { 2, 'B', WS_CK_GoToBlockStart}, 82 { 11, 'K', WS_CK_GoToBlockEnd}, 83 {-1, -1, 0} 84 }; 85 86 87 static const WSCommandDef wsKCommands[] = { 88 { 2, 'B', WS_CK_BlockStart}, 89 { 11, 'K', WS_CK_BlockEnd}, 90 {400, 'H', WS_CK_BlockToggleVis}, /*8*/ 91 { 25, 'Y', CK_Remove}, 92 { 3, 'C', CK_Copy}, 93 { 22, 'V', CK_Move}, 94 { 21, 'U', CK_BlockShiftLeft}, 95 { 9, 'I', CK_BlockShiftRight}, 96 { 23, 'W', CK_Store}, 97 { 18, 'R', CK_Paste}, 98 { 5, 'E', CK_DeleteToEnd}, 99 {-1, -1, 0} 100 }; 101 102 103 static unsigned long wsFindCommand (const WSCommandDef *list, long key) { 104 if (key >= 'a' && key <= 'z') key -= 32; 105 if (key >= 16384 && key <= 16384+26) key -= 16384; 106 for (; list->key > 0; ++list) { 107 if (key == list->key || key == list->key1) return list->cmd; 108 } 109 return 0; 110 } 111 112 113 static unsigned long edit_wordstar (gchar emode, long x_key) { 114 unsigned long cmd = wsFindCommand(emode==11?wsKCommands:wsQCommands, x_key); 115 if (cmd == 0) cmd = (unsigned long)CK_InsertChar; 116 return cmd; 117 } 118 119 73 120 /* 74 121 * Translate the keycode into either 'command' or 'char_for_insertion'. 75 122 * 'command' is one of the editor commands from cmddef.h. … … edit_translate_key (WEdit * edit, long x_key, int *cmd, int *ch) 81 128 int char_for_insertion = -1; 82 129 int c; 83 130 131 if (!edit->extmod && edit->wsextmod) { 132 command = edit_wordstar(edit->wsextmod, x_key); 133 edit->wsextmod = 0; 134 goto fin; 135 } 136 137 if (!edit->extmod && (x_key-16384 == 11 || x_key-16384 == 17)) { 138 edit->wsextmod = x_key-16384; 139 goto fin; 140 } 141 84 142 /* an ordinary insertable character */ 85 if (!edit->extmod && x_key < 256)143 if (!edit->extmod && !edit->wsextmod && x_key < 256) 86 144 { 87 145 #ifdef HAVE_CHARSET 88 146 if (edit->charpoint >= 4)