1 /* editor menu definitions and initialisation
3 Copyright (C) 1996, 1998, 2001, 2002, 2003, 2005, 2007
4 Free Software Foundation, Inc.
6 Authors: 1996, 1997 Paul Sheer
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 * \brief Source: editor menu definitions and initialisation
34 #include <sys/types.h>
42 #include "../src/global.h"
44 #include "edit-impl.h"
45 #include "edit-widget.h"
46 #include "editcmddef.h"
48 #include "../src/tty/tty.h" /* KEY_F */
49 #include "../src/tty/key.h" /* XCTRL */
51 #include "../src/cmd.h" /* save_setup_cmd() */
52 #include "../src/wtools.h" /* query_dialog() */
53 #include "../src/menu.h" /* menu_entry */
54 #include "../src/main.h" /* drop_menus */
55 #include "../src/learn.h" /* learn_keys */
58 menu_cmd (int command
)
60 edit_execute_key_command (wedit
, command
, -1);
61 edit_update_screen (wedit
);
64 static void menu_key (int i
)
66 send_message ((Widget
*) wedit
, WIDGET_KEY
, i
);
72 query_dialog (_(" About "),
73 _("\n Cooledit v3.11.5\n\n"
74 " Copyright (C) 1996 the Free Software Foundation\n\n"
75 " A user friendly text editor written\n"
76 " for the Midnight Commander.\n"), D_NORMAL
,
105 menu_save_as_cmd (void)
107 menu_cmd (CK_Save_As
);
111 menu_insert_file_cmd (void)
113 menu_cmd (CK_Insert_File
);
129 menu_markcol_cmd (void)
131 menu_cmd (CK_Column_Mark
);
137 menu_cmd (CK_Toggle_Insert
);
153 menu_delete_cmd (void)
155 menu_cmd (CK_Remove
);
159 menu_xstore_cmd (void)
161 menu_cmd (CK_XStore
);
171 menu_xpaste_cmd (void)
173 menu_cmd (CK_XPaste
);
177 menu_toggle_bookmark_cmd (void)
179 menu_cmd (CK_Toggle_Bookmark
);
183 menu_flush_bookmark_cmd (void)
185 menu_cmd (CK_Flush_Bookmarks
);
189 menu_next_bookmark_cmd (void)
191 menu_cmd (CK_Next_Bookmark
);
195 menu_prev_bookmark_cmd (void)
197 menu_cmd (CK_Prev_Bookmark
);
203 menu_cmd (CK_Save_Block
);
207 menu_search_cmd (void)
213 menu_search_again_cmd (void)
215 menu_cmd (CK_Find_Again
);
219 menu_replace_cmd (void)
221 menu_cmd (CK_Replace
);
225 menu_select_codepage_cmd (void)
227 menu_cmd (CK_Select_Codepage
);
231 menu_begin_record_cmd (void)
233 menu_cmd (CK_Begin_Record_Macro
);
237 menu_end_record_cmd (void)
239 menu_cmd (CK_End_Record_Macro
);
243 menu_exec_macro_cmd (void)
245 menu_key (XCTRL ('a'));
249 menu_exec_macro_delete_cmd (void)
251 menu_cmd (CK_Delete_Macro
);
255 menu_c_form_cmd (void)
257 menu_key (KEY_F (19));
261 menu_ispell_cmd (void)
263 menu_cmd (CK_Pipe_Block (1));
275 menu_cmd (CK_ExtCmd
);
291 menu_beginning_cmd (void)
293 menu_cmd (CK_Beginning_Of_Text
);
299 menu_cmd (CK_End_Of_Text
);
303 menu_refresh_cmd (void)
305 menu_cmd (CK_Refresh
);
309 menu_goto_line (void)
315 menu_toggle_line_state (void)
317 menu_cmd (CK_Toggle_Line_State
);
321 menu_goto_bracket (void)
323 menu_cmd (CK_Match_Bracket
);
329 menu_key (XCTRL ('q'));
333 menu_format_paragraph (void)
335 menu_cmd (CK_Paragraph_Format
);
339 menu_edit_syntax_file_cmd (void)
341 menu_cmd (CK_Load_Syntax_File
);
345 menu_edit_menu_file_cmd (void)
347 menu_cmd (CK_Load_Menu_File
);
351 menu_user_menu_cmd (void)
353 menu_key (KEY_F (11));
357 menu_find_declare (void)
359 menu_cmd (CK_Find_Definition
);
363 menu_declare_back (void)
365 menu_cmd (CK_Load_Prev_File
);
369 menu_declare_forward (void)
371 menu_cmd (CK_Load_Next_File
);
374 static menu_entry FileMenu
[] =
376 {' ', N_("&Open file..."), NULL_HOTKEY
, menu_load_cmd
},
377 {' ', N_("&New C-n"), NULL_HOTKEY
, menu_new_cmd
},
378 {' ', "", NULL_HOTKEY
, 0},
379 {' ', N_("&Save F2"), NULL_HOTKEY
, menu_save_cmd
},
380 {' ', N_("Save &as... F12"), NULL_HOTKEY
, menu_save_as_cmd
},
381 {' ', "", NULL_HOTKEY
, 0},
382 {' ', N_("&Insert file... F15"), NULL_HOTKEY
, menu_insert_file_cmd
},
383 {' ', N_("Copy to &file... C-f"), NULL_HOTKEY
, menu_cut_cmd
},
384 {' ', "", NULL_HOTKEY
, 0},
385 {' ', N_("&User menu... F11"), NULL_HOTKEY
, menu_user_menu_cmd
},
386 {' ', "", NULL_HOTKEY
, 0},
387 {' ', N_("A&bout... "), NULL_HOTKEY
, edit_about_cmd
},
388 {' ', "", NULL_HOTKEY
, 0},
389 {' ', N_("&Quit F10"), NULL_HOTKEY
, menu_quit_cmd
}
392 static menu_entry FileMenuEmacs
[] =
394 {' ', N_("&Open file..."), NULL_HOTKEY
, menu_load_cmd
},
395 {' ', N_("&New C-x k"), NULL_HOTKEY
, menu_new_cmd
},
396 {' ', "", NULL_HOTKEY
, 0},
397 {' ', N_("&Save F2"), NULL_HOTKEY
, menu_save_cmd
},
398 {' ', N_("Save &as... F12"), NULL_HOTKEY
, menu_save_as_cmd
},
399 {' ', "", NULL_HOTKEY
, 0},
400 {' ', N_("&Insert file... F15"), NULL_HOTKEY
, menu_insert_file_cmd
},
401 {' ', N_("Copy to &file... "), NULL_HOTKEY
, menu_cut_cmd
},
402 {' ', "", NULL_HOTKEY
, 0},
403 {' ', N_("&User menu... F11"), NULL_HOTKEY
, menu_user_menu_cmd
},
404 {' ', "", NULL_HOTKEY
, 0},
405 {' ', N_("A&bout... "), NULL_HOTKEY
, edit_about_cmd
},
406 {' ', "", NULL_HOTKEY
, 0},
407 {' ', N_("&Quit F10"), NULL_HOTKEY
, menu_quit_cmd
}
410 static menu_entry EditMenu
[] =
412 {' ', N_("&Toggle mark F3"), NULL_HOTKEY
, menu_mark_cmd
},
413 {' ', N_("Mar&k columns S-F3"), NULL_HOTKEY
, menu_markcol_cmd
},
414 {' ', "", NULL_HOTKEY
, 0},
415 {' ', N_("Toggle &ins/overw Ins"), NULL_HOTKEY
, menu_ins_cmd
},
416 {' ', "", NULL_HOTKEY
, 0},
417 {' ', N_("&Copy F5"), NULL_HOTKEY
, menu_copy_cmd
},
418 {' ', N_("&Move F6"), NULL_HOTKEY
, menu_move_cmd
},
419 {' ', N_("&Delete F8"), NULL_HOTKEY
, menu_delete_cmd
},
420 {' ', "", NULL_HOTKEY
, 0},
421 {' ', N_("C&opy to clipfile C-Ins"), NULL_HOTKEY
, menu_xstore_cmd
},
422 {' ', N_("C&ut to clipfile S-Del"), NULL_HOTKEY
, menu_xcut_cmd
},
423 {' ', N_("&Paste from clipfile S-Ins"), NULL_HOTKEY
, menu_xpaste_cmd
},
424 {' ', "", NULL_HOTKEY
, 0},
425 {' ', N_("Toggle bookmar&k M-k"), NULL_HOTKEY
, menu_toggle_bookmark_cmd
},
426 {' ', N_("&Next bookmark M-j"), NULL_HOTKEY
, menu_next_bookmark_cmd
},
427 {' ', N_("Pre&v bookmark M-i"), NULL_HOTKEY
, menu_prev_bookmark_cmd
},
428 {' ', N_("&Flush bookmark M-o"), NULL_HOTKEY
, menu_flush_bookmark_cmd
},
429 {' ', "", NULL_HOTKEY
, 0},
430 {' ', N_("&Undo C-u"), NULL_HOTKEY
, menu_undo_cmd
},
431 {' ', "", NULL_HOTKEY
, 0},
432 {' ', N_("&Beginning C-PgUp"), NULL_HOTKEY
, menu_beginning_cmd
},
433 {' ', N_("&End C-PgDn"), NULL_HOTKEY
, menu_end_cmd
}
436 static menu_entry EditMenuEmacs
[] =
438 {' ', N_("&Toggle mark F3"), NULL_HOTKEY
, menu_mark_cmd
},
439 {' ', N_("Mar&k columns S-F3"), NULL_HOTKEY
, menu_markcol_cmd
},
440 {' ', "", NULL_HOTKEY
, 0},
441 {' ', N_("Toggle &ins/overw Ins"), NULL_HOTKEY
, menu_ins_cmd
},
442 {' ', "", NULL_HOTKEY
, 0},
443 {' ', N_("&Copy F5"), NULL_HOTKEY
, menu_copy_cmd
},
444 {' ', N_("&Move F6"), NULL_HOTKEY
, menu_move_cmd
},
445 {' ', N_("&Delete F8"), NULL_HOTKEY
, menu_delete_cmd
},
446 {' ', "", NULL_HOTKEY
, 0},
447 {' ', N_("C&opy to clipfile M-w"), NULL_HOTKEY
, menu_xstore_cmd
},
448 {' ', N_("C&ut to clipfile C-w"), NULL_HOTKEY
, menu_xcut_cmd
},
449 {' ', N_("&Paste from clipfile C-y"), NULL_HOTKEY
, menu_xpaste_cmd
},
450 {' ', "", NULL_HOTKEY
, 0},
451 {' ', N_("Toggle bookmar&k "), NULL_HOTKEY
, menu_toggle_bookmark_cmd
},
452 {' ', N_("&Next bookmark "), NULL_HOTKEY
, menu_next_bookmark_cmd
},
453 {' ', N_("Pre&v bookmark "), NULL_HOTKEY
, menu_prev_bookmark_cmd
},
454 {' ', N_("&Flush bookmark "), NULL_HOTKEY
, menu_flush_bookmark_cmd
},
455 {' ', "", NULL_HOTKEY
, 0},
456 {' ', N_("&Undo C-u"), NULL_HOTKEY
, menu_undo_cmd
},
457 {' ', "", NULL_HOTKEY
, 0},
458 {' ', N_("&Beginning C-PgUp"), NULL_HOTKEY
, menu_beginning_cmd
},
459 {' ', N_("&End C-PgDn"), NULL_HOTKEY
, menu_end_cmd
}
462 static menu_entry SearReplMenu
[] =
464 {' ', N_("&Search... F7"), NULL_HOTKEY
, menu_search_cmd
},
465 {' ', N_("Search &again F17"), NULL_HOTKEY
, menu_search_again_cmd
},
466 {' ', N_("&Replace... F4"), NULL_HOTKEY
, menu_replace_cmd
}
469 #define SearReplMenuEmacs SearReplMenu
471 static menu_entry CmdMenu
[] =
473 {' ', N_("&Go to line... M-l"), NULL_HOTKEY
, menu_goto_line
},
474 {' ', N_("Toggle li&ne state M-n"), NULL_HOTKEY
, menu_toggle_line_state
},
475 {' ', N_("Go to matching &bracket M-b"), NULL_HOTKEY
, menu_goto_bracket
},
476 {' ', "", NULL_HOTKEY
, 0},
477 {' ', N_("Find declaration A-Enter"), NULL_HOTKEY
, menu_find_declare
},
478 {' ', N_("Back from declaration M--"), NULL_HOTKEY
, menu_declare_back
},
479 {' ', N_("Forward to declaration M-+"), NULL_HOTKEY
, menu_declare_forward
},
481 {' ', "", NULL_HOTKEY
, 0},
482 {' ', N_("Encod&ing... C-t"), NULL_HOTKEY
, menu_select_codepage_cmd
},
484 {' ', "", NULL_HOTKEY
, 0},
485 {' ', N_("Insert &literal... C-q"), NULL_HOTKEY
, menu_lit_cmd
},
486 {' ', "", NULL_HOTKEY
, 0},
487 {' ', N_("&Refresh screen C-l"), NULL_HOTKEY
, menu_refresh_cmd
},
488 {' ', "", NULL_HOTKEY
, 0},
489 {' ', N_("&Start record macro C-r"), NULL_HOTKEY
, menu_begin_record_cmd
},
490 {' ', N_("&Finish record macro... C-r"), NULL_HOTKEY
, menu_end_record_cmd
},
491 {' ', N_("&Execute macro... C-a, KEY"), NULL_HOTKEY
, menu_exec_macro_cmd
},
492 {' ', N_("Delete macr&o... "), NULL_HOTKEY
, menu_exec_macro_delete_cmd
},
493 {' ', "", NULL_HOTKEY
, 0},
494 {' ', N_("Insert &date/time "), NULL_HOTKEY
, menu_date_cmd
},
495 {' ', "", NULL_HOTKEY
, 0},
496 {' ', N_("Format p&aragraph M-p"), NULL_HOTKEY
, menu_format_paragraph
},
497 {' ', N_("'ispell' s&pell check C-p"), NULL_HOTKEY
, menu_ispell_cmd
},
498 {' ', N_("Sor&t... M-t"), NULL_HOTKEY
, menu_sort_cmd
},
499 {' ', N_("Paste o&utput of... M-u"), NULL_HOTKEY
, menu_ext_cmd
},
500 {' ', N_("E&xternal Formatter F19"), NULL_HOTKEY
, menu_c_form_cmd
},
501 {' ', N_("&Mail... "), NULL_HOTKEY
, menu_mail_cmd
}
504 static menu_entry CmdMenuEmacs
[] =
506 {' ', N_("&Go to line... M-l"), NULL_HOTKEY
, menu_goto_line
},
507 {' ', N_("Toggle li&ne state M-n"), NULL_HOTKEY
, menu_toggle_line_state
},
508 {' ', N_("Go to matching &bracket M-b"), NULL_HOTKEY
, menu_goto_bracket
},
509 {' ', "", NULL_HOTKEY
, 0},
510 {' ', N_("Insert &literal... C-q"), NULL_HOTKEY
, menu_lit_cmd
},
511 {' ', "", NULL_HOTKEY
, 0},
512 {' ', N_("&Refresh screen C-l"), NULL_HOTKEY
, menu_refresh_cmd
},
513 {' ', "", NULL_HOTKEY
, 0},
514 {' ', N_("&Start record macro C-r"), NULL_HOTKEY
, menu_begin_record_cmd
},
515 {' ', N_("&Finish record macro... C-r"), NULL_HOTKEY
, menu_end_record_cmd
},
516 {' ', N_("&Execute macro... C-x e, KEY"), NULL_HOTKEY
, menu_exec_macro_cmd
},
517 {' ', N_("Delete macr&o... "), NULL_HOTKEY
, menu_exec_macro_delete_cmd
},
518 {' ', "", NULL_HOTKEY
, 0},
519 {' ', N_("Insert &date/time "), NULL_HOTKEY
, menu_date_cmd
},
520 {' ', "", NULL_HOTKEY
, 0},
521 {' ', N_("Format p&aragraph M-p"), NULL_HOTKEY
, menu_format_paragraph
},
522 {' ', N_("'ispell' s&pell check M-$"), NULL_HOTKEY
, menu_ispell_cmd
},
523 {' ', N_("Sor&t... M-t"), NULL_HOTKEY
, menu_sort_cmd
},
524 {' ', N_("Paste o&utput of... M-u"), NULL_HOTKEY
, menu_ext_cmd
},
525 {' ', N_("E&xternal Formatter F19"), NULL_HOTKEY
, menu_c_form_cmd
},
526 {' ', N_("&Mail... "), NULL_HOTKEY
, menu_mail_cmd
}
529 static menu_entry OptMenu
[] =
531 {' ', N_("&General... "), NULL_HOTKEY
, edit_options_dialog
},
532 {' ', N_("&Save mode..."), NULL_HOTKEY
, menu_save_mode_cmd
},
533 {' ', N_("Learn &Keys..."), NULL_HOTKEY
, learn_keys
},
534 {' ', N_("Syntax &Highlighting..."), NULL_HOTKEY
, edit_syntax_dialog
},
535 {' ', "", NULL_HOTKEY
, 0},
536 {' ', N_("S&yntax file"), NULL_HOTKEY
, menu_edit_syntax_file_cmd
},
537 {' ', N_("&Menu file"), NULL_HOTKEY
, menu_edit_menu_file_cmd
},
538 {' ', "", NULL_HOTKEY
, 0},
539 {' ', N_("Save setu&p"), NULL_HOTKEY
, save_setup_cmd
}
542 #define OptMenuEmacs OptMenu
544 #define menu_entries(x) sizeof(x)/sizeof(menu_entry)
548 static Menu
*EditMenuBar
[N_menus
];
551 edit_init_menu_normal (void)
553 EditMenuBar
[0] = create_menu (_(" File "), FileMenu
, menu_entries (FileMenu
),
554 "[Internal File Editor]");
555 EditMenuBar
[1] = create_menu (_(" Edit "), EditMenu
, menu_entries (EditMenu
),
556 "[Internal File Editor]");
557 EditMenuBar
[2] = create_menu (_(" Sear/Repl "), SearReplMenu
, menu_entries (SearReplMenu
),
558 "[Internal File Editor]");
559 EditMenuBar
[3] = create_menu (_(" Command "), CmdMenu
, menu_entries (CmdMenu
),
560 "[Internal File Editor]");
561 EditMenuBar
[4] = create_menu (_(" Options "), OptMenu
, menu_entries (OptMenu
),
562 "[Internal File Editor]");
566 edit_init_menu_emacs (void)
568 EditMenuBar
[0] = create_menu (_(" File "), FileMenuEmacs
, menu_entries (FileMenuEmacs
),
569 "[Internal File Editor]");
570 EditMenuBar
[1] = create_menu (_(" Edit "), EditMenuEmacs
, menu_entries (EditMenuEmacs
),
571 "[Internal File Editor]");
572 EditMenuBar
[2] = create_menu (_(" Sear/Repl "), SearReplMenuEmacs
, menu_entries (SearReplMenuEmacs
),
573 "[Internal File Editor]");
574 EditMenuBar
[3] = create_menu (_(" Command "), CmdMenuEmacs
, menu_entries (CmdMenuEmacs
),
575 "[Internal File Editor]");
576 EditMenuBar
[4] = create_menu (_(" Options "), OptMenuEmacs
, menu_entries (OptMenuEmacs
),
577 "[Internal File Editor]");
581 edit_init_menu (void)
583 switch (edit_key_emulation
) {
585 case EDIT_KEY_EMULATION_NORMAL
:
586 edit_init_menu_normal ();
588 case EDIT_KEY_EMULATION_EMACS
:
589 edit_init_menu_emacs ();
595 edit_create_menu (void)
598 return menubar_new (0, 0, COLS
, EditMenuBar
, N_menus
);
602 edit_done_menu (struct WMenu
*wmenu
)
605 for (i
= 0; i
< N_menus
; i
++)
606 destroy_menu (wmenu
->menu
[i
]);
611 edit_reload_menu (void)
613 edit_done_menu (edit_menubar
);
615 menubar_arrange (edit_menubar
);
620 edit_drop_menu_cmd (WEdit
*e
, int which
)
622 if (edit_menubar
->active
)
624 edit_menubar
->active
= 1;
625 edit_menubar
->dropped
= drop_menus
;
627 edit_menubar
->selected
= which
;
630 edit_menubar
->previous_widget
= e
->widget
.parent
->current
->dlg_id
;
631 dlg_select_widget (edit_menubar
);
635 void edit_menu_cmd (WEdit
* e
)
637 edit_drop_menu_cmd (e
, -1);
641 int edit_drop_hotkey_menu (WEdit
* e
, int key
)
646 if (edit_key_emulation
== EDIT_KEY_EMULATION_EMACS
)
666 edit_drop_menu_cmd (e
, m
);