aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2009-07-30 08:29:43 +0000
committernyamatongwe <devnull@localhost>2009-07-30 08:29:43 +0000
commitd8afa085aba4f6b61f29bee5e896623bb5448605 (patch)
tree089cc73c6396c1d45e59dc3c30ec5633c1857d11
parent3eda35484e2a59ae676127df9915e0a48bfccefa (diff)
downloadscintilla-mirror-d8afa085aba4f6b61f29bee5e896623bb5448605.tar.gz
When using Ctrl+Drag for multiple selection when previous selections
dragged over but then that area is deselected, reveal the previous selections again. This allows the user to undo some bad effects when the mouse moves further than wanted.
-rw-r--r--src/Editor.cxx9
-rw-r--r--src/Selection.cxx17
-rw-r--r--src/Selection.h6
3 files changed, 24 insertions, 8 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index ee44a6972..caeb9dfdf 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5644,8 +5644,9 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b
SetDragPosition(SelectionPosition(invalidPosition));
if (!shift) {
if (ctrl && multipleSelection) {
- InvalidateSelection(SelectionRange(newPos), true);
- sel.AddSelection(newPos);
+ SelectionRange range(newPos);
+ sel.TentativeSelection(range);
+ InvalidateSelection(range, true);
} else {
InvalidateSelection(SelectionRange(newPos), true);
if (sel.Count() > 1)
@@ -5756,8 +5757,7 @@ void Editor::ButtonMove(Point pt) {
SetSelection(movePos, sel.RangeMain().anchor);
} else if (sel.Count() > 1) {
SelectionRange range(movePos, sel.RangeMain().anchor);
- sel.TrimSelection(range);
- sel.RangeMain() = range;
+ sel.TentativeSelection(range);
InvalidateSelection(range, true);
} else {
SetSelection(movePos, sel.RangeMain().anchor);
@@ -5883,6 +5883,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
SetSelection(newPos, sel.RangeMain().anchor);
}
}
+ sel.CommitTentative();
}
SetRectangularRange();
lastClickTime = curTime;
diff --git a/src/Selection.cxx b/src/Selection.cxx
index 246cfe709..b44d4e96c 100644
--- a/src/Selection.cxx
+++ b/src/Selection.cxx
@@ -156,7 +156,7 @@ void SelectionRange::MinimizeVirtualSpace() {
}
}
-Selection::Selection() : mainRange(0), moveExtends(false), selType(selStream) {
+Selection::Selection() : mainRange(0), moveExtends(false), selType(selStream), tentativeMain(false) {
AddSelection(SelectionPosition(0));
}
@@ -270,8 +270,19 @@ void Selection::AddSelection(SelectionRange range) {
mainRange = ranges.size() - 1;
}
-void Selection::AddSelection(SelectionPosition spPos) {
- AddSelection(SelectionRange(spPos, spPos));
+void Selection::TentativeSelection(SelectionRange range) {
+ if (!tentativeMain) {
+ rangesSaved = ranges;
+ }
+ ranges = rangesSaved;
+ AddSelection(range);
+ TrimSelection(ranges[mainRange]);
+ tentativeMain = true;
+}
+
+void Selection::CommitTentative() {
+ rangesSaved.clear();
+ tentativeMain = false;
}
int Selection::CharacterInSelection(int posCharacter) const {
diff --git a/src/Selection.h b/src/Selection.h
index ff13f2130..c18e5c02e 100644
--- a/src/Selection.h
+++ b/src/Selection.h
@@ -123,9 +123,11 @@ struct SelectionRange {
class Selection {
std::vector<SelectionRange> ranges;
+ std::vector<SelectionRange> rangesSaved;
SelectionRange rangeRectangular;
size_t mainRange;
bool moveExtends;
+ bool tentativeMain;
public:
enum selTypes { noSel, selStream, selRectangle, selLines, selThin };
selTypes selType;
@@ -150,13 +152,15 @@ public:
void TrimSelection(SelectionRange range);
void SetSelection(SelectionRange range);
void AddSelection(SelectionRange range);
- void AddSelection(SelectionPosition spPos);
+ void TentativeSelection(SelectionRange range);
+ void CommitTentative();
int CharacterInSelection(int posCharacter) const;
int InSelectionForEOL(int pos) const;
int VirtualSpaceFor(int pos) const;
void Clear();
void RemoveDuplicates();
void RotateMain();
+ bool Tentative() const { return tentativeMain; }
};
#ifdef SCI_NAMESPACE