home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR8 / WSPLUS12.ZIP / WSPLUS.S < prev   
Text File  |  1993-07-28  |  71KB  |  2,175 lines

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