Really? I can send a screen capture if you are interested in seeing the effect.
Using windows 10 mingw64 is the compiler I use,
Codeblocks 17.12 wxWidgets 3.12 64bit version
The selection error appears while selecting with left mouse down and moving mouse, and is quite noticable.
It is only a drawing issue because content in selection is correct when hitting copy or cut. It also occurs for both multiple selections and single selection options.
There is a larger code change that does some other things such as condensing invalidation and redrawing from idle that is more efficient but simplier is better, and only added drawing overhead is when selecting multiple lines with mouse.
If you are not having the same issue you can ignore this post, although I have been using the latest released source code downloaded to build with, although I know there still are ways that the code base could be different for some reason.
If someone does have an issue where selection is not being redrawn correctly, this code change corrects that error I was experiencing.
it is in this function of Editor.cxx
void Editor::ButtonMoveWithModifiers(Point pt, int modifiers)
While selecting multiple lines the selection is correct but the drawing misses many invalidation.
(Also someone added a fix where 'when scrolling to fast while selecting lines' was fixed in an awkward way, it would slow down by skipping function always when selecting, even when not scrolling)
the fix to selection issue is to add these four lines, I did not indent them to show what lines are new.
It does add more drawing while dragging mouse to select lines, but the other option is to store the last mouse and make sure all old selection gets invalidated, and is more complex.
Since while line selecting other 'selection based' activities are mostly off, I just repaint when line selecting with mouse to fix it.
The invalidate selection previously probably can be moved since irrelevant, but it solves the selection artifact items
if (sel.IsRectangular()) {
sel.Rectangular() = SelectionRange(movePos, sel.Rectangular().anchor);
SetSelection(movePos, sel.RangeMain().anchor);
RedrawRect(GetClientDrawingRectangle());//New Line Added
} else if (sel.Count() > 1) {
InvalidateSelection(sel.RangeMain(), false);
SelectionRange range(movePos, sel.RangeMain().anchor);
sel.TentativeSelection(range);
InvalidateSelection(range, true);
RedrawRect(GetClientDrawingRectangle());//New Line Added
} else {
SetSelection(movePos, sel.RangeMain().anchor);
RedrawRect(GetClientDrawingRectangle());//New Line Added
}
} else if (selectionType == selWord) {
// Continue selecting by word
if (movePos.Position() == wordSelectInitialCaretPos) { // Didn't move
// No need to do anything. Previously this case was lumped
// in with "Moved forward", but that can be harmful in this
// case: a handler for the NotifyDoubleClick re-adjusts
// the selection for a fancier definition of "word" (for
// example, in Perl it is useful to include the leading
// '$', '%' or '@' on variables for word selection). In this
// the ButtonMove() called via Tick() for auto-scrolling
// could result in the fancier word selection adjustment
// being unmade.
} else {
wordSelectInitialCaretPos = -1;
WordSelection(movePos.Position());
}
} else {
// Continue selecting by line
RedrawRect(GetClientDrawingRectangle());//New Line Added
LineSelection(movePos.Position(), lineAnchorPos, selectionType == selWholeLine);
}
}
This part is just a different way, without slowing down selection, of doing auto scrolling.
Add this to Editor.h class as class members
int nautoScrollAmount;
int nautoScrollTotal;
//initialize them in constructor
nautoScrollAmount = 50;//slows down scrolling when selecting lines with mouse by 50% 100 is cpu speed, 20 would be 1/5 speed etc..
nautoScrollTotal = 0;
//comment out this code that previously skipped out of function even when not scrolling
// Slow down autoscrolling/selection
/*autoScrollTimer.ticksToWait -= timer.tickSize;
if (autoScrollTimer.ticksToWait > 0)
{
return;
}
autoScrollTimer.ticksToWait = autoScrollDelay;*/
and then replace the old autoscroll code
// Autoscroll
int lineMove = DisplayFromPosition(movePos.Position());
if (pt.y > rcClient.bottom) {
ScrollTo(lineMove - LinesOnScreen() + 1);
Redraw();
} else if (pt.y < rcClient.top) {
ScrollTo(lineMove);
Redraw();
}
EnsureCaretVisible(false, false, true);
with where only auto scrolling is skipped if at less then 100%
by using this mechanism it only does its thing when scrolling while selecting, not everytime selecting
// Autoscroll
if(nautoScrollTotal > 99)//skip the scrolling till amount needed gets to over 99
{
int lineMove = DisplayFromPosition(movePos.Position());
if (pt.y > rcClient.bottom) {
//will allow for double or tripple scrolling speed if amount entered is 200 or 300
ScrollTo(lineMove - LinesOnScreen() + (nautoScrollTotal / 100));
Redraw();
} else if (pt.y < rcClient.top) {
//allows faster, but always at least 100 to get here, and always positive
ScrollTo(lineMove - ((nautoScrollTotal / 100) - 1));
Redraw();
}
nautoScrollTotal = 0;
}else{
nautoScrollTotal += nautoScrollAmount;
}
EnsureCaretVisible(false, false, true);