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

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