Today I wrote a little new tool: Electric scissors for text files.
It mimics a feature some other programs have:
You can collapse some lines of text to make the remaining part smaller and so easier to read.
At will you can of course expand those lines again.
In fact those lines are not hidden, but cut out and stored elsewhere... (Those cut-out lines are stored in a file PATHNAME.clx)
I'm using the keys Ctrl-Numpad- and Ctrl-Numpad+ for this macro.
Please note: This is a beta version!
It's not yet fully stress-tested!
So use at your own risk!
Example:
Imagine some code like this:
// Check version #, first time in.
//
if (#69==0) {
#100 = 610
if (Version_Num<#100) {
Reg_Push(0,1)
Reg_Set(1,"Field delimiting macro requires VEDIT version ")
#1 = #100/100
#2 = Remainder
ITOA(#1,1,LEFT+NOCR+APPEND)
Reg_Set(1,".",APPEND)
ITOA(#2,1,LEFT+NOCR+APPEND)
Reg_Set(1," or later.",APPEND)
Alert()
Dialog_Input_1(0,`"Error","|@(1)"`)
Reg_Pop(0,1)
if (Is_Quiet) {
XALL(1)
} else {
Break_Out(EXTRA)
}
}
}
Now highlighting the inner part of the big if() and collapsing it (via Ctrl-Numpad-)
gives:
//
// Check version #, first time in.
//
if (#69==0) {
#100 = 610
if (Version_Num<#100) {
// %<--00007-- -->%
}
}
(Imagine those %< as a pair of scissors)
A bit more readable, isn't it?
Now some commenting within the label improves it a bit more:
//
// Check version #, first time in.
//
if (#69==0) {
#100 = 610
if (Version_Num<#100) {
// %<--00007-- do something complicated -->%
}
}
Positioning the cursor in that line of scissors and pressing Ctrl-Numpad+
expand the lines again and all is as it was originally.
The macro can be downloaded here: http://www.ziemski.net/vedit/macros/collexp.vdm
Comments, suggestions etc. are welcome.
Christian
Edit: At 2005-11-15 I enhanced it a bit: Indention and (some) comment characters are automatically inserted before a label.
Additionally the macro shows a message box when initially called: It says that it made some key assignments.