StyledTextCtrl & highlights

I have to build an editor to use it to run queries on a database. In this regard StyledTextCtrl use. But I want to change a setting on the highlights. Currently
it works that when a word is typed completely the highlight is
activated only when a space is added at the end of the word.
I wish that the highlight is activated immediately after you type the last letter of the word.

You can do this.

···


Fabio Spadaro
www.fabiospadaro.com

I'm not aware of any settings that would change how that works.

···

On 2/12/10 10:40 AM, Fabio Spadaro wrote:

I have to build an editor to use it to run queries on a database. In
this regard StyledTextCtrl use. But I want to change a setting on the
highlights. Currently it works that when a word is typed completely the
highlight is activated only when a space is added at the end of the word.
I wish that the highlight is activated immediately after you type the
last letter of the word.
You can do this.

--
Robin Dunn
Software Craftsman

hi,

editortrigger.py (22.6 KB)

···

2010/2/14 Robin Dunn robin@alldunn.com

On 2/12/10 10:40 AM, Fabio Spadaro wrote:

I have to build an editor to use it to run queries on a database. In

this regard StyledTextCtrl use. But I want to change a setting on the

highlights. Currently it works that when a word is typed completely the

highlight is activated only when a space is added at the end of the word.

I wish that the highlight is activated immediately after you type the

last letter of the word.

You can do this.

I’m not aware of any settings that would change how that works.

Robin Dunn

Software Craftsman

http://wxPython.org

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

Get the attached code.

For example, you can try typing the word ‘ALTER’. You’ll see that the word will change color when you type a space after ALTER.

I wish instead of the color already changed since you can type the last character R.

Fabio Spadaro

www.fabiospadaro.com

Hi,

···

On Thu, Feb 18, 2010 at 4:18 PM, Fabio Spadaro <fabiolinospad@gmail.com> wrote:

Get the attached code.
For example, you can try typing the word 'ALTER'. You'll see that the word
will change color when you type a space after ALTER.
I wish instead of the color already changed since you can type the last
character R.

As Robin mentioned there is nothing you can do about it. This is an
implementation detail of the Scintilla lexer in question. Some lexers
apply the styles after each character others are word based parsers
which only apply the styles after completed words.

Cody

You could probably set a binding on EVT_STC_STYLENEEDED, and parse the
data and add styles however you want.

I guess ideally you want to create your own lexer, but I found very
little documentation to help me do that. I gave up and just do my
custom styling in the event handler. Works quite well, all things
considered.

···

On Thu, Feb 18, 2010 at 4:21 PM, Cody Precord <codyprecord@gmail.com> wrote:

Hi,

On Thu, Feb 18, 2010 at 4:18 PM, Fabio Spadaro <fabiolinospad@gmail.com> wrote:

Get the attached code.
For example, you can try typing the word 'ALTER'. You'll see that the word
will change color when you type a space after ALTER.
I wish instead of the color already changed since you can type the last
character R.

As Robin mentioned there is nothing you can do about it. This is an
implementation detail of the Scintilla lexer in question. Some lexers
apply the styles after each character others are word based parsers
which only apply the styles after completed words.

Hi,

Hi,

Get the attached code.

For example, you can try typing the word ‘ALTER’. You’ll see that the word

will change color when you type a space after ALTER.

I wish instead of the color already changed since you can type the last

character R.

As Robin mentioned there is nothing you can do about it. This is an

implementation detail of the Scintilla lexer in question. Some lexers

apply the styles after each character others are word based parsers

which only apply the styles after completed words.

You could probably set a binding on EVT_STC_STYLENEEDED, and parse the

data and add styles however you want.

I guess ideally you want to create your own lexer, but I found very

little documentation to help me do that. I gave up and just do my

custom styling in the event handler. Works quite well, all things

considered.

To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-users?hl=en

I tried to set a binding on EVT_STC_MODIFIED but no style’s character highlight:

def OnEvtStcMod(self,e):

start = self.GetEndStyled() # this is the first character that needs styling

end = e.GetPosition() # this is the last character that needs styling

self.StartStyling(start, 1) # in this example, only style the text style bits

print start,end

for pos in range(start, end): # in this example, simply loop over it…

self.SetStyling(1, 34) # …and set it all to the NUMBER style

What’s wrong ?
Attached new code

__editortrigger.py (22 KB)

···

2010/2/18 Bryan Oakley bryan.oakley@gmail.com

On Thu, Feb 18, 2010 at 4:21 PM, Cody Precord codyprecord@gmail.com wrote:

On Thu, Feb 18, 2010 at 4:18 PM, Fabio Spadaro fabiolinospad@gmail.com wrote:

Fabio Spadaro
www.fabiospadaro.com

Hi,

On Fri, Feb 19, 2010 at 7:51 AM, Fabio Spadaro

I tried to set a binding on EVT_STC_MODIFIED but no style's character
highlight:
...
def OnEvtStcMod(self,e):
start = self.GetEndStyled() # this is the first character that
needs styling
end = e.GetPosition() # this is the last character that
needs styling
self.StartStyling(start, 1) # in this example, only style the text
style bits
print start,end
for pos in range(start, end): # in this example, simply loop over
it..
self.SetStyling(1, 34) # ..and set it all to the NUMBER style

\.\.\.

What's wrong ?
Attached new code

Read the documentation for the STC and for Scintilla, you cannot
modify the buffer when inside of an EVT_STC_MODIFIED handler. That
includes modifying style information.

If you want to do your own styling then use STC_LEX_CONTAINER as the
buffers lexer and listen for EVT_STC_STYLENEEDED to do the styling.

Cody