Question

wxWidgets has wxStyledTextCtrl which (as I understand) uses Scintilla behind the scenes

I don't know much about Scintilla API, but I kinda have the idea that you issue commands to it.

In particular, I want to make the cursor have a block style, I found in Notepad++ the following snippet:

execute(SCI_SETCARETSTYLE, CARETSTYLE_BLOCK)

I want to do the same in the StyledTextCtrl, but I have no idea how to get to the scinitilla control behind the scene.

How do I do this?

P.S. I'm working in wxPython, but I suppose it doesn't make a difference.

Update:

After some digging in the c++ sources of wxWidgets, I found that most functions just call SendMsg, for instance:

// Get the time in milliseconds that the caret is on and off. 0 = steady on.
void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds)
{
    SendMsg(2076, periodMilliseconds, 0);
}

So I figured that this is how one would send commands to the underlying scintilla component.

So, I got the values I need

#define CARETSTYLE_INVISIBLE 0
#define CARETSTYLE_LINE 1
#define CARETSTYLE_BLOCK 2
#define SCI_SETCARETSTYLE 2512
#define SCI_GETCARETSTYLE 2513

So SCI_SETCARETSTYLE is 2512, and block style is 2.

So I called SengMsg with these parameters:

self.SendMsg(2512, 2)

But there didn't seem to be any effect!

What could be the reason? How can I debug this?

Was it helpful?

Solution

You don't write which version of wxPython / wxWidgets you are using, but I assume that it is the 2.8.x version. This contains Scintilla version 1.70, while the SVN trunk (soon to be released as wxWidgets version 2.9) has Scintilla version 1.75. A grep over the Scintilla header files reveals that SCI_GETCARETSTYLE and SCI_SETCARETSTYLE are only in the wxWidgets trunk, so those messages will not be handled at all in wxWidgets 2.8.

OTHER TIPS

Try

self.SendMsg(msg=2512, lp=2)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top