1 /* we_menue.c */
2 /* Copyright (C) 1993 Fred Kruse */
3 /* This is free software; you can redistribute it and/or */
4 /* modify it under the terms of the */
5 /* GNU General Public License, see the file COPYING. */
6
7 #include "messages.h"
8 #include "edit.h"
9
10 int e_p_show_messages(FENSTER *f);
11 int e_p_show_watches(FENSTER *f);
12 int e_blck_gt_beg(FENSTER *f);
13 int e_blck_gt_end(FENSTER *f);
14 int e_blck_mrk_line(FENSTER *f);
15 int e_blck_mrk_all(FENSTER *f);
16 int e_blck_to_left(FENSTER *f);
17 int e_blck_to_right(FENSTER *f);
18 int e_cl_project(FENSTER *f);
19 int e_p_add_item(FENSTER *f);
20 int e_p_del_item(FENSTER *f);
21 int e_show_project(FENSTER *f);
22 int e_info(FENSTER *f);
23 int e_help_options(FENSTER *f);
24 int e_hp_ret(FENSTER *f);
25 int e_hp_back(FENSTER *f);
26 int e_hp_prev(FENSTER *f);
27 int e_hp_next(FENSTER *f);
28
29 /* main menu control bar */
WpeHandleMainmenu(int n,FENSTER * f)30 int WpeHandleMainmenu(int n, FENSTER *f)
31 {
32 extern int e_mn_men;
33 int i, c = 255, nold = n <= 0 ? 1 : n - 1;
34 extern OPT opt[];
35 extern char *e_hlp, *e_hlp_str[];
36 ECNT *cn = f->ed;
37 MENU *mainmenu = MALLOC(MENOPT * sizeof(MENU));
38
39 for(i = 0; i < MENOPT; i++)
40 mainmenu[i].width = 0;
41 fk_cursor(0);
42 if(n < 0)
43 n = 0;
44 else
45 c = WPE_CR;
46 #ifdef UNIX
47 #ifdef NEWSTYLE
48 if(WpeIsXwin())
49 mainmenu[0].position = -3;
50 else
51 #endif
52 mainmenu[0].position = -2;
53 mainmenu[0].no_of_items = 6;
54 mainmenu[0].width = 23;
55 #else
56 mainmenu[0].position = -3;
57 mainmenu[0].no_of_items = 4;
58 mainmenu[0].width = 20;
59 #endif
60 if((mainmenu[0].menuitems = MALLOC(mainmenu[0].no_of_items * sizeof(OPTK))) == NULL)
61 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
62 mainmenu[0].menuitems[0] = WpeFillSubmenuItem("About WE", 0, 'A', e_about_WE);
63 mainmenu[0].menuitems[1] = WpeFillSubmenuItem("Clear Desktop", 0, 'C', e_clear_desk);
64 mainmenu[0].menuitems[2] = WpeFillSubmenuItem("Repaint Desktop", 0, 'R', e_repaint_desk);
65 mainmenu[0].menuitems[3] = WpeFillSubmenuItem("System Info", 0, 'S', e_sys_info);
66 #ifdef UNIX
67 mainmenu[0].menuitems[4] = WpeFillSubmenuItem("Show Wastebasket", 5, 'W', WpeShowWastebasket);
68 mainmenu[0].menuitems[5] = WpeFillSubmenuItem("Delete Wastebasket", 0, 'D', WpeDelWastebasket);
69 #endif
70 mainmenu[1].position = -3;
71 #ifdef UNIX
72 mainmenu[1].width = 24;
73 mainmenu[1].no_of_items = 11;
74 if((mainmenu[1].menuitems = MALLOC(mainmenu[1].no_of_items * sizeof(OPTK))) == NULL)
75 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
76 if(f->ed->edopt & ED_CUA_STYLE)
77 {
78 mainmenu[1].menuitems[0] = WpeFillSubmenuItem("File-Manager F2", 0, 'M', WpeManager);
79 mainmenu[1].menuitems[2] = WpeFillSubmenuItem("Save Alt F2", 0, 'S', e_m_save);
80 mainmenu[1].menuitems[10] = WpeFillSubmenuItem("Quit Alt F4", 0, 'Q', e_quit);
81 }
82 else
83 {
84 mainmenu[1].menuitems[0] = WpeFillSubmenuItem("File-Manager F3", 0, 'M', WpeManager);
85 mainmenu[1].menuitems[2] = WpeFillSubmenuItem("Save F2", 0, 'S', e_m_save);
86 mainmenu[1].menuitems[10] = WpeFillSubmenuItem("Quit Alt X", 0, 'Q', e_quit);
87 }
88 mainmenu[1].menuitems[1] = WpeFillSubmenuItem("New", 0, 'N', e_new);
89 mainmenu[1].menuitems[3] = WpeFillSubmenuItem("Save As", 5, 'A', WpeSaveAsManager);
90 mainmenu[1].menuitems[4] = WpeFillSubmenuItem("Save aLl", 6, 'L', e_saveall);
91 mainmenu[1].menuitems[5] = WpeFillSubmenuItem("Execute", 0, 'E', WpeExecuteManager);
92 mainmenu[1].menuitems[6] = WpeFillSubmenuItem("SHell", 1, 'H', WpeShell);
93 mainmenu[1].menuitems[7] = WpeFillSubmenuItem("Find", 0, 'F', WpeFindWindow);
94 mainmenu[1].menuitems[8] = WpeFillSubmenuItem("Grep", 0, 'G', WpeGrepWindow);
95 mainmenu[1].menuitems[9] = WpeFillSubmenuItem("Print File", 0, 'P', WpePrintFile);
96 #endif
97 mainmenu[2].position = -3;
98 mainmenu[2].width = 27;
99 #if !defined(NO_XWINDOWS) && !defined(DJGPP)
100 if(WpeIsXwin())
101 mainmenu[2].no_of_items = 9;
102 else
103 #endif
104 mainmenu[2].no_of_items = 7;
105 if((mainmenu[2].menuitems = MALLOC(mainmenu[2].no_of_items * sizeof(OPTK))) == NULL)
106 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
107 mainmenu[2].menuitems[0] = WpeFillSubmenuItem("Cut Shift Del / ^X", 2, 'T', e_edt_del);
108 mainmenu[2].menuitems[1] = WpeFillSubmenuItem("Copy ^Ins / ^C", 0, 'C', e_edt_copy);
109 mainmenu[2].menuitems[2] = WpeFillSubmenuItem("Paste Shift Ins / ^V", 0, 'P', e_edt_einf);
110 mainmenu[2].menuitems[3] = WpeFillSubmenuItem("Show Buffer ^W", 0, 'S', e_show_clipboard);
111 mainmenu[2].menuitems[4] = WpeFillSubmenuItem("Delete ^Del", 0, 'D', e_blck_del);
112 mainmenu[2].menuitems[5] = WpeFillSubmenuItem("Undo ^U", 0, 'U', e_make_undo);
113 mainmenu[2].menuitems[6] = WpeFillSubmenuItem("Redo ^R", 0, 'R', e_make_redo);
114 #ifndef NO_XWINDOWS
115 if(WpeIsXwin())
116 {
117 mainmenu[2].menuitems[7] = WpeFillSubmenuItem("PAste(XBuffer) Alt Ins", 0, 'A', e_u_copy_X_buffer);
118 mainmenu[2].menuitems[8] = WpeFillSubmenuItem("COpy(XBuffer) Alt Del", 0, 'O', e_u_paste_X_buffer);
119 }
120 #endif
121 mainmenu[3].position = -3;
122 mainmenu[3].width = 28;
123 mainmenu[3].no_of_items = 4;
124 if((mainmenu[3].menuitems = MALLOC(mainmenu[3].no_of_items * sizeof(OPTK))) == NULL)
125 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
126 if(f->ed->edopt & ED_CUA_STYLE)
127 {
128 mainmenu[3].menuitems[0] = WpeFillSubmenuItem("Find Alt F3 / ^O F", 0, 'F', e_find);
129 mainmenu[3].menuitems[1] = WpeFillSubmenuItem("Replace Shift F3 / ^O A", 0, 'R', e_replace);
130 mainmenu[3].menuitems[2] = WpeFillSubmenuItem("Search again F3", 0, 'S', e_rep_search);
131 }
132 else
133 {
134 mainmenu[3].menuitems[0] = WpeFillSubmenuItem("Find F4 / ^O F", 0, 'F', e_find);
135 mainmenu[3].menuitems[1] = WpeFillSubmenuItem("Replace Alt F4 / ^O A", 0, 'R', e_replace);
136 mainmenu[3].menuitems[2] = WpeFillSubmenuItem("Search again ^L", 0, 'S', e_rep_search);
137 }
138 mainmenu[3].menuitems[3] = WpeFillSubmenuItem("Go to Line Alt G", 0, 'G', e_goto_line);
139 mainmenu[4].position = -3;
140 mainmenu[4].width = 25;
141 mainmenu[4].no_of_items = 15;
142 if((mainmenu[4].menuitems = MALLOC(mainmenu[4].no_of_items * sizeof(OPTK))) == NULL)
143 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
144 mainmenu[4].menuitems[0] = WpeFillSubmenuItem("Begin Mark ^K B", 0, 'B', e_blck_begin);
145 mainmenu[4].menuitems[1] = WpeFillSubmenuItem("End Mark ^K K", 0, 'E', e_blck_end);
146 mainmenu[4].menuitems[2] = WpeFillSubmenuItem("Mark WhOle ^K X", 7, 'O', e_blck_mrk_all);
147 mainmenu[4].menuitems[3] = WpeFillSubmenuItem("Mark Line ^K L", 5, 'L', e_blck_mrk_line);
148 mainmenu[4].menuitems[4] = WpeFillSubmenuItem("Goto Begin ^K A", 0, 'G', e_blck_gt_beg);
149 mainmenu[4].menuitems[5] = WpeFillSubmenuItem("Goto ENd ^K Z", 6, 'N', e_blck_gt_end);
150 mainmenu[4].menuitems[6] = WpeFillSubmenuItem("Copy ^K C", 0, 'C', e_blck_copy);
151 mainmenu[4].menuitems[7] = WpeFillSubmenuItem("Move ^K V", 0, 'M', e_blck_move);
152 mainmenu[4].menuitems[8] = WpeFillSubmenuItem("Delete ^K Y", 0, 'D', e_blck_del);
153 mainmenu[4].menuitems[9] = WpeFillSubmenuItem("Hide ^K H", 0, 'H', e_blck_hide);
154 mainmenu[4].menuitems[10] = WpeFillSubmenuItem("Read ^K R", 0, 'R', e_blck_read);
155 mainmenu[4].menuitems[11] = WpeFillSubmenuItem("Write ^K W", 0, 'W', e_blck_write);
156 mainmenu[4].menuitems[12] = WpeFillSubmenuItem("Move to RIght ^K I", 9, 'I', e_blck_to_right);
157 mainmenu[4].menuitems[13] = WpeFillSubmenuItem("Move to LefT ^K U", 11, 'T', e_blck_to_left);
158 mainmenu[4].menuitems[14] = WpeFillSubmenuItem("ChAnge Case ^K D", 2, 'A', e_changecase_dialog);
159 #ifdef PROG
160 if(WpeIsProg())
161 {
162 mainmenu[5].position = -3;
163 mainmenu[5].width = 35;
164 mainmenu[5].no_of_items = 12;
165 if((mainmenu[5].menuitems = MALLOC(mainmenu[5].no_of_items * sizeof(OPTK))) == NULL)
166 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
167 mainmenu[5].menuitems[0] = WpeFillSubmenuItem("Compile Alt F9 / Alt C", 0, 'C', e_compile);
168 mainmenu[5].menuitems[1] = WpeFillSubmenuItem("Make F9 / Alt M", 0, 'M', e_p_make);
169 mainmenu[5].menuitems[2] = WpeFillSubmenuItem("Run ^F9 / Alt U", 0, 'R', e_run);
170 mainmenu[5].menuitems[3] = WpeFillSubmenuItem("Install Alt L", 0, 'I', e_install);
171 mainmenu[5].menuitems[4] = WpeFillSubmenuItem("Execute Make Alt A", 0, 'E', e_exec_make);
172 mainmenu[5].menuitems[5] = WpeFillSubmenuItem("Next Error Alt F8 / Alt T", 0, 'N', e_next_error);
173 mainmenu[5].menuitems[6] = WpeFillSubmenuItem("Previous Error Alt F7 / Alt V", 0, 'P', e_previous_error);
174 mainmenu[5].menuitems[7] = WpeFillSubmenuItem("Show Definition ^O S", 0, 'S', e_sh_def);
175 mainmenu[5].menuitems[8] = WpeFillSubmenuItem("Show NeXt Definition ^O N", 7, 'X', e_sh_nxt_def);
176 mainmenu[5].menuitems[9] = WpeFillSubmenuItem("Matching BracKet ^O K", 13, 'K', e_nxt_brk);
177 mainmenu[5].menuitems[10] = WpeFillSubmenuItem("Beautify ^O B", 0, 'B', e_p_beautify);
178 mainmenu[5].menuitems[11] = WpeFillSubmenuItem("Arguments ", 0, 'A', e_arguments);
179
180 mainmenu[MENOPT - 4].position = -3;
181 mainmenu[MENOPT - 4].width = 23;
182 mainmenu[MENOPT - 4].no_of_items = 5;
183 if((mainmenu[MENOPT - 4].menuitems = MALLOC(mainmenu[MENOPT - 4].no_of_items * sizeof(OPTK))) == NULL)
184 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
185 mainmenu[MENOPT - 4].menuitems[0] = WpeFillSubmenuItem("Open Project", 5, 'P', e_project);
186 mainmenu[MENOPT - 4].menuitems[1] = WpeFillSubmenuItem("Close Project", 0, 'C', e_cl_project);
187 mainmenu[MENOPT - 4].menuitems[2] = WpeFillSubmenuItem("Add Item", 0, 'A', e_p_add_item);
188 mainmenu[MENOPT - 4].menuitems[3] = WpeFillSubmenuItem("Delete Item", 0, 'D', e_p_del_item);
189 mainmenu[MENOPT - 4].menuitems[4] = WpeFillSubmenuItem("Options", 0, 'O', e_project_options);
190 }
191 #endif
192 #ifdef DEBUGGER
193 if(WpeIsProg())
194 {
195 mainmenu[MENOPT - 5].position = -3;
196 mainmenu[MENOPT - 5].width = 33;
197 mainmenu[MENOPT - 5].no_of_items = 13;
198 if((mainmenu[MENOPT - 5].menuitems = MALLOC(mainmenu[MENOPT - 5].no_of_items * sizeof(OPTK))) == NULL)
199 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
200
201 if(f->ed->edopt & ED_CUA_STYLE)
202 {
203 mainmenu[MENOPT - 5].menuitems[0] = WpeFillSubmenuItem("Toggle Breakpoint F5 / ^G B", 7, 'B', e_breakpoint);
204 mainmenu[MENOPT - 5].menuitems[2] = WpeFillSubmenuItem("Make Watch ^F5 / ^G W", 5, 'W', e_make_watches);
205 mainmenu[MENOPT - 5].menuitems[6] = WpeFillSubmenuItem("Show stacK ^F3 / ^G K", 9, 'K', e_deb_stack);
206 }
207 else
208 {
209 mainmenu[MENOPT - 5].menuitems[0] = WpeFillSubmenuItem("Toggle Breakpoint ^F8 / ^G B", 7, 'B', e_breakpoint);
210 mainmenu[MENOPT - 5].menuitems[2] = WpeFillSubmenuItem("Make Watch ^F7 / ^G W", 5, 'W', e_make_watches);
211 mainmenu[MENOPT - 5].menuitems[6] = WpeFillSubmenuItem("Show stacK ^F6 / ^G K", 9, 'K', e_deb_stack);
212 }
213 mainmenu[MENOPT - 5].menuitems[1] = WpeFillSubmenuItem("ReMove all Breakp. ^G M", 2, 'M', e_remove_breakpoints);
214 mainmenu[MENOPT - 5].menuitems[3] = WpeFillSubmenuItem("Edit watch ^G E", 0, 'E', e_edit_watches);
215 mainmenu[MENOPT - 5].menuitems[4] = WpeFillSubmenuItem("Delete watch ^G D", 0, 'D', e_delete_watches);
216 mainmenu[MENOPT - 5].menuitems[5] = WpeFillSubmenuItem("Remove All watches ^G A", 7, 'A', e_remove_all_watches);
217 mainmenu[MENOPT - 5].menuitems[7] = WpeFillSubmenuItem("Goto cursor ^G U", 0, 'U', e_d_goto_cursor);
218 mainmenu[MENOPT - 5].menuitems[8] = WpeFillSubmenuItem("Finish function ^G F", 0, 'F', e_d_finish_func);
219 mainmenu[MENOPT - 5].menuitems[9] = WpeFillSubmenuItem("Trace F7 / ^G T", 0, 'T', e_deb_trace);
220 mainmenu[MENOPT - 5].menuitems[10] = WpeFillSubmenuItem("Step F8 / ^G S", 0, 'S', e_deb_next);
221 mainmenu[MENOPT - 5].menuitems[11] = WpeFillSubmenuItem("Run/Continue ^F10 / ^G R", 0, 'R', e_deb_run);
222 mainmenu[MENOPT - 5].menuitems[12] = WpeFillSubmenuItem("Quit ^F2 / ^G Q", 0, 'Q', e_d_quit);
223 }
224 #endif
225 mainmenu[MENOPT - 3].position = -4;
226 mainmenu[MENOPT - 3].width = 22;
227 #ifdef PROG
228 if(WpeIsProg())
229 #ifdef DEBUGGER
230 mainmenu[MENOPT - 3].no_of_items = 8;
231 #else
232 mainmenu[MENOPT - 3].no_of_items = 7;
233 #endif
234 else
235 #endif
236 mainmenu[MENOPT - 3].no_of_items = 5;
237 if((mainmenu[MENOPT - 3].menuitems = MALLOC(mainmenu[MENOPT - 3].no_of_items * sizeof(OPTK))) == NULL)
238 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
239 mainmenu[MENOPT - 3].menuitems[0] = WpeFillSubmenuItem("Adjust Colors", 0, 'A', e_ad_colors);
240 mainmenu[MENOPT - 3].menuitems[1] = WpeFillSubmenuItem("Save Options", 0, 'S', e_opt_save);
241 mainmenu[MENOPT - 3].menuitems[2] = WpeFillSubmenuItem("Editor", 0, 'E', e_edt_options);
242 mainmenu[MENOPT - 3].menuitems[3] = WpeFillSubmenuItem("File-Manager", 0, 'F', WpeFileManagerOptions);
243 mainmenu[MENOPT - 3].menuitems[4] = WpeFillSubmenuItem("Help", 0, 'H', e_help_options);
244 #ifdef PROG
245 if(WpeIsProg())
246 {
247 mainmenu[MENOPT - 3].menuitems[5] = WpeFillSubmenuItem("ProGramming", 3, 'G', e_program_opt);
248 mainmenu[MENOPT - 3].menuitems[6] = WpeFillSubmenuItem("Compiler", 0, 'C', e_run_options);
249 #ifdef DEBUGGER
250 mainmenu[MENOPT - 3].menuitems[7] = WpeFillSubmenuItem("Debugger", 0, 'D', e_deb_options);
251 #endif
252 }
253 #endif
254 #ifdef NEWSTYLE
255 if(WpeIsXwin())
256 mainmenu[MENOPT - 2].position = -13;
257 else
258 #endif
259 mainmenu[MENOPT - 2].position = -14;
260 mainmenu[MENOPT - 2].width = 28;
261 #ifdef DJGPP
262 #ifdef PROG
263 mainmenu[MENOPT - 2].no_of_items = 10;
264 #else
265 mainmenu[MENOPT - 2].no_of_items = 8;
266 #endif
267 #else
268 #ifdef UNIX
269 #ifdef PROG
270 if(WpeIsProg())
271 #ifdef DEBUGGER
272 mainmenu[MENOPT - 2].no_of_items = !WpeIsXwin()? 11 : 10;
273 #else
274 mainmenu[MENOPT - 2].no_of_items = !WpeIsXwin()? 10 : 9;
275 #endif
276 else
277 #endif
278 mainmenu[MENOPT - 2].no_of_items = !WpeIsXwin()? 8 : 7;
279 #else
280 mainmenu[MENOPT - 2].no_of_items = !WpeIsXwin()? 7 : 6;
281 #endif
282 #endif
283 if((mainmenu[MENOPT - 2].menuitems = MALLOC(mainmenu[MENOPT - 2].no_of_items * sizeof(OPTK))) == NULL)
284 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
285 if(f->ed->edopt & ED_CUA_STYLE)
286 {
287 mainmenu[MENOPT - 2].menuitems[0] = WpeFillSubmenuItem("Size/Move ^L", 0, 'S', e_size_move);
288 mainmenu[MENOPT - 2].menuitems[1] = WpeFillSubmenuItem("Zoom Shift F6 / Alt Z", 0, 'Z', e_ed_zoom);
289 mainmenu[MENOPT - 2].menuitems[4] = WpeFillSubmenuItem("Next ^F6 / Alt N", 2, 'X', e_ed_next);
290 mainmenu[MENOPT - 2].menuitems[5] = WpeFillSubmenuItem("Close ^F4 / Alt X", 0, 'C', e_close_window);
291 }
292 else
293 {
294 mainmenu[MENOPT - 2].menuitems[0] = WpeFillSubmenuItem("Size/Move Alt F2", 0, 'S', e_size_move);
295 mainmenu[MENOPT - 2].menuitems[1] = WpeFillSubmenuItem("Zoom F5 / Alt Z", 0, 'Z', e_ed_zoom);
296 mainmenu[MENOPT - 2].menuitems[4] = WpeFillSubmenuItem("Next F6 / Alt N", 2, 'X', e_ed_next);
297 mainmenu[MENOPT - 2].menuitems[5] = WpeFillSubmenuItem("Close Alt F3", 0, 'C', e_close_window);
298 }
299 mainmenu[MENOPT - 2].menuitems[2] = WpeFillSubmenuItem("Tile Shift F4", 0, 'T', e_ed_tile);
300 mainmenu[MENOPT - 2].menuitems[3] = WpeFillSubmenuItem("Cascade Shift F5", 1, 'A', e_ed_cascade);
301 mainmenu[MENOPT - 2].menuitems[6] = WpeFillSubmenuItem("List All Alt 0", 0, 'L', e_list_all_win);
302 #ifndef DJGPP
303 if(!WpeIsXwin())
304 #endif
305 mainmenu[MENOPT - 2].menuitems[7] = WpeFillSubmenuItem("Output Alt F5 / ^G P", 0, 'O', e_u_deb_out);
306 #ifdef PROG
307 if(WpeIsProg())
308 {
309 mainmenu[MENOPT - 2].menuitems[mainmenu[MENOPT - 2].no_of_items - 2] =
310 WpeFillSubmenuItem("Messages", 0, 'M', e_p_show_messages);
311 mainmenu[MENOPT - 2].menuitems[mainmenu[MENOPT - 2].no_of_items - 1] =
312 WpeFillSubmenuItem("Project", 0, 'P', e_show_project);
313 #ifdef DEBUGGER
314 mainmenu[MENOPT - 2].menuitems[mainmenu[MENOPT - 2].no_of_items - 3] =
315 WpeFillSubmenuItem("Watches", 0, 'W', e_p_show_watches);
316 #endif
317 }
318 #endif
319 #ifdef NEWSTYLE
320 if(WpeIsXwin())
321 mainmenu[MENOPT - 1].position = -21;
322 else
323 #endif
324 mainmenu[MENOPT - 1].position = -22;
325 mainmenu[MENOPT - 1].width = 27;
326 #if defined(PROG) && !defined(DJGPP)
327 mainmenu[MENOPT - 1].no_of_items = 8;
328 #else
329 mainmenu[MENOPT - 1].no_of_items = 6;
330 #endif
331 if((mainmenu[MENOPT - 1].menuitems = MALLOC(mainmenu[MENOPT - 1].no_of_items * sizeof(OPTK))) == NULL)
332 e_error(e_msg[ERR_LOWMEM], 1, f->fb);
333 mainmenu[MENOPT - 1].menuitems[0] = WpeFillSubmenuItem("Editor F1", 0, 'E', e_help);
334 #if defined(PROG) && !defined(DJGPP)
335 mainmenu[MENOPT - 1].menuitems[1] = WpeFillSubmenuItem("Topic Search ^F1", 0, 'T', e_topic_search);
336 mainmenu[MENOPT - 1].menuitems[2] = WpeFillSubmenuItem("FUnction Index Alt F1", 1, 'U', e_funct_in);
337 /* mainmenu[MENOPT-1].menuitems[2] = WpeFillSubmenuItem("Functions Alt F1", 0, 'F', e_funct); */
338 #endif
339 mainmenu[MENOPT - 1].menuitems[mainmenu[MENOPT - 1].no_of_items - 5] =
340 WpeFillSubmenuItem("Info ", 0, 'I', e_info);
341 mainmenu[MENOPT - 1].menuitems[mainmenu[MENOPT - 1].no_of_items - 4] =
342 WpeFillSubmenuItem("Goto <CR>", 0, 'G', e_hp_ret);
343 mainmenu[MENOPT - 1].menuitems[mainmenu[MENOPT - 1].no_of_items - 3] =
344 WpeFillSubmenuItem("Back <BSP>", 0, 'B', e_hp_back);
345 mainmenu[MENOPT - 1].menuitems[mainmenu[MENOPT - 1].no_of_items - 2] =
346 WpeFillSubmenuItem("Next Alt F8 / Alt T", 0, 'G', e_hp_next);
347 mainmenu[MENOPT - 1].menuitems[mainmenu[MENOPT - 1].no_of_items - 1] =
348 WpeFillSubmenuItem("Prev. Alt F7 / Alt V", 0, 'P', e_hp_prev);
349
350 /* check for valid n */
351 if(n < 0 || n > MENOPT - 1)
352 n = 0;
353
354 /* go until the user leaves the main control bar */
355 while(c != WPE_ESC)
356 {
357
358 f = cn->f[cn->mxedt];
359 if(e_tst_dfkt(f, c) == 0)
360 {
361 c = 0;
362 break;
363 }
364
365 /* check for a menu shortcut */
366 for(i = 0; i < MENOPT; i++)
367 if(c == opt[i].s || c == opt[i].as)
368 {
369 n = i;
370 c = WPE_CR;
371 }
372
373 /* if the selection is not the same as before do some drawing */
374 if(nold != n)
375 {
376 /* paint unselected the option */
377 e_pr_str_wsd(opt[nold].x, 0, opt[nold].t, f->fb->mt.fb, 0, 1,
378 f->fb->ms.fb, (nold == 0 ? 0 : opt[nold].x - e_mn_men),
379 (nold == MENOPT - 1) ? MAXSCOL - 1 : opt[nold + 1].x - e_mn_men - 1);
380
381 /* paint selected the option */
382 e_pr_str_wsd(opt[n].x, 0, opt[n].t, f->fb->mz.fb, 0, 1,
383 f->fb->mz.fb, (n == 0 ? 0 : opt[n].x - e_mn_men),
384 (n == MENOPT - 1) ? MAXSCOL - 1 : opt[n + 1].x - e_mn_men - 1);
385
386 /* store the selected menu option for later use */
387 nold = n;
388 }
389
390 if(c == WPE_CR)
391 #ifdef PROG
392 #ifdef DEBUGGER
393 {
394 if(!WpeIsProg() && n > 4)
395 e_hlp = e_hlp_str[9 + n];
396 else
397 e_hlp = e_hlp_str[6 + n];
398 #else
399 {
400 if(!WpeIsProg() && n > 4)
401 e_hlp = e_hlp_str[8 + n];
402 else
403 e_hlp = e_hlp_str[6 + n];
404 #endif
405 #else
406 {
407 e_hlp = e_hlp_str[6 + n];
408 #endif
409 /* Handle user interaction with the submenu.
410 If the user moved to another main option, the function returns. */
411 if(mainmenu[n].width != 0)
412 c = WpeHandleSubmenu(opt[n].x + mainmenu[n].position, 1,
413 opt[n].x + mainmenu[n].width + mainmenu[n].position,
414 mainmenu[n].no_of_items + 2, n, mainmenu[n].menuitems, f);
415 if(c < MENOPT)
416 {
417 n = c;
418 c = WPE_CR;
419 }
420 else if(c != WPE_ESC)
421 c = 0;
422 }
423 else
424 {
425 e_hlp = e_hlp_str[24];
426 #if MOUSE
427 if((c = e_getch()) == -1)
428 c = e_m1_mouse();
429 #else
430 c = e_getch();
431 #endif
432 c = e_toupper(c);
433 }
434 if(c == CDO || c == CtrlN) /* down -> submenu open */
435 c = WPE_CR;
436 else if(c == CLE || c == CtrlB) /* going left in the main menu */
437 n--;
438 else if(c == CRI || c == CtrlF) /* going right in the main menu */
439 n++;
440 else if(c == POS1 || c == CtrlA) /* most left in the main menu */
441 n = 0;
442 else if(c == ENDE || c == CtrlE) /* most right in the main menu */
443 n = MENOPT - 1;
444 else if(c == AltX) /* quit the whole business */
445 c = e_quit(f);
446
447 /* adjust the selected main menu */
448 if(n < 0)
449 n = MENOPT - 1;
450 else if(n >= MENOPT)
451 n = 0;
452 }
453
454 /* paint unselected the last selected main menu option */
455 f = cn->f[cn->mxedt];
456 e_pr_str_wsd(opt[nold].x, 0, opt[nold].t, f->fb->mt.fb, 0, 1,
457 f->fb->ms.fb, (nold == 0 ? 0 : opt[nold].x - e_mn_men),
458 (nold == MENOPT - 1) ? MAXSCOL - 1 : opt[nold + 1].x - e_mn_men - 1);
459
460 /* free up the submenu structure */
461 for(i = 0; i < MENOPT; i++)
462 if(mainmenu[i].width != 0)
463 FREE(mainmenu[i].menuitems);
464 FREE(mainmenu);
465
466 fk_cursor(1);
467 return(c);
468 }
469
470 /* sub menu box */
471 int WpeHandleSubmenu(int xa, int ya, int xe, int ye, int nm, OPTK * fopt, FENSTER * f)
472 {
473 #if MOUSE
474 extern struct mouse e_mouse;
475 extern int e_mn_men;
476 #endif
477 PIC *pic;
478 int i, n = 0, nold = 1, c = 0;
479 extern OPT opt[];
480
481 /* save whatever will be behind the submenu */
482 #ifdef NEWSTYLE
483 if(WpeIsXwin())
484 pic = e_open_view(xa + 1, ya, xe - 1, ye, f->fb->mt.fb, 1);
485 else
486 #endif
487 pic = e_open_view(xa, ya, xe, ye, f->fb->mt.fb, 1);
488
489 if(pic == NULL)
490 {
491 e_error(e_msg[ERR_LOWMEM], 0, f->fb);
492 return(WPE_ESC);
493 }
494
495 /* draw the frame and the background of the submenu */
496 e_std_rahmen(xa + 1, ya, xe - 1, ye, NULL, 0, f->fb->mr.fb, 0);
497
498 /* draw the submenu items (colors are default, none selected) */
499 for(i = ya + 1; i < ye; i++)
500 e_pr_str_scan(xa + 3, i, fopt[i - ya - 1].t, f->fb->mt.fb, fopt[i - ya - 1].x, 1,
501 f->fb->ms.fb, xa + 2, xe - 2);
502
503 #if MOUSE
504 /* show the actual changes */
505 e_refresh();
506 /* until mouse button released */
507 while(e_mshit() != 0)
508 {
509 c = -1;
510 /* mouse is in the range of the submenu */
511 if(e_mouse.y > ya && e_mouse.y < ye)
512 {
513 n = e_mouse.y - ya - 1;
514 /* if a new item is selected */
515 if(nold != n)
516 {
517 /* check whether nold is in the range of the available items and unselect it */
518 if(nold < ye - ya - 1 && nold >= 0)
519 e_pr_str_scan(xa + 3, nold + ya + 1, fopt[nold].t, f->fb->mt.fb, fopt[nold].x,
520 1, f->fb->ms.fb, xa + 2, xe - 2);
521 /* draw the newly selected item */
522 e_pr_str_scan(xa + 3, n + ya + 1, fopt[n].t, f->fb->mz.fb, fopt[n].x, 1,
523 f->fb->mz.fb, xa + 2, xe - 2);
524 /* save the selection */
525 nold = n;
526 e_refresh();
527 }
528 }
529 /* mouse is in the main menu area */
530 else if(e_mouse.y == 0)
531 {
532 /* search for the selected main menu option */
533 for(i = 1; i < MENOPT; i++)
534 if(e_mouse.x < opt[i].x - e_mn_men)
535 break;
536 /* check whether a new menu option has been selected */
537 if(i != nm + 1)
538 {
539 /* if yes, restore what was behind */
540 e_close_view(pic, 1);
541 return(i - 1);
542 }
543 }
544 }
545
546 /* there was a selection and mouse is within the submenu !!! */
547 if(c < 0 && e_mouse.y > ya && e_mouse.y < ye && e_mouse.x > xa &&
548 e_mouse.x < xe)
549 c = MBKEY;
550 #endif
551
552 while(c != WPE_ESC)
553 {
554 if(nold != n)
555 {
556 /* check whether nold is in the range of the available items and unselect it */
557 if(nold < ye - ya - 1 && nold >= 0)
558 e_pr_str_scan(xa + 3, nold + ya + 1, fopt[nold].t, f->fb->mt.fb, fopt[nold].x,
559 1, f->fb->ms.fb, xa + 2, xe - 2);
560 /* draw the newly selected item */
561 e_pr_str_scan(xa + 3, n + ya + 1, fopt[n].t, f->fb->mz.fb, fopt[n].x, 1,
562 f->fb->mz.fb, xa + 2, xe - 2);
563 /* save the selection */
564 nold = n;
565 }
566 #if MOUSE
567 if(c != MBKEY)
568 {
569 if((c = e_toupper(e_getch())) == -1)
570 c = e_m2_mouse(xa, ya, xe, ye, fopt);
571 }
572 else
573 c = WPE_CR; /* mouse released at a proper place, submenu item accepted */
574 #else
575 c = e_toupper(e_getch());
576 #endif
577
578 /* check main menu shortcut keys */
579 for(i = 0; i < MENOPT; i++)
580 if(c == opt[i].as)
581 {
582 e_close_view(pic, 1);
583 return(i);
584 }
585
586 /* check submenu items' shortcut keys */
587 for(i = 0; i < ye - ya - 1; i++)
588 if(c == fopt[i].o)
589 {
590 e_close_view(pic, 1);
591 fopt[i].fkt(f);
592 return(WPE_ESC);
593 }
594
595 if(c == Alt0)
596 c = WPE_ESC;
597
598 if(i > ye - ya)
599 c = WPE_ESC;
600 else if(c == WPE_CR) /* submenu item accepted */
601 {
602 e_close_view(pic, 1);
603 fopt[n].fkt(f);
604 return(WPE_ESC);
605 }
606 else if(c == CUP || c == CtrlP) /* going up in the submenu */
607 n = n > 0 ? n - 1 : ye - ya - 2;
608 else if(c == CDO || c == CtrlN) /* going down in the submenu */
609 n = n < ye - ya - 2 ? n + 1 : 0;
610 else if(c == CLE || c == CtrlB) /* going left in the main menu */
611 {
612 c = nm > 0 ? nm - 1 : MENOPT - 1;
613 break;
614 }
615 else if(c == CRI || c == CtrlF) /* going right in the main menu */
616 {
617 c = nm < MENOPT - 1 ? nm + 1 : 0;
618 break;
619 }
620 else if(c == POS1 || c == CtrlA) /* to the top in the submenu */
621 n = 0;
622 else if(c == ENDE || c == CtrlE) /* to the bottom in the submenu */
623 n = ye - ya - 2;
624 else
625 {
626 /* this is the anything else case, ESC, keys which are not listed in
627 the submenu */
628 e_close_view(pic, 1);
629 if(c != WPE_ESC && e_tst_dfkt(f, c) == 0)
630 return(WPE_ESC);
631 #ifdef NEWSTYLE
632 pic = e_open_view(xa + 1, ya, xe - 1, ye, f->fb->mt.fb, 1);
633 #else
634 pic = e_open_view(xa, ya, xe, ye, f->fb->mt.fb, 1);
635 #endif
636 /* draw the frame for the submenu */
637 e_std_rahmen(xa + 1, ya, xe - 1, ye, NULL, 0, f->fb->mr.fb, 0);
638 /* draw every item in the submenu, unselected */
639 for(i = ya + 1; i < ye; i++)
640 e_pr_str_scan(xa + 3, i, fopt[i - ya - 1].t, f->fb->mt.fb, fopt[i - ya - 1].x, 1,
641 f->fb->ms.fb, xa + 2, xe - 2);
642 /* draw the selected item */
643 e_pr_str_scan(xa + 3, n + ya + 1, fopt[n].t, f->fb->mz.fb, fopt[n].x, 1,
644 f->fb->mz.fb, xa + 2, xe - 2);
645 }
646 }
647 e_close_view(pic, 1);
648 return(c == WPE_ESC ? 255 : c);
649 }
650
651 /* fill "options" struct */
652 OPTK WpeFillSubmenuItem(char *t, int x, char o, int(*fkt) ())
653 {
654 OPTK opt;
655
656 opt.t = t;
657 opt.x = x;
658 opt.o = o;
659 opt.fkt = fkt;
660 return(opt);
661 }
662
663