home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Der Mediaplex Sampler - Die 6 von Plex
/
6_v_plex.zip
/
6_v_plex
/
DISK5
/
DOS_34
/
AMAC44.ZIP
/
COM004.QM
< prev
next >
Wrap
Text File
|
1992-06-22
|
44KB
|
905 lines
* com004.qm
* Macros to Comment and Un-Comment
* By Tom Hogshead
* [ See COMTxx.QM For Use ]
* 6/22/92
*
* New Old
* @1 @1 Shifts Lines, Stars in Col 1 (QEdit v2.10 only)
* @2 @5 Shifts Lines, Stars in Col 1 (QEdit v2.15 only)
*
* @3 @2 Preserve Juxtaposition, Stars in Col 1
* @4 @3 Preserve Juxtaposition, Stars Two Spaces Left of First Character
*
* @5 @6 Preserve Indention, Stars at First Character of Each Line
* @6 @4 Preserve Indention, Stars at First Character of Block
*
* Description
* Commenting/Un-Commenting Functions, Examples
* Summary of Macro Key Functions
* Keys Summary Commenting
* Preference/Key Assignment
* Macros
*
* {e:\up\COMT*} Return To COMTxx.QM
*
*-- eoi
*
* (Description)
* --------------
* The following set of QEdit macros provide a means to easily comment
* and un-comment lines and blocks. Each line is commented by inserting
* an asterisk as the first character in a line, and un-commented by
* removing the asterisk. Each macro will both comment un-commented
* lines and un-comment commented lines. A line block may be marked
* before invoking, either open or closed, and all lines in the block
* will be processed without pausing. If a block is not marked before
* invoking, the macro opens a line block and pauses for the user to
* cursor to the end of the block and hit <enter>.
* What the macros do and what commented and un-commented lines look
* like can be seen below in section Commenting Functions. The centered
* comment lines, with the commenting '*' character in col 5, were made
* with @2 in Amac44.zip com001.qm.
*
* A Few Notes
* ------------
* a) A line, column or character block may be marked before
* invoking, either open or closed, and block will be processed
* without pausing.
* b) Blank lines are not commented (except @5), but macros are
* easily modifiable to do so, as shown in the macro.
* c) Macros, except @5, will not work correctly if in any
* 'out-dention' occurs after line 1 in the block.
* d) Macros may be modified to comment blank lines by replacing
* #32 with #42 (asterisk) and removing the findreplace lines
* (@1/2/3/4).
* e) Commenting star must be separated from firstnonwhite character
* at least one space when un-commenting.
* f) Ascii #173 (eob marker) must not exist in file for @3 or @4.
* g) Commented lines w/text in col's 1-2 before commenting must
* not have user inserted invisible Ascii #255 character(s) in
* line, otherwise lines will not be returned to their original
* position when un-commenting with @3 or @4.
* h) Lines commented with @3 and @4 having text in col's 1-2
* before commenting must not have appended invisible Ascii #255
* character(s) at eol removed, otherwise lines will not be
* returned to their original position when un-commenting with
* @3 or @4.
* (Commenting)/Un-Commenting Functions, Examples
* -----------------------------------------------
* The functions of these macros can be seen in the following examples:
*
* A) With boxes removed and 'As Is' column in col 4, commenting
* the first three lines:
* <------- Preserve ------->
* Shift <-- Juxtaposition --> Indention
* ┌─ As Is ┐ ┌ @1/@2 ┐ ┌── @3 ──┐ ┌── @4───┐ ┌ @5/@6 ┐
* aaa │ * aaa│ * aaa │ ∙ * aaa │ ∙ * aaa│
* aaa │ * aaa│ * aaa │ ∙ * aaa │ ∙ * aaa│
* aaa │ * aaa│ * aaa │ ∙ * aaa │ ∙ * aaa│
* aaa │ ∙ aaa │ ∙ aaa │ ∙ aaa │ ∙ aaa │
* aaa │ ∙ aaa │ ∙ aaa │ ∙ aaa │ ∙ aaa │
* aaa │ ∙ aaa │ ∙ aaa │ ∙ aaa │ ∙ aaa │
* 123456789┘ 123456789┘ 123456789┘ 123456789┘ 123456789┘
* <- Star in Col 1 ->
*
* B) Commenting a line of text in col's 1, 2, 3, 4, 5 gives:
* ┌── c1 ──┐ ┌── c2───┐ ┌── c3 ──┐ ┌── c4 ──┐ ┌── c5 ──┐
* aaa ∙ ∙aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │ As Is
* aaa ∙ ∙aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │ |
* aaa ∙ ∙aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │ |
* * aaa ∙ * aaa ∙ * aaa ∙ * aaa ∙ * aaa│ @1/@2 Comt
* * aaa ∙ * aaa ∙ * aaa ∙ * aaa ∙ * aaa │ @3 |
* * aaa ∙ * aaa ∙ * aaa ∙ ∙* aaa ∙ ∙ * aaa │ @4 |
* * aaa ∙ ∙* aaa ∙ ∙ * aaa ∙ ∙ * aaa ∙ ∙ * aaa│ @5/@6 |
* aaa ∙ ∙aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │ @1/@2 Un-Comt
* aaa ∙ ∙aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │ @3 |
* aaa ∙ ∙aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │ @4 |
* aaa ∙ ∙aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │ @5/@6 |
* [123456789┘ 123456789┘ 123456789┘ 123456789┘ 123456789┘
*
* C) Lines 2 and 3 of each set, positioned in col 1 w/o boxes,
* is commented. Then line 3 is un-commented:
* <------- Preserve -------->
* Shift <- Juxtaposition -> Indention
* ┌ As Is ┐ ┌ @1/@2 ┐ ┌─ @3 ──┐ ┌─ @4 ──┐ ┌ @5/@6 ┐
* aaa │ aaa ∙ aaa ∙ aaa ∙ aaa │
* aaa │ * aaa ∙ * aaa ∙ * aaa ∙ * aaa │
* aaa │ aaa ∙ aaa ∙ aaa ∙ aaa │
* │ ∙ ∙ ∙ ∙ ∙ ∙ ∙ │
* aaa │ ∙aaa ∙ ∙aaa ∙ ∙aaa ∙ ∙aaa │
* aaa │ * aaa ∙ * aaa ∙ * aaa ∙ ∙* aaa │
* aaa │ ∙aaa ∙ ∙aaa ∙ ∙aaa ∙ ∙aaa │
* │ ∙ ∙ ∙ ∙ ∙ ∙ ∙ │
* aaa │ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │
* aaa │ * aaa ∙ * aaa ∙ * aaa ∙ ∙ * aaa │
* aaa │ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │
* │ ∙ ∙ ∙ ∙ ∙ ∙ ∙ │
* aaa │ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │
* aaa │ * aaa∙ * aaa ∙ ∙* aaa ∙ ∙ * aaa│
* aaa │ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa ∙ ∙ aaa │
* 12345678┘ 12345678┘ 12345678┘ 12345678┘ 12345678┘
* <- Star in Col 1 ->
*
* D) Marking lines 3-10 of the following @5 and @6 gives:
* ┌── As Is ──┐ ┌──── @5 ────┐ ┌──── @6 ────┐
* aaa │ ∙ aaa │ * aaa │
* aaa │ ∙ aaa │ * aaa │
* aaa │ ∙ * aaa │ * aaa │
* aaa │ ∙ * aaa │ * aaa │
* │ ∙ * │ │
* aaa │ ∙ * aaa│ * aaa │
* aaa │ ∙ * aaa│ * aaa │
* │ ∙ * │ │
* aaa │ * aaa │ aa │
* aaa │ * aaa │ aa │
* 1234567890123┘ 1234567890123┘ 1234567890123┘
* ^
* Error, no out-dention except @5
* To test, un-comment with @3 or @4
* ----------------------------------
* aaa
* aaa
* aaa
* aaa
* aaa
* aaa
* aaa
* aaa
* ----1234567890123
*
* My (preference) #1 #2 #3 #4
* Key ^Dn @Dn @Up ^Lft
* ┌── @3 ──┐ ┌── @4───┐ ┌── @2 ──┐ ┌── @6 ──┐
* * aaa │ ∙ * aaa │ * aaa│ ∙ * aaa│
* * aaa │ ∙ * aaa │ * aaa│ ∙ * aaa│
* * aaa │ ∙ * aaa │ * aaa│ ∙ * aaa│
* aaa │ ∙ aaa │ ∙ aaa │ ∙ aaa │
* aaa │ ∙ aaa │ ∙ aaa │ ∙ aaa │
* aaa │ ∙ aaa │ ∙ aaa │ ∙ aaa │
* └────────┘ └────────┘ └────────┘ └────────┘
*
* ┌──────────────────────────────────────┐
* │ (Summary) of Macro Key Functions │
* └───────────────── ( ) ────────────────┘ Alt Key
* COMMENTING Inserts star space col 1··1··2··3··4········
* Preserve juxtaposition········3··4········
* Preserve indention··············5··6··
* Comment Blank Lines 5
* Inserts star space at firstnonwhite each line··············5·· ··
* Inserts star space at firstnonwhite in block·················6··
* Inserts star 2 char's left of firstnonwhite···········4········
* Shifts only col 1-2 text lines to col 3-4········3··4········
* Shifts all lines in block two columns right··1··2········5··6··
*
* UN-COMMENTING Preserve juxtaposition········3··4·· ·····
* Preserve indention··············5··6··
* Will un-comment stars only in col 1··1·················
* Returns all text to original position··1··2··3··4··5··6··
* Will un-comment stars as in any first char·····2··3··4··5··6··
* Returns col 1-2 text to original position········3··4·· ·····
*
* Requires QEdit v2.10··1·················
* Requires QEdit v2.15·····2··3··4··5··6··
* Fits on one line of Qconfig.dat··1··2········5··6··
*
* ┌────────────────────────────────────┐
* │ (Keys) Summary Commenting │
* └────────────────────────────────────┘
* Shifts all lines in block 2 columns right ─┐
* Shifts only col 1-2 text lines to col 3-4 ─┐ │
* Inserts star 2 char's left of firstnonwhite ─┐ │ │
* Comment Blank Lines ─┐ │ │ │
* Inserts star space at firstnonwhite ┐ │ │ │ │
* Preserve indention ─┐ │ │ │ │ │
* Preserve juxtaposition ─┐ │ │ │ │ │ │
* Inserts star space col 1 ─┐ │ │ │ │ │ │ │ Bytes
* -----
* @1·····1····················1·· 71
* @2·····2····················2·· 72
* @3·····3··3···········3··3·····175
* @4·····4··4··············4·····177
* @5···········5··5··5········5·· 70
* @6···········6··6···········6·· 72
* (Macros)
*
* M A C R O S
* -------------------------------------------------------------------
* @(1) Comment or Un-Comment Line or Block,
* Insert 'Star'Space in Col 1,
* Shifts All Lines Right Two Spaces Commenting,
* Shift Lines to Original Position Un-Commenting
* Will Fit Qconfig.dat with 'Label' changed to 'L' in Qmac (See below)
* (Tom Hogshead and John Goodman authors)
* -------------------------------------------------------------------
* See Examples A, B and C above.
@1 MacroBegin
CursorRight * Needed for single line blocks
GotoBlockBeg JTrue A * Test if block closed
MarkLine * Set line block marker
GotoBlockBeg JTrue OK * Test again if block closed
Pause * Nothing marked, let user mark it
Jump B * Jump to finish block
A: * Here if both ends originally marked
GotoBlockEnd UnmarkBlock * Remove block completely
MarkLine PrevPosition
B:
MarkLine * Convert start block to line block
GotoBlockBeg * Make sure we're at the beginning
OK: * Now have completed line block
* setscreenoff * Un-comment for QEdit v2.15
* --------------- Check If Block Already Commented --------------*
BegLine CursorRight * Position cursor for find
Find "*" Return * Test if line is already commented
"LB" Return *(assumes all block commented or not)
Jfalse COMMENT * If no star in col 1, must comment
* ---------------------- Un-Comment Block -----------------------*
UNCOMMENT: *ELSE
ShiftLeft ShiftLeft * Col 1 has star, uncomment block
Jump END * End macro
* ------------------------ Comment Block ------------------------*
COMMENT:
ShiftRight ShiftRight * Shift all lines right twice
BegLine * Move cursor to col 1
GotoBlockEnd * Move to 1st char of last line
MarkColumn * Mark 1st char, column block
PrevPosition * Return to block begin col 2
begline * Needed for single-line case
markcolumn * Close column block to go to at end
FillBlock * Fill block
#32 Return * with space #32 (Change #32 to any
* Ascii char to comment blank lines)
FindReplace * Replace
#32 Return * space
"*" Return * with "*"
"LN" Return * Local, No Prompt Replace
END:
GoToBlockEnd UnmarkBlock * Unmark block
begline CursorDown * Go to line after block col 1
*
* 46 bytes Sun 03-31-1991 01:51:24 (TH/JG @8)
* 58 bytes Tue 04-30-1991 19:06:16 (TH/JG @3 not comment blank lines)
* 66 bytes Mon 05-27-1991 18:55:32 (TH sent to JG as @7)
* 65 bytes Tue 07-09-1991 14:49:01 (TH ^cursordown, line blocks only)
* 78 bytes Tue 07-09-1991 15:09:58 (TH ^cursordown, col/char blocks OK,)
* 74 bytes Tue 07-09-1991 23:15:04 (TH ^cursordown, shortened/sent to JG)
* 74 bytes Thu 07-11-1991 23:09:20 (TH ^CursorDown, moved begline up)
* 71 bytes Tue 07-23-1991 20:49:09 (JG @1, Replaced all above OK: label)
* 71 bytes Tue 07-23-1991 20:49:09 (JG/TH ^cursordown, shortened)
* (In Amac43.zip)
* 71 bytes Tue 06-09-1992 16:29:39 (TH @1, to ALL #3/863, 6/13/92)
* QConfig Version To Fit
* -----------------------
* Changing "Label" to "L", the following QMAC compiled version will fit
* on one line of QConfig.dat:
* @1 macrobegin cursorright gotoblockbeg jtrue L0 markline gotoblockbeg
* jtrue L1 pause jump L2 L0: gotoblockend unmarkblock markline
* prevposition L2: markline gotoblockbeg L1: begline cursorright
* find "*" return "LB" return jfalse L3 shiftleft shiftleft jump L4
* L3: shiftright shiftright begline gotoblockend markcolumn
* prevposition begline markcolumn fillblock #32 return findreplace
* #32 return "*" return "LN" return L4: gotoblockend unmarkblock
* begline cursordown
* 71 bytes Tue 07-23-1991 20:49:09 (JG/TH @1)
* Single line (464 chars)
* ------------------------
* @1 macrobegin cursorright gotoblockbeg jtrue L0 markline gotoblockbeg jtrue L1 pause jump L2 L0: gotoblockend unmarkblock markline prevposition L2: markline gotoblockbeg L1: begline cursorright find "*" return "lb" return jfalse L3 shiftleft shiftleft jump L4 L3: shiftright shiftright begline gotoblockend markcolumn prevposition begline markcolumn fillblock #32 return findreplace #32 return "*" return "ln" return L4: gotoblockend unmarkblock begline cursordown
*
* 71 bytes Tue 07-23-1991 20:49:09 (JG/TH @1)
*
* -------------------------------------------------------------------
* @(2) Comment or Un-Comment Line or Block, (More versatile Version of @1)
* Insert 'Star'Space in Col 1,
* Shifts All Lines Right Two Spaces Commenting,
* Shift All Lines to Original Position Un-Commenting,
* Will Fit Qconfig.dat with 'Label' changed to 'L' in Qmac (See below)
* >> Will Un-Comment All Stars as First Character,
* >> Requires QEdit v2.15
* -------------------------------------------------------------------
* See Examples A, B and C above.
@2 macrobegin
setsoundoff
gotoblockend jtrue OK markline
gotoblockend jtrue OK
pause * Select block if not closed
markline * And close it
OK:
setscreenoff
addline * Add line for single line blocks
markline * Extend block to include blank line
gotoblockbeg
* ------------------- Test If Block Commented -------------------*
firstnonwhite cursorright * Pos 1 spc rt of first char in line
find "*" return * Test if line is commented
"LB" return *(assumes all block commented or not)
jfalse COMMENT * If no star as first char, comment
* ---------------------- Un-Comment Block -----------------------*
UNCOMMENT: *ELSE we must un-comment
firstnonwhite
delch delch * Delete star space
cursordown * Move down 1 line to test if at eob
iscursorinblock * Test if past eob
jtrue UNCOMMENT * If so, cont until out of block
jump END *ELSE end macro
* ------------------------ Comment Block ------------------------*
COMMENT:
shiftright shiftright * Shift all lines right twice
begline * Move cursor to col 1
gotoblockend * Move to 1st char of last line
markcolumn * Mark 1st char, column block
prevposition * Return to block begin col 2
markcolumn * Close column block to go to at end
fillblock * Fill single column block
#32 Return * with space #32 (Change #32 to any
* Ascii char to comment blank lines)
findreplace * Replace
#32 return * space
"*" return * with "*"
"LN" return * Local, No Prompt Replace
END:
gotoblockend unmarkblock
delline begline * Delete extra blank line
*
* 72 bytes Sun 06-21-1992 17:57:50 (TH @2)
* QConfig Version To Fit
* -----------------------
* Changing "Label" to "L", the following QMAC compiled version will fit
* on one line of QConfig.dat:
* @2 macrobegin setsoundoff gotoblockend jtrue L1 markline gotoblockend
* jtrue L1 pause markline L1: setscreenoff addline markline
* gotoblockbeg firstnonwhite cursorright find "*" return "lb" return
* jfalse L2 L3: firstnonwhite delch delch cursordown iscursorinblock
* jtrue L3 jump L4 L2: shiftright shiftright begline gotoblockend
* markcolumn begline markcolumn fillblock #32 return findreplace #32
* return "*" return "ln" return L4: gotoblockend unmarkblock delline
* begline
* 72 bytes Sun 06-21-1992 17:57:50
* Single line (472 chars)
* ------------------------
* @2 macrobegin setsoundoff gotoblockend jtrue L1 markline gotoblockend jtrue L1 pause markline L1: setscreenoff addline markline gotoblockbeg firstnonwhite cursorright find "*" return "lb" return jfalse L2 L3: firstnonwhite delch delch cursordown iscursorinblock jtrue L3 jump L4 L2: shiftright shiftright begline gotoblockend markcolumn prevposition markcolumn fillblock #32 return findreplace #32 return "*" return "ln" return L4: gotoblockend unmarkblock delline begline
*
* 72 bytes Sun 06-21-1992 17:57:50
*
* -------------------------------------------------------------------
* @(3) Comment or Un-Comment Line or Block,
* Preserve Text Juxtaposition (Except text in col's 1-2),
* >> Insert 'Star Space' in Col 1,
* Shifts Lines w/Text in Col's 1-2 to Col 3-4 When Commenting,
* Shifts Previous Col 1-2 Lines Back Where They Were Un-Commenting,
* Does Not Shift Other Lines when Un-Commenting,
* Will Un-Comment All Stars as First Character,
* This Macro Will Not Fit One Line of Qconfig.dat,
* Requires QEdit v2.15
* -------------------------------------------------------------------
* Since this macro will not fit on one line of qconfig.dat, a NewKey
* macro can be used to call and execute this macro so it is available
* at all times without having to manually load.
* See Examples A, B and C above.
@3 MacroBegin
savesettings setinsmode setsoundoff *:
setwordwrapmode togglewordwrap
gotoblockend jtrue OK markline
gotoblockend jtrue OK
pause * Select block if not closed
markline * And close it
OK:
setscreenoff
addline begline cursorright * Add line for eob marker
#173 * Insert eob marker empty line *col 2
markline * Extend block to include blank line
* ------------------- Test If Block Commented -------------------*
gotoblockbeg
firstnonwhite cursorright * Pos 1 spc rt of first char line 1
find "*" return * Test if line 1 is commented
"LB" return *(assumes all block commented or not)*:
jfalse COMMENT * If no star as first char, comment
* ========================== Un-Comment =========================*
UNCOMMENT: *ELSE we must un-comment
firstnonwhite
delch #32 * Delete star/shift line rt 1 spc *:
cursordown cursordown * Move down 2 lines to test if at eob*:
iscursorinblock * Test if past eob *:
jfalse SHIFTBACK * If not, shift back to col 1-2 *:
cursorup * Still in block, move up 1 line *:
jump UNCOMMENT * Continue 'til block un-commented *:
* Shift Lines w/Text in Col 3 *
* ----------------- to Col 1/2 If There To Start ----------------*
SHIFTBACK:
gotoblockbeg begline * Pos for col 1-2 shiftback *:
unmarkblock markline
find * Test/move to #255 in line
#255 return
'L' return
jfalse WAS_COL3 * If no #255's, line was not shifted
* from col 1 or 2
unmarkblock
markcolumn * Mark first #255 in line
endline cursorleft
cut * Cut all #255's at eol to scrap
begline pasteover * Paste at bol
deleteblock * Returns line to original
* un-commented juxtaposition
WAS_COL3:
cursordown endline * Pos eol to test if past eob marker *:
find
#173 return
delline return
jfalse END * End macro if past eob marker
prevposition * If not, return to line we were in
jump SHIFTBACK * Continue to test/shiftback 'til done
* =========================== Comment ===========================*
COMMENT:
findreplace * Remove
#255 return * all stray #255's
delline return
'GLN' return * from block before commenting
* --------- Shift Lines With Text in Col 1-2 to Col 3-4 ---------*
firstnonwhite * Re-position on firstnonwhite
PUSH_COL3:
isemptyline *:21
jtrue COL2 * Bypass empty lines *:21
isbegline * Test if first char in col 1
jfalse COL1
#32 #32 * If so, shift col 1 line 2 spcs rt
endline
#255 #255 * Insert 2 eol markers, was col 1
jump COL2
COL1:
cursorleft
isbegline * Test if first char in col 2
jfalse COL2
#32 * If so, shift col 2 line 1 spc rt
endline
#255 * Insert 1 eol marker, was col 2
COL2:
cursordown * Move to next line
cursordown
iscursorinblock * Test if we're past block
jfalse SHIFTED * If we are, it's time to insert stars
cursorup * Move back to next line to comment
firstnonwhite * Return to first char of next line
jump PUSH_COL3 * Push 'till all out of col's 1-2
SHIFTED:
* ----------------- Insert Stars For Commenting -----------------*
gotoblockbeg
*-- @3
begline *:
*-- @4
* firstnonwhite
* cursorleft cursorleft * Pos 2 spcs left of firstnonwhite
*--
gotoblockend markcolumn
prevposition markcolumn * Finish blk spsc lft of firstnonwhite
fillblock * Fill single column block
#32 Return * with space #32 (Change #32 to any
* Ascii char to comment blank lines)
findreplace * Replace
#32 return * space
"*" return * with "*"
"LN" return * Local, No Prompt Replace
END:
gotoblockend unmarkblock
delline begline * Delete extra blank line
restoresettings *:
*
* 69 bytes Tue 06-09-1992 22:01:02 (TH @3, to ALL #3/864, 6/13/92)
* 116 bytes Fri 06-19-1992 13:51:31 (TH @3, improved col 1-2 routine)
* 165 bytes Sat 06-20-1992 01:19:59 (TH @3, un-comment stars any col)
* 166 bytes Sat 06-20-1992 13:33:38 (TH @3, corrected un-comment)
* 166 bytes Sat 06-20-1992 16:48:07 (TH @3, changed cursorright to endline)
* 167 bytes Sat 06-20-1992 17:05:36 (TH @3, added begline)
* 169 bytes Sat 06-20-1992 17:23:32 (TH @3, changed 'LN' to 'GLN')
* 171 bytes Sat 06-20-1992 17:29:00 (TH @3, added restoresettings)
* 175 bytes Sun 06-21-1992 16:37:56 (TH @3, bypass empty lines)
*
* -------------------------------------------------------------------
* @(4) Comment or Un-Comment Line or Block,
* Preserve Text Juxtaposition (Except text in col's 1-2),
* >> Insert 'Star' Left of FirstNonWhite Two Spaces Commenting,
* Shifts Lines w/Text in Col's 1-2 to Col 3-4 When Commenting,
* Shifts Previous Col 1-2 Lines Back Where They Were Un-Commenting,
* Does Not Shift Other Lines when Un-Commenting,
* Will Un-Comment All Stars as First Character,
* This Macro Will Not Fit One Line of Qconfig.dat,
* Requires QEdit v2.15
* -------------------------------------------------------------------
* Since this macro will not fit on one line of qconfig.dat, a NewKey
* macro can be used to call and execute this macro so it is available
* at all times without having to manually load.
* See Examples A, B and C above.
@4 macrobegin
savesettings setinsmode setsoundoff *:
setwordwrapmode togglewordwrap
gotoblockend jtrue OK markline
gotoblockend jtrue OK
pause * Select block if not closed
markline * And close it
OK:
setscreenoff
addline begline cursorright * Add line for eob marker
#173 * Insert eob marker empty line *col 2
markline * Extend block to include blank line
* ------------------- Test If Block Commented -------------------*
gotoblockbeg
firstnonwhite cursorright * Pos 1 spc rt of first char line 1
find "*" return * Test if line 1 is commented
"LB" return *(assumes all block commented or not)*:
jfalse COMMENT * If no star as first char, comment
* ========================== Un-Comment =========================*
UNCOMMENT: *ELSE we must un-comment
firstnonwhite
delch #32 * Delete star/shift line rt 1 spc *:
cursordown cursordown * Move down 2 lines to test if at eob*:
iscursorinblock * Test if past eob *:
jfalse SHIFTBACK * If not, shift back to col 1-2 *:
cursorup * Still in block, move up 1 line *:
jump UNCOMMENT * Continue 'til block un-commented *:
* Shift Lines w/Text in Col 3 *
* ----------------- to Col 1/2 If There To Start ----------------*
SHIFTBACK:
gotoblockbeg begline * Pos for col 1-2 shiftback *:
unmarkblock markline
find * Test/move to #255 in line
#255 return
'L' return
jfalse WAS_COL3 * If no #255's, line was not shifted
* from col 1 or 2
unmarkblock
markcolumn * Mark first #255 in line
endline cursorleft
cut * Cut all #255's at eol to scrap
begline pasteover * Paste at bol
deleteblock * Returns line to original
* un-commented juxtaposition
WAS_COL3:
cursordown endline * Pos eol to test if past eob marker *:
find
#173 return
delline return
jfalse END * End macro if past eob marker
prevposition * If not, return to line we were in
jump SHIFTBACK * Continue to test/shiftback 'til done
* =========================== Comment ===========================*
COMMENT:
findreplace * Remove
#255 return * all stray #255's
delline return
'GLN' return * from block before commenting
* --------- Shift Lines With Text in Col 1-2 to Col 3-4 ---------*
firstnonwhite * Re-position on firstnonwhite
PUSH_COL3:
isemptyline *:
jtrue COL2 * Bypass empty lines *:
isbegline * Test if first char in col 1
jfalse COL1
#32 #32 * If so, shift col 1 line 2 spcs rt
endline
#255 #255 * Insert 2 eol markers, was col 1
jump COL2
COL1:
cursorleft
isbegline * Test if first char in col 2
jfalse COL2
#32 * If so, shift col 2 line 1 spc rt
endline
#255 * Insert 1 eol marker, was col 2
COL2:
cursordown * Move to next line
cursordown
iscursorinblock * Test if we're past block
jfalse SHIFTED * If we are, it's time to insert stars
cursorup * Move back to next line to comment
firstnonwhite * Return to first char of next line
jump PUSH_COL3 * Push 'till all out of col's 1-2
SHIFTED:
* ----------------- Insert Stars For Commenting -----------------*
gotoblockbeg
*-- @3
* begline
*-- @4
firstnonwhite *:
cursorleft cursorleft * Pos 2 spcs left of firstnonwhite *:
*--
gotoblockend markcolumn
prevposition markcolumn * Finish blk spsc lft of firstnonwhite
fillblock * Fill single column block
#32 Return * with space #32 (Change #32 to any
* Ascii char to comment blank lines)
findreplace * Replace
#32 return * space
"*" return * with "*"
"LN" return * Local, No Prompt Replace
END:
gotoblockend unmarkblock
delline begline * Delete extra blank line
restoresettings *:
*
* 116 bytes Sat 06-13-1992 12:30:41 (TH @5, to ALL #3/865, 6/13/92)
* 173 bytes Sat 06-20-1992 17:30:10 (TH @5, changed routines)
* 177 bytes Sun 06-21-1992 16:37:07 (TH @5, bypass empty lines)
*
* -------------------------------------------------------------------
* @(5) Comment or Un-Comment Line or Block,
* Preserves Indention,
* >> Insert 'Star Space' at FirstNonWhite of Each Line Commenting,
* Shifts All Lines Right Two Spaces Commenting,
* Shift All Lines to Original Position Un-Commenting,
* Will Un-Comment All Stars as First Character,
* Will Fit Qconfig.dat with 'Label' changed to 'L' in Qmac (See below)
* Requires QEdit v2.15,
* >> Comments Blank Lines
* -------------------------------------------------------------------
* Macro @5 differs from @6 in that @5 inserts a 'star space' at the
* position of the firstnonwhite character of *each* un-commented line
* in the block, thus maintaining indention of each group of indented
* lines. Although this macro comments blank lines as written, it can
* be modified to not comment blank lines as shown in the macro.
* See Example D above.
@5 macrobegin
setsoundoff setinsmode
gotoblockend jtrue OK markline
gotoblockend jtrue OK
pause * Select block if not closed
markline * And close it
OK:
setscreenoff
addline * Add line for single line blocks
markline * Extend block to include blank line
gotoblockbeg
* ------------------- Test If Block Commented -------------------*
firstnonwhite cursorright * Pos 1 spc rt of first char in line
find "*" return * Test if line is commented
"LB" return *(assumes all block commented or not)
jfalse COMMENT * If no star as first char, comment
* ----------------------- Un-Comment Block ----------------------*
UNCOMMENT: *ELSE we must un-comment
firstnonwhite
delch delch * Delete star space
cursordown * Move down 1 line to test if at eob
iscursorinblock * Test if past eob
jtrue UNCOMMENT * If so, cont until out of block
jump END *ELSE end macro
* ------------------------ Comment Block ------------------------*
COMMENT:
shiftright * Shift block right one space
IS_IN_BLOCK:
firstnonwhite
cursorleft
* --------------------- Comment Blank Lines ---------------------*
* BLANK:
* '*' * Insert star
* cursordown * Move down 1 line to test if at eob
* iscursorinblock * Test if past eob
* jfalse END
* isemptyline
* jfalse IS_IN_BLOCK * Move on if not blank
* cursorup
* firstnonwhite
* cursordown * Pos cursor underneath top char
* jump BLANK
* ---------------------- Bypass Blank Line ----------------------*
'*' * Insert star
BLANK:
cursordown * Move down 1 line to test if at eob
isemptyline
jtrue BLANK * Bypass blank lines
iscursorinblock * Test if past eob
jtrue IS_IN_BLOCK * If so, cont until out of block
* ---------------------------------------------------------------*
END:
gotoblockend unmarkblock
begline delline * Delete extra blank line
*
* 64 bytes Mon 06-22-1992 15:54:36 (TH @5, bypass blank lines)
* 70 bytes Mon 06-22-1992 15:47:09 (TH @5, comment blank lines)
* QConfig Version To Fit
* -----------------------
* Changing "Label" to "L", the following QMAC compiled version will fit
* on one line of QConfig.dat (502 chars):
* @5 macrobegin setsoundoff setinsmode gotoblockend jtrue L1 markline
* gotoblockend jtrue L1 pause markline L1: setscreenoff addline
* markline gotoblockbeg firstnonwhite cursorright find "*" return
* "lb" return jfalse L2 L3: firstnonwhite delch delch cursordown
* iscursorinblock jtrue L3 jump L4 L2: setscreenon shiftright L6:
* firstnonwhite cursorleft L7: "*" cursordown iscursorinblock jfalse
* L5 isemptyline jfalse L6 cursorup firstnonwhite cursordown jump L7
* L4 L5: gotoblockend unmarkblock delline begline
* 70 bytes Mon 06-22-1992 15:47:09 (TH @5, comment blank lines)
*
* -------------------------------------------------------------------
* @(6) Comment or Un-Comment Line or Block,
* Preserves Indention,
* >> Insert 'Star Space' at FirstNonWhite Commenting,
* Shifts All Lines Right Two Spaces Commenting,
* Shift All Lines to Original Position Un-Commenting,
* Will Un-Comment All Stars as First Character,
* Will Fit Qconfig.dat with 'Label' changed to 'L' in Qmac (See below)
* Requires QEdit v2.15
* -------------------------------------------------------------------
* This macro is useful for preserving indention levels and improving
* readability of commented text, as suggested by Angus Scott-Fleming in
* SemWare Conference 3 Message #865, 06-16-92.
* Example (w/o col 1 stars)
* --------------------------
* DO WHILE .T.
* IF condition THEN
* DO CASE
* CASE item = 1
* * do some thing
* CASE item = 2 << Mark these two lines
* * do some thing else <<
* OTHERWISE
* * punt
* ENDCASE
* ELSE
* * frown
* ENDIF
* ENDDO
* Commenting out CASE item = 2 looks like this:
* DO WHILE .T.
* IF condition THEN
* DO CASE
* CASE item = 1
* * do some thing
* * CASE item = 2 << Note: indention Preserveed
* * * do some thing else <<
* OTHERWISE
* * punt
* ENDCASE
* ELSE
* * frown
* ENDIF
* ENDDO
* Also see Example D above.
@6 macrobegin
setsoundoff
gotoblockend jtrue OK markline
gotoblockend jtrue OK
pause * Select block if not closed
markline * And close it
OK:
setscreenoff
addline * Add line for single line blocks
markline * Extend block to include blank line
gotoblockbeg
* ------------------- Test If Block Commented -------------------*
firstnonwhite cursorright * Pos 1 spc rt of first char in line
find "*" return * Test if line is commented
"LB" return *(assumes all block commented or not)
jfalse COMMENT * If no star as first char, comment
* ----------------------- Un-Comment Block ----------------------*
UNCOMMENT: *ELSE we must un-comment
firstnonwhite
delch delch * Delete star space
cursordown * Move down 1 line to test if at eob
iscursorinblock * Test if past eob
jtrue UNCOMMENT * If so, cont until out of block
jump END *ELSE end macro
* ------------------------ Comment Block ------------------------*
COMMENT:
shiftright shiftright * Make room for the stars
cursorleft * Re-position to insert stars
gotoblockend
markcolumn
prevposition
markcolumn
fillblock * Fill single column block
#32 Return * with space #32 (Change #32 to any
* Ascii char to comment blank lines)
findreplace * Replace
#32 return * space
"*" return * with "*"
"LN" return * Local, No Prompt Replace
END:
gotoblockend unmarkblock
delline begline * Delete extra blank line
*
* 105 bytes Tue 06-16-1992 12:39:14 (TH @6, to AS-F #3/868-869 as @4)
* 71 bytes Tue 06-16-1992 17:25:36 (TH @6, shortened w/dummy blank line)
* 72 bytes Sun 06-21-1992 11:54:30 (TH @6, un-comment stars any first char)
* QConfig Version To Fit
* -----------------------
* Changing "Label" to "L", the following QMAC compiled version will fit
* on one line of QConfig.dat:
* @6 macrobegin setsoundoff gotoblockend jtrue L1 markline gotoblockend
* jtrue L1 pause markline L1: setscreenoff addline markline
* gotoblockbeg firstnonwhite cursorright find "*" return "lb" return
* jfalse L2 L3: firstnonwhite delch delch cursordown iscursorinblock
* jtrue L3 jump L4 L2: shiftright shiftright cursorleft gotoblockend
* markcolumn prevposition markcolumn fillblock #32 return
* findreplace #32 return "*" return "ln" return L4: gotoblockend
* unmarkblock delline begline
* 72 bytes Sun 06-21-1992 11:54:30
* Single line (475 chars)
* ------------------------
* @6 macrobegin setsoundoff gotoblockend jtrue L1 markline gotoblockend jtrue L1 pause markline L1: setscreenoff addline markline gotoblockbeg firstnonwhite cursorright find "*" return "lb" return jfalse L2 L3: firstnonwhite delch delch cursordown iscursorinblock jtrue L3 jump L4 L2: shiftright shiftright cursorleft gotoblockend markcolumn prevposition markcolumn fillblock #32 return findreplace #32 return "*" return "ln" return L4: gotoblockend unmarkblock delline begline
*
* 72 bytes Sun 06-21-1992 11:54:30