Is "block highlighting" possible?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Sheila Carlisle

Is "block highlighting" possible?

Post by Sheila Carlisle »

Is it possible to make a macro that would "block highlight" increasing levels of nested code expanding outward from the current cursor location? I know about Ctl-m and Ctl-shift-m, but that requires that you start at the beginning or ending of the bracketed content.

For example, if I have a nested series of bracketed code like this:

<@macro_name> {
<#def> total_chap @eval(<#total_chap> + 1)
<|print> { Starting side = <#S_S>}
@if(@match(<#tpl_spec>, {specialist})) {
<#def> _tfile {<#tmplt>\ specialist.mif}
}}

I would like to be able to place my cursor before "_chap" and hit "Ctl-g" (or whatever) to have the "<#total_chap>" highlighted. A second Ctl-g would expand the highlight to "(<#total_chap> + 1)". A third Ctl-g would expand it to the entire macro within the curly braces.

The sequence of nested pairs isn't always the same, so I can't always rely on any particular order.

Thanks for any suggestions.

Sheila
Bob Hansen

RE: Is "block highlighting" possible?

Post by Bob Hansen »

Hope this works for you, it solved a similar problem for me.
The general overviw of steps would be similar to the following:

1. Move the cursot to the beginning of the desired block.
2. SH-CTRL-F2 to clear all bookmarks.
3. Search, Find (F5), enter the character for end of desired block, Mark All to create bookmarks.
4. CTRL-G to GoTo Next Bookmark, and check off Extend Selection. Block is now highlighted.
5. Do as you want with highlighted area, such as cut/copy, etc.
6. SH-CTRL-F2 to clear all bookmarks again.

As I understand your needs, you may have to have couple of these to run in a particular sequence checking for different end of block characters.

If this doesn't work, perhaps it will trigger someone else with a better method.

I use another macro program MacroScheduler (www.mjtnet.com) to interface with TextPad which will allow me to create certain "If-Then" types of decisions which might apply here. Use if-then to determine the value to be used as the ending bookmark.
=====================================
Sample of MacroScheduler macro follows, uses IF to continue a TextPad macro (FormatEmail) if a certain file size is over 100 bytes.

//DONE Saving file. Repeat Macros until done.
Label>RepeatSavingEmail
Wait>2
Press CTRL
SendCharacter/Text>S
Release CTRL
WaitReady>1
FileSize>d:\reports\text\allrprts02.asc,MyFileSize
WaitReady>1
If>MyFileSize>100,FormatEmail

Label>CloseTextPad
========================================
Good luck.
Bob Hansen
Sheila Carlisle

RE: Is "block highlighting" possible?

Post by Sheila Carlisle »

Thanks, Bob -- that's close, but I'm hoping for a single-keystroke solution. You probably understand this already, but the main goal is to have a quick visual check to see where the brackets around the "cursored" content start/end, and that doesn't require me to go to the beginning/end in order to start the keystroke.

This is the general "theory":

1. cursor is placed at any location
2. "Ctl-g"
-- searches to the left for the first occurence of the open char. of
any of the user-defined pairs
(in my case, I would define { }, < >, ( ) and [ ] as the pairs)
-- searches to the right for the first occurrence of the close char. of
the found pair
-- highlights all the text between the pair
3. Next Ctl-g (or maybe needing a different keystroke?)
-- searches to the left of the highlighted text for the first occurrence of the
open char. of another code pair
-- searches to the right of the highlighted text for the first occurrence of the
close char. of this pair.
-- highlights all the text between the pair

and so on.

Even if it wasn't possible to do the second-level "expansion" in step 3, it would still be useful to be able to see the first-level bracketing around the cursor location.

Actually, this is very similar to what double-clicking does, in selecting text that is bounded by spaces and/or specific characters like /?,." etc. It would be cool to be able to do it with Shift-Click or some other click-key combo.

Sheila
mike

RE: Is "block highlighting" possible?

Post by mike »

have you tried ctrl-m?

I just tried it, and, from your first example, If I put the cursor before _chap, press CTRL-m, then shift-ctrl-m, it highlights everything inside the brackets.

If I press shift-ctrl-m again, it selects the brackets, too...

It doesn't keep exxpanding after that, tho'

but you can mess around with ctrl-left-arrow/right-arrow to get to the next word, then do ctrl-m, ctrl-shift-m again...I'm getting unpredictable results...

but it's 2AM...
Sheila Carlisle

RE: Is "block highlighting" possible?

Post by Sheila Carlisle »

Thanks, Mike -- yes, you're right, the combination of ctl-m and then shift-ctl-m does highlight the block. I hadn't noticed that.

But still I want a single click to do it, or a right-mouse-click, rather than 5 presses ....
Post Reply