editmenu.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /* editor menu definitions and initialisation
  2. Copyright (C) 1996, 1998, 2001, 2002, 2003, 2005, 2007
  3. Free Software Foundation, Inc.
  4. Authors: 1996, 1997 Paul Sheer
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. 02110-1301, USA.
  17. */
  18. /** \file
  19. * \brief Source: editor menu definitions and initialisation
  20. * \author Paul Sheer
  21. * \date 1996, 1997
  22. */
  23. #include <config.h>
  24. #include <stdio.h>
  25. #include <stdarg.h>
  26. #include <sys/types.h>
  27. #include <unistd.h>
  28. #include <string.h>
  29. #include <ctype.h>
  30. #include <errno.h>
  31. #include <sys/stat.h>
  32. #include <stdlib.h>
  33. #include "../src/global.h"
  34. #include "edit-impl.h"
  35. #include "edit-widget.h"
  36. #include "editcmddef.h"
  37. #include "../src/tty/tty.h" /* KEY_F */
  38. #include "../src/tty/key.h" /* XCTRL */
  39. #include "../src/cmd.h" /* save_setup_cmd() */
  40. #include "../src/wtools.h" /* query_dialog() */
  41. #include "../src/menu.h" /* menu_entry */
  42. #include "../src/main.h" /* drop_menus */
  43. #include "../src/learn.h" /* learn_keys */
  44. #include "edit-widget.h"
  45. #include "../src/cmddef.h"
  46. static void
  47. menu_cmd (int command)
  48. {
  49. edit_execute_key_command (wedit, command, -1);
  50. edit_update_screen (wedit);
  51. }
  52. static void menu_key (int i)
  53. {
  54. send_message ((Widget *) wedit, WIDGET_KEY, i);
  55. }
  56. static void
  57. edit_about_cmd (void)
  58. {
  59. query_dialog (_(" About "),
  60. _("\n Cooledit v3.11.5\n\n"
  61. " Copyright (C) 1996 the Free Software Foundation\n\n"
  62. " A user friendly text editor written\n"
  63. " for the Midnight Commander.\n"), D_NORMAL,
  64. 1, _("&OK"));
  65. }
  66. static void
  67. menu_mail_cmd (void)
  68. {
  69. menu_cmd (CK_Mail);
  70. }
  71. static void
  72. menu_load_cmd (void)
  73. {
  74. menu_cmd (CK_Load);
  75. }
  76. static void
  77. menu_new_cmd (void)
  78. {
  79. menu_cmd (CK_New);
  80. }
  81. static void
  82. menu_save_cmd (void)
  83. {
  84. menu_cmd (CK_Save);
  85. }
  86. static void
  87. menu_save_as_cmd (void)
  88. {
  89. menu_cmd (CK_Save_As);
  90. }
  91. static void
  92. menu_insert_file_cmd (void)
  93. {
  94. menu_cmd (CK_Insert_File);
  95. }
  96. static void
  97. menu_quit_cmd (void)
  98. {
  99. menu_cmd (CK_Exit);
  100. }
  101. static void
  102. menu_mark_cmd (void)
  103. {
  104. menu_cmd (CK_Mark);
  105. }
  106. static void
  107. menu_markcol_cmd (void)
  108. {
  109. menu_cmd (CK_Column_Mark);
  110. }
  111. static void
  112. menu_ins_cmd (void)
  113. {
  114. menu_cmd (CK_Toggle_Insert);
  115. }
  116. static void
  117. menu_copy_cmd (void)
  118. {
  119. menu_cmd (CK_Copy);
  120. }
  121. static void
  122. menu_move_cmd (void)
  123. {
  124. menu_cmd (CK_Move);
  125. }
  126. static void
  127. menu_delete_cmd (void)
  128. {
  129. menu_cmd (CK_Remove);
  130. }
  131. static void
  132. menu_xstore_cmd (void)
  133. {
  134. menu_cmd (CK_XStore);
  135. }
  136. static void
  137. menu_xcut_cmd (void)
  138. {
  139. menu_cmd (CK_XCut);
  140. }
  141. static void
  142. menu_xpaste_cmd (void)
  143. {
  144. menu_cmd (CK_XPaste);
  145. }
  146. static void
  147. menu_toggle_bookmark_cmd (void)
  148. {
  149. menu_cmd (CK_Toggle_Bookmark);
  150. }
  151. static void
  152. menu_flush_bookmark_cmd (void)
  153. {
  154. menu_cmd (CK_Flush_Bookmarks);
  155. }
  156. static void
  157. menu_next_bookmark_cmd (void)
  158. {
  159. menu_cmd (CK_Next_Bookmark);
  160. }
  161. static void
  162. menu_prev_bookmark_cmd (void)
  163. {
  164. menu_cmd (CK_Prev_Bookmark);
  165. }
  166. static void
  167. menu_cut_cmd (void)
  168. {
  169. menu_cmd (CK_Save_Block);
  170. }
  171. static void
  172. menu_search_cmd (void)
  173. {
  174. menu_cmd (CK_Find);
  175. }
  176. static void
  177. menu_search_again_cmd (void)
  178. {
  179. menu_cmd (CK_Find_Again);
  180. }
  181. static void
  182. menu_replace_cmd (void)
  183. {
  184. menu_cmd (CK_Replace);
  185. }
  186. static void
  187. menu_select_codepage_cmd (void)
  188. {
  189. menu_cmd (CK_SelectCodepage);
  190. }
  191. static void
  192. menu_begin_record_cmd (void)
  193. {
  194. menu_cmd (CK_Begin_Record_Macro);
  195. }
  196. static void
  197. menu_end_record_cmd (void)
  198. {
  199. menu_cmd (CK_End_Record_Macro);
  200. }
  201. static void
  202. menu_exec_macro_cmd (void)
  203. {
  204. menu_key (XCTRL ('a'));
  205. }
  206. static void
  207. menu_exec_macro_delete_cmd (void)
  208. {
  209. menu_cmd (CK_Delete_Macro);
  210. }
  211. static void
  212. menu_c_form_cmd (void)
  213. {
  214. menu_key (KEY_F (19));
  215. }
  216. static void
  217. menu_ispell_cmd (void)
  218. {
  219. menu_cmd (CK_Pipe_Block (1));
  220. }
  221. static void
  222. menu_sort_cmd (void)
  223. {
  224. menu_cmd (CK_Sort);
  225. }
  226. static void
  227. menu_ext_cmd (void)
  228. {
  229. menu_cmd (CK_ExtCmd);
  230. }
  231. static void
  232. menu_date_cmd (void)
  233. {
  234. menu_cmd (CK_Date);
  235. }
  236. static void
  237. menu_undo_cmd (void)
  238. {
  239. menu_cmd (CK_Undo);
  240. }
  241. static void
  242. menu_beginning_cmd (void)
  243. {
  244. menu_cmd (CK_Beginning_Of_Text);
  245. }
  246. static void
  247. menu_end_cmd (void)
  248. {
  249. menu_cmd (CK_End_Of_Text);
  250. }
  251. static void
  252. menu_refresh_cmd (void)
  253. {
  254. menu_cmd (CK_Refresh);
  255. }
  256. static void
  257. menu_goto_line (void)
  258. {
  259. menu_cmd (CK_Goto);
  260. }
  261. static void
  262. menu_toggle_line_state (void)
  263. {
  264. menu_cmd (CK_Toggle_Line_State);
  265. }
  266. static void
  267. menu_goto_bracket (void)
  268. {
  269. menu_cmd (CK_Match_Bracket);
  270. }
  271. static void
  272. menu_lit_cmd (void)
  273. {
  274. menu_key (XCTRL ('q'));
  275. }
  276. static void
  277. menu_format_paragraph (void)
  278. {
  279. menu_cmd (CK_Paragraph_Format);
  280. }
  281. static void
  282. menu_edit_syntax_file_cmd (void)
  283. {
  284. menu_cmd (CK_Load_Syntax_File);
  285. }
  286. static void
  287. menu_edit_menu_file_cmd (void)
  288. {
  289. menu_cmd (CK_Load_Menu_File);
  290. }
  291. static void
  292. menu_user_menu_cmd (void)
  293. {
  294. menu_key (KEY_F (11));
  295. }
  296. static void
  297. menu_find_declare (void)
  298. {
  299. menu_cmd (CK_Find_Definition);
  300. }
  301. static void
  302. menu_declare_back (void)
  303. {
  304. menu_cmd (CK_Load_Prev_File);
  305. }
  306. static void
  307. menu_declare_forward (void)
  308. {
  309. menu_cmd (CK_Load_Next_File);
  310. }
  311. static menu_entry FileMenu[] =
  312. {
  313. {' ', N_("&Open file..."), NULL_HOTKEY, menu_load_cmd},
  314. {' ', N_("&New C-n"), NULL_HOTKEY, menu_new_cmd},
  315. {' ', "", NULL_HOTKEY, 0},
  316. {' ', N_("&Save F2"), NULL_HOTKEY, menu_save_cmd},
  317. {' ', N_("Save &as... F12"), NULL_HOTKEY, menu_save_as_cmd},
  318. {' ', "", NULL_HOTKEY, 0},
  319. {' ', N_("&Insert file... F15"), NULL_HOTKEY, menu_insert_file_cmd},
  320. {' ', N_("Copy to &file... C-f"), NULL_HOTKEY, menu_cut_cmd},
  321. {' ', "", NULL_HOTKEY, 0},
  322. {' ', N_("&User menu... F11"), NULL_HOTKEY, menu_user_menu_cmd},
  323. {' ', "", NULL_HOTKEY, 0},
  324. {' ', N_("A&bout... "), NULL_HOTKEY, edit_about_cmd},
  325. {' ', "", NULL_HOTKEY, 0},
  326. {' ', N_("&Quit F10"), NULL_HOTKEY, menu_quit_cmd}
  327. };
  328. static menu_entry FileMenuEmacs[] =
  329. {
  330. {' ', N_("&Open file..."), NULL_HOTKEY, menu_load_cmd},
  331. {' ', N_("&New C-x k"), NULL_HOTKEY, menu_new_cmd},
  332. {' ', "", NULL_HOTKEY, 0},
  333. {' ', N_("&Save F2"), NULL_HOTKEY, menu_save_cmd},
  334. {' ', N_("Save &as... F12"), NULL_HOTKEY, menu_save_as_cmd},
  335. {' ', "", NULL_HOTKEY, 0},
  336. {' ', N_("&Insert file... F15"), NULL_HOTKEY, menu_insert_file_cmd},
  337. {' ', N_("Copy to &file... "), NULL_HOTKEY, menu_cut_cmd},
  338. {' ', "", NULL_HOTKEY, 0},
  339. {' ', N_("&User menu... F11"), NULL_HOTKEY, menu_user_menu_cmd},
  340. {' ', "", NULL_HOTKEY, 0},
  341. {' ', N_("A&bout... "), NULL_HOTKEY, edit_about_cmd},
  342. {' ', "", NULL_HOTKEY, 0},
  343. {' ', N_("&Quit F10"), NULL_HOTKEY, menu_quit_cmd}
  344. };
  345. static menu_entry EditMenu[] =
  346. {
  347. {' ', N_("&Toggle mark F3"), NULL_HOTKEY, menu_mark_cmd},
  348. {' ', N_("Mar&k columns S-F3"), NULL_HOTKEY, menu_markcol_cmd},
  349. {' ', "", NULL_HOTKEY, 0},
  350. {' ', N_("Toggle &ins/overw Ins"), NULL_HOTKEY, menu_ins_cmd},
  351. {' ', "", NULL_HOTKEY, 0},
  352. {' ', N_("&Copy F5"), NULL_HOTKEY, menu_copy_cmd},
  353. {' ', N_("&Move F6"), NULL_HOTKEY, menu_move_cmd},
  354. {' ', N_("&Delete F8"), NULL_HOTKEY, menu_delete_cmd},
  355. {' ', "", NULL_HOTKEY, 0},
  356. {' ', N_("C&opy to clipfile C-Ins"), NULL_HOTKEY, menu_xstore_cmd},
  357. {' ', N_("C&ut to clipfile S-Del"), NULL_HOTKEY, menu_xcut_cmd},
  358. {' ', N_("&Paste from clipfile S-Ins"), NULL_HOTKEY, menu_xpaste_cmd},
  359. {' ', "", NULL_HOTKEY, 0},
  360. {' ', N_("Toggle bookmar&k M-k"), NULL_HOTKEY, menu_toggle_bookmark_cmd},
  361. {' ', N_("&Next bookmark M-j"), NULL_HOTKEY, menu_next_bookmark_cmd},
  362. {' ', N_("Pre&v bookmark M-i"), NULL_HOTKEY, menu_prev_bookmark_cmd},
  363. {' ', N_("&Flush bookmark M-o"), NULL_HOTKEY, menu_flush_bookmark_cmd},
  364. {' ', "", NULL_HOTKEY, 0},
  365. {' ', N_("&Undo C-u"), NULL_HOTKEY, menu_undo_cmd},
  366. {' ', "", NULL_HOTKEY, 0},
  367. {' ', N_("&Beginning C-PgUp"), NULL_HOTKEY, menu_beginning_cmd},
  368. {' ', N_("&End C-PgDn"), NULL_HOTKEY, menu_end_cmd}
  369. };
  370. static menu_entry EditMenuEmacs[] =
  371. {
  372. {' ', N_("&Toggle mark F3"), NULL_HOTKEY, menu_mark_cmd},
  373. {' ', N_("Mar&k columns S-F3"), NULL_HOTKEY, menu_markcol_cmd},
  374. {' ', "", NULL_HOTKEY, 0},
  375. {' ', N_("Toggle &ins/overw Ins"), NULL_HOTKEY, menu_ins_cmd},
  376. {' ', "", NULL_HOTKEY, 0},
  377. {' ', N_("&Copy F5"), NULL_HOTKEY, menu_copy_cmd},
  378. {' ', N_("&Move F6"), NULL_HOTKEY, menu_move_cmd},
  379. {' ', N_("&Delete F8"), NULL_HOTKEY, menu_delete_cmd},
  380. {' ', "", NULL_HOTKEY, 0},
  381. {' ', N_("C&opy to clipfile M-w"), NULL_HOTKEY, menu_xstore_cmd},
  382. {' ', N_("C&ut to clipfile C-w"), NULL_HOTKEY, menu_xcut_cmd},
  383. {' ', N_("&Paste from clipfile C-y"), NULL_HOTKEY, menu_xpaste_cmd},
  384. {' ', "", NULL_HOTKEY, 0},
  385. {' ', N_("Toggle bookmar&k "), NULL_HOTKEY, menu_toggle_bookmark_cmd},
  386. {' ', N_("&Next bookmark "), NULL_HOTKEY, menu_next_bookmark_cmd},
  387. {' ', N_("Pre&v bookmark "), NULL_HOTKEY, menu_prev_bookmark_cmd},
  388. {' ', N_("&Flush bookmark "), NULL_HOTKEY, menu_flush_bookmark_cmd},
  389. {' ', "", NULL_HOTKEY, 0},
  390. {' ', N_("&Undo C-u"), NULL_HOTKEY, menu_undo_cmd},
  391. {' ', "", NULL_HOTKEY, 0},
  392. {' ', N_("&Beginning C-PgUp"), NULL_HOTKEY, menu_beginning_cmd},
  393. {' ', N_("&End C-PgDn"), NULL_HOTKEY, menu_end_cmd}
  394. };
  395. static menu_entry SearReplMenu[] =
  396. {
  397. {' ', N_("&Search... F7"), NULL_HOTKEY, menu_search_cmd},
  398. {' ', N_("Search &again F17"), NULL_HOTKEY, menu_search_again_cmd},
  399. {' ', N_("&Replace... F4"), NULL_HOTKEY, menu_replace_cmd}
  400. };
  401. #define SearReplMenuEmacs SearReplMenu
  402. static menu_entry CmdMenu[] =
  403. {
  404. {' ', N_("&Go to line... M-l"), NULL_HOTKEY, menu_goto_line},
  405. {' ', N_("Toggle li&ne state M-n"), NULL_HOTKEY, menu_toggle_line_state},
  406. {' ', N_("Go to matching &bracket M-b"), NULL_HOTKEY, menu_goto_bracket},
  407. {' ', "", NULL_HOTKEY, 0},
  408. {' ', N_("Find declaration A-Enter"), NULL_HOTKEY, menu_find_declare},
  409. {' ', N_("Back from declaration M--"), NULL_HOTKEY, menu_declare_back},
  410. {' ', N_("Forward to declaration M-+"), NULL_HOTKEY, menu_declare_forward},
  411. #ifdef HAVE_CHARSET
  412. {' ', "", NULL_HOTKEY, 0},
  413. {' ', N_("Encod&ing... C-t"), NULL_HOTKEY, menu_select_codepage_cmd},
  414. #endif
  415. {' ', "", NULL_HOTKEY, 0},
  416. {' ', N_("Insert &literal... C-q"), NULL_HOTKEY, menu_lit_cmd},
  417. {' ', "", NULL_HOTKEY, 0},
  418. {' ', N_("&Refresh screen C-l"), NULL_HOTKEY, menu_refresh_cmd},
  419. {' ', "", NULL_HOTKEY, 0},
  420. {' ', N_("&Start record macro C-r"), NULL_HOTKEY, menu_begin_record_cmd},
  421. {' ', N_("&Finish record macro... C-r"), NULL_HOTKEY, menu_end_record_cmd},
  422. {' ', N_("&Execute macro... C-a, KEY"), NULL_HOTKEY, menu_exec_macro_cmd},
  423. {' ', N_("Delete macr&o... "), NULL_HOTKEY, menu_exec_macro_delete_cmd},
  424. {' ', "", NULL_HOTKEY, 0},
  425. {' ', N_("Insert &date/time "), NULL_HOTKEY, menu_date_cmd},
  426. {' ', "", NULL_HOTKEY, 0},
  427. {' ', N_("Format p&aragraph M-p"), NULL_HOTKEY, menu_format_paragraph},
  428. {' ', N_("'ispell' s&pell check C-p"), NULL_HOTKEY, menu_ispell_cmd},
  429. {' ', N_("Sor&t... M-t"), NULL_HOTKEY, menu_sort_cmd},
  430. {' ', N_("Paste o&utput of... M-u"), NULL_HOTKEY, menu_ext_cmd},
  431. {' ', N_("E&xternal Formatter F19"), NULL_HOTKEY, menu_c_form_cmd},
  432. {' ', N_("&Mail... "), NULL_HOTKEY, menu_mail_cmd}
  433. };
  434. static menu_entry CmdMenuEmacs[] =
  435. {
  436. {' ', N_("&Go to line... M-l"), NULL_HOTKEY, menu_goto_line},
  437. {' ', N_("Toggle li&ne state M-n"), NULL_HOTKEY, menu_toggle_line_state},
  438. {' ', N_("Go to matching &bracket M-b"), NULL_HOTKEY, menu_goto_bracket},
  439. {' ', "", NULL_HOTKEY, 0},
  440. {' ', N_("Insert &literal... C-q"), NULL_HOTKEY, menu_lit_cmd},
  441. {' ', "", NULL_HOTKEY, 0},
  442. {' ', N_("&Refresh screen C-l"), NULL_HOTKEY, menu_refresh_cmd},
  443. {' ', "", NULL_HOTKEY, 0},
  444. {' ', N_("&Start record macro C-r"), NULL_HOTKEY, menu_begin_record_cmd},
  445. {' ', N_("&Finish record macro... C-r"), NULL_HOTKEY, menu_end_record_cmd},
  446. {' ', N_("&Execute macro... C-x e, KEY"), NULL_HOTKEY, menu_exec_macro_cmd},
  447. {' ', N_("Delete macr&o... "), NULL_HOTKEY, menu_exec_macro_delete_cmd},
  448. {' ', "", NULL_HOTKEY, 0},
  449. {' ', N_("Insert &date/time "), NULL_HOTKEY, menu_date_cmd},
  450. {' ', "", NULL_HOTKEY, 0},
  451. {' ', N_("Format p&aragraph M-p"), NULL_HOTKEY, menu_format_paragraph},
  452. {' ', N_("'ispell' s&pell check M-$"), NULL_HOTKEY, menu_ispell_cmd},
  453. {' ', N_("Sor&t... M-t"), NULL_HOTKEY, menu_sort_cmd},
  454. {' ', N_("Paste o&utput of... M-u"), NULL_HOTKEY, menu_ext_cmd},
  455. {' ', N_("E&xternal Formatter F19"), NULL_HOTKEY, menu_c_form_cmd},
  456. {' ', N_("&Mail... "), NULL_HOTKEY, menu_mail_cmd}
  457. };
  458. static menu_entry OptMenu[] =
  459. {
  460. {' ', N_("&General... "), NULL_HOTKEY, edit_options_dialog},
  461. {' ', N_("&Save mode..."), NULL_HOTKEY, menu_save_mode_cmd},
  462. {' ', N_("Learn &Keys..."), NULL_HOTKEY, learn_keys},
  463. {' ', N_("Syntax &Highlighting..."), NULL_HOTKEY, edit_syntax_dialog},
  464. {' ', "", NULL_HOTKEY, 0},
  465. {' ', N_("S&yntax file"), NULL_HOTKEY, menu_edit_syntax_file_cmd},
  466. {' ', N_("&Menu file"), NULL_HOTKEY, menu_edit_menu_file_cmd},
  467. {' ', "", NULL_HOTKEY, 0},
  468. {' ', N_("Save setu&p"), NULL_HOTKEY, save_setup_cmd}
  469. };
  470. #define OptMenuEmacs OptMenu
  471. #define menu_entries(x) sizeof(x)/sizeof(menu_entry)
  472. #define N_menus 5
  473. static Menu *EditMenuBar [N_menus];
  474. static void
  475. edit_init_menu_normal (void)
  476. {
  477. EditMenuBar[0] = create_menu (_(" File "), FileMenu, menu_entries (FileMenu),
  478. "[Internal File Editor]");
  479. EditMenuBar[1] = create_menu (_(" Edit "), EditMenu, menu_entries (EditMenu),
  480. "[Internal File Editor]");
  481. EditMenuBar[2] = create_menu (_(" Sear/Repl "), SearReplMenu, menu_entries (SearReplMenu),
  482. "[Internal File Editor]");
  483. EditMenuBar[3] = create_menu (_(" Command "), CmdMenu, menu_entries (CmdMenu),
  484. "[Internal File Editor]");
  485. EditMenuBar[4] = create_menu (_(" Options "), OptMenu, menu_entries (OptMenu),
  486. "[Internal File Editor]");
  487. }
  488. static void
  489. edit_init_menu_emacs (void)
  490. {
  491. EditMenuBar[0] = create_menu (_(" File "), FileMenuEmacs, menu_entries (FileMenuEmacs),
  492. "[Internal File Editor]");
  493. EditMenuBar[1] = create_menu (_(" Edit "), EditMenuEmacs, menu_entries (EditMenuEmacs),
  494. "[Internal File Editor]");
  495. EditMenuBar[2] = create_menu (_(" Sear/Repl "), SearReplMenuEmacs, menu_entries (SearReplMenuEmacs),
  496. "[Internal File Editor]");
  497. EditMenuBar[3] = create_menu (_(" Command "), CmdMenuEmacs, menu_entries (CmdMenuEmacs),
  498. "[Internal File Editor]");
  499. EditMenuBar[4] = create_menu (_(" Options "), OptMenuEmacs, menu_entries (OptMenuEmacs),
  500. "[Internal File Editor]");
  501. }
  502. static void
  503. edit_init_menu (void)
  504. {
  505. switch (edit_key_emulation) {
  506. default:
  507. case EDIT_KEY_EMULATION_NORMAL:
  508. edit_init_menu_normal ();
  509. break;
  510. case EDIT_KEY_EMULATION_EMACS:
  511. edit_init_menu_emacs ();
  512. break;
  513. }
  514. }
  515. struct WMenu *
  516. edit_create_menu (void)
  517. {
  518. edit_init_menu ();
  519. return menubar_new (0, 0, COLS, EditMenuBar, N_menus);
  520. }
  521. void
  522. edit_done_menu (struct WMenu *wmenu)
  523. {
  524. int i;
  525. for (i = 0; i < N_menus; i++)
  526. destroy_menu (wmenu->menu[i]);
  527. }
  528. void
  529. edit_reload_menu (void)
  530. {
  531. edit_done_menu (edit_menubar);
  532. edit_init_menu ();
  533. menubar_arrange (edit_menubar);
  534. }
  535. static void
  536. edit_drop_menu_cmd (WEdit *e, int which)
  537. {
  538. if (edit_menubar->active)
  539. return;
  540. edit_menubar->active = 1;
  541. edit_menubar->dropped = drop_menus;
  542. if (which >= 0) {
  543. edit_menubar->selected = which;
  544. }
  545. edit_menubar->previous_widget = e->widget.parent->current->dlg_id;
  546. dlg_select_widget (edit_menubar);
  547. }
  548. void edit_menu_cmd (WEdit * e)
  549. {
  550. edit_drop_menu_cmd (e, -1);
  551. }
  552. int edit_drop_hotkey_menu (WEdit * e, int key)
  553. {
  554. int m = 0;
  555. switch (key) {
  556. case ALT ('f'):
  557. if (edit_key_emulation == EDIT_KEY_EMULATION_EMACS)
  558. return 0;
  559. m = 0;
  560. break;
  561. case ALT ('e'):
  562. m = 1;
  563. break;
  564. case ALT ('s'):
  565. m = 2;
  566. break;
  567. case ALT ('c'):
  568. m = 3;
  569. break;
  570. case ALT ('o'):
  571. m = 4;
  572. break;
  573. default:
  574. return 0;
  575. }
  576. edit_drop_menu_cmd (e, m);
  577. return 1;
  578. }