diff options
author | Neil <nyamatongwe@gmail.com> | 2013-12-17 14:16:29 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2013-12-17 14:16:29 +1100 |
commit | 07510a6ffd4f5b286c0d39711ddd9a651c4a84e2 (patch) | |
tree | 9e8a3b88e8b0cf0f330ce63bfa093a41eb9a1e3c /src | |
parent | 5d22624b5ff89b8e3fcefeb27c19012c668b247c (diff) | |
download | scintilla-mirror-07510a6ffd4f5b286c0d39711ddd9a651c4a84e2.tar.gz |
Added DropSelectionN API.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 5 | ||||
-rw-r--r-- | src/Selection.cxx | 15 | ||||
-rw-r--r-- | src/Selection.h | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 7e1da9e20..f254af4dd 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -9526,6 +9526,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { Redraw(); break; + case SCI_DROPSELECTIONN: + sel.DropSelection(wParam); + Redraw(); + break; + case SCI_SETMAINSELECTION: sel.SetMain(wParam); Redraw(); diff --git a/src/Selection.cxx b/src/Selection.cxx index 0c02c198b..ae4d8bfc7 100644 --- a/src/Selection.cxx +++ b/src/Selection.cxx @@ -305,6 +305,21 @@ void Selection::AddSelectionWithoutTrim(SelectionRange range) { mainRange = ranges.size() - 1; } +void Selection::DropSelection(size_t r) { + if ((ranges.size() > 1) && (r < ranges.size())) { + size_t mainNew = mainRange; + if (mainNew >= r) { + if (mainNew == 0) { + mainNew = ranges.size() - 2; + } else { + mainNew--; + } + } + ranges.erase(ranges.begin() + r); + mainRange = mainNew; + } +} + void Selection::TentativeSelection(SelectionRange range) { if (!tentativeMain) { rangesSaved = ranges; diff --git a/src/Selection.h b/src/Selection.h index 956a0f99d..e84d3c32c 100644 --- a/src/Selection.h +++ b/src/Selection.h @@ -167,6 +167,7 @@ public: void SetSelection(SelectionRange range); void AddSelection(SelectionRange range); void AddSelectionWithoutTrim(SelectionRange range); + void DropSelection(size_t r); void TentativeSelection(SelectionRange range); void CommitTentative(); int CharacterInSelection(int posCharacter) const; |