diff -u -r -w mc-4.7.1-org/src/cmd.c mc-4.7.1-viewertoeditor/src/cmd.c
old
|
new
|
|
117 | 117 | { |
118 | 118 | static const char *viewer = NULL; |
119 | 119 | int move_dir = 0; |
| 120 | int run_editor = 0; |
120 | 121 | |
121 | 122 | |
122 | 123 | if (plain_view) { |
… |
… |
|
136 | 137 | mcview_default_hex_mode = 0; |
137 | 138 | mcview_default_nroff_flag = 0; |
138 | 139 | mcview_default_magic_flag = 0; |
139 | | mcview_viewer (NULL, filename, &move_dir, start_line); |
| 140 | mcview_viewer (NULL, filename, &move_dir, start_line, &run_editor); |
140 | 141 | if (changed_hex_mode && !mcview_altered_hex_mode) |
141 | 142 | mcview_default_hex_mode = 1; |
142 | 143 | if (changed_nroff_flag && !mcview_altered_nroff_flag) |
… |
… |
|
144 | 145 | if (changed_magic_flag && !mcview_altered_magic_flag) |
145 | 146 | mcview_default_magic_flag = 1; |
146 | 147 | repaint_screen (); |
| 148 | if (run_editor) { |
| 149 | do_edit_at_line (filename, start_line, 1); |
| 150 | repaint_screen (); |
| 151 | } |
147 | 152 | return move_dir; |
148 | 153 | } |
149 | 154 | if (internal) { |
… |
… |
|
156 | 161 | strcpy (view_entry, "View"); |
157 | 162 | |
158 | 163 | if (regex_command (filename, view_entry, &move_dir) == 0) { |
159 | | mcview_viewer (NULL, filename, &move_dir, start_line); |
| 164 | mcview_viewer (NULL, filename, &move_dir, start_line, &run_editor); |
160 | 165 | repaint_screen (); |
161 | 166 | } |
162 | 167 | } else { |
… |
… |
|
169 | 174 | } |
170 | 175 | execute_with_vfs_arg (viewer, filename); |
171 | 176 | } |
| 177 | if (run_editor) { |
| 178 | do_edit_at_line (filename, start_line, 1); |
| 179 | repaint_screen (); |
| 180 | } |
172 | 181 | return move_dir; |
173 | 182 | } |
174 | 183 | |
… |
… |
|
289 | 298 | if (!command) |
290 | 299 | return; |
291 | 300 | |
292 | | mcview_viewer (command, "", NULL, 0); |
| 301 | mcview_viewer (command, "", NULL, 0, NULL); |
293 | 302 | |
294 | 303 | g_free (command); |
295 | 304 | } |
296 | 305 | |
297 | 306 | void |
298 | | do_edit_at_line (const char *what, int start_line) |
| 307 | do_edit_at_line (const char *what, int start_line, int no_center) |
299 | 308 | { |
300 | 309 | static const char *editor = NULL; |
301 | 310 | |
302 | 311 | #ifdef USE_INTERNAL_EDIT |
303 | 312 | if (use_internal_edit) |
304 | | edit_file (what, start_line); |
| 313 | edit_file (what, start_line, no_center); |
305 | 314 | else |
306 | 315 | #else |
307 | 316 | (void) start_line; |
… |
… |
|
321 | 330 | static void |
322 | 331 | do_edit (const char *what) |
323 | 332 | { |
324 | | do_edit_at_line (what, 0); |
| 333 | do_edit_at_line (what, 0, 0); |
325 | 334 | } |
326 | 335 | |
327 | 336 | void |
diff -u -r -w mc-4.7.1-org/src/cmddef.h mc-4.7.1-viewertoeditor/src/cmddef.h
old
|
new
|
|
274 | 274 | #define CK_ViewPrevFile 5025 |
275 | 275 | #define CK_ViewToggleRuler 5026 |
276 | 276 | #define CK_ViewToggleHexNavMode 5027 |
| 277 | #define CK_ViewRunEditor 5028 |
277 | 278 | |
278 | 279 | /* Tree */ |
279 | 280 | #define CK_TreeHelp 6001 |
diff -u -r -w mc-4.7.1-org/src/cmd.h mc-4.7.1-viewertoeditor/src/cmd.h
old
|
new
|
|
24 | 24 | void view_file_cmd (void); |
25 | 25 | void view_simple_cmd (void); |
26 | 26 | void filtered_view_cmd (void); |
27 | | void do_edit_at_line (const char *what, int start_line); |
| 27 | void do_edit_at_line (const char *what, int start_line, int no_center); |
28 | 28 | void edit_cmd (void); |
29 | 29 | void edit_cmd_new (void); |
30 | 30 | void copy_cmd (void); |
diff -u -r -w mc-4.7.1-org/src/editor/edit.c mc-4.7.1-viewertoeditor/src/editor/edit.c
old
|
new
|
|
709 | 709 | line = edit->curs_line; |
710 | 710 | } |
711 | 711 | edit_move_to_prev_col (edit, edit_bol (edit, edit->curs1)); |
| 712 | if (!edit->no_center) |
712 | 713 | edit_move_display (edit, line - (edit->num_widget_lines / 2)); |
| 714 | else |
| 715 | edit_move_display (edit, line); |
713 | 716 | } |
714 | 717 | |
715 | 718 | /* Save cursor position in the file */ |
… |
… |
|
760 | 763 | */ |
761 | 764 | WEdit * |
762 | 765 | edit_init (WEdit *edit, int lines, int columns, const char *filename, |
763 | | long line) |
| 766 | long line, int no_center) |
764 | 767 | { |
765 | 768 | int to_free = 0; |
766 | 769 | option_auto_syntax = 1; /* Resetting to auto on every invokation */ |
… |
… |
|
821 | 824 | } |
822 | 825 | edit->utf8 = 0; |
823 | 826 | edit->converter = str_cnv_from_term; |
| 827 | edit->no_center = no_center ? 1 : 0; |
824 | 828 | #ifdef HAVE_CHARSET |
825 | 829 | { |
826 | 830 | const char *cp_id = NULL; |
… |
… |
|
915 | 919 | int columns = edit->num_widget_columns; |
916 | 920 | |
917 | 921 | edit_clean (edit); |
918 | | return (edit_init (edit, lines, columns, "", 0) != NULL); |
| 922 | return (edit_init (edit, lines, columns, "", 0, 0) != NULL); |
919 | 923 | } |
920 | 924 | |
921 | 925 | /* |
… |
… |
|
933 | 937 | |
934 | 938 | e = g_malloc0 (sizeof (WEdit)); |
935 | 939 | e->widget = edit->widget; |
936 | | if (!edit_init (e, lines, columns, filename, 0)) { |
| 940 | if (!edit_init (e, lines, columns, filename, 0, 0)) { |
937 | 941 | g_free (e); |
938 | 942 | return 0; |
939 | 943 | } |
… |
… |
|
958 | 962 | |
959 | 963 | e = g_malloc0 (sizeof (WEdit)); |
960 | 964 | e->widget = edit->widget; |
961 | | if (!edit_init (e, lines, columns, filename, line)) { |
| 965 | if (!edit_init (e, lines, columns, filename, line, 0)) { |
962 | 966 | g_free (e); |
963 | 967 | return 0; |
964 | 968 | } |
diff -u -r -w mc-4.7.1-org/src/editor/edit.h mc-4.7.1-viewertoeditor/src/editor/edit.h
old
|
new
|
|
67 | 67 | void edit_stack_init (void); |
68 | 68 | void edit_stack_free (void); |
69 | 69 | |
70 | | int edit_file (const char *_file, int line); |
| 70 | int edit_file (const char *_file, int line, int no_center); |
71 | 71 | |
72 | 72 | const char *edit_get_file_name (const WEdit *edit); |
73 | 73 | int edit_get_curs_col (const WEdit *edit); |
diff -u -r -w mc-4.7.1-org/src/editor/edit-impl.h mc-4.7.1-viewertoeditor/src/editor/edit-impl.h
old
|
new
|
|
211 | 211 | int edit_save_confirm_cmd (WEdit * edit); |
212 | 212 | int edit_save_as_cmd (WEdit * edit); |
213 | 213 | WEdit *edit_init (WEdit *edit, int lines, int columns, |
214 | | const char *filename, long line); |
| 214 | const char *filename, long line, int no_center); |
215 | 215 | int edit_clean (WEdit * edit); |
216 | 216 | int edit_ok_to_exit (WEdit *edit); |
217 | 217 | int edit_renew (WEdit * edit); |
diff -u -r -w mc-4.7.1-org/src/editor/editwidget.c mc-4.7.1-viewertoeditor/src/editor/editwidget.c
old
|
new
|
|
227 | 227 | } |
228 | 228 | |
229 | 229 | int |
230 | | edit_file (const char *_file, int line) |
| 230 | edit_file (const char *_file, int line, int no_center) |
231 | 231 | { |
232 | 232 | static gboolean made_directory = FALSE; |
233 | 233 | Dlg_head *edit_dlg; |
… |
… |
|
238 | 238 | g_free (dir); |
239 | 239 | } |
240 | 240 | |
241 | | wedit = edit_init (NULL, LINES - 2, COLS, _file, line); |
| 241 | wedit = edit_init (NULL, LINES - 2, COLS, _file, line, no_center); |
242 | 242 | |
243 | 243 | if (wedit == NULL) |
244 | 244 | return 0; |
diff -u -r -w mc-4.7.1-org/src/editor/edit-widget.h mc-4.7.1-viewertoeditor/src/editor/edit-widget.h
old
|
new
|
|
74 | 74 | unsigned int delete_file:1; /* New file, needs to be deleted unless modified */ |
75 | 75 | unsigned int highlight:1; /* There is a selected block */ |
76 | 76 | unsigned int utf8:1; /* It's multibyte file codeset */ |
| 77 | unsigned int no_center:1; /* Do not move edit line to center when create editor window */ |
| 78 | |
77 | 79 | long prev_col; /* recent column position of the cursor - used when moving |
78 | 80 | up or down past lines that are shorter than the current line */ |
79 | 81 | long curs_line; /* line number of the cursor. */ |
… |
… |
|
126 | 128 | int extmod; |
127 | 129 | |
128 | 130 | char *labels[10]; |
129 | | |
130 | 131 | }; |
131 | 132 | |
132 | 133 | #endif /* MC_EDIT_WIDGET_H */ |
diff -u -r -w mc-4.7.1-org/src/ext.c mc-4.7.1-viewertoeditor/src/ext.c
old
|
new
|
|
252 | 252 | * into view |
253 | 253 | */ |
254 | 254 | if (written_nonspace) { |
255 | | mcview_viewer (cmd, filename, move_dir, start_line); |
| 255 | mcview_viewer (cmd, filename, move_dir, start_line, NULL); |
256 | 256 | unlink (file_name); |
257 | 257 | } else { |
258 | | mcview_viewer (NULL, filename, move_dir, start_line); |
| 258 | mcview_viewer (NULL, filename, move_dir, start_line, NULL); |
259 | 259 | } |
260 | 260 | if (changed_hex_mode && !mcview_altered_hex_mode) |
261 | 261 | mcview_default_hex_mode = def_hex_mode; |
diff -u -r -w mc-4.7.1-org/src/find.c mc-4.7.1-viewertoeditor/src/find.c
old
|
new
|
|
1029 | 1029 | |
1030 | 1030 | fullname = make_fullname (dir, filename); |
1031 | 1031 | if (edit) |
1032 | | do_edit_at_line (fullname, line); |
| 1032 | do_edit_at_line (fullname, line, 0); |
1033 | 1033 | else |
1034 | 1034 | view_file_at_line (fullname, unparsed_view, use_internal_view, line); |
1035 | 1035 | g_free (fullname); |
diff -u -r -w mc-4.7.1-org/src/keybind.c mc-4.7.1-viewertoeditor/src/keybind.c
old
|
new
|
|
249 | 249 | { "ViewPrevFile", CK_ViewPrevFile }, |
250 | 250 | { "ViewToggleRuler", CK_ViewToggleRuler }, |
251 | 251 | { "ViewToggleHexNavMode", CK_ViewToggleHexNavMode }, |
| 252 | { "ViewRunEditor", CK_ViewRunEditor }, |
252 | 253 | |
253 | 254 | /* help */ |
254 | 255 | { "HelpHelp", CK_HelpHelp }, |
… |
… |
|
514 | 515 | { ALT ('e'), CK_SelectCodepage, "M-e" }, |
515 | 516 | { XCTRL ('o'), CK_ShowCommandLine, "C-o" }, |
516 | 517 | |
| 518 | { KEY_F (14), CK_ViewRunEditor, "S-F4" }, |
| 519 | |
517 | 520 | { 0, CK_Ignore_Key, "" } |
518 | 521 | }; |
519 | 522 | |
diff -u -r -w mc-4.7.1-org/src/main.c mc-4.7.1-viewertoeditor/src/main.c
old
|
new
|
|
1827 | 1828 | } |
1828 | 1829 | #ifdef USE_INTERNAL_EDIT |
1829 | 1830 | else |
1830 | | edit_file (edit_one_file, edit_one_file_start_line); |
| 1831 | edit_file (edit_one_file, edit_one_file_start_line, 0); |
1831 | 1832 | #endif /* USE_INTERNAL_EDIT */ |
1832 | 1833 | midnight_shutdown = 1; |
1833 | 1834 | done_mc (); |
diff -u -r -w mc-4.7.1-org/src/user.c mc-4.7.1-viewertoeditor/src/user.c
old
|
new
|
|
702 | 702 | chmod (file_name, S_IRWXU); |
703 | 703 | if (run_view) { |
704 | 704 | run_view = 0; |
705 | | mcview_viewer (file_name, NULL, &run_view, 0); |
| 705 | mcview_viewer (file_name, NULL, &run_view, 0, NULL); |
706 | 706 | } else { |
707 | 707 | /* execute the command indirectly to allow execution even |
708 | 708 | * on no-exec filesystems. */ |
diff -u -r -w mc-4.7.1-org/src/viewer/actions_cmd.c mc-4.7.1-viewertoeditor/src/viewer/actions_cmd.c
old
|
new
|
|
439 | 439 | if (!mcview_is_in_panel (view)) |
440 | 440 | view->move_dir = (command == CK_ViewNextFile) ? 1 : -1; |
441 | 441 | /* fallthrough */ |
| 442 | case CK_ViewRunEditor: |
| 443 | view->run_editor = 1; |
442 | 444 | case CK_ViewQuit: |
443 | 445 | if (mcview_ok_to_quit (view)) |
444 | 446 | view->want_to_quit = TRUE; |
diff -u -r -w mc-4.7.1-org/src/viewer/internal.h mc-4.7.1-viewertoeditor/src/viewer/internal.h
old
|
new
|
|
191 | 191 | struct mcview_nroff_struct *search_nroff_seq; |
192 | 192 | |
193 | 193 | int search_numNeedSkipChar; |
| 194 | |
| 195 | int run_editor; |
194 | 196 | } mcview_t; |
195 | 197 | |
196 | 198 | typedef struct mcview_nroff_struct |
diff -u -r -w mc-4.7.1-org/src/viewer/mcviewer.c mc-4.7.1-viewertoeditor/src/viewer/mcviewer.c
old
|
new
|
|
257 | 257 | view->update_steps = 0; |
258 | 258 | view->update_activate = 0; |
259 | 259 | |
| 260 | view->run_editor = 0; |
| 261 | |
260 | 262 | if (mcview_default_hex_mode) |
261 | 263 | mcview_toggle_hex_mode (view); |
262 | 264 | if (mcview_default_nroff_flag) |
… |
… |
|
275 | 277 | |
276 | 278 | /* Real view only */ |
277 | 279 | int |
278 | | mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line) |
| 280 | mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line, int * run_editor) |
279 | 281 | { |
280 | 282 | gboolean succeeded; |
281 | 283 | mcview_t *lc_mcview; |
… |
… |
|
296 | 298 | run_dlg (view_dlg); |
297 | 299 | if (move_dir_p) |
298 | 300 | *move_dir_p = lc_mcview->move_dir; |
| 301 | if (run_editor) |
| 302 | *run_editor = lc_mcview->run_editor; |
299 | 303 | } |
300 | 304 | else |
301 | 305 | { |
diff -u -r -w mc-4.7.1-org/src/viewer/mcviewer.h mc-4.7.1-viewertoeditor/src/viewer/mcviewer.h
old
|
new
|
|
43 | 43 | * point to a variable that will receive the direction in which the user |
44 | 44 | * wants to move (-1 = previous file, 1 = next file, 0 = do nothing). |
45 | 45 | */ |
46 | | extern int mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line); |
| 46 | extern int mcview_viewer (const char *command, const char *file, int *move_dir_p, int start_line, int * run_editor); |
47 | 47 | |
48 | 48 | extern gboolean mcview_load (struct mcview_struct *, const char *, const char *, int); |
49 | 49 | |