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 "lib/global.h"
44 #include "lib/tty/tty.h" /* KEY_F */
45 #include "lib/tty/key.h" /* XCTRL */
46 #include "lib/widget.h"
48 #include "src/setup.h" /* drop_menus */
49 #include "src/keybind-defaults.h"
51 #include "edit-impl.h"
52 #include "edit-widget.h"
54 /*** global variables ****************************************************************************/
56 /*** file scope macro definitions ****************************************************************/
58 /*** file scope type declarations ****************************************************************/
60 /*** file scope variables ************************************************************************/
62 /*** file scope functions ************************************************************************/
63 /* --------------------------------------------------------------------------------------------- */
66 create_file_menu (void)
68 GList
*entries
= NULL
;
70 entries
= g_list_append (entries
, menu_entry_create (_("&Open file..."), CK_Load
));
71 entries
= g_list_append (entries
, menu_entry_create (_("&New"), CK_New
));
72 entries
= g_list_append (entries
, menu_separator_create ());
73 entries
= g_list_append (entries
, menu_entry_create (_("&Save"), CK_Save
));
74 entries
= g_list_append (entries
, menu_entry_create (_("Save &as..."), CK_Save_As
));
75 entries
= g_list_append (entries
, menu_separator_create ());
76 entries
= g_list_append (entries
, menu_entry_create (_("&Insert file..."), CK_Insert_File
));
77 entries
= g_list_append (entries
, menu_entry_create (_("Cop&y to file..."), CK_Save_Block
));
78 entries
= g_list_append (entries
, menu_separator_create ());
79 entries
= g_list_append (entries
, menu_entry_create (_("&User menu..."), CK_User_Menu
));
80 entries
= g_list_append (entries
, menu_separator_create ());
81 entries
= g_list_append (entries
, menu_entry_create (_("A&bout..."), CK_About
));
82 entries
= g_list_append (entries
, menu_separator_create ());
83 entries
= g_list_append (entries
, menu_entry_create (_("&Quit"), CK_Quit
));
88 /* --------------------------------------------------------------------------------------------- */
91 create_edit_menu (void)
93 GList
*entries
= NULL
;
95 entries
= g_list_append (entries
, menu_entry_create (_("&Undo"), CK_Undo
));
96 entries
= g_list_append (entries
, menu_entry_create (_("&Redo"), CK_Redo
));
97 entries
= g_list_append (entries
, menu_separator_create ());
98 entries
= g_list_append (entries
, menu_entry_create (_("&Toggle ins/overw"), CK_Toggle_Insert
));
99 entries
= g_list_append (entries
, menu_separator_create ());
100 entries
= g_list_append (entries
, menu_entry_create (_("To&ggle mark"), CK_Mark
));
101 entries
= g_list_append (entries
, menu_entry_create (_("&Mark columns"), CK_Column_Mark
));
102 entries
= g_list_append (entries
, menu_entry_create (_("Mark &all"), CK_Mark_All
));
103 entries
= g_list_append (entries
, menu_entry_create (_("Unmar&k"), CK_Unmark
));
104 entries
= g_list_append (entries
, menu_separator_create ());
105 entries
= g_list_append (entries
, menu_entry_create (_("Cop&y"), CK_Copy
));
106 entries
= g_list_append (entries
, menu_entry_create (_("Mo&ve"), CK_Move
));
107 entries
= g_list_append (entries
, menu_entry_create (_("&Delete"), CK_Remove
));
108 entries
= g_list_append (entries
, menu_separator_create ());
109 entries
= g_list_append (entries
, menu_entry_create (_("Co&py to clipfile"), CK_XStore
));
110 entries
= g_list_append (entries
, menu_entry_create (_("&Cut to clipfile"), CK_XCut
));
111 entries
= g_list_append (entries
, menu_entry_create (_("Pa&ste from clipfile"), CK_XPaste
));
112 entries
= g_list_append (entries
, menu_separator_create ());
113 entries
= g_list_append (entries
, menu_entry_create (_("&Beginning"), CK_Beginning_Of_Text
));
114 entries
= g_list_append (entries
, menu_entry_create (_("&End"), CK_End_Of_Text
));
119 /* --------------------------------------------------------------------------------------------- */
122 create_search_replace_menu (void)
124 GList
*entries
= NULL
;
126 entries
= g_list_append (entries
, menu_entry_create (_("&Search..."), CK_Find
));
127 entries
= g_list_append (entries
, menu_entry_create (_("Search &again"), CK_Find_Again
));
128 entries
= g_list_append (entries
, menu_entry_create (_("&Replace..."), CK_Replace
));
129 entries
= g_list_append (entries
, menu_separator_create ());
131 g_list_append (entries
, menu_entry_create (_("&Toggle bookmark"), CK_Toggle_Bookmark
));
132 entries
= g_list_append (entries
, menu_entry_create (_("&Next bookmark"), CK_Next_Bookmark
));
133 entries
= g_list_append (entries
, menu_entry_create (_("&Prev bookmark"), CK_Prev_Bookmark
));
134 entries
= g_list_append (entries
, menu_entry_create (_("&Flush bookmark"), CK_Flush_Bookmarks
));
139 /* --------------------------------------------------------------------------------------------- */
142 create_command_menu (void)
144 GList
*entries
= NULL
;
146 entries
= g_list_append (entries
, menu_entry_create (_("&Go to line..."), CK_Goto
));
148 g_list_append (entries
, menu_entry_create (_("&Toggle line state"), CK_Toggle_Line_State
));
150 g_list_append (entries
, menu_entry_create (_("Go to matching &bracket"), CK_Match_Bracket
));
152 g_list_append (entries
,
153 menu_entry_create (_("Toggle s&yntax highlighting"), CK_Toggle_Syntax
));
154 entries
= g_list_append (entries
, menu_separator_create ());
156 g_list_append (entries
, menu_entry_create (_("&Find declaration"), CK_Find_Definition
));
158 g_list_append (entries
, menu_entry_create (_("Back from &declaration"), CK_Load_Prev_File
));
160 g_list_append (entries
,
161 menu_entry_create (_("For&ward to declaration"), CK_Load_Next_File
));
163 entries
= g_list_append (entries
, menu_separator_create ());
164 entries
= g_list_append (entries
, menu_entry_create (_("Encod&ing..."), CK_SelectCodepage
));
166 entries
= g_list_append (entries
, menu_separator_create ());
167 entries
= g_list_append (entries
, menu_entry_create (_("&Refresh screen"), CK_Refresh
));
168 entries
= g_list_append (entries
, menu_separator_create ());
170 g_list_append (entries
,
171 menu_entry_create (_("&Start/Stop record macro"), CK_Begin_End_Macro
));
172 entries
= g_list_append (entries
, menu_entry_create (_("Delete macr&o..."), CK_Delete_Macro
));
173 entries
= g_list_append (entries
, menu_entry_create (_("Record/Repeat &actions"), CK_Begin_End_Repeat
));
174 entries
= g_list_append (entries
, menu_separator_create ());
176 g_list_append (entries
, menu_entry_create (_("'ispell' s&pell check"), CK_Pipe_Block (1)));
177 entries
= g_list_append (entries
, menu_entry_create (_("&Mail..."), CK_Mail
));
182 /* --------------------------------------------------------------------------------------------- */
185 create_format_menu (void)
187 GList
*entries
= NULL
;
190 g_list_append (entries
, menu_entry_create (_("Insert &literal..."), CK_Insert_Literal
));
191 entries
= g_list_append (entries
, menu_entry_create (_("Insert &date/time"), CK_Date
));
192 entries
= g_list_append (entries
, menu_separator_create ());
194 g_list_append (entries
, menu_entry_create (_("&Format paragraph"), CK_Paragraph_Format
));
195 entries
= g_list_append (entries
, menu_entry_create (_("&Sort..."), CK_Sort
));
196 entries
= g_list_append (entries
, menu_entry_create (_("&Paste output of..."), CK_ExtCmd
));
198 g_list_append (entries
, menu_entry_create (_("&External formatter"), CK_Pipe_Block (0)));
203 /* --------------------------------------------------------------------------------------------- */
206 create_options_menu (void)
208 GList
*entries
= NULL
;
210 entries
= g_list_append (entries
, menu_entry_create (_("&General..."), CK_Edit_Options
));
211 entries
= g_list_append (entries
, menu_entry_create (_("Save &mode..."), CK_Edit_Save_Mode
));
212 entries
= g_list_append (entries
, menu_entry_create (_("Learn &keys..."), CK_LearnKeys
));
214 g_list_append (entries
, menu_entry_create (_("Syntax &highlighting..."), CK_Choose_Syntax
));
215 entries
= g_list_append (entries
, menu_separator_create ());
216 entries
= g_list_append (entries
, menu_entry_create (_("S&yntax file"), CK_Load_Syntax_File
));
217 entries
= g_list_append (entries
, menu_entry_create (_("&Menu file"), CK_Load_Menu_File
));
218 entries
= g_list_append (entries
, menu_separator_create ());
219 entries
= g_list_append (entries
, menu_entry_create (_("&Save setup"), CK_SaveSetupCmd
));
224 /* --------------------------------------------------------------------------------------------- */
227 edit_drop_menu_cmd (WEdit
* e
, int which
)
231 menubar
= find_menubar (e
->widget
.owner
);
233 if (!menubar
->is_active
)
235 menubar
->is_active
= TRUE
;
236 menubar
->is_dropped
= (drop_menus
!= 0);
238 menubar
->selected
= which
;
240 menubar
->previous_widget
= dlg_get_current_widget_id (e
->widget
.owner
);
241 dlg_select_widget (menubar
);
245 /* --------------------------------------------------------------------------------------------- */
246 /*** public functions ****************************************************************************/
247 /* --------------------------------------------------------------------------------------------- */
250 edit_init_menu (struct WMenuBar
*menubar
)
252 menubar_add_menu (menubar
,
253 create_menu (_("&File"), create_file_menu (), "[Internal File Editor]"));
254 menubar_add_menu (menubar
,
255 create_menu (_("&Edit"), create_edit_menu (), "[Internal File Editor]"));
256 menubar_add_menu (menubar
,
257 create_menu (_("&Search"), create_search_replace_menu (),
258 "[Internal File Editor]"));
259 menubar_add_menu (menubar
,
260 create_menu (_("&Command"), create_command_menu (),
261 "[Internal File Editor]"));
262 menubar_add_menu (menubar
,
263 create_menu (_("For&mat"), create_format_menu (), "[Internal File Editor]"));
264 menubar_add_menu (menubar
,
265 create_menu (_("&Options"), create_options_menu (),
266 "[Internal File Editor]"));
269 /* --------------------------------------------------------------------------------------------- */
272 edit_menu_cmd (WEdit
* e
)
274 edit_drop_menu_cmd (e
, -1);
277 /* --------------------------------------------------------------------------------------------- */
280 edit_drop_hotkey_menu (WEdit
* e
, int key
)
307 edit_drop_menu_cmd (e
, m
);
311 /* --------------------------------------------------------------------------------------------- */