Creating a text editor with custom syntax highlighting.

Hey there.
I am trying to write a basic code editor for my emulator project. I want it to colorize modified assembly language.
I know about StyledTextCtrl.SetStyling() and stuff, but how do I actually implement the highlighting? Parsing the whole code when I add just one character doesn’t seem like a good idea to me.

Hi,

Hey there.
I am trying to write a basic code editor for my emulator project. I want it to colorize modified assembly language.
I know about StyledTextCtrl.SetStyling() and stuff, but how do I actually implement the highlighting? Parsing the whole code when I add just one character doesn't seem like a good idea to me.

Never done anything like this, but if you check out the wxPython demo StyledTextCtrl_2, which does Python highlighting you might get some ideas.

Maybe just changing this:
self.SetLexer(stc.STC_LEX_PYTHON)

to
self.SetLexer(stc.STC_LEX_ASM)

might be enough - but really just a guess.

You might also want to do some googling on Scintilla which I believe STC is build on.

Werner

···

On 10/8/2014 14:58, GamerCat wrote:

Unfortunely, it doesn’t work as I want it to. I am writing editor for a custom assembly, which should have custom highlighting for different parts (like matching Vx [x is register number]).

···

On Wednesday, October 8, 2014 3:35:40 PM UTC+2, werner wrote:

Hi,

On 10/8/2014 14:58, GamerCat wrote:

Hey there.

I am trying to write a basic code editor for my emulator project. I
want it to colorize modified assembly language.

I know about StyledTextCtrl.SetStyling() and stuff, but how do I
actually implement the highlighting? Parsing the whole code when I add
just one character doesn’t seem like a good idea to me.

Never done anything like this, but if you check out the wxPython demo
StyledTextCtrl_2, which does Python highlighting you might get some ideas.

Maybe just changing this:

self.SetLexer(stc.STC_LEX_PYTHON)

to

self.SetLexer(stc.STC_LEX_ASM)

might be enough - but really just a guess.

You might also want to do some googling on Scintilla which I believe STC
is build on.

http://www.scintilla.org/

Werner

GamerCat wrote:

I am trying to write a basic code editor for my emulator project. I
want it to colorize modified assembly language.
I know about StyledTextCtrl.SetStyling() and stuff, but how do I
actually implement the highlighting? Parsing the whole code when I add
just one character doesn't seem like a good idea to me.

I think you HAVE to do that. Adding a single quote mark could change
the meaning of many lines of code.

And, after all, how long does it really take to reparse an assembly file?

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.