scintilla current column

Just starting out? Need help? Post your questions and find answers here.
cybergeek
User
User
Posts: 33
Joined: Sat Jul 03, 2010 11:11 am

scintilla current column

Post by cybergeek »

this retreives the line number of the current line

Code: Select all

ScintillaSendMessage(1,#SCI_LINEFROMPOSITION,ScintillaSendMessage(1,#SCI_GETCURRENTPOS,0,0),0)+1
but how to retreive column? [the pos of caret in the line]
PUREBASIC is AWSUM
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: scintilla current column

Post by srod »

Well, you have to be very careful with this because of the fact that, generally speaking, Scintilla does not really utilise character positions; it deals with byte-positions instead and this can be complicated by the use of, for example, the utf-8 codepage.

The #SCI_GETCOLUMN message does, however, deal with character positions, though of what use this might be when you are probably using a variable width font is unclear?

The #SCI_GETCURLINE message can be used to get the current caret position within the currently selected line, but it will return it as a byte position which, if using UTF-8, for example, will not always equate to a character position. You will need to add some additional code to convert this to a character position.

The following may or may not give you what you are after :

Code: Select all

ScintillaSendMessage(1, #SCI_GETCOLUMN, ScintillaSendMessage(1, #SCI_GETCURRENTPOS))
I may look like a mule, but I'm not a complete ass.
cybergeek
User
User
Posts: 33
Joined: Sat Jul 03, 2010 11:11 am

Re: scintilla current column

Post by cybergeek »

thx a lot........

you could add these to Goscintilla Library sometime?
PUREBASIC is AWSUM
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: scintilla current column

Post by srod »

Probably not because it would be of limited use in my opinion and it is very easy to send the messages directly as you are doing. I try to avoid just wrapping single message calls where possible.
I may look like a mule, but I'm not a complete ass.
Post Reply