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'
- tryinclude 'MYCNF.E' -- Include the user's configuration customizations.
- 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)
- const LOCAL_MOUSE_SUPPORT = 0
- compile endif
- compile if not defined(TOP_OF_FILE_VALID)
- TOP_OF_FILE_VALID = 1
- 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
- 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)
- compile if EVERSION >= 5.50 -- can go to MAXCOL+1 for GPI-style marking
- MouseCol = min(max(yyy, 1), MAXCOL + (rightstr(arg(5),1)='G' and minline))
- compile else
- MouseCol = min(max(yyy, 1), MAXCOL)
- compile endif
- MouseOff = off
-
- 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 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
- call MouseLineColOff(MouseLine, MouseCol, MouseOff, 0)
- compile else
- call MouseLineColOff(MouseLine, MouseCol, MouseOff, 1)
- 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
- .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
- 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 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
- 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
- call MouseLineColOff(BeginningLineOfDrag, BeginningColOfDrag, MouseOff, 1, arg(1));
- 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 upcase(arg(1))=BLOCKG_MARK then
- .DragStyle = 1
- elseif upcase(arg(1))=CHARG_MARK 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
- call MouseLineColOff(endingline, endingcol, MouseOff, 1, arg(1));
- unmark
- getfileid CurrentFile
- call pset_mark(BeginningLineOfDrag, endingline,
- BeginningColOfDrag, max(endingcol,1), arg(1), CurrentFile)
- mouse_setpointer EPM_POINTER
- compile if WANT_CUA_MARKING
- compile if WANT_CUA_MARKING = 'SWITCH'
- if CUA_marking_switch 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
- 'MH_gotoposition'
- compile if WANT_CUA_MARKING = 'SWITCH'
- endif
- compile endif
- compile endif
- ; refresh ???
- call register_mousehandler(1, 'ENDDRAG', ' ')
- call register_mousehandler(1, 'CANCELDRAG', ' ')
- /* Copy the marked area to the clipboard in case we want to copy it */
- /* into a different editor window. */
- 'Copy2SharBuff'
-
- defc MH_cancel_mark
- mouse_setpointer EPM_POINTER
- call register_mousehandler(1, 'ENDDRAG', ' ')
- call register_mousehandler(1, 'CANCELDRAG', ' ')
-
- defc markword
- 'MH_gotoposition'
- unmark
- call pmark_word()
-
- defc marktoken
- 'MH_gotoposition'
- if find_token(startcol, endcol) then
- getfileid fid
- call pset_mark(.line, .line, startcol, endcol, 'BLOCK', fid)
- endif
-
- defc findword
- 'MH_gotoposition'
- 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'
-
- definit
- universal EPM_utility_array_ID, MouseStyle
- 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 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')
- call register_mousehandler(1, '1 SECONDCLK 0', 'MH_dblclick')
- call register_mousehandler(1, '1 SECONDCLK 2', 'MH_dblclick')
- 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
-
- compile if WANT_CUA_MARKING = 'SWITCH'
- call register_mousehandler(1, '2 BEGINDRAG 0', '') -- Delete the defs
- compile if EVERSION < 5.50
- call register_mousehandler(1, '2 BEGINDRAG 2', '')
- compile endif
- call register_mousehandler(1, '3 BEGINDRAG 0', '') -- from the other style.
- 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', '')
- call register_mousehandler(1, '1 SECONDCLK 2', '')
- 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
- call register_mousehandler(1, '2 BEGINDRAG 0', 'MH_begin_drag_2 0')
- call register_mousehandler(1, '2 BEGINDRAG 2', 'MH_begin_drag_2 1')
- call register_mousehandler(1, '1 CLICK 2', 'MH_gotoposition')
- compile endif
- call register_mousehandler(1, '3 BEGINDRAG 0', 'MH_begin_mark 'c_but_1)
- call register_mousehandler(1, '1 SECONDCLK 0', 'MH_double')
- call register_mousehandler(1, '2 SECONDCLK 0', 'markword')
- call register_mousehandler(1, '2 SECONDCLK 2', 'marktoken')
- call register_mousehandler(1, '2 SECONDCLK 1', 'findword')
- compile if WANT_KEYWORD_HELP
- 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
- -- 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)
- inselection=0
- 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
- inselection=1
- endif
- endif
- endif
- if inselection then
- call WindowMessage(0, getpminfo(EPMINFO_EDITCLIENT),
- 5434, -- EPM_DRAGDROP_DIRECTMINP
- arg(1),
- 0)
- else
- 'MH_begin_mark LINE'
- endif
-
- compile endif
-