diff options
| -rw-r--r-- | src/Editor.cxx | 62 | ||||
| -rw-r--r-- | src/Editor.h | 2 | 
2 files changed, 32 insertions, 32 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 8e4d85902..c6fa503e2 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -134,7 +134,7 @@ Editor::Editor() : durationWrapOneLine(0.00001, 0.000001, 0.0001) {  	dropWentOutside = false;  	posDrop = SelectionPosition(Sci::invalidPosition);  	hotSpotClickPos = INVALID_POSITION; -	selectionType = selChar; +	selectionUnit = TextUnit::character;  	lastXChosen = 0;  	lineAnchorPos = 0; @@ -4551,34 +4551,34 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie  		//Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime);  		SetMouseCapture(true);  		FineTickerStart(tickScroll, 100, 10); -		if (!ctrl || !multipleSelection || (selectionType != selChar && selectionType != selWord)) +		if (!ctrl || !multipleSelection || (selectionUnit != TextUnit::character && selectionUnit != TextUnit::word))  			SetEmptySelection(newPos.Position());  		bool doubleClick = false;  		if (inSelMargin) { -			// Inside margin selection type should be either selSubLine or selWholeLine. -			if (selectionType == selSubLine) { -				// If it is selSubLine, we're inside a *double* click and word wrap is enabled, -				// so we switch to selWholeLine in order to select whole line. -				selectionType = selWholeLine; -			} else if (selectionType != selSubLine && selectionType != selWholeLine) { +			// Inside margin selection type should be either subLine or wholeLine. +			if (selectionUnit == TextUnit::subLine) { +				// If it is subLine, we're inside a *double* click and word wrap is enabled, +				// so we switch to wholeLine in order to select whole line. +				selectionUnit = TextUnit::wholeLine; +			} else if (selectionUnit != TextUnit::subLine && selectionUnit != TextUnit::wholeLine) {  				// If it is neither, reset selection type to line selection. -				selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; +				selectionUnit = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? TextUnit::subLine : TextUnit::wholeLine;  			}  		} else { -			if (selectionType == selChar) { -				selectionType = selWord; +			if (selectionUnit == TextUnit::character) { +				selectionUnit = TextUnit::word;  				doubleClick = true; -			} else if (selectionType == selWord) { +			} else if (selectionUnit == TextUnit::word) {  				// Since we ended up here, we're inside a *triple* click, which should always select  				// whole line regardless of word wrap being enabled or not. -				selectionType = selWholeLine; +				selectionUnit = TextUnit::wholeLine;  			} else { -				selectionType = selChar; +				selectionUnit = TextUnit::character;  				originalAnchorPos = sel.MainCaret();  			}  		} -		if (selectionType == selWord) { +		if (selectionUnit == TextUnit::word) {  			Sci::Position charPos = originalAnchorPos;  			if (sel.MainCaret() == originalAnchorPos) {  				charPos = PositionFromLocation(pt, false, true); @@ -4606,9 +4606,9 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie  			wordSelectAnchorEndPos = endWord;  			wordSelectInitialCaretPos = sel.MainCaret();  			WordSelection(wordSelectInitialCaretPos); -		} else if (selectionType == selSubLine || selectionType == selWholeLine) { +		} else if (selectionUnit == TextUnit::subLine || selectionUnit == TextUnit::wholeLine) {  			lineAnchorPos = newPos.Position(); -			LineSelection(lineAnchorPos, lineAnchorPos, selectionType == selWholeLine); +			LineSelection(lineAnchorPos, lineAnchorPos, selectionUnit == TextUnit::wholeLine);  			//Platform::DebugPrintf("Triple click: %d - %d\n", anchor, currentPos);  		} else {  			SetEmptySelection(sel.MainCaret()); @@ -4627,10 +4627,10 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie  			}  			sel.selType = Selection::selStream;  			if (!shift) { -				// Single click in margin: select whole line or only subline if word wrap is enabled +				// Single click in margin: select wholeLine or only subLine if word wrap is enabled  				lineAnchorPos = newPos.Position(); -				selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; -				LineSelection(lineAnchorPos, lineAnchorPos, selectionType == selWholeLine); +				selectionUnit = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? TextUnit::subLine : TextUnit::wholeLine; +				LineSelection(lineAnchorPos, lineAnchorPos, selectionUnit == TextUnit::wholeLine);  			} else {  				// Single shift+click in margin: select from line anchor to clicked line  				if (sel.MainAnchor() > sel.MainCaret()) @@ -4639,11 +4639,11 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie  					lineAnchorPos = sel.MainAnchor();  				// Reset selection type if there is an empty selection.  				// This ensures that we don't end up stuck in previous selection mode, which is no longer valid. -				// Otherwise, if there's a non empty selection, reset selection type only if it differs from selSubLine and selWholeLine. +				// Otherwise, if there's a non empty selection, reset selection type only if it differs from subLine and wholeLine.  				// This ensures that we continue selecting in the same selection mode. -				if (sel.Empty() || (selectionType != selSubLine && selectionType != selWholeLine)) -					selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine; -				LineSelection(newPos.Position(), lineAnchorPos, selectionType == selWholeLine); +				if (sel.Empty() || (selectionUnit != TextUnit::subLine && selectionUnit != TextUnit::wholeLine)) +					selectionUnit = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? TextUnit::subLine : TextUnit::wholeLine; +				LineSelection(newPos.Position(), lineAnchorPos, selectionUnit == TextUnit::wholeLine);  			}  			SetDragPosition(SelectionPosition(Sci::invalidPosition)); @@ -4684,7 +4684,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie  					anchorCurrent = sel.IsRectangular() ?  						sel.Rectangular().anchor : sel.RangeMain().anchor;  				sel.selType = alt ? Selection::selRectangle : Selection::selStream; -				selectionType = selChar; +				selectionUnit = TextUnit::character;  				originalAnchorPos = sel.MainCaret();  				sel.Rectangular() = SelectionRange(newPos, anchorCurrent);  				SetRectangularRange(); @@ -4811,7 +4811,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {  		if (posDrag.IsValid()) {  			SetDragPosition(movePos);  		} else { -			if (selectionType == selChar) { +			if (selectionUnit == TextUnit::character) {  				if (sel.selType == Selection::selStream && (modifiers & SCI_ALT) && mouseSelectionRectangularSwitch) {  					sel.selType = Selection::selRectangle;  				} @@ -4826,7 +4826,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {  				} else {  					SetSelection(movePos, sel.RangeMain().anchor);  				} -			} else if (selectionType == selWord) { +			} else if (selectionUnit == TextUnit::word) {  				// Continue selecting by word  				if (movePos.Position() == wordSelectInitialCaretPos) {  // Didn't move  					// No need to do anything. Previously this case was lumped @@ -4844,7 +4844,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) {  				}  			} else {  				// Continue selecting by line -				LineSelection(movePos.Position(), lineAnchorPos, selectionType == selWholeLine); +				LineSelection(movePos.Position(), lineAnchorPos, selectionUnit == TextUnit::wholeLine);  			}  		} @@ -4906,7 +4906,7 @@ void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers  	if (inDragDrop == ddInitial) {  		inDragDrop = ddNone;  		SetEmptySelection(newPos); -		selectionType = selChar; +		selectionUnit = TextUnit::character;  		originalAnchorPos = sel.MainCaret();  	}  	if (hotSpotClickPos != INVALID_POSITION && PointIsHotspot(pt)) { @@ -4958,10 +4958,10 @@ void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers  					}  					drag.Clear();  				} -				selectionType = selChar; +				selectionUnit = TextUnit::character;  			}  		} else { -			if (selectionType == selChar) { +			if (selectionUnit == TextUnit::character) {  				if (sel.Count() > 1) {  					sel.RangeMain() =  						SelectionRange(newPos, sel.Range(sel.Count() - 1).anchor); diff --git a/src/Editor.h b/src/Editor.h index 74137cd48..8c875a49c 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -210,7 +210,7 @@ protected:	// ScintillaBase subclass needs access to much of Editor  	int dwellDelay;  	int ticksToDwell;  	bool dwelling; -	enum { selChar, selWord, selSubLine, selWholeLine } selectionType; +	enum class TextUnit { character, word, subLine, wholeLine } selectionUnit;  	Point ptMouseLast;  	enum { ddNone, ddInitial, ddDragging } inDragDrop;  	bool dropWentOutside;  | 
