Displaying search result in color

27 views
Skip to first unread message

Fred H Olson

unread,
Mar 9, 2026, 5:48:23 PM (3 days ago) Mar 9
to Semware
I'd like to write a macro to search for specially formatted strings (command
categories Two Dimension TSE command listing - see separate message) and
display multiple strings in Intense Bright White ON Red. The strings end in
":" which does not occur elsewhere in the file. The strings do not have embeded
spaces.

I have done very little with video commands or syntax hiliting which uses
video commands. I studied the "Video Output Commands" section of help and the
help for PutAttr(), GotoXY() and VgotoXY(). I have not found code that
implements syntax hiliting that does something like this to study. Where is it?

I have flailed around and have been able to get searchable strings displayed in
red. But so far I have only been able to hilite one at a time and I get
unintended scrolling. See attached 2d-cmds.s

Fred

--
Fred H. Olson Minneapolis,MN 55411 USA (near north Mpls)
Email: fholson at cohousing.org 612-588-9532
My Link Pg: http://fholson.cohousing.org ybb_
2d-cmds.s

Carlo Hogeveen

unread,
Mar 9, 2026, 6:28:19 PM (3 days ago) Mar 9
to sem...@googlegroups.com

Hi Fred,

The way I understand it you have a screen of strings, and want to recolor certain special strings for better visibility.
I have two possible solutions.

1.
If you want to do so from a running macro, then program a GetStrAttrXy(x, y, s, a) for all screen lines, search "s" for your strings-to-color, change the equivalent positions in "a" to the new color attribute, and PutStrAttrXY(x, y, s, a) to relocolor the line.
One macro that (buried amongst other logic) does this is the "hiliteall" macro.

2.
If you just want to do this when viewing one specific text file in the editor, then give the text file a unique file extension, like 2d-cmds.2d-cmds, and define syntax highlighting for .2d-cmds files, in which your special strings are defined in a keywords section that already has a suitable highlight color.
Highlighting colors for keyword sections are the same for all extensions, so you cannot just change them them for .2d-cmds files.

Hope this helps or sparks an idea,
Carlo



Message has been deleted

zhong zhao

unread,
Mar 9, 2026, 11:02:36 PM (2 days ago) Mar 9
to SemWare TSE Pro text editor
Attached showcv.s for reference.
showcv.s

Fred H Olson

unread,
Mar 10, 2026, 12:05:34 PM (2 days ago) Mar 10
to SemWare TSE Pro text editor
Thanks to Carlo, Knud and zhong zhao. You've given me lots to learn
from. I agree that studying existing code is a great way to learn.

Kund's 'add .s extension' comes close to what I want and sure was
simple. A few strings did not get colored right, e.g. strings that are
both commands and categories like PROCESS.

I changed my categories from ending with a ":" to starting with "`"
so searching my 2c-cmd.txt file with Carlo's showcv2 for "`.* "
with options "gxv" gave a display very close to what I want.
It lacks lines that have no category and of course is only in a
compressed view result but still demonstartes that it is very doable.

Is there a wildcard that would find just "BLOCKS:" in the string:
SetBit BLOCKS: CopyBlock ?
It was easier to change the syntax...

I read the long help entry "Syntaxhilite Mode" -- very helpful.

Fred

--
You can fool all the people some of the time and some of the people
all the time, but you cannot fool all the people all the time.

Abraham Lincoln

Trump has proved he can fool enough of the people (aided by circumstances)
to get elected US president. But what happens when his plans and boasts
go awry. For example, mass deportations and huge tariffs will do a number
on the economy. Fred 11/11/24

Carlo Hogeveen

unread,
Mar 10, 2026, 3:00:16 PM (2 days ago) Mar 10
to sem...@googlegroups.com

Fred wrote:
> Is there a wildcard that would find just "BLOCKS:" in the string:
> SetBit BLOCKS: CopyBlock ?

Given the context I assume you mean a search string with wildcards like:
Find("[A-Za-z_/()]#:", "givx")

Uh ..., oops!
I ran this search-string on your 2d-cmds.txt file using showcv2, and showcv2 gave lots of display errors.
showcv2 did test ok with a regular expression with variable length results, but this search breaks it.
I have some debugging to do.

Carlo



zhong zhao

unread,
Mar 10, 2026, 9:39:37 PM (2 days ago) Mar 10
to SemWare TSE Pro text editor
ScreenShot_2026-03-11_093231_287.png
ScreenShot_2026-03-11_093300_719.png
ScreenShot_2026-03-11_093738_166.png

Carlo Hogeveen

unread,
Mar 11, 2026, 5:06:59 AM (yesterday) Mar 11
to sem...@googlegroups.com

Hi Zhong Zhao,

I confess that I did not get your showcv macro to work,
and that I guessed its functionality by reading its name and its code.
Based on the 3 screenshots you just sent my guess was wrong.
From your screenshots my new guess is that showcv is more like the hiliteall macro.
In showcv2 I will change the description "a rewrite of showcv" to "inspired by showcv".
Thank you for inspiring me,

Carlo



Fred H Olson

unread,
Mar 11, 2026, 12:49:25 PM (19 hours ago) Mar 11
to sem...@googlegroups.com
On Tue, 10 Mar 2026, Carlo Hogeveen wrote:

> Fred wrote:
> > Is there a wildcard that would find just "BLOCKS:" in the string:
> > SetBit BLOCKS: CopyBlock ?
>
> Given the context I assume you mean a search string with wildcards like:
> Find("[A-Za-z_/()]#:", "givx")

This worked but I was surprized it did not need to only find a capital
letter (all desired hits start with a cap) so I tried:

Find("[A-Z_/()]#:", "givx")
It does what I wanted.

I wondered if min/max closure was involved; so I tried
Find("[A-Za-z_/()]*:", "givx")
(* instead of # in original) It does what I wanted.

I concluded that the key is that " " (space)
is NOT in the Class of characters in the [] bracketts.

Thanks Carlo.

Fred, who continues to be challenged by the regex subtleties.


--
Reply all
Reply to author
Forward
0 new messages