fixed doxygen.cfg, excluded directory /tests/ from doxygen path's
[midnight-commander.git] / src / editor / editmenu.c
blobc1ea8fa126f4831c67cc5d02a6577d471ea9128a
1 /*
2 Editor menu definitions and initialisation
4 Copyright (C) 1996, 1998, 2001, 2002, 2003, 2005, 2007, 2011
5 The Free Software Foundation, Inc.
7 Written by:
8 Paul Sheer, 1996, 1997
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 /** \file
27 * \brief Source: editor menu definitions and initialisation
28 * \author Paul Sheer
29 * \date 1996, 1997
32 #include <config.h>
34 #include <stdio.h>
35 #include <stdarg.h>
36 #include <sys/types.h>
37 #include <unistd.h>
38 #include <string.h>
39 #include <ctype.h>
40 #include <errno.h>
41 #include <sys/stat.h>
42 #include <stdlib.h>
44 #include "lib/global.h"
46 #include "lib/tty/tty.h" /* KEY_F */
47 #include "lib/tty/key.h" /* XCTRL */
48 #include "lib/widget.h"
50 #include "src/setup.h" /* drop_menus */
51 #include "src/keybind-defaults.h"
53 #include "edit-impl.h"
54 #include "editwidget.h"
56 /*** global variables ****************************************************************************/
58 /*** file scope macro definitions ****************************************************************/
60 /*** file scope type declarations ****************************************************************/
62 /*** file scope variables ************************************************************************/
64 /*** file scope functions ************************************************************************/
65 /* --------------------------------------------------------------------------------------------- */
67 static GList *
68 create_file_menu (void)
70 GList *entries = NULL;
72 entries = g_list_prepend (entries, menu_entry_create (_("&Open file..."), CK_EditFile));
73 entries = g_list_prepend (entries, menu_entry_create (_("&New"), CK_EditNew));
74 entries = g_list_prepend (entries, menu_separator_create ());
75 entries = g_list_prepend (entries, menu_entry_create (_("&Save"), CK_Save));
76 entries = g_list_prepend (entries, menu_entry_create (_("Save &as..."), CK_SaveAs));
77 entries = g_list_prepend (entries, menu_separator_create ());
78 entries = g_list_prepend (entries, menu_entry_create (_("&Insert file..."), CK_InsertFile));
79 entries = g_list_prepend (entries, menu_entry_create (_("Cop&y to file..."), CK_BlockSave));
80 entries = g_list_prepend (entries, menu_separator_create ());
81 entries = g_list_prepend (entries, menu_entry_create (_("&User menu..."), CK_UserMenu));
82 entries = g_list_prepend (entries, menu_separator_create ());
83 entries = g_list_prepend (entries, menu_entry_create (_("A&bout..."), CK_About));
84 entries = g_list_prepend (entries, menu_separator_create ());
85 entries = g_list_prepend (entries, menu_entry_create (_("&Quit"), CK_Quit));
87 return g_list_reverse (entries);
90 /* --------------------------------------------------------------------------------------------- */
92 static GList *
93 create_edit_menu (void)
95 GList *entries = NULL;
97 entries = g_list_prepend (entries, menu_entry_create (_("&Undo"), CK_Undo));
98 entries = g_list_prepend (entries, menu_entry_create (_("&Redo"), CK_Redo));
99 entries = g_list_prepend (entries, menu_separator_create ());
100 entries =
101 g_list_prepend (entries, menu_entry_create (_("&Toggle ins/overw"), CK_InsertOverwrite));
102 entries = g_list_prepend (entries, menu_separator_create ());
103 entries = g_list_prepend (entries, menu_entry_create (_("To&ggle mark"), CK_Mark));
104 entries = g_list_prepend (entries, menu_entry_create (_("&Mark columns"), CK_MarkColumn));
105 entries = g_list_prepend (entries, menu_entry_create (_("Mark &all"), CK_MarkAll));
106 entries = g_list_prepend (entries, menu_entry_create (_("Unmar&k"), CK_Unmark));
107 entries = g_list_prepend (entries, menu_separator_create ());
108 entries = g_list_prepend (entries, menu_entry_create (_("Cop&y"), CK_Copy));
109 entries = g_list_prepend (entries, menu_entry_create (_("Mo&ve"), CK_Move));
110 entries = g_list_prepend (entries, menu_entry_create (_("&Delete"), CK_Remove));
111 entries = g_list_prepend (entries, menu_separator_create ());
112 entries = g_list_prepend (entries, menu_entry_create (_("Co&py to clipfile"), CK_Store));
113 entries = g_list_prepend (entries, menu_entry_create (_("&Cut to clipfile"), CK_Cut));
114 entries = g_list_prepend (entries, menu_entry_create (_("Pa&ste from clipfile"), CK_Paste));
115 entries = g_list_prepend (entries, menu_separator_create ());
116 entries = g_list_prepend (entries, menu_entry_create (_("&Beginning"), CK_Top));
117 entries = g_list_prepend (entries, menu_entry_create (_("&End"), CK_Bottom));
119 return g_list_reverse (entries);
122 /* --------------------------------------------------------------------------------------------- */
124 static GList *
125 create_search_replace_menu (void)
127 GList *entries = NULL;
129 entries = g_list_prepend (entries, menu_entry_create (_("&Search..."), CK_Search));
130 entries = g_list_prepend (entries, menu_entry_create (_("Search &again"), CK_SearchContinue));
131 entries = g_list_prepend (entries, menu_entry_create (_("&Replace..."), CK_Replace));
132 entries = g_list_prepend (entries, menu_separator_create ());
133 entries = g_list_prepend (entries, menu_entry_create (_("&Toggle bookmark"), CK_Bookmark));
134 entries = g_list_prepend (entries, menu_entry_create (_("&Next bookmark"), CK_BookmarkNext));
135 entries = g_list_prepend (entries, menu_entry_create (_("&Prev bookmark"), CK_BookmarkPrev));
136 entries = g_list_prepend (entries, menu_entry_create (_("&Flush bookmarks"), CK_BookmarkFlush));
138 return g_list_reverse (entries);
141 /* --------------------------------------------------------------------------------------------- */
143 static GList *
144 create_command_menu (void)
146 GList *entries = NULL;
148 entries = g_list_prepend (entries, menu_entry_create (_("&Go to line..."), CK_Goto));
149 entries = g_list_prepend (entries, menu_entry_create (_("&Toggle line state"), CK_ShowNumbers));
150 entries =
151 g_list_prepend (entries, menu_entry_create (_("Go to matching &bracket"), CK_MatchBracket));
152 entries =
153 g_list_prepend (entries,
154 menu_entry_create (_("Toggle s&yntax highlighting"), CK_SyntaxOnOff));
155 entries = g_list_prepend (entries, menu_separator_create ());
156 entries = g_list_prepend (entries, menu_entry_create (_("&Find declaration"), CK_Find));
157 entries =
158 g_list_prepend (entries, menu_entry_create (_("Back from &declaration"), CK_FilePrev));
159 entries =
160 g_list_prepend (entries, menu_entry_create (_("For&ward to declaration"), CK_FileNext));
161 #ifdef HAVE_CHARSET
162 entries = g_list_prepend (entries, menu_separator_create ());
163 entries = g_list_prepend (entries, menu_entry_create (_("Encod&ing..."), CK_SelectCodepage));
164 #endif
165 entries = g_list_prepend (entries, menu_separator_create ());
166 entries = g_list_prepend (entries, menu_entry_create (_("&Refresh screen"), CK_Refresh));
167 entries = g_list_prepend (entries, menu_separator_create ());
168 entries =
169 g_list_prepend (entries,
170 menu_entry_create (_("&Start/Stop record macro"), CK_MacroStartStopRecord));
171 entries = g_list_prepend (entries, menu_entry_create (_("Delete macr&o..."), CK_MacroDelete));
172 entries =
173 g_list_prepend (entries,
174 menu_entry_create (_("Record/Repeat &actions"), CK_RepeatStartStopRecord));
175 entries = g_list_prepend (entries, menu_separator_create ());
176 entries =
177 g_list_prepend (entries, menu_entry_create (_("'ispell' s&pell check"), CK_PipeBlock (1)));
178 entries = g_list_prepend (entries, menu_entry_create (_("&Mail..."), CK_Mail));
180 return g_list_reverse (entries);
183 /* --------------------------------------------------------------------------------------------- */
185 static GList *
186 create_format_menu (void)
188 GList *entries = NULL;
190 entries =
191 g_list_prepend (entries, menu_entry_create (_("Insert &literal..."), CK_InsertLiteral));
192 entries = g_list_prepend (entries, menu_entry_create (_("Insert &date/time"), CK_Date));
193 entries = g_list_prepend (entries, menu_separator_create ());
194 entries =
195 g_list_prepend (entries, menu_entry_create (_("&Format paragraph"), CK_ParagraphFormat));
196 entries = g_list_prepend (entries, menu_entry_create (_("&Sort..."), CK_Sort));
197 entries =
198 g_list_prepend (entries, menu_entry_create (_("&Paste output of..."), CK_ExternalCommand));
199 entries =
200 g_list_prepend (entries, menu_entry_create (_("&External formatter"), CK_PipeBlock (0)));
202 return g_list_reverse (entries);
205 /* --------------------------------------------------------------------------------------------- */
207 static GList *
208 create_options_menu (void)
210 GList *entries = NULL;
212 entries = g_list_prepend (entries, menu_entry_create (_("&General..."), CK_Options));
213 entries = g_list_prepend (entries, menu_entry_create (_("Save &mode..."), CK_OptionsSaveMode));
214 entries = g_list_prepend (entries, menu_entry_create (_("Learn &keys..."), CK_LearnKeys));
215 entries =
216 g_list_prepend (entries, menu_entry_create (_("Syntax &highlighting..."), CK_SyntaxChoose));
217 entries = g_list_prepend (entries, menu_separator_create ());
218 entries = g_list_prepend (entries, menu_entry_create (_("S&yntax file"), CK_EditSyntaxFile));
219 entries = g_list_prepend (entries, menu_entry_create (_("&Menu file"), CK_EditUserMenu));
220 entries = g_list_prepend (entries, menu_separator_create ());
221 entries = g_list_prepend (entries, menu_entry_create (_("&Save setup"), CK_SaveSetup));
223 return g_list_reverse (entries);
226 /* --------------------------------------------------------------------------------------------- */
228 static void
229 edit_drop_menu_cmd (WEdit * e, int which)
231 WMenuBar *menubar;
233 menubar = find_menubar (e->widget.owner);
235 if (!menubar->is_active)
237 menubar->is_active = TRUE;
238 menubar->is_dropped = (drop_menus != 0);
239 if (which >= 0)
240 menubar->selected = which;
242 menubar->previous_widget = dlg_get_current_widget_id (e->widget.owner);
243 dlg_select_widget (menubar);
247 /* --------------------------------------------------------------------------------------------- */
248 /*** public functions ****************************************************************************/
249 /* --------------------------------------------------------------------------------------------- */
251 void
252 edit_init_menu (struct WMenuBar *menubar)
254 menubar_add_menu (menubar,
255 create_menu (_("&File"), create_file_menu (), "[Internal File Editor]"));
256 menubar_add_menu (menubar,
257 create_menu (_("&Edit"), create_edit_menu (), "[Internal File Editor]"));
258 menubar_add_menu (menubar,
259 create_menu (_("&Search"), create_search_replace_menu (),
260 "[Internal File Editor]"));
261 menubar_add_menu (menubar,
262 create_menu (_("&Command"), create_command_menu (),
263 "[Internal File Editor]"));
264 menubar_add_menu (menubar,
265 create_menu (_("For&mat"), create_format_menu (), "[Internal File Editor]"));
266 menubar_add_menu (menubar,
267 create_menu (_("&Options"), create_options_menu (),
268 "[Internal File Editor]"));
271 /* --------------------------------------------------------------------------------------------- */
273 void
274 edit_menu_cmd (WEdit * e)
276 edit_drop_menu_cmd (e, -1);
279 /* --------------------------------------------------------------------------------------------- */
281 gboolean
282 edit_drop_hotkey_menu (WEdit * e, int key)
284 int m = 0;
285 switch (key)
287 case ALT ('f'):
288 m = 0;
289 break;
290 case ALT ('e'):
291 m = 1;
292 break;
293 case ALT ('s'):
294 m = 2;
295 break;
296 case ALT ('c'):
297 m = 3;
298 break;
299 case ALT ('m'):
300 m = 4;
301 break;
302 case ALT ('o'):
303 m = 5;
304 break;
305 default:
306 return FALSE;
309 edit_drop_menu_cmd (e, m);
310 return TRUE;
313 /* --------------------------------------------------------------------------------------------- */