2 Editor menu definitions and initialisation
4 Copyright (C) 1996-2024
5 Free Software Foundation, Inc.
9 Andrew Borodin <aborodin@vmail.ru> 2012
11 This file is part of the Midnight Commander.
13 The Midnight Commander is free software: you can redistribute it
14 and/or modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
18 The Midnight Commander is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>.
28 * \brief Source: editor menu definitions and initialisation
37 #include <sys/types.h>
44 #include "lib/global.h"
46 #include "lib/tty/key.h" /* ALT */
47 #include "lib/widget.h"
49 #include "src/setup.h" /* drop_menus */
51 #include "edit-impl.h"
52 #include "editwidget.h"
54 /*** global variables ****************************************************************************/
56 /*** file scope macro definitions ****************************************************************/
58 /*** file scope type declarations ****************************************************************/
60 /*** forward declarations (file scope functions) *************************************************/
62 /*** file scope variables ************************************************************************/
64 /* --------------------------------------------------------------------------------------------- */
65 /*** file scope functions ************************************************************************/
66 /* --------------------------------------------------------------------------------------------- */
69 create_file_menu (void)
71 GList
*entries
= NULL
;
73 entries
= g_list_prepend (entries
, menu_entry_new (_("&Open file..."), CK_EditFile
));
74 entries
= g_list_prepend (entries
, menu_entry_new (_("&New"), CK_EditNew
));
75 entries
= g_list_prepend (entries
, menu_entry_new (_("&Close"), CK_Close
));
76 entries
= g_list_prepend (entries
, menu_entry_new (_("&History..."), CK_History
));
77 entries
= g_list_prepend (entries
, menu_separator_new ());
78 entries
= g_list_prepend (entries
, menu_entry_new (_("&Save"), CK_Save
));
79 entries
= g_list_prepend (entries
, menu_entry_new (_("Save &as..."), CK_SaveAs
));
80 entries
= g_list_prepend (entries
, menu_separator_new ());
81 entries
= g_list_prepend (entries
, menu_entry_new (_("&Insert file..."), CK_InsertFile
));
82 entries
= g_list_prepend (entries
, menu_entry_new (_("Cop&y to file..."), CK_BlockSave
));
83 entries
= g_list_prepend (entries
, menu_separator_new ());
84 entries
= g_list_prepend (entries
, menu_entry_new (_("&User menu..."), CK_UserMenu
));
85 entries
= g_list_prepend (entries
, menu_separator_new ());
86 entries
= g_list_prepend (entries
, menu_entry_new (_("A&bout..."), CK_About
));
87 entries
= g_list_prepend (entries
, menu_separator_new ());
88 entries
= g_list_prepend (entries
, menu_entry_new (_("&Quit"), CK_Quit
));
90 return g_list_reverse (entries
);
93 /* --------------------------------------------------------------------------------------------- */
96 create_edit_menu (void)
98 GList
*entries
= NULL
;
100 entries
= g_list_prepend (entries
, menu_entry_new (_("&Undo"), CK_Undo
));
101 entries
= g_list_prepend (entries
, menu_entry_new (_("&Redo"), CK_Redo
));
102 entries
= g_list_prepend (entries
, menu_separator_new ());
103 entries
= g_list_prepend (entries
, menu_entry_new (_("&Toggle ins/overw"), CK_InsertOverwrite
));
104 entries
= g_list_prepend (entries
, menu_separator_new ());
105 entries
= g_list_prepend (entries
, menu_entry_new (_("To&ggle mark"), CK_Mark
));
106 entries
= g_list_prepend (entries
, menu_entry_new (_("&Mark columns"), CK_MarkColumn
));
107 entries
= g_list_prepend (entries
, menu_entry_new (_("Mark &all"), CK_MarkAll
));
108 entries
= g_list_prepend (entries
, menu_entry_new (_("Unmar&k"), CK_Unmark
));
109 entries
= g_list_prepend (entries
, menu_separator_new ());
110 entries
= g_list_prepend (entries
, menu_entry_new (_("Cop&y"), CK_Copy
));
111 entries
= g_list_prepend (entries
, menu_entry_new (_("Mo&ve"), CK_Move
));
112 entries
= g_list_prepend (entries
, menu_entry_new (_("&Delete"), CK_Remove
));
113 entries
= g_list_prepend (entries
, menu_separator_new ());
114 entries
= g_list_prepend (entries
, menu_entry_new (_("Co&py to clipfile"), CK_Store
));
115 entries
= g_list_prepend (entries
, menu_entry_new (_("&Cut to clipfile"), CK_Cut
));
116 entries
= g_list_prepend (entries
, menu_entry_new (_("Pa&ste from clipfile"), CK_Paste
));
117 entries
= g_list_prepend (entries
, menu_separator_new ());
118 entries
= g_list_prepend (entries
, menu_entry_new (_("&Beginning"), CK_Top
));
119 entries
= g_list_prepend (entries
, menu_entry_new (_("&End"), CK_Bottom
));
121 return g_list_reverse (entries
);
124 /* --------------------------------------------------------------------------------------------- */
127 create_search_replace_menu (void)
129 GList
*entries
= NULL
;
131 entries
= g_list_prepend (entries
, menu_entry_new (_("&Search..."), CK_Search
));
132 entries
= g_list_prepend (entries
, menu_entry_new (_("Search &again"), CK_SearchContinue
));
133 entries
= g_list_prepend (entries
, menu_entry_new (_("&Replace..."), CK_Replace
));
134 entries
= g_list_prepend (entries
, menu_separator_new ());
135 entries
= g_list_prepend (entries
, menu_entry_new (_("&Toggle bookmark"), CK_Bookmark
));
136 entries
= g_list_prepend (entries
, menu_entry_new (_("&Next bookmark"), CK_BookmarkNext
));
137 entries
= g_list_prepend (entries
, menu_entry_new (_("&Prev bookmark"), CK_BookmarkPrev
));
138 entries
= g_list_prepend (entries
, menu_entry_new (_("&Flush bookmarks"), CK_BookmarkFlush
));
140 return g_list_reverse (entries
);
143 /* --------------------------------------------------------------------------------------------- */
146 create_command_menu (void)
148 GList
*entries
= NULL
;
150 entries
= g_list_prepend (entries
, menu_entry_new (_("&Go to line..."), CK_Goto
));
151 entries
= g_list_prepend (entries
, menu_entry_new (_("&Toggle line state"), CK_ShowNumbers
));
153 g_list_prepend (entries
, menu_entry_new (_("Go to matching &bracket"), CK_MatchBracket
));
155 g_list_prepend (entries
, menu_entry_new (_("Toggle s&yntax highlighting"), CK_SyntaxOnOff
));
156 entries
= g_list_prepend (entries
, menu_separator_new ());
157 entries
= g_list_prepend (entries
, menu_entry_new (_("&Find declaration"), CK_Find
));
158 entries
= g_list_prepend (entries
, menu_entry_new (_("Back from &declaration"), CK_FilePrev
));
159 entries
= g_list_prepend (entries
, menu_entry_new (_("For&ward to declaration"), CK_FileNext
));
161 entries
= g_list_prepend (entries
, menu_separator_new ());
162 entries
= g_list_prepend (entries
, menu_entry_new (_("Encod&ing..."), CK_SelectCodepage
));
164 entries
= g_list_prepend (entries
, menu_separator_new ());
165 entries
= g_list_prepend (entries
, menu_entry_new (_("&Refresh screen"), CK_Refresh
));
166 entries
= g_list_prepend (entries
, menu_separator_new ());
168 g_list_prepend (entries
,
169 menu_entry_new (_("&Start/Stop record macro"), CK_MacroStartStopRecord
));
170 entries
= g_list_prepend (entries
, menu_entry_new (_("Delete macr&o..."), CK_MacroDelete
));
172 g_list_prepend (entries
,
173 menu_entry_new (_("Record/Repeat &actions"), CK_RepeatStartStopRecord
));
174 entries
= g_list_prepend (entries
, menu_separator_new ());
176 if (strcmp (spell_language
, "NONE") != 0)
178 entries
= g_list_prepend (entries
, menu_entry_new (_("S&pell check"), CK_SpellCheck
));
180 g_list_prepend (entries
, menu_entry_new (_("C&heck word"), CK_SpellCheckCurrentWord
));
182 g_list_prepend (entries
,
183 menu_entry_new (_("Change spelling &language..."),
184 CK_SpellCheckSelectLang
));
185 entries
= g_list_prepend (entries
, menu_separator_new ());
187 #endif /* HAVE_ASPELL */
188 entries
= g_list_prepend (entries
, menu_entry_new (_("&Mail..."), CK_EditMail
));
191 return g_list_reverse (entries
);
194 /* --------------------------------------------------------------------------------------------- */
197 create_format_menu (void)
199 GList
*entries
= NULL
;
201 entries
= g_list_prepend (entries
, menu_entry_new (_("Insert &literal..."), CK_InsertLiteral
));
202 entries
= g_list_prepend (entries
, menu_entry_new (_("Insert &date/time"), CK_Date
));
203 entries
= g_list_prepend (entries
, menu_separator_new ());
204 entries
= g_list_prepend (entries
, menu_entry_new (_("&Format paragraph"), CK_ParagraphFormat
));
205 entries
= g_list_prepend (entries
, menu_entry_new (_("&Sort..."), CK_Sort
));
207 g_list_prepend (entries
, menu_entry_new (_("&Paste output of..."), CK_ExternalCommand
));
208 entries
= g_list_prepend (entries
, menu_entry_new (_("&External formatter"), CK_PipeBlock (0)));
210 return g_list_reverse (entries
);
213 /* --------------------------------------------------------------------------------------------- */
215 * Create the 'window' popup menu
219 create_window_menu (void)
221 GList
*entries
= NULL
;
223 entries
= g_list_prepend (entries
, menu_entry_new (_("&Move"), CK_WindowMove
));
224 entries
= g_list_prepend (entries
, menu_entry_new (_("&Resize"), CK_WindowResize
));
226 g_list_prepend (entries
, menu_entry_new (_("&Toggle fullscreen"), CK_WindowFullscreen
));
227 entries
= g_list_prepend (entries
, menu_separator_new ());
228 entries
= g_list_prepend (entries
, menu_entry_new (_("&Next"), CK_WindowNext
));
229 entries
= g_list_prepend (entries
, menu_entry_new (_("&Previous"), CK_WindowPrev
));
230 entries
= g_list_prepend (entries
, menu_entry_new (_("&List..."), CK_WindowList
));
232 return g_list_reverse (entries
);
235 /* --------------------------------------------------------------------------------------------- */
238 create_options_menu (void)
240 GList
*entries
= NULL
;
242 entries
= g_list_prepend (entries
, menu_entry_new (_("&General..."), CK_Options
));
243 entries
= g_list_prepend (entries
, menu_entry_new (_("Save &mode..."), CK_OptionsSaveMode
));
244 entries
= g_list_prepend (entries
, menu_entry_new (_("Learn &keys..."), CK_LearnKeys
));
246 g_list_prepend (entries
, menu_entry_new (_("Syntax &highlighting..."), CK_SyntaxChoose
));
247 entries
= g_list_prepend (entries
, menu_separator_new ());
248 entries
= g_list_prepend (entries
, menu_entry_new (_("S&yntax file"), CK_EditSyntaxFile
));
249 entries
= g_list_prepend (entries
, menu_entry_new (_("&Menu file"), CK_EditUserMenu
));
250 entries
= g_list_prepend (entries
, menu_separator_new ());
251 entries
= g_list_prepend (entries
, menu_entry_new (_("&Save setup"), CK_SaveSetup
));
253 return g_list_reverse (entries
);
256 /* --------------------------------------------------------------------------------------------- */
259 edit_drop_menu_cmd (WDialog
* h
, int which
)
263 menubar
= menubar_find (h
);
264 menubar_activate (menubar
, drop_menus
, which
);
267 /* --------------------------------------------------------------------------------------------- */
268 /*** public functions ****************************************************************************/
269 /* --------------------------------------------------------------------------------------------- */
272 edit_init_menu (WMenuBar
* menubar
)
274 menubar_add_menu (menubar
,
275 menu_new (_("&File"), create_file_menu (), "[Internal File Editor]"));
276 menubar_add_menu (menubar
,
277 menu_new (_("&Edit"), create_edit_menu (), "[Internal File Editor]"));
278 menubar_add_menu (menubar
,
279 menu_new (_("&Search"), create_search_replace_menu (),
280 "[Internal File Editor]"));
281 menubar_add_menu (menubar
,
282 menu_new (_("&Command"), create_command_menu (), "[Internal File Editor]"));
283 menubar_add_menu (menubar
,
284 menu_new (_("For&mat"), create_format_menu (), "[Internal File Editor]"));
285 menubar_add_menu (menubar
,
286 menu_new (_("&Window"), create_window_menu (), "[Internal File Editor]"));
287 menubar_add_menu (menubar
,
288 menu_new (_("&Options"), create_options_menu (), "[Internal File Editor]"));
291 /* --------------------------------------------------------------------------------------------- */
294 edit_menu_cmd (WDialog
* h
)
296 edit_drop_menu_cmd (h
, -1);
299 /* --------------------------------------------------------------------------------------------- */
302 edit_drop_hotkey_menu (WDialog
* h
, int key
)
332 edit_drop_menu_cmd (h
, m
);
336 /* --------------------------------------------------------------------------------------------- */