syntax highlight on the fly?

9 views
Skip to first unread message

noman9607

unread,
Jun 29, 2008, 5:02:44 PM6/29/08
to SemWare
I would like to highlight words based on grep's etc that I do in my
programs. These word sets are not meant to last a long time. I just
discovered the 'Overlay settings from mapping text file' in the
\Options\configure systaxhitlite mapping sets menu. Can I use this
option setting in a macro that will run the overlay file when the file
is opened? I don't see a way to do this from the command line (future
feature Sam?) but I can generate the overlay file in my own program
and save it to a hard coded file name that a tse macro might run if
that will work.
The syntax files are binary so I do not want to tackle the problem
that way.
thanks,

knud van eeden

unread,
Jun 30, 2008, 4:40:02 PM6/30/08
to sem...@googlegroups.com
Can you show a very simple example?
With friendly greetings
Knud van Eeden

Kyle Waters

unread,
Jul 1, 2008, 4:32:22 AM7/1/08
to sem...@googlegroups.com

Thank-You,
Kyle


No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.3/1526 - Release Date: 6/30/2008
8:43 AM

noman9607

unread,
Jul 2, 2008, 1:25:04 PM7/2/08
to SemWare
Here is a current example. I have the novel "Don Quixote" loaded (from
project Gutenberg) to study and later write a paper. I use TSE like a
database because it is so fast. I search using [alt+v]for say 'barber'
and 'curate' then look at the results and from that I get a list of
words like:
Treasury
various
poems
books
author
barber
curate
Now I want the words in the list above 'syntax hilited' because
although I could have used TSE to go to the lines where the patterns
were found the results are too narrow; by looking at these words
hilited it is easy to tie ideas together paragraphs and pages from the
narrow focus of the one-line grep search. It takes too long to add
these 'keywords' to the 'language' in the normal programming sense. I
can generate a 'overlay' text file by editing or by using basic
program with the words I want to hilite in it. Using the full options
menu as I stated above you can overlay the settings using the file you
just created progrmmatically but now is the key idea: I want to run
the options setup including the new 'overlay settings from mapping
text fle...' when I start TSE from the command line. The following is
'made-up' command line. I think the solution will have to be a
automatically loaded macro.

g32.exe overlay-dq.txt DonQuixote.txt

It is handy to hilite words if you can do it quickly and easily
thanks for your help.
> thanks,- Hide quoted text -
>
> - Show quoted text -

knud van eeden

unread,
Jul 2, 2008, 1:27:53 PM7/2/08
to sem...@googlegroups.com

> I use TSE like a database because it is so fast.

Just shaking hands



knud van eeden

unread,
Jul 4, 2008, 11:38:55 AM7/4/08
to sem...@googlegroups.com
Some ideas:
In general, what I can think of is, as a first maybe possible approach:
1. Get all the unique words of your (e.g. Gutenberg) file (e.g. save this in file 'yourExample.ext')
(using e.g. something like a TSE macro or otherwise a combination of pipe and redirect
  split | unique | sort >yourKeywords.txt
)
2. Use this yourKeywords.txt file to generate a
    TSE syntax highlight file (e.g. yoursyntaxhighlight) for a particular extension (e.g. .ext)
You can maybe e.g. concatenate minimally the string
[keyWords1]
in front of your unique keyword file to get at least 1 different color,
then save the result
3. On that file you run that standard TSE macro
    syncfg2.mac
(it might have to be recompiled/redesigned to accept a .txt filename as a command line parameter)
4. you copy the resulting .syn (e.g. yourwords.syn) to the TSE synhi directory
5. Then you activate this syntax highlight file (e.g. if extension is .ext then highlight that file)
But usually you will have to quit and reload tse to activate it, as far as I know.
So you might have to start TSE using a batch file.
Something like a file mybatchfile.bat containing at least something like (loading TSE twice thus,
the first time to activate the new syntax highlight, the second time to show that new highlight.
g32.exe yourGutenberg.ext -eyourMacro.mac
g32.exe yourGutenberg.ext
exit
===
Troubleshooting:
-You get too many unique words, giving problems for syntax highlighting maximum size files
So you might have to make some (manual) decisions what to take and what to throw away.
Just some thoughts,
with friendly greetings,
Knud van Eeden
  

----- Original Message ----
From: noman9607 <pgb...@yahoo.com>
To: SemWare <sem...@googlegroups.com>

Sent: Wednesday, July 2, 2008 7:25:04 PM
Subject: [TSE] Re: syntax highlight on the fly?


Here is a current example. I have the novel "Don Quixote" loaded (from

project Gutenberg) to study and later write a paper. I use TSE like a

noman9607

unread,
Jul 6, 2008, 1:50:08 AM7/6/08
to SemWare
Hello:
I can get the keyword list ok
but I don't understand the syntax of the syncfg2 macro...
How do I 'run' the list file against it?
Somehow the tse editor uses the ascii.txt file that is made when you
choose
'write settings to mapping text file' in the options menu.

I can modify the [keywords#]sections easily using my own programs but
how do I run
syncfg2.mac against that file, presuming that one can?

If I could run sc32 to compile the macro before g32 eMyMac,
then g32 eMyMac might work.

Is there some way to duplicate the 'Overlay Settings from Mapping Text
File'
that is in the Options menu by command line using sc32? TSE has to be
compiling the
syn file at this time using the user interface config, I just need to
do it at
the command line.
That would do the trick.
> > - Show quoted text -- Hide quoted text -

Carlo Hogeveen

unread,
Jul 6, 2008, 11:03:49 AM7/6/08
to sem...@googlegroups.com

/*
This example macro toggles syntax-hiliting on-the-fly
for the "proc" word in TSE's own macro language,
for example for this macro source.

Points of interest:
- The .syn file needs to be loaded in binary mode 2.
See in TSE's Help the topic BinaryMode() for an explanation.
- Syncfg2 converts to an unsaved file in the CURRENT directory.
- The TSE compiler does not understand the documented LinkSynFile
parameter _ALWAYS_LOAD_: use -1 instead.
*/

string syntaxfile_name [255] = "f:\tse32\synhi\sal.syn"

proc Main()
integer original_id = GetBufferId()
integer syntaxfile_id = EditThisFile("-b-2 " + syntaxfile_name)
integer textfile_id = 0
ExecMacro("syncfg2")
if CurrExt() == ".txt" // Did syncfg2 succeed?
textfile_id = GetBufferId()
AbandonFile(syntaxfile_id)
// Toggle syntax hiliting for "proc".
if lFind("proc", "giw")
lReplace("proc", "noproc", "ginw")
else
lReplace("noproc", "proc", "ginw")
endif
ExecMacro("syncfg2")
if CurrExt() == ".syn" // Did syncfg2 succeed?
syntaxfile_id = GetBufferId()
AbandonFile(textfile_id)
// Saving .syn file using original dir instead of current dir!
SaveAs(syntaxfile_name, _OVERWRITE_)
GotoBufferId(original_id)
AbandonFile(syntaxfile_id)
// Relink the new syntax hiliting file ALWAYS (-1).
LinkSynFile(syntaxfile_name, -1)
UpdateDisplay(_ALL_WINDOWS_REFRESH_) // Just in case.
endif
endif
PurgeMacro(SplitPath(CurrMacroFilename(), _NAME_))
end

knud van eeden

unread,
Jul 6, 2008, 2:56:27 PM7/6/08
to sem...@googlegroups.com
Computer: Editor: TSE: Syntax: Highlight: How to possibly convert automatically a .txt file to .syn file?
http://www.knudvaneeden.com/tinyurl.php?urlKey=url000141



knud van eeden

unread,
Jul 6, 2008, 2:57:51 PM7/6/08
to sem...@googlegroups.com
Computer: Editor: TSE: Syntax: Highlight: How to possibly create syntax highlighting for your XML file?
http://www.knudvaneeden.com/tinyurl.php?urlKey=url000142



Reply all
Reply to author
Forward
0 new messages