herbert breunung wrote:
sorry if this is dup, but i find it very hard to count selected char
while selection is rectangular,
or is there a scintilla method for this here that i overseen?
I am the guy which did the change to count the chars in selection in
SciTE and display the result in the status bar, if set up this way.
Since I also improved rectangular selection in Scintilla, I feel a bit
targeted by this message :-)
Well, in SciTE, the display of the number of selected lines is OK, but
the char count is obviously wrong, probably based on the number of chars
between start and end of selection, including parts not in the
rectangular selection.
Since this doesn't seems so a compelling feature, I doubt we need to add
this to Scintilla, as it can be computed the hard way...
Something like:
int startPosition = SendEditor(SCI_GETSELECTIONSTART);
int endPosition = SendEditor(SCI_GETSELECTIONEND);
int startLine = SendEditor(SCI_LINEFROMPOSITION, startPosition);
int endLine = SendEditor(SCI_LINEFROMPOSITION, endPosition);
selType = SendEditor(SCI_GETSELECTIONMODE);
if (selType == SC_SEL_RECTANGLE) {
int charCount = 0;
for (int line = startLine; line <= endLine; line++)
int startPos = SendEditor(SCI_GETLINESELSTARTPOSITION, line);
int endPos = SendEditor(SCI_GETLINESELENDPOSITION, line);
charCount += endPos - startPos;
}
}
thank in advance and still curious abou what happend with my last post
to this list, it was an announcement
to version 0.3 of my scintilla based editor. proton-ce.sf.net.
I received this message on 20051106.
Oh, Neil, as I wrote the above code, I thought I could update as well
the status bar code, and so I could test this code.
In SciTEBase.cxx, SciTEBase::SetTextProperties, I changed the following
lines:
CharacterRange crange = GetSelection();
sprintf(temp, "%ld", crange.cpMax - crange.cpMin);
ps.Set("SelLength", temp);
int selFirstLine = SendEditor(SCI_LINEFROMPOSITION, crange.cpMin);
int selLastLine = SendEditor(SCI_LINEFROMPOSITION, crange.cpMax);
to:
CharacterRange crange = GetSelection();
int selFirstLine = SendEditor(SCI_LINEFROMPOSITION, crange.cpMin);
int selLastLine = SendEditor(SCI_LINEFROMPOSITION, crange.cpMax);
if (SendEditor(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) {
long charCount = 0;
for (int line = selFirstLine; line <= selLastLine; line++) {
int startPos = SendEditor(SCI_GETLINESELSTARTPOSITION, line);
int endPos = SendEditor(SCI_GETLINESELENDPOSITION, line);
charCount += endPos - startPos;
}
sprintf(temp, "%ld", charCount);
} else {
sprintf(temp, "%ld", crange.cpMax - crange.cpMin);
}
ps.Set("SelLength", temp);
and it seems to work...
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest