home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR8 / QEDITTSE.ZIP / QEDIT.S
Text File  |  1993-07-23  |  70KB  |  2,143 lines

  1. /*****************************************************************************
  2.  Copyright 1992-1993 SemWare Corporation.  All Rights Reserved Worldwide.
  3.  
  4.  QEdit 2.15 emulation for TSE
  5.  *****************************************************************************/
  6.  
  7. help QuickHelp
  8.     x = 1
  9.     y = 1
  10.     title = "Miscellaneous Commands"
  11.  
  12.     "                 PRESS <RETURN> or <ESCAPE> to Cancel help                      "
  13.     "                     Selected TSE Commands By Function  "
  14.     "                            <Esc> for Menus"
  15.     ""
  16.     "    Cursor Movement  ====================================================="
  17.     ""
  18.     "             BegFile                  <Ctrl PgUp>, <Qtrl Q><R>"
  19.     "             EndFile                  <Ctrl PgDn>, <Qtrl Q><C>"
  20.     "             GotoBlockBeg             <Ctrl Q><B>"
  21.     "             GotoBlockEnd             <Ctrl Q><K>"
  22.     "             GotoLine                 <Ctrl J>"
  23.     "             PrevPosition             <Ctrl Q><P>"
  24.     "             ScreenLeft               <Alt F5>"
  25.     "             ScreenRight              <Alt F6>"
  26.     "             ScrollUp                 <Ctrl W>"
  27.     "             ScrollDown               <Ctrl Z>"
  28.     "             WordRight                <Ctrl CursorRight>, <Ctrl F>"
  29.     "             WordLeft                 <Ctrl CursorLeft>, <Ctrl A>"
  30.     ""
  31.     "    Toggles  ============================================================="
  32.     ""
  33.     "             43/50 line mode          <Ctrl F1>"
  34.     "             ToggleBoxDraw            <Shift F1>"
  35.     "             ToggleBoxType            <Alt F1>"
  36.     "             ToggleIndent             <Ctrl Q><I>"
  37.     "             ToggleSmartTabs          <Ctrl Q><T>"
  38.     "             ToggleTabsExpand         <Alt V>"
  39.     "             ToggleWordwrap           <Ctrl O><W>"
  40.     ""
  41.     "    Block  ==============================================================="
  42.     ""
  43.     "             AppendScrBuff            <Ctrl B><A>"
  44.     "             Copy                     <grey+>"
  45.     "             CopyBlock                <Alt C>"
  46.     "             Cut                      <grey->"
  47.     "             DeleteBlock              <Alt G>, <Ctrl K><Y>"
  48.     "             DropAnchor               <Alt A>"
  49.     "             FillBlock                <Ctrl K><L>"
  50.     "             GetScrBuff               <Ctrl B><L>"
  51.     "             MarkColumn               <Alt K>"
  52.     "             MarkLine                 <Alt L>"
  53.     "             MarkWord                 <Ctrl K><T>"
  54.     "             MoveBlock                <Alt M>"
  55.     "             Paste                    <grey*>"
  56.     "             PasteOver                <Ctrl PrtSc>"
  57.     "             SaveBlock                <Alt W>, <Ctrl K><W>"
  58.     "             StoreScrBuff             <Ctrl B><S>"
  59.     "             UnmarkBlock              <Alt U>"
  60.     ""
  61.     "    File  ================================================================"
  62.     ""
  63.     "             ChangeFilename           <Alt O>"
  64.     "             EditFile                 <Alt E>"
  65.     "             EditFile at Cursor       <Ctrl ]>"
  66.     "             Exit                     <Ctrl K><D>"
  67.     "             GlobalExit               <Alt X>"
  68.     "             GlobalSave               <Alt Y>"
  69.     "             NextFile                 <Alt N>, <Ctrl K><N>"
  70.     "             PrevFile                 <Ctrl K><P>"
  71.     "             ReadBlock                <Alt R>"
  72.     "             SaveFile                 <Ctrl K><S>"
  73.     "             WriteBlock               <Alt W>"
  74.     ""
  75.     "    Editing  ============================================================="
  76.     ""
  77.     "             AddLine                  <F2>"
  78.     "             DelLine                  <Alt D>"
  79.     "             DelRtWord                <Ctrl T>"
  80.     "             DelToEol                 <F6>"
  81.     "             DupLine                  <F4>"
  82.     "             InsertLine               <Alt F2>"
  83.     "             JoinLine                 <Alt J>"
  84.     "             Literal                  <Ctrl P>"
  85.     "             SplitLine                <Alt S>"
  86.     "             UnKill                   <Ctrl U>"
  87.     ""
  88.     "    Other  ==============================================================="
  89.     ""
  90.     "             CenterLine               <Ctrl O><T>"
  91.     "             Dos Shell                <F9>"
  92.     "             Flip                     <Alt 3>"
  93.     "             Lower                    <Alt 2>"
  94.     "             RepeatCmd                <Ctrl Q><Q>"
  95.     "             Sort                     <Shift F3>"
  96.     "             UndoCursorline           <Ctrl Q><L>"
  97.     "             Upper                    <Alt 1>"
  98.     "             WrapPara                 <Alt B>"
  99.  
  100. end
  101.  
  102. /*****************************************************************
  103.   Some definitions / notes
  104.  
  105.   Macros used as commands (that are assigned to keys or menus sequences)
  106.   are prefixed with lower case "m" to distinguish them from built-in
  107.   commands, e.g., mDelChar() is a macro in this file, DelChar() is a
  108.   builtin command.
  109.  
  110.   Current character - The character at the cursor position in the
  111.   currently edited file.  Where the next typed character will be
  112.   inserted or replaced.
  113.  
  114.  *****************************************************************/
  115.  
  116. /*----------------------------------------------------------------
  117.   A simple language indenting package, providing the following:
  118.  
  119.   When AutoIndent is on,
  120.  
  121.   BackSpace, when the cursor is on a blank line or the first
  122.   non-blank character of a line, issues  TabLeft(), in
  123.   effect doing an outdent.
  124.  
  125.   Return, causes an extra indent when the first word of the line
  126.   is one of the following:
  127.  
  128.   if else elseif while repeat loop for switch case when
  129.  
  130.   Additionally, special handling of {} is provided for C
  131.   programmers.
  132.  
  133.   To make this package work:
  134.  
  135.   Assign mBackSpace() to <backspace>
  136.   Assign mCReturn() to <Enter>          // special handling for C
  137.   Assign  TabLeft() to <shift tab>
  138.   Assign CloseBrace() to <shift ]>      // For C files
  139.  
  140.   The _ON_CHANGING_FILES_ hook sets this mode (language) for files with
  141.   extensions of s, c, and h.
  142.   cmode is also set for files with extensions of c and h.
  143.  
  144.   ----------------------------------------------------------------*/
  145.  
  146. // Global variables - assumes globals initialized to 0.
  147.  
  148. integer
  149.     cmode,              // used to invoke C-mode
  150.     language,           // used to invoke language package
  151.     sort_flags,
  152.     pick_buffer,        // id of the pick-buffer
  153.     matchmode           // EnterMatching
  154.  
  155. string KeyWords[] = " if else elseif while repeat loop for switch case when otherwise proc "
  156.  
  157. /*************************************************************************
  158.   Helper macros/Subroutines
  159.  
  160.   These routines are:
  161.  
  162.    not intended for use as commands by themselves
  163.    not intended to be assigned to keys or menus
  164.    intended to be called from other macros
  165.  
  166.  *************************************************************************/
  167.  
  168. string proc CurrExt()
  169.     return (SplitPath(CurrFilename(), _EXT_))
  170. end
  171.  
  172. integer proc ListIt(string title, integer width)
  173.     width = width + 4
  174.     if width > Query(ScreenCols)
  175.         width = Query(ScreenCols)
  176.     endif
  177.     return (List(title, width))
  178. end
  179.  
  180. /*************************************************************************
  181.   Return the word at the cursor as a string.
  182.  *************************************************************************/
  183. string proc GetWordAtCursor()
  184.     string word[80] = ''
  185.  
  186.     PushBlock()                     // Save current block status
  187.     if MarkWord()                   // Mark the word
  188.         word = GetMarkedText()      // Get it
  189.     endif
  190.     PopBlock()                      // Restore block status
  191.     return (word)                   // Thats all, folks!
  192. end GetWordAtCursor
  193.  
  194. /*************************************************************************
  195.    Return the first word on the line as string - '' if not there.
  196.  *************************************************************************/
  197. string proc GetFirstWord()
  198.     string word[32] = ''
  199.  
  200.     PushPosition()                  // Save where we're at
  201.     GotoPos(PosFirstNonWhite())     // Go to first non white
  202.     word = GetWordAtCursor()        // Now get the word there
  203.     PopPosition()                   // Restore saved position
  204.     Lower(word)                     // Make it lower case
  205.     return (' ' + word + ' ')       // And return the word
  206. end
  207.  
  208. string proc GetTextUntil(string stopchar)
  209.     integer start = CurrPos()
  210.  
  211.     while CurrChar() <> Asc(stopchar) and CurrChar() >= 0 and Right()
  212.     endwhile
  213.  
  214.     return (GetText(start, CurrPos() - start))
  215. end
  216.  
  217. /*************************************************************************
  218.  *************************************************************************/
  219. menu ExecLoadPurge()
  220.     Title = "Macro function"
  221.     Width = 16
  222.  
  223.     "&Execute..."
  224.     "&Load..."
  225.     "&Purge..."
  226. end
  227.  
  228. /*************************************************************************
  229.  *************************************************************************/
  230. menu LoadExec()
  231.     "&Load macro"
  232.     "&Execute macro"
  233. end
  234.  
  235. /*************************************************************************
  236.  *************************************************************************/
  237. string proc OnOffStr(integer i)
  238.     return (iif(i, "On", "Off"))
  239. end
  240.  
  241. /*************************************************************************
  242.  *************************************************************************/
  243. string proc ShowSortFlag()
  244.     return (iif(sort_flags & 1, "Descending", "Ascending"))
  245. end
  246.  
  247. proc ToggleSortFlag(integer which)
  248.     if sort_flags & which
  249.         sort_flags = sort_flags & ~ which
  250.     else
  251.         sort_flags = sort_flags | which
  252.     endif
  253. end
  254.  
  255. /*************************************************************************
  256.  *************************************************************************/
  257. integer proc ReadNum(integer n)
  258.     string s[5] = str(n)
  259.  
  260.     return (iif(Read(s), val(s), n))
  261. end ReadNum
  262.  
  263. ///////////////////// End Help Macros/Subroutines ///////////////////////
  264.  
  265. /*************************************************************************
  266.   Macros that follow can:
  267.  
  268.    be assigned to keys and menus as commands
  269.    therefore, can be directly executed by the user
  270.  
  271.   Commands implemented in the macro langauge:
  272.  
  273.      mCopyCharAbove
  274.      ToggleEnterMatching()
  275.      mSetPLMargin()
  276.      mSetRMargin()
  277.      mEditFileAtCursor()
  278.      mToggleEGA43
  279.      mPQuit
  280.      mGPQuit
  281.      mMarkBlockBegin
  282.      mMarkBlockEnd
  283.      mMatch
  284.      mListOpenFiles
  285.      mCenterLine
  286.      mScratchBuffer
  287.      mShift [ShiftBlock]
  288.      mIncrementalSearch
  289.      mFindWordAtCursor
  290.      mclosebrace
  291.      mCompressView
  292.      mAsciiChart
  293.      mListRecentFiles
  294.      mMacMenu
  295.      mSwapLines
  296.      mCount
  297.      mSendFormFeed
  298.      GetPrintDevice
  299.      GetHeader
  300.      GetFooter
  301.      GetInitString
  302.      SendInit
  303.      mDateTimeStamp
  304.  
  305.   Commands augmented via macros:
  306.  
  307.      mBackSpace()
  308.      mDelChar()
  309.      mCReturn()
  310.      mUpper()
  311.      mLower()
  312.      mFlip()
  313.      mWrapPara
  314.  *************************************************************************/
  315.  
  316. /*********************************************************************
  317.   The GetPrev() command.
  318.  *********************************************************************/
  319. integer proc mCopyCharAbove()
  320.     integer c, sv = Set(RemoveTrailingWhite, OFF)
  321.  
  322.     PushPosition()                  // save position
  323.     c = iif(up(), CurrChar(), -1)   // Try for char on line above
  324.     PopPosition()                   // back to where we were
  325.     Set(RemoveTrailingWhite, sv)
  326.     return (c >= 0 and InsertText(Chr(c)))
  327. end mCopyCharAbove
  328.  
  329. /************************************************************************
  330.   Author:  SemWare (Richard Blackburn)
  331.  
  332.   Date:    March  1992  - Initial version
  333.            July   1993  - Re-worked to use newly added Keydefs
  334.  
  335.   Description:
  336.  
  337.   Macro that inserts the matching character for certain keys.  This is to
  338.   emulate the QEdit Advanced EnterMatching mode.
  339.  
  340.   Usage notes:
  341.  
  342.   To use, add these macros to your TSE.S file, and key assignments to
  343.   your TSE.KEY file, and re-bind the editor using the -b switch of sc.
  344.  
  345.   Be sure to rename the main routine if used in TSE.S.  A suitable name is
  346.   ToggleEnterMatching.
  347.  
  348.   Example key assignments might be:
  349.  
  350.   <f11>         ToggleEnterMatching()
  351.  
  352.   Alternatively, add the key assignments to this file, and load the
  353.   macro (as an external macro) as needed via the LoadMacro command
  354.   (<ctrl f10><L> or 'menu->macro->load')
  355.  
  356.   This keydef when active will insert both the character represented
  357.   by the key pressed and its matching key.  It moves back to the left
  358.   to place you within the two characters.
  359. ***********************************************************************/
  360. keydef ent_match
  361.     <[>         InsertText('[]') Left()
  362.     <'>         InsertText("''") Left()
  363.     <Shift '>   InsertText('""') Left()
  364.     <Shift 9>   InsertText('()') Left()
  365.     <Shift [>   InsertText('{}') Left()
  366.     <Shift ,>   InsertText('<>') Left()
  367. end
  368.  
  369. /***********************************************************************
  370.   Toggle the global variable matchmode, depending on the value of the
  371.   matchmode Enable/Disable the keydef ent_match.
  372. ***********************************************************************/
  373. proc ToggleEnterMatching()
  374.     matchmode = not matchmode
  375.     if matchmode
  376.         Enable(ent_match)
  377.     else
  378.         Disable(ent_match)
  379.     endif
  380. end
  381.  
  382. proc mSetPLMargin()
  383.     string margin[5] = ''
  384.     if Ask('Printer Left Margin [0..200]:', margin) AND Length(margin)
  385.         if Abs(Val(margin)) < 200
  386.             Set(PrintLeftMargin, Abs(Val(margin)))
  387.         endif
  388.     endif
  389. end
  390.  
  391. proc mSetRMargin()
  392.     string margin[5] = ''
  393.     if Ask('Right Margin [0..500]:', margin) AND Length(margin)
  394.         if Abs(Val(margin)) < 500
  395.             Set(RightMargin, Abs(Val(margin)))
  396.         endif
  397.     endif
  398. end
  399.  
  400. proc mEditFileAtCursor()
  401.     string  wset[32] = Set(WordSet, ChrSet("A-Za-z0-9_!#$%&`()./\\@{}~:^'-"))
  402.  
  403.     PushBlock()
  404.     UnMarkBlock()
  405.     MarkWord()
  406.     EditFile(GetMarkedText())
  407.     PopBlock()
  408.     Set(WordSet, wset)
  409. end
  410.  
  411. proc mToggleEGA43()
  412.     if Query(ScreenRows) <> 25
  413.         Set(CurrVideoMode, _25_LINES_)
  414.     else
  415.         Set(CurrVideoMode, _50_LINES_)
  416.         if Query(ScreenRows) <> 50
  417.             Set(CurrVideoMode, _43_LINES_)
  418.         endif
  419.     endif
  420. end
  421.  
  422.  
  423. integer proc mPQuit()
  424.     if isChanged()
  425.         if YesNo("Lose Changes?") == 1
  426.                 ForceChanged(FALSE)
  427.         else
  428.             return (FALSE)
  429.         endif
  430.     endif
  431.     return (QuitFile())
  432. end
  433.  
  434. proc mGPQuit()
  435.     while mPQuit()
  436.     endwhile
  437. end
  438.  
  439. /*
  440.  MarkBlockBegin, MarkBlockEnd
  441.  
  442.  Written by:   Tim Farley
  443.  Last updated: 12 February 1992
  444.  
  445.  Enhancement:  Returns appropriate TRUE/FALSE value, where 2.1x always returned
  446.                TRUE.
  447.  
  448.  Limitations:  Uses PlaceMark()'s "Y" and "Z" to implement the marking, could
  449.                interfere with users using these same letters.
  450.  
  451.                Cross-file marking doesn't work *precisely* like it does in
  452.                2.1x.
  453. */
  454. string PlaceMarkBegin[ 1 ] = "y"        // PlaceMark() to use for begin block
  455. string PlaceMarkEnd[ 1 ]   = "z"        // PlaceMark() to use for end block
  456.  
  457. integer proc ShowMark()
  458.     integer BeginID, EndID, Success = FALSE
  459.     integer BeginRow, BeginCol, EndRow, EndCol
  460.  
  461.     PushPosition()                      // Remember originalposition
  462.  
  463.     GotoMark( PlaceMarkBegin )          // Goto beginning of mark
  464.     BeginID  = GetBufferID()            // Record where that is
  465.     BeginRow = CurrLine()
  466.     BeginCol = CurrPos()
  467.  
  468.     GotoMark( PlaceMarkEnd )            // Goto end of mark
  469.     EndID    = GetBufferID()            // Record where that is
  470.     EndRow   = CurrLine()
  471.     EndCol   = CurrPos()
  472.  
  473.     //
  474.     // Is end of mark somewhere past beginning of mark, in the same file?
  475.     //
  476.     Success = ( BeginID == EndID ) AND
  477.               ( EndRow >= BeginRow ) AND ( EndCol >= BeginCol )
  478.     if  Success
  479.         GotoMark( PlaceMarkBegin )      // Go to top
  480.         MarkChar()                      // and start marking...
  481.         GotoMark( PlaceMarkEnd )        // Go to bottom
  482.         MarkChar()                      // and end the mark!
  483.     endif
  484.     PopPosition()                       // Return to original position
  485.  
  486.     return ( Success )
  487. end ShowMark
  488.  
  489. integer proc mMarkBlockBegin()
  490.     UnmarkBlock()
  491.     PlaceMark( PlaceMarkBegin )
  492.  
  493.     return ( ShowMark() )
  494. end mMarkBlockBegin
  495.  
  496. integer proc mMarkBlockEnd()
  497.     UnmarkBlock()
  498.     PlaceMark( PlaceMarkEnd )
  499.  
  500.     return ( ShowMark() )
  501. end mMarkBlockEnd
  502.  
  503. /*************************************************************************
  504.   The match command.  Use this macro to match (){}{}<> chars.
  505.  *************************************************************************/
  506. string match_chars[] = "(){}[]<>"   // pairs of chars to match
  507. integer proc mMatch()
  508.     integer p, level, mc, ch, start_line = CurrLine()
  509.  
  510.     p = Pos(chr(CurrChar()), match_chars)
  511.     // If we're not already on a match char, go forward to find one
  512.     if p == 0 and lFind("[(){}[\]<>]", "x")
  513.         ScrollToRow(CurrLine() - start_line + CurrRow())
  514.         return (FALSE)
  515.     endif
  516.  
  517.     PushPosition()
  518.     if p
  519.         ch = asc(match_chars[p])             // Get the character we're matching
  520.         mc = asc(match_chars[iif(p & 1, p + 1, p - 1)])  // And its reverse
  521.         level = 1                       // Start out at level 1
  522.  
  523.         while lFind("[\" + chr(ch) + "\" + chr(mc) + "]", iif(p & 1, "x+", "xb"))
  524.             case CurrChar()             // And check out the current character
  525.                 when ch
  526.                     level = level + 1
  527.                 when mc
  528.                     level = level - 1
  529.                     if level == 0
  530.                         KillPosition()          // Found a match, remove position
  531.                         GotoXoffset(0)          // Fix up possible horizontal scrolling
  532.                         ScrollToRow(CurrLine() - start_line + CurrRow())
  533.                         return (TRUE)           // And return success
  534.                     endif
  535.             endcase
  536.         endwhile
  537.     endif
  538.     PopPosition()                       // Restore position
  539.     return (warn("Match not found"))    // Warn() returns False
  540. end mMatch
  541.  
  542. /*****************************************************************************
  543.   List Files placed in the editor's internal ring of files.
  544.  
  545.   Notes:
  546.     System buffers are _not_ intended for interactive editing.  Therefore,
  547.     this command will exit if it is determined that the current buffer is a
  548.     system buffer.
  549.  *****************************************************************************/
  550. proc mListOpenFiles()
  551.     integer start_file, filelist, id, rc, maxl, total, n
  552.     string fn[65]
  553.  
  554.     n = NumFiles() + (Query(BufferType) <> _NORMAL_)
  555.     if n == 0
  556.         return ()
  557.     endif
  558.     maxl = 0
  559.     total = 0
  560.     start_file = GetBufferid()                 // Save current
  561.     filelist = CreateTempBuffer()
  562.     if filelist == 0
  563.         warn("Can't create filelist")
  564.         return ()
  565.     endif
  566.     GotoBufferId(start_file)
  567.     id = GetBufferid()
  568.     while n
  569.         fn = CurrFilename()
  570.         if length(fn)
  571.             if length(fn) > maxl
  572.                 maxl = length(fn)
  573.             endif
  574.             rc = isChanged()
  575.             GotoBufferId(filelist)
  576.             AddLine(iif(rc, '*', ' ') + fn)
  577.             GotoBufferId(id)
  578.         endif
  579.         NextFile(_DONT_LOAD_)
  580.         id = GetBufferid()
  581.         n = n - 1
  582.     endwhile
  583.     GotoBufferId(filelist)
  584.     BegFile()
  585.     if ListIt("Buffer List", maxl)
  586.         EditFile(GetText(2, sizeof(fn)))    // Force loading from disk
  587.     else
  588.         GotoBufferId(start_file)
  589.     endif
  590.     AbandonFile(filelist)
  591. end mListOpenFiles
  592.  
  593. /************************************************************************
  594.   Routine to center a line.
  595.   If a block is marked, all the lines in the block are centered, using
  596.     the left and right margins;
  597.   if the block is a column block, only the text in the column block is
  598.     centered, without disturbing surrounding text.
  599.  ************************************************************************/
  600. proc mCenterLine()
  601.     integer right_margin = Query(RightMargin),
  602.         left_margin = Query(LeftMargin),
  603.         first_line, last_line, type, p, center, cid, tid
  604.  
  605.     PushPosition()
  606.     PushBlock()
  607.     if left_margin == 0 or left_margin >= right_margin
  608.         left_margin = 1
  609.     endif
  610.     first_line = CurrLine()
  611.     last_line = first_line
  612.     type = isCursorInBlock()
  613.     if type
  614.         Set(Marking, off)
  615.         first_line = Query(BlockBegLine)
  616.         last_line = Query(BlockEndLine)
  617.         if type == _COLUMN_
  618.             GotoBlockBegin()
  619.             cid = GetBufferId()
  620.             tid = CreateTempBuffer()
  621.             CopyBlock()
  622.  
  623.             /*
  624.               Need to make sure we overlay everything with spaces
  625.              */
  626.             PushBlock()
  627.             GotoBufferId(cid)
  628.             CopyBlock(_OVERWRITE_)
  629.             FillBlock(' ')
  630.             GotoBufferid(tid)
  631.             PopBlock()
  632.  
  633.             last_line = last_line - first_line + 1
  634.             first_line = 1
  635.             left_margin = 1
  636.             right_margin = Query(BlockEndCol) - Query(BlockBegCol) + 1
  637.         endif
  638.     else
  639.         UnmarkBlock()
  640.     endif
  641.     if right_margin > left_margin
  642.         GotoLine(first_line)
  643.         repeat
  644.             p = PosFirstNonWhite()
  645.             center = ((p + PosLastNonWhite()) / 2) - ((left_margin + right_margin) / 2)
  646.             ShiftText(iif(center > 0,
  647.                 - (iif(center < p, center, p - 1)), Abs(center)))
  648.         until (not RollDown()) or CurrLine() > last_line
  649.         if type == _COLUMN_
  650.             GotoBufferId(cid)
  651.             CopyBlock(_OVERWRITE_)
  652.             AbandonFile(tid)
  653.         endif
  654.     endif
  655.     PopBlock()
  656.     PopPosition()
  657. end mCenterLine
  658.  
  659. // QEdit 2.15 style scratch buffer package
  660.  
  661. constant
  662.     GETOVERLAY =    0,
  663.     GETTING =       1,  // code depends on this order
  664.  
  665.     STORING =       2,
  666.     APPENDING =     3,
  667.     CUTTING =       4,
  668.     CUTAPPEND =     5
  669.  
  670. integer proc mScratchBuffer(integer operation)
  671.     integer cid, id, result, SaveClipBoardId
  672.     string BufferName[40], msg[30]
  673.  
  674.     if operation > GETTING and (NOT isBlockInCurrFile())
  675.         return (FALSE)
  676.     endif
  677.     BufferName = ""
  678.     result = TRUE                               // assume success
  679.     SaveClipBoardId = GetClipBoardId()          // save id
  680.     case operation
  681.         when STORING    msg = "Copy to ClipBoard:"
  682.         when APPENDING  msg = "Copy Append to ClipBoard:"
  683.         when GETTING    msg = "Paste from ClipBoard:"
  684.         when GETOVERLAY msg = "Paste Over from ClipBoard:"
  685.         when CUTTING    msg = "Cut to ClipBoard:"
  686.         when CUTAPPEND  msg = "Cut Append to ClipBoard:"
  687.     endcase
  688.     if ask(msg, BufferName) and Length(BufferName)   // get scratch name
  689.         BufferName = "+++" + BufferName         // Fudge for scratch
  690.         id = GetBufferId(BufferName)             // See if already there
  691.         if operation <> GETTING and id == 0
  692.             cid = GetBufferId()
  693.             id = CreateBuffer(BufferName, _SYSTEM_)    // create a buffer
  694.             GotoBufferId(cid)
  695.         endif
  696.         if id <> 0                              // if it worked
  697.             SetClipBoardId(id)                  // new ClipBoard
  698.             case operation
  699.                 when STORING    result = Copy()
  700.                 when APPENDING    result = Copy(_APPEND_)
  701.                 when GETTING    result = Paste()
  702.                 when GETOVERLAY result = Paste(_OVERWRITE_)
  703.                 when CUTTING    result = Cut()
  704.                 when CUTAPPEND  result = Cut(_APPEND_)
  705.             endcase
  706.             SetClipBoardId(SaveClipBoardId)     // restore ClipBoard
  707.         else
  708.             warn("Could not create/find buffer")
  709.         endif
  710.     endif
  711.     return (result)                               // return result
  712. end
  713.  
  714. constant SHIFTLEFT = -1, SHIFTRIGHT = 1
  715.  
  716. integer proc mShiftBlock(integer direction)
  717.     integer goal_line = CurrLine(),
  718.             btype     = isCursorInBlock(),
  719.             save_marking   = Query(Marking),
  720.             p = CurrPos()
  721.  
  722.     PushPosition()
  723.     if btype
  724.         goal_line = Query(BlockEndLine)
  725.         GotoBlockBegin()
  726.     endif
  727.     repeat until not ShiftText(direction)
  728.             or   not RollDown()
  729.             or   CurrLine() > goal_line
  730.     PopPosition()
  731.     GotoPos(p)
  732.     Set(Marking, save_marking)
  733.     return (TRUE)
  734. end
  735.  
  736. proc mShift()
  737.     integer k = Set(EquateEnhancedKbd, ON)
  738.  
  739.     loop
  740.         Message("<Left>,<Right> or <Tab>,<Shift Tab> to shift text; <Enter> when done")
  741.         case GetKey()
  742.             when <CursorLeft>
  743.                 mShiftBlock(-1)
  744.             when <CursorRight>
  745.                 mShiftBlock(1)
  746.             when <Tab>
  747.                 mShiftBlock(Query(TabWidth))
  748.             when <Shift Tab>
  749.                 mShiftBlock(-Query(TabWidth))
  750.             when <Escape>, <Enter>
  751.                 break
  752.             when <Alt U>
  753.                 if isCursorInBlock()
  754.                     UnMarkBlock()
  755.                     break
  756.                 endif
  757.         endcase
  758.         UpdateDisplay(_REFRESH_THIS_ONLY_ | _WINDOW_REFRESH_)
  759.     endloop
  760.     Set(EquateEnhancedKbd, k)
  761.     UpdateDisplay()
  762. end
  763.  
  764.  
  765. /***************************************************************************
  766.   An Incremental search.  I rarely use regular search, since implementing
  767.   this...
  768.  ***************************************************************************/
  769. proc mIncrementalSearch()
  770.     string s[40]="", option[8] = "i"
  771.     integer ch, global_or_reverse, next
  772.  
  773.     global_or_reverse = FALSE
  774.  
  775.     PushPosition()
  776.     loop
  777.         if Length(s) and global_or_reverse
  778.             option = substr(option, 1, length(option) - 1)
  779.             global_or_reverse = FALSE
  780.         endif
  781.         next = FALSE
  782.         message("I-Search (^N=Next ^P=Prev ^B=Beginning):", s)
  783.  
  784.         retry:
  785.         ch = getkey()
  786.         case ch
  787.             when <BackSpace>                // go back to start
  788.                 PopPosition()
  789.                 PushPosition()
  790.                 s = iif(length(s) <= 1, "", substr(s, 1, length(s) - 1))
  791.             when <Ctrl L>, <Ctrl N>         // just search again
  792.                 NextChar()
  793.                 next = TRUE
  794.             when <Ctrl R>, <Ctrl P>         // go to previous occurrence
  795.                 option = option + 'b'
  796.                 global_or_reverse = TRUE
  797.             when <Ctrl G>, <Ctrl B>         // beginning of file
  798.                 option = option + 'g'
  799.                 global_or_reverse = TRUE
  800.             when <Enter>, <Escape>
  801.                 if Length(s)
  802.                     AddHistoryStr(s, _FINDHISTORY_)
  803.                 endif
  804.                 break
  805.             otherwise
  806.                 if (ch & 0xff) == 0         // Function key?
  807.                     goto retry              // Yes, try again.
  808.                 endif
  809.                 s = s + chr(ch & 0xff)      // mask off the scan code
  810.         endcase
  811.         if Length(s) and NOT find(s, option) and NOT global_or_reverse and NOT next
  812.             s = substr(s, 1, length(s) - 1)
  813.         endif
  814.     endloop
  815.     KillPosition()
  816.     UpdateDisplay()
  817. end
  818.  
  819. integer proc mFindWordAtCursor(string option)
  820.     if Length(GetWordAtCursor())
  821.         AddHistoryStr(GetWordAtCursor(), _FINDHISTORY_)
  822.         return (Find(GetWordAtCursor(), Query(FindOptions) + option))
  823.     endif
  824.     return (Find())
  825. end mFindWordAtCursor
  826.  
  827. // Special handling of } for C programmers
  828. integer proc mCloseBrace()
  829.     if cmode and PosFirstNonWhite() == 0
  830.         TabLeft()
  831.     endif
  832.     return (InsertText("}"))
  833. end
  834.  
  835. string lineone[] = "      ■■■ Select this line to edit COMPRESS file ■■■"
  836. integer compress_hist, compress_options_history
  837. string compress_buffer_name[] = "[<compress>]"
  838.  
  839. proc mCompressView(integer compress_type)
  840.     string expr[65] = '', opts[12] = '',
  841.            line[132]
  842.     integer
  843.         line_no,        // saved CurrLine() for compressed view
  844.         list_no,        // line we exited on
  845.         start_line_no,   // line number we were on
  846.         goto_line_no,
  847.         width,
  848.         mk,
  849.         compress_id,
  850.         current_id = GetBufferId(), maxlen = Length(lineone)
  851.  
  852.     if compress_hist == 0   // This must be first time through - do initialization.
  853.         compress_hist = GetFreeHistory()
  854.         compress_options_history = GetFreeHistory()
  855.         AddHistoryStr(Query(FindOptions), compress_options_history)
  856.     endif
  857.  
  858.     start_line_no = CurrLine()
  859.     if NumLines() == 0
  860.         return ()
  861.     endif
  862.  
  863.     line_no = 0
  864.     list_no = 0
  865.     goto_line_no = 1
  866.     width = Length(Str(NumLines()))
  867.  
  868.     // compress_types are [0..1]
  869.     if compress_type == 0
  870.         if not ask("String to list all occurrences of:", expr, compress_hist)
  871.             return ()
  872.         endif
  873.         if Length(expr) == 0
  874.             opts = "x"
  875.             expr = "^[a-zA-Z_]"
  876.         elseif not ask("Search options [IWX] (Ignore-case Words reg-eXp):", opts, compress_options_history)
  877.             return ()
  878.         endif
  879.     else
  880.         opts = "ix"
  881.         case CurrExt()
  882.             when ".c",".cpp"
  883.                 expr = "^[a-zA-Z_].*\(.*[~;]$"
  884.             when ".s"
  885.                 expr = "^{public #}?{{integer #}|{string #}}@proc +[a-zA-Z_]"
  886.             when ".pas"
  887.                 expr = "{procedure}|{function} +[a-zA-Z_]"
  888.             when ".prg",".spr",".mpr",".qpr",".fmt",".frg",".lbg",".ch"
  889.                 expr = "^{procedure}|{function} +[a-zA-Z_]"
  890.             otherwise
  891.                 warn("Extension not supported")
  892.                 return ()
  893.         endcase
  894.     endif
  895.  
  896.     compress_id = CreateBuffer(compress_buffer_name)
  897.     if compress_id == 0
  898.         compress_id = GetBufferId(compress_buffer_name)
  899.     endif
  900.     if compress_id == current_id
  901.         warn("Can't use this buffer")
  902.         return ()
  903.     endif
  904.     if compress_id == 0 or not GotoBufferId(compress_id)
  905.         return ()
  906.     endif
  907.  
  908.     // At this point, we are in the compress buffer
  909.     EmptyBuffer()
  910.     InsertText(lineone)
  911.     GotoBufferId(current_id)
  912.     PushPosition()
  913.     BegFile()
  914.     if lFind(expr, opts)
  915.         repeat
  916.             line = GetText(1, sizeof(line))
  917.             line_no = CurrLine()
  918.             if Length(line) > maxlen
  919.                 maxlen = Length(line)
  920.             endif
  921.             GotoBufferId(compress_id)
  922.             if not AddLine(Format(line_no:width, ': ', line))
  923.                 break
  924.             endif
  925.             if goto_line_no == 1 and line_no > start_line_no
  926.                 goto_line_no = CurrLine() - 1
  927.             endif
  928.             GotoBufferId(current_id)
  929.             EndLine()
  930.         until not lRepeatFind()
  931.     endif
  932.     GotoBufferId(compress_id)
  933.     GotoLine(goto_line_no)
  934.     if ListIt(iif(compress_type == 0, expr, "Function List"), maxlen + width)
  935.         if CurrLine() == 1
  936.             PopPosition()
  937.             GotoBufferId(compress_id)
  938.             mk = Set(KillMax, 0)
  939.             DelLine()
  940.             Set(KillMax, mk)
  941.             ForceChanged(FALSE)
  942.             return ()
  943.         endif
  944.         list_no = val(GetText(1, width))
  945.     endif
  946.     AbandonFile()
  947.     PopPosition()
  948.     if list_no
  949.         GotoLine(list_no)
  950.         ScrollToRow(Query(WindowRows)/2)
  951.     endif
  952. end mCompressView
  953.  
  954. integer chartid
  955. proc mAsciiChart()
  956.     integer
  957.         i,
  958.         ok,
  959.         c = CurrChar(),
  960.         et = Set(ExpandTabs, off)
  961.  
  962.     PushPosition()
  963.     if chartid == 0
  964.         chartid = CreateTempBuffer()
  965.         i = 0
  966.         while AddLine(format(i:4, str(i, 16):4, chr(i):4)) and i <> 255
  967.             i = i + 1
  968.         endwhile
  969.     endif
  970.     GotoBufferId(chartid)
  971.     BegFile()
  972.     if c > 0
  973.         GotoLine(c + 1)
  974.     endif
  975.     ok = ListIt("DEC HEX Char", 12)
  976.     i = CurrLine() - 1
  977.     PopPosition()
  978.     if ok
  979.         InsertText(chr(i))
  980.     endif
  981.     Set(ExpandTabs, et)
  982. end mAsciiChart
  983.  
  984. proc mListRecentFiles()
  985.     integer maxl = 0, cid = GetBufferId()
  986.  
  987.     if GotoBufferId(pick_buffer)
  988.         BegFile()
  989.         repeat
  990.             if CurrLineLen() > maxl
  991.                 maxl = CurrLineLen()
  992.             endif
  993.         until not down()
  994.         GotoLine(2)
  995.         if ListIt("Recent Files", maxl)
  996.             EditFile(GetText(1, CurrLineLen()))
  997.         else
  998.             GotoBufferId(cid)
  999.         endif
  1000.     endif
  1001. end mListRecentFiles
  1002.  
  1003. /************************************************************************
  1004.   This version assumes the compiler program is either in the current
  1005.   directory or available via the path.
  1006.  ************************************************************************/
  1007. proc mCompile()
  1008.     string fn[65] = CurrFilename(),
  1009.         err_fn[12] = "$errors$.tmp"
  1010.     integer line, col
  1011.  
  1012.     if CurrExt() <> ".s"
  1013.         Warn("Extension not supported")
  1014.         return ()
  1015.     endif
  1016.     OneWindow()         // Force a single window
  1017.     if isChanged()
  1018.         SaveFile()
  1019.     endif
  1020.     // Remove the error file if we're already editing it
  1021.     AbandonFile(GetBufferId(ExpandPath(err_fn)))
  1022.     PurgeMacro(fn)
  1023.     EraseDiskFile(err_fn)
  1024.     Dos("sc " + fn + ">" + err_fn, _DONT_CLEAR_)
  1025.     EditFile(err_fn)
  1026.     EraseDiskFile(err_fn)
  1027.     //
  1028.     // 3 cases -
  1029.     //      1 - SC didn't run, probably not found. Identify by empty err_fn
  1030.     //      2 - Error/Warning msg found in err_fn - position to error
  1031.     //      3 - No Errors/Warnings!  Load/Exec the new macro.
  1032.     //
  1033.     if NumLines() == 0                          // If empty, we failed
  1034.         AbandonFile()
  1035.         Updatedisplay()
  1036.         Warn("Error running SC.EXE")
  1037.     elseif lFind("^{Error}|{Warning} #[0-9]# #\c","ix")
  1038.         PrevFile()
  1039.         HWindow()
  1040.         if CurrChar() == Asc('(')
  1041.             Right()
  1042.             line = Val(GetTextUntil(','))
  1043.             Right()                             // skip the comma
  1044.             col  = Val(GetTextUntil(')'))
  1045.             PrevWindow()
  1046.             GotoLine(line)
  1047.             ScrollToRow(Query(WindowRows) / 2)
  1048.             GotoColumn(col)
  1049.         endif
  1050.         UpdateDisplay()
  1051.     else
  1052.         // At this point, no error/warning messages found, in the error file
  1053.         AbandonFile()
  1054.         UpdateDisplay()                     // Force a statusline refresh
  1055.         fn = SplitPath(fn, _DRIVE_ | _NAME_)
  1056.         case LoadExec("Compile successful")
  1057.             when 1
  1058.                 LoadMacro(fn)
  1059.             when 2
  1060.                 ExecMacro(fn)
  1061.         endcase
  1062.     endif
  1063. end
  1064.  
  1065. integer proc mMacMenu(integer n)
  1066.     string s[8] = ''
  1067.  
  1068.     if n == 0
  1069.         n = ExecLoadPurge()
  1070.     endif
  1071.     case n
  1072.         when 1
  1073.             return (ExecMacro())
  1074.         when 2
  1075.             return (LoadMacro())
  1076.         when 3
  1077.             if ask("Purge macro:", s) and Length(s) and PurgeMacro(s)
  1078.                 Message(s, " purged.")
  1079.                 return (TRUE)
  1080.             endif
  1081.     endcase
  1082.     return (FALSE)
  1083. end
  1084.  
  1085. proc mSwapLines()
  1086.     integer km
  1087.  
  1088.     if Down()
  1089.         km = Set(KillMax, 1)
  1090.         DelLine()
  1091.         Up()
  1092.         UnDelete()
  1093.         Set(KillMax, km)
  1094.     endif
  1095. end
  1096.  
  1097. /***********************************************************************
  1098.   Find and do.
  1099.  
  1100.   Applies one of several options to a found string.
  1101.  ***********************************************************************/
  1102. constant
  1103.     dofCOUNT = 1, dofDELLINE = 2, dofCUTAPPEND = 3, dofCOPYAPPEND = 4
  1104.  
  1105. menu FindAndDoMenu()
  1106.     History
  1107.     Title = "After Find do"
  1108.     Width = 20
  1109.  
  1110.     "Cou&nt"           , , CloseAllBefore
  1111.     "&Delete Line"     , , CloseAllBefore
  1112.     "C&ut Append"      , , CloseAllBefore
  1113.     "&Copy Append"     , , CloseAllBefore
  1114. end
  1115.  
  1116. proc mFindAndDo()
  1117.     integer choice, curr_id, count, n, old_sound
  1118.     string find_st[65] = '', find_option_st[12] = ''
  1119.  
  1120.     curr_id = GetBufferId()
  1121.     choice = FindAndDoMenu()
  1122.     case choice
  1123.         when 0
  1124.             return ()
  1125.         when dofCUTAPPEND, dofCOPYAPPEND    // cut/copy to buffer
  1126.             GotoBufferId(GetClipBoardId())
  1127.             EmptyBuffer()
  1128.             GotoBufferId(curr_id)
  1129.     endcase
  1130.     count = 0
  1131.     PushPosition()
  1132.     if Ask("Search for:", find_st, _FIND_HISTORY_) and Ask("Options [BGLIWX] (Back Global Local Ignore-case Words reg-eXp):", find_option_st, _FIND_OPTIONS_HISTORY_) and lFind(find_st, find_option_st)
  1133.         old_sound = Set(sound, off)
  1134.         repeat
  1135.             count = count + 1
  1136.             n = NumLines()
  1137.             case choice
  1138.                 when dofDELLINE
  1139.                     DelLine()
  1140.                 when dofCUTAPPEND, dofCOPYAPPEND
  1141.                     PushBlock()
  1142.                     MarkLine()
  1143.                     MarkLine()
  1144.                     if choice == dofCUTAPPEND
  1145.                         Cut(_APPEND_)
  1146.                     else
  1147.                         Copy(_APPEND_)
  1148.                     endif
  1149.                     PopBlock()
  1150.             endcase
  1151.             if NumLines() < n
  1152.                 BegLine()
  1153.                 PrevChar()
  1154.             endif
  1155.         until not lRepeatFind()
  1156.         Set(sound, old_sound)
  1157.     endif
  1158.     PopPosition()
  1159.     Message(count, " occurrences found")
  1160. end
  1161.  
  1162.  
  1163. proc mSendFormFeed()
  1164.     if not PrintChar(chr(12))
  1165.         warn("Error sending formfeed")
  1166.     endif
  1167. end
  1168.  
  1169. proc GetPrintDevice()
  1170.     string s[48] = Query(PrintDevice)
  1171.  
  1172.     if ask("Print Device:", s)
  1173.         Set(PrintDevice, s)
  1174.     endif
  1175. end
  1176.  
  1177. proc GetHeader()
  1178.     string s[4] = Query(PrintHeader)
  1179.  
  1180.     if ask("Print Header [FDTP] (Filename Date Time Page):", s)
  1181.         Set(PrintHeader, s)
  1182.     endif
  1183. end
  1184.  
  1185. proc GetFooter()
  1186.     string s[4] = Query(PrintFooter)
  1187.  
  1188.     if ask("Print Footer [FDTP] (Filename Date Time Page):", s)
  1189.         Set(PrintFooter, s)
  1190.     endif
  1191. end
  1192.  
  1193. proc GetInitString()
  1194.     string s[60] = Query(PrintInit)
  1195.  
  1196.     if ask("Init String:", s)
  1197.         Set(PrintInit, s)
  1198.     endif
  1199. end
  1200.  
  1201. proc mSendInitString()
  1202.     string s[60] = Query(PrintInit)
  1203.     integer i = 1
  1204.  
  1205.     while i <= Length(s) and PrintChar(s[i])
  1206.         i = i + 1
  1207.     endwhile
  1208. end
  1209.  
  1210. proc mDateTimeStamp()
  1211.     InsertText(GetDateStr(), _INSERT_)
  1212.     InsertText(" ", _INSERT_)
  1213.     InsertText(GetTimeStr(), _INSERT_)
  1214. end
  1215.  
  1216. /*************************************************************************
  1217.   Commands augmented by macros:
  1218.  *************************************************************************/
  1219.  
  1220. /*********************************************************************
  1221.   Fancy backspace() command.
  1222.   Sort of like Borlands environment.  In language mode, backspace
  1223.   does a "outdent" when there is only white space before the cursor.
  1224.  
  1225.   Also does special handling for overwrite mode.  In overwrite mode,
  1226.   does a "rubout" instead of a backspace.
  1227.  *********************************************************************/
  1228. proc mBackSpace()
  1229.     if CurrPos() == 1       // at beg-of-line, just join to previous
  1230.         if PrevChar()
  1231.             JoinLine()
  1232.         endif
  1233.         return ()
  1234.     endif
  1235.  
  1236.     // if from here to prev-tabstop is 'white', then TabLeft()
  1237.  
  1238.     if Query(AutoIndent) and language
  1239.         if CurrPos() <= PosFirstNonWhite()
  1240.             TabLeft()
  1241.             return ()
  1242.         endif
  1243.         PushPosition()
  1244.         GotoColumn(CurrCol() - DistanceToTab())
  1245.         if CurrPos() > PosLastNonWhite()
  1246.             PopPosition()
  1247.             TabLeft()
  1248.             return ()
  1249.         endif
  1250.         PopPosition()
  1251.     endif
  1252.  
  1253.     // Finally, do either rubout or backspace based on InsertMode
  1254.  
  1255.     Left()
  1256.     if CurrChar() >= 0
  1257.         if Query(Insert)
  1258.             DelChar()
  1259.         else
  1260.             InsertText(" ", _OVERWRITE_)
  1261.             Left()
  1262.         endif
  1263.     endif
  1264. end
  1265.  
  1266. // Augment delchar by joining lines if at or passed eol
  1267. integer proc mDelChar()
  1268.     return(iif(CurrChar() >= 0, DelChar(), JoinLine()))
  1269. end
  1270.  
  1271. // Fancy CarriageReturn command.  Works if language mode is on.
  1272. integer proc mCReturn()
  1273.     integer found = FALSE
  1274.  
  1275.     if language and CurrPos() > PosFirstNonWhite()
  1276.         if pos(GetFirstWord(), KeyWords)
  1277.             found = TRUE
  1278.         elseif cmode
  1279.             PushPosition()
  1280.             repeat
  1281.                 if CurrChar() == asc('{')
  1282.                     found = TRUE
  1283.                     break
  1284.                 endif
  1285.             until not left()
  1286.             PopPosition()
  1287.         endif
  1288.     endif
  1289.     if not CReturn()
  1290.         return (FALSE)
  1291.     endif
  1292.     return (iif(found
  1293.                 and ((Query(Insert) and Query(ReturnEqNextLine) == FALSE)
  1294.                 or PosFirstNonWhite() == 0),
  1295.                 TabRight(), TRUE))
  1296. end
  1297.  
  1298. constant WORDCASE  = 1,
  1299.          LINECASE  = 2,
  1300.          BLOCKCASE = 3
  1301.  
  1302. constant UPPER_CASE = 0,
  1303.          LOWER_CASE = 1,
  1304.          FLIP_CASE  = 2
  1305.  
  1306. integer casetype
  1307.  
  1308. // Assume type is always one of WORDCASE, LINECASE or BLOCKCASE.
  1309. proc ChangeCase(integer type)
  1310.     PushBlock()
  1311.     if type <> BLOCKCASE
  1312.         UnMarkBlock()
  1313.         if type == LINECASE
  1314.             MarkLine()
  1315.         elseif not MarkWord()
  1316.             goto done
  1317.         endif
  1318.     elseif not isCursorInBlock()
  1319.         goto done
  1320.     endif
  1321.     case casetype
  1322.         when UPPER_CASE
  1323.             Upper()
  1324.         when LOWER_CASE
  1325.             Lower()
  1326.         otherwise
  1327.             Flip()
  1328.     endcase
  1329.     done:
  1330.  
  1331.     PopBlock()
  1332. end
  1333.  
  1334. menu CaseMenu()
  1335.     Command = ChangeCase(MenuOption())
  1336.  
  1337.     "&Word at Cursor"   // if the order of these options is changed,
  1338.     "Current &Line"     // Change to order of the constants
  1339.     "&Block"            // WORDCASE, LINECASE, and BLOCKCASE
  1340. end
  1341.  
  1342. proc mUpper()
  1343.     casetype = UPPER_CASE
  1344.     CaseMenu("Upper Case")
  1345. end
  1346.  
  1347. proc mLower()
  1348.     casetype = LOWER_CASE
  1349.     CaseMenu("Lower Case")
  1350. end
  1351.  
  1352. proc mFlip()
  1353.     casetype = FLIP_CASE
  1354.     CaseMenu("Flip Case")
  1355. end
  1356.  
  1357. integer proc mSaveSettings()
  1358.     if YesNo("Overwrite existing config?") == 1
  1359.         return (iif(SaveSettings(), TRUE, Warn("Error updating executable")))
  1360.     endif
  1361.     return (FALSE)
  1362. end
  1363.  
  1364. /************************************************************************
  1365.   Macro to wrap text in a column block, without distrubing the surrounding
  1366.   text.
  1367.  
  1368.   If a column isn't marked, the normal WrapPara() is called.
  1369.  ************************************************************************/
  1370. proc mWrapPara()
  1371.     integer
  1372.         id,                         // work buffer id
  1373.         block_beg_col,
  1374.         save_leftmargin,
  1375.         save_rightmargin,
  1376.         save_autoindent,
  1377.         save_wrapend,
  1378.         curr_id = GetBufferId(),    // current file id
  1379.         blocktype = isCursorInBlock()
  1380.  
  1381.     if blocktype == 0
  1382.         WrapPara()
  1383.     else
  1384.         Set(Marking, off)               // Stop marking
  1385.         if blocktype <> _COLUMN_        // Wrap entire block if not column
  1386.             GotoBlockEnd()
  1387.             AddLine()
  1388.             GotoBlockBegin()
  1389.             repeat
  1390.             until not WrapPara() or CurrLine() >= Query(BlockEndLine)
  1391.             if CurrLineLen() == 0
  1392.                 DelLine()
  1393.             endif
  1394.         else                            // Otherwise, wrap whats in col
  1395.             GotoBlockBegin()
  1396.             block_beg_col = CurrCol()
  1397.             id = CreateTempBuffer()
  1398.             CopyBlock()                 // Copy block to temp buffer
  1399.  
  1400.             /**************************************************************
  1401.               The number of lines in the column may become less than what
  1402.               it was - so we must fill the old block with spaces.
  1403.              **************************************************************/
  1404.             PushBlock()                 // Save block settings
  1405.             GotoBufferId(curr_id)       // Back to original file
  1406.             CopyBlock(_OVERWRITE_)      // And get the block back
  1407.             FillBlock(' ')              // Wipe it out
  1408.             GotoBufferid(id)            // Back to where we were
  1409.             PopBlock()                  // And get our block marked again
  1410.  
  1411.             /**************************************************************
  1412.               Prepare to wrap - we need to set the left/right margins to
  1413.               1 and the width of the column.  We also need to preserve the
  1414.               old settings.
  1415.              **************************************************************/
  1416.             save_leftmargin = Set(LeftMargin, 1)
  1417.             GotoBlockEnd()
  1418.             save_rightmargin = Set(RightMargin, CurrCol())
  1419.             save_autoindent = Set(AutoIndent, Off)
  1420.             save_wrapend = Set(ParaEndStyle, 0)
  1421.             BegFile()
  1422.             repeat
  1423.             until not WrapPara()
  1424.             UnmarkBlock()           // We need to re-mark the block
  1425.             BegFile()
  1426.             MarkColumn()
  1427.             EndFile()
  1428.             GotoColumn(Query(RightMargin))
  1429.  
  1430.             /*************************************************************
  1431.               And finally, go back to the original file, and copy the block
  1432.               in.
  1433.              *************************************************************/
  1434.             GotoBufferId(curr_id)
  1435.             CopyBlock(_OVERWRITE_)
  1436.             AbandonFile(id)
  1437.             GotoBlockEnd()
  1438.             Down()
  1439.             GotoColumn(block_beg_col)
  1440.  
  1441.             // Restore saved settings
  1442.  
  1443.             Set(LeftMargin, save_leftmargin)
  1444.             Set(RightMargin, save_rightmargin)
  1445.             Set(AutoIndent, save_autoindent)
  1446.             Set(ParaEndStyle, save_wrapend)
  1447.         endif
  1448.     endif
  1449. end mWrapPara
  1450.  
  1451. /*************************************************************************
  1452.   TSE called macros, including:
  1453.  
  1454.   WhenLoaded
  1455.   Main
  1456.   Hooked functions
  1457.  *************************************************************************/
  1458.  
  1459. /**************************************************************************
  1460.   This macro is called everytime EditFile() or Next/PrevFile() is called.
  1461.  **************************************************************************/
  1462. proc OnChangingFiles()
  1463.     string fn[65] = CurrFilename()
  1464.     integer mk, cid = GetBufferId()
  1465.  
  1466.     /* First, do 'RecentFiles' processing */
  1467.  
  1468.     if Query(BufferType) == _NORMAL_ and GotoBufferId(pick_buffer)
  1469.         mk = Set(KillMax, 0)
  1470.         if lFind(fn, "^$g")
  1471.             DelLine()
  1472.         elseif NumLines() > 20
  1473.             EndFile()
  1474.             DelLine()
  1475.         endif
  1476.         BegFile()
  1477.         InsertLine(fn)
  1478.         GotoBufferId(cid)
  1479.         Set(KillMax, mk)
  1480.     endif
  1481.  
  1482.     /* Ok, on with the rest of the show */
  1483.  
  1484.     language = FALSE
  1485.     cmode = FALSE
  1486.     case CurrExt()
  1487.         when ".s",".asm",".pas",".inc",".prg"
  1488.             language = TRUE
  1489.         when ".c",".h",".cpp",".hpp"
  1490.             language = TRUE
  1491.             cmode = TRUE
  1492.     endcase
  1493. end
  1494.  
  1495. /**************************************************************************
  1496.   This macro is called The firsttime a file is loaded into the editor.
  1497.  **************************************************************************/
  1498. proc OnFirstEdit()
  1499. end
  1500.  
  1501. /***************************************************************************
  1502.   This macro is called just after the editor starts, before the command line
  1503.   has been processed and any files are loaded.
  1504.  ***************************************************************************/
  1505. proc WhenLoaded()
  1506.     integer cid = GetBufferId()
  1507.  
  1508.     pick_buffer = CreateTempBuffer()
  1509.     GotoBufferId(cid)
  1510.     Hook(_ON_CHANGING_FILES_, OnChangingFiles)
  1511.     Hook(_ON_FIRST_EDIT_, OnFirstEdit)
  1512. end
  1513.  
  1514. /***************************************************************************
  1515.    This macro is called just after the first file is loaded, but before the
  1516.    user is given control, and before any hook functions are called.
  1517.  ***************************************************************************/
  1518. proc Main()
  1519. end
  1520.  
  1521. //  ╔═══════════╗
  1522. //  ║ The Menus ║
  1523. //  ╚═══════════╝
  1524.  
  1525. Menu File215()
  1526.   history
  1527.  
  1528.   "&Load..."                         ,   Editfile()
  1529.   "&Next"                            ,   Nextfile()
  1530.   "&Prev"                            ,   Prevfile()
  1531.   "&Read..."                         ,   InsertFile()
  1532.   "&Changename..."                   ,   ChangeCurrFilename()
  1533.   "lis&T Open  "                    ,   mListOpenFiles()
  1534.   "L&ist Recent  "                  ,   mListRecentFiles()
  1535.   "",                                ,   DIVIDE
  1536.   "&File"                            ,   SaveAndQuitFile()
  1537.   "&Save"                            ,   SaveFile()
  1538.   "&Quitfile"                        ,   mPQuit()
  1539.   "&Writeblock..."                   ,   SaveBlock()
  1540.   "&Globalfile"                      ,   SaveAllAndExit()
  1541.   "",                                ,   DIVIDE
  1542.   "&Os shell"                        ,   Shell()
  1543.  
  1544. end
  1545.  
  1546.  
  1547. Menu Window215()
  1548.   history
  1549.  
  1550.   "Split &Horizontal"                ,   HWindow()
  1551.   "Split &Vertical"                  ,   VWindow()
  1552.   "",                                ,   DIVIDE
  1553.   "&Close"                           ,   CloseWindow()
  1554.   "&One"                             ,   OneWindow()
  1555.   "&Zoom"                            ,   ZoomWindow()
  1556.   "&Resize..."                       ,   ResizeWindow()
  1557.   "",                                ,   DIVIDE
  1558.   "&Next"                            ,   NextWindow()
  1559.   "&Prev"                            ,   PrevWindow()
  1560.   "&Goto..."                         ,   GotoWindow()
  1561.  
  1562. end
  1563.  
  1564. Menu NamedClipBoardMenu()
  1565.     history
  1566.  
  1567.     "Cu&t..."           ,   mScratchBuffer(CUTTING)
  1568.     "C&ut Append..."    ,   mScratchBuffer(CUTAPPEND)
  1569.     "&Copy..."          ,   mScratchBuffer(STORING)
  1570.     "Cop&y Append..."   ,   mScratchBuffer(APPENDING)
  1571.     ""                  ,   ,                           Divide
  1572.     "&Paste..."         ,   mScratchBuffer(GETTING)
  1573.     "&Paste &Over..."   ,   mScratchBuffer(GETOVERLAY)
  1574. end
  1575.  
  1576. Menu ClipboardMenu()
  1577.     history
  1578.  
  1579.     "Cu&t"              ,   Cut()
  1580.     "C&ut Append"       ,   Cut(_APPEND_)
  1581.     "&Copy"             ,   Copy()
  1582.     "Cop&y Append"      ,   Copy(_APPEND_)
  1583.     ""                  ,                       , Divide
  1584.     "&Paste"            ,   Paste()
  1585.     "Paste &Over"       ,   Paste(_OVERWRITE_)
  1586.     ""                  ,                       , Divide
  1587.     "&Named ClipBoards  ", NamedClipBoardMenu(), DontClose
  1588. end
  1589.  
  1590. Menu Block215()
  1591.   history
  1592.  
  1593.   "mark &Line"                       ,   MarkLine()
  1594.   "mark c&Haracter"                  ,   MarkStream()
  1595.   "mark &Kolumn"                     ,   MarkColumn()
  1596.   "mark &Begin"                      ,   mMarkBlockBegin()
  1597.   "mark &End"                        ,   mMarkBlockEnd()
  1598.   "&Unmark"                          ,   UnmarkBlock()
  1599.   "",                                ,   DIVIDE
  1600.   "&Copy block"                      ,   CopyBlock()
  1601.   "&Move block"                      ,   MoveBlock()
  1602.   "Sh&ift..."                        ,   mShift()
  1603.   "&Delete"                          ,   DelBlock()
  1604.   "copy&Over"                        ,   CopyBlock(_OVERWRITE_)
  1605.   "&Fill..."                         ,   FillBlock()
  1606.   "",                                ,   DIVIDE
  1607.   "U&pper  "                        ,   mUpper()            , DontClose
  1608.   "Lowe&r  "                        ,   mLower()            , DontClose
  1609.   "Fl&ip   "                        ,   mFlip()             , DontClose
  1610.   "",                                ,   DIVIDE
  1611.   "&Sort"                            ,   Sort(sort_flags)
  1612.   "Sort O&rder"   [ShowSortFlag() : 10], ToggleSortFlag(1), DontClose
  1613.   "C&ase-Sensitive Sort" [OnOffStr((sort_flags & 2) == 0):3], ToggleSortFlag(2), DontClose
  1614. end
  1615.  
  1616. Menu Search215()
  1617.   history
  1618.  
  1619.   "&Find..."                         ,   Find()
  1620.   "&Replace..."                      ,   Replace()
  1621.   "&Again"                           ,   RepeatFind()
  1622.   "Find and &Do..."                  ,   mFindAndDo()
  1623.   "C&enter Finds" [OnOffStr(Query(CenterFinds)):3], Toggle(CenterFinds)
  1624.   "",                                ,   DIVIDE
  1625.   "Find &Word at Cursor"          ,   mFindWordAtCursor('+')
  1626.   "&Incremental Search..."        ,   mIncrementalSearch()
  1627.   "Compressed &View..."           ,   mCompressView(0)
  1628.   ""                              ,                       , Divide
  1629.   "F&unction List"                ,   mCompressView(1)
  1630.   "&Match"                        ,   mMatch()
  1631.   ""                              ,                       , Divide
  1632.   "&Place Bookmark..."            ,   placemark()
  1633.   "&Go to Bookmark..."            ,   gotomark()
  1634.   ""                              ,                       , Divide
  1635.   "Go to &Line..."                ,   GotoLine()
  1636.   "Go to &Column..."              ,   GotoColumn()
  1637. end
  1638.  
  1639. Menu PrintConfig()
  1640.     Title = 'Print Output Options'
  1641.     History
  1642.  
  1643.     "Line &Spacing"             [Query(PrintLineSpacing):5],
  1644.             Set(PrintLineSpacing,ReadNum(Query(PrintLineSpacing))),
  1645.             DontClose,
  1646.             "Type of spacing, 1=Single 2=Double 3=Triple etc..."
  1647.     ""      ,,
  1648.             Divide
  1649.     "&Header"                   [Query(PrintHeader):4],
  1650.             GetHeader(),
  1651.             DontClose,
  1652.             "Specifies what to print at top of each page"
  1653.     "&Footer"                   [Query(PrintFooter):4],
  1654.             GetFooter(),
  1655.             DontClose,
  1656.             "Specifies what to print at bottom of each page"
  1657.     "&Device"                   [Query(PrintDevice):15],
  1658.             GetPrintDevice(),
  1659.             DontClose,
  1660.             "Name of device to send print,  can be a filename"
  1661.     "&Init String"              [Query(PrintInit):10],
  1662.             GetInitString(),
  1663.             DontClose,
  1664.             "String to be sent to the printer before each print job"
  1665.     ""      ,,
  1666.             Divide
  1667.     "First P&age"               [Query(PrintFirstPage):5],
  1668.             Set(PrintFirstPage,ReadNum(Query(PrintFirstPage))),
  1669.             DontClose,
  1670.             "Page Number to start printing from"
  1671.     "Last Pa&ge"                [Query(PrintLastPage):5],
  1672.             Set(PrintLastPage,ReadNum(Query(PrintLastPage))),
  1673.             DontClose,
  1674.             "Page Number of last page to print"
  1675.     "Number of &Copies"         [Query(PrintCopies):5],
  1676.             Set(PrintCopies,ReadNum(Query(PrintCopies))),
  1677.             DontClose,
  1678.             "Number of copies to print"
  1679.     ""      ,,
  1680.             Divide
  1681.     "Print Line &Numbers"           [OnOffStr(Query(PrintLineNumbers)):3],
  1682.             Toggle(PrintLineNumbers),
  1683.             DontClose,
  1684.             "Line numbers will be printed at beginning of each line"
  1685.     "F&ormfeed After Printing"      [OnOffStr(Query(PrintAddFF)):3],
  1686.             Toggle(PrintAddFF),
  1687.             DontClose,
  1688.             "Sends a Form Feed to the printer after print job is complete"
  1689.     "Pa&use Between Pages"          [OnOffStr(Query(PrintPause)):3],
  1690.             Toggle(PrintPause),
  1691.             DontClose,
  1692.             "Pause between each printed page"
  1693. end PrintConfig
  1694.  
  1695.  
  1696. Menu Print215()
  1697.  
  1698.   history
  1699.   nokeys
  1700.   "print &All"                        ,   PrintFile()
  1701.   "print &Block"                      ,   PrintBlock()
  1702.   "send &Formfeed"                    ,   mSendFormFeed()
  1703.   "Send &Init String"                 ,   mSendInitString(),  DontClose
  1704.   "",                                ,   DIVIDE
  1705.  
  1706.   "set print &Left margin" [Query(PrintLeftMargin):5],
  1707.             Set(PrintLeftMargin,ReadNum(Query(PrintLeftMargin))),
  1708.             DontClose
  1709.  
  1710.   "set print &Right margin" [Query(PrintRightMargin):5],
  1711.             Set(PrintRightMargin,ReadNum(Query(PrintRightMargin))),
  1712.             DontClose
  1713.  
  1714.   "set print &Page length" [Query(PrintLinesPerPage):5],
  1715.             Set(PrintLinesPerPage,ReadNum(Query(PrintLinesPerPage))),
  1716.             DontClose
  1717.  
  1718.   "set print &Top margin" [Query(PrintTopMargin):5],
  1719.             Set(PrintTopMargin,ReadNum(Query(PrintTopMargin))),
  1720.             DontClose
  1721.  
  1722.   "set print b&Ottom margin" [Query(PrintBotMargin):5],
  1723.             Set(PrintBotMargin,ReadNum(Query(PrintBotMargin))),
  1724.             DontClose
  1725.   "",                                ,   DIVIDE
  1726.   "&Set Options  "       ,   PrintConfig(),      DontClose
  1727.  
  1728. end
  1729.  
  1730. Menu Macro215()
  1731.     history
  1732.     title = "Keyboard Macros"
  1733.  
  1734.     "&Macro record..."                  ,   RecordKeyMacro()
  1735.     "&Read macro..."                    ,   LoadKeyMacro()
  1736.     "&Write macro..."                   ,   SaveKeyMacro()
  1737.     "&Execute scrap"                    ,   ExecScrapMacro()
  1738.     "Pur&ge..."                         ,   PurgeKeyMacro()
  1739.     "Compiled Macros"                   ,                   ,   Divide
  1740.     "E&xecute..."                       ,   mMacMenu(1)
  1741.     "&Load..."                          ,   mMacMenu(2)
  1742.     "&Purge..."                         ,   mMacMenu(3)
  1743.     "&Compile"                          ,   mCompile()
  1744. end
  1745.  
  1746.  
  1747. Menu Editing215()
  1748.   history
  1749.  
  1750.   "&Addline"                         ,   Addline()
  1751.   "&Deleteline"                      ,   DelLine()
  1752.   "Swap &Lines"                      ,   mSwapLines()
  1753.   "delete to &End of line"           ,   DelToEol()
  1754.   "&Insertline"                      ,   InsertLine()
  1755.   "&Joinline"                        ,   JoinLine()
  1756.   "&Splitline"                       ,   SplitLine()
  1757.   "&Undelete"                        ,   UnDelete()
  1758.  
  1759. end
  1760.  
  1761. menu AutoIndentMenu()
  1762.     command = Set(AutoIndent, MenuOption() - 1)
  1763.     history = query(AutoIndent) + 1
  1764.  
  1765.     "O&ff"      ,, CloseBefore
  1766.     "O&n"       ,, CloseBefore
  1767.     "&Sticky"   ,, CloseBefore
  1768. end
  1769.  
  1770.  
  1771. Menu TabTypeMenu()
  1772.     history = query(tabtype) + 1
  1773.     command = Set(TabType,MenuOption()-1)
  1774.  
  1775.     "&Hard"     ,, CloseBefore
  1776.     "&Soft"     ,, CloseBefore
  1777.     "Smar&t"    ,, CloseBefore
  1778.     "&Variable" ,, CloseBefore
  1779. end
  1780.  
  1781. Menu VideoModeMenu()
  1782.     history = Query(CurrVideoMode)
  1783.     command = Set(CurrVideoMode,MenuOption())
  1784.  
  1785.     "&25-Line"
  1786.     "2&8-Line"
  1787.     "&43-Line"
  1788.     "&50-Line"
  1789. end
  1790.  
  1791. Menu Other215()
  1792.   history
  1793.  
  1794.     "&AutoIndent"           [MenuStr(AutoIndentMenu,query(AutoIndent)+1) : 6],
  1795.                             AutoIndentMenu()            ,   DontClose
  1796.     "&Insert"       [OnOffStr(query(Insert))   : 3]           ,   ToggleInsert(), DontClose
  1797.     "&WordWrap"             [OnOffStr(query(WordWrap))   : 3],
  1798.                             Toggle(WordWrap)            ,   DontClose
  1799.  
  1800.     "&Right Margin"         [query(RightMargin) : 5],
  1801.                             set(RightMargin, ReadNum(Query(RightMargin))),   DontClose
  1802.  
  1803.     "&Left Margin"          [query(LeftMargin) : 5],
  1804.                             set(LeftMargin, ReadNum(Query(LeftMargin))),   DontClose
  1805.     "Tab Ty&pe"             [MenuStr(TabTypeMenu,query(TabType)+1) : 8],
  1806.                             TabTypeMenu()               ,   DontClose
  1807.     "Tab Widt&h"            [query(TabWidth) : 5],
  1808.                             set(TabWidth, ReadNum(Query(TabWidth))),   DontClose
  1809.     ""                          ,                   ,   Divide
  1810.     "&Backups"              [OnOffStr(Query(MakeBackups)) : 3],
  1811.                             Toggle(MakeBackups)         ,   DontClose
  1812.     "&Enter matching"       [OnOffStr(matchmode) : 3],
  1813.                             ToggleEnterMatching()       ,   DontClose
  1814.     "ascii char&T"                      ,  mAsciiChart()
  1815.     "Li&ne Draw" [OnOffStr(Query(LineDraw)):3], Toggle(LineDraw), DontClose
  1816.     "Line T&ype  "         ,   LineTypeMenu()      ,   DontClose
  1817.     ""                          ,                   ,   Divide
  1818.     "&Date/Time Stamp"      ,   mDateTimeStamp()
  1819.     "Change &Video Mode  " ,   VideoModeMenu()     ,   DontClose
  1820.  
  1821.     ""                                  ,               ,   Divide
  1822.     "&Full Configuration  "            ,  ExecMacro("iconfig"),    DontClose
  1823.     "&Save Current Settings"            ,  mSaveSettings()
  1824. end
  1825.  
  1826. Menu Quit215()
  1827.  
  1828.   history
  1829.   "&Quit all files"                  ,   mGPQuit()
  1830.   "e&Xit all files"                  ,   Exit()
  1831. end
  1832.  
  1833. MenuBar MainMenu()
  1834.     history
  1835.  
  1836.     "&File"             ,    File215()
  1837.     "&Window"           ,    Window215()
  1838.     "&Block"            ,    Block215()
  1839.     "&Search"           ,    Search215()
  1840.     "&ClipBoard"        ,    ClipBoardMenu()
  1841.     "&Print"            ,    Print215()
  1842.     "&Macro"            ,    Macro215()
  1843.     "&Editing"          ,    editing215()
  1844.     "&Other"            ,    Other215()
  1845.     "&Quit"             ,    Quit215()
  1846. end
  1847.  
  1848. proc mMainMenu(integer key)
  1849.     PushKey(key)
  1850.     MainMenu()
  1851. end
  1852.  
  1853. // Key assignments from here on out...
  1854.  
  1855. <HelpLine>        "{F1}-Help {F2}-AddLn {F3}-Quit {F4}-DupLn {F5}-ScrollToTop {F6}-DelToEol {F7/F8}-MarkBegin{/}End"
  1856. <Alt HelpLine>    "{F1}-Line Type {F2}-InsLn {F3}-Match {F5/F6}-ScreenLeft{/}Right {F9}-DOS {F10}-ShowEntryScr"
  1857. <Ctrl HelpLine>   "{F1}-Toggle video mode"
  1858. <Shift HelpLine>  "{F1}-Toggle LineDraw {F3}-Sort {F5}-ScrollToCenter {F7/F8}-ShiftBlockLeft{/}Right"
  1859.  
  1860. <f1>                        ShowHelp(QuickHelp)
  1861. <f2>                        AddLine()
  1862. <f3>                        mGPQuit()
  1863. <f4>                        DupLine()
  1864. <f5>                        ScrollToRow(1)
  1865. <f6>                        DelToEol()
  1866. <f7>                        mMarkBlockBegin()
  1867. <f8>                        mMarkBlockEnd()
  1868. <f9>                        Shell()
  1869. <f10>                       MainMenu()
  1870.  
  1871. // enhanced keyboard only
  1872. <f11>
  1873. <f12>
  1874.  
  1875. <Shift f1>                  Toggle(LineDraw)
  1876. <Shift f2>
  1877. <Shift f3>                  Sort(sort_flags)
  1878. <Shift f4>                  mUpper()
  1879. <Shift f5>                  ScrollToRow(Query(ScreenRows)/2)
  1880. <Shift f6>
  1881. <Shift f7>                  mShiftBlock(SHIFTLEFT)      // macro 
  1882. <Shift f8>                  mShiftBlock(SHIFTRIGHT)     // macro 
  1883. <Shift f9>
  1884. <Shift f10>
  1885.  
  1886. // enhanced keyboard only
  1887. <Shift f11>
  1888. <Shift f12>
  1889.  
  1890. <Ctrl f1>                   mToggleEGA43()
  1891. <Ctrl f2>                   mSwapLines()
  1892. <Ctrl f3>
  1893. <Ctrl f4>
  1894. <Ctrl f5>
  1895. <Ctrl f6>
  1896. <Ctrl f7>                   mShift()
  1897. <Ctrl f8>
  1898. <Ctrl f9>
  1899. <Ctrl f10>
  1900.  
  1901. // enhanced keyboard only
  1902. <Ctrl f11>
  1903. <Ctrl f12>
  1904.  
  1905. <Alt f1>                    LineTypeMenu()
  1906. <Alt f2>                    InsertLine()
  1907. <Alt f3>                    mMatch()              // macro 
  1908. <Alt f4>                    mLower()
  1909. <Alt f5>                    RollLeft()
  1910. <Alt f6>                    RollRight()
  1911. <Alt f7>
  1912. <Alt f8>
  1913. <Alt f9>                    Dos()
  1914. <Alt f10>                   ShowEntryScreen()
  1915.  
  1916. // enhanced keyboard only
  1917. <Alt f11>
  1918. <Alt f12>
  1919.  
  1920. //
  1921. // special keys
  1922. //
  1923.  
  1924. <cursorup>                  Up()
  1925. <cursordown>                Down()
  1926. <cursorleft>                Left()
  1927. <cursorright>               Right()
  1928. <Ctrl cursorleft>           WordLeft()
  1929. <Ctrl cursorright>          WordRight()
  1930. <home>                      BegLine()
  1931. <end>                       EndLine()
  1932. <Ctrl home>                 BegWindow()
  1933. <Ctrl end>                  EndWindow()
  1934. <pgup>                      PageUp()
  1935. <pgdn>                      PageDown()
  1936. <Ctrl pgdn>                 EndFile()
  1937. <Ctrl pgup>                 BegFile()
  1938.  
  1939. <Shift tab>                 TabLeft()
  1940. <tab>                       TabRight()
  1941.  
  1942. <ins>                       Toggle(Insert)
  1943. <del>                       mDelChar()          // macro 
  1944.  
  1945. <backspace>                 mBackspace()        // macro 
  1946. <Ctrl backspace>            DelLeftWord()
  1947.  
  1948. <enter>                     mCReturn()
  1949. <Ctrl enter>                ExecScrapMacro()
  1950.  
  1951. <escape>                    MainMenu()          // macro 
  1952.  
  1953. <grey*>                     Paste()
  1954. <grey+>                     Copy()
  1955. <grey->                     Cut()
  1956. <Shift del>
  1957. <Shift ins>
  1958. <Shift ]>                   mCloseBrace()
  1959. <`>
  1960. <Shift `>
  1961. </>
  1962.  
  1963. <Ctrl prtsc>                Paste(_OVERWRITE_)
  1964. <Ctrl 2>
  1965. <Ctrl 6>
  1966. <Ctrl [>
  1967. <Ctrl \>
  1968. //
  1969. // Macro to edit the file whose name is sitting at the cursor in the editor
  1970. //
  1971. <Ctrl ]>                    mEditFileAtCursor()
  1972. <Ctrl ->                    mCopyCharAbove()
  1973.  
  1974. //
  1975. // alternate keys
  1976. //
  1977.  
  1978. <Alt a>                     MarkStream()
  1979. <Alt b>                     mWrapPara()
  1980. <Alt c>                     CopyBlock()
  1981. <Alt d>                     DelLine()
  1982. <Alt e>                     EditFile()
  1983. <Alt f>                     mMainMenu (<f>)
  1984. <Alt g>                     DelBlock()
  1985. <Alt h>                     ShowHelp(QuickHelp)
  1986. <Alt i>
  1987. <Alt j>                     JoinLine()
  1988. <Alt k>                     MarkColumn()
  1989. <Alt l>                     MarkLine()
  1990. <Alt m>                     MoveBlock()
  1991. <Alt n>                     NextFile()
  1992. <Alt o>                     ChangeCurrFilename()
  1993. <Alt p>                     mMainMenu(<p>)
  1994. <Alt q>                     mMainMenu(<q>)
  1995. <Alt r>                     InsertFile()
  1996. <Alt s>                     SplitLine()
  1997. <Alt t>
  1998. <Alt u>                     UnmarkBlock()
  1999. <Alt v>                     Toggle(ExpandTabs)
  2000. <Alt w>                     SaveBlock()
  2001. <Alt x>                     Exit()
  2002. <Alt y>
  2003. <Alt z>                     CopyBlock(_OVERWRITE_)
  2004. <Alt 1>                     Upper()
  2005. <Alt 2>                     Lower()
  2006. <Alt 3>                     Flip()
  2007. <Alt 4>
  2008. <Alt 5>
  2009. <Alt 6>
  2010. <Alt 7>
  2011. <Alt 8>
  2012. <Alt 9>
  2013. <Alt 0>                     mListOpenFiles()
  2014. <Alt ->
  2015. <Alt =>                     mFindWordAtCursor('+')      // macro
  2016.  
  2017. //
  2018. // control keys
  2019. //
  2020.  
  2021. <Ctrl 0>                    mListRecentFiles()
  2022. <Ctrl a>                    WordLeft()
  2023. <Ctrl b><a>                 mScratchBuffer(APPENDING)  // macro
  2024. <Ctrl b><l>                 mScratchBuffer(GETTING)    // macro
  2025. <Ctrl b><s>                 mScratchBuffer(STORING)    // macro
  2026. <Ctrl c>                    PageDown()
  2027. <Ctrl d>                    Right()
  2028. <Ctrl e>                    Up()
  2029. <Ctrl f>                    WordRight()
  2030. <Ctrl g>                    mDelChar()              // macro
  2031. <Ctrl h>                    mBackspace()            // macro
  2032. <Ctrl i>                    TabRight()
  2033. <Ctrl j>                    GotoLine()
  2034. <Ctrl k><b>                 mMarkBlockBegin()
  2035. <Ctrl k><c>                 CopyBlock()
  2036. <Ctrl k><d>                 QuitFile()
  2037. <Ctrl k><e>                 EditFile()
  2038. <Ctrl k><f>                 ChangeCurrFilename()
  2039. <Ctrl k><h>                 UnmarkBlock()
  2040. <Ctrl k><k>                 mMarkBlockEnd()
  2041. <Ctrl k><l>                 FillBlock()
  2042. <Ctrl k><n>                 NextFile()
  2043. <Ctrl k><p>                 PrevFile()
  2044. <Ctrl k><q>                 mPQuit()
  2045. <Ctrl k><r>                 InsertFile()
  2046. <Ctrl k><s>                 SaveFile()
  2047. <Ctrl k><t>                 MarkWord()
  2048. <Ctrl k><v>                 MoveBlock()
  2049. <Ctrl k><w>                 SaveBlock()
  2050. <Ctrl k><x>                 SaveAndQuitFile()
  2051. <Ctrl k><y>                 DelBlock()
  2052. <Ctrl k><z>                 KillFile()
  2053. <Ctrl l>                    RepeatFind()
  2054. <Ctrl m>                    RecordKeyMacro()
  2055. <Ctrl n>                    SplitLine()
  2056. <Ctrl o><c>                 CloseWindow()
  2057. <Ctrl o><g>                 ResizeWindow()
  2058. <Ctrl o><h>                 HWindow()
  2059. <Ctrl o><l>                 mSetPLMargin()
  2060. <Ctrl o><n>                 NextWindow()
  2061. <Ctrl o><o>                 OneWindow()
  2062. <Ctrl o><p>                 PrevWindow()
  2063. <Ctrl o><r>                 mSetRMargin()
  2064. <Ctrl o><s>                 ResizeWindow()
  2065. <Ctrl o><t>                 mCenterLine()
  2066. <Ctrl o><v>                 VWindow()
  2067. <Ctrl o><w>                 Toggle(WordWrap)
  2068. <Ctrl o><z>                 ZoomWindow()
  2069. <Ctrl p>                    Literal()
  2070. <Ctrl q><a>                 Replace()
  2071. <Ctrl q><b>                 GotoBlockBegin()
  2072. <Ctrl q><c>                 EndFile()
  2073. <Ctrl q><d>                 EndLine()
  2074. <Ctrl q><e>                 BegWindow()
  2075. <Ctrl q><f>                 Find()
  2076. <Ctrl q><i>                 AutoIndentMenu('AutoIndent')
  2077. <Ctrl q><k>                 GotoBlockEnd()
  2078. <Ctrl q><l>                 RestoreCursorline()
  2079. <Ctrl q><p>                 PrevPosition()
  2080. <Ctrl q><q>                 RepeatCmd()
  2081. <Ctrl q><r>                 BegFile()
  2082. <Ctrl q><s>                 BegLine()
  2083. <Ctrl q><t>                 TabTypeMenu('Tab Type')
  2084. <Ctrl q><x>                 EndWindow()
  2085. <Ctrl q><y>                 DelToEol()
  2086. <Ctrl r>                    PageUp()
  2087. <Ctrl s>                    Left()
  2088. <Ctrl t>                    DelRightWord()
  2089. <Ctrl u>                    UnDelete()
  2090. <Ctrl v>                    Toggle(Insert)
  2091. <Ctrl w>                    ScrollUp()
  2092. <Ctrl x>                    Down()
  2093. <Ctrl y>                    DelLine()
  2094. <Ctrl z>                    ScrollDown()
  2095.  
  2096. //
  2097. // other enhanced only keys
  2098. //
  2099. <Alt '>
  2100. <Alt ,>
  2101. <Alt .>
  2102. <Alt />
  2103. <Alt ;>
  2104. <Alt [>
  2105. <Alt \>
  2106. <Alt ]>
  2107. <Alt `>
  2108. <Alt backspace>
  2109. <Alt enter>
  2110. <Alt escape>
  2111. <Alt grey*>
  2112. <Alt grey+>
  2113. <Alt grey->
  2114. <Alt grey/>
  2115. <Alt greycursordown>
  2116. <Alt greycursorleft>
  2117. <Alt greycursorright>
  2118. <Alt greycursorup>
  2119. <Alt greydel>
  2120. <Alt greyend>
  2121. <Alt greyhome>
  2122. <Alt greyins>
  2123. <Alt greypgdn>
  2124. <Alt greypgup>
  2125. <Alt greyenter>
  2126. <Alt tab>
  2127.  
  2128. <greyenter>                 CReturn()
  2129. <Ctrl greyenter>            ExecScrapMacro()
  2130. <Ctrl centercursor>
  2131. <Ctrl cursordown>           RollDown()
  2132. <Ctrl cursorup>             RollUp()
  2133. <Ctrl del>
  2134.  
  2135. <Ctrl grey*>
  2136. <Ctrl grey+>                Copy(_APPEND_)
  2137. <Ctrl grey->                Cut(_APPEND_)
  2138. <Ctrl grey/>
  2139. <Ctrl ins>
  2140. <Ctrl tab>
  2141.  
  2142. <centercursor>
  2143.