1 /* editor menu definitions and initialisation
3 Copyright (C) 1996 the Free Software Foundation
5 Authors: 1996, 1997 Paul Sheer
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 #include <sys/types.h>
38 #include "../src/global.h"
41 #include "../src/wtools.h" /* query_dialog() */
42 #include "../src/menu.h" /* menu_entry */
43 #include "../src/tty.h" /* KEY_F */
44 #include "../src/key.h" /* XCTRL */
45 #include "../src/main.h" /* drop_menus */
46 #include "../src/learn.h" /* learn_keys */
48 #include "edit-widget.h"
49 #include "editcmddef.h"
52 menu_cmd (int command
)
54 edit_execute_key_command (wedit
, command
, -1);
55 edit_update_screen (wedit
);
58 static void menu_key (int i
)
60 send_message ((Widget
*) wedit
, WIDGET_KEY
, i
);
66 query_dialog (_(" About "),
67 _("\n Cooledit v3.11.5\n\n"
68 " Copyright (C) 1996 the Free Software Foundation\n\n"
69 " A user friendly text editor written\n"
70 " for the Midnight Commander.\n"), D_NORMAL
,
99 menu_save_as_cmd (void)
101 menu_cmd (CK_Save_As
);
105 menu_insert_file_cmd (void)
107 menu_cmd (CK_Insert_File
);
123 menu_markcol_cmd (void)
125 menu_cmd (CK_Column_Mark
);
131 menu_cmd (CK_Toggle_Insert
);
147 menu_delete_cmd (void)
149 menu_cmd (CK_Remove
);
155 menu_cmd (CK_Save_Block
);
159 menu_search_cmd (void)
165 menu_search_again_cmd (void)
167 menu_cmd (CK_Find_Again
);
171 menu_replace_cmd (void)
173 menu_cmd (CK_Replace
);
177 menu_begin_record_cmd (void)
179 menu_cmd (CK_Begin_Record_Macro
);
183 menu_end_record_cmd (void)
185 menu_cmd (CK_End_Record_Macro
);
189 menu_exec_macro_cmd (void)
191 menu_key (XCTRL ('a'));
195 menu_exec_macro_delete_cmd (void)
197 menu_cmd (CK_Delete_Macro
);
201 menu_c_form_cmd (void)
203 menu_key (KEY_F (19));
207 menu_ispell_cmd (void)
209 menu_cmd (CK_Pipe_Block (1));
221 menu_cmd (CK_ExtCmd
);
237 menu_beginning_cmd (void)
239 menu_cmd (CK_Beginning_Of_Text
);
245 menu_cmd (CK_End_Of_Text
);
249 menu_refresh_cmd (void)
251 menu_cmd (CK_Refresh
);
255 menu_goto_line (void)
261 menu_goto_bracket (void)
263 menu_cmd (CK_Match_Bracket
);
269 menu_key (XCTRL ('q'));
273 menu_format_paragraph (void)
275 menu_cmd (CK_Paragraph_Format
);
281 edit_options_dialog ();
287 edit_syntax_dialog ();
291 menu_user_menu_cmd (void)
293 menu_key (KEY_F (11));
296 static menu_entry FileMenu
[] =
298 {' ', N_("&Open file..."), 'O', menu_load_cmd
},
299 {' ', N_("&New C-n"), 'N', menu_new_cmd
},
301 {' ', N_("&Save F2"), 'S', menu_save_cmd
},
302 {' ', N_("Save &as... F12"), 'A', menu_save_as_cmd
},
304 {' ', N_("&Insert file... F15"), 'I', menu_insert_file_cmd
},
305 {' ', N_("Copy to &file... C-f"), 'F', menu_cut_cmd
},
307 {' ', N_("&User menu... F11"), 'U', menu_user_menu_cmd
},
309 {' ', N_("A&bout... "), 'B', edit_about_cmd
},
311 {' ', N_("&Quit F10"), 'Q', menu_quit_cmd
}
314 static menu_entry FileMenuEmacs
[] =
316 {' ', N_("&Open file..."), 'O', menu_load_cmd
},
317 {' ', N_("&New C-x k"), 'N', menu_new_cmd
},
319 {' ', N_("&Save F2"), 'S', menu_save_cmd
},
320 {' ', N_("Save &as... F12"), 'A', menu_save_as_cmd
},
322 {' ', N_("&Insert file... F15"), 'I', menu_insert_file_cmd
},
323 {' ', N_("Copy to &file... "), 'F', menu_cut_cmd
},
325 {' ', N_("&User menu... F11"), 'U', menu_user_menu_cmd
},
327 {' ', N_("A&bout... "), 'B', edit_about_cmd
},
329 {' ', N_("&Quit F10"), 'Q', menu_quit_cmd
}
332 static menu_entry EditMenu
[] =
334 {' ', N_("&Toggle Mark F3"), 'T', menu_mark_cmd
},
335 {' ', N_("&Mark Columns S-F3"), 'T', menu_markcol_cmd
},
337 {' ', N_("Toggle &ins/overw Ins"), 'I', menu_ins_cmd
},
339 {' ', N_("&Copy F5"), 'C', menu_copy_cmd
},
340 {' ', N_("&Move F6"), 'M', menu_move_cmd
},
341 {' ', N_("&Delete F8"), 'D', menu_delete_cmd
},
343 {' ', N_("&Undo C-u"), 'U', menu_undo_cmd
},
345 {' ', N_("&Beginning C-PgUp"), 'B', menu_beginning_cmd
},
346 {' ', N_("&End C-PgDn"), 'E', menu_end_cmd
}
349 #define EditMenuEmacs EditMenu
351 static menu_entry SearReplMenu
[] =
353 {' ', N_("&Search... F7"), 'S', menu_search_cmd
},
354 {' ', N_("Search &again F17"), 'A', menu_search_again_cmd
},
355 {' ', N_("&Replace... F4"), 'R', menu_replace_cmd
}
358 #define SearReplMenuEmacs SearReplMenu
360 static menu_entry CmdMenu
[] =
362 {' ', N_("&Go to line... M-l"), 'G', menu_goto_line
},
363 {' ', N_("Go to matching &bracket M-b"), 'B', menu_goto_bracket
},
365 {' ', N_("Insert &literal... C-q"), 'L', menu_lit_cmd
},
367 {' ', N_("&Refresh screen C-l"), 'R', menu_refresh_cmd
},
369 {' ', N_("&Start record macro C-r"), 'S', menu_begin_record_cmd
},
370 {' ', N_("&Finish record macro... C-r"), 'F', menu_end_record_cmd
},
371 {' ', N_("&Execute macro... C-a, KEY"), 'E', menu_exec_macro_cmd
},
372 {' ', N_("Delete macr&o... "), 'O', menu_exec_macro_delete_cmd
},
374 {' ', N_("Insert &date/time "), 'D', menu_date_cmd
},
376 {' ', N_("Format p&aragraph M-p"), 'A', menu_format_paragraph
},
377 {' ', N_("'ispell' s&pell check C-p"), 'P', menu_ispell_cmd
},
378 {' ', N_("Sor&t... M-t"), 'T', menu_sort_cmd
},
379 {' ', N_("Paste o&utput of... M-u"), 'U', menu_ext_cmd
},
380 {' ', N_("E&xternal Formatter F19"), 'C', menu_c_form_cmd
},
381 {' ', N_("&Mail... "), 'M', menu_mail_cmd
}
384 static menu_entry CmdMenuEmacs
[] =
386 {' ', N_("&Go to line... M-l"), 'G', menu_goto_line
},
387 {' ', N_("Go to matching &bracket M-b"), 'B', menu_goto_bracket
},
389 {' ', N_("Insert &literal... C-q"), 'L', menu_lit_cmd
},
391 {' ', N_("&Refresh screen C-l"), 'R', menu_refresh_cmd
},
393 {' ', N_("&Start record macro C-r"), 'S', menu_begin_record_cmd
},
394 {' ', N_("&Finish record macro... C-r"), 'F', menu_end_record_cmd
},
395 {' ', N_("&Execute macro... C-x e, KEY"), 'E', menu_exec_macro_cmd
},
396 {' ', N_("Delete macr&o... "), 'o', menu_exec_macro_delete_cmd
},
398 {' ', N_("Insert &date/time "), 'D', menu_date_cmd
},
400 {' ', N_("Format p&aragraph M-p"), 'a', menu_format_paragraph
},
401 {' ', N_("'ispell' s&pell check M-$"), 'P', menu_ispell_cmd
},
402 {' ', N_("Sor&t... M-t"), 'T', menu_sort_cmd
},
403 {' ', N_("Paste o&utput of... M-u"), 'U', menu_ext_cmd
},
404 {' ', N_("E&xternal Formatter F19"), 'C', menu_c_form_cmd
},
405 {' ', N_("&Mail... "), 'M', menu_mail_cmd
}
408 static menu_entry OptMenu
[] =
410 {' ', N_("&General... "), 'G', menu_options
},
411 {' ', N_("&Save mode..."), 'S', menu_save_mode_cmd
},
412 {' ', N_("Learn &Keys..."), 'K', learn_keys
},
413 {' ', N_("Syntax &Highlighting..."), 'H', menu_syntax
}
416 #define OptMenuEmacs OptMenu
418 #define menu_entries(x) sizeof(x)/sizeof(menu_entry)
420 void edit_init_menu_normal (struct Menu
*EditMenuBar
[])
422 EditMenuBar
[0] = create_menu (_(" File "), FileMenu
, menu_entries (FileMenu
),
423 "[Internal File Editor]");
424 EditMenuBar
[1] = create_menu (_(" Edit "), EditMenu
, menu_entries (EditMenu
),
425 "[Internal File Editor]");
426 EditMenuBar
[2] = create_menu (_(" Sear/Repl "), SearReplMenu
, menu_entries (SearReplMenu
),
427 "[Internal File Editor]");
428 EditMenuBar
[3] = create_menu (_(" Command "), CmdMenu
, menu_entries (CmdMenu
),
429 "[Internal File Editor]");
430 EditMenuBar
[4] = create_menu (_(" Options "), OptMenu
, menu_entries (OptMenu
),
431 "[Internal File Editor]");
434 void edit_init_menu_emacs (struct Menu
*EditMenuBar
[])
436 EditMenuBar
[0] = create_menu (_(" File "), FileMenuEmacs
, menu_entries (FileMenuEmacs
),
437 "[Internal File Editor]");
438 EditMenuBar
[1] = create_menu (_(" Edit "), EditMenuEmacs
, menu_entries (EditMenuEmacs
),
439 "[Internal File Editor]");
440 EditMenuBar
[2] = create_menu (_(" Sear/Repl "), SearReplMenuEmacs
, menu_entries (SearReplMenuEmacs
),
441 "[Internal File Editor]");
442 EditMenuBar
[3] = create_menu (_(" Command "), CmdMenuEmacs
, menu_entries (CmdMenuEmacs
),
443 "[Internal File Editor]");
444 EditMenuBar
[4] = create_menu (_(" Options "), OptMenuEmacs
, menu_entries (OptMenuEmacs
),
445 "[Internal File Editor]");
449 edit_init_menu (void)
451 struct Menu
**EditMenuBar
= g_new(struct Menu
*, N_menus
);
453 switch (edit_key_emulation
) {
455 case EDIT_KEY_EMULATION_NORMAL
:
456 edit_init_menu_normal (EditMenuBar
);
458 case EDIT_KEY_EMULATION_EMACS
:
459 edit_init_menu_emacs (EditMenuBar
);
462 return menubar_new (0, 0, COLS
, EditMenuBar
, N_menus
);
466 edit_done_menu (struct WMenu
*wmenu
)
469 for (i
= 0; i
< N_menus
; i
++)
470 destroy_menu (wmenu
->menu
[i
]);
477 edit_reload_menu (void)
479 struct WMenu
*new_edit_menubar
;
481 new_edit_menubar
= edit_init_menu ();
482 dlg_replace_widget (&edit_menubar
->widget
, &new_edit_menubar
->widget
);
483 edit_done_menu (edit_menubar
);
484 edit_menubar
= new_edit_menubar
;
489 edit_drop_menu_cmd (WEdit
*e
, int which
)
491 if (edit_menubar
->active
)
493 edit_menubar
->active
= 1;
494 edit_menubar
->dropped
= drop_menus
;
496 edit_menubar
->selected
= which
;
499 edit_menubar
->previous_widget
= e
->widget
.parent
->current
->dlg_id
;
500 dlg_select_widget (edit_menubar
);
504 void edit_menu_cmd (WEdit
* e
)
506 edit_drop_menu_cmd (e
, -1);
510 int edit_drop_hotkey_menu (WEdit
* e
, int key
)
515 if (edit_key_emulation
== EDIT_KEY_EMULATION_EMACS
)
535 edit_drop_menu_cmd (e
, m
);