source: trunk/src/netlabs/macros/popup.e@ 4491

Last change on this file since 4491 was 4491, checked in by Andreas Schnellbacher, 4 years ago
  • Set focus to client on Esc, Ctrl+ and Preferences -> Close menu.
    • This is a workaround for an EPM bug: On dismissing a popup menu, the focus is often not set back to the edit window, but to the horizontal scroll bar instead.
  • Property svn:keywords set to Date Revision Author HeadURL Id
File size: 36.5 KB
Line 
1/****************************** Module Header *******************************
2*
3* Module Name: popup.e
4*
5* Copyright (c) Netlabs EPM Distribution Project 2004
6*
7* $Id: popup.e 4491 2021-05-06 11:46:42Z aschn $
8*
9* ===========================================================================
10*
11* This file is part of the Netlabs EPM Distribution package and is free
12* software. You can redistribute it and/or modify it under the terms of the
13* GNU General Public License as published by the Free Software
14* Foundation, in version 2 as it comes in the "COPYING" file of the
15* Netlabs EPM Distribution. This library is distributed in the hope that it
16* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18* General Public License for more details.
19*
20****************************************************************************/
21
22; Popup menu defs, moved from MOUSE.E.
23
24compile if not defined( SMALL) -- If compiled separately
25 EA_comment 'This defines the popup menu.'
26
27define
28 INCLUDING_FILE = 'POPUP.E'
29
30 include 'stdconst.e'
31const
32 tryinclude 'mycnf.e'
33const
34 compile if not defined( NLS_LANGUAGE)
35 NLS_LANGUAGE = 'ENGLISH'
36 compile endif
37 include NLS_LANGUAGE'.e'
38compile endif
39
40; ---------------------------------------------------------------------------
41const
42compile if not defined( WANT_TEXT_PROCS)
43 WANT_TEXT_PROCS = 1
44compile endif
45compile if not defined( CHECK_FOR_LEXAM)
46 CHECK_FOR_LEXAM = 0
47compile endif
48
49; ---------------------------------------------------------------------------
50const
51 FILL_MARK_MENU__MSG = '~Fill mark'
52 FILL_MARK_MENUP__MSG = \1'Fill marked region with a character, overlaying current contents'
53 HP_POPUP_FILL = 0
54 REFLOW_MARK_MENU__MSG = 'Reflo~w mark'
55 REFLOW_MARK_MENUP__MSG = \1'Reflow text in marked region'
56 HP_POPUP_REFLOW = 0
57 MARK_WORD_MENU__MSG = 'Mark ~word'
58 MARK_WORD_MENUP__MSG = \1'Mark space-delimited word under cursor'
59 HP_POPUP_MARKWORD = 0
60 MARK_TOKEN_MENU__MSG = 'Mark ~identifier'
61 MARK_TOKEN_MENUP__MSG = \1'Mark the C-language identifier under the cursor'
62 HP_POPUP_MARKTOKEN = 0
63 FIND_TOKEN_MENU__MSG = '~Find identifier'
64 FIND_TOKEN_MENUP__MSG = \1'Find the next occurrence of the identifier under the cursor'
65 HP_POPUP_FINDTOKEN = 0
66compile if WANT_TEXT_PROCS
67 MARK_SENTENCE_MENU__MSG = 'Mark se~ntence'
68 MARK_SENTENCE_MENUP__MSG = \1'Mark sentence around cursor'
69 HP_POPUP_MARKSENTENCE = 0
70 MARK_PARAGRAPH_MENU__MSG = 'Mark paragrap~h'
71 MARK_PARAGRAPH_MENUP__MSG = \1'Mark paragraph around cursor'
72 HP_POPUP_MARKPARAGRAPH = 0
73 EXTEND_SENTENCE_MENU__MSG = 'E~xtend sentence mark'
74 EXTEND_SENTENCE_MENUP__MSG = \1'Extend character mark through end of next sentence'
75 HP_POPUP_EXTENDSENTENCE = 0
76 EXTEND_PARAGRAPH_MENU__MSG = 'Extend p~aragraph mark'
77 EXTEND_PARAGRAPH_MENUP__MSG = \1'Extend character mark through end of next paragraph'
78 HP_POPUP_EXTENDPARAGRAPH = 0
79compile endif -- WANT_TEXT_PROCS
80 UPCASE_MARK_MENU__MSG = 'Uppe~rcase mark'
81 UPCASE_MARK_MENUP__MSG = \1'Translate selected text to upper case'
82 HP_POPUP_UPCASEMARK = 0
83 LOCASE_MARK_MENU__MSG = '~Lowercase mark'
84 LOCASE_MARK_MENUP__MSG = \1'Translate selected text to lower case'
85 HP_POPUP_LOCASEMARK = 0
86 UPCASE_WORD_MENU__MSG = '~Uppercase word'
87 UPCASE_WORD_MENUP__MSG = \1'Translate word under mouse pointer to upper case'
88 HP_POPUP_UPCASEWORD = 0
89 LOCASE_WORD_MENU__MSG = '~Lowercase word'
90 LOCASE_WORD_MENUP__MSG = \1'Translate word under mouse pointer to lower case'
91 HP_POPUP_LOCASEWORD = 0
92 SHIFT_MENU__MSG = '~Shift'
93 SHIFT_MENUP__MSG = \1'Shift marked text left or right'
94 HP_POPUP_SHIFT = 0
95 SHIFTLEFT_MENU__MSG = 'Shift ~left 1'
96 SHIFTLEFT_MENUP__MSG = \1'Shift marked text left 1 character'
97 HP_POPUP_SHIFTLEFT = 0
98 SHIFTLEFT3_MENU__MSG = 'Shift l~eft 3'
99 SHIFTLEFT3_MENUP__MSG = \1'Shift marked text left 3 characters'
100 HP_POPUP_SHIFTLEFT3 = 0
101 SHIFTLEFT8_MENU__MSG = 'Shift le~ft 8'
102 SHIFTLEFT8_MENUP__MSG = \1'Shift marked text left 8 characters'
103 HP_POPUP_SHIFTLEFT8 = 0
104 SHIFTRIGHT_MENU__MSG = 'Shift right ~1'
105 SHIFTRIGHT_MENUP__MSG = \1'Shift marked text right 1 character'
106 HP_POPUP_SHIFTRIGHT = 0
107 SHIFTRIGHT3_MENU__MSG = 'Shift right ~3'
108 SHIFTRIGHT3_MENUP__MSG = \1'Shift marked text right 3 characters'
109 HP_POPUP_SHIFTRIGHT3 = 0
110 SHIFTRIGHT8_MENU__MSG = 'Shift right ~8'
111 SHIFTRIGHT8_MENUP__MSG = \1'Shift marked text right 8 characters'
112 HP_POPUP_SHIFTRIGHT8 = 0
113 CENTER_LINE_MENU__MSG = 'Cen~ter line'
114 CENTER_LINE_MENUP__MSG = \1'Center line under cursor vertically in window'
115 HP_POPUP_CENTERLINE = 0
116 CENTER_MARK_MENU__MSG = 'Cen~ter text'
117 CENTER_MARK_MENUP__MSG = \1'Center marked text within margins or block mark'
118 HP_POPUP_CENTERMARK = 0
119 SORT_MARK_MENU__MSG = 'S~ort'
120 SORT_MARK_MENUP__MSG = \1'Sort marked lines, using block mark (if present) as key'
121 HP_POPUP_SORT = 0
122 TOP_LINE_MENU__MSG = 'Sc~roll to top'
123 TOP_LINE_MENUP__MSG = \1'Scroll so line under cursor is at top of window'
124 HP_POPUP_TOP = 0
125
126;compile if WANT_TREE
127 LOAD_FILE_MENU__MSG = '~Load file'
128 SORT_ASCENDING_MENU__MSG = '~Sort ascending'
129 SORT_DATE_MENU__MSG = 'Sort by ~date'
130 SORT_TIME_MENU__MSG = 'Sort by ~time'
131 SORT_SIZE_MENU__MSG = 'Sort by ~size'
132 SORT_EASIZE_MENU__MSG = 'Sort by ~EA size'
133 SORT_FULLNAME_MENU__MSG = 'Sort by ~fully-qualified filename'
134 SORT_NAME_MENU__MSG = 'Sort by ~name'
135 SORT_EXTENSION_MENU__MSG = 'Sort by e~xtension'
136 SORT_DESCENDING_MENU__MSG = 'Sort ~descending'
137
138 LOAD_FILE_MENUP__MSG = \1'Load the file or list the directory under the cursor'
139 SORT_ASCENDING_MENUP__MSG = \1'Sort the file or marked lines from smallest to largest'
140 SORT_XXXX_MENUP__MSG = \1'Sort the file or marked lines by the indicated attribute'
141 SORT_DESCENDING_MENUP__MSG = \1'Sort the file or marked lines from largest to smallest'
142;compile endif
143
144; ---------------------------------------------------------------------------
145definit
146 call SetAVar( 'mid_popup', 80)
147
148; ---------------------------------------------------------------------------
149const
150 -- EPM bug:
151 -- Cascade menu is now replaced by inline menu items, because it doesnot
152 -- work correctly:
153 -- The frame around the submenu arrow is only painted after activating
154 -- that menu item. Before that, one thinks that's a normal submenu item
155 -- that won't execute something on selecting it.
156 POPUP_ENABLE_CASCADE = 0 -- 0|1
157
158; ---------------------------------------------------------------------------
159; Open the popup menu at the pointer position.
160; With arg( 1) = 0, the popup menu is opened at the cursor pos.
161; EPM bug:
162; On dismissing a popup menu, the focus is often not set back to the edit
163; window. Click into it first. Focus switching was also addded to
164; ShowCursor (Ctrl+.) and ProcessEscape (Esc).
165defc MH_Popup
166 universal activemenu
167
168 menuname = 'popup'
169 activemenu = menuname -- required for DefSubMenu and DefSubMenuItem
170
171 deletemenu menuname, 0, 0, 0
172
173 -- For a popup menu, the submenu item itself is invisible. Therefore simply
174 -- use the same name here as for the popup menu:
175 DefSubMenu( menuname, -- Popup ----------
176 '',
177 '',
178 '')
179
180 -- Add menu items
181 mt = strip( leftstr( marktype(), 1))
182 if arg( 1) = 0 then
183 call PointerToCursorPos()
184 endif
185 fInMark = mouse_in_mark()
186 fIsTreeList = upcase( leftstr( .filename, 5)) = '.TREE'
187 fIsDirList = OnADirListLine()
188 if fIsTreeList then
189 --'MH_GoToPointerPos'
190 -- Better always use the cursor pos., because many actions refer to
191 -- the filename in the processed line.
192 PointerToCursorPos()
193 call PopupMenuItemsTreeList()
194 elseif fIsDirList then
195 --'MH_GoToPointerPos'
196 -- Better always use the cursor pos., because many actions refer to
197 -- the filename in the processed line.
198 PointerToCursorPos()
199 call PopupMenuItemsDirList()
200 elseif fInMark then -- inside-mark
201 call PopupMenuItemsInsideMark()
202 elseif mt <> '' then -- outside-mark
203 call PopupMenuItemsOutsideMark()
204 else -- no-mark
205 call PopupMenuItemsNoMark()
206 endif
207 if not fIsTreeList & not fIsDirList then
208 call PopupMenuItemsCommon()
209 endif
210
211 showmenu menuname, 1 -- 0 = standard menu (default for missing parameter), 1 = popup menu, 2 = undefined, 3 = UC menu (toolbar)
212
213 -- Cascade menu is now replaced by inline menu items, because it doesnot
214 -- work correctly:
215 -- The frame around the submenu arrow is only painted after activating
216 -- that menu item. Before that, one thinks that's a normal submenu item
217 -- that won't execute something on selecting it.
218compile if POPUP_ENABLE_CASCADE
219 'PostMe AddCascadePopupMenu'
220compile endif
221
222 -- This highlights the cursor below the popup menu.
223 'PostMe HighlightCursor'
224
225; ---------------------------------------------------------------------------
226defproc PopupMenuItemsTreeList
227 if IsATreeListFilename() = 1 then -- file
228 miatreelistfile = ''
229 miatreelistfiledir = ''
230 elseif IsATreeListFilename() = 2 then -- dir
231 miatreelistfile = 'DISABLED'
232 miatreelistfiledir = ''
233 else
234 miatreelistfile = 'DISABLED'
235 miatreelistfiledir = 'DISABLED'
236 endif
237 BackupDir = GetBackupDir()
238 fIsBackupList = (pos( '.TREEBACKUP', upcase( .filename)) = 1) &
239 (pos( upcase( BackupDir), upcase( .filename)) > 0)
240
241 DefMenuItem( '', -- Filename
242 DoubleCharInStr( '~', GetFileSpec( GetTreeListFilename(), 'N')),
243 '',
244 '',
245 '',
246 'STATIC')
247 DefMenuItem( '', -- Load file
248 LOAD_FILE_MENU__MSG''MenuAccelString( 'alt_1'),
249 'dokey a_1',
250 LOAD_FILE_MENUP__MSG,
251 '',
252 miatreelistfiledir)
253 DefMenuSep() --------------------
254
255 if fIsBackupList then
256 DefMenuItem( '', -- Compare file
257 'Comp~are',
258 'CompareBackupFile',
259 'Compare backup file under cursor with original file',
260 '',
261 miatreelistfile)
262 DefMenuItem( '', -- Restore file
263 '~Restore...',
264 'RestoreFromTreeFile',
265 'Restore backup file under cursor to original file',
266 '',
267 miatreelistfile)
268 DefMenuSep() --------------------
269 endif
270 DefMenuItem( '', -- Delete file
271 'D~elete file...'MenuAccelString( 'DeleteListFile BackSpace', 'DeleteListFile DeleteLine'),
272 'DeleteListFile',
273 'Delete file under cursor ('CTRL_KEY__MSG' to bypass confirmation)',
274 '',
275 miatreelistfile)
276 DefMenuSep() --------------------
277
278 DefNextItemStartsSubMenu()
279 DefMenuItem( '', -- Sort ascending >
280 SORT_ASCENDING_MENU__MSG,
281 '',
282 SORT_ASCENDING_MENUP__MSG,
283 '')
284 DefMenuItem( '', -- Sort by date
285 SORT_DATE_MENU__MSG,
286 'TreeSort D',
287 SORT_XXXX_MENUP__MSG,
288 '')
289 DefMenuItem( '', -- Sort by time
290 SORT_TIME_MENU__MSG,
291 'TreeSort T',
292 SORT_XXXX_MENUP__MSG,
293 '')
294 DefMenuItem( '', -- Sort by size
295 SORT_SIZE_MENU__MSG,
296 'TreeSort S',
297 SORT_XXXX_MENUP__MSG,
298 '')
299 DefMenuItem( '', -- Sort by EA size
300 SORT_EASIZE_MENU__MSG,
301 'TreeSort EA',
302 SORT_XXXX_MENUP__MSG,
303 '')
304 DefMenuItem( '', -- Sort by fully-qualified filename
305 SORT_FULLNAME_MENU__MSG,
306 'TreeSort F',
307 SORT_XXXX_MENUP__MSG,
308 '')
309 DefMenuItem( '', -- Sort by name
310 SORT_NAME_MENU__MSG,
311 'TreeSort N',
312 SORT_XXXX_MENUP__MSG,
313 '')
314 DefNextItemEndsSubMenu()
315 DefMenuItem( '', -- Sort by extension
316 SORT_EXTENSION_MENU__MSG,
317 'TreeSort EX',
318 SORT_XXXX_MENUP__MSG,
319 '')
320 DefNextItemStartsSubMenu()
321 DefMenuItem( '', -- Sort descending >
322 SORT_DESCENDING_MENU__MSG,
323 '',
324 SORT_DESCENDING_MENUP__MSG,
325 '')
326 DefMenuItem( '', -- Sort by date
327 SORT_DATE_MENU__MSG,
328 'TreeSort /R D',
329 SORT_XXXX_MENUP__MSG,
330 '')
331 DefMenuItem( '', -- Sort by time
332 SORT_TIME_MENU__MSG,
333 'TreeSort /R T',
334 SORT_XXXX_MENUP__MSG,
335 '')
336 DefMenuItem( '', -- Sort by size
337 SORT_SIZE_MENU__MSG,
338 'TreeSort /R S',
339 SORT_XXXX_MENUP__MSG,
340 '')
341 DefMenuItem( '', -- Sort by EA size
342 SORT_EASIZE_MENU__MSG,
343 'TreeSort /R EA',
344 SORT_XXXX_MENUP__MSG,
345 '')
346 DefMenuItem( '', -- Sort by fully-qualified filename
347 SORT_FULLNAME_MENU__MSG,
348 'TreeSort /R F',
349 SORT_XXXX_MENUP__MSG,
350 '')
351 DefMenuItem( '', -- Sort by name
352 SORT_NAME_MENU__MSG,
353 'TreeSort /R N',
354 SORT_XXXX_MENUP__MSG,
355 '')
356 DefNextItemEndsSubMenu()
357 DefMenuItem( '', -- Sort by extension
358 SORT_EXTENSION_MENU__MSG,
359 'TreeSort /R EX',
360 SORT_XXXX_MENUP__MSG,
361 '')
362
363; ---------------------------------------------------------------------------
364defproc PopupMenuItemsDirList
365 if IsADirListFilename() = 1 then -- file
366 miadirlistfile = ''
367 miadirlistfiledir = ''
368 elseif IsADirListFilename() = 2 then -- dir
369 miadirlistfile = 'DISABLED'
370 miadirlistfiledir = ''
371 else
372 miadirlistfile = 'DISABLED'
373 miadirlistfiledir = 'DISABLED'
374 endif
375
376 DefMenuItem( '', -- Filename
377 DoubleCharInStr( '~', GetFileSpec( GetDirListFilename(), 'N')),
378 '',
379 '',
380 '',
381 'STATIC')
382 DefMenuItem( '', -- Load file
383 LOAD_FILE_MENU__MSG''MenuAccelString( 'alt_1'),
384 'dokey a_1',
385 LOAD_FILE_MENUP__MSG,
386 '',
387 miadirlistfiledir)
388 DefMenuSep() --------------------
389
390 DefMenuItem( '', -- Delete file
391 'D~elete file...'MenuAccelString( 'DeleteListFile BackSpace', 'DeleteListFile DeleteLine'),
392 'DeleteListFile',
393 'Delete file under cursor ('CTRL_KEY__MSG' to bypass confirmation)',
394 '',
395 miadirlistfile)
396
397; ---------------------------------------------------------------------------
398defproc PopupMenuItemsInsideMark
399 universal nodismiss
400compile if CHECK_FOR_LEXAM
401 universal LEXAM_is_available
402compile endif
403 universal LastSubMenuId
404
405 mt = strip( leftstr( marktype(), 1))
406 -- Disable some menu items if char mark is active
407 fCharMark = (mt = 'C')
408 if fCharMark then
409 miaformatable = 'DISABLED'
410 else
411 miaformatable = ''
412 endif
413
414 DefMenuItem( '', -- Unmark
415 UNMARK_MARK_MENU__MSG,
416 'UnMark',
417 UNMARK_MARK_MENUP__MSG,
418 HP_EDIT_UNMARK)
419 DefMenuItem( '', -- Delete mark
420 DELETE_MARK_MENU__MSG,
421 'DeleteMark',
422 DELETE_MARK_MENUP__MSG,
423 HP_EDIT_DELETE)
424 DefMenuItem( '', -- Fill mark
425 FILL_MARK_MENU__MSG,
426 'FillMark',
427 FILL_MARK_MENUP__MSG,
428 HP_POPUP_FILL)
429 DefMenuItem( '', -- Reflow mark
430 REFLOW_MARK_MENU__MSG,
431 'ReflowPar2ReflowMargins',
432 REFLOW_MARK_MENUP__MSG,
433 HP_POPUP_REFLOW,
434 miaformatable)
435 DefMenuItem( '', -- Uppercase mark
436 UPCASE_MARK_MENU__MSG,
437 'UppercaseMark',
438 UPCASE_MARK_MENUP__MSG,
439 HP_POPUP_UPCASEMARK)
440 DefMenuItem( '', -- Lowercase mark
441 LOCASE_MARK_MENU__MSG,
442 'LowercaseMark',
443 LOCASE_MARK_MENUP__MSG,
444 HP_POPUP_LOCASEMARK)
445 DefMenuItem( '', -- Sort
446 SORT_MARK_MENU__MSG,
447 'Sort',
448 SORT_MARK_MENUP__MSG,
449 HP_POPUP_SORT,
450 miaformatable)
451 DefMenuSep() --------------------
452
453 DefMenuItem( '', -- Find mark
454 'Fi~nd mark',
455 'FindMark',
456 'Find marked string in text',
457 '')
458 DefMenuSep() --------------------
459
460 DefMenuItem( '', -- Comment
461 '~Comment',
462 'Comment',
463 'Comment marked lines',
464 '')
465 DefMenuItem( '', -- Uncomment
466 'Unco~mment',
467 'Uncomment',
468 'Uncomment marked lines',
469 '')
470 DefMenuSep() --------------------
471
472compile if WANT_TEXT_PROCS
473 DefMenuItem( '', -- Extend sentence mark
474 EXTEND_SENTENCE_MENU__MSG,
475 'ExtendSentence',
476 EXTEND_SENTENCE_MENUP__MSG,
477 HP_POPUP_EXTENDSENTENCE)
478 DefMenuItem( '', -- Extend paragraph mark
479 EXTEND_PARAGRAPH_MENU__MSG,
480 'ExtendParagraph',
481 EXTEND_PARAGRAPH_MENUP__MSG,
482 HP_POPUP_EXTENDPARAGRAPH)
483 DefMenuSep() --------------------
484
485compile endif -- WANT_TEXT_PROCS
486 DefNextItemStartsSubMenu()
487 DefMenuItem( '', -- Shift >
488 'S~hift' /*SHIFT_MENU__MSG*/,
489 '',
490 SHIFT_MENUP__MSG,
491 HP_POPUP_SHIFT)
492 DefMenuItem( '', -- Shift left 1
493 SHIFTLEFT_MENU__MSG''MenuAccelString( 'ShiftLeft'),
494 'DoCmd 1 ShiftLeft',
495 SHIFTLEFT_MENUP__MSG,
496 HP_POPUP_SHIFTLEFT,
497 nodismiss)
498 DefMenuItem( '', -- Shift left 3
499 SHIFTLEFT3_MENU__MSG,
500 'DoCmd 3 ShiftLeft',
501 SHIFTLEFT3_MENUP__MSG,
502 HP_POPUP_SHIFTLEFT3,
503 nodismiss)
504 DefMenuItem( '', -- Shift left 8
505 SHIFTLEFT8_MENU__MSG,
506 'DoCmd 8 ShiftLeft',
507 SHIFTLEFT8_MENUP__MSG,
508 HP_POPUP_SHIFTLEFT8,
509 nodismiss)
510 DefMenuItem( '', -- Shift right 1
511 SHIFTRIGHT_MENU__MSG''MenuAccelString( 'ShiftRight'),
512 'DoCmd 1 ShiftRight',
513 SHIFTRIGHT_MENUP__MSG,
514 HP_POPUP_SHIFTRIGHT,
515 'BREAKSEPARATOR' nodismiss)
516 DefMenuItem( '', -- Shift right 3
517 SHIFTRIGHT3_MENU__MSG,
518 'DoCmd 3 ShiftRight',
519 SHIFTRIGHT3_MENUP__MSG,
520 HP_POPUP_SHIFTRIGHT3,
521 nodismiss)
522 DefNextItemEndsSubMenu()
523 DefMenuItem( '', -- Shift right 8
524 SHIFTRIGHT8_MENU__MSG,
525 'DoCmd 8 ShiftRight',
526 SHIFTRIGHT8_MENUP__MSG,
527 HP_POPUP_SHIFTRIGHT8,
528 nodismiss)
529 DefMenuItem( '', -- Center text
530 CENTER_MARK_MENU__MSG,
531 'CenterMark',
532 CENTER_MARK_MENUP__MSG,
533 HP_POPUP_CENTERMARK,
534 miaformatable)
535 DefMenuSep() --------------------
536
537 DefMenuItem( '', -- Copy
538 CLIP_COPY_MENU__MSG,
539 'Copy2Clip',
540 CLIP_COPY_MENUP__MSG,
541 HP_EDIT_COPY)
542 DefMenuItem( '', -- Cut
543 CUT_MENU__MSG,
544 'Cut',
545 CUT_MENUP__MSG,
546 HP_EDIT_CUT)
547 DefMenuSep() --------------------
548
549 DefMenuItem( '', -- Style...
550 'St~yle...',
551 'FontList',
552 'St~yle...',
553 HP_OPTIONS_STYLE)
554compile if CHECK_FOR_LEXAM
555 if LEXAM_is_available then
556compile endif
557 DefMenuSep() --------------------
558
559 DefMenuItem( '', -- Proof
560 PROOF_MENU__MSG,
561 'Proof',
562 PROOF_MENUP__MSG,
563 HP_OPTIONS_PROOF)
564compile if CHECK_FOR_LEXAM
565 endif
566compile endif
567 DefMenuSep() --------------------
568
569 DefMenuItem( '', -- Print mark...
570 PRT_MARK_MENU__MSG'...',
571 'PrintDlg M',
572 ENHPRT_MARK_MENUP__MSG,
573 HP_EDIT_ENHPRINT)
574
575; ---------------------------------------------------------------------------
576defproc PopupMenuItemsOutsideMark
577 universal CUA_marking_switch
578 on = (marktype() <> '')
579 if CUA_marking_switch then
580 cua_on = 1
581 else
582 cua_on = 0
583 endif
584 if (on & not cua_on) then
585 miamark = ''
586 else
587 miamark = 'DISABLED'
588 endif
589 DefMenuItem( '', -- Copy mark
590 '~Copy mark',
591 'CopyMark',
592 COPY_MARK_MENUP__MSG,
593 HP_EDIT_COPYMARK,
594 miamark)
595 DefMenuItem( '', -- Move mark
596 MOVE_MARK_MENU__MSG,
597 'MoveMark',
598 MOVE_MARK_MENUP__MSG,
599 HP_EDIT_MOVE,
600 miamark)
601 DefMenuItem( '', -- Overlay mark
602 OVERLAY_MARK_MENU__MSG,
603 'OverlayMark',
604 OVERLAY_MARK_MENUP__MSG,
605 HP_EDIT_OVERLAY,
606 miamark)
607 DefMenuItem( '', -- Adjust mark
608 '~Adjust mark',
609 'AdjustMark',
610 ADJUST_MARK_MENUP__MSG,
611 HP_EDIT_ADJUST,
612 miamark)
613 DefMenuSep() --------------------
614
615 DefMenuItem( '', -- Unmark
616 UNMARK_MARK_MENU__MSG,
617 'Unmark',
618 UNMARK_MARK_MENUP__MSG,
619 HP_EDIT_UNMARK)
620
621; ---------------------------------------------------------------------------
622defproc PopupMenuItemsNoMark
623 -- Disable menu items if cursor is on a space char
624 ch = substr( textline( .line), .col, 1)
625 fCurCharIsMarkable = (ch <> ' ' & .line)
626 if fCurCharIsMarkable then
627 miamarkable = ''
628 else
629 miamarkable = 'DISABLED'
630 endif
631
632 -- Disable menu items if clipboard is empty or file is not editable
633 fPasteEnabled = (ClipCheck( format) & (format = 1024) & not (browse() | .readonly))
634 if fPasteEnabled then
635 miapastable = ''
636 else
637 miapastable = 'DISABLED'
638 endif
639
640 -- Build MenuAccelString dynamically, depending on the definition for
641 -- DefaultPaste and AlternatePaste
642 KeyPath = '\NEPMD\User\Mark\DefaultPaste'
643 next = substr( upcase( QueryConfigKey( KeyPath)), 1, 1)
644 if next = 'L' then
645 style = 'L'
646 altstyle = 'C'
647 elseif next = 'B' then
648 style = 'B'
649 altstyle = 'C'
650 else
651 style = 'C'
652 altstyle = 'L'
653 endif
654 if style = 'C' then
655 PasteCMenuAccelString = MenuAccelString( 'DefaultPaste')
656 elseif altstyle = 'C' then
657 PasteCMenuAccelString = MenuAccelString( 'AlternatePaste')
658 else
659 PasteCMenuAccelString = ''
660 endif
661 if style = 'L' then
662 PasteLMenuAccelString = MenuAccelString( 'DefaultPaste')
663 elseif altstyle = 'L' then
664 PasteLMenuAccelString = MenuAccelString( 'AlternatePaste')
665 else
666 PasteLMenuAccelString = ''
667 endif
668 if style = 'B' then
669 PasteBMenuAccelString = MenuAccelString( 'DefaultPaste')
670 elseif altstyle = 'B' then
671 PasteBMenuAccelString = MenuAccelString( 'AlternatePaste')
672 else
673 PasteBMenuAccelString = ''
674 endif
675
676 DefMenuItem( '', -- Mark identifier
677 MARK_TOKEN_MENU__MSG,
678 'MarkToken',
679 MARK_TOKEN_MENUP__MSG,
680 HP_POPUP_MARKTOKEN,
681 miamarkable)
682 DefMenuItem( '', -- Mark word
683 MARK_WORD_MENU__MSG,
684 'MarkWord',
685 MARK_WORD_MENUP__MSG,
686 HP_POPUP_MARKWORD,
687 miamarkable)
688 DefMenuItem( '', -- Find identifier
689 FIND_TOKEN_MENU__MSG,
690 'FindToken',
691 FIND_TOKEN_MENUP__MSG,
692 HP_POPUP_FINDTOKEN,
693 miamarkable)
694 DefMenuSep() --------------------
695
696compile if WANT_TEXT_PROCS
697 DefMenuItem( '', -- Mark sentence
698 MARK_SENTENCE_MENU__MSG,
699 'MarkSentence',
700 MARK_SENTENCE_MENUP__MSG,
701 HP_POPUP_MARKSENTENCE)
702 DefMenuItem( '', -- Mark paragraph
703 MARK_PARAGRAPH_MENU__MSG,
704 'MarkParagraph',
705 MARK_PARAGRAPH_MENUP__MSG,
706 HP_POPUP_MARKPARAGRAPH)
707 DefMenuSep() --------------------
708
709compile endif -- WANT_TEXT_PROCS
710 DefMenuItem( '', -- Reflow paragraph
711 'Refl~ow paragraph',
712 'ReflowPar2ReflowMargins',
713 'Reflow text from cursor to next empty line',
714 HP_POPUP_REFLOW)
715 DefMenuSep() --------------------
716
717 DefMenuItem( '', -- Toggle case of word
718 'Toggle ~case of word',
719 'CaseWord',
720 'Rotate case: lower -> mixed -> upper',
721 HP_POPUP_UPCASEWORD,
722 miamarkable)
723 DefMenuItem( '', -- Uppercase word
724 UPCASE_WORD_MENU__MSG,
725 'UppercaseWord',
726 UPCASE_WORD_MENUP__MSG,
727 HP_POPUP_UPCASEWORD,
728 miamarkable)
729 DefMenuItem( '', -- Lowercase word
730 LOCASE_WORD_MENU__MSG,
731 'LowercaseWord',
732 LOCASE_WORD_MENUP__MSG,
733 HP_POPUP_LOCASEWORD,
734 miamarkable)
735 DefMenuSep() --------------------
736
737 DefMenuItem( '', -- Center line
738 CENTER_LINE_MENU__MSG,
739 'CenterLine',
740 CENTER_LINE_MENUP__MSG,
741 HP_POPUP_CENTERLINE)
742 DefMenuItem( '', -- Scroll to top
743 TOP_LINE_MENU__MSG,
744 'NewTop',
745 TOP_LINE_MENUP__MSG,
746 HP_POPUP_TOP)
747 DefMenuSep() --------------------
748
749compile if POPUP_ENABLE_CASCADE
750 -- Cascade menu are now replaced by inline menu items, because it doesnot work correctly:
751 DefNextItemStartsSubMenu()
752 DefMenuItem( 'popup_paste', -- Paste >
753 PASTE_C_MENU__MSG,
754 PASTE_C_MENUP__MSG ,
755 '',
756 HP_EDIT_PASTEMENU,
757 miapastable)
758 DefMenuItem( 'popup_pastec', -- Paste
759 PASTE_C_MENU__MSG''PasteCMenuAccelString,
760 'Paste C',
761 PASTE_C_MENUP__MSG,
762 HP_EDIT_PASTEC,
763 miapastable)
764 DefMenuItem( 'popup_pastel', -- Paste lines
765 PASTE_L_MENU__MSG''PasteLMenuAccelString,
766 'Paste',
767 PASTE_L_MENUP__MSG,
768 HP_EDIT_PASTE,
769 miapastable)
770 DefNextItemEndsSubMenu()
771 DefMenuItem( 'popup_pasteb', -- Paste block
772 PASTE_B_MENU__MSG''PasteBMenuAccelString,
773 'Paste B',
774 PASTE_B_MENUP__MSG,
775 HP_EDIT_PASTEB,
776 miapastable)
777compile else
778 DefMenuItem( '', -- Paste
779 PASTE_C_MENU__MSG''PasteCMenuAccelString,
780 'Paste C',
781 PASTE_C_MENUP__MSG,
782 HP_EDIT_PASTEC,
783 miapastable)
784 DefMenuItem( '', -- Paste lines
785 'P~aste lines'PasteLMenuAccelString,
786 'Paste',
787 PASTE_L_MENUP__MSG,
788 HP_EDIT_PASTE,
789 miapastable)
790 DefMenuItem( '', -- Paste block
791 PASTE_B_MENU__MSG''PasteBMenuAccelString,
792 'Paste B',
793 PASTE_B_MENUP__MSG,
794 HP_EDIT_PASTEB,
795 miapastable)
796compile endif
797
798; ---------------------------------------------------------------------------
799; These items are appended, except for .Tree files
800defproc PopupMenuItemsCommon
801 CurMode = GetMode()
802
803 -- Disable TagScan menu item if mode is not supported
804 'LinkVerify tags' -- Remains linked afterwards
805 if leftstr( .filename, 1) = '.' then -- virtual file
806 miatagssupported = 'DISABLED'
807 elseif Tags_Supported( CurMode) then
808 miatagssupported = ''
809 else
810 miatagssupported = 'DISABLED'
811 endif
812
813 -- Disable FindDef menu item if cursor is not on an identifier
814 -- CurIdentifier() here would lead to crashes - by grep search with pos?
815 ch = substr( textline( .line), .col, 1)
816 fCurCharIsMarkable = (ch <> ' ' & .line)
817 if fCurCharIsMarkable & GetFindDefOptionDefined( 'finddefmode') then
818 miafinddefmode = ''
819 else
820 miafinddefmode = 'DISABLED'
821 endif
822
823 DefMenuSep() --------------------
824
825 DefMenuItem( '', -- Open extracted string
826 'Open extracted strin~g',
827 'Alt_1',
828 'Load file or URL under cursor',
829 '')
830 DefMenuSep() --------------------
831
832 DefMenuItem( '', -- Find definition for mode
833 'Find d~efinition',
834 'FindDef',
835 '',
836 '',
837 miafinddefmode)
838 DefMenuItem( '', -- Scan file for tags
839 '~Scan file for tags' /*SCAN_TAGS_MENU__MSG*/,
840 'TagScan',
841 SCAN_TAGS_MENUP__MSG,
842 HP_SEARCH_TAGS,
843 miatagssupported)
844
845 if isadefc( 'PrefsPopupMenu') then
846 DefMenuSep() --------------------
847
848 DefMenuItem( 'preferences', -- Preferences...
849 'Preferences~...',
850 'PrefsPopupMenu',
851 'Menus related to editor settings',
852 '')
853 endif
854
855; ---------------------------------------------------------------------------
856; Cascade menu is now replaced by inline menu items, because it doesnot
857; work correctly:
858; The frame around the submenu arrow is only painted after activating
859; that menu item. Before that, one thinks that's a normal submenu item
860; that won't execute something on selecting it.
861; This is executed posted by popup.e:"defc MH_Popup".
862compile if POPUP_ENABLE_CASCADE
863defc AddCascadePopupMenu
864 -- Define that only for the Nomark popup menu
865 if marktype() = '' then
866 KeyPath = "\NEPMD\User\Mark\DefaultPaste"
867 DefaultPaste = QueryConfigKey( KeyPath)
868 if DefaultPaste = 'C' then
869 AlternatePaste = 'L'
870 else
871 AlternatePaste = 'C'
872 endif
873 if DefaultPaste = 'L' then -- arg for defc paste maybe 'C', 'B' or ''
874 DefaultPaste = ''
875 endif
876 if AlternatePaste = 'L' then -- arg for defc paste maybe 'C', 'B' or ''
877 AlternatePaste = ''
878 endif
879
880 if isadefc( 'CascadeMenu') then
881 CascadeCmd = 'CascadeMenu'
882 else
883 CascadeCmd = 'Cascade_Menu'
884 endif
885 if DefaultPaste = 'C' then
886 CascadeCmd' popup_paste popup_pastec' -- Paste cascade; default is Paste (character mark)
887 elseif DefaultPaste = 'B' then
888 CascadeCmd' popup_paste popup_pasteb' -- Paste cascade; default is Paste Block
889 else
890 CascadeCmd' popup_paste popup_pastel' -- Paste cascade; default is Paste Lines
891 endif
892 endif
893compile endif
894
Note: See TracBrowser for help on using the repository browser.