Syntax highlighting theory implmentation



Hi, I need to write a simple app for our company (OpenSource and
non-commercial), it involes a text editor that needs a GtkText widget
that handles syntax highlighting.

Nothing fancy, just to highlight some words like `if' and `then'.

I know how to set gtk styles and colors and how to insert text with
different fonts and colors, also I can handle the "insert_text" event
that comes from the GtkEditable.

The one problem I'm stumbed at is how to go about doing all this.
The only way I can think of when the text changes is to record the cursor
position, and read all the text from the GtkEditable widget, then
reinsert with the proper coloring.

This basically a bunch of work per each character change and that would be
a hassle so I was thinking if there is a way to only `replace' text with a
different color on the GtkEditable?  In which case we only need to change
at most one line (+/- 80 characters from the position of last insert).


   Does anyone have a better idea though? I'm not looking to make an
insanly complex editor, just some simple word highlighting (changing of
color) on a GtkEditable and that's all.

Thanks in advance!

--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]