1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Multi-cursor tweaks

This commit is contained in:
Brian Fiete 2025-05-26 08:25:07 +02:00
parent ba4d29d28d
commit 2ce4ec2e3f
22 changed files with 402 additions and 422 deletions

View file

@ -554,9 +554,9 @@ namespace Beefy.theme.dark
int selStartIdx = -1; int selStartIdx = -1;
int selEndIdx = -1; int selEndIdx = -1;
if (mSelection != null) if (CurSelection != null)
{ {
mSelection.Value.GetAsForwardSelect(out selStartIdx, out selEndIdx); CurSelection.Value.GetAsForwardSelect(out selStartIdx, out selEndIdx);
GetLineCharAtIdx(selStartIdx, out selStartLine, out selStartCharIdx); GetLineCharAtIdx(selStartIdx, out selStartLine, out selStartCharIdx);
GetLineCharAtIdx(selEndIdx, out selEndLine, out selEndCharIdx); GetLineCharAtIdx(selEndIdx, out selEndLine, out selEndCharIdx);
} }
@ -721,17 +721,17 @@ namespace Beefy.theme.dark
if ((mEditWidget.mHasFocus) && (!drewCursor)) if ((mEditWidget.mHasFocus) && (!drewCursor))
{ {
float aX = -1; float aX = -1;
if (mVirtualCursorPos != null) if (CurVirtualCursorPos != null)
{ {
if ((lineIdx == mVirtualCursorPos.Value.mLine) && (lineDrawEnd == lineEnd)) if ((lineIdx == CurVirtualCursorPos.Value.mLine) && (lineDrawEnd == lineEnd))
{ {
aX = mVirtualCursorPos.Value.mColumn * mCharWidth; aX = CurVirtualCursorPos.Value.mColumn * mCharWidth;
} }
} }
else if (mCursorTextPos >= lineDrawStart) else if (CurCursorTextPos >= lineDrawStart)
{ {
bool isInside = mCursorTextPos < lineDrawEnd; bool isInside = CurCursorTextPos < lineDrawEnd;
if ((mCursorTextPos == lineDrawEnd) && (lineDrawEnd == lineEnd)) if ((CurCursorTextPos == lineDrawEnd) && (lineDrawEnd == lineEnd))
{ {
if (lineDrawEnd == mData.mTextLength) if (lineDrawEnd == mData.mTextLength)
isInside = true; isInside = true;
@ -746,8 +746,8 @@ namespace Beefy.theme.dark
if (isInside) if (isInside)
{ {
String subText = new:ScopedAlloc! String(mCursorTextPos - lineDrawStart); String subText = new:ScopedAlloc! String(CurCursorTextPos - lineDrawStart);
subText.Append(sectionText, 0, mCursorTextPos - lineDrawStart); subText.Append(sectionText, 0, CurCursorTextPos - lineDrawStart);
aX = GetTabbedWidth(subText, curX); aX = GetTabbedWidth(subText, curX);
} }
} }
@ -793,7 +793,7 @@ namespace Beefy.theme.dark
if (!HasSelection()) if (!HasSelection())
return; return;
mSelection.Value.GetAsForwardSelect(var startPos, var endPos); CurSelection.Value.GetAsForwardSelect(var startPos, var endPos);
GetLineColumnAtIdx(startPos, var startLine, var startColumn); GetLineColumnAtIdx(startPos, var startLine, var startColumn);
GetLineColumnAtIdx(endPos, var endLine, var endColumn); GetLineColumnAtIdx(endPos, var endLine, var endColumn);

View file

@ -170,7 +170,6 @@ namespace Beefy.utils
mUndoIdx = (.)mUndoList.Count; mUndoIdx = (.)mUndoList.Count;
Debug.WriteLine("SUCCESS: Merged");
return true; return true;
} }

View file

@ -170,9 +170,9 @@ namespace Beefy.widgets
mPrevTextVersionId = editWidget.mData.mCurTextVersionId; mPrevTextVersionId = editWidget.mData.mCurTextVersionId;
mEditWidgetContentData = editWidget.mData; mEditWidgetContentData = editWidget.mData;
if (editWidget.HasSelection()) if (editWidget.HasSelection())
mSelection = editWidget.mSelection; mSelection = editWidget.CurSelection;
mCursorTextPos = (int32)editWidget.CursorTextPos; mCursorTextPos = (int32)editWidget.CursorTextPos;
mVirtualCursorPos = editWidget.mVirtualCursorPos; mVirtualCursorPos = editWidget.CurVirtualCursorPos;
mTextCursorId = editWidget.mCurrentTextCursor.mId; mTextCursorId = editWidget.mCurrentTextCursor.mId;
if ((editWidget.IsPrimaryTextCursor()) && (editWidget.mMultiCursorUndoBatch != null)) if ((editWidget.IsPrimaryTextCursor()) && (editWidget.mMultiCursorUndoBatch != null))
editWidget.mMultiCursorUndoBatch.mPrimaryUndoAction = this; editWidget.mMultiCursorUndoBatch.mPrimaryUndoAction = this;
@ -184,11 +184,11 @@ namespace Beefy.widgets
editWidgetContent.SetTextCursor(mTextCursorId); editWidgetContent.SetTextCursor(mTextCursorId);
mEditWidgetContentData.mCurTextVersionId = mPrevTextVersionId; mEditWidgetContentData.mCurTextVersionId = mPrevTextVersionId;
if ((mRestoreSelectionOnUndo) || (force)) if ((mRestoreSelectionOnUndo) || (force))
editWidgetContent.mSelection = mSelection; editWidgetContent.CurSelection = mSelection;
else else
editWidgetContent.mSelection = null; editWidgetContent.CurSelection = null;
editWidgetContent.mCursorTextPos = mCursorTextPos; editWidgetContent.CurCursorTextPos = mCursorTextPos;
editWidgetContent.mVirtualCursorPos = mVirtualCursorPos; editWidgetContent.CurVirtualCursorPos = mVirtualCursorPos;
if (mMoveCursor) if (mMoveCursor)
editWidgetContent.EnsureCursorVisible(); editWidgetContent.EnsureCursorVisible();
} }
@ -208,7 +208,7 @@ namespace Beefy.widgets
var currentSelection = ewc.GetAsSelection(ewc.mCurrentTextCursor, true); var currentSelection = ewc.GetAsSelection(ewc.mCurrentTextCursor, true);
var offset = 0; var offset = 0;
if (currentSelection.Length > 0) if (currentSelection.Length > 0)
offset -= ewc.mSelection.Value.Length; offset -= ewc.CurSelection.Value.Length;
for (var cursor in ewc.mTextCursors) for (var cursor in ewc.mTextCursors)
{ {
@ -450,7 +450,7 @@ namespace Beefy.widgets
editWidgetContent.InsertText(idxChar.0, charStr); editWidgetContent.InsertText(idxChar.0, charStr);
} }
editWidgetContent.ContentChanged(); editWidgetContent.ContentChanged();
editWidgetContent.mSelection = mNewSelection; editWidgetContent.CurSelection = mNewSelection;
editWidgetContent.CursorTextPos = mNewSelection.mEndPos; editWidgetContent.CursorTextPos = mNewSelection.mEndPos;
return true; return true;
@ -745,9 +745,9 @@ namespace Beefy.widgets
public List<TextCursor> mTextCursors = new List<TextCursor>() ~ DeleteContainerAndItems!(_); public List<TextCursor> mTextCursors = new List<TextCursor>() ~ DeleteContainerAndItems!(_);
public TextCursor mCurrentTextCursor; public TextCursor mCurrentTextCursor;
public int32 mCursorBlinkTicks; public int32 mCursorBlinkTicks;
public ref bool mCursorImplicitlyMoved => ref mCurrentTextCursor.mCursorImplicitlyMoved; public ref bool CurCursorImplicitlyMoved => ref mCurrentTextCursor.mCursorImplicitlyMoved;
public ref bool mJustInsertedCharPair => ref mCurrentTextCursor.mJustInsertedCharPair; // Pressing backspace will delete last char8, even though cursor is between char8 pairs (ie: for brace pairs 'speculatively' inserted) public ref bool CurJustInsertedCharPair => ref mCurrentTextCursor.mJustInsertedCharPair; // Pressing backspace will delete last char8, even though cursor is between char8 pairs (ie: for brace pairs 'speculatively' inserted)
public ref EditSelection? mSelection => ref mCurrentTextCursor.mSelection; public ref EditSelection? CurSelection => ref mCurrentTextCursor.mSelection;
public EditSelection? mDragSelectionUnion; // For double-clicking a word and then "dragging" the selection public EditSelection? mDragSelectionUnion; // For double-clicking a word and then "dragging" the selection
public DragSelectionKind mDragSelectionKind; public DragSelectionKind mDragSelectionKind;
public bool mIsReadOnly = false; public bool mIsReadOnly = false;
@ -757,9 +757,9 @@ namespace Beefy.widgets
public float mCursorWantX; // For keyboard cursor selection, accounting for when we truncate to line end public float mCursorWantX; // For keyboard cursor selection, accounting for when we truncate to line end
public bool mOverTypeMode = false; public bool mOverTypeMode = false;
public ref int32 mCursorTextPos => ref mCurrentTextCursor.mCursorTextPos; public ref int32 CurCursorTextPos => ref mCurrentTextCursor.mCursorTextPos;
public bool mShowCursorAtLineEnd; public bool mShowCursorAtLineEnd;
public ref LineAndColumn? mVirtualCursorPos => ref mCurrentTextCursor.mVirtualCursorPos; public ref LineAndColumn? CurVirtualCursorPos => ref mCurrentTextCursor.mVirtualCursorPos;
public bool mEnsureCursorVisibleOnModify = true; public bool mEnsureCursorVisibleOnModify = true;
public bool mAllowVirtualCursor; public bool mAllowVirtualCursor;
public bool mAllowMaximalScroll = true; // Allows us to scroll down such that edit widget is blank except for one line of content at the top public bool mAllowMaximalScroll = true; // Allows us to scroll down such that edit widget is blank except for one line of content at the top
@ -769,27 +769,27 @@ namespace Beefy.widgets
{ {
get get
{ {
if (mCursorTextPos == -1) if (CurCursorTextPos == -1)
{ {
float x; float x;
float y; float y;
GetTextCoordAtLineAndColumn(mVirtualCursorPos.Value.mLine, mVirtualCursorPos.Value.mColumn, out x, out y); GetTextCoordAtLineAndColumn(CurVirtualCursorPos.Value.mLine, CurVirtualCursorPos.Value.mColumn, out x, out y);
int lineChar; int lineChar;
float overflowX; float overflowX;
GetLineCharAtCoord(mVirtualCursorPos.Value.mLine, x, out lineChar, out overflowX); GetLineCharAtCoord(CurVirtualCursorPos.Value.mLine, x, out lineChar, out overflowX);
mCursorTextPos = (int32)GetTextIdx(mVirtualCursorPos.Value.mLine, lineChar); CurCursorTextPos = (int32)GetTextIdx(CurVirtualCursorPos.Value.mLine, lineChar);
} }
return mCursorTextPos; return CurCursorTextPos;
} }
set set
{ {
Debug.Assert(value >= 0); Debug.Assert(value >= 0);
mVirtualCursorPos = null; CurVirtualCursorPos = null;
mCursorTextPos = (int32)value; CurCursorTextPos = (int32)value;
} }
} }
@ -797,13 +797,13 @@ namespace Beefy.widgets
{ {
get get
{ {
if (mVirtualCursorPos.HasValue) if (CurVirtualCursorPos.HasValue)
return mVirtualCursorPos.Value; return CurVirtualCursorPos.Value;
LineAndColumn lineAndColumn; LineAndColumn lineAndColumn;
int line; int line;
int lineChar; int lineChar;
GetLineCharAtIdx(mCursorTextPos, out line, out lineChar); GetLineCharAtIdx(CurCursorTextPos, out line, out lineChar);
int coordLineColumn; int coordLineColumn;
GetLineAndColumnAtLineChar(line, lineChar, out coordLineColumn); GetLineAndColumnAtLineChar(line, lineChar, out coordLineColumn);
@ -814,10 +814,10 @@ namespace Beefy.widgets
set set
{ {
mVirtualCursorPos = value; CurVirtualCursorPos = value;
mCursorTextPos = -1; CurCursorTextPos = -1;
Debug.Assert(mAllowVirtualCursor); Debug.Assert(mAllowVirtualCursor);
Debug.Assert(mVirtualCursorPos.Value.mColumn >= 0); Debug.Assert(CurVirtualCursorPos.Value.mColumn >= 0);
} }
} }
@ -825,12 +825,12 @@ namespace Beefy.widgets
{ {
get get
{ {
if (mVirtualCursorPos.HasValue) if (CurVirtualCursorPos.HasValue)
return mVirtualCursorPos.Value.mLine; return CurVirtualCursorPos.Value.mLine;
int line; int line;
int lineChar; int lineChar;
GetLineCharAtIdx(mCursorTextPos, out line, out lineChar); GetLineCharAtIdx(CurCursorTextPos, out line, out lineChar);
return (.)line; return (.)line;
} }
} }
@ -869,12 +869,12 @@ namespace Beefy.widgets
public bool TryGetCursorTextPos(out int textPos, out float overflowX) public bool TryGetCursorTextPos(out int textPos, out float overflowX)
{ {
if (mVirtualCursorPos.HasValue) if (CurVirtualCursorPos.HasValue)
{ {
int32 line = mVirtualCursorPos.Value.mLine; int32 line = CurVirtualCursorPos.Value.mLine;
float x; float x;
float y; float y;
GetTextCoordAtLineAndColumn(line, mVirtualCursorPos.Value.mColumn, out x, out y); GetTextCoordAtLineAndColumn(line, CurVirtualCursorPos.Value.mColumn, out x, out y);
int lineChar; int lineChar;
bool success = GetLineCharAtCoord(line, x, out lineChar, out overflowX); bool success = GetLineCharAtCoord(line, x, out lineChar, out overflowX);
@ -882,7 +882,7 @@ namespace Beefy.widgets
textPos = GetTextIdx(line, lineChar); textPos = GetTextIdx(line, lineChar);
return success; return success;
} }
textPos = mCursorTextPos; textPos = CurCursorTextPos;
overflowX = 0; overflowX = 0;
return true; return true;
} }
@ -954,6 +954,44 @@ namespace Beefy.widgets
return (c.IsLetterOrDigit) || (c == '_') || (c >= '\x80'); return (c.IsLetterOrDigit) || (c == '_') || (c >= '\x80');
} }
public void SelectWord()
{
StartSelection();
int cursorTextPos = CursorTextPos;
int textPos = cursorTextPos;
if (mData.mTextLength == 0)
{
//Nothing
}
else if ((textPos < mData.mTextLength) && (!IsNonBreakingChar((char8)mData.mText[textPos].mChar)))
{
if ((char8)mData.mText[textPos].mChar == '\n')
return;
CurSelection.ValueRef.mEndPos++;
}
else
{
while ((textPos > 0) && (IsNonBreakingChar((char8)mData.mText[textPos - 1].mChar)))
{
CurSelection.ValueRef.mStartPos--;
textPos--;
}
textPos = cursorTextPos + 1;
while ((textPos <= mData.mTextLength) && ((textPos == mData.mTextLength) || (mData.mText[textPos - 1].mChar != '\n')) &&
(IsNonBreakingChar((char8)mData.mText[textPos - 1].mChar)))
{
CurSelection.ValueRef.mEndPos++;
textPos++;
}
}
mDragSelectionUnion = CurSelection;
CursorTextPos = CurSelection.Value.MaxPos;
}
public override void MouseDown(float x, float y, int32 btn, int32 btnCount) public override void MouseDown(float x, float y, int32 btn, int32 btnCount)
{ {
SetPrimaryTextCursor(); SetPrimaryTextCursor();
@ -973,7 +1011,7 @@ namespace Beefy.widgets
{ {
GetLineCharAtCoord(x, y, var line, var lineChar, ?); GetLineCharAtCoord(x, y, var line, var lineChar, ?);
int textPos = GetTextIdx(line, lineChar); int textPos = GetTextIdx(line, lineChar);
if ((textPos > mSelection.Value.MinPos) && (textPos < mSelection.Value.MaxPos)) if ((textPos > CurSelection.Value.MinPos) && (textPos < CurSelection.Value.MaxPos))
{ {
// Leave selection // Leave selection
mDragSelectionKind = .ClickedInside; mDragSelectionKind = .ClickedInside;
@ -981,7 +1019,7 @@ namespace Beefy.widgets
} }
} }
if ((mSelection == null) && (mWidgetWindow.IsKeyDown(KeyCode.Shift))) if ((CurSelection == null) && (mWidgetWindow.IsKeyDown(KeyCode.Shift)))
StartSelection(); StartSelection();
MoveCursorToCoord(x, y); MoveCursorToCoord(x, y);
@ -992,45 +1030,11 @@ namespace Beefy.widgets
if ((btn == 0) && (btnCount >= 3) && (!mWidgetWindow.IsKeyDown(KeyCode.Shift))) if ((btn == 0) && (btnCount >= 3) && (!mWidgetWindow.IsKeyDown(KeyCode.Shift)))
{ {
GetLinePosition(CursorLineAndColumn.mLine, var lineStart, var lineEnd); GetLinePosition(CursorLineAndColumn.mLine, var lineStart, var lineEnd);
mSelection = EditSelection(lineStart, lineEnd); CurSelection = EditSelection(lineStart, lineEnd);
} }
else if ((btn == 0) && (btnCount >= 2) && (!mWidgetWindow.IsKeyDown(KeyCode.Shift))) else if ((btn == 0) && (btnCount >= 2) && (!mWidgetWindow.IsKeyDown(KeyCode.Shift)))
{ {
// Select word SelectWord();
StartSelection();
int cursorTextPos = CursorTextPos;
int textPos = cursorTextPos;
if (mData.mTextLength == 0)
{
//Nothing
}
else if ((textPos < mData.mTextLength) && (!IsNonBreakingChar((char8)mData.mText[textPos].mChar)))
{
if ((char8)mData.mText[textPos].mChar == '\n')
return;
mSelection.ValueRef.mEndPos++;
}
else
{
while ((textPos > 0) && (IsNonBreakingChar((char8)mData.mText[textPos - 1].mChar)))
{
mSelection.ValueRef.mStartPos--;
textPos--;
}
textPos = cursorTextPos + 1;
while ((textPos <= mData.mTextLength) && ((textPos == mData.mTextLength) || (mData.mText[textPos - 1].mChar != '\n')) &&
(IsNonBreakingChar((char8)mData.mText[textPos - 1].mChar)))
{
mSelection.ValueRef.mEndPos++;
textPos++;
}
}
mDragSelectionUnion = mSelection;
CursorTextPos = mSelection.Value.MaxPos;
} }
else if (!mWidgetWindow.IsKeyDown(KeyCode.Shift)) else if (!mWidgetWindow.IsKeyDown(KeyCode.Shift))
{ {
@ -1049,7 +1053,7 @@ namespace Beefy.widgets
mDragSelectionUnion = null; mDragSelectionUnion = null;
if ((mDragSelectionKind == .ClickedInside) && (btn == 0)) if ((mDragSelectionKind == .ClickedInside) && (btn == 0))
{ {
mSelection = null; CurSelection = null;
MoveCursorToCoord(x, y); MoveCursorToCoord(x, y);
ClampCursor(); ClampCursor();
} }
@ -1097,10 +1101,10 @@ namespace Beefy.widgets
{ {
int startIdx = 0; int startIdx = 0;
int endIdx = 0; int endIdx = 0;
mSelection.Value.GetAsForwardSelect(out startIdx, out endIdx); CurSelection.Value.GetAsForwardSelect(out startIdx, out endIdx);
RemoveText(startIdx, endIdx - startIdx); RemoveText(startIdx, endIdx - startIdx);
mSelection = null; CurSelection = null;
CursorTextPos = startIdx; CursorTextPos = startIdx;
@ -1115,7 +1119,7 @@ namespace Beefy.widgets
public virtual void DeleteSelection(bool moveCursor = true) public virtual void DeleteSelection(bool moveCursor = true)
{ {
if (mSelection != null) if (CurSelection != null)
{ {
var action = new DeleteSelectionAction(this); var action = new DeleteSelectionAction(this);
action.mMoveCursor = moveCursor; action.mMoveCursor = moveCursor;
@ -1126,12 +1130,12 @@ namespace Beefy.widgets
public bool GetSelectionText(String outStr) public bool GetSelectionText(String outStr)
{ {
if (mSelection == null) if (CurSelection == null)
return false; return false;
int startIdx = 0; int startIdx = 0;
int endIdx = 0; int endIdx = 0;
mSelection.Value.GetAsForwardSelect(out startIdx, out endIdx); CurSelection.Value.GetAsForwardSelect(out startIdx, out endIdx);
ExtractString(startIdx, endIdx - startIdx, outStr); ExtractString(startIdx, endIdx - startIdx, outStr);
return true; return true;
@ -1188,44 +1192,44 @@ namespace Beefy.widgets
{ {
if (HasSelection()) if (HasSelection())
{ {
var isCaretAtStartPos = (mSelection.Value.mStartPos == mCursorTextPos); var isCaretAtStartPos = (CurSelection.Value.mStartPos == CurCursorTextPos);
if (((ofs > 0) && (mSelection.Value.MinPos >= index)) || if (((ofs > 0) && (CurSelection.Value.MinPos >= index)) ||
((ofs < 0) && (mSelection.Value.MinPos > index))) ((ofs < 0) && (CurSelection.Value.MinPos > index)))
{ {
mSelection.ValueRef.mStartPos = Math.Clamp(mSelection.Value.mStartPos + int32(ofs), 0, mData.mTextLength + 1); CurSelection.ValueRef.mStartPos = Math.Clamp(CurSelection.Value.mStartPos + int32(ofs), 0, mData.mTextLength + 1);
mSelection.ValueRef.mEndPos = Math.Clamp(mSelection.Value.mEndPos + int32(ofs), 0, mData.mTextLength + 1); CurSelection.ValueRef.mEndPos = Math.Clamp(CurSelection.Value.mEndPos + int32(ofs), 0, mData.mTextLength + 1);
} }
mCursorTextPos = (isCaretAtStartPos) CurCursorTextPos = (isCaretAtStartPos)
? mSelection.Value.mStartPos ? CurSelection.Value.mStartPos
: mSelection.Value.mEndPos; : CurSelection.Value.mEndPos;
} }
else else
if (((ofs > 0) && (CursorTextPos > index)) || if (((ofs > 0) && (CursorTextPos > index)) ||
((ofs < 0) && (CursorTextPos >= index - ofs))) ((ofs < 0) && (CursorTextPos >= index - ofs)))
{ {
mCursorTextPos = Math.Clamp(mCursorTextPos + int32(ofs), 0, mData.mTextLength + 1); CurCursorTextPos = Math.Clamp(CurCursorTextPos + int32(ofs), 0, mData.mTextLength + 1);
if (mVirtualCursorPos.HasValue) if (CurVirtualCursorPos.HasValue)
mVirtualCursorPos = LineAndColumn(mVirtualCursorPos.Value.mLine + lineOfs, mVirtualCursorPos.Value.mColumn); CurVirtualCursorPos = LineAndColumn(CurVirtualCursorPos.Value.mLine + lineOfs, CurVirtualCursorPos.Value.mColumn);
} }
if (mSelection.HasValue && mSelection.Value.mStartPos == mSelection.Value.mEndPos) if (CurSelection.HasValue && CurSelection.Value.mStartPos == CurSelection.Value.mEndPos)
mSelection = null; CurSelection = null;
} }
else else
{ {
int cursorPos = CursorTextPos; int cursorPos = CursorTextPos;
if (cursorPos >= index) if (cursorPos >= index)
CursorTextPos = Math.Clamp(mCursorTextPos + (int32)ofs, 0, mData.mTextLength + 1); CursorTextPos = Math.Clamp(CurCursorTextPos + (int32)ofs, 0, mData.mTextLength + 1);
if (HasSelection()) if (HasSelection())
{ {
if (((ofs > 0) && (mSelection.Value.mStartPos >= index)) || if (((ofs > 0) && (CurSelection.Value.mStartPos >= index)) ||
((ofs < 0) && (mSelection.Value.mStartPos > index))) ((ofs < 0) && (CurSelection.Value.mStartPos > index)))
mSelection.ValueRef.mStartPos += (int32)ofs; CurSelection.ValueRef.mStartPos += (int32)ofs;
if (mSelection.Value.mEndPos > index) if (CurSelection.Value.mEndPos > index)
mSelection.ValueRef.mEndPos += (int32)ofs; CurSelection.ValueRef.mEndPos += (int32)ofs;
} }
} }
} }
@ -1530,7 +1534,7 @@ namespace Beefy.widgets
Debug.Assert(!theString.StartsWith("\x06")); Debug.Assert(!theString.StartsWith("\x06"));
if ((!HasSelection()) && (mVirtualCursorPos.HasValue) && (theString != "\n")) if ((!HasSelection()) && (CurVirtualCursorPos.HasValue) && (theString != "\n"))
{ {
int textPos; int textPos;
TryGetCursorTextPos(out textPos); TryGetCursorTextPos(out textPos);
@ -1545,7 +1549,7 @@ namespace Beefy.widgets
float cursorX; float cursorX;
float cursorY; float cursorY;
GetTextCoordAtLineAndColumn(mVirtualCursorPos.Value.mLine, mVirtualCursorPos.Value.mColumn, out cursorX, out cursorY); GetTextCoordAtLineAndColumn(CurVirtualCursorPos.Value.mLine, CurVirtualCursorPos.Value.mColumn, out cursorX, out cursorY);
if (cursorX > textX) if (cursorX > textX)
{ {
@ -1625,13 +1629,13 @@ namespace Beefy.widgets
public virtual void ClampCursor() public virtual void ClampCursor()
{ {
if (mVirtualCursorPos.HasValue) if (CurVirtualCursorPos.HasValue)
{ {
var cursorPos = mVirtualCursorPos.Value; var cursorPos = CurVirtualCursorPos.Value;
cursorPos.mLine = Math.Min(GetLineCount() - 1, cursorPos.mLine); cursorPos.mLine = Math.Min(GetLineCount() - 1, cursorPos.mLine);
mVirtualCursorPos = cursorPos; CurVirtualCursorPos = cursorPos;
} }
mCursorTextPos = Math.Min(mCursorTextPos, mData.mTextLength); CurCursorTextPos = Math.Min(CurCursorTextPos, mData.mTextLength);
} }
public virtual void ContentChanged() public virtual void ContentChanged()
@ -1768,10 +1772,10 @@ namespace Beefy.widgets
public virtual void Backspace() public virtual void Backspace()
{ {
if (mJustInsertedCharPair) if (CurJustInsertedCharPair)
{ {
CursorTextPos++; CursorTextPos++;
mJustInsertedCharPair = false; CurJustInsertedCharPair = false;
} }
if (HasSelection()) if (HasSelection())
@ -1779,7 +1783,7 @@ namespace Beefy.widgets
DeleteSelection(); DeleteSelection();
return; return;
} }
mSelection = null; CurSelection = null;
int textPos = 0; int textPos = 0;
if (!TryGetCursorTextPos(out textPos)) if (!TryGetCursorTextPos(out textPos))
@ -1816,7 +1820,7 @@ namespace Beefy.widgets
// Roll back past UTF8 data if necessary // Roll back past UTF8 data if necessary
while (true) while (true)
{ {
char8 c = mData.SafeGetChar(mCursorTextPos + removeNum); char8 c = mData.SafeGetChar(CurCursorTextPos + removeNum);
if ((uint8)c & 0xC0 != 0x80) if ((uint8)c & 0xC0 != 0x80)
break; break;
removeNum--; removeNum--;
@ -1851,9 +1855,9 @@ namespace Beefy.widgets
var prevCursorLineAndCol = CursorLineAndColumn; var prevCursorLineAndCol = CursorLineAndColumn;
mSelection = EditSelection(); CurSelection = EditSelection();
mSelection.ValueRef.mStartPos = (int32)(CursorTextPos - lineChar); CurSelection.ValueRef.mStartPos = (int32)(CursorTextPos - lineChar);
mSelection.ValueRef.mEndPos = mSelection.Value.mStartPos + (int32)lineText.Length; CurSelection.ValueRef.mEndPos = CurSelection.Value.mStartPos + (int32)lineText.Length;
DeleteSelection(); DeleteSelection();
CursorLineAndColumn = prevCursorLineAndCol; CursorLineAndColumn = prevCursorLineAndCol;
@ -1870,9 +1874,9 @@ namespace Beefy.widgets
var prevCursorLineAndCol = CursorLineAndColumn; var prevCursorLineAndCol = CursorLineAndColumn;
mSelection = EditSelection(); CurSelection = EditSelection();
mSelection.ValueRef.mStartPos = (int32)(CursorTextPos - lineChar); CurSelection.ValueRef.mStartPos = (int32)(CursorTextPos - lineChar);
mSelection.ValueRef.mEndPos = mSelection.ValueRef.mStartPos + (int32)lineText.Length + 1; CurSelection.ValueRef.mEndPos = CurSelection.ValueRef.mStartPos + (int32)lineText.Length + 1;
DeleteSelection(); DeleteSelection();
CursorLineAndColumn = prevCursorLineAndCol; CursorLineAndColumn = prevCursorLineAndCol;
@ -1885,13 +1889,13 @@ namespace Beefy.widgets
public virtual void DeleteChar() public virtual void DeleteChar()
{ {
mJustInsertedCharPair = false; CurJustInsertedCharPair = false;
if (HasSelection()) if (HasSelection())
{ {
DeleteSelection(); DeleteSelection();
return; return;
} }
mSelection = null; CurSelection = null;
int textPos = CursorTextPos; int textPos = CursorTextPos;
if (textPos >= mData.mTextLength) if (textPos >= mData.mTextLength)
@ -1998,7 +2002,7 @@ namespace Beefy.widgets
return; return;
InsertAtCursor(charPair); InsertAtCursor(charPair);
MoveCursorToIdx(CursorTextPos - 1, false, .FromTyping); MoveCursorToIdx(CursorTextPos - 1, false, .FromTyping);
mJustInsertedCharPair = true; CurJustInsertedCharPair = true;
} }
public virtual bool WantsInsertCharPair(char8 theChar) public virtual bool WantsInsertCharPair(char8 theChar)
@ -2026,7 +2030,7 @@ namespace Beefy.widgets
int startIdx = CursorTextPos; int startIdx = CursorTextPos;
SelectLeft(line, lineChar, true, false); SelectLeft(line, lineChar, true, false);
mSelection = EditSelection(CursorTextPos, startIdx); CurSelection = EditSelection(CursorTextPos, startIdx);
var action = new DeleteSelectionAction(this); var action = new DeleteSelectionAction(this);
action.mMoveCursor = true; action.mMoveCursor = true;
@ -2120,7 +2124,7 @@ namespace Beefy.widgets
return; return;
} }
mJustInsertedCharPair = false; CurJustInsertedCharPair = false;
switch (useChar) switch (useChar)
{ {
@ -2204,7 +2208,7 @@ namespace Beefy.widgets
char8 c = (char8)mData.mText[cursorPos].mChar; char8 c = (char8)mData.mText[cursorPos].mChar;
if ((c != '\n') && (c != '\r')) if ((c != '\n') && (c != '\r'))
{ {
mSelection = EditSelection(cursorPos, cursorPos + 1); CurSelection = EditSelection(cursorPos, cursorPos + 1);
restoreSelectionOnUndo = false; restoreSelectionOnUndo = false;
} }
} }
@ -2216,7 +2220,7 @@ namespace Beefy.widgets
} }
} }
mCursorImplicitlyMoved = true; CurCursorImplicitlyMoved = true;
} }
public virtual float GetPageScrollTextHeight() public virtual float GetPageScrollTextHeight()
@ -2258,32 +2262,32 @@ namespace Beefy.widgets
public virtual void GetTextCoordAtCursor(out float x, out float y) public virtual void GetTextCoordAtCursor(out float x, out float y)
{ {
if (mVirtualCursorPos.HasValue) if (CurVirtualCursorPos.HasValue)
{ {
GetTextCoordAtLineAndColumn(mVirtualCursorPos.Value.mLine, mVirtualCursorPos.Value.mColumn, out x, out y); GetTextCoordAtLineAndColumn(CurVirtualCursorPos.Value.mLine, CurVirtualCursorPos.Value.mColumn, out x, out y);
} }
else else
{ {
int line; int line;
int lineChar; int lineChar;
GetLineCharAtIdx(mCursorTextPos, out line, out lineChar); GetLineCharAtIdx(CurCursorTextPos, out line, out lineChar);
GetTextCoordAtLineChar(line, lineChar, out x, out y); GetTextCoordAtLineChar(line, lineChar, out x, out y);
} }
} }
public bool GetCursorLineChar(out int line, out int lineChar) public bool GetCursorLineChar(out int line, out int lineChar)
{ {
if (mVirtualCursorPos == null) if (CurVirtualCursorPos == null)
{ {
GetLineCharAtIdx_Fast(mCursorTextPos, true, out line, out lineChar); GetLineCharAtIdx_Fast(CurCursorTextPos, true, out line, out lineChar);
return true; return true;
} }
line = mVirtualCursorPos.Value.mLine; line = CurVirtualCursorPos.Value.mLine;
float x; float x;
float y; float y;
GetTextCoordAtLineAndColumn(mVirtualCursorPos.Value.mLine, mVirtualCursorPos.Value.mColumn, out x, out y); GetTextCoordAtLineAndColumn(CurVirtualCursorPos.Value.mLine, CurVirtualCursorPos.Value.mColumn, out x, out y);
float overflowX; float overflowX;
@ -2294,14 +2298,14 @@ namespace Beefy.widgets
{ {
if (mWidgetWindow.IsKeyDown(KeyCode.Shift)) if (mWidgetWindow.IsKeyDown(KeyCode.Shift))
return false; return false;
if ((mSelection == null) || (!mSelection.Value.HasSelection)) if ((CurSelection == null) || (!CurSelection.Value.HasSelection))
return false; return false;
if (dir < 0) if (dir < 0)
CursorTextPos = mSelection.Value.MinPos; CursorTextPos = CurSelection.Value.MinPos;
else if (dir > 0) else if (dir > 0)
CursorTextPos = mSelection.Value.MaxPos; CursorTextPos = CurSelection.Value.MaxPos;
mSelection = null; CurSelection = null;
return true; return true;
} }
@ -2371,7 +2375,7 @@ namespace Beefy.widgets
} }
else else
{ {
mSelection = selection = GetAsSelection(cursor, true); CurSelection = selection = GetAsSelection(cursor, true);
} }
// ... // ...
@ -2505,11 +2509,11 @@ namespace Beefy.widgets
} }
GetLinePosition(CursorLineAndColumn.mLine, var lineStart, var lineEnd); GetLinePosition(CursorLineAndColumn.mLine, var lineStart, var lineEnd);
mSelection = .(lineStart, lineEnd); CurSelection = .(lineStart, lineEnd);
if (mSelection.Value.mEndPos < mData.mTextLength) if (CurSelection.Value.mEndPos < mData.mTextLength)
mSelection.ValueRef.mEndPos++; CurSelection.ValueRef.mEndPos++;
DeleteSelection(); DeleteSelection();
mSelection = null; CurSelection = null;
sortedCursors.Remove(cursor); sortedCursors.Remove(cursor);
if (sortedCursors.Count == 0) if (sortedCursors.Count == 0)
@ -2612,7 +2616,7 @@ namespace Beefy.widgets
if (secondary.mCursorTextPos > 0) if (secondary.mCursorTextPos > 0)
secondary.mCursorTextPos--; secondary.mCursorTextPos--;
} }
else if ((mCursorTextPos > 0) && (idx + 1 != fragments.Count)) else if ((CurCursorTextPos > 0) && (idx + 1 != fragments.Count))
{ {
CursorTextPos--; CursorTextPos--;
} }
@ -2695,11 +2699,11 @@ namespace Beefy.widgets
MoveCursorTo(lineIdx, lineChar - 1, false, 0, .SelectLeft); MoveCursorTo(lineIdx, lineChar - 1, false, 0, .SelectLeft);
else if (lineIdx > 0) else if (lineIdx > 0)
{ {
int cursorIdx = mCursorTextPos; int cursorIdx = CurCursorTextPos;
String lineText = scope String(); String lineText = scope String();
GetLineText(lineIdx - 1, lineText); GetLineText(lineIdx - 1, lineText);
MoveCursorTo(lineIdx - 1, (int32)lineText.Length, false, 0, .SelectLeft); MoveCursorTo(lineIdx - 1, (int32)lineText.Length, false, 0, .SelectLeft);
if ((!mAllowVirtualCursor) && (cursorIdx == mCursorTextPos)) if ((!mAllowVirtualCursor) && (cursorIdx == CurCursorTextPos))
MoveCursorTo(lineIdx - 1, (int32)lineText.Length - 1, false, 0, .SelectLeft); MoveCursorTo(lineIdx - 1, (int32)lineText.Length - 1, false, 0, .SelectLeft);
break; break;
} }
@ -2930,7 +2934,7 @@ namespace Beefy.widgets
if (doVirtualMove) if (doVirtualMove)
{ {
mCursorBlinkTicks = 0; mCursorBlinkTicks = 0;
mSelection = null; CurSelection = null;
var lineAndColumn = CursorLineAndColumn; var lineAndColumn = CursorLineAndColumn;
CursorLineAndColumn = LineAndColumn(lineAndColumn.mLine, lineAndColumn.mColumn + 1); CursorLineAndColumn = LineAndColumn(lineAndColumn.mLine, lineAndColumn.mColumn + 1);
EnsureCursorVisible(true, false, false); EnsureCursorVisible(true, false, false);
@ -2957,10 +2961,10 @@ namespace Beefy.widgets
if (mAllowVirtualCursor) if (mAllowVirtualCursor)
{ {
var lineAndCol = CursorLineAndColumn; var lineAndCol = CursorLineAndColumn;
var usePos = (aDir < 0) ? (int32)mSelection.Value.MinPos : mSelection.Value.MaxPos; var usePos = (aDir < 0) ? (int32)CurSelection.Value.MinPos : CurSelection.Value.MaxPos;
GetLineCharAtIdx(usePos, var selLine, var selLineChar); GetLineCharAtIdx(usePos, var selLine, var selLineChar);
CursorLineAndColumn = .(selLine, lineAndCol.mColumn); CursorLineAndColumn = .(selLine, lineAndCol.mColumn);
mSelection = null; CurSelection = null;
} }
else else
PrepareForCursorMove(aDir); PrepareForCursorMove(aDir);
@ -3137,7 +3141,7 @@ namespace Beefy.widgets
{ {
int startIdx = CursorTextPos; int startIdx = CursorTextPos;
CursorToLineEnd(); CursorToLineEnd();
mSelection = EditSelection(CursorTextPos, startIdx); CurSelection = EditSelection(CursorTextPos, startIdx);
var action = new DeleteSelectionAction(this); var action = new DeleteSelectionAction(this);
action.mMoveCursor = true; action.mMoveCursor = true;
mData.mUndoManager.Add(action); mData.mUndoManager.Add(action);
@ -3152,7 +3156,7 @@ namespace Beefy.widgets
int startIdx = CursorTextPos; int startIdx = CursorTextPos;
SelectRight(line, lineChar, true, false); SelectRight(line, lineChar, true, false);
mSelection = EditSelection(CursorTextPos, startIdx); CurSelection = EditSelection(CursorTextPos, startIdx);
var action = new DeleteSelectionAction(this); var action = new DeleteSelectionAction(this);
action.mMoveCursor = true; action.mMoveCursor = true;
@ -3174,7 +3178,7 @@ namespace Beefy.widgets
CreateMultiCursorUndoBatch("EWC.KeyDown(DeleteChar)"); CreateMultiCursorUndoBatch("EWC.KeyDown(DeleteChar)");
DeleteChar(); DeleteChar();
} }
mCursorImplicitlyMoved = true; CurCursorImplicitlyMoved = true;
break; break;
default: default:
} }
@ -3186,12 +3190,12 @@ namespace Beefy.widgets
if (!HasSelection()) if (!HasSelection())
{ {
StartSelection(); StartSelection();
mSelection.ValueRef.mStartPos = (int32)prevCursorPos; CurSelection.ValueRef.mStartPos = (int32)prevCursorPos;
} }
SelectToCursor(); SelectToCursor();
} }
else else
mSelection = null; CurSelection = null;
EnsureCursorVisible(); EnsureCursorVisible();
} }
@ -3220,7 +3224,7 @@ namespace Beefy.widgets
public override void Update() public override void Update()
{ {
Debug.Assert((mCursorTextPos != -1) || (mVirtualCursorPos != null)); Debug.Assert((CurCursorTextPos != -1) || (CurVirtualCursorPos != null));
base.Update(); base.Update();
if (mContentChanged) if (mContentChanged)
@ -3370,7 +3374,7 @@ namespace Beefy.widgets
{ {
int32 lineStart = mData.mLineStarts[lineIdx]; int32 lineStart = mData.mLineStarts[lineIdx];
if ((idx < lineStart) || ((idx == lineStart) && (lineIdx > 0) && (mCursorTextPos == lineStart) && (mShowCursorAtLineEnd))) if ((idx < lineStart) || ((idx == lineStart) && (lineIdx > 0) && (CurCursorTextPos == lineStart) && (mShowCursorAtLineEnd)))
{ {
line = lineIdx - 1; line = lineIdx - 1;
theChar = idx - mData.mLineStarts[lineIdx - 1]; theChar = idx - mData.mLineStarts[lineIdx - 1];
@ -3526,10 +3530,10 @@ namespace Beefy.widgets
// so what was that for? // so what was that for?
public virtual void PhysCursorMoved(CursorMoveKind moveKind) public virtual void PhysCursorMoved(CursorMoveKind moveKind)
{ {
mJustInsertedCharPair = false; CurJustInsertedCharPair = false;
mShowCursorAtLineEnd = false; mShowCursorAtLineEnd = false;
mCursorBlinkTicks = 0; mCursorBlinkTicks = 0;
mCursorImplicitlyMoved = false; CurCursorImplicitlyMoved = false;
// //
ResetWantX(); ResetWantX();
@ -3609,10 +3613,10 @@ namespace Beefy.widgets
public void StartSelection() public void StartSelection()
{ {
mDragSelectionKind = .Dragging; mDragSelectionKind = .Dragging;
mSelection = EditSelection(); CurSelection = EditSelection();
int textPos; int textPos;
TryGetCursorTextPos(out textPos); TryGetCursorTextPos(out textPos);
mSelection.ValueRef.mEndPos = mSelection.ValueRef.mStartPos = (int32)textPos; CurSelection.ValueRef.mEndPos = CurSelection.ValueRef.mStartPos = (int32)textPos;
} }
public void SelectToCursor() public void SelectToCursor()
@ -3629,35 +3633,35 @@ namespace Beefy.widgets
if (mDragSelectionUnion != null) if (mDragSelectionUnion != null)
{ {
mSelection = EditSelection(mDragSelectionUnion.Value.MinPos, mDragSelectionUnion.Value.MaxPos); CurSelection = EditSelection(mDragSelectionUnion.Value.MinPos, mDragSelectionUnion.Value.MaxPos);
if (textPos <= mSelection.Value.mStartPos) if (textPos <= CurSelection.Value.mStartPos)
{ {
mSelection.ValueRef.mStartPos = (int32)Math.Max(0, textPos - 1); CurSelection.ValueRef.mStartPos = (int32)Math.Max(0, textPos - 1);
while ((textPos > 0) && (IsNonBreakingChar((char8)mData.mText[textPos - 1].mChar))) while ((textPos > 0) && (IsNonBreakingChar((char8)mData.mText[textPos - 1].mChar)))
{ {
textPos--; textPos--;
mSelection.ValueRef.mStartPos = (int32)textPos; CurSelection.ValueRef.mStartPos = (int32)textPos;
} }
CursorTextPos = mSelection.Value.mStartPos; CursorTextPos = CurSelection.Value.mStartPos;
} }
else else
{ {
if (textPos > mSelection.Value.mEndPos) if (textPos > CurSelection.Value.mEndPos)
{ {
mSelection.ValueRef.mEndPos = (int32)textPos; CurSelection.ValueRef.mEndPos = (int32)textPos;
while ((textPos <= mData.mTextLength) && ((textPos == mData.mTextLength) || (mData.mText[textPos - 1].mChar != '\n')) && while ((textPos <= mData.mTextLength) && ((textPos == mData.mTextLength) || (mData.mText[textPos - 1].mChar != '\n')) &&
(IsNonBreakingChar((char8)mData.mText[textPos - 1].mChar))) (IsNonBreakingChar((char8)mData.mText[textPos - 1].mChar)))
{ {
mSelection.ValueRef.mEndPos = (int32)textPos; CurSelection.ValueRef.mEndPos = (int32)textPos;
textPos++; textPos++;
} }
} }
CursorTextPos = mSelection.Value.mEndPos; CursorTextPos = CurSelection.Value.mEndPos;
} }
} }
else if (mSelection != null) else if (CurSelection != null)
{ {
mSelection.ValueRef.mEndPos = (int32)textPos; CurSelection.ValueRef.mEndPos = (int32)textPos;
} }
} }
@ -3802,18 +3806,18 @@ namespace Beefy.widgets
bool isMultilineSelection = HasSelection(); bool isMultilineSelection = HasSelection();
if (isMultilineSelection) if (isMultilineSelection)
{ {
GetLineCharAtIdx(mSelection.Value.MinPos, out minLineIdx, out minLineCharIdx); GetLineCharAtIdx(CurSelection.Value.MinPos, out minLineIdx, out minLineCharIdx);
GetLineCharAtIdx(mSelection.Value.MaxPos, out maxLineIdx, out maxLineCharIdx); GetLineCharAtIdx(CurSelection.Value.MaxPos, out maxLineIdx, out maxLineCharIdx);
isMultilineSelection = maxLineIdx != minLineIdx; isMultilineSelection = maxLineIdx != minLineIdx;
} }
if (isMultilineSelection) if (isMultilineSelection)
{ {
var indentTextAction = new EditWidgetContent.IndentTextAction(this); var indentTextAction = new EditWidgetContent.IndentTextAction(this);
EditSelection newSel = mSelection.Value; EditSelection newSel = CurSelection.Value;
mSelection.ValueRef.MakeForwardSelect(); CurSelection.ValueRef.MakeForwardSelect();
mSelection.ValueRef.mStartPos -= (int32)minLineCharIdx; CurSelection.ValueRef.mStartPos -= (int32)minLineCharIdx;
//int32 minPos = newSel.MinPos; //int32 minPos = newSel.MinPos;
int32 startAdjust = 0; int32 startAdjust = 0;
@ -3902,7 +3906,7 @@ namespace Beefy.widgets
else else
delete indentTextAction; delete indentTextAction;
mSelection = newSel; CurSelection = newSel;
return; return;
} }
else // Non-block else // Non-block
@ -3913,8 +3917,8 @@ namespace Beefy.widgets
if (unIndent) if (unIndent)
{ {
var prevSelection = mSelection; var prevSelection = CurSelection;
mSelection = null; CurSelection = null;
if (lineCharIdx > 0) if (lineCharIdx > 0)
{ {
@ -3945,7 +3949,7 @@ namespace Beefy.widgets
CursorLineAndColumn = cursorPos; CursorLineAndColumn = cursorPos;
} }
mSelection = prevSelection; CurSelection = prevSelection;
return; return;
} }
@ -4005,12 +4009,12 @@ namespace Beefy.widgets
ExtractString(lineStart, CursorTextPos - lineStart, str); ExtractString(lineStart, CursorTextPos - lineStart, str);
if (str.IsWhiteSpace) if (str.IsWhiteSpace)
{ {
let prevSelection = mSelection.Value; let prevSelection = CurSelection.Value;
mSelection = null; CurSelection = null;
for (int32 i = 0; i < indentCount; i++) for (int32 i = 0; i < indentCount; i++)
InsertAtCursor(GetTabString(.. scope .())); InsertAtCursor(GetTabString(.. scope .()));
GetLinePosition(minLineIdx, out lineStart, out lineEnd); GetLinePosition(minLineIdx, out lineStart, out lineEnd);
mSelection = EditSelection(prevSelection.mStartPos + indentCount, prevSelection.mEndPos + indentCount); CurSelection = EditSelection(prevSelection.mStartPos + indentCount, prevSelection.mEndPos + indentCount);
} }
else else
InsertAtCursor(GetTabString(.. scope .())); InsertAtCursor(GetTabString(.. scope .()));
@ -4028,7 +4032,7 @@ namespace Beefy.widgets
StartSelection(); StartSelection();
CursorToEnd(); CursorToEnd();
SelectToCursor(); SelectToCursor();
Debug.Assert(mSelection.Value.mEndPos <= mData.mTextLength); Debug.Assert(CurSelection.Value.mEndPos <= mData.mTextLength);
} }
public virtual void GetLineAndColumnAtLineChar(int line, int lineChar, out int lineColumn) public virtual void GetLineAndColumnAtLineChar(int line, int lineChar, out int lineColumn)
@ -4063,12 +4067,12 @@ namespace Beefy.widgets
// Skip over UTF8 parts AND unicode combining marks (ie: when we have a letter with an accent mark following it) // Skip over UTF8 parts AND unicode combining marks (ie: when we have a letter with an accent mark following it)
while (true) while (true)
{ {
char8 c = mData.SafeGetChar(mCursorTextPos); char8 c = mData.SafeGetChar(CurCursorTextPos);
if (c < (char8)0x80) if (c < (char8)0x80)
break; break;
if ((uint8)c & 0xC0 != 0x80) if ((uint8)c & 0xC0 != 0x80)
{ {
var checkChar = mData.GetChar32(mCursorTextPos); var checkChar = mData.GetChar32(CurCursorTextPos);
if (!checkChar.IsCombiningMark) if (!checkChar.IsCombiningMark)
break; break;
} }
@ -4081,14 +4085,14 @@ namespace Beefy.widgets
} }
useCharIdx++; useCharIdx++;
mCursorTextPos++; CurCursorTextPos++;
} }
else else
{ {
if (mCursorTextPos == 0) if (CurCursorTextPos == 0)
break; break;
useCharIdx--; useCharIdx--;
mCursorTextPos--; CurCursorTextPos--;
} }
} }
@ -4151,7 +4155,7 @@ namespace Beefy.widgets
public bool HasSelection() public bool HasSelection()
{ {
return (mSelection != null) && (mSelection.Value.HasSelection); return (CurSelection != null) && (CurSelection.Value.HasSelection);
} }
public override void RehupScale(float oldScale, float newScale) public override void RehupScale(float oldScale, float newScale)
@ -4190,14 +4194,12 @@ namespace Beefy.widgets
} }
} }
[Inline]
public void SetTextCursor(TextCursor cursor) public void SetTextCursor(TextCursor cursor)
{ {
Debug.Assert(cursor != null); Debug.Assert(cursor != null);
mCurrentTextCursor = cursor; mCurrentTextCursor = cursor;
} }
[Inline]
public bool IsPrimaryTextCursor() public bool IsPrimaryTextCursor()
{ {
return (mCurrentTextCursor.mId == 0); return (mCurrentTextCursor.mId == 0);
@ -4224,7 +4226,6 @@ namespace Beefy.widgets
mCurrentTextCursor = cursor; mCurrentTextCursor = cursor;
} }
[Inline]
public void SetPrimaryTextCursor() public void SetPrimaryTextCursor()
{ {
Debug.Assert((mTextCursors.Count > 0) && (mTextCursors.Front.mId == 0)); Debug.Assert((mTextCursors.Count > 0) && (mTextCursors.Front.mId == 0));
@ -4349,18 +4350,21 @@ namespace Beefy.widgets
return !((lhsSelection.mEndPos <= rhsSelection.mStartPos) || (rhsSelection.mEndPos <= lhsSelection.mStartPos)); return !((lhsSelection.mEndPos <= rhsSelection.mStartPos) || (rhsSelection.mEndPos <= lhsSelection.mStartPos));
} }
public void SelectNextMatch(bool createCursor = true, bool exhaustiveSearch = false) public void AddSelectionToNextFindMatch(bool createCursor = true, bool exhaustiveSearch = false)
{ {
SetPrimaryTextCursor(); SetPrimaryTextCursor();
if (!HasSelection()) if (!HasSelection())
{
SelectWord();
return; return;
}
mJustInsertedCharPair = false; CurJustInsertedCharPair = false;
mCursorImplicitlyMoved = false; CurCursorImplicitlyMoved = false;
var text = scope String(); var text = scope String();
ExtractString(mSelection.Value.MinPos, mSelection.Value.Length, text); ExtractString(CurSelection.Value.MinPos, CurSelection.Value.Length, text);
bool Matches(int startPos) bool Matches(int startPos)
{ {
@ -4377,25 +4381,9 @@ namespace Beefy.widgets
return true; return true;
} }
bool IsSelectionExists(int startPos, int endPos, out TextCursor textCursor) var lastCursor = mTextCursors.Back;
{ var startPos = lastCursor.mSelection.Value.MaxPos;
textCursor = null; //var startPos = mSelection.Value.MaxPos;
for (var cursor in mTextCursors)
{
if (!cursor.mSelection.HasValue)
continue;
if ((cursor.mSelection.Value.MinPos == startPos) && (cursor.mSelection.Value.MaxPos == endPos))
{
textCursor = cursor;
return true;
}
}
return false;
}
var startPos = mSelection.Value.MaxPos;
var endPos = (int)mData.mTextLength; var endPos = (int)mData.mTextLength;
var found = false; var found = false;
@ -4406,30 +4394,19 @@ namespace Beefy.widgets
if (!Matches(idx)) if (!Matches(idx))
continue; continue;
if (IsSelectionExists(idx, idx + text.Length, var cursor))
{
Swap!(mSelection, cursor.mSelection);
Swap!(mCursorTextPos, cursor.mCursorTextPos);
EnsureCursorVisible();
if (!createCursor)
{
mTextCursors.Remove(cursor);
delete cursor;
}
return;
}
if (createCursor) if (createCursor)
mTextCursors.Add(new TextCursor(-1, mCurrentTextCursor)); mTextCursors.Add(new TextCursor(-1, mCurrentTextCursor));
SetTextCursor(mTextCursors.Back);
// Making selection consistent across all cursors // Making selection consistent across all cursors
mSelection = (mSelection.Value.IsForwardSelect) CurSelection = (CurSelection.Value.IsForwardSelect)
? EditSelection(idx, idx+text.Length) ? EditSelection(idx, idx+text.Length)
: EditSelection(idx+text.Length, idx); : EditSelection(idx+text.Length, idx);
mCursorTextPos = mSelection.Value.mEndPos; CurCursorTextPos = CurSelection.Value.mEndPos;
mVirtualCursorPos = null; CurVirtualCursorPos = null;
SetPrimaryTextCursor();
if (!exhaustiveSearch) if (!exhaustiveSearch)
{ {
@ -4451,9 +4428,9 @@ namespace Beefy.widgets
} }
} }
public void SkipCurrentMatchAndSelectNext() public void MoveLastSelectionToNextFindMatch()
{ {
SelectNextMatch(createCursor: false); AddSelectionToNextFindMatch(createCursor: false);
} }
} }

View file

@ -340,8 +340,8 @@ namespace IDE
Add("Zoom Out", new => gApp.Cmd_ZoomOut); Add("Zoom Out", new => gApp.Cmd_ZoomOut);
Add("Zoom Reset", new => gApp.Cmd_ZoomReset); Add("Zoom Reset", new => gApp.Cmd_ZoomReset);
Add("Attach to Process", new => gApp.[Friend]DoAttach); Add("Attach to Process", new => gApp.[Friend]DoAttach);
Add("Select Next Match", new => gApp.Cmd_SelectNextMatch); Add("Add Selection to Next Find Match", new => gApp.Cmd_AddSelectionToNextFindMatch);
Add("Skip Current Match and Select Next", new => gApp.Cmd_SkipCurrentMatchAndSelectNext); Add("Move Last Selection to Next Find Match", new => gApp.Cmd_MoveLastSelectionToNextFindMatch);
Add("Test Enable Console", new => gApp.Cmd_TestEnableConsole); Add("Test Enable Console", new => gApp.Cmd_TestEnableConsole);
} }

View file

@ -5963,15 +5963,15 @@ namespace IDE
} }
[IDECommand] [IDECommand]
public void Cmd_SelectNextMatch() public void Cmd_AddSelectionToNextFindMatch()
{ {
GetActiveSourceEditWidgetContent()?.SelectNextMatch(); GetActiveSourceEditWidgetContent()?.AddSelectionToNextFindMatch();
} }
[IDECommand] [IDECommand]
public void Cmd_SkipCurrentMatchAndSelectNext() public void Cmd_MoveLastSelectionToNextFindMatch()
{ {
GetActiveSourceEditWidgetContent()?.SkipCurrentMatchAndSelectNext(); GetActiveSourceEditWidgetContent()?.MoveLastSelectionToNextFindMatch();
} }
public void UpdateMenuItem_HasActivePanel(IMenu menu) public void UpdateMenuItem_HasActivePanel(IMenu menu)
@ -8799,7 +8799,7 @@ namespace IDE
c = c.ToLower; c = c.ToLower;
}*/ }*/
var prevSel = ewc.mSelection.Value; var prevSel = ewc.CurSelection.Value;
var str = scope String(); var str = scope String();
ewc.GetSelectionText(str); ewc.GetSelectionText(str);
@ -8818,7 +8818,7 @@ namespace IDE
ewc.CreateMultiCursorUndoBatch("IDEApp.ChangeCase()"); ewc.CreateMultiCursorUndoBatch("IDEApp.ChangeCase()");
ewc.InsertAtCursor(str); ewc.InsertAtCursor(str);
ewc.mSelection = prevSel; ewc.CurSelection = prevSel;
} }
ewc.CloseMultiCursorUndoBatch(); ewc.CloseMultiCursorUndoBatch();
ewc.SetPrimaryTextCursor(); ewc.SetPrimaryTextCursor();

View file

@ -2310,7 +2310,7 @@ namespace IDE
sel.mStartPos = (.)ewc.CursorTextPos; sel.mStartPos = (.)ewc.CursorTextPos;
ewc.CursorLineAndColumn = prevPos; ewc.CursorLineAndColumn = prevPos;
sel.mEndPos = (.)ewc.CursorTextPos; sel.mEndPos = (.)ewc.CursorTextPos;
ewc.mSelection = sel; ewc.CurSelection = sel;
} }
[IDECommand] [IDECommand]
@ -2321,7 +2321,7 @@ namespace IDE
return; return;
var ewc = textPanel.EditWidget.mEditWidgetContent; var ewc = textPanel.EditWidget.mEditWidgetContent;
ewc.mSelection = null; ewc.CurSelection = null;
} }
[IDECommand] [IDECommand]
@ -2429,7 +2429,7 @@ namespace IDE
{ {
var text = ewc.mData.mText; var text = ewc.mData.mText;
ewc.mSelection = EditSelection(startPos, startPos + 1); ewc.CurSelection = EditSelection(startPos, startPos + 1);
ewc.DeleteSelection(); ewc.DeleteSelection();
checkIdx = (.)startPos; checkIdx = (.)startPos;
@ -2443,7 +2443,7 @@ namespace IDE
(text[checkIdx + 3].mChar == '*') && (text[checkIdx + 3].mChar == '*') &&
(text[checkIdx + 4].mChar == '/')) (text[checkIdx + 4].mChar == '/'))
{ {
ewc.mSelection = EditSelection(checkIdx, checkIdx + 3); ewc.CurSelection = EditSelection(checkIdx, checkIdx + 3);
ewc.DeleteSelection(); ewc.DeleteSelection();
break; break;
} }

View file

@ -707,6 +707,7 @@ namespace IDE
public bool mFuzzyAutoComplete = false; public bool mFuzzyAutoComplete = false;
public bool mShowLocatorAnim = true; public bool mShowLocatorAnim = true;
public bool mHiliteCursorReferences = true; public bool mHiliteCursorReferences = true;
public bool mDebugMultiCursor = false;
public bool mHiliteCurrentLine = false; public bool mHiliteCurrentLine = false;
public bool mLockEditing; public bool mLockEditing;
public LockWhileDebuggingKind mLockEditingWhenDebugging = .WhenNotHotSwappable;// Only applicable for public LockWhileDebuggingKind mLockEditingWhenDebugging = .WhenNotHotSwappable;// Only applicable for
@ -858,6 +859,7 @@ namespace IDE
public void SetDefaults() public void SetDefaults()
{ {
Add("Add Selection to Next Find Match", "Ctrl+D");
Add("Autocomplete", "Ctrl+Space"); Add("Autocomplete", "Ctrl+Space");
Add("Bookmark Next", "F2"); Add("Bookmark Next", "F2");
Add("Bookmark Prev", "Shift+F2"); Add("Bookmark Prev", "Shift+F2");
@ -882,7 +884,6 @@ namespace IDE
Add("Comment Lines", "Ctrl+K, Ctrl+/"); Add("Comment Lines", "Ctrl+K, Ctrl+/");
Add("Comment Toggle", "Ctrl+K, Ctrl+T"); Add("Comment Toggle", "Ctrl+K, Ctrl+T");
Add("Debug Comptime", "Alt+F7"); Add("Debug Comptime", "Alt+F7");
Add("Duplicate Line", "Ctrl+D");
Add("Find Class", "Alt+Shift+L"); Add("Find Class", "Alt+Shift+L");
Add("Find in Document", "Ctrl+F"); Add("Find in Document", "Ctrl+F");
Add("Find in Files", "Ctrl+Shift+F"); Add("Find in Files", "Ctrl+Shift+F");
@ -896,6 +897,7 @@ namespace IDE
Add("Make Uppercase", "Ctrl+Shift+U"); Add("Make Uppercase", "Ctrl+Shift+U");
Add("Match Brace Select", "Ctrl+Shift+RBracket"); Add("Match Brace Select", "Ctrl+Shift+RBracket");
Add("Match Brace", "Ctrl+RBracket"); Add("Match Brace", "Ctrl+RBracket");
//Add("Move Last Selection to Next Find Match, "Ctrl+K, Ctrl+D");
Add("Move Line Down", "Alt+Shift+Down"); Add("Move Line Down", "Alt+Shift+Down");
Add("Move Line Up", "Alt+Shift+Up"); Add("Move Line Up", "Alt+Shift+Up");
Add("Move Statement Down", "Ctrl+Shift+Down"); Add("Move Statement Down", "Ctrl+Shift+Down");
@ -1253,6 +1255,7 @@ namespace IDE
{ {
sd.Add("WakaTimeKey", mWakaTimeKey); sd.Add("WakaTimeKey", mWakaTimeKey);
sd.Add("EnableDevMode", mEnableDevMode); sd.Add("EnableDevMode", mEnableDevMode);
sd.Add("DebugMultiCursor", mEditorSettings.mDebugMultiCursor);
} }
using (sd.CreateObject("TutorialsFinished")) using (sd.CreateObject("TutorialsFinished"))
@ -1353,6 +1356,7 @@ namespace IDE
{ {
sd.Get("WakaTimeKey", mWakaTimeKey); sd.Get("WakaTimeKey", mWakaTimeKey);
sd.Get("EnableDevMode", ref mEnableDevMode); sd.Get("EnableDevMode", ref mEnableDevMode);
sd.Get("DebugMultiCursor", ref mEditorSettings.mDebugMultiCursor);
} }
using (sd.Open("TutorialsFinished")) using (sd.Open("TutorialsFinished"))

View file

@ -2834,10 +2834,10 @@ namespace IDE.ui
if (focusChange) if (focusChange)
sourceEditWidgetContent.EnsureCursorVisible(true, true); sourceEditWidgetContent.EnsureCursorVisible(true, true);
sourceEditWidgetContent.mSelection = null; sourceEditWidgetContent.CurSelection = null;
if (fixitLen > 0) if (fixitLen > 0)
{ {
sourceEditWidgetContent.mSelection = EditSelection(fixitIdx, fixitIdx + fixitLen); sourceEditWidgetContent.CurSelection = EditSelection(fixitIdx, fixitIdx + fixitLen);
sourceEditWidgetContent.DeleteSelection(); sourceEditWidgetContent.DeleteSelection();
fixitLen = 0; fixitLen = 0;
} }
@ -3105,8 +3105,8 @@ namespace IDE.ui
if ((prevText.Length > 0) && (insertText == prevText)) if ((prevText.Length > 0) && (insertText == prevText))
continue; continue;
sewc.mSelection = editSelection; sewc.CurSelection = editSelection;
sewc.mCursorTextPos = (int32)editSelection.MaxPos; sewc.CurCursorTextPos = (int32)editSelection.MaxPos;
if (insertText.EndsWith("<>")) if (insertText.EndsWith("<>"))
{ {

View file

@ -86,10 +86,10 @@ namespace IDE.ui
bool isMultiline = false; bool isMultiline = false;
var content = editWidget.mEditWidgetContent; var content = editWidget.mEditWidgetContent;
if (content.mSelection.HasValue) if (content.CurSelection.HasValue)
{ {
int selStart = content.mSelection.Value.MinPos; int selStart = content.CurSelection.Value.MinPos;
int selEnd = content.mSelection.Value.MaxPos; int selEnd = content.CurSelection.Value.MaxPos;
for (int i = selStart; i < selEnd; i++) for (int i = selStart; i < selEnd; i++)
{ {
if (content.mData.mText[i].mChar == '\n') if (content.mData.mText[i].mChar == '\n')

View file

@ -745,7 +745,7 @@ namespace IDE.ui
if (matches) if (matches)
{ {
editWidgetContent.CursorTextPos = i; editWidgetContent.CursorTextPos = i;
editWidgetContent.mSelection = EditSelection(i, i + mSearchOptions.mSearchString.Length); editWidgetContent.CurSelection = EditSelection(i, i + mSearchOptions.mSearchString.Length);
var insertTextAction = new EditWidgetContent.InsertTextAction(editWidgetContent, mSearchOptions.mReplaceString, .None); var insertTextAction = new EditWidgetContent.InsertTextAction(editWidgetContent, mSearchOptions.mReplaceString, .None);
insertTextAction.mMoveCursor = false; insertTextAction.mMoveCursor = false;
editWidgetContent.mData.mUndoManager.Add(insertTextAction); editWidgetContent.mData.mUndoManager.Add(insertTextAction);

View file

@ -69,7 +69,7 @@ namespace IDE.ui
if (isFinal) if (isFinal)
{ {
editWidgetContent.Content.mSelection = null; editWidgetContent.Content.CurSelection = null;
mSourceViewPanel.RecordHistoryLocation(); mSourceViewPanel.RecordHistoryLocation();
} }
else else
@ -77,7 +77,7 @@ namespace IDE.ui
int lineStart; int lineStart;
int lineEnd; int lineEnd;
editWidgetContent.Content.GetLinePosition(line, out lineStart, out lineEnd); editWidgetContent.Content.GetLinePosition(line, out lineStart, out lineEnd);
editWidgetContent.Content.mSelection = EditSelection(lineStart, lineEnd + 1); editWidgetContent.Content.CurSelection = EditSelection(lineStart, lineEnd + 1);
} }
} }
else else
@ -100,7 +100,7 @@ namespace IDE.ui
void Cancel() void Cancel()
{ {
var editWidgetContent = mSourceViewPanel.mEditWidget; var editWidgetContent = mSourceViewPanel.mEditWidget;
editWidgetContent.Content.mSelection = null; editWidgetContent.Content.CurSelection = null;
mSourceViewPanel.mEditWidget.Content.CursorTextPos = mCursorPos; mSourceViewPanel.mEditWidget.Content.CursorTextPos = mCursorPos;
mSourceViewPanel.mEditWidget.mVertPos.Set(mVertPos); mSourceViewPanel.mEditWidget.mVertPos.Set(mVertPos);

View file

@ -91,15 +91,15 @@ namespace IDE.ui
void CheckSelection() void CheckSelection()
{ {
if ((mSelection != null) && (!mSkipCheckSelection)) if ((CurSelection != null) && (!mSkipCheckSelection))
{ {
if ((!IsInsideEntry(mSelection.Value.MinPos) && (IsInsideEntry(mSelection.Value.MaxPos)))) if ((!IsInsideEntry(CurSelection.Value.MinPos) && (IsInsideEntry(CurSelection.Value.MaxPos))))
{ {
var immediateWidget = (ImmediateWidget)mEditWidget; var immediateWidget = (ImmediateWidget)mEditWidget;
mSelection = EditSelection(immediateWidget.mEntryStartPos.mIndex + 1, mSelection.Value.MaxPos); CurSelection = EditSelection(immediateWidget.mEntryStartPos.mIndex + 1, CurSelection.Value.MaxPos);
} }
if ((!IsInsideEntry(mSelection.Value.mStartPos)) || (!IsInsideEntry(mSelection.Value.mEndPos))) if ((!IsInsideEntry(CurSelection.Value.mStartPos)) || (!IsInsideEntry(CurSelection.Value.mEndPos)))
return; return;
} }
} }
@ -122,7 +122,7 @@ namespace IDE.ui
public override void Backspace() public override void Backspace()
{ {
if (!IsInsideEntry(mCursorTextPos - 1)) if (!IsInsideEntry(CurCursorTextPos - 1))
return; return;
base.Backspace(); base.Backspace();
} }
@ -134,9 +134,9 @@ namespace IDE.ui
immediateWidget.mHistoryIdx = -1; immediateWidget.mHistoryIdx = -1;
CheckSelection(); CheckSelection();
if (!IsInsideEntry(mCursorTextPos)) if (!IsInsideEntry(CurCursorTextPos))
{ {
mSelection = null; CurSelection = null;
MoveCursorToIdx(mData.mTextLength); MoveCursorToIdx(mData.mTextLength);
} }
@ -446,7 +446,7 @@ namespace IDE.ui
if (c == '\x7F') // Ctrl+Backspace if (c == '\x7F') // Ctrl+Backspace
{ {
var editWidgetContent = (ImmediateWidgetContent)mEditWidgetContent; var editWidgetContent = (ImmediateWidgetContent)mEditWidgetContent;
if (!editWidgetContent.IsInsideEntry(editWidgetContent.mCursorTextPos - 1)) if (!editWidgetContent.IsInsideEntry(editWidgetContent.CurCursorTextPos - 1))
return; return;
} }
@ -497,7 +497,7 @@ namespace IDE.ui
void SelectEntry() void SelectEntry()
{ {
mEditWidgetContent.mSelection = EditSelection(mEntryStartPos.mIndex + 1, mEditWidgetContent.mData.mTextLength); mEditWidgetContent.CurSelection = EditSelection(mEntryStartPos.mIndex + 1, mEditWidgetContent.mData.mTextLength);
mEditWidgetContent.CursorTextPos = mEntryStartPos.mIndex + 1; mEditWidgetContent.CursorTextPos = mEntryStartPos.mIndex + 1;
} }
@ -688,8 +688,8 @@ namespace IDE.ui
{ {
mEditWidgetContent.AppendText("> "); mEditWidgetContent.AppendText("> ");
mEditWidgetContent.mData.mUndoManager.Clear(); mEditWidgetContent.mData.mUndoManager.Clear();
mEditWidgetContent.mSelection = null; mEditWidgetContent.CurSelection = null;
mEditWidgetContent.mCursorTextPos = mEditWidgetContent.mData.mTextLength; mEditWidgetContent.CurCursorTextPos = mEditWidgetContent.mData.mTextLength;
mEditWidgetContent.mIsReadOnly = false; mEditWidgetContent.mIsReadOnly = false;
mEntryStartPos.mWasDeleted = false; mEntryStartPos.mWasDeleted = false;
mEntryStartPos.mIndex = mEditWidgetContent.mData.mTextLength - 1; mEntryStartPos.mIndex = mEditWidgetContent.mData.mTextLength - 1;
@ -702,8 +702,8 @@ namespace IDE.ui
var subItem1 = listViewItem.GetSubItem(1); var subItem1 = listViewItem.GetSubItem(1);
var content = Content; var content = Content;
let prevSelection = content.mSelection; let prevSelection = content.CurSelection;
defer { content.mSelection = prevSelection; } defer { content.CurSelection = prevSelection; }
int line; int line;
int lineChar; int lineChar;
@ -718,7 +718,7 @@ namespace IDE.ui
replaceStr.Append(" "); replaceStr.Append(" ");
replaceStr.Append(subItem1.Label); replaceStr.Append(subItem1.Label);
content.mSelection = EditSelection(lineStart, lineEnd); content.CurSelection = EditSelection(lineStart, lineEnd);
content.CursorTextPos = lineStart; content.CursorTextPos = lineStart;
content.InsertAtCursor(replaceStr); content.InsertAtCursor(replaceStr);

View file

@ -127,7 +127,7 @@ namespace IDE.ui
public override void FocusForKeyboard() public override void FocusForKeyboard()
{ {
mOutputWidget.mEditWidgetContent.mSelection = null; mOutputWidget.mEditWidgetContent.CurSelection = null;
mOutputWidget.mEditWidgetContent.CursorLineAndColumn = EditWidgetContent.LineAndColumn(mOutputWidget.mEditWidgetContent.GetLineCount() - 1, 0); mOutputWidget.mEditWidgetContent.CursorLineAndColumn = EditWidgetContent.LineAndColumn(mOutputWidget.mEditWidgetContent.GetLineCount() - 1, 0);
mOutputWidget.mEditWidgetContent.EnsureCursorVisible(); mOutputWidget.mEditWidgetContent.EnsureCursorVisible();
} }

View file

@ -30,7 +30,7 @@ namespace IDE.ui
int lineCheck = Math.Max(0, line + lineOfs); int lineCheck = Math.Max(0, line + lineOfs);
GetLinePosition(lineCheck, out lineStart, out lineEnd); GetLinePosition(lineCheck, out lineStart, out lineEnd);
mSelection = EditSelection(lineStart, lineEnd); CurSelection = EditSelection(lineStart, lineEnd);
var selectionText = scope String(); var selectionText = scope String();
GetSelectionText(selectionText); GetSelectionText(selectionText);
@ -223,7 +223,7 @@ namespace IDE.ui
{ {
bool selectLine = lineOfs == 0; bool selectLine = lineOfs == 0;
if (!selectLine) if (!selectLine)
mSelection = null; CurSelection = null;
CursorTextPos = lineStart; CursorTextPos = lineStart;
EnsureCursorVisible(); EnsureCursorVisible();
return true; return true;

View file

@ -2723,7 +2723,7 @@ namespace IDE.ui
int lastDot = str.LastIndexOf('.'); int lastDot = str.LastIndexOf('.');
if (lastDot != -1) if (lastDot != -1)
{ {
mListView.mEditWidget.mEditWidgetContent.mSelection = .(0, lastDot); mListView.mEditWidget.mEditWidgetContent.CurSelection = .(0, lastDot);
mListView.mEditWidget.mEditWidgetContent.CursorTextPos = lastDot; mListView.mEditWidget.mEditWidgetContent.CursorTextPos = lastDot;
} }
} }

View file

@ -120,8 +120,8 @@ namespace IDE.ui
var sourceContent = editWidget.Content as SourceEditWidgetContent; var sourceContent = editWidget.Content as SourceEditWidgetContent;
if (content.HasSelection()) if (content.HasSelection())
{ {
int selStart = content.mSelection.Value.MinPos; int selStart = content.CurSelection.Value.MinPos;
int selEnd = content.mSelection.Value.MaxPos; int selEnd = content.CurSelection.Value.MaxPos;
bool isMultiline = false; bool isMultiline = false;
for (int i = selStart; i < selEnd; i++) for (int i = selStart; i < selEnd; i++)
{ {
@ -154,7 +154,7 @@ namespace IDE.ui
mFindEditWidget.Content.SelectAll(); mFindEditWidget.Content.SelectAll();
} }
content.mSelection = null; content.CurSelection = null;
} }
} }
@ -170,7 +170,7 @@ namespace IDE.ui
mHasNewActiveCursorPos = true; mHasNewActiveCursorPos = true;
mLastActiveCursorPos = (int32)mEditWidget.Content.CursorTextPos; mLastActiveCursorPos = (int32)mEditWidget.Content.CursorTextPos;
if (mEditWidget.Content.HasSelection()) if (mEditWidget.Content.HasSelection())
mLastActiveCursorPos = (int32)mEditWidget.Content.mSelection.Value.MinPos; mLastActiveCursorPos = (int32)mEditWidget.Content.CurSelection.Value.MinPos;
} }
} }
@ -428,7 +428,7 @@ namespace IDE.ui
editWidgetContent.MoveCursorToIdx(mCurFindIdx + (int32)findText.Length, true, .QuickFind); editWidgetContent.MoveCursorToIdx(mCurFindIdx + (int32)findText.Length, true, .QuickFind);
editWidgetContent.mSelection = EditSelection(mCurFindIdx, mCurFindIdx + (int32)findText.Length); editWidgetContent.CurSelection = EditSelection(mCurFindIdx, mCurFindIdx + (int32)findText.Length);
/*for (int32 idx = mCurFindIdx; idx < mCurFindIdx + findText.Length; idx++) /*for (int32 idx = mCurFindIdx; idx < mCurFindIdx + findText.Length; idx++)
{ {
@ -744,10 +744,10 @@ namespace IDE.ui
EditSelection selection = EditSelection(); EditSelection selection = EditSelection();
selection.mStartPos = selStart; selection.mStartPos = selStart;
selection.mEndPos = selEnd + 1; selection.mEndPos = selEnd + 1;
ewc.mSelection = selection; ewc.CurSelection = selection;
} }
else else
selStart = (.)ewc.mSelection.Value.MinPos; selStart = (.)ewc.CurSelection.Value.MinPos;
EditWidgetContent.InsertFlags insertFlags = .NoMoveCursor | .NoRestoreSelectionOnUndo | .IsGroupPart; EditWidgetContent.InsertFlags insertFlags = .NoMoveCursor | .NoRestoreSelectionOnUndo | .IsGroupPart;
if (searchCount == 0) if (searchCount == 0)
insertFlags |= .IsGroupStart; insertFlags |= .IsGroupStart;
@ -851,7 +851,7 @@ namespace IDE.ui
if (mSelectionStart != null) if (mSelectionStart != null)
{ {
if (mSelectionEnd != null) if (mSelectionEnd != null)
sourceContent.mSelection = .(mSelectionStart.mIndex, mSelectionEnd.mIndex); sourceContent.CurSelection = .(mSelectionStart.mIndex, mSelectionEnd.mIndex);
if (sourceContent != null) if (sourceContent != null)
sourceContent.PersistentTextPositions.Remove(mSelectionStart); sourceContent.PersistentTextPositions.Remove(mSelectionStart);
DeleteAndNullify!(mSelectionStart); DeleteAndNullify!(mSelectionStart);

View file

@ -319,7 +319,7 @@ namespace IDE.ui
// then that would have removed the selection anyway so we don't do the full-select in that case // then that would have removed the selection anyway so we don't do the full-select in that case
if (ewc.CursorTextPos == mCursorPos) if (ewc.CursorTextPos == mCursorPos)
{ {
ewc.mSelection = EditSelection(mStartIdx, mEndIdx); ewc.CurSelection = EditSelection(mStartIdx, mEndIdx);
ewc.CursorTextPos = mEndIdx; ewc.CursorTextPos = mEndIdx;
} }
} }
@ -640,7 +640,7 @@ namespace IDE.ui
cursorPositions.Add((int32)sourceEditWidgetContent.CursorTextPos); cursorPositions.Add((int32)sourceEditWidgetContent.CursorTextPos);
} }
var prevSelection = activeSourceEditWidgetContent.mSelection; var prevSelection = activeSourceEditWidgetContent.CurSelection;
for (int sourceIdx = 0; sourceIdx < mUpdatingProjectSources.Count; sourceIdx++) for (int sourceIdx = 0; sourceIdx < mUpdatingProjectSources.Count; sourceIdx++)
{ {
@ -740,7 +740,7 @@ namespace IDE.ui
if ((mUpdateTextCount == 0) && (mKind == Kind.Rename)) if ((mUpdateTextCount == 0) && (mKind == Kind.Rename))
{ {
activeSourceEditWidgetContent.mSelection = prevSelection; activeSourceEditWidgetContent.CurSelection = prevSelection;
} }
mUpdateTextCount++; mUpdateTextCount++;

View file

@ -42,19 +42,19 @@ namespace IDE.ui
editWidgetContent.mData.mUndoManager.Add(firstUndoAction); editWidgetContent.mData.mUndoManager.Add(firstUndoAction);
editWidgetContent.mData.mUndoManager.Add(new EditWidgetContent.SetCursorAction(editWidgetContent)); editWidgetContent.mData.mUndoManager.Add(new EditWidgetContent.SetCursorAction(editWidgetContent));
mVirtualCursorPos = editWidgetContent.mVirtualCursorPos; mVirtualCursorPos = editWidgetContent.CurVirtualCursorPos;
mTrackedCursorPosition = new PersistentTextPosition((int32)editWidgetContent.CursorTextPos); mTrackedCursorPosition = new PersistentTextPosition((int32)editWidgetContent.CursorTextPos);
editWidgetContent.PersistentTextPositions.Add(mTrackedCursorPosition); editWidgetContent.PersistentTextPositions.Add(mTrackedCursorPosition);
if (editWidgetContent.HasSelection()) if (editWidgetContent.HasSelection())
{ {
mSelStartPostion = new PersistentTextPosition(editWidgetContent.mSelection.Value.mStartPos); mSelStartPostion = new PersistentTextPosition(editWidgetContent.CurSelection.Value.mStartPos);
editWidgetContent.PersistentTextPositions.Add(mSelStartPostion); editWidgetContent.PersistentTextPositions.Add(mSelStartPostion);
mSelEndPostion = new PersistentTextPosition(editWidgetContent.mSelection.Value.mEndPos); mSelEndPostion = new PersistentTextPosition(editWidgetContent.CurSelection.Value.mEndPos);
editWidgetContent.PersistentTextPositions.Add(mSelEndPostion); editWidgetContent.PersistentTextPositions.Add(mSelEndPostion);
} }
editWidgetContent.mSelection = null; editWidgetContent.CurSelection = null;
} }
public void Finish(UndoAction lastUndoAction = null) public void Finish(UndoAction lastUndoAction = null)
@ -70,7 +70,7 @@ namespace IDE.ui
if (mSelStartPostion != null) if (mSelStartPostion != null)
{ {
editWidgetContent.mSelection = EditSelection(mSelStartPostion.mIndex, mSelEndPostion.mIndex); editWidgetContent.CurSelection = EditSelection(mSelStartPostion.mIndex, mSelEndPostion.mIndex);
editWidgetContent.PersistentTextPositions.Remove(mSelEndPostion); editWidgetContent.PersistentTextPositions.Remove(mSelEndPostion);
delete mSelEndPostion; delete mSelEndPostion;
editWidgetContent.PersistentTextPositions.Remove(mSelStartPostion); editWidgetContent.PersistentTextPositions.Remove(mSelStartPostion);
@ -162,11 +162,11 @@ namespace IDE.ui
g.FillRect(rect.mX, rect.mY, rect.mWidth, rect.mHeight); g.FillRect(rect.mX, rect.mY, rect.mWidth, rect.mHeight);
} }
if ((mEditWidgetContent.mSelection != null) && (mCollapseIndex < mEditWidgetContent.mOrderedCollapseEntries.Count)) if ((mEditWidgetContent.CurSelection != null) && (mCollapseIndex < mEditWidgetContent.mOrderedCollapseEntries.Count))
{ {
var collapseEntry = mEditWidgetContent.mOrderedCollapseEntries[mCollapseIndex]; var collapseEntry = mEditWidgetContent.mOrderedCollapseEntries[mCollapseIndex];
int32 startIdx = mEditWidgetContent.mData.mLineStarts[collapseEntry.mStartLine]; int32 startIdx = mEditWidgetContent.mData.mLineStarts[collapseEntry.mStartLine];
if ((mEditWidgetContent.mSelection.Value.MinPos <= collapseEntry.mEndIdx) && (mEditWidgetContent.mSelection.Value.MaxPos >= startIdx)) if ((mEditWidgetContent.CurSelection.Value.MinPos <= collapseEntry.mEndIdx) && (mEditWidgetContent.CurSelection.Value.MaxPos >= startIdx))
{ {
using (g.PushColor(mEditWidgetContent.GetSelectionColor(0))) using (g.PushColor(mEditWidgetContent.GetSelectionColor(0)))
g.FillRect(rect.mX, rect.mY, rect.mWidth, rect.mHeight); g.FillRect(rect.mX, rect.mY, rect.mWidth, rect.mHeight);
@ -563,11 +563,11 @@ namespace IDE.ui
g.FillRect(rect.mX + 1, rect.mY + 1, rect.mWidth - 2, rect.mHeight - 2); g.FillRect(rect.mX + 1, rect.mY + 1, rect.mWidth - 2, rect.mHeight - 2);
} }
if ((mEditWidgetContent.mSelection != null) && (mCollapseIndex < mEditWidgetContent.mOrderedCollapseEntries.Count)) if ((mEditWidgetContent.CurSelection != null) && (mCollapseIndex < mEditWidgetContent.mOrderedCollapseEntries.Count))
{ {
var collapseEntry = mEditWidgetContent.mOrderedCollapseEntries[mCollapseIndex]; var collapseEntry = mEditWidgetContent.mOrderedCollapseEntries[mCollapseIndex];
int32 startIdx = mEditWidgetContent.mData.mLineStarts[collapseEntry.mStartLine]; int32 startIdx = mEditWidgetContent.mData.mLineStarts[collapseEntry.mStartLine];
if ((mEditWidgetContent.mSelection.Value.MinPos <= collapseEntry.mEndIdx) && (mEditWidgetContent.mSelection.Value.MaxPos >= startIdx)) if ((mEditWidgetContent.CurSelection.Value.MinPos <= collapseEntry.mEndIdx) && (mEditWidgetContent.CurSelection.Value.MaxPos >= startIdx))
{ {
using (g.PushColor(mEditWidgetContent.GetSelectionColor(0))) using (g.PushColor(mEditWidgetContent.GetSelectionColor(0)))
g.FillRect(rect.mX, rect.mY, rect.mWidth, rect.mHeight); g.FillRect(rect.mX, rect.mY, rect.mWidth, rect.mHeight);
@ -934,7 +934,7 @@ namespace IDE.ui
UndoBatchStart undoBatchStart = new UndoBatchStart("applyDiff"); UndoBatchStart undoBatchStart = new UndoBatchStart("applyDiff");
editWidgetContent.mData.mUndoManager.Add(undoBatchStart); editWidgetContent.mData.mUndoManager.Add(undoBatchStart);
editWidgetContent.mSelection = null; editWidgetContent.CurSelection = null;
int32 curSrcLineIdx = -1; int32 curSrcLineIdx = -1;
List<TextLineSegment> deletedLineSegments = scope List<TextLineSegment>(); List<TextLineSegment> deletedLineSegments = scope List<TextLineSegment>();
@ -982,7 +982,7 @@ namespace IDE.ui
} }
editWidgetContent.mHadPersistentTextPositionDeletes = false; editWidgetContent.mHadPersistentTextPositionDeletes = false;
editWidgetContent.mSelection = EditSelection(pos, pos + len); editWidgetContent.CurSelection = EditSelection(pos, pos + len);
editWidgetContent.DeleteSelection(false); editWidgetContent.DeleteSelection(false);
// If we have modified a section of text containing breakpoint (for example), this gets encoded by // If we have modified a section of text containing breakpoint (for example), this gets encoded by
@ -1913,7 +1913,7 @@ namespace IDE.ui
{ {
int startPos; int startPos;
int endPos; int endPos;
mSelection.Value.GetAsForwardSelect(out startPos, out endPos); CurSelection.Value.GetAsForwardSelect(out startPos, out endPos);
int line; int line;
int lineChar; int lineChar;
GetLineCharAtIdx(startPos, out line, out lineChar); GetLineCharAtIdx(startPos, out line, out lineChar);
@ -2154,7 +2154,7 @@ namespace IDE.ui
if ((HasSelection()) && (gApp.mSymbolReferenceHelper != null) && (gApp.mSymbolReferenceHelper.mKind == .Rename)) if ((HasSelection()) && (gApp.mSymbolReferenceHelper != null) && (gApp.mSymbolReferenceHelper.mKind == .Rename))
{ {
bool hasSymbolSelection = true; bool hasSymbolSelection = true;
mSelection.Value.GetAsForwardSelect(var startPos, var endPos); CurSelection.Value.GetAsForwardSelect(var startPos, var endPos);
var text = mEditWidget.mEditWidgetContent.mData.mText; var text = mEditWidget.mEditWidgetContent.mData.mText;
for (int i = startPos; i < endPos; i++) for (int i = startPos; i < endPos; i++)
{ {
@ -2311,7 +2311,7 @@ namespace IDE.ui
int maxLineIdx = 0; int maxLineIdx = 0;
int maxLineCharIdx = 0; int maxLineCharIdx = 0;
var selection = mSelection.Value; var selection = CurSelection.Value;
GetLineCharAtIdx(selection.MinPos, out minLineIdx, out minLineCharIdx); GetLineCharAtIdx(selection.MinPos, out minLineIdx, out minLineCharIdx);
GetLineCharAtIdx(selection.MaxPos, out maxLineIdx, out maxLineCharIdx); GetLineCharAtIdx(selection.MaxPos, out maxLineIdx, out maxLineCharIdx);
@ -2349,7 +2349,7 @@ namespace IDE.ui
undoBatchStart = new UndoBatchStart("embeddedOpenCodeBlock"); undoBatchStart = new UndoBatchStart("embeddedOpenCodeBlock");
mData.mUndoManager.Add(undoBatchStart); mData.mUndoManager.Add(undoBatchStart);
mSelection = null; CurSelection = null;
CursorTextPos = i; CursorTextPos = i;
InsertAtCursor("\n"); InsertAtCursor("\n");
embeddedEndIdx = i; embeddedEndIdx = i;
@ -2422,7 +2422,7 @@ namespace IDE.ui
EditSelection newSel = selection; EditSelection newSel = selection;
selection.MakeForwardSelect(); selection.MakeForwardSelect();
mSelection = selection; CurSelection = selection;
int startAdjust = 0; int startAdjust = 0;
int endAdjust = 0; int endAdjust = 0;
@ -2562,7 +2562,7 @@ namespace IDE.ui
if (undoBatchStart != null) if (undoBatchStart != null)
mData.mUndoManager.Add(undoBatchStart.mBatchEnd); mData.mUndoManager.Add(undoBatchStart.mBatchEnd);
mSelection = newSel; CurSelection = newSel;
return true; return true;
} }
@ -2761,8 +2761,8 @@ namespace IDE.ui
if (!HasSelection()) if (!HasSelection())
return false; return false;
int minIdx = mSelection.Value.MinPos; int minIdx = CurSelection.Value.MinPos;
int maxIdx = mSelection.Value.MaxPos; int maxIdx = CurSelection.Value.MaxPos;
while (true) while (true)
{ {
@ -2798,7 +2798,7 @@ namespace IDE.ui
UndoBatchStart undoBatchStart = new UndoBatchStart("closeCodeBlock"); UndoBatchStart undoBatchStart = new UndoBatchStart("closeCodeBlock");
mData.mUndoManager.Add(undoBatchStart); mData.mUndoManager.Add(undoBatchStart);
mSelection = EditSelection(maxIdx - 1, maxIdx); CurSelection = EditSelection(maxIdx - 1, maxIdx);
GetLineCharAtIdx(maxIdx - 1, var endLine, var endLineChar); GetLineCharAtIdx(maxIdx - 1, var endLine, var endLineChar);
String endStr = scope .(); String endStr = scope .();
ExtractLine(endLine, endStr); ExtractLine(endLine, endStr);
@ -2812,7 +2812,7 @@ namespace IDE.ui
else else
DeleteSelection(); DeleteSelection();
mSelection = EditSelection(minIdx, minIdx + 1); CurSelection = EditSelection(minIdx, minIdx + 1);
GetLineCharAtIdx(minIdx, var startLine, var startLineChar); GetLineCharAtIdx(minIdx, var startLine, var startLineChar);
String startStr = scope .(); String startStr = scope .();
ExtractLine(startLine, startStr); ExtractLine(startLine, startStr);
@ -2838,7 +2838,7 @@ namespace IDE.ui
} }
CursorTextPos = startLineStart; CursorTextPos = startLineStart;
mSelection = EditSelection(startLineStart, endLineEnd); CurSelection = EditSelection(startLineStart, endLineEnd);
if (undoBatchStart != null) if (undoBatchStart != null)
mData.mUndoManager.Add(undoBatchStart.mBatchEnd); mData.mUndoManager.Add(undoBatchStart.mBatchEnd);
@ -2857,7 +2857,7 @@ namespace IDE.ui
var startLineAndCol = CursorLineAndColumn; var startLineAndCol = CursorLineAndColumn;
int startTextPos = CursorTextPos; int startTextPos = CursorTextPos;
var prevSelection = mSelection; var prevSelection = CurSelection;
bool hadSelection = HasSelection(); bool hadSelection = HasSelection();
if (!HasSelection()) if (!HasSelection())
@ -2865,7 +2865,7 @@ namespace IDE.ui
CursorToLineEnd(); CursorToLineEnd();
int cursorEndPos = CursorTextPos; int cursorEndPos = CursorTextPos;
CursorToLineStart(false); CursorToLineStart(false);
mSelection = EditSelection(CursorTextPos, cursorEndPos); CurSelection = EditSelection(CursorTextPos, cursorEndPos);
} }
if (HasSelection()) if (HasSelection())
@ -2876,9 +2876,9 @@ namespace IDE.ui
setCursorAction.mCursorTextPos = (int32)startTextPos; setCursorAction.mCursorTextPos = (int32)startTextPos;
mData.mUndoManager.Add(setCursorAction); mData.mUndoManager.Add(setCursorAction);
int minPos = mSelection.GetValueOrDefault().MinPos; int minPos = CurSelection.GetValueOrDefault().MinPos;
int maxPos = mSelection.GetValueOrDefault().MaxPos; int maxPos = CurSelection.GetValueOrDefault().MaxPos;
mSelection = null; CurSelection = null;
var str = scope String(); var str = scope String();
ExtractString(minPos, maxPos - minPos, str); ExtractString(minPos, maxPos - minPos, str);
@ -2899,7 +2899,7 @@ namespace IDE.ui
CursorTextPos = lastCharPos + 2; CursorTextPos = lastCharPos + 2;
InsertAtCursor("*/"); InsertAtCursor("*/");
mSelection = EditSelection(firstCharPos, lastCharPos + 4); CurSelection = EditSelection(firstCharPos, lastCharPos + 4);
if (startTextPos <= minPos) if (startTextPos <= minPos)
CursorLineAndColumn = startLineAndCol; CursorLineAndColumn = startLineAndCol;
@ -2907,7 +2907,7 @@ namespace IDE.ui
CursorTextPos = startTextPos + 2; CursorTextPos = startTextPos + 2;
if (!hadSelection) if (!hadSelection)
mSelection = null; CurSelection = null;
} }
} }
@ -2935,7 +2935,7 @@ namespace IDE.ui
SetTextCursor(cursor); SetTextCursor(cursor);
var startTextPos = CursorTextPos; var startTextPos = CursorTextPos;
var prevSelection = mSelection; var prevSelection = CurSelection;
var hadSelection = HasSelection(); var hadSelection = HasSelection();
var startLineAndCol = CursorLineAndColumn; var startLineAndCol = CursorLineAndColumn;
if (!HasSelection()) if (!HasSelection())
@ -2943,7 +2943,7 @@ namespace IDE.ui
CursorToLineEnd(); CursorToLineEnd();
int cursorEndPos = CursorTextPos; int cursorEndPos = CursorTextPos;
CursorToLineStart(false); CursorToLineStart(false);
mSelection = .(CursorTextPos, cursorEndPos); CurSelection = .(CursorTextPos, cursorEndPos);
} }
var setCursorAction = new SetCursorAction(this); var setCursorAction = new SetCursorAction(this);
@ -2951,9 +2951,9 @@ namespace IDE.ui
setCursorAction.mCursorTextPos = (int32)startTextPos; setCursorAction.mCursorTextPos = (int32)startTextPos;
mData.mUndoManager.Add(setCursorAction); mData.mUndoManager.Add(setCursorAction);
int minPos = mSelection.Value.MinPos; int minPos = CurSelection.Value.MinPos;
int maxPos = mSelection.Value.MaxPos; int maxPos = CurSelection.Value.MaxPos;
mSelection = null; CurSelection = null;
while (minPos > 0) while (minPos > 0)
{ {
@ -3070,7 +3070,7 @@ namespace IDE.ui
appendedCount += str.Length; appendedCount += str.Length;
} }
} }
mSelection = EditSelection(minPos, maxPos); CurSelection = EditSelection(minPos, maxPos);
if (appendedCount > 0) if (appendedCount > 0)
CursorTextPos = startTextPos + appendedCount; CursorTextPos = startTextPos + appendedCount;
@ -3078,7 +3078,7 @@ namespace IDE.ui
CursorLineAndColumn = startLineAndCol; CursorLineAndColumn = startLineAndCol;
if (!hadSelection) if (!hadSelection)
mSelection = null; CurSelection = null;
} }
CloseMultiCursorUndoBatch(); CloseMultiCursorUndoBatch();
@ -3091,11 +3091,11 @@ namespace IDE.ui
{ {
if (!HasSelection()) if (!HasSelection())
return; return;
if (CursorTextPos >= mSelection.Value.MaxPos) if (CursorTextPos >= CurSelection.Value.MaxPos)
CursorTextPos = mSelection.Value.MaxPos; CursorTextPos = CurSelection.Value.MaxPos;
if (mSelection.Value.MaxPos - mSelection.Value.MinPos <= 1) if (CurSelection.Value.MaxPos - CurSelection.Value.MinPos <= 1)
{ {
mSelection = null; CurSelection = null;
return; return;
} }
} }
@ -3116,7 +3116,7 @@ namespace IDE.ui
int startTextPos = CursorTextPos; int startTextPos = CursorTextPos;
bool doLineComment = false; bool doLineComment = false;
var prevSelection = mSelection; var prevSelection = CurSelection;
var cursorAtEndPos = true; var cursorAtEndPos = true;
LineAndColumn? startLineAndCol = CursorLineAndColumn; LineAndColumn? startLineAndCol = CursorLineAndColumn;
@ -3125,12 +3125,12 @@ namespace IDE.ui
CursorToLineEnd(); CursorToLineEnd();
int cursorEndPos = CursorTextPos; int cursorEndPos = CursorTextPos;
CursorToLineStart(false); CursorToLineStart(false);
mSelection = EditSelection(CursorTextPos, cursorEndPos); CurSelection = EditSelection(CursorTextPos, cursorEndPos);
doLineComment = true; doLineComment = true;
} }
else else
{ {
cursorAtEndPos = (mSelection.Value.mStartPos == mCursorTextPos); cursorAtEndPos = (CurSelection.Value.mStartPos == CurCursorTextPos);
} }
if (HasSelection()) if (HasSelection())
@ -3142,9 +3142,9 @@ namespace IDE.ui
setCursorAction.mCursorTextPos = (int32)startTextPos; setCursorAction.mCursorTextPos = (int32)startTextPos;
mData.mUndoManager.Add(setCursorAction); mData.mUndoManager.Add(setCursorAction);
var minPos = mSelection.GetValueOrDefault().MinPos; var minPos = CurSelection.GetValueOrDefault().MinPos;
var maxPos = mSelection.GetValueOrDefault().MaxPos; var maxPos = CurSelection.GetValueOrDefault().MaxPos;
mSelection = null; CurSelection = null;
var str = scope String(); var str = scope String();
ExtractString(minPos, (maxPos - minPos), str); ExtractString(minPos, (maxPos - minPos), str);
@ -3165,7 +3165,7 @@ namespace IDE.ui
CursorLineAndColumn = startLineAndCol.Value; CursorLineAndColumn = startLineAndCol.Value;
if (doComment == null) if (doComment == null)
mSelection = null; CurSelection = null;
//return false; // not sure if this should be false in blank/only whitespace selection case //return false; // not sure if this should be false in blank/only whitespace selection case
continue; continue;
@ -3180,7 +3180,7 @@ namespace IDE.ui
{ {
if (SafeGetChar(i - 0) == '/' && SafeGetChar(i + 1) == '/') if (SafeGetChar(i - 0) == '/' && SafeGetChar(i + 1) == '/')
{ {
mSelection = EditSelection(i - 0, i + 2); CurSelection = EditSelection(i - 0, i + 2);
DeleteSelection(); DeleteSelection();
lastCharPos -= 2; lastCharPos -= 2;
while (i < maxPos && SafeGetChar(i) != '\n') while (i < maxPos && SafeGetChar(i) != '\n')
@ -3194,20 +3194,20 @@ namespace IDE.ui
startLineAndCol = null; startLineAndCol = null;
CursorToLineEnd(); CursorToLineEnd();
int cursorEndPos = CursorTextPos; int cursorEndPos = CursorTextPos;
mSelection = .(minPos, cursorEndPos); CurSelection = .(minPos, cursorEndPos);
} }
else if ((doComment != true) && trimmedStr.StartsWith("/*")) else if ((doComment != true) && trimmedStr.StartsWith("/*"))
{ {
didComment = true; didComment = true;
if (trimmedStr.EndsWith("*/\n")) if (trimmedStr.EndsWith("*/\n"))
{ {
mSelection = EditSelection(firstCharPos, firstCharPos + 2); CurSelection = EditSelection(firstCharPos, firstCharPos + 2);
DeleteChar(); DeleteChar();
mSelection = EditSelection(lastCharPos - 4, lastCharPos - 2); CurSelection = EditSelection(lastCharPos - 4, lastCharPos - 2);
DeleteChar(); DeleteChar();
if (prevSelection != null) if (prevSelection != null)
mSelection = EditSelection(firstCharPos, lastCharPos - 4); CurSelection = EditSelection(firstCharPos, lastCharPos - 4);
} }
} }
else if (doComment != false) else if (doComment != false)
@ -3227,7 +3227,7 @@ namespace IDE.ui
InsertAtCursor("*/"); InsertAtCursor("*/");
} }
mSelection = EditSelection(firstCharPos, lastCharPos + 4); CurSelection = EditSelection(firstCharPos, lastCharPos + 4);
if (startTextPos <= minPos) if (startTextPos <= minPos)
CursorLineAndColumn = startLineAndCol.Value; CursorLineAndColumn = startLineAndCol.Value;
else else
@ -3236,25 +3236,25 @@ namespace IDE.ui
} }
else else
{ {
mSelection = prevSelection; CurSelection = prevSelection;
} }
if (startLineAndCol != null) if (startLineAndCol != null)
CursorLineAndColumn = startLineAndCol.Value; CursorLineAndColumn = startLineAndCol.Value;
if (prevSelection == null) if (prevSelection == null)
mSelection = null; CurSelection = null;
ClampCursor(); ClampCursor();
FixSelection(); FixSelection();
if (mSelection.HasValue) if (CurSelection.HasValue)
{ {
// Placing cursor where it was before, meaning // Placing cursor where it was before, meaning
// at the start or at the end of the selection. // at the start or at the end of the selection.
mCursorTextPos = (cursorAtEndPos) CurCursorTextPos = (cursorAtEndPos)
? (int32)mSelection.Value.mStartPos ? (int32)CurSelection.Value.mStartPos
: (int32)mSelection.Value.mEndPos : (int32)CurSelection.Value.mEndPos
; ;
} }
} }
@ -3273,7 +3273,7 @@ namespace IDE.ui
int endPos; int endPos;
if (HasSelection()) if (HasSelection())
{ {
mSelection.ValueRef.GetAsForwardSelect(out startPos, out endPos); CurSelection.ValueRef.GetAsForwardSelect(out startPos, out endPos);
} }
else else
{ {
@ -3294,9 +3294,9 @@ namespace IDE.ui
return; return;
} }
mSelection = EditSelection(); CurSelection = EditSelection();
mSelection.ValueRef.mStartPos = (int32)startPos; CurSelection.ValueRef.mStartPos = (int32)startPos;
mSelection.ValueRef.mEndPos = (int32)endPos; CurSelection.ValueRef.mEndPos = (int32)endPos;
DeleteSelection(); DeleteSelection();
CursorTextPos = startPos; CursorTextPos = startPos;
@ -3323,12 +3323,12 @@ namespace IDE.ui
var line = CursorLineAndColumn.mLine; var line = CursorLineAndColumn.mLine;
var column = CursorLineAndColumn.mColumn; var column = CursorLineAndColumn.mColumn;
var prevCursorPos = mCursorTextPos; var prevCursorPos = CurCursorTextPos;
lineText.Clear(); lineText.Clear();
GetLineText(line, lineText); GetLineText(line, lineText);
mSelection = null; CurSelection = null;
CursorLineAndColumn = LineAndColumn(line+1, 0); CursorLineAndColumn = LineAndColumn(line+1, 0);
InsertAtCursor("\n"); InsertAtCursor("\n");
@ -3601,8 +3601,8 @@ namespace IDE.ui
var prevCursorLineAndColumn = CursorLineAndColumn; var prevCursorLineAndColumn = CursorLineAndColumn;
var str = scope String(); var str = scope String();
int startSelPos = mSelection.Value.MinPos; int startSelPos = CurSelection.Value.MinPos;
ExtractString(mSelection.Value.MinPos, mSelection.Value.Length, str); ExtractString(CurSelection.Value.MinPos, CurSelection.Value.Length, str);
DeleteSelection(); DeleteSelection();
if (str.EndsWith('\n')) if (str.EndsWith('\n'))
@ -3762,7 +3762,7 @@ namespace IDE.ui
} }
GetLinePosition(endLineNum, ?, var lineEnd); GetLinePosition(endLineNum, ?, var lineEnd);
mSelection = .(lineStart, Math.Min(lineEnd + 1, mData.mTextLength)); CurSelection = .(lineStart, Math.Min(lineEnd + 1, mData.mTextLength));
if (dir == .Down) if (dir == .Down)
MoveSelection(endLineNum + (int)dir, false); MoveSelection(endLineNum + (int)dir, false);
@ -3801,7 +3801,7 @@ namespace IDE.ui
mData.mUndoManager.Add(new SetCursorAction(this)); mData.mUndoManager.Add(new SetCursorAction(this));
mSelection = .(lineStart, selEnd); CurSelection = .(lineStart, selEnd);
int toLine = Math.Clamp(lineNum + (int)dir, 0, GetLineCount()); int toLine = Math.Clamp(lineNum + (int)dir, 0, GetLineCount());
if (dir == .Down) if (dir == .Down)
@ -3907,14 +3907,14 @@ namespace IDE.ui
{ {
if (HasSelection()) if (HasSelection())
{ {
mSelection = null; CurSelection = null;
return; return;
} }
} }
else if (keyChar == '\b') else if (keyChar == '\b')
{ {
if (HasSelection()) if (HasSelection())
mSelection = null; CurSelection = null;
} }
} }
@ -3957,10 +3957,10 @@ namespace IDE.ui
if ((IsPrimaryTextCursor()) && (isEndingChar)) if ((IsPrimaryTextCursor()) && (isEndingChar))
{ {
bool forceAsyncFinish = false; bool forceAsyncFinish = false;
if (mCursorTextPos > 0) if (CurCursorTextPos > 0)
{ {
char8 c = mData.mText[mCursorTextPos - 1].mChar; char8 c = mData.mText[CurCursorTextPos - 1].mChar;
var displayType = (SourceElementType)mData.mText[mCursorTextPos - 1].mDisplayTypeId; var displayType = (SourceElementType)mData.mText[CurCursorTextPos - 1].mDisplayTypeId;
if ((displayType != .Comment) && (displayType != .Literal)) if ((displayType != .Comment) && (displayType != .Literal))
{ {
if ((c.IsLetterOrDigit) || (c == '_')) if ((c.IsLetterOrDigit) || (c == '_'))
@ -4004,7 +4004,7 @@ namespace IDE.ui
if ((IsPrimaryTextCursor()) && (mAutoComplete != null) && (mAutoComplete.mAutoCompleteListWidget != null)) if ((IsPrimaryTextCursor()) && (mAutoComplete != null) && (mAutoComplete.mAutoCompleteListWidget != null))
{ {
if ((mAutoComplete.mInsertEndIdx != -1) && (mAutoComplete.mInsertEndIdx != mCursorTextPos) && (keyChar != '\t') && (keyChar != '\r') && (keyChar != '\n')) if ((mAutoComplete.mInsertEndIdx != -1) && (mAutoComplete.mInsertEndIdx != CurCursorTextPos) && (keyChar != '\t') && (keyChar != '\r') && (keyChar != '\n'))
doAutocomplete = false; doAutocomplete = false;
/*if ((mAutoComplete.IsInsertEmpty()) && (!mAutoComplete.mIsFixit) && (keyChar != '.') && (keyChar != '\t') && (keyChar != '\r')) /*if ((mAutoComplete.IsInsertEmpty()) && (!mAutoComplete.mIsFixit) && (keyChar != '.') && (keyChar != '\t') && (keyChar != '\r'))
@ -4134,13 +4134,13 @@ namespace IDE.ui
if (!HasSelection()) if (!HasSelection())
{ {
// Select whitespace at the end of the line so we trim it as we InsertAtCursor // Select whitespace at the end of the line so we trim it as we InsertAtCursor
mSelection = EditSelection(CursorTextPos, CursorTextPos); CurSelection = EditSelection(CursorTextPos, CursorTextPos);
for (int checkIdx = beforeCursorLineText.Length - 1; checkIdx >= 0; checkIdx--) for (int checkIdx = beforeCursorLineText.Length - 1; checkIdx >= 0; checkIdx--)
{ {
char8 c = beforeCursorLineText[checkIdx]; char8 c = beforeCursorLineText[checkIdx];
if (!c.IsWhiteSpace) if (!c.IsWhiteSpace)
break; break;
mSelection.ValueRef.mStartPos--; CurSelection.ValueRef.mStartPos--;
} }
insertFlags |= .NoRestoreSelectionOnUndo; insertFlags |= .NoRestoreSelectionOnUndo;
} }
@ -4310,7 +4310,7 @@ namespace IDE.ui
((keyChar == '"') || (keyChar == '\'') || (keyChar == ')') || (keyChar == ']') || (keyChar == '>') || (keyChar == '}')) && ((keyChar == '"') || (keyChar == '\'') || (keyChar == ')') || (keyChar == ']') || (keyChar == '>') || (keyChar == '}')) &&
(IsCurrentPairClosing(cursorTextPos, true))) (IsCurrentPairClosing(cursorTextPos, true)))
{ {
mJustInsertedCharPair = false; CurJustInsertedCharPair = false;
CursorTextPos++; CursorTextPos++;
return; return;
} }
@ -4371,9 +4371,9 @@ namespace IDE.ui
UndoBatchStart undoBatchStart = new UndoBatchStart("blockSurround"); UndoBatchStart undoBatchStart = new UndoBatchStart("blockSurround");
mData.mUndoManager.Add(undoBatchStart); mData.mUndoManager.Add(undoBatchStart);
int minPos = mSelection.GetValueOrDefault().MinPos; int minPos = CurSelection.GetValueOrDefault().MinPos;
int maxPos = mSelection.GetValueOrDefault().MaxPos; int maxPos = CurSelection.GetValueOrDefault().MaxPos;
mSelection = null; CurSelection = null;
CursorTextPos = minPos; CursorTextPos = minPos;
String insertStr = scope String(); String insertStr = scope String();
insertStr.Append(keyChar); insertStr.Append(keyChar);
@ -4557,19 +4557,19 @@ namespace IDE.ui
int32 columnPos = (int32)(GetTabbedWidth(tabStartStr, 0) / mCharWidth + 0.001f); int32 columnPos = (int32)(GetTabbedWidth(tabStartStr, 0) / mCharWidth + 0.001f);
if (columnPos >= wantLineColumn + gApp.mSettings.mEditorSettings.mTabSize) if (columnPos >= wantLineColumn + gApp.mSettings.mEditorSettings.mTabSize)
{ {
mSelection = EditSelection(); CurSelection = EditSelection();
mSelection.ValueRef.mEndPos = (int32)(cursorTextIdx - trimmedLineText.Length); CurSelection.ValueRef.mEndPos = (int32)(cursorTextIdx - trimmedLineText.Length);
if (lineText.EndsWith(scope String(" ", trimmedLineText), StringComparison.Ordinal)) if (lineText.EndsWith(scope String(" ", trimmedLineText), StringComparison.Ordinal))
mSelection.ValueRef.mStartPos = mSelection.Value.mEndPos - 4; CurSelection.ValueRef.mStartPos = CurSelection.Value.mEndPos - 4;
else if (lineText.EndsWith(scope String("\t", trimmedLineText), StringComparison.Ordinal)) else if (lineText.EndsWith(scope String("\t", trimmedLineText), StringComparison.Ordinal))
mSelection.ValueRef.mStartPos = mSelection.Value.mEndPos - 1; CurSelection.ValueRef.mStartPos = CurSelection.Value.mEndPos - 1;
if (mSelection.Value.mStartPos > 0) if (CurSelection.Value.mStartPos > 0)
{ {
CreateMultiCursorUndoBatch("SEWC.KeyChar(case)"); CreateMultiCursorUndoBatch("SEWC.KeyChar(case)");
DeleteSelection(); DeleteSelection();
CursorToLineEnd(); CursorToLineEnd();
} }
mSelection = null; CurSelection = null;
} }
} }
} }
@ -4593,9 +4593,9 @@ namespace IDE.ui
insertStr.Append("else"); insertStr.Append("else");
var cursorPos = CursorTextPos; var cursorPos = CursorTextPos;
mSelection = EditSelection(); CurSelection = EditSelection();
mSelection.ValueRef.mStartPos = (int32)cursorPos - 4; CurSelection.ValueRef.mStartPos = (int32)cursorPos - 4;
mSelection.ValueRef.mEndPos = (int32)cursorPos; CurSelection.ValueRef.mEndPos = (int32)cursorPos;
InsertAtCursor(insertStr, .NoRestoreSelectionOnUndo); InsertAtCursor(insertStr, .NoRestoreSelectionOnUndo);
//var indentTextAction = new EditWidgetContent.IndentTextAction(this); //var indentTextAction = new EditWidgetContent.IndentTextAction(this);
@ -4610,7 +4610,7 @@ namespace IDE.ui
} }
} }
mCursorImplicitlyMoved = true; CurCursorImplicitlyMoved = true;
} }
public void ShowAutoComplete(bool isUserRequested) public void ShowAutoComplete(bool isUserRequested)
@ -4685,9 +4685,9 @@ namespace IDE.ui
return; return;
} }
if ((keyCode == KeyCode.Escape) && (mSelection != null) && (mSelection.Value.HasSelection)) if ((keyCode == KeyCode.Escape) && (CurSelection != null) && (CurSelection.Value.HasSelection))
{ {
mSelection = null; CurSelection = null;
} }
if (((keyCode == KeyCode.Up) || (keyCode == KeyCode.Down) || (keyCode == KeyCode.PageUp) || (keyCode == KeyCode.PageDown))) if (((keyCode == KeyCode.Up) || (keyCode == KeyCode.Down) || (keyCode == KeyCode.PageUp) || (keyCode == KeyCode.PageDown)))
@ -4767,13 +4767,13 @@ namespace IDE.ui
{ {
if (mWidgetWindow.IsKeyDown(.Shift)) if (mWidgetWindow.IsKeyDown(.Shift))
{ {
if (mSelection == null) if (CurSelection == null)
mSelection = .(CursorTextPos, wantCursorPos); CurSelection = .(CursorTextPos, wantCursorPos);
else else
mSelection.ValueRef.mEndPos = (.)wantCursorPos; CurSelection.ValueRef.mEndPos = (.)wantCursorPos;
} }
else else
mSelection = null; CurSelection = null;
CursorTextPos = wantCursorPos; CursorTextPos = wantCursorPos;
return; return;
@ -4820,8 +4820,8 @@ namespace IDE.ui
void ReplaceWord(int leftIdx, int rightIdx, String origWord, String newWord) void ReplaceWord(int leftIdx, int rightIdx, String origWord, String newWord)
{ {
mSelection.ValueRef.mStartPos = (int32)leftIdx; CurSelection.ValueRef.mStartPos = (int32)leftIdx;
mSelection.ValueRef.mEndPos = (int32)rightIdx; CurSelection.ValueRef.mEndPos = (int32)rightIdx;
InsertAtCursor(newWord, .NoRestoreSelectionOnUndo); InsertAtCursor(newWord, .NoRestoreSelectionOnUndo);
} }
@ -5013,9 +5013,9 @@ namespace IDE.ui
BfPassInstance passInstance = null; BfPassInstance passInstance = null;
BfParser parser = null; BfParser parser = null;
if ((mSelection != null) && if ((CurSelection != null) &&
(textIdx >= mSelection.Value.MinPos) && (textIdx >= CurSelection.Value.MinPos) &&
(textIdx < mSelection.Value.MaxPos)) (textIdx < CurSelection.Value.MaxPos))
{ {
GetSelectionText(debugExpr); GetSelectionText(debugExpr);
} }
@ -5624,7 +5624,7 @@ namespace IDE.ui
{ {
base.ClampCursor(); base.ClampCursor();
if (mVirtualCursorPos == null) if (CurVirtualCursorPos == null)
return; return;
if (gApp.mSettings.mEditorSettings.mFreeCursorMovement) if (gApp.mSettings.mEditorSettings.mFreeCursorMovement)
return; return;
@ -5640,7 +5640,7 @@ namespace IDE.ui
GetLineText(line, curLineStr); GetLineText(line, curLineStr);
int32 lineEnd = (int32)curLineStr.NumCodePoints; int32 lineEnd = (int32)curLineStr.NumCodePoints;
mVirtualCursorPos.ValueRef.mColumn = (.)Math.Min(mVirtualCursorPos.Value.mColumn, Math.Max(virtualEnd, lineEnd)); CurVirtualCursorPos.ValueRef.mColumn = (.)Math.Min(CurVirtualCursorPos.Value.mColumn, Math.Max(virtualEnd, lineEnd));
} }
bool CheckCollapseOpen(int checkLine, CursorMoveKind cursorMoveKind = .Unknown) bool CheckCollapseOpen(int checkLine, CursorMoveKind cursorMoveKind = .Unknown)
@ -5682,14 +5682,14 @@ namespace IDE.ui
{ {
bool hadSelection = HasSelection(); bool hadSelection = HasSelection();
if ((dir > 0) && (HasSelection()) && (mSelection.Value.Length > 1) && (!mWidgetWindow.IsKeyDown(.Shift))) if ((dir > 0) && (HasSelection()) && (CurSelection.Value.Length > 1) && (!mWidgetWindow.IsKeyDown(.Shift)))
{ {
GetLineCharAtIdx(mSelection.Value.MaxPos - 1, var maxLine, ?); GetLineCharAtIdx(CurSelection.Value.MaxPos - 1, var maxLine, ?);
if (IsLineCollapsed(maxLine)) if (IsLineCollapsed(maxLine))
{ {
if (hadSelection) if (hadSelection)
{ {
mSelection = null; CurSelection = null;
CursorToLineEnd(); CursorToLineEnd();
return true; return true;
} }
@ -5705,7 +5705,7 @@ namespace IDE.ui
CursorLineAndColumn = .(anchorLine, 0); CursorLineAndColumn = .(anchorLine, 0);
base.CursorToLineEnd(); base.CursorToLineEnd();
if ((mWidgetWindow.IsKeyDown(.Shift)) && (HasSelection())) if ((mWidgetWindow.IsKeyDown(.Shift)) && (HasSelection()))
mSelection.ValueRef.mEndPos = (.)CursorTextPos; CurSelection.ValueRef.mEndPos = (.)CursorTextPos;
return true; return true;
} }
} }
@ -5733,13 +5733,13 @@ namespace IDE.ui
mSourceViewPanel?.mQuickFind?.SetFindIdx(CursorTextPos, !moveKind.IsFromTyping); mSourceViewPanel?.mQuickFind?.SetFindIdx(CursorTextPos, !moveKind.IsFromTyping);
} }
if (mVirtualCursorPos != null) if (CurVirtualCursorPos != null)
{ {
CheckCollapseOpen(mVirtualCursorPos.Value.mLine, moveKind); CheckCollapseOpen(CurVirtualCursorPos.Value.mLine, moveKind);
} }
else else
{ {
GetLineCharAtIdx(mCursorTextPos, var checkLine, ?); GetLineCharAtIdx(CurCursorTextPos, var checkLine, ?);
CheckCollapseOpen(checkLine, moveKind); CheckCollapseOpen(checkLine, moveKind);
} }
@ -6735,12 +6735,12 @@ namespace IDE.ui
} }
int32 startIdx = mData.mLineStarts[entry.mStartLine]; int32 startIdx = mData.mLineStarts[entry.mStartLine];
if ((!wantOpen) && (mSelection != null) && (mSelection.Value.MinPos >= startIdx) && (mSelection.Value.MinPos <= entry.mEndIdx)) if ((!wantOpen) && (CurSelection != null) && (CurSelection.Value.MinPos >= startIdx) && (CurSelection.Value.MinPos <= entry.mEndIdx))
{ {
if (mSelection.Value.MaxPos > entry.mEndIdx + 1) if (CurSelection.Value.MaxPos > entry.mEndIdx + 1)
mSelection = .(entry.mEndIdx + 1, mSelection.Value.MaxPos); CurSelection = .(entry.mEndIdx + 1, CurSelection.Value.MaxPos);
else else
mSelection = null; CurSelection = null;
} }
if ((!wantOpen) && (cursorLineAndColumn.mLine >= entry.mStartLine) && (cursorLineAndColumn.mLine <= entry.mEndLine)) if ((!wantOpen) && (cursorLineAndColumn.mLine >= entry.mStartLine) && (cursorLineAndColumn.mLine <= entry.mEndLine))

View file

@ -887,7 +887,7 @@ namespace IDE.ui
return false; return false;
} }
int32 cursorPos = data.GetInt("CursorPos"); int32 cursorPos = data.GetInt("CursorPos");
mEditWidget.Content.mCursorTextPos = Math.Min(cursorPos, mEditWidget.mEditWidgetContent.mData.mTextLength); mEditWidget.Content.CurCursorTextPos = Math.Min(cursorPos, mEditWidget.mEditWidgetContent.mData.mTextLength);
mDesiredVertPos = data.GetFloat("VertPos"); mDesiredVertPos = data.GetFloat("VertPos");
return true; return true;
@ -2462,10 +2462,10 @@ namespace IDE.ui
mEditWidget.Content.CursorTextPos = searchIdx; mEditWidget.Content.CursorTextPos = searchIdx;
if (mWidgetWindow.IsKeyDown(KeyCode.Shift)) if (mWidgetWindow.IsKeyDown(KeyCode.Shift))
{ {
mEditWidget.Content.mSelection = EditSelection(cursorStartPos, mEditWidget.Content.CursorTextPos); mEditWidget.Content.CurSelection = EditSelection(cursorStartPos, mEditWidget.Content.CursorTextPos);
} }
else else
mEditWidget.Content.mSelection = null; mEditWidget.Content.CurSelection = null;
mEditWidget.Content.CursorMoved(); mEditWidget.Content.CursorMoved();
mEditWidget.Content.EnsureCursorVisible(); mEditWidget.Content.EnsureCursorVisible();
break; break;
@ -2522,14 +2522,14 @@ namespace IDE.ui
int32 prevLine = mEditWidget.Content.CursorLineAndColumn.mLine; int32 prevLine = mEditWidget.Content.CursorLineAndColumn.mLine;
mEditWidget.Content.mSelection = null; mEditWidget.Content.CurSelection = null;
int wantCursorPos = Math.Min(mEditWidget.Content.mData.mTextLength - 1, cursorIdx); int wantCursorPos = Math.Min(mEditWidget.Content.mData.mTextLength - 1, cursorIdx);
if (wantCursorPos >= 0) if (wantCursorPos >= 0)
mEditWidget.Content.CursorTextPos = wantCursorPos; mEditWidget.Content.CursorTextPos = wantCursorPos;
mEditWidget.Content.CursorMoved(); mEditWidget.Content.CursorMoved();
mEditWidget.Content.EnsureCursorVisible(true, true); mEditWidget.Content.EnsureCursorVisible(true, true);
mEditWidget.Content.mCursorImplicitlyMoved = true; mEditWidget.Content.CurCursorImplicitlyMoved = true;
if (mJustShown) // Jump to whatever position we're scrolling to if (mJustShown) // Jump to whatever position we're scrolling to
{ {
mEditWidget.mVertPos.mPct = 1.0f; mEditWidget.mVertPos.mPct = 1.0f;
@ -5187,7 +5187,7 @@ namespace IDE.ui
} }
if ((mEditWidget.Content.HasSelection()) && (!ignoreSelection)) if ((mEditWidget.Content.HasSelection()) && (!ignoreSelection))
parser.ReformatInto(mEditWidget, mEditWidget.Content.mSelection.Value.MinPos, mEditWidget.Content.mSelection.Value.MaxPos); parser.ReformatInto(mEditWidget, mEditWidget.Content.CurSelection.Value.MinPos, mEditWidget.Content.CurSelection.Value.MaxPos);
else else
parser.ReformatInto(mEditWidget, 0, text.Length); parser.ReformatInto(mEditWidget, 0, text.Length);
@ -5409,9 +5409,9 @@ namespace IDE.ui
bool doSimpleMouseover = false; bool doSimpleMouseover = false;
if ((editWidgetContent.mSelection != null) && if ((editWidgetContent.CurSelection != null) &&
(textIdx >= editWidgetContent.mSelection.Value.MinPos) && (textIdx >= editWidgetContent.CurSelection.Value.MinPos) &&
(textIdx < editWidgetContent.mSelection.Value.MaxPos)) (textIdx < editWidgetContent.CurSelection.Value.MaxPos))
{ {
debugExpr = scope:: String(); debugExpr = scope:: String();
editWidgetContent.GetSelectionText(debugExpr); editWidgetContent.GetSelectionText(debugExpr);
@ -6827,7 +6827,7 @@ namespace IDE.ui
int cursorIdx = sourceEditWidgetContent.CursorTextPos; int cursorIdx = sourceEditWidgetContent.CursorTextPos;
bool hasFlag = false; bool hasFlag = false;
if (!sourceEditWidgetContent.mVirtualCursorPos.HasValue) if (!sourceEditWidgetContent.CurVirtualCursorPos.HasValue)
{ {
for (int32 ofs = -1; ofs <= 0; ofs++) for (int32 ofs = -1; ofs <= 0; ofs++)
{ {
@ -6866,7 +6866,7 @@ namespace IDE.ui
if ((gApp.mSettings.mEditorSettings.mHiliteCursorReferences) && (!gApp.mDeterministic) && (HasFocus(true)) && if ((gApp.mSettings.mEditorSettings.mHiliteCursorReferences) && (!gApp.mDeterministic) && (HasFocus(true)) &&
((mProjectSource != null) || (mEmbedKind != .None)) /*&& (IDEApp.sApp.mSymbolReferenceHelper == null)*/) ((mProjectSource != null) || (mEmbedKind != .None)) /*&& (IDEApp.sApp.mSymbolReferenceHelper == null)*/)
{ {
if ((mEditWidget.mHasFocus) && (mIsBeefSource) && (sourceEditWidgetContent.mCursorStillTicks == 10) && (!sourceEditWidgetContent.mCursorImplicitlyMoved) && (!sourceEditWidgetContent.mVirtualCursorPos.HasValue)) if ((mEditWidget.mHasFocus) && (mIsBeefSource) && (sourceEditWidgetContent.mCursorStillTicks == 10) && (!sourceEditWidgetContent.CurCursorImplicitlyMoved) && (!sourceEditWidgetContent.CurVirtualCursorPos.HasValue))
{ {
var symbolReferenceHelper = IDEApp.sApp.mSymbolReferenceHelper; var symbolReferenceHelper = IDEApp.sApp.mSymbolReferenceHelper;
if (symbolReferenceHelper == null) if (symbolReferenceHelper == null)

View file

@ -347,7 +347,7 @@ namespace IDE.ui
int lineCount = 1; int lineCount = 1;
var data = activeEditWidget.mEditWidgetContent.mData; var data = activeEditWidget.mEditWidgetContent.mData;
var sel = activeEditWidget.mEditWidgetContent.mSelection.GetValueOrDefault(); var sel = activeEditWidget.mEditWidgetContent.CurSelection.GetValueOrDefault();
for (int i in sel.MinPos..<sel.MaxPos-1) for (int i in sel.MinPos..<sel.MaxPos-1)
{ {
var c = data.mText[i].mChar; var c = data.mText[i].mChar;

View file

@ -45,7 +45,7 @@ namespace IDE.ui
var editWidget = EditWidget; var editWidget = EditWidget;
if (editWidget.Content.HasSelection()) if (editWidget.Content.HasSelection())
{ {
editWidget.Content.mSelection = null; editWidget.Content.CurSelection = null;
return true; return true;
} }

View file

@ -1595,7 +1595,7 @@ namespace IDE.ui
String textPosString = scope String(); String textPosString = scope String();
if (mEditWidget.Content.HasSelection()) if (mEditWidget.Content.HasSelection())
{ {
var selection = mEditWidget.Content.mSelection; var selection = mEditWidget.Content.CurSelection;
textPosString.AppendF("Start {0} Len {1}", selection.Value.MinPos, selection.Value.MaxPos - selection.Value.MinPos); textPosString.AppendF("Start {0} Len {1}", selection.Value.MinPos, selection.Value.MaxPos - selection.Value.MinPos);
} }
else else