home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / e / epmmac2.zip / MOUSE.E < prev    next >
Text File  |  1992-12-18  |  29KB  |  722 lines

  1. compile if EVERSION < 5
  2.    *** Error:  This file supports EPM only, not earlier versions of E.
  3. compile endif
  4.  
  5. compile if not defined(SMALL)  -- If SMALL not defined, then being separately compiled
  6.    include 'stdconst.e'
  7.    include 'colors.e'
  8.  define INCLUDING_FILE = 'MOUSE.E'
  9.    tryinclude 'MYCNF.E'        -- Include the user's configuration customizations.
  10.  
  11.  compile if not defined(SITE_CONFIG)
  12.     const SITE_CONFIG = 'SITECNF.E'
  13.  compile endif
  14.  compile if SITE_CONFIG
  15.     tryinclude SITE_CONFIG
  16.  compile endif
  17.  
  18. const
  19.  compile if not defined(WANT_CUA_MARKING)
  20.    WANT_CUA_MARKING = 0
  21.  compile endif
  22.  compile if not defined(WANT_STREAM_MODE)
  23.    WANT_STREAM_MODE = 0
  24.  compile endif
  25.  compile if not defined(NLS_LANGUAGE)
  26.    NLS_LANGUAGE = 'ENGLISH'
  27.  compile endif
  28.  compile if not defined(WANT_KEYWORD_HELP)
  29.    WANT_KEYWORD_HELP = 0
  30.  compile endif
  31.  include NLS_LANGUAGE'.e'
  32. compile endif
  33.  
  34. const
  35. compile if not defined(EPM_POINTER)
  36.  compile if EVERSION < 5.50
  37.    EPM_POINTER = SYSTEM_POINTER    -- AVIO version gets arrow pointer
  38.  compile else
  39.    EPM_POINTER = TEXT_POINTER      -- GPI version gets text pointer
  40.  compile endif
  41. compile endif
  42. compile if not defined(LOCAL_MOUSE_SUPPORT)
  43.    LOCAL_MOUSE_SUPPORT = 0
  44. compile endif
  45. compile if not defined(TOP_OF_FILE_VALID)
  46.    TOP_OF_FILE_VALID = 1
  47. compile endif
  48. compile if not defined(DRAG_ALWAYS_MARKS)
  49.    DRAG_ALWAYS_MARKS = 0
  50. compile endif
  51.  
  52.  
  53. const
  54.   BlankMouseHandler = "BlankMouseHandler"
  55.   TransparentMouseHandler = "TransparentMouseHandler"
  56.  
  57. define
  58. compile if EVERSION < 5.50
  59.    CHARG_MARK =  'CHAR'
  60.    BLOCKG_MARK = 'BLOCK'
  61. compile else                -- New mark types
  62.    CHARG_MARK =  'CHARG'
  63.    BLOCKG_MARK = 'BLOCKG'
  64. compile endif
  65.  
  66. compile if EVERSION >= 5.20
  67. defproc prestore_pos2(save_pos)
  68.    parse value save_pos with svline svcol svsx svsy
  69.    compile if EVERSION >= 5.50
  70.       .lineg = min(svline, .last);                       -- set .line
  71.    compile else
  72.       min(svline, .last);                       -- set .line
  73.    compile endif
  74.    .col = svcol;
  75.    .scrollx = svsx;
  76.    compile if EVERSION >= 5.50
  77.       .cursoryg= svsy;
  78.    compile else
  79.       .scrolly = svsy;
  80.    compile endif
  81.  
  82. defproc psave_pos2(var save_pos)
  83.    compile if EVERSION >= 5.50
  84.       save_pos=.line .col .scrollx .cursoryg
  85.    compile else
  86.       save_pos=.line .col .scrollx .scrolly
  87.    compile endif
  88. compile endif
  89.  
  90. defproc MouseLineColOff(var MouseLine, var MouseCol, var MouseOff, minline)
  91.                         -- MIN = 0 for positioning, 1 for marking.
  92.    xxx = .mousex
  93.    yyy = .mousey
  94.  
  95.    -- saying 5.21, below, but not sure if it will work for that.
  96.    --    it will work for 5.50.
  97.  
  98.    compile if EVERSION >= 5.21
  99.       --call messagenwait("xxx1="xxx "yyy1="yyy);
  100.       map_point 5, xxx, yyy, off, comment;  -- map screen to line
  101.       --call messagenwait("doc xxx2="xxx "yyy2="yyy);
  102.    compile else
  103.       --call messagenwait("xxx1="xxx "yyy1="yyy);
  104.       map_point 1, xxx, yyy, off, comment;  -- map screen to doc
  105.       --call messagenwait("doc xxx2="xxx "yyy2="yyy);
  106.       map_point 2, xxx, yyy, off, comment;  -- map doc to line/col/offset
  107.       --call messagenwait("line="xxx "col="yyy "off="off);
  108.    compile endif
  109.    MouseLine = min(max(xxx, minline), .last)
  110. compile if EVERSION >= 5.50  -- can go to MAXCOL+1 for GPI-style marking
  111.    MouseCol  = min(max(yyy, 1), MAXCOL + (rightstr(arg(5),1)='G' and minline))
  112. compile else
  113.    MouseCol  = min(max(yyy, 1), MAXCOL)
  114. compile endif
  115.    MouseOff  = off
  116.  
  117. defproc SetMouseSet(IsGlobal, NewMSName)
  118.    universal GMousePrefix
  119.    universal LMousePrefix
  120.    universal EPM_utility_array_ID
  121.    if IsGlobal then
  122.       GMousePrefix = NewMSName"."
  123. compile if LOCAL_MOUSE_SUPPORT
  124.    else
  125.       LMousePrefix = NewMSName"."
  126.       -- Remember Local MouseSet
  127.       getfileid ThisFile;
  128.       do_array 2, EPM_utility_array_ID, "LocalMausSet."ThisFile, NewMSName
  129. compile endif
  130.    endif
  131.  
  132. compile if 0  -- Now in SELECT.E, only if LOCAL_MOUSE_SUPPORT = 1
  133. defselect
  134.    universal LMousePrefix
  135.    universal EPM_utility_array_ID
  136.    getfileid ThisFile
  137.    OldRC = Rc
  138.    rc = get_array_value(EPM_utility_array_ID, "LocalMausSet."ThisFile, NewMSName)
  139.    if RC then
  140.       if rc=-330 then
  141.          -- no mouseset bound to file yet, assume blank.
  142.          LMousePrefix = TransparentMouseHandler"."
  143.       else
  144.          call messagenwait('RC='RC)
  145.       endif
  146.       RC = OldRC
  147.    else
  148.       LMousePrefix = NewMSName"."
  149.    endif
  150. compile endif
  151.  
  152. defc processmouse
  153.    universal EPM_utility_array_ID
  154.    universal GMousePrefix
  155.    universal LMousePrefix
  156.    if LMousePrefix<>BlankMouseHandler"." then
  157.       OldRc = rc
  158. compile if LOCAL_MOUSE_SUPPORT
  159.       rc = get_array_value(EPM_utility_array_ID, LMousePrefix||arg(1), CommandString)
  160.       if not rc then
  161.          -- Found it.
  162.          Rc = oldRC
  163.          if CommandString<>'' then
  164.             CommandString
  165.             return
  166.          endif
  167.       else
  168.          if rc<>-330 then
  169.             sayerror UNKNOWN_MOUSE_ERROR__MSG rc
  170.             rc = OldRc
  171.             return
  172.          endif
  173.          -- rc==-330 (no local handler found), now try to find a global one.
  174.       endif
  175. compile endif
  176.       if GMousePrefix<>BlankMouseHandler"." then
  177.          rc = get_array_value(EPM_utility_array_ID, GMousePrefix||arg(1), CommandString)
  178.          if not rc then
  179.             -- Found it.
  180.             Rc = oldRC
  181.             if CommandString<>'' then
  182.                CommandString
  183.             endif
  184.             return
  185.          else
  186.             if rc<>-330 then
  187.                sayerror UNKNOWN_MOUSE_ERROR__MSG rc
  188.             else
  189.                -- nothing assigned to that action
  190.             endif
  191.             rc = OldRc
  192.             return
  193.          endif
  194.       endif
  195.    endif
  196.  
  197.  
  198. defproc register_mousehandler(IsGlobal, event, mcommand)
  199.    universal EPM_utility_array_ID
  200.    universal GMousePrefix
  201.    universal LMousePrefix
  202.    if IsGlobal then
  203.       MousePrefix = GMousePrefix
  204.    else
  205. compile if LOCAL_MOUSE_SUPPORT
  206.       if (LMousePrefix=BlankMouseHandler".") or
  207.          (LMousePrefix=TransparentMouseHandler".") then
  208.          -- can't assign to that mouse handler.
  209. compile endif
  210.          return
  211. compile if LOCAL_MOUSE_SUPPORT
  212.       endif
  213.       MousePrefix = LMousePrefix
  214. compile endif
  215.    endif
  216.    do_array 2, EPM_utility_array_ID, MousePrefix||event, mcommand   -- assign
  217.  
  218. defc MH_gotoposition
  219. compile if WANT_STREAM_MODE = 'SWITCH'
  220.    universal stream_mode
  221. compile endif
  222.    -- this procedure moves the cursor to the current mouse location.
  223. ;;
  224. ;;  Old way
  225. ;;
  226. ;;   .cursory = .mousey
  227. ;;   .cursorx = .mousex
  228. ;;
  229. compile if TOP_OF_FILE_VALID
  230.    call MouseLineColOff(MouseLine, MouseCol, MouseOff, 0)
  231. compile else
  232.    call MouseLineColOff(MouseLine, MouseCol, MouseOff, 1)
  233. compile endif
  234. compile if EVERSION >= 5.20
  235.    oldsx = .scrollx;
  236.  compile if EVERSION >= 5.50
  237.    .lineg = MouseLine
  238.  compile else
  239.    oldsy = .scrolly;
  240.    MouseLine
  241.  compile endif
  242. compile else
  243.    MouseLine
  244. compile endif
  245.    .col  = MouseCol
  246.    while MouseOff<0 do
  247.       left
  248.       MouseOff = MouseOff + 1
  249.    endwhile
  250.    while MouseOff>0 do
  251.       right
  252.       MouseOff = MouseOff - 1
  253.    endwhile
  254. compile if WANT_STREAM_MODE
  255.  compile if WANT_STREAM_MODE = 'SWITCH'
  256.    if stream_mode then
  257.  compile endif
  258.    if .col > length(textline(.line)) then
  259.       end_line
  260.    endif
  261.  compile if WANT_STREAM_MODE = 'SWITCH'
  262.    endif
  263.  compile endif
  264. compile endif
  265. compile if EVERSION >= 5.20
  266.    .scrollx = oldsx;
  267.    compile if EVERSION >= 5.50
  268.    compile else
  269.       .scrolly = oldsy;
  270.    compile endif
  271. compile endif
  272.  
  273. defc MH_begin_mark
  274.    universal BeginningLineOfDrag
  275.    universal BeginningColOfDrag
  276. compile if WANT_CUA_MARKING = 'SWITCH'
  277.    universal CUA_marking_switch
  278. compile endif
  279. compile if 0
  280.    mt = upcase(arg(1))
  281.    if marktype() then
  282.       getfileid curfileid
  283.       getmark markfirstline,marklastline,markfirstcol,marklastcol,markfileid
  284.       if marktype() <> mt or markfileid <> curfileid then
  285.          sayerror -279  -- sayerror('Text already marked')
  286.          return
  287.       endif
  288.    endif
  289. compile elseif WANT_CUA_MARKING = 1 | DRAG_ALWAYS_MARKS
  290.    unmark
  291.    'ClearSharBuff'       /* Remove Content in EPM shared text buffer */
  292. compile else
  293.  compile if WANT_CUA_MARKING = 'SWITCH'
  294.    if CUA_marking_switch then
  295.       unmark
  296.       'ClearSharBuff'       /* Remove Content in EPM shared text buffer */
  297.    endif
  298.  compile endif
  299.    if marktype() then
  300.       sayerror-279  --  sayerror('Text already marked')
  301.       return
  302.    endif
  303. compile endif
  304.    call MouseLineColOff(BeginningLineOfDrag, BeginningColOfDrag, MouseOff, 1, arg(1));
  305.    call register_mousehandler(1, 'ENDDRAG',    'MH_end_mark '||arg(1))  -- shifted
  306.    call register_mousehandler(1, 'CANCELDRAG', 'MH_cancel_mark')  -- shifted
  307.    if upcase(arg(1))='LINE' then
  308.       .DragStyle = 2
  309.    elseif leftstr(upcase(arg(1)),5)='BLOCK' then
  310.       .DragStyle = 1
  311.    elseif leftstr(upcase(arg(1)),4)='CHAR' then
  312.       .DragStyle = 3
  313.    endif
  314.    mouse_setpointer MARK_POINTER
  315. compile if DRAGCOLOR<>''
  316.    .DragColor = DRAGCOLOR
  317. compile else
  318.    .DragColor = .markcolor
  319. compile endif
  320.  
  321. defc MH_end_mark
  322.    universal BeginningLineOfDrag
  323.    universal BeginningColOfDrag
  324. compile if WANT_CUA_MARKING = 'SWITCH'
  325.    universal CUA_marking_switch
  326. compile endif
  327.    call MouseLineColOff(endingline, endingcol, MouseOff, 1, arg(1));
  328.    unmark
  329.    getfileid CurrentFile
  330.    call pset_mark(BeginningLineOfDrag, endingline,
  331.                   BeginningColOfDrag,  max(endingcol,1),  arg(1), CurrentFile)
  332.    mouse_setpointer EPM_POINTER
  333. compile if WANT_CUA_MARKING
  334.  compile if WANT_CUA_MARKING = 'SWITCH'
  335.    if CUA_marking_switch then
  336.  compile endif
  337.  compile if EVERSION >= '5.50'  -- GPI version allows cursor to be off screen
  338.    if .cursorx > 0 & .cursorx <= .windowwidth & .cursory > 0 & .cursory <= .windowheight then
  339.  compile endif
  340.    getmark  firstline,lastline,firstcol,lastcol,fileid
  341.    if marktype()<>'LINE' then
  342.       .col=lastcol
  343.    endif
  344.    if lastline<>.line then
  345.       if lastline>.line then '+'lastline-.line; else lastline-.line; endif
  346.    endif
  347.  compile if EVERSION >= '5.50'
  348.    endif
  349.  compile endif
  350.    'MH_gotoposition'
  351.  compile if WANT_CUA_MARKING = 'SWITCH'
  352.    endif
  353.  compile endif
  354. compile endif
  355. ;  refresh                                          ???
  356.    call register_mousehandler(1, 'ENDDRAG', ' ')
  357.    call register_mousehandler(1, 'CANCELDRAG', ' ')
  358.    /* Copy the marked area to the clipboard in case we want to copy it */
  359.    /* into a different editor window.                                  */
  360.    'Copy2SharBuff'
  361.  
  362. defc MH_cancel_mark
  363.    mouse_setpointer EPM_POINTER
  364.    call register_mousehandler(1, 'ENDDRAG', ' ')
  365.    call register_mousehandler(1, 'CANCELDRAG', ' ')
  366.  
  367. defc markword
  368.    if arg(1) then
  369.       'MH_gotoposition'
  370.       unmark
  371.    endif
  372.    call pmark_word()
  373.  
  374. defc marktoken
  375.    if arg(1) then
  376.       'MH_gotoposition'
  377.    endif
  378.    if find_token(startcol, endcol) then
  379.       getfileid fid
  380.       call pset_mark(.line, .line, startcol, endcol, 'BLOCK', fid)
  381.    endif
  382.  
  383. defc findword
  384.    if arg(1) then
  385.       'MH_gotoposition'
  386.    endif
  387.    if find_token(startcol, endcol) then
  388.       .col = endcol
  389.       'l '\1 || substr(textline(.line), startcol, (endcol-startcol)+1)
  390.    endif
  391.  
  392. compile if WANT_CUA_MARKING
  393. defc MH_singleclick
  394.    unmark
  395.    'ClearSharBuff'       /* Remove Content in EPM shared text buffer */
  396.    'MH_gotoposition'
  397.  
  398. defc MH_dblclick
  399.    unmark
  400.    if .line then
  401. ;;    call pmark_word()  -- pmark_word doesn't include white space; the following does:
  402.       call pbegin_word()
  403.       mark_block
  404.       startcol = .col
  405.       tab_word
  406.       if .col<length(textline(.line)) then .col = .col - 1; endif
  407.       mark_block
  408.       .col = startcol
  409.    endif
  410.    'Copy2SharBuff'       /* Copy mark to shared text buffer */
  411.  
  412. compile endif
  413.  
  414. defc MH_double  -- Used to be just 'dupmark U', but now overloaded in a DIR listing:
  415.    if upcase(subword(.filename,1,2)) = '.DOS DIR' then
  416.       executekey a_1  -- For simplicity, assume user hasn't redefined this key:
  417.    else
  418.       unmark
  419.       'ClearSharBuff'
  420.    endif
  421.  
  422. defc MH_shiftclick
  423.    if marktype() then
  424.       getmark markfirstline,marklastline,markfirstcol,marklastcol,markfileid
  425.    else
  426.       markfileid=''
  427.    endif
  428.    unmark
  429.    getfileid CurrentFile
  430.    if CurrentFile<>markfileid then
  431.       markfirstline=.line; markfirstcol=.col
  432.    elseif markfirstline=.line & markfirstcol=.col then
  433.       markfirstline=marklastline; markfirstcol=marklastcol
  434.    endif
  435.    call MouseLineColOff(MouseLine, MouseCol, MouseOff, 1, arg(1))
  436.    call pset_mark(markfirstline, MouseLine, markfirstcol, MouseCol, 'CHAR', CurrentFile)
  437.    'MH_gotoposition'
  438.    'Copy2SharBuff'
  439.  
  440. definit
  441.    universal EPM_utility_array_ID, MouseStyle
  442. compile if (EVERSION < 5.21 & EPM_POINTER<>SYSTEM_POINTER) | (EVERSION >= 5.21 & EPM_POINTER<>TEXT_POINTER)
  443.    mouse_setpointer EPM_POINTER
  444. compile endif
  445.    -- set initial mousesets
  446.    SetMouseSet(1, "BaseMouseHandlers") -- default global mouseset
  447. compile if LOCAL_MOUSE_SUPPORT
  448.    SetMouseSet(0, TransparentMouseHandler)  -- default local mouseset is blank.
  449. compile endif
  450. compile if WANT_CUA_MARKING = 'SWITCH'
  451.    call MH_SET_Mouse()
  452.  
  453. defproc MH_set_mouse
  454.    universal CUA_marking_switch, MouseStyle
  455.  
  456.  
  457.    if CUA_marking_switch then
  458. compile endif
  459.  
  460.       -- 1 == shift, 2 = control, 4 = alt.
  461. compile if WANT_CUA_MARKING
  462.    call register_mousehandler(1, '1 CLICK 0',     'MH_singleclick')
  463.    call register_mousehandler(1, '1 CLICK 1',     'MH_shiftclick')
  464.    call register_mousehandler(1, '1 CLICK 2',     'MH_singleclick')
  465.    call register_mousehandler(1, '1 CLICK 3',     'MH_shiftclick')
  466.    call register_mousehandler(1, '1 CLICK 4',     'MH_singleclick')
  467.    call register_mousehandler(1, '1 CLICK 5',     'MH_shiftclick')
  468.    call register_mousehandler(1, '1 CLICK 6',     'MH_singleclick')
  469.    call register_mousehandler(1, '1 CLICK 7',     'MH_shiftclick')
  470.    call register_mousehandler(1, '1 SECONDCLK 0', 'MH_dblclick')
  471.    call register_mousehandler(1, '1 SECONDCLK 2', 'MH_dblclick')
  472.    call register_mousehandler(1, '1 SECONDCLK 4', 'MH_dblclick')
  473.    call register_mousehandler(1, '1 SECONDCLK 6', 'MH_dblclick')
  474.    call register_mousehandler(1, '1 BEGINDRAG 0', 'MH_begin_mark' CHARG_MARK)
  475.    call register_mousehandler(1, '1 BEGINDRAG 1', 'MH_begin_mark' CHARG_MARK)
  476.    call register_mousehandler(1, '1 BEGINDRAG 2', 'MH_begin_mark' CHARG_MARK)
  477.    call register_mousehandler(1, '1 BEGINDRAG 3', 'MH_begin_mark' CHARG_MARK)
  478.    call register_mousehandler(1, '1 BEGINDRAG 4', 'MH_begin_mark' CHARG_MARK)
  479.    call register_mousehandler(1, '1 BEGINDRAG 5', 'MH_begin_mark' CHARG_MARK)
  480.    call register_mousehandler(1, '1 BEGINDRAG 6', 'MH_begin_mark' CHARG_MARK)
  481.    call register_mousehandler(1, '1 BEGINDRAG 7', 'MH_begin_mark' CHARG_MARK)
  482. compile endif
  483.  
  484. compile if WANT_CUA_MARKING = 'SWITCH'
  485.       call register_mousehandler(1, '2 BEGINDRAG 0', '')  -- Delete the defs
  486.  compile if EVERSION < 5.50
  487.       call register_mousehandler(1, '2 BEGINDRAG 2', '')
  488.  compile endif
  489.       call register_mousehandler(1, '3 BEGINDRAG 0', '')  -- from the other style.
  490.  compile if EVERSION >= 5.60
  491.       call register_mousehandler(1, '2 CLICK 0',     '')
  492.  compile endif
  493.       call register_mousehandler(1, '2 SECONDCLK 0', '')
  494.       call register_mousehandler(1, '2 SECONDCLK 2', '')
  495.       call register_mousehandler(1, '2 SECONDCLK 1', '')
  496.    else
  497.  compile if EVERSION < 5.50
  498.       call register_mousehandler(1, '1 CLICK 2',     '')  -- (ditto)
  499.  compile endif
  500.       call register_mousehandler(1, '1 CLICK 4',     '')
  501.       call register_mousehandler(1, '1 CLICK 6',     '')
  502.       call register_mousehandler(1, '1 SECONDCLK 2', '')
  503.       call register_mousehandler(1, '1 SECONDCLK 4', '')
  504.       call register_mousehandler(1, '1 SECONDCLK 6', '')
  505.       call register_mousehandler(1, '1 BEGINDRAG 1', '')
  506.       call register_mousehandler(1, '1 BEGINDRAG 3', '')
  507.       call register_mousehandler(1, '1 BEGINDRAG 4', '')
  508.       call register_mousehandler(1, '1 BEGINDRAG 5', '')
  509.       call register_mousehandler(1, '1 BEGINDRAG 6', '')
  510.       call register_mousehandler(1, '1 BEGINDRAG 7', '')
  511. compile endif
  512.  
  513. compile if WANT_CUA_MARKING = 'SWITCH' or WANT_CUA_MARKING = 0
  514.    call register_mousehandler(1, '1 CLICK 0',     'MH_gotoposition')
  515.    call register_mousehandler(1, '1 CLICK 1',     'MH_shiftclick')
  516.    if MouseStyle = 1 then but_1 = BLOCKG_MARK; c_but_1 = CHARG_MARK
  517.                      else but_1 = CHARG_MARK;  c_but_1 = BLOCKG_MARK
  518.    endif
  519.    call register_mousehandler(1, '1 BEGINDRAG 0', 'MH_begin_mark 'but_1)
  520.    call register_mousehandler(1, '1 BEGINDRAG 2', 'MH_begin_mark 'c_but_1)
  521.  compile if EVERSION < 5.50
  522.    call register_mousehandler(1, '2 BEGINDRAG 0', 'MH_begin_mark LINE')
  523.  compile else
  524.    call register_mousehandler(1, '2 BEGINDRAG 0', 'MH_begin_drag_2 0')
  525.    call register_mousehandler(1, '2 BEGINDRAG 2', 'MH_begin_drag_2 1')
  526.    call register_mousehandler(1, '1 CLICK 2',     'MH_gotoposition')
  527.  compile endif
  528.    call register_mousehandler(1, '3 BEGINDRAG 0', 'MH_begin_mark 'c_but_1)
  529.    call register_mousehandler(1, '1 SECONDCLK 0', 'MH_double')
  530.  compile if EVERSION >= 5.60
  531.    call register_mousehandler(1, '2 CLICK 0',     'MH_popup')
  532.  compile endif
  533.    call register_mousehandler(1, '2 SECONDCLK 0', 'markword 1')
  534.    call register_mousehandler(1, '2 SECONDCLK 2', 'marktoken 1')
  535.    call register_mousehandler(1, '2 SECONDCLK 1', 'findword 1')
  536.  compile if WANT_KEYWORD_HELP
  537.    call register_mousehandler(1, '1 SECONDCLK 2', 'kwhelp')
  538.  compile endif
  539. compile endif
  540.  
  541. compile if WANT_CUA_MARKING = 'SWITCH'
  542.    endif
  543. compile endif
  544.  
  545. compile if EVERSION >= 5.50
  546. defc MH_begin_drag_2  -- Determine if a click is within the selected area
  547.  compile if WANT_CUA_MARKING = 'SWITCH'
  548.    universal CUA_marking_switch
  549.  compile endif
  550.    if mouse_in_mark() then
  551.       call WindowMessage(0,  getpminfo(EPMINFO_EDITCLIENT),
  552.                          5434,               -- EPM_DRAGDROP_DIRECTMINP
  553.                          arg(1),
  554.                          0)
  555.    else
  556.       'MH_begin_mark LINE'
  557.    endif
  558.  
  559. defproc mouse_in_mark()
  560.    -- First we query the position of the mouse
  561.    call MouseLineColOff(MouseLine, MouseCol, MouseOff, 0)
  562.    -- Now determine if the mouse is in the selected text area.
  563.    mt=leftstr(marktype(),1)
  564.    if mt then
  565.       getfileid curfileid
  566.       getmark markfirstline,marklastline,markfirstcol,marklastcol,markfileid
  567.       if  (markfileid == curfileid) and
  568.           (MouseLine >= markfirstline) and (MouseLine <= marklastline) then
  569.  
  570.           -- assert:  at this point the only case where the text is outside
  571.           --          the selected area is on a single line char mark and a
  572.           --          block mark.  Any place else is a valid selection
  573.           if not ((mt=='C' & (markfirstline=MouseLine & MouseCol < markfirstcol) or (marklastline=MouseLine & MouseCol > marklastcol)) or
  574.                   (mt=='B' & (MouseCol < markfirstcol or MouseCol > marklastcol)) ) then
  575.              return 1
  576.           endif
  577.       endif
  578.    endif
  579. compile endif
  580.  
  581. compile if EVERSION >= 5.60
  582. const
  583.    FILL_MARK_MENU__MSG = 'Fill mark'
  584.    FILL_MARK_MENUP__MSG = \1'Fill marked region with a character, overlaying current contents.'
  585.    HP_POPUP_FILL = 0
  586.    REFLOW_MARK_MENU__MSG = 'Reflow mark'
  587.    REFLOW_MARK_MENUP__MSG = \1'Reflow text in marked region.'
  588.    HP_POPUP_REFLOW = 0
  589.    MARK_WORD_MENU__MSG = 'Mark word'
  590.    MARK_WORD_MENUP__MSG = \1'Mark space-delimited word under mouse pointer.'
  591.    HP_POPUP_MARKWORD = 0
  592.    MARK_TOKEN_MENU__MSG = 'Mark identifier'
  593.    MARK_TOKEN_MENUP__MSG = \1'Mark the C-language identifier under the mouse pointer.'
  594.    HP_POPUP_MARKTOKEN = 0
  595.    FIND_TOKEN_MENU__MSG = 'Find identifier'
  596.    FIND_TOKEN_MENUP__MSG = \1'Find the next occurrence of the identifier under the mouse pointer.'
  597.    HP_POPUP_FINDTOKEN = 0
  598.    UPCASE_MARK_MENU__MSG = 'Uppercase selection'
  599.    UPCASE_MARK_MENUP__MSG = \1'Translate selected text to upper case.'
  600.    HP_POPUP_UPCASEMARK = 0
  601.    LOCASE_MARK_MENU__MSG = 'Lowercase selection'
  602.    LOCASE_MARK_MENUP__MSG = \1'Translate selected text to lower case.'
  603.    HP_POPUP_LOCASEMARK = 0
  604.    UPCASE_WORD_MENU__MSG = 'Uppercase word'
  605.    UPCASE_WORD_MENUP__MSG = \1'Translate word under mouse pointer to upper case.'
  606.    HP_POPUP_UPCASEWORD = 0
  607.    LOCASE_WORD_MENU__MSG = 'Lowercase word'
  608.    LOCASE_WORD_MENUP__MSG = \1'Translate word under mouse pointer to lower case.'
  609.    HP_POPUP_LOCASEWORD = 0
  610.    SHIFT_MENU__MSG = 'Shift'
  611.    SHIFT_MENUP__MSG = \1'Shift marked text left or right.'
  612.    HP_POPUP_SHIFT = 0
  613.    SHIFTLEFT_MENU__MSG = 'Shift left 1'
  614.    SHIFTLEFT_MENUP__MSG = \1'Shift marked text left 1 character.'
  615.    HP_POPUP_SHIFTLEFT = 0
  616.    SHIFTLEFT3_MENU__MSG = 'Shift left 3'
  617.    SHIFTLEFT3_MENUP__MSG = \1'Shift marked text left 3 characters.'
  618.    HP_POPUP_SHIFTLEFT3 = 0
  619.    SHIFTLEFT8_MENU__MSG = 'Shift left 8'
  620.    SHIFTLEFT8_MENUP__MSG = \1'Shift marked text left 8 characters.'
  621.    HP_POPUP_SHIFTLEFT8 = 0
  622.    SHIFTRIGHT_MENU__MSG = 'Shift right 1'
  623.    SHIFTRIGHT_MENUP__MSG = \1'Shift marked text right 1 character.'
  624.    HP_POPUP_SHIFTRIGHT = 0
  625.    SHIFTRIGHT3_MENU__MSG = 'Shift right 3'
  626.    SHIFTRIGHT3_MENUP__MSG = \1'Shift marked text right 3 characters.'
  627.    HP_POPUP_SHIFTRIGHT3 = 0
  628.    SHIFTRIGHT8_MENU__MSG = 'Shift right 8'
  629.    SHIFTRIGHT8_MENUP__MSG = \1'Shift marked text right 8 characters.'
  630.    HP_POPUP_SHIFTRIGHT8 = 0
  631.    CENTER_LINE_MENU__MSG = 'Center line'
  632.    CENTER_LINE_MENUP__MSG = \1'Center line under mouse pointer vertically in window.'
  633.    HP_POPUP_CENTERLINE = 0
  634.    CENTER_MARK_MENU__MSG = 'Center text'
  635.    CENTER_MARK_MENUP__MSG = \1'Center marked text within margins or block mark.'
  636.    HP_POPUP_CENTERMARK = 0
  637.    SORT_MARK_MENU__MSG = 'Sort'
  638.    SORT_MARK_MENUP__MSG = \1'Sort marked lines, using block mark (if present) as key.'
  639.    HP_POPUP_SORT = 0
  640.    TOP_LINE_MENU__MSG = 'Scroll to top'
  641.    TOP_LINE_MENUP__MSG = \1'Scroll so line under mouse pointer is at top of window.'
  642.    HP_POPUP_TOP = 0
  643.  
  644. defc MH_popup
  645.    universal activemenu, previouslyactivemenu
  646. compile if CHECK_FOR_LEXAM
  647.    universal LEXAM_is_available
  648. compile endif
  649.    if previouslyactivemenu = '' then
  650.       previouslyactivemenu = activemenu
  651.    endif
  652.    menuname = 'popup1'
  653.    activemenu = menuname
  654.  
  655.    deletemenu menuname, 0, 0, 0
  656.    buildsubmenu  menuname, 80, '', '', 0 , 0
  657.    mt = leftstr(marktype(),1)
  658.    if mouse_in_mark() then  -- Build Inside-Mark pop-up
  659.       gray_if_charmark = 16384*(MT='C')
  660.       buildmenuitem menuname, 80, 8000, UNMARK_MARK_MENU__MSG\9'Alt+U',   'DUPMARK U'UNMARK_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_UNMARK, 0)
  661.       buildmenuitem menuname, 80, 8001, DELETE_MARK_MENU__MSG\9'Alt+D',   'DUPMARK D'DELETE_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_DELETE, 0)
  662.       buildmenuitem menuname, 80, 8002, FILL_MARK_MENU__MSG\9'Alt+F',     'Fill'FILL_MARK_MENUP__MSG, 0, mpfrom2short(HP_POPUP_FILL, 0)
  663.       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)
  664.       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)
  665.       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)
  666.       buildmenuitem menuname, 80, 8006, SORT_MARK_MENU__MSG,              'Sort'SORT_MARK_MENUP__MSG, 0, mpfrom2short(HP_POPUP_SORT, gray_if_charmark)
  667.       buildmenuitem menuname, 80, 8007, \0,                               '',          4, 0
  668.       buildmenuitem menuname, 80, 8008, SHIFT_MENU__MSG,   ''SHIFT_MENUP__MSG, 17, mpfrom2short(HP_POPUP_SHIFT, gray_if_charmark)
  669.       nodismiss_gifc = gray_if_charmark + 32  -- 32 = MIA_NODISMISS
  670.       buildmenuitem menuname, 80, 8009, SHIFTLEFT_MENU__MSG\9'Ctrl+F7',   'key 1 a+F7'SHIFTLEFT_MENUP__MSG, 1, mpfrom2short(HP_POPUP_SHIFTLEFT, nodismiss_gifc)
  671.       buildmenuitem menuname, 80, 8010, SHIFTLEFT3_MENU__MSG,             'key 3 a+F7'SHIFTLEFT3_MENUP__MSG, 1, mpfrom2short(HP_POPUP_SHIFTLEFT3, nodismiss_gifc)
  672.       buildmenuitem menuname, 80, 8011, SHIFTLEFT8_MENU__MSG,             'key 8 a+F7'SHIFTLEFT8_MENUP__MSG, 1, mpfrom2short(HP_POPUP_SHIFTLEFT8, nodismiss_gifc)
  673.       buildmenuitem menuname, 80, 8013, SHIFTRIGHT_MENU__MSG\9'Ctrl+F8',  'key 1 a+F8'SHIFTRIGHT_MENUP__MSG, 2049, mpfrom2short(HP_POPUP_SHIFTRIGHT, nodismiss_gifc)
  674.       buildmenuitem menuname, 80, 8014, SHIFTRIGHT3_MENU__MSG,            'key 3 a+F8'SHIFTRIGHT3_MENUP__MSG, 1, mpfrom2short(HP_POPUP_SHIFTRIGHT3, nodismiss_gifc)
  675.       buildmenuitem menuname, 80, 8015, SHIFTRIGHT8_MENU__MSG,            'key 8 a+F8'SHIFTRIGHT8_MENUP__MSG, 32769, mpfrom2short(HP_POPUP_SHIFTRIGHT8, nodismiss_gifc)
  676.       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)
  677.       buildmenuitem menuname, 80, 8017, \0,                               '',          4, 0
  678.       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)
  679.       buildmenuitem menuname, 80, 8019, CUT_MENU__MSG\9 || SHIFT_KEY__MSG'+'DELETE_KEY__MSG, 'Cut'CUT_MENUP__MSG,       0, mpfrom2short(HP_EDIT_CUT, 0)
  680.       buildmenuitem menuname, 80, 8020, \0,                               '',          4, 0
  681.       buildmenuitem menuname, 80, 8021, STYLE_MENU__MSG\9'Ctrl+Y',        'fontlist'STYLE_MENUP__MSG,    0, mpfrom2short(HP_OPTIONS_STYLE, 0)
  682.  compile if CHECK_FOR_LEXAM
  683.    if LEXAM_is_available then
  684.  compile endif
  685.       buildmenuitem menuname, 80, 8022, \0,                               '',          4, 0
  686.       buildmenuitem menuname, 80, 8023, PROOF_MENU__MSG,           'proof'PROOF_MENUP__MSG,     0, mpfrom2short(HP_OPTIONS_PROOF, 16384*(mt<>'L'))
  687.  compile if CHECK_FOR_LEXAM
  688.    endif
  689.  compile endif
  690.       buildmenuitem menuname, 80, 8024, \0,                               '',          4, 0
  691. compile if ENHANCED_PRINT_SUPPORT
  692.       buildmenuitem menuname, 80, 8025, PRT_MARK_MENU__MSG'...',          'PRINTDLG M'ENHPRT_MARK_MENUP__MSG,0, mpfrom2short(HP_EDIT_ENHPRINT, 0)
  693. compile else
  694.       buildmenuitem menuname, 80, 8025, PRT_MARK_MENU__MSG,               'DUPMARK P'PRT_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_PRINT, 0)
  695. compile endif
  696.    elseif mt<>' ' then  -- Build Outside-Mark pop-up
  697.       'MH_gotoposition'
  698.       buildmenuitem menuname, 80, 8000, COPY_MARK_MENU__MSG\9'Alt+C',     'DUPMARK C'COPY_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_COPYMARK, 0)
  699.       buildmenuitem menuname, 80, 8001, MOVE_MARK_MENU__MSG\9'Alt+M',     'DUPMARK M'MOVE_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_MOVE, 0)
  700.       buildmenuitem menuname, 80, 8002, OVERLAY_MARK_MENU__MSG\9'Alt+O',  'DUPMARK O'OVERLAY_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_OVERLAY, 0)
  701.       buildmenuitem menuname, 80, 8003, ADJUST_MARK_MENU__MSG\9'Alt+A',   'DUPMARK A'ADJUST_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_ADJUST, 0)
  702.       buildmenuitem menuname, 80, 8004, \0,                       '',          4, 0
  703.       buildmenuitem menuname, 80, 8005, UNMARK_MARK_MENU__MSG\9'Alt+U',   'DUPMARK U'UNMARK_MARK_MENUP__MSG, 0, mpfrom2short(HP_EDIT_UNMARK, 0)
  704.    else  -- Build No-mark pop-up
  705.       'MH_gotoposition'
  706.       ch = substr(textline(.line), .col, 1)
  707.       gray_if_space = 16384*(ch=' ')
  708.       buildmenuitem menuname, 80, 8000, MARK_WORD_MENU__MSG\9'Alt+W',      'MARKWORD'MARK_WORD_MENUP__MSG, 0, mpfrom2short(HP_POPUP_MARKWORD, gray_if_space)
  709.       buildmenuitem menuname, 80, 8001, MARK_TOKEN_MENU__MSG\9'CtrL+W',    'MARKTOKEN'MARK_TOKEN_MENUP__MSG, 0, mpfrom2short(HP_POPUP_MARKTOKEN, gray_if_space)
  710.       buildmenuitem menuname, 80, 8002, FIND_TOKEN_MENU__MSG,              'FINDWORD'FIND_TOKEN_MENUP__MSG, 0, mpfrom2short(HP_POPUP_FINDTOKEN, gray_if_space)
  711.       buildmenuitem menuname, 80, 8003, \0,                       '',          4, 0
  712.       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)
  713.       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)
  714.       buildmenuitem menuname, 80, 8006, \0,                       '',          4, 0
  715.       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)
  716.       buildmenuitem menuname, 80, 8008, TOP_LINE_MENU__MSG,                'newtop'TOP_LINE_MENUP__MSG, 0, mpfrom2short(HP_POPUP_TOP, 0)
  717.    endif
  718.    showmenu menuname,1
  719.  
  720. defc newtop = l=.line; .cursory=1; l
  721. compile endif
  722.