SCI_SELECTIONISRECTANGLE and Selection::IsRectangular() discrepancy

26 views
Skip to first unread message

Teodor Petrov

unread,
Jan 15, 2018, 3:40:14 AM1/15/18
to scintilla...@googlegroups.com
Hello,

Is there an explanation why these two return different results?
The first checks if the mode is rectangular and the second checks if it
is rectangular or thin.

Best regards,
Teodor

Neil Hodgson

unread,
Jan 16, 2018, 2:17:36 AM1/16/18
to Scintilla mailing list
Teodor Petrov:

> Is there an explanation why these two return different results?

SCI_SELECTIONISRECTANGLE was a very early addition and Selection::IsRectangular appeared much later with more complex selection features including the thin-rectangular state.

I think I may have been concerned that clients which were written to perform actions on rectangular selections could be confused if they saw a true return from SCI_SELECTIONISRECTANGLE for something that doesn’t behave exactly like a rectangular selection. New or updated applications could use SCI_GETSELECTIONMODE for more accurate information including the SC_SEL_THIN state.

Changing SCI_SELECTIONISRECTANGLE may be reasonable but its probably better to encourage use of SCI_GETSELECTIONMODE.

Neil


Teodor Petrov

unread,
Jan 17, 2018, 5:24:55 AM1/17/18
to scintilla...@googlegroups.com
Makes sense, but I guess this could be better documented. It should
mention that complex
apps using rect/thin selections are better of using
SCI_GETSELECTIONMODE. And they
should check for both modes (rect and thin).

Also it is not very clear what different selection modes do. What is the
difference between
them and when to use them and so on.

Another strangeness in the api is the behaviour of SCI_SETSELECTIONMODE.
It is
clearly documented that when switching modes it will enter a move-extend
mode, but
reading the docs for the first time I thought this doesn't relate to me.
Because I didn't
understand what extend means. Then after I spent some time (30-60
minutes) debugging
why the code which drops from rect to stream selection is causing cursor
movements to
change the selection I understood its meaning. The ugly part is that to
do what I want I
have to send the command twice.

I'm not sure why the api is designed this way, but I guess it is very
surprising the first time
one uses it. It would have been better if this mode is enabled by
passing some kind of a
flag parameter.

Just sharing my experience, if it matters.

/Teodor

Neil Hodgson

unread,
Jan 18, 2018, 4:20:31 AM1/18/18
to Scintilla mailing list
Teodor Petrov:

> Makes sense, but I guess this could be better documented.

Its difficult to get contributors to write comprehensive documentation - or any at all sometimes.

> Another strangeness in the api is the behaviour of SCI_SETSELECTIONMODE. It is
> clearly documented that when switching modes it will enter a move-extend mode, but
> reading the docs for the first time I thought this doesn't relate to me. …
> I'm not sure why the api is designed this way, but I guess it is very surprising the first time
> one uses it. It would have been better if this mode is enabled by passing some kind of a
> flag parameter.

The feature addition that added SCI_SETSELECTIONMODE was all about extending selections through the keyboard. The contributor wasn’t really thinking about other uses. Perhaps the API name should have included EXTENDS.

Neil
Reply all
Reply to author
Forward
0 new messages