1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-07 19:18: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 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(selEndIdx, out selEndLine, out selEndCharIdx);
}
@ -721,17 +721,17 @@ namespace Beefy.theme.dark
if ((mEditWidget.mHasFocus) && (!drewCursor))
{
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;
if ((mCursorTextPos == lineDrawEnd) && (lineDrawEnd == lineEnd))
bool isInside = CurCursorTextPos < lineDrawEnd;
if ((CurCursorTextPos == lineDrawEnd) && (lineDrawEnd == lineEnd))
{
if (lineDrawEnd == mData.mTextLength)
isInside = true;
@ -746,8 +746,8 @@ namespace Beefy.theme.dark
if (isInside)
{
String subText = new:ScopedAlloc! String(mCursorTextPos - lineDrawStart);
subText.Append(sectionText, 0, mCursorTextPos - lineDrawStart);
String subText = new:ScopedAlloc! String(CurCursorTextPos - lineDrawStart);
subText.Append(sectionText, 0, CurCursorTextPos - lineDrawStart);
aX = GetTabbedWidth(subText, curX);
}
}
@ -793,7 +793,7 @@ namespace Beefy.theme.dark
if (!HasSelection())
return;
mSelection.Value.GetAsForwardSelect(var startPos, var endPos);
CurSelection.Value.GetAsForwardSelect(var startPos, var endPos);
GetLineColumnAtIdx(startPos, var startLine, var startColumn);
GetLineColumnAtIdx(endPos, var endLine, var endColumn);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -745,7 +745,7 @@ namespace IDE.ui
if (matches)
{
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);
insertTextAction.mMoveCursor = false;
editWidgetContent.mData.mUndoManager.Add(insertTextAction);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -120,8 +120,8 @@ namespace IDE.ui
var sourceContent = editWidget.Content as SourceEditWidgetContent;
if (content.HasSelection())
{
int selStart = content.mSelection.Value.MinPos;
int selEnd = content.mSelection.Value.MaxPos;
int selStart = content.CurSelection.Value.MinPos;
int selEnd = content.CurSelection.Value.MaxPos;
bool isMultiline = false;
for (int i = selStart; i < selEnd; i++)
{
@ -154,7 +154,7 @@ namespace IDE.ui
mFindEditWidget.Content.SelectAll();
}
content.mSelection = null;
content.CurSelection = null;
}
}
@ -170,7 +170,7 @@ namespace IDE.ui
mHasNewActiveCursorPos = true;
mLastActiveCursorPos = (int32)mEditWidget.Content.CursorTextPos;
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.mSelection = EditSelection(mCurFindIdx, mCurFindIdx + (int32)findText.Length);
editWidgetContent.CurSelection = EditSelection(mCurFindIdx, mCurFindIdx + (int32)findText.Length);
/*for (int32 idx = mCurFindIdx; idx < mCurFindIdx + findText.Length; idx++)
{
@ -744,10 +744,10 @@ namespace IDE.ui
EditSelection selection = EditSelection();
selection.mStartPos = selStart;
selection.mEndPos = selEnd + 1;
ewc.mSelection = selection;
ewc.CurSelection = selection;
}
else
selStart = (.)ewc.mSelection.Value.MinPos;
selStart = (.)ewc.CurSelection.Value.MinPos;
EditWidgetContent.InsertFlags insertFlags = .NoMoveCursor | .NoRestoreSelectionOnUndo | .IsGroupPart;
if (searchCount == 0)
insertFlags |= .IsGroupStart;
@ -851,7 +851,7 @@ namespace IDE.ui
if (mSelectionStart != null)
{
if (mSelectionEnd != null)
sourceContent.mSelection = .(mSelectionStart.mIndex, mSelectionEnd.mIndex);
sourceContent.CurSelection = .(mSelectionStart.mIndex, mSelectionEnd.mIndex);
if (sourceContent != null)
sourceContent.PersistentTextPositions.Remove(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
if (ewc.CursorTextPos == mCursorPos)
{
ewc.mSelection = EditSelection(mStartIdx, mEndIdx);
ewc.CurSelection = EditSelection(mStartIdx, mEndIdx);
ewc.CursorTextPos = mEndIdx;
}
}
@ -640,7 +640,7 @@ namespace IDE.ui
cursorPositions.Add((int32)sourceEditWidgetContent.CursorTextPos);
}
var prevSelection = activeSourceEditWidgetContent.mSelection;
var prevSelection = activeSourceEditWidgetContent.CurSelection;
for (int sourceIdx = 0; sourceIdx < mUpdatingProjectSources.Count; sourceIdx++)
{
@ -740,7 +740,7 @@ namespace IDE.ui
if ((mUpdateTextCount == 0) && (mKind == Kind.Rename))
{
activeSourceEditWidgetContent.mSelection = prevSelection;
activeSourceEditWidgetContent.CurSelection = prevSelection;
}
mUpdateTextCount++;

View file

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

View file

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

View file

@ -347,7 +347,7 @@ namespace IDE.ui
int lineCount = 1;
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)
{
var c = data.mText[i].mChar;

View file

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

View file

@ -1595,7 +1595,7 @@ namespace IDE.ui
String textPosString = scope String();
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);
}
else