aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Editor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r--src/Editor.cxx49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index e7a309e67..0289fa5e5 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -143,6 +143,7 @@ Editor::Editor() : durationWrapOneByte(0.000001, 0.00000001, 0.00001) {
dwelling = false;
ptMouseLast.x = 0;
ptMouseLast.y = 0;
+ dragDropEnabled = true;
inDragDrop = DragDrop::none;
dropWentOutside = false;
posDrop = SelectionPosition(Sci::invalidPosition);
@@ -4167,42 +4168,37 @@ void Editor::Indent(bool forwards, bool lineIndent) {
Sci::Position caretPosition = sel.Range(r).caret.Position();
const Sci::Line lineCurrentPos = pdoc->SciLineFromPosition(caretPosition);
if (lineOfAnchor == lineCurrentPos && !lineIndent) {
+ const int indentationStep = pdoc->IndentSize();
if (forwards) {
pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length());
caretPosition = sel.Range(r).caret.Position();
- if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) &&
- pdoc->tabIndents) {
- const int indentation = pdoc->GetLineIndentation(lineCurrentPos);
- const int indentationStep = pdoc->IndentSize();
+ const int indentation = pdoc->GetLineIndentation(lineCurrentPos);
+ const Sci::Position column = pdoc->GetColumn(caretPosition);
+ if (column <= indentation && pdoc->tabIndents) {
+ // Inside initial whitespace
const Sci::Position posSelect = pdoc->SetLineIndentation(
- lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
+ lineCurrentPos, indentation + indentationStep - (indentation % indentationStep));
sel.Range(r) = SelectionRange(posSelect);
} else {
if (pdoc->useTabs) {
- const Sci::Position lengthInserted = pdoc->InsertString(caretPosition, "\t", 1);
+ const Sci::Position lengthInserted = pdoc->InsertString(caretPosition, "\t");
sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
} else {
- int numSpaces = (pdoc->tabInChars) -
- static_cast<int>((pdoc->GetColumn(caretPosition) % (pdoc->tabInChars)));
- if (numSpaces < 1)
- numSpaces = pdoc->tabInChars;
+ const Sci::Position numSpaces = pdoc->tabInChars - (column % pdoc->tabInChars);
const std::string spaceText(numSpaces, ' ');
const Sci::Position lengthInserted = pdoc->InsertString(caretPosition, spaceText);
sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
}
}
} else {
- if (pdoc->GetColumn(caretPosition) <= pdoc->GetLineIndentation(lineCurrentPos) &&
- pdoc->tabIndents) {
- const int indentation = pdoc->GetLineIndentation(lineCurrentPos);
- const int indentationStep = pdoc->IndentSize();
+ const int indentation = pdoc->GetLineIndentation(lineCurrentPos);
+ const Sci::Position column = pdoc->GetColumn(caretPosition);
+ if (column <= indentation && pdoc->tabIndents) {
const Sci::Position posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
sel.Range(r) = SelectionRange(posSelect);
} else {
- Sci::Position newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) *
- pdoc->tabInChars;
- if (newColumn < 0)
- newColumn = 0;
+ const Sci::Position newColumn = std::max<Sci::Position>(0,
+ ((column - 1) / pdoc->tabInChars) * pdoc->tabInChars);
Sci::Position newPos = caretPosition;
while (pdoc->GetColumn(newPos) > newColumn)
newPos--;
@@ -5041,7 +5037,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, KeyMod modifiers) {
AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
movePos = MovePositionOutsideChar(movePos, sel.MainCaret() - movePos.Position());
- if (inDragDrop == DragDrop::initial) {
+ if (dragDropEnabled && inDragDrop == DragDrop::initial) {
if (DragThreshold(ptMouseLast, pt)) {
ChangeMouseCapture(false);
SetDragPosition(movePos);
@@ -5139,7 +5135,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, KeyMod modifiers) {
}
}
// Display regular (drag) cursor over selection
- if (PointInSelection(pt) && !SelectionEmpty()) {
+ if (dragDropEnabled && PointInSelection(pt) && !SelectionEmpty()) {
DisplayCursor(Window::Cursor::arrow);
SetHoverIndicatorPosition(Sci::invalidPosition);
} else {
@@ -6178,11 +6174,11 @@ void Editor::SetSelectionNMessage(Message iMessage, uptr_t wParam, sptr_t lParam
break;
case Message::SetSelectionNStart:
- sel.Range(wParam).anchor.SetPosition(lParam);
+ sel.Range(wParam).StartSet(SelectionPosition(lParam));
break;
case Message::SetSelectionNEnd:
- sel.Range(wParam).caret.SetPosition(lParam);
+ sel.Range(wParam).EndSet(SelectionPosition(lParam));
break;
default:
@@ -6988,7 +6984,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
return static_cast<sptr_t>(vs.tabDrawMode);
case Message::SetTabDrawMode:
- vs.tabDrawMode = static_cast<TabDrawMode>(wParam);
+ SetAppearance(vs.tabDrawMode, static_cast<TabDrawMode>(wParam));
Redraw();
break;
@@ -7084,6 +7080,13 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::GetBufferedDraw:
return view.bufferedDraw;
+ case Message::GetDragDropEnabled:
+ return dragDropEnabled;
+
+ case Message::SetDragDropEnabled:
+ dragDropEnabled = wParam != 0;
+ break;
+
#ifdef INCLUDE_DEPRECATED_FEATURES
case SCI_GETTWOPHASEDRAW:
return view.phasesDraw == EditView::phasesTwo;