diff options
| author | Neil <nyamatongwe@gmail.com> | 2023-11-06 08:31:47 +1100 | 
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2023-11-06 08:31:47 +1100 | 
| commit | 026058ceca31c336a6d76f248ae2510fe1b1247c (patch) | |
| tree | cd4e6895609eb8efed0ba2b6882291e3b93ac126 /src/Editor.cxx | |
| parent | c32f6adbe3ba88dc14839280213578c7656d2e38 (diff) | |
| download | scintilla-mirror-026058ceca31c336a6d76f248ae2510fe1b1247c.tar.gz | |
Simplify variable flow in ButtonDownWithModifiers and enforce with const to make
adding features easier.
Does not change behaviour.
Diffstat (limited to 'src/Editor.cxx')
| -rw-r--r-- | src/Editor.cxx | 23 | 
1 files changed, 11 insertions, 12 deletions
| diff --git a/src/Editor.cxx b/src/Editor.cxx index d65c8aea3..3018cc0bd 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4657,10 +4657,10 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modi  	const bool ctrl = FlagSet(modifiers, KeyMod::Ctrl);  	const bool shift = FlagSet(modifiers, KeyMod::Shift);  	const bool alt = FlagSet(modifiers, KeyMod::Alt); -	SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, alt)); -	newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position()); -	SelectionPosition newCharPos = SPositionFromLocation(pt, false, true, false); -	newCharPos = MovePositionOutsideChar(newCharPos, -1); +	const SelectionPosition clickPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, alt)); +	const SelectionPosition newPos = MovePositionOutsideChar(clickPos, sel.MainCaret() - clickPos.Position()); +	const SelectionPosition newCharPos = MovePositionOutsideChar( +		SPositionFromLocation(pt, false, true, false), -1);  	inDragDrop = DragDrop::none;  	sel.SetMoveExtends(false); @@ -4669,18 +4669,20 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modi  	NotifyIndicatorClick(true, newPos.Position(), modifiers); +	const bool multiClick = (curTime < (lastClickTime + Platform::DoubleClickTime())) && Close(pt, lastClick, doubleClickCloseThreshold); +	lastClickTime = curTime; +	lastClick = pt; +  	const bool inSelMargin = PointInSelMargin(pt);  	// In margin ctrl+(double)click should always select everything  	if (ctrl && inSelMargin) {  		SelectAll(); -		lastClickTime = curTime; -		lastClick = pt;  		return;  	}  	if (shift && !inSelMargin) {  		SetSelection(newPos);  	} -	if ((curTime < (lastClickTime+Platform::DoubleClickTime())) && Close(pt, lastClick, doubleClickCloseThreshold)) { +	if (multiClick) {  		//Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime);  		ChangeMouseCapture(true);  		if (!ctrl || !multipleSelection || (selectionUnit != TextUnit::character && selectionUnit != TextUnit::word)) @@ -4787,10 +4789,9 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modi  				hotSpotClickPos = newCharPos.Position();  			}  			if (!shift) { -				if (PointInSelection(pt) && !SelectionEmpty()) +				if (PointInSelection(pt) && !SelectionEmpty()) {  					inDragDrop = DragDrop::initial; -				else -					inDragDrop = DragDrop::none; +				}  			}  			ChangeMouseCapture(true);  			if (inDragDrop != DragDrop::initial) { @@ -4822,8 +4823,6 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modi  			}  		}  	} -	lastClickTime = curTime; -	lastClick = pt;  	lastXChosen = static_cast<int>(pt.x) + xOffset;  	ShowCaretAtCurrentPosition();  } | 
