home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / uedit-stuff_429.lzh / Uedit-Stuff / Ctl-Click < prev    next >
Text File  |  1991-01-10  |  19KB  |  436 lines

  1.  
  2.                  PAUL'S NEW IMPROVED CONTROL-CLICK COMMANDS
  3.  
  4. These here are an improved version of the Uedit commands used for listing
  5. directories and click-loading files.  The improvements are:
  6.  
  7.     Directory listings are faster because they are produced with my high
  8.     speed program Dr instead of regular Dir.  See below for info about Dr.
  9.     A regular Dir version is also here.
  10.  
  11.     You can drag the mouse with the control key held down to cover file or
  12.     directory names that have spaces in them.
  13.  
  14.     The alt-z command is better behaved.  If you don't type anything it lists
  15.     the current directory instead of the click-loading directory or "/".  To
  16.     list the click-loading dir use ctl-click-whitespace F2.
  17.  
  18.     There's a new command lAmiga-z which is like alt-z except that you
  19.     specify a file pattern in the directory to be listed, e.g. "U:Con#?"
  20.  
  21.     Alt-z and ctl-click-whitespace-followed-by-F2 now use the same routine to
  22.     do the actual directory listing, so they no longer do the same thing two
  23.     different ways.  This makes the code smaller.
  24.  
  25.     When the buf38 split window is showing (with the prompt F1=Edit, F2=List,
  26.     etc) you can scroll the split vertically with the up and down arrow keys.
  27.     By default it opens scrolled to show the hilite region if any.
  28.  
  29. The version that uses Dr is I guess intended for the Extras disk.  I am
  30. including (commented out) a version that uses plain old Dir.  This version
  31. could very well (in my opinion) be the new standard vanilla control-click
  32. command.  Except that it doesn't use switch/case, to keep it compileable by
  33. Uedit 2.4 users if it gets relegated to Extras.
  34.  
  35. If you want to use Dir, beware:  Dir has a bug which will make it useless
  36. when Uedit is a workbench process and there is no disk in the boot drive.  Dr
  37. has no such bug.  (Though you do have to specify the current directory by
  38. name instead of just hitting return, if Uedit is a workbench process, because
  39. Uedit cannot pass its current directory to programs it executes unless it is
  40. a CLI process.)  Dr, by the way, is just as "pure" as Dir is.
  41.  
  42. Notes about control-clicking with dragging:  the drag assumes you meant to
  43. bracket all words which are wholly or partially between the two end points of
  44. the drag.  Click in the middle of either the first or the last word, and drag
  45. to the middle of the word at the opposite end.  Stay on the same line if you
  46. want useful results.  "Word" in this context means text bounded by whitespace.
  47.  
  48. It decides whether the click is in whitespace or on text when the button is
  49. released, not when pressed.  If you click in whitespace and release on text,
  50. it will ignore the whitespace between the click and the nearest word (before
  51. or after, depending on whether you dragged the mouse leftward or rightward). 
  52. If you click on text and release on whitespace, it opens the buf38 split
  53. window.  There is a comment in virtual-buttonDown showing how you can make it
  54. decide on the click rather than on the release whether it is on whitespace or
  55. text.
  56.  
  57. You can clear the click-loading directory (so that you can click-load names
  58. of files in the current directory) by ctl-clicking on whitespace when the
  59. buf38 split is open.  There should be a space at the beginning of the first
  60. line of buf38, because both this version and the original version have a
  61. problem otherwise: they will hilite the first word in buf38 if you ctl-click
  62. on whitespace in a different window split.
  63.  
  64. About scrolling the split window:  It begins with the top line visible,
  65. unless there is a hilite region below the bottom end, in which case it
  66. scrolls so that the hilite region is visible.  You can then scroll it
  67. manually using the up and down arrow keys.  But there is a little flaky
  68. problem here.  If you keep pressing downArrow when the last line is at the
  69. top, it scrolls rightward (the text moves left) until no text is visible.  If
  70. you replace the two refreshDisplay's in virtual-buttonUp's cases for macroNum
  71. = normal-downArrow and normal-upArrow with updateDisplay's instead, it
  72. doesn't scroll sideways but may fail to show the cursor and the hilite
  73. region if they're scrolled out of view and then back.
  74.  
  75. ABOUT DR:  Dr is a full featured CLI directory listing command which has been
  76. optimized for speed to within an inch of my life.  It is plenty faster than
  77. some other "fast" listing programs.  It is pure and can be made resident. 
  78. It is intended to replace both Dir and List.  (And other programs as well: du
  79. and rls.)  If you want the complete documentation and source code for Dr,
  80. they'll probably be on a Fish disk some time in early 1991, if the doc file
  81. isn't included with this file.  For simple help on how to use Dr, just give
  82. the command "Dr ?". The most important thing that the usage summary doesn't
  83. tell you is that by default, .info files are left out of the listing. 
  84. Instead, when the output is to a console window, files that have .info files
  85. associated with them get their names written in orange (or whatever color the
  86. window's text cursor is).  When the output is sent to Uedit, there is no such
  87. marking.  You can make .info files appear by changing the command in virtual-
  88. d from "Dr " to "Dr -i ", but I don't know why you'd want to.
  89.  
  90. This stuff is by  Paul Kienitz
  91.                   6430 San Pablo ave.
  92.                   Oakland, CA  94608
  93.                   USA
  94.  
  95. and is in the public domain.
  96.  
  97. ============================================================================
  98.  
  99. Here are the actual functions:
  100.  
  101. Mark region clicked with mouse
  102. <virtual-buttonDown:
  103.     moveCursor(curFile,mouseLoc)
  104. .. change mouseLoc to locA ^^^ to make it decide on the click not the release
  105.     if (eqNum(curFile,38)) equateLoc(buf38,eHilite,sHilite)
  106.     if (is(curFile,eFile)) returnFalse
  107.     if (is(curFile,whiteSpace)) returnFalse
  108.  
  109.     if (gtLoc(curfile, mouseLoc, locA)) {
  110.         equateLoc(curFile, sInvert, locA)
  111.         equateLoc(curFile, eInvert, mouseLoc)
  112.     } else {
  113.         equateLoc(curFile, sInvert, mouseLoc)
  114.         equateLoc(curFile, eInvert, locA)
  115.     }
  116.     moveCursor(curFile, sInvert)
  117.  
  118.     while (not is(curFile,whiteSpace)) {             .. find start non-white
  119.         moveCursor(curFile,sChar)
  120.         if (is(curFile,sFile)) goto label(1)
  121.     }
  122. label(1)
  123.     while (is(curFile,whiteSpace)) moveCursor(curFile,eChar)
  124.     equateLoc(curFile,sInvert,atCursor)         .. sinvert = start non-white
  125.  
  126.     moveCursor(curFile, eInvert)
  127.     while (not is(curFile,whiteSpace)) {               .. find end non-white
  128.         moveCursor(curFile,eChar)
  129.         if (is(curFile,eFile)) goto label(2)
  130.     }
  131. label(2)
  132.     while (is(curFile,whiteSpace)) moveCursor(curFile,sChar)
  133.     moveCursor(curFile, eChar)
  134.     equateLoc(curFile,eInvert,atCursor)           .. einvert = end non-white
  135.     if (eqNum(curFile,38)) {                       .. in directory buffer 38
  136.         equateLoc(curFile,sHilite,sInvert)
  137.         equateLoc(curFile,eHilite,eInvert)
  138.         equateLoc(curFile,sInvert,eInvert)
  139.         moveCursor(curFile,sHilite)
  140.     }
  141.     refreshDisplay
  142. >
  143.  
  144. Load File or select Directory that is CTRL-clicked
  145. <ctl-buttonDown:
  146.     equateNum(n7,curFile)
  147.     equateLoc(curFile, locA, mouseLoc)
  148.     if (mouseDown) while (not inputWaiting)
  149.         trackMouse
  150.     if (not runKey(virtual-buttonDown)) {
  151.         runKey(virtual-buttonUp)
  152.         return
  153.     }
  154.     if (not eqNum(curFile,38)) {
  155.         if (geLoc(curFile,sInvert,eInvert)) return .. no rgn
  156.         moveCursor(curFile,sChar)
  157.         if (not is(curFile,"/")) if (not is(curFile,":")) {
  158.             freeBuf(buf43)              .. leave in current filename buf
  159.             moveCursor(curFile,sInvert)
  160.             while (not eqLoc(curFile,atCursor,eInvert)) {
  161.                 if (is(curFile,":")) goto label(99)
  162.                 moveCursor(curFile,eChar)
  163.             }
  164.             insertRgn(buf43,sFile,buf38,hilite)
  165. label(99)
  166.             insertRgn(buf43,eFile,curFile,invert)
  167.             loadFile(buf43)
  168. .. these two lines are a feature I like in my own version of this and alt-f1:
  169. ..          if (not eqNum(curFile, buf0))
  170. ..              if (isEmpty(buf0)) freeBuf(buf0)  .. eliminate excess NoNames
  171.             return
  172.         }
  173.         moveCursor(curFile,eInvert)
  174.         freeBuf(buf53)
  175.         insertRgn(buf53,eFile,curFile,invert)
  176.         runKey(virtual-7) .. add dir to buf38
  177.     }
  178.     runKey(virtual-9) .. show dir msg
  179. >
  180.  
  181. Handle buf38 directory traffic
  182. <virtual-buttonUp:
  183.     runKey(virtual-8)                   .. load in dir defaults if not loaded
  184.     equateNum(n8,0)
  185.     if (not eqNum(curFile,38)) if (not gotoSplit(buf38)) {
  186.         if (not splitWindow(buf38,splitsize)) {
  187.             putMsg("Close a split window so I can show buf38")
  188.             return
  189.         }
  190.         equateNum(n8,1) .. had to make split window
  191.     }
  192.     vScroll(atCursor)                   .. bug workaround
  193.     vScroll(sFile)
  194.     updateDisplay
  195. .. this ^^ updateDisplay does need to be here even when the updateDisplay a
  196. .. few lines down also happens.  apparently another facet of the same bug
  197.     if (gtLoc(curFile, eHilite, sHilite))
  198.         if (geLoc(curFile, sHilite, ePage)) {
  199.             vScroll(sHilite)
  200.         ... vScroll(upLine)     .. I like to have this here
  201.             updateDisplay
  202.         }
  203.  
  204. label(98)
  205.     equateLoc(buf38,mouseLoc,sFile)
  206. .. if you un-comment this putmsg, comment out the following text calls:
  207. ..  putMsg(
  208. .."Ctl-mouse=Select  F1=Edit  F2=List  F3=Save  F4=ChDir  F5=CD?  Arrow=scroll")
  209.     text("Ctl-click to select (hilite) a directory", 1, 0, 7, -1)
  210.     text("F1 to edit this directory buffer", 2, 0, -1, -1)
  211.     text("F2 to list the hilited dir's contents", 3, 0, -1, -1)
  212.     text("F3 to save this directory buffer to disk", 4, 0, -1, -1)
  213.     text("F4 to set Uedit's current directory to the hilited dir", 5, 0, -1, -1)
  214.     text("F5 to display Uedit's current directory", 6, 0, -1, -1)
  215.     text("Uparrow and downarrow keys to scroll the directory buffer", 7, 0, -1, -1)
  216.  
  217.     getKeyVal(macroNum,inputChar)
  218.     .. use SWITCH (macronum) here, if you are using Uedit 2.5+
  219.     if (eqNum(macroNum,normal-buttonDown)) { .. done bring down window
  220.         gotoSplit(buf[n7])
  221.         if (eqNum(n8,1)) splitWindow(buf38,0) .. close it if made it
  222.         .. I prefer to make the closing of the split window unconditional
  223.         runKey(virtual-9)
  224.         return
  225.     }
  226.     if (eqNum(macroNum,normal-downArrow)) {
  227.         vScroll(downLine)
  228.         refreshDisplay
  229.     }
  230.     if (eqNum(macroNum,normal-upArrow)) {
  231.         vScroll(upLine)
  232.         refreshDisplay
  233.     }
  234.     if (eqNum(macroNum,ctl-buttonDown)) {
  235.         equateLoc(curfile, locA, mouseLoc)
  236.         if (mouseDown) while (not inputWaiting)
  237.             trackMouse
  238.         if (not runKey(virtual-buttonDown))
  239.             refreshDisplay
  240.         runKey(virtual-9)
  241.         delay(10)
  242.     }
  243.     if (eqNum(macroNum,normal-f1)) { .. edit buf38
  244.         putMsg("Press lAmiga-0 to eliminate split window.")
  245.         return
  246.     }
  247.     if (eqNum(macroNum,normal-f2)) { .. get dir list
  248.         gotoSplit(buf[n7])
  249.         if (eqNum(n8,1)) splitWindow(buf38,0) .. close it if made it
  250.         .. I prefer to close the split unconditionally
  251.         freebuf(buf50)
  252.         insertrgn(buf50, efile, buf38, hilite)
  253. .. this virtual-d takes dir-to-scan in buf50 so L-z can give it patterns
  254.         runkey(virtual-d)
  255.         updatedisplay
  256.         return          .. resume normal editing
  257.     }
  258.     if (eqNum(macroNum,normal-f3)) saveFile(buf38)
  259.     if (eqNum(macroNum,normal-f4)) { .. change dir
  260.         if (gtLoc(buf38,eHilite,sHilite)) {
  261.             freeBuf(buf54)
  262.             insertRgn(buf54,eFile,buf38,hilite)
  263.             changeDir(buf54)
  264.             goto label(0)
  265.         }
  266.     }
  267.     if (eqNum(macroNum,normal-f5)) { .. get CD
  268. label(0)
  269.         freeBuf(buf53)
  270.         execute(buf53,"CD")
  271.         freeBuf(buf54)
  272.         insertRgn(buf54,eFile,"current directory = ",all)
  273.         insertRgn(buf54,eFile,buf53,line)
  274.         putMsg(buf54)
  275.         delay(20)
  276.     }
  277.     goto label(98)
  278. >
  279.  
  280.  
  281. Read a directory (with Dr) into a pseudo-requester click-loading buffer
  282. <virtual-d: equatenum(n0, curfile)
  283.             if (newFile) {
  284.                 equateLoc(curFile,sPage,sFile)
  285.         ..      updateDisplay
  286.                 freeBuf(buf54)
  287.                 insertRgn(buf54,eFile,"Dr \"",all)      .. " <- make em match
  288.                 insertRgn(buf54,eFile,buf50,all)
  289.                 moveCursor(buf54, eFile)
  290.                 insertChar(buf54,"\"")                  .. "
  291.                 setFileName(curFile, buf54)
  292.                 execute(curFile,buf54)
  293. .. These next three or four lines are strictly OPTIONAL:
  294.         ..      movecursor(curfile, sfile)
  295.         ..      insertchar(curfile, eline)
  296.         ..      insertrgn(curfile, sfile, buf38, hilite)
  297.     ..........  insertrgn(curfile, sfile, "    Contents of  ", all)
  298.  
  299.                 .. massage dir list Dr style:
  300.                 getSearch(buf49)
  301.                 moveCursor(curFile,sFile)
  302. .. Include this line IF the 3 or 4 optional lines above are used:
  303.         ..      moveCursor(curfile,downLine)
  304.                 setSearch("/")
  305.                 while (search(curFile,locA,locB,1)) {
  306.                     movecursor(curfile, echar)
  307.                     while (is(curfile, whitespace)) clearchar(curfile)
  308.                     insertchar(curfile, eline)
  309.                     moveCursor(curFile,sLine)
  310.                     insertRgn(curFile,atCursor,buf38,hilite)
  311.                     movecursor(curfile, eline)
  312.                 }
  313.                 .. do something to remove the line of dashes?
  314.                 setSearch(buf49) .. restore search string
  315.                 moveCursor(curFile,sFile)
  316.                 flipFlag(curFile,changed)
  317.                 putMsg("Ctl-click dirnames to add to buf38, filenames to load.")
  318.             } else putMsg("Can't open file buffer for directory listing")
  319. >
  320.  
  321. HERE'S THE REGULAR DIR VERSION:
  322.  
  323. Read a directory (with Dir) into a pseudo-requester click-loading buffer
  324. .. <virtual-d:
  325.             equatenum(n0, curfile)
  326.             if (newFile) {
  327.                 equateLoc(curFile,sPage,sFile)
  328.         ..      updateDisplay
  329.                 freeBuf(buf54)
  330.                 insertRgn(buf54,eFile,"Dir ",all)
  331.                 insertRgn(buf54,eFile,buf50,all)
  332.                 setFileName(curFile, buf54)
  333.                 execute(curFile,buf54)
  334. .. These next three or four lines are strictly OPTIONAL:
  335.         ..      movecursor(curfile, sfile)
  336.         ..      insertchar(curfile, eline)
  337.         ..      insertrgn(curfile, sfile, buf38, hilite)
  338.     ..........  insertrgn(curfile, sfile, "    Contents of  ", all)
  339.  
  340.                 .. massage dir list Dir style:
  341.                 getSearch(buf49)
  342.                 moveCursor(curFile,sFile)
  343. .. Include this line IF the 3 or 4 optional lines above are used:
  344.         ..      moveCursor(curfile,downLine)
  345.                 setSearch(" (dir)")
  346.                 while (search(curFile,locA,locB,1)) {
  347.                     clearRgn(curfile,loc)
  348.                     insertChar(curfile,"/")
  349.                     moveCursor(curFile,sLine)
  350.                     while (is(curfile, whitespace)) clearchar(curfile)
  351.                     insertRgn(curFile,atCursor,buf38,hilite)
  352.                     movecursor(curfile, eline)
  353.                 }
  354.                 setSearch(buf49) .. restore search string
  355.                 moveCursor(curFile,sFile)
  356.                 flipFlag(curFile,changed)
  357.                 putMsg("Ctl-click dirnames to add to buf38, filenames to load.")
  358.             } else putMsg("Can't open file buffer for directory listing")
  359. >
  360.  
  361.  
  362. Get directory listing. (Also set dirname used in ctl-buttonDown.)
  363. <alt-z:    putMsg("Directory to list:")
  364.            freeBuf(buf53)
  365.            inputString(buf53)
  366.            freeBuf(buf50)
  367.            insertRgn(buf50, eFile, buf53, all)
  368.            if (not isEmpty(buf53)) runKey(virtual-7)
  369.            else equateLoc(buf38, eHilite, sHilite)
  370.            runKey(virtual-d)  >
  371. .. the reason we don't just go if (inputstring) is that if the user goes alt-z
  372. and then types something and then erases it again, inputstring returns true
  373. and a slash gets put in buf38.  I have in general removed "if (inputstring..."
  374. tests throughout most of my config.
  375.  
  376.  
  377. Get a directory listing, using a pattern.  (Sets ctl-click dir)
  378. <lAmiga-z:      Putmsg("Directory/pattern to list:")
  379.                 freebuf(buf50)
  380.                 inputstring(buf50)
  381.                 movecursor(buf50, efile)
  382.                 while (movecursor(buf50, schar)) {
  383.                     if (is(buf50, ":") | is(buf50, "/")) {
  384.                         movecursor(buf50, echar)
  385.                         equateloc(buf50, ehilite, atcursor)
  386.                         goto label (1)
  387.                     }
  388.                 }
  389.                 equateloc(buf50, ehilite, sfile)
  390.             label (1)
  391.                 equateloc(buf50, shilite, sfile)
  392.                 freebuf(buf53)
  393.                 insertrgn(buf53, sfile, buf50, hilite)
  394.                 if (not isempty(buf53)) runkey(virtual-7)
  395.                 else equateloc(buf38, ehilite, shilite)
  396.                 runkey(virtual-d)
  397. >
  398. That there assumes that virtual-d is getting a dirname from buf50 instead of
  399. the hilite region of buf38
  400.  
  401.  
  402. Just for the hell of it, I'll throw these two in:
  403.  
  404. Change the current working directory
  405. <altCtl-z:  putMsg("Change current directory to:")
  406.             freeBuf(buf53)
  407.             inputString(buf53)          .. if returns false go ahead anyway
  408.             if (not changeDir(buf53))
  409.                 putmsg("Couldn't find that directory") >
  410.  
  411.  
  412. Execute an AmigaDOS command made from last cut text and show the results
  413. <shftCtl-z:     putmsg("Enter AmigaDOS command")
  414.                 freebuf(buf40)
  415. .. If you use the standard cut&paste commands which store the last cut in
  416. .. buf45, leave the next line in.  If you use my special cut&paste commands
  417. .. that remember the last eight cuts, comment out this next line and un-
  418. .. comment the line after it:
  419.                 insertrgn(buf40, efile, buf45, all)
  420. ....            insertrgn(buf40, efile, buf[n28], all)
  421.                 inputString(buf40)
  422.                 if (isempty(buf40)) returnFalse
  423.                 freeBuf(buf39)
  424.                 if (not execute(buf39,buf40)) returnFalse
  425.                 if (not isEmpty(buf39)) {
  426.                     putMsg("Result of AmigaDOS command:")
  427.                     if (getFlag(buf39, changed)) flipFlag(buf39,changed)
  428.                     editBuf(buf39)
  429.                     vScroll(sFile)
  430.                     updateDisplay
  431.                 } else {
  432.                     putMsg("No reply from AmigaDOS.")
  433.                     freeBuf(buf39)
  434.                 }
  435. >
  436.