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 */
47 #include "src/menu.h" /* menu_entry */
48 #include "src/main.h" /* drop_menus */
49 #include "src/dialog.h" /* cb_ret_t */
50 #include "src/cmddef.h"
52 #include "edit-impl.h"
53 #include "edit-widget.h"
56 create_file_menu (void)
58 GList
*entries
= NULL
;
60 entries
= g_list_append (entries
, menu_entry_create (_("&Open file..."), CK_Load
));
61 entries
= g_list_append (entries
, menu_entry_create (_("&New"), CK_New
));
62 entries
= g_list_append (entries
, menu_separator_create ());
63 entries
= g_list_append (entries
, menu_entry_create (_("&Save"), CK_Save
));
64 entries
= g_list_append (entries
, menu_entry_create (_("Save &as..."), CK_Save_As
));
65 entries
= g_list_append (entries
, menu_separator_create ());
66 entries
= g_list_append (entries
, menu_entry_create (_("&Insert file..."), CK_Insert_File
));
67 entries
= g_list_append (entries
, menu_entry_create (_("Cop&y to file..."), CK_Save_Block
));
68 entries
= g_list_append (entries
, menu_separator_create ());
69 entries
= g_list_append (entries
, menu_entry_create (_("&User menu..."), CK_User_Menu
));
70 entries
= g_list_append (entries
, menu_separator_create ());
71 entries
= g_list_append (entries
, menu_entry_create (_("A&bout..."), CK_About
));
72 entries
= g_list_append (entries
, menu_separator_create ());
73 entries
= g_list_append (entries
, menu_entry_create (_("&Quit"), CK_Quit
));
79 create_edit_menu (void)
81 GList
*entries
= NULL
;
83 entries
= g_list_append (entries
, menu_entry_create (_("&Undo"), CK_Undo
));
84 entries
= g_list_append (entries
, menu_separator_create ());
85 entries
= g_list_append (entries
, menu_entry_create (_("&Toggle ins/overw"), CK_Toggle_Insert
));
86 entries
= g_list_append (entries
, menu_separator_create ());
87 entries
= g_list_append (entries
, menu_entry_create (_("To&ggle mark"), CK_Mark
));
88 entries
= g_list_append (entries
, menu_entry_create (_("&Mark columns"), CK_Column_Mark
));
89 entries
= g_list_append (entries
, menu_entry_create (_("Mark &all"), CK_Mark_All
));
90 entries
= g_list_append (entries
, menu_entry_create (_("Unmar&k"), CK_Unmark
));
91 entries
= g_list_append (entries
, menu_separator_create ());
92 entries
= g_list_append (entries
, menu_entry_create (_("Cop&y"), CK_Copy
));
93 entries
= g_list_append (entries
, menu_entry_create (_("Mo&ve"), CK_Move
));
94 entries
= g_list_append (entries
, menu_entry_create (_("&Delete"), CK_Remove
));
95 entries
= g_list_append (entries
, menu_separator_create ());
96 entries
= g_list_append (entries
, menu_entry_create (_("Co&py to clipfile"), CK_XStore
));
97 entries
= g_list_append (entries
, menu_entry_create (_("&Cut to clipfile"), CK_XCut
));
98 entries
= g_list_append (entries
, menu_entry_create (_("Pa&ste from clipfile"), CK_XPaste
));
99 entries
= g_list_append (entries
, menu_separator_create ());
100 entries
= g_list_append (entries
, menu_entry_create (_("&Beginning"), CK_Beginning_Of_Text
));
101 entries
= g_list_append (entries
, menu_entry_create (_("&End"), CK_End_Of_Text
));
107 create_search_replace_menu (void)
109 GList
*entries
= NULL
;
111 entries
= g_list_append (entries
, menu_entry_create (_("&Search..."), CK_Find
));
112 entries
= g_list_append (entries
, menu_entry_create (_("Search &again"), CK_Find_Again
));
113 entries
= g_list_append (entries
, menu_entry_create (_("&Replace..."), CK_Replace
));
114 entries
= g_list_append (entries
, menu_separator_create ());
115 entries
= g_list_append (entries
, menu_entry_create (_("&Toggle bookmark"), CK_Toggle_Bookmark
));
116 entries
= g_list_append (entries
, menu_entry_create (_("&Next bookmark"), CK_Next_Bookmark
));
117 entries
= g_list_append (entries
, menu_entry_create (_("&Prev bookmark"), CK_Prev_Bookmark
));
118 entries
= g_list_append (entries
, menu_entry_create (_("&Flush bookmark"), CK_Flush_Bookmarks
));
124 create_command_menu (void)
126 GList
*entries
= NULL
;
128 entries
= g_list_append (entries
, menu_entry_create (_("&Go to line..."), CK_Goto
));
129 entries
= g_list_append (entries
, menu_entry_create (_("&Toggle line state"), CK_Toggle_Line_State
));
130 entries
= g_list_append (entries
, menu_entry_create (_("Go to matching &bracket"), CK_Match_Bracket
));
131 entries
= g_list_append (entries
, menu_separator_create ());
132 entries
= g_list_append (entries
, menu_entry_create (_("&Find declaration"), CK_Find_Definition
));
133 entries
= g_list_append (entries
, menu_entry_create (_("Back from &declaration"), CK_Load_Prev_File
));
134 entries
= g_list_append (entries
, menu_entry_create (_("For&ward to declaration"), CK_Load_Next_File
));
136 entries
= g_list_append (entries
, menu_separator_create ());
137 entries
= g_list_append (entries
, menu_entry_create (_("Encod&ing..."), CK_SelectCodepage
));
139 entries
= g_list_append (entries
, menu_separator_create ());
140 entries
= g_list_append (entries
, menu_entry_create (_("&Refresh screen"), CK_Refresh
));
141 entries
= g_list_append (entries
, menu_separator_create ());
142 entries
= g_list_append (entries
, menu_entry_create (_("&Start record macro"), CK_Begin_Record_Macro
));
143 entries
= g_list_append (entries
, menu_entry_create (_("Finis&h record macro..."), CK_End_Record_Macro
));
144 entries
= g_list_append (entries
, menu_entry_create (_("&Execute macro..."), CK_Execute_Macro
));
145 entries
= g_list_append (entries
, menu_entry_create (_("Delete macr&o..."), CK_Delete_Macro
));
146 entries
= g_list_append (entries
, menu_separator_create ());
147 entries
= g_list_append (entries
, menu_entry_create (_("'ispell' s&pell check"), CK_Pipe_Block (1)));
148 entries
= g_list_append (entries
, menu_entry_create (_("&Mail..."), CK_Mail
));
154 create_format_menu (void)
156 GList
*entries
= NULL
;
158 entries
= g_list_append (entries
, menu_entry_create (_("Insert &literal..."), CK_Insert_Literal
));
159 entries
= g_list_append (entries
, menu_entry_create (_("Insert &date/time"), CK_Date
));
160 entries
= g_list_append (entries
, menu_separator_create ());
161 entries
= g_list_append (entries
, menu_entry_create (_("&Format paragraph"), CK_Paragraph_Format
));
162 entries
= g_list_append (entries
, menu_entry_create (_("&Sort..."), CK_Sort
));
163 entries
= g_list_append (entries
, menu_entry_create (_("&Paste output of..."), CK_ExtCmd
));
164 entries
= g_list_append (entries
, menu_entry_create (_("&External formatter"), CK_Pipe_Block (0)));
170 create_options_menu (void)
172 GList
*entries
= NULL
;
174 entries
= g_list_append (entries
, menu_entry_create (_("&General... "), CK_Edit_Options
));
175 entries
= g_list_append (entries
, menu_entry_create (_("Save &mode..."), CK_Edit_Save_Mode
));
176 entries
= g_list_append (entries
, menu_entry_create (_("Learn &keys..."), CK_LearnKeys
));
177 entries
= g_list_append (entries
, menu_entry_create (_("Syntax &highlighting..."), CK_Choose_Syntax
));
178 entries
= g_list_append (entries
, menu_separator_create ());
179 entries
= g_list_append (entries
, menu_entry_create (_("S&yntax file"), CK_Load_Syntax_File
));
180 entries
= g_list_append (entries
, menu_entry_create (_("&Menu file"), CK_Load_Menu_File
));
181 entries
= g_list_append (entries
, menu_separator_create ());
182 entries
= g_list_append (entries
, menu_entry_create (_("&Save setup"), CK_SaveSetupCmd
));
188 edit_init_menu (struct WMenuBar
*menubar
)
190 menubar_add_menu (menubar
, create_menu (_("&File"), create_file_menu (), "[Internal File Editor]"));
191 menubar_add_menu (menubar
, create_menu (_("&Edit"), create_edit_menu (), "[Internal File Editor]"));
192 menubar_add_menu (menubar
, create_menu (_("&Search"), create_search_replace_menu (), "[Internal File Editor]"));
193 menubar_add_menu (menubar
, create_menu (_("&Command"), create_command_menu (), "[Internal File Editor]"));
194 menubar_add_menu (menubar
, create_menu (_("For&mat"), create_format_menu (), "[Internal File Editor]"));
195 menubar_add_menu (menubar
, create_menu (_("&Options"), create_options_menu (), "[Internal File Editor]"));
199 edit_drop_menu_cmd (WEdit
*e
, int which
)
201 if (!edit_menubar
->is_active
) {
202 edit_menubar
->is_active
= TRUE
;
203 edit_menubar
->is_dropped
= (drop_menus
!= 0);
205 edit_menubar
->selected
= which
;
207 edit_menubar
->previous_widget
= e
->widget
.parent
->current
->dlg_id
;
208 dlg_select_widget (edit_menubar
);
213 edit_menu_cmd (WEdit
*e
)
215 edit_drop_menu_cmd (e
, -1);
219 edit_drop_hotkey_menu (WEdit
*e
, int key
)
245 edit_drop_menu_cmd (e
, m
);