🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #6149

Syntax Highlighting

#6149
From: Michel Corbin
Date: Mon, 06 Jun 2005 13:42
33 lines
2296 bytes
Hi,
I'm planning to add syntax-highlighting to an editor I've already
written. I've read Robert Dunn's article entitled "Faster rich edit
syntax highlighting" which saves me a lot of effort and trouble.

All the keywords I'd like to display in a specific color begin with
a backslash, so it's quite easy to search the text for the backslashes
using EM_FINDTEXTEX. The problem is how to find quite quickly the end
of those keywords :
each keyword ends just before the first non-letter character following
the backslash, for instance, if we meet :
  ...  \begin{quote} ...
the keyword is "\begin" because the curly brace is the first non-letter
character after the "\"
(I can't store all the keywords in an array, because they are too many
and each user can add new keywords)

My question is :
What is the fastest method to read a few characters after finding a 
backslash,
that is when we just know the backslah zero-based position given by 
EM_FINDTEXTEX ?

Of course I could use EM_LINEFROMCHAR and EM_LINEINDEX to get the line 
and column numbers and then use
RichEdit->Lines->Strings[lineNumber]...
but I don't think that would be very fast.
Perhaps I could use EM_GETSELTEXT to store let's say the 20 or 30 next
characters in a buffer ...
Any idea  would be welcome.
(for those who want to know I use that program to edit TeX and LaTeX code)

Michel.
Technical Details
Message-ID: <42a452d4@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e549c567e259b6cf,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Mon, 06 Jun 2005 15:42:33 +0200
From: "Michel Corbin" <"Michel Corbin">
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr-FR; rv:1.0.2) Gecko/20030208 Netscape/7.02
X-Accept-Language: fr-fr, fr, en, en-us, es, it, p
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Syntax Highlighting
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 80.125.117.27
Message-ID: <42a452d4@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1118065364 80.125.117.27 (6 Jun 2005 06:42:44 -0700)
Lines: 34
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail