home *** CD-ROM | disk | FTP | other *** search
- compile if EVERSION < 5
- *** Error: This file supports EPM only, not earlier versions of E.
- compile endif
-
- compile if not defined(SMALL) -- If SMALL not defined, then being separately compiled
- include 'stdconst.e'
- include 'colors.e'
- define INCLUDING_FILE = 'MOUSE.E'
- tryinclude 'MYCNF.E' -- Include the user's configuration customizations.
-
- compile if not defined(SITE_CONFIG)
- const SITE_CONFIG = 'SITECNF.E'
- compile endif
- compile if SITE_CONFIG
- tryinclude SITE_CONFIG
- compile endif
-
- const
- compile if not defined(WANT_CUA_MARKING)
- WANT_CUA_MARKING = 0
- compile endif
- compile if not defined(WANT_STREAM_MODE)
- WANT_STREAM_MODE = 0
- compile endif
- compile if not defined(NLS_LANGUAGE)
- NLS_LANGUAGE = 'ENGLISH'
- compile endif
- compile if not defined(WANT_KEYWORD_HELP)
- WANT_KEYWORD_HELP = 0
- compile endif
- include NLS_LANGUAGE'.e'
- compile endif
-
- const
- compile if not defined(EPM_POINTER)
- compile if EVERSION < 5.50
- EPM_POINTER = SYSTEM_POINTER -- AVIO version gets arrow pointer
- compile else
- EPM_POINTER = TEXT_POINTER -- GPI version gets text pointer
- compile endif
- compile endif
- compile if not defined(LOCAL_MOUSE_SUPPORT)
- LOCAL_MOUSE_SUPPORT = 0
- compile endif
- compile if not defined(TOP_OF_FILE_VALID)
- TOP_OF_FILE_VALID = 1
- compile endif
- compile if not defined(DRAG_ALWAYS_MARKS)
- DRAG_ALWAYS_MARKS = 0
- compile endif
- compile if not defined(WANT_MMEDIA)
- WANT_MMEDIA = 0
- compile endif
- compile if not defined(WANT_SPEECH)
- WANT_SPEECH = 0
- compile endif
- compile if not defined(UNDERLINE_CURSOR)
- UNDERLINE_CURSOR = 0
- compile endif
-
-
- const
- BlankMouseHandler = "BlankMouseHandler"
- TransparentMouseHandler = "TransparentMouseHandler"
-
- define
- compile if EVERSION < 5.50
- CHARG_MARK = 'CHAR'
- BLOCKG_MARK = 'BLOCK'
- compile else -- New mark types
- CHARG_MARK = 'CHARG'
- BLOCKG_MARK = 'BLOCKG'
- compile endif
-
- compile if EVERSION >= 5.20
- defproc prestore_pos2(save_pos)
- parse value save_pos with svline svcol svsx svsy
- compile if EVERSION >= 5.50
- .lineg = min(svline, .last); -- set .line
- compile else
- min(svline, .last); -- set .line
- compile endif
- .col = svcol;
- .scrollx = svsx;
- compile if EVERSION >= 5.50
- .cursoryg= svsy;
- compile else
- .scrolly = svsy;
- compile endif
-
- defproc psave_pos2(var save_pos)
- compile if EVERSION >= 5.50
- save_pos=.line .col .scrollx .cursoryg
- compile else
- save_pos=.line .col .scrollx .scrolly
- compile endif
- compile endif
-
- defproc MouseLineColOff(var MouseLine, var MouseCol, var MouseOff, minline)
- -- MIN = 0 for positioning, 1 for marking.
- xxx = .mousex; mx = xxx
- yyy = .mousey
-
- -- saying 5.21, below, but not sure if it will work for that.
- -- it will work for 5.50.
-
- compile if EVERSION >= 5.21
- --call messagenwait("xxx1="xxx "yyy1="yyy);
- map_point 5, xxx, yyy, off, comment; -- map screen to line
- --call messagenwait("doc xxx2="xxx "yyy2="yyy);
- compile else
- --call messagenwait("xxx1="xxx "yyy1="yyy);
- map_point 1, xxx, yyy, off, comment; -- map screen to doc
- --call messagenwait("doc xxx2="xxx "yyy2="yyy);
- map_point 2, xxx, yyy, off, comment; -- map doc to line/col/offset
- --call messagenwait("line="xxx "col="yyy "off="off);
- compile endif
- MouseLine = min(max(xxx, minline), .last)
- MouseOff = off
- compile if EVERSION >= 5.50 -- can go to MAXCOL+1 for GPI-style marking
- if arg(6) then -- Flag we want character we're on, not nearest intersection.
- lne = xxx
- col = yyy
- map_point 6, lne, col, off, comment; -- map line/col/offset to screen
- if lne>mx then -- The intersection selected is to the right of the mouse pointer;
- yyy = yyy - 1 -- the character clicked on is the one to the left.
- endif -- Note: could get col. 0 this way, the but following takes care of that.
- endif
- MouseCol = min(max(yyy, 1), MAXCOL + (rightstr(arg(5),1)='G' and minline))
- compile else
- MouseCol = min(max(yyy, 1), MAXCOL)
- compile endif
- return xxx
-
- defproc SetMouseSet(IsGlobal, NewMSName)
- universal GMousePrefix
- universal LMousePrefix
- universal EPM_utility_array_ID
- if IsGlobal then
- GMousePrefix = NewMSName"."
- compile if LOCAL_MOUSE_SUPPORT
- else
- LMousePrefix = NewMSName"."
- -- Remember Local MouseSet
- getfileid ThisFile;
- do_array 2, EPM_utility_array_ID, "LocalMausSet."ThisFile, NewMSName
- compile endif
- endif
-
- compile if 0 -- Now in SELECT.E, only if LOCAL_MOUSE_SUPPORT = 1
- defselect
- universal LMousePrefix
- universal EPM_utility_array_ID
- getfileid ThisFile
- OldRC = Rc
- rc = get_array_value(EPM_utility_array_ID, "LocalMausSet."ThisFile, NewMSName)
- if RC then
- if rc=-330 then
- -- no mouseset bound to file yet, assume blank.
- LMousePrefix = TransparentMouseHandler"."
- else
- call messagenwait('RC='RC)
- endif
- RC = OldRC
- else
- LMousePrefix = NewMSName"."
- endif
- compile endif
-
- defc processmousedropping
- call psave_pos(savepos)
- 'MH_gotoposition'
- 'GetSharBuff' -- See clipbrd.e for details
- call prestore_pos(savepos)
-
- defc processmouse
- universal EPM_utility_array_ID
- universal GMousePrefix
- universal LMousePrefix
- if LMousePrefix<>BlankMouseHandler"." then
- OldRc = rc
- compile if LOCAL_MOUSE_SUPPORT
- rc = get_array_value(EPM_utility_array_ID, LMousePrefix||arg(1), CommandString)
- if not rc then
- -- Found it.
- Rc = oldRC
- if CommandString<>'' then
- CommandString
- return
- endif
- else
- if rc<>-330 then
- sayerror UNKNOWN_MOUSE_ERROR__MSG rc
- rc = OldRc
- return
- endif
- -- rc==-330 (no local handler found), now try to find a global one.
- endif
- compile endif
- if GMousePrefix<>BlankMouseHandler"." then
- rc = get_array_value(EPM_utility_array_ID, GMousePrefix||arg(1), CommandString)
- if not rc then
- -- Found it.
- Rc = oldRC
- if CommandString<>'' then
- CommandString
- endif
- return
- else
- if rc<>-330 then
- sayerror UNKNOWN_MOUSE_ERROR__MSG rc
- else
- -- nothing assigned to that action
- endif
- rc = OldRc
- return
- endif
- endif
- endif
-
-
- defproc register_mousehandler(IsGlobal, event, mcommand)
- universal EPM_utility_array_ID
- universal GMousePrefix
- universal LMousePrefix
- if IsGlobal then
- MousePrefix = GMousePrefix
- else
- compile if LOCAL_MOUSE_SUPPORT
- if (LMousePrefix=BlankMouseHandler".") or
- (LMousePrefix=TransparentMouseHandler".") then
- -- can't assign to that mouse handler.
- compile endif
- return
- compile if LOCAL_MOUSE_SUPPORT
- endif
- MousePrefix = LMousePrefix
- compile endif
- endif
- do_array 2, EPM_utility_array_ID, MousePrefix||event, mcommand -- assign
-
- defc MH_gotoposition
- compile if WANT_STREAM_MODE = 'SWITCH'
- universal stream_mode
- compile endif
- -- this procedure moves the cursor to the current mouse location.
- ;;
- ;; Old way
- ;;
- ;; .cursory = .mousey
- ;; .cursorx = .mousex
- ;;
- compile if TOP_OF_FILE_VALID
- compile if UNDERLINE_CURSOR
- ml = MouseLineColOff(MouseLine, MouseCol, MouseOff, 0, '', 1)
- compile else
- ml = MouseLineColOff(MouseLine, MouseCol, MouseOff, 0)
- compile endif
- compile else
- compile if UNDERLINE_CURSOR
- ml = MouseLineColOff(MouseLine, MouseCol, MouseOff, 1, '', 1)
- compile else
- ml = MouseLineColOff(MouseLine, MouseCol, MouseOff, 1)
- compile endif
- compile endif
- compile if EVERSION >= 5.20
- oldsx = .scrollx;
- compile if EVERSION >= 5.50
- .lineg = MouseLine
- compile else
- oldsy = .scrolly;
- MouseLine
- compile endif
- compile else
- MouseLine
- compile endif
- compile if WANT_STREAM_MODE
- compile if WANT_STREAM_MODE = 'SWITCH'
- if stream_mode & ml > .last then
- compile else
- if ml > .last then -- If click below "Bottom of File",
- compile endif
- end_line -- go to end of last line.
- else
- compile endif -- WANT_STREAM_MODE
- .col = MouseCol
- while MouseOff<0 do
- left
- MouseOff = MouseOff + 1
- endwhile
- while MouseOff>0 do
- right
- MouseOff = MouseOff - 1
- endwhile
- compile if WANT_STREAM_MODE
- endif
- compile endif -- WANT_STREAM_MODE
- compile if WANT_STREAM_MODE
- compile if WANT_STREAM_MODE = 'SWITCH'
- if stream_mode then
- compile endif
- if .col > length(textline(.line)) then
- end_line
- endif
- compile if WANT_STREAM_MODE = 'SWITCH'
- endif
- compile endif
- compile endif
- compile if EVERSION >= 5.20
- .scrollx = oldsx;
- compile if EVERSION >= 5.50
- compile else
- .scrolly = oldsy;
- compile endif
- compile endif
-
- defc MH_begin_mark
- universal BeginningLineOfDrag
- universal BeginningColOfDrag
- compile if WANT_CUA_MARKING = 'SWITCH'
- universal CUA_marking_switch
- compile endif
- compile if WANT_STREAM_MODE = 'SWITCH'
- universal stream_mode
- compile endif
- compile if 0
- mt = upcase(arg(1))
- if marktype() then
- getfileid curfileid
- getmark markfirstline,marklastline,markfirstcol,marklastcol,markfileid
- if marktype() <> mt or markfileid <> curfileid then
- sayerror -279 -- sayerror('Text already marked')
- return
- endif
- endif
- compile elseif WANT_CUA_MARKING = 1 | DRAG_ALWAYS_MARKS
- unmark
- 'ClearSharBuff' /* Remove Content in EPM shared text buffer */
- compile else
- compile if WANT_CUA_MARKING = 'SWITCH'
- if CUA_marking_switch then
- unmark
- 'ClearSharBuff' /* Remove Content in EPM shared text buffer */
- endif
- compile endif
- if marktype() then
- sayerror-279 -- sayerror('Text already marked')
- return
- endif
- compile endif
- ml = MouseLineColOff(BeginningLineOfDrag, BeginningColOfDrag, MouseOff, 1, arg(1));
- compile if WANT_STREAM_MODE
- compile if WANT_STREAM_MODE = 'SWITCH'
- if stream_mode & ml > .last then
- compile else
- if ml > .last then -- If click below "Bottom of File" ...
- compile endif
- BeginningLineOfDrag = .last
- BeginningColOfDrag = length(textline(.last))+1
- endif
- compile endif -- WANT_STREAM_MODE
- call register_mousehandler(1, 'ENDDRAG', 'MH_end_mark '||arg(1)) -- shifted
- call register_mousehandler(1, 'CANCELDRAG', 'MH_cancel_mark') -- shifted
- if upcase(arg(1))='LINE' then
- .DragStyle = 2
- elseif leftstr(upcase(arg(1)),5)='BLOCK' then
- .DragStyle = 1
- elseif leftstr(upcase(arg(1)),4)='CHAR' then
- .DragStyle = 3
- endif
- mouse_setpointer MARK_POINTER
- compile if DRAGCOLOR<>''
- .DragColor = DRAGCOLOR
- compile else
- .DragColor = .markcolor
- compile endif
-
- defc MH_end_mark
- universal BeginningLineOfDrag
- universal BeginningColOfDrag
- compile if WANT_CUA_MARKING = 'SWITCH'
- universal CUA_marking_switch
- compile endif
- compile if WANT_STREAM_MODE = 'SWITCH'
- universal stream_mode
- compile endif
- ml = MouseLineColOff(endingline, endingcol, MouseOff, 1, arg(1));
- compile if WANT_STREAM_MODE
- compile if WANT_STREAM_MODE = 'SWITCH'
- if stream_mode & ml > .last then
- compile else
- if ml > .last then -- If click below "Bottom of File" ...
- compile endif
- endingline = .last
- endingcol = length(textline(.last))+1
- endif
- if not (ml > .last & BeginningLineOfDrag = endingline & BeginningColOfDrag = endingcol) then
- compile endif -- WANT_STREAM_MODE
- unmark
- getfileid CurrentFile
- call pset_mark(BeginningLineOfDrag, endingline,
- BeginningColOfDrag, max(endingcol,1), arg(1), CurrentFile)
- /* Copy the marked area to the clipboard in case we want to copy it */
- /* into a different editor window. */
- 'Copy2SharBuff'
- compile if WANT_STREAM_MODE
- else
- refresh -- Get rid of the drag-mark highlighting
- endif
- compile endif -- WANT_STREAM_MODE
- mouse_setpointer EPM_POINTER
- compile if WANT_CUA_MARKING
- compile if WANT_CUA_MARKING = 'SWITCH'
- if CUA_marking_switch then
- compile endif
- compile if EVERSION >= '5.50' -- GPI version allows cursor to be off screen
- if .cursorx > 0 & .cursorx <= .windowwidth & .cursory > 0 & .cursory <= .windowheight then
- compile endif
- getmark firstline,lastline,firstcol,lastcol,fileid
- if marktype()<>'LINE' then
- .col=lastcol
- endif
- if lastline<>.line then
- if lastline>.line then '+'lastline-.line; else lastline-.line; endif
- endif
- compile if EVERSION >= '5.50'
- endif
- compile endif
- 'MH_gotoposition'
- compile if WANT_CUA_MARKING = 'SWITCH'
- endif
- compile endif
- compile endif
- ; refresh ???
- call register_mousehandler(1, 'ENDDRAG', ' ')
- call register_mousehandler(1, 'CANCELDRAG', ' ')
-
- defc MH_cancel_mark
- mouse_setpointer EPM_POINTER
- call register_mousehandler(1, 'ENDDRAG', ' ')
- call register_mousehandler(1, 'CANCELDRAG', ' ')
- refresh
-
- defc markword
- if arg(1) then
- 'MH_gotoposition'
- unmark
- endif
- call pmark_word()
-
- defc marktoken
- if arg(1) then
- 'MH_gotoposition'
- endif
- if find_token(startcol, endcol) then
- getfileid fid
- compile if WANT_CHAR_OPS
- call pset_mark(.line, .line, startcol, endcol, 'CHAR', fid)
- compile else
- call pset_mark(.line, .line, startcol, endcol, 'BLOCK', fid)
- compile endif
- 'Copy2SharBuff' /* Copy mark to shared text buffer */
- endif
-
- defc findword
- if arg(1) then
- 'MH_gotoposition'
- endif
- if find_token(startcol, endcol) then
- .col = endcol
- 'l '\1 || substr(textline(.line), startcol, (endcol-startcol)+1)
- endif
-
- compile if WANT_CUA_MARKING
- defc MH_singleclick
- unmark
- 'ClearSharBuff' /* Remove Content in EPM shared text buffer */
- 'MH_gotoposition'
-
- defc MH_dblclick
- unmark
- if .line then
- ;; call pmark_word() -- pmark_word doesn't include white space; the following does:
- call pbegin_word()
- mark_block
- startcol = .col
- tab_word
- if .col<length(textline(.line)) then .col = .col - 1; endif
- mark_block
- .col = startcol
- endif
- 'Copy2SharBuff' /* Copy mark to shared text buffer */
-
- compile endif
-
- defc MH_double -- Used to be just 'dupmark U', but now overloaded in a DIR listing:
- if upcase(subword(.filename,1,2)) = '.DOS DIR' then
- executekey a_1 -- For simplicity, assume user hasn't redefined this key:
- else
- unmark
- 'ClearSharBuff'
- endif
-
- defc MH_shiftclick
- if marktype() then
- getmark markfirstline,marklastline,markfirstcol,marklastcol,markfileid
- else
- markfileid=''
- endif
- unmark
- getfileid CurrentFile
- if CurrentFile<>markfileid then
- markfirstline=.line; markfirstcol=.col
- elseif markfirstline=.line & markfirstcol=.col then
- markfirstline=marklastline; markfirstcol=marklastcol
- endif
- call MouseLineColOff(MouseLine, MouseCol, MouseOff, 1, arg(1))
- call pset_mark(markfirstline, MouseLine, markfirstcol, MouseCol, 'CHAR', CurrentFile)
- 'MH_gotoposition'
- 'Copy2SharBuff'
-
- define
- SUPPORT_DRAGDROP_FOR_BOTH = 1 -- Let's see if this works; make it easy to remove if not.
-
- definit
- universal EPM_utility_array_ID, MouseStyle
- compile if WANT_MMEDIA
- universal mmedia_font
- mmedia_font = registerfont('Multimedia Icons', 0, 0)
- compile endif
- compile if (EVERSION < 5.21 & EPM_POINTER<>SYSTEM_POINTER) | (EVERSION >= 5.21 & EPM_POINTER<>TEXT_POINTER)
- mouse_setpointer EPM_POINTER
- compile endif
- -- set initial mousesets
- SetMouseSet(1, "BaseMouseHandlers") -- default global mouseset
- compile if LOCAL_MOUSE_SUPPORT
- SetMouseSet(0, TransparentMouseHandler) -- default local mouseset is blank.
- compile endif
- compile if SUPPORT_DRAGDROP_FOR_BOTH
- call register_mousehandler(1, '2 BEGINDRAG 0', 'MH_begin_drag_2 0')
- call register_mousehandler(1, '2 BEGINDRAG 2', 'MH_begin_drag_2 1')
- compile endif
- compile if WANT_MMEDIA
- call register_mousehandler(1, '1 SECONDCLK 0', 'MH_MM_dblclick')
- compile elseif WANT_SPEECH
- call register_mousehandler(1, '1 SECONDCLK 0', 'SPPopUp')
- compile endif
- compile if WANT_SPEECH
- call register_mousehandler(1, '1 SECONDCLK 2', 'SPPlay')
- compile endif
- compile if WANT_CUA_MARKING = 'SWITCH'
- call MH_SET_Mouse()
-
- defproc MH_set_mouse
- universal CUA_marking_switch, MouseStyle
-
-
- if CUA_marking_switch then
- compile endif
-
- -- 1 == shift, 2 = control, 4 = alt.
- compile if WANT_CUA_MARKING
- call register_mousehandler(1, '1 CLICK 0', 'MH_singleclick')
- call register_mousehandler(1, '1 CLICK 1', 'MH_shiftclick')
- call register_mousehandler(1, '1 CLICK 2', 'MH_singleclick')
- call register_mousehandler(1, '1 CLICK 3', 'MH_shiftclick')
- call register_mousehandler(1, '1 CLICK 4', 'MH_singleclick')
- call register_mousehandler(1, '1 CLICK 5', 'MH_shiftclick')
- call register_mousehandler(1, '1 CLICK 6', 'MH_singleclick')
- call register_mousehandler(1, '1 CLICK 7', 'MH_shiftclick')
- compile if not WANT_MMEDIA and not WANT_SPEECH
- call register_mousehandler(1, '1 SECONDCLK 0', 'MH_dblclick')
- compile endif
- compile if not WANT_SPEECH
- call register_mousehandler(1, '1 SECONDCLK 2', 'MH_dblclick')
- compile endif
- call register_mousehandler(1, '1 SECONDCLK 4', 'MH_dblclick')
- call register_mousehandler(1, '1 SECONDCLK 6', 'MH_dblclick')
- call register_mousehandler(1, '1 BEGINDRAG 0', 'MH_begin_mark' CHARG_MARK)
- call register_mousehandler(1, '1 BEGINDRAG 1', 'MH_begin_mark' CHARG_MARK)
- call register_mousehandler(1, '1 BEGINDRAG 2', 'MH_begin_mark' CHARG_MARK)
- call register_mousehandler(1, '1 BEGINDRAG 3', 'MH_begin_mark' CHARG_MARK)
- call register_mousehandler(1, '1 BEGINDRAG 4', 'MH_begin_mark' CHARG_MARK)
- call register_mousehandler(1, '1 BEGINDRAG 5', 'MH_begin_mark' CHARG_MARK)
- call register_mousehandler(1, '1 BEGINDRAG 6', 'MH_begin_mark' CHARG_MARK)
- call register_mousehandler(1, '1 BEGINDRAG 7', 'MH_begin_mark' CHARG_MARK)
- compile endif -- WANT_CUA_MARKING
-
- compile if WANT_CUA_MARKING = 'SWITCH'
- compile if not SUPPORT_DRAGDROP_FOR_BOTH
- call register_mousehandler(1, '2 BEGINDRAG 0', '') -- Delete the defs
- compile if EVERSION >= 5.50
- call register_mousehandler(1, '2 BEGINDRAG 2', '')
- compile endif
- compile endif -- not SUPPORT_DRAGDROP_FOR_BOTH
- call register_mousehandler(1, '3 BEGINDRAG 0', '') -- from the other style.
- compile if EVERSION >= 5.60
- call register_mousehandler(1, '2 CLICK 0', '')
- compile endif
- call register_mousehandler(1, '2 SECONDCLK 0', '')
- call register_mousehandler(1, '2 SECONDCLK 2', '')
- call register_mousehandler(1, '2 SECONDCLK 1', '')
- else
- compile if EVERSION < 5.50
- call register_mousehandler(1, '1 CLICK 2', '') -- (ditto)
- compile endif
- call register_mousehandler(1, '1 CLICK 4', '')
- call register_mousehandler(1, '1 CLICK 6', '')
- compile if not WANT_SPEECH
- call register_mousehandler(1, '1 SECONDCLK 2', '')
- compile endif
- call register_mousehandler(1, '1 SECONDCLK 4', '')
- call register_mousehandler(1, '1 SECONDCLK 6', '')
- call register_mousehandler(1, '1 BEGINDRAG 1', '')
- call register_mousehandler(1, '1 BEGINDRAG 3', '')
- call register_mousehandler(1, '1 BEGINDRAG 4', '')
- call register_mousehandler(1, '1 BEGINDRAG 5', '')
- call register_mousehandler(1, '1 BEGINDRAG 6', '')
- call register_mousehandler(1, '1 BEGINDRAG 7', '')
- compile endif
-
- compile if WANT_CUA_MARKING = 'SWITCH' or WANT_CUA_MARKING = 0
- call register_mousehandler(1, '1 CLICK 0', 'MH_gotoposition')
- call register_mousehandler(1, '1 CLICK 1', 'MH_shiftclick')
- if MouseStyle = 1 then but_1 = BLOCKG_MARK; c_but_1 = CHARG_MARK
- else but_1 = CHARG_MARK; c_but_1 = BLOCKG_MARK
- endif
- call register_mousehandler(1, '1 BEGINDRAG 0', 'MH_begin_mark 'but_1)
- call register_mousehandler(1, '1 BEGINDRAG 2', 'MH_begin_mark 'c_but_1)
- compile if EVERSION < 5.50
- call register_mousehandler(1, '2 BEGINDRAG 0', 'MH_begin_mark LINE')
- compile else
- compile if not SUPPORT_DRAGDROP_FOR_BOTH
- call register_mousehandler(1, '2 BEGINDRAG 0', 'MH_begin_drag_2 0')
- call register_mousehandler(1, '2 BEGINDRAG 2', 'MH_begin_drag_2 1')
- compile endif -- not SUPPORT_DRAGDROP_FOR_BOTH
- call register_mousehandler(1, '1 CLICK 2', 'MH_gotoposition')
- compile endif
- call register_mousehandler(1, '3 BEGINDRAG 0', 'MH_begin_mark 'c_but_1)
- compile if not WANT_MMEDIA and not WANT_SPEECH
- call register_mousehandler(1, '1 SECONDCLK 0', 'MH_double')
- compile endif
- compile if EVERSION >= 5.60
- call register_mousehandler(1, '2 CLICK 0', 'MH_popup')
- compile endif
- call register_mousehandler(1, '2 SECONDCLK 0', 'markword 1')
- call register_mousehandler(1, '2 SECONDCLK 2', 'marktoken 1')
- call register_mousehandler(1, '2 SECONDCLK 1', 'findword 1')
- compile if WANT_KEYWORD_HELP and not WANT_SPEECH
- call register_mousehandler(1, '1 SECONDCLK 2', 'kwhelp')
- compile endif
- compile endif
-
- compile if WANT_CUA_MARKING = 'SWITCH'
- endif
- compile endif
-
- compile if EVERSION >= 5.50
- defc MH_begin_drag_2 -- Determine if a click is within the selected area
- compile if WANT_CUA_MARKING = 'SWITCH'
- universal CUA_marking_switch
- compile endif
- if mouse_in_mark() then
- call WindowMessage(0, getpminfo(EPMINFO_EDITCLIENT),
- 5434, -- EPM_DRAGDROP_DIRECTMINP
- arg(1),
- 0)
- compile if WANT_CUA_MARKING <> 1 -- If 1, we never do a line mark
- compile if WANT_CUA_MARKING = 'SWITCH'
- elseif not CUA_marking_switch then -- If 'SWITCH', we line mark if CUA switch is off
- compile else -- Else WANT_CUA_MARKING = 0
- else -- so if not drag/drop, we always line mark.
- compile endif -- WANT_CUA_MARKING = 'SWITCH'
- 'MH_begin_mark LINE'
- compile endif -- WANT_CUA_MARKING <> 1
- endif
-
- defproc mouse_in_mark()
- -- First we query the position of the mouse
- call MouseLineColOff(MouseLine, MouseCol, MouseOff, 0)
- -- Now determine if the mouse is in the selected text area.
- mt=leftstr(marktype(),1)
- if mt then
- getfileid curfileid
- getmark markfirstline,marklastline,markfirstcol,marklastcol,markfileid
- if (markfileid == curfileid) and
- (MouseLine >= markfirstline) and (MouseLine <= marklastline) then
-
- -- assert: at this point the only case where the text is outside
- -- the selected area is on a single line char mark and a
- -- block mark. Any place else is a valid selection
- if not ((mt=='C' & (markfirstline=MouseLine & MouseCol < markfirstcol) or (marklastline=MouseLine & MouseCol > marklastcol)) or
- (mt=='B' & (MouseCol < markfirstcol or MouseCol > marklastcol)) ) then
- return 1
- endif
- endif
- endif
- compile endif
-
- compile if WANT_MMEDIA
- defc MH_MM_dblclick
- universal mmedia_font
- compile if WANT_CUA_MARKING = 'SWITCH'
- universal CUA_marking_switch
- compile endif
- -- First we query the position of the mouse
- call MouseLineColOff(MouseLine, MouseCol, MouseOff, 0, '', 1)
- class = 0; offst = -2
- query_attribute class, val, IsPush, offst, MouseCol, MouseLine
- if class=32 /* | (class=16 & val=mmedia_font & IsPush) */ then
- ;; if class=16 then -- If we got the font class, go for the mmedia class.
- ;; offst = -2
- ;; query_attribute class, val, IsPush, offst, MouseCol, MouseLine
- ;; endif
- .col = MouseCol
- ch = asc(substr(textline(MouseLine), MouseCol, 1))
- sayerror 'selected MMedia type' ch 'with value' val
- circleit 1, MouseLine, MouseCol-1, MouseCol+1, 16777220
- compile if WANT_SPEECH
- else -- not mmedia, so do the standard action
- 'SPPopUp' -- Speech support always does this
- compile else
- compile if WANT_CUA_MARKING = 'SWITCH'
- elseif CUA_marking_switch then
- compile else
- else
- compile endif
- compile if WANT_CUA_MARKING
- 'MH_dblclick' -- This is the CUA-marking-mode action
- compile endif
- compile if WANT_CUA_MARKING = 'SWITCH'
- else
- compile endif
- compile if WANT_CUA_MARKING <> 1
- 'MH_Double' -- This is the normal EPM marking mode action
- compile endif
- compile endif
- endif
- compile endif
-
- compile if EVERSION >= 5.60
- const
- FILL_MARK_MENU__MSG = 'Fill mark'
- FILL_MARK_MENUP__MSG = \1'Fill marked region with a character, overlaying current contents.'
- HP_POPUP_FILL = 0
- REFLOW_MARK_MENU__MSG = 'Reflow mark'
- REFLOW_MARK_MENUP__MSG = \1'Reflow text in marked region.'
- HP_POPUP_REFLOW = 0
- MARK_WORD_MENU__MSG = 'Mark word'
- MARK_WORD_MENUP__MSG = \1'Mark space-delimited word under mouse pointer.'
- HP_POPUP_MARKWORD = 0
- MARK_TOKEN_MENU__MSG = 'Mark identifier'
- MARK_TOKEN_MENUP__MSG = \1'Mark the C-language identifier under the mouse pointer.'
- HP_POPUP_MARKTOKEN = 0
- FIND_TOKEN_MENU__MSG = 'Find identifier'
- FIND_TOKEN_MENUP__MSG = \1'Find the next occurrence of the identifier under the mouse pointer.'
- HP_POPUP_FINDTOKEN = 0
- UPCASE_MARK_MENU__MSG = 'Uppercase selection'
- UPCASE_MARK_MENUP__MSG = \1'Translate selected text to upper case.'
- HP_POPUP_UPCASEMARK = 0
- LOCASE_MARK_MENU__MSG = 'Lowercase selection'
- LOCASE_MARK_MENUP__MSG = \1'Translate selected text to lower case.'
- HP_POPUP_LOCASEMARK = 0
- UPCASE_WORD_MENU__MSG = 'Uppercase word'
- UPCASE_WORD_MENUP__MSG = \1'Translate word under mouse pointer to upper case.'
- HP_POPUP_UPCASEWORD = 0
- LOCASE_WORD_MENU__MSG = 'Lowercase word'
- LOCASE_WORD_MENUP__MSG = \1'Translate word under mouse pointer to lower case.'
- HP_POPUP_LOCASEWORD = 0
- SHIFT_MENU__MSG = 'Shift'
- SHIFT_MENUP__MSG = \1'Shift marked text left or right.'
- HP_POPUP_SHIFT = 0
- SHIFTLEFT_MENU__MSG = 'Shift left 1'
- SHIFTLEFT_MENUP__MSG = \1'Shift marked text left 1 character.'
- HP_POPUP_SHIFTLEFT = 0
- SHIFTLEFT3_MENU__MSG = 'Shift left 3'
- SHIFTLEFT3_MENUP__MSG = \1'Shift marked text left 3 characters.'
- HP_POPUP_SHIFTLEFT3 = 0
- SHIFTLEFT8_MENU__MSG = 'Shift left 8'
- SHIFTLEFT8_MENUP__MSG = \1'Shift marked text left 8 characters.'
- HP_POPUP_SHIFTLEFT8 = 0
- SHIFTRIGHT_MENU__MSG = 'Shift right 1'
- SHIFTRIGHT_MENUP__MSG = \1'Shift marked text right 1 character.'
- HP_POPUP_SHIFTRIGHT = 0
- SHIFTRIGHT3_MENU__MSG = 'Shift right 3'
- SHIFTRIGHT3_MENUP__MSG = \1'Shift marked text right 3 characters.'
- HP_POPUP_SHIFTRIGHT3 = 0
- SHIFTRIGHT8_MENU__MSG = 'Shift right 8'
- SHIFTRIGHT8_MENUP__MSG = \1'Shift marked text right 8 characters.'
- HP_POPUP_SHIFTRIGHT8 = 0
- CENTER_LINE_MENU__MSG = 'Center line'
- CENTER_LINE_MENUP__MSG = \1'Center line under mouse pointer vertically in window.'
- HP_POPUP_CENTERLINE = 0
- CENTER_MARK_MENU__MSG = 'Center text'
- CENTER_MARK_MENUP__MSG = \1'Center marked text within margins or block mark.'
- HP_POPUP_CENTERMARK = 0
- SORT_MARK_MENU__MSG = 'Sort'
- SORT_MARK_MENUP__MSG = \1'Sort marked lines, using block mark (if present) as key.'
- HP_POPUP_SORT = 0
- TOP_LINE_MENU__MSG = 'Scroll to top'
- TOP_LINE_MENUP__MSG = \1'Scroll so line under mouse pointer is at top of window.'
- HP_POPUP_TOP = 0
-
- defc MH_popup
- universal activemenu, previouslyactivemenu
- compile if CHECK_FOR_LEXAM
- universal LEXAM_is_available
- compile endif
- if previouslyactivemenu = '' then
- previouslyactivemenu = activemenu
- endif
- menuname = 'popup1'
- activemenu = menuname
-
- deletemenu menuname, 0, 0, 0
- buildsubmenu menuname, 80, '', '', 0 , 0
- mt = leftstr(marktype(),1)
- if mouse_in_mark() then -- Build Inside-Mark pop-up
- gray_if_charmark = 16384*(MT='C')
- buildmenuitem menuname, 80, 8000, UNMARK_MARK_MENU__MSG\9'Alt+U', 'DUPMARK U'UNMARK_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_UNMARK, 0)
- buildmenuitem menuname, 80, 8001, DELETE_MARK_MENU__MSG\9'Alt+D', 'DUPMARK D'DELETE_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_DELETE, 0)
- buildmenuitem menuname, 80, 8002, FILL_MARK_MENU__MSG\9'Alt+F', 'Fill'FILL_MARK_MENUP__MSG, 0, mpfrom2short(HP_POPUP_FILL, 0)
- buildmenuitem menuname, 80, 8003, REFLOW_MARK_MENU__MSG\9'Alt+P', 'key 1 a+P'REFLOW_MARK_MENUP__MSG, 0, mpfrom2short(HP_POPUP_REFLOW, gray_if_charmark)
- buildmenuitem menuname, 80, 8004, UPCASE_MARK_MENU__MSG\9'Ctrl+F3', 'key 1 c+f3'UPCASE_MARK_MENUP__MSG, 0, mpfrom2short(HP_POPUP_UPCASEMARK, 0)
- buildmenuitem menuname, 80, 8005, LOCASE_MARK_MENU__MSG\9'Ctrl+F4', 'key 1 c+f4'LOCASE_MARK_MENUP__MSG, 0, mpfrom2short(HP_POPUP_LOCASEMARK, 0)
- buildmenuitem menuname, 80, 8006, SORT_MARK_MENU__MSG, 'Sort'SORT_MARK_MENUP__MSG, 0, mpfrom2short(HP_POPUP_SORT, gray_if_charmark)
- buildmenuitem menuname, 80, 8007, \0, '', 4, 0
- buildmenuitem menuname, 80, 8008, SHIFT_MENU__MSG, ''SHIFT_MENUP__MSG, 17, mpfrom2short(HP_POPUP_SHIFT, gray_if_charmark)
- nodismiss_gifc = gray_if_charmark + 32 -- 32 = MIA_NODISMISS
- buildmenuitem menuname, 80, 8009, SHIFTLEFT_MENU__MSG\9'Ctrl+F7', 'key 1 a+F7'SHIFTLEFT_MENUP__MSG, 1, mpfrom2short(HP_POPUP_SHIFTLEFT, nodismiss_gifc)
- buildmenuitem menuname, 80, 8010, SHIFTLEFT3_MENU__MSG, 'key 3 a+F7'SHIFTLEFT3_MENUP__MSG, 1, mpfrom2short(HP_POPUP_SHIFTLEFT3, nodismiss_gifc)
- buildmenuitem menuname, 80, 8011, SHIFTLEFT8_MENU__MSG, 'key 8 a+F7'SHIFTLEFT8_MENUP__MSG, 1, mpfrom2short(HP_POPUP_SHIFTLEFT8, nodismiss_gifc)
- buildmenuitem menuname, 80, 8013, SHIFTRIGHT_MENU__MSG\9'Ctrl+F8', 'key 1 a+F8'SHIFTRIGHT_MENUP__MSG, 2049, mpfrom2short(HP_POPUP_SHIFTRIGHT, nodismiss_gifc)
- buildmenuitem menuname, 80, 8014, SHIFTRIGHT3_MENU__MSG, 'key 3 a+F8'SHIFTRIGHT3_MENUP__MSG, 1, mpfrom2short(HP_POPUP_SHIFTRIGHT3, nodismiss_gifc)
- buildmenuitem menuname, 80, 8015, SHIFTRIGHT8_MENU__MSG, 'key 8 a+F8'SHIFTRIGHT8_MENUP__MSG, 32769, mpfrom2short(HP_POPUP_SHIFTRIGHT8, nodismiss_gifc)
- buildmenuitem menuname, 80, 8016, CENTER_MARK_MENU__MSG\9'Alt+T', 'key 1 a+t'CENTER_MARK_MENUP__MSG, 0, mpfrom2short(HP_POPUP_CENTERMARK, gray_if_charmark)
- buildmenuitem menuname, 80, 8017, \0, '', 4, 0
- buildmenuitem menuname, 80, 8018, CLIP_COPY_MENU__MSG\9 || CTRL_KEY__MSG'+'INSERT_KEY__MSG , 'Copy2Clip'CLIP_COPY_MENUP__MSG, 0, mpfrom2short(HP_EDIT_COPY, 0)
- buildmenuitem menuname, 80, 8019, CUT_MENU__MSG\9 || SHIFT_KEY__MSG'+'DELETE_KEY__MSG, 'Cut'CUT_MENUP__MSG, 0, mpfrom2short(HP_EDIT_CUT, 0)
- buildmenuitem menuname, 80, 8020, \0, '', 4, 0
- buildmenuitem menuname, 80, 8021, STYLE_MENU__MSG\9'Ctrl+Y', 'fontlist'STYLE_MENUP__MSG, 0, mpfrom2short(HP_OPTIONS_STYLE, 0)
- compile if CHECK_FOR_LEXAM
- if LEXAM_is_available then
- compile endif
- buildmenuitem menuname, 80, 8022, \0, '', 4, 0
- buildmenuitem menuname, 80, 8023, PROOF_MENU__MSG, 'proof'PROOF_MENUP__MSG, 0, mpfrom2short(HP_OPTIONS_PROOF, 16384*(mt<>'L'))
- compile if CHECK_FOR_LEXAM
- endif
- compile endif
- buildmenuitem menuname, 80, 8024, \0, '', 4, 0
- compile if ENHANCED_PRINT_SUPPORT
- buildmenuitem menuname, 80, 8025, PRT_MARK_MENU__MSG'...', 'PRINTDLG M'ENHPRT_MARK_MENUP__MSG,0, mpfrom2short(HP_EDIT_ENHPRINT, 0)
- compile else
- buildmenuitem menuname, 80, 8025, PRT_MARK_MENU__MSG, 'DUPMARK P'PRT_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_PRINT, 0)
- compile endif
- elseif mt<>' ' then -- Build Outside-Mark pop-up
- 'MH_gotoposition'
- buildmenuitem menuname, 80, 8000, COPY_MARK_MENU__MSG\9'Alt+C', 'DUPMARK C'COPY_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_COPYMARK, 0)
- buildmenuitem menuname, 80, 8001, MOVE_MARK_MENU__MSG\9'Alt+M', 'DUPMARK M'MOVE_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_MOVE, 0)
- buildmenuitem menuname, 80, 8002, OVERLAY_MARK_MENU__MSG\9'Alt+O', 'DUPMARK O'OVERLAY_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_OVERLAY, 0)
- buildmenuitem menuname, 80, 8003, ADJUST_MARK_MENU__MSG\9'Alt+A', 'DUPMARK A'ADJUST_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_ADJUST, 0)
- buildmenuitem menuname, 80, 8004, \0, '', 4, 0
- buildmenuitem menuname, 80, 8005, UNMARK_MARK_MENU__MSG\9'Alt+U', 'DUPMARK U'UNMARK_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_UNMARK, 0)
- else -- Build No-mark pop-up
- 'MH_gotoposition'
- ch = substr(textline(.line), .col, 1)
- gray_if_space = 16384*(ch=' ')
- buildmenuitem menuname, 80, 8000, MARK_WORD_MENU__MSG\9'Alt+W', 'MARKWORD'MARK_WORD_MENUP__MSG, 0, mpfrom2short(HP_POPUP_MARKWORD, gray_if_space)
- buildmenuitem menuname, 80, 8001, MARK_TOKEN_MENU__MSG\9'CtrL+W', 'MARKTOKEN'MARK_TOKEN_MENUP__MSG, 0, mpfrom2short(HP_POPUP_MARKTOKEN, gray_if_space)
- buildmenuitem menuname, 80, 8002, FIND_TOKEN_MENU__MSG, 'FINDWORD'FIND_TOKEN_MENUP__MSG, 0, mpfrom2short(HP_POPUP_FINDTOKEN, gray_if_space)
- buildmenuitem menuname, 80, 8003, \0, '', 4, 0
- buildmenuitem menuname, 80, 8004, UPCASE_WORD_MENU__MSG\9'Ctrl+F1', 'key 1 c+f1'UPCASE_WORD_MENUP__MSG, 0, mpfrom2short(HP_POPUP_UPCASEWORD, gray_if_space)
- buildmenuitem menuname, 80, 8005, LOCASE_WORD_MENU__MSG\9'Ctrl+F2', 'key 1 c+f2'LOCASE_WORD_MENUP__MSG, 0, mpfrom2short(HP_POPUP_LOCASEWORD, gray_if_space)
- buildmenuitem menuname, 80, 8006, \0, '', 4, 0
- buildmenuitem menuname, 80, 8007, CENTER_LINE_MENU__MSG\9'Shift+F5', 'key 1 s+f5'CENTER_LINE_MENUP__MSG, 0, mpfrom2short(HP_POPUP_CENTERLINE, 0)
- buildmenuitem menuname, 80, 8008, TOP_LINE_MENU__MSG, 'newtop'TOP_LINE_MENUP__MSG, 0, mpfrom2short(HP_POPUP_TOP, 0)
- endif
- showmenu menuname,1
-
- defc newtop = l=.line; .cursory=1; l
-
- defc STATWNDMOUSECMD -- do nothing; present to avoid "Unknown command"
-
- defc MSGWNDMOUSECMD
- if arg(1)='1 SECONDCLK 0' then
- 'messagebox'
- endif
- compile endif
-