mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-23 18:18:00 +02:00
Ctrl+Alt+Up/Down support, QuickFind Ctrl+D fixes
This commit is contained in:
parent
2ce4ec2e3f
commit
adb7a2bdef
8 changed files with 259 additions and 110 deletions
|
@ -87,11 +87,11 @@ namespace IDE.ui
|
|||
bool mFoundMatches;
|
||||
public bool mIsShowingMatches = false;
|
||||
static String sLastSearchString = new String() ~ delete _;
|
||||
public List<Range> mFoundRanges = new .() ~ delete _;
|
||||
|
||||
public bool mOwnsSelection;
|
||||
PersistentTextPosition mSelectionStart ~ { Debug.Assert(_ == null); };
|
||||
PersistentTextPosition mSelectionEnd ~ { Debug.Assert(_ == null); };
|
||||
|
||||
|
||||
public this(Widget parent, EditWidget editWidget, bool isReplace)
|
||||
{
|
||||
|
@ -394,6 +394,7 @@ namespace IDE.ui
|
|||
mCurFindCount = 0;
|
||||
//mSearchDidWrap = false;
|
||||
|
||||
mFoundRanges.Clear();
|
||||
ClearFlags(true, true);
|
||||
if (mSelectionStart != null)
|
||||
{
|
||||
|
@ -404,10 +405,21 @@ namespace IDE.ui
|
|||
}
|
||||
}
|
||||
|
||||
bool DoFindNext(bool select)
|
||||
{
|
||||
if (var range = FindNext(1, select, ErrorReportType.None))
|
||||
{
|
||||
mFoundRanges.Add(range);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (doSelect)
|
||||
FindNext(1, true, ErrorReportType.None);
|
||||
DoFindNext(true);
|
||||
|
||||
int32 curFindIdx = mCurFindIdx;
|
||||
while (FindNext(1, false, ErrorReportType.None))
|
||||
while (DoFindNext(false))
|
||||
{
|
||||
}
|
||||
mCurFindIdx = curFindIdx;
|
||||
|
@ -483,7 +495,7 @@ namespace IDE.ui
|
|||
return;
|
||||
}
|
||||
|
||||
if (FindNext(dir, true, showMessage ? ErrorReportType.MessageBox : ErrorReportType.Sound))
|
||||
if (FindNext(dir, true, showMessage ? ErrorReportType.MessageBox : ErrorReportType.Sound) case .Ok)
|
||||
{
|
||||
ShowCurrentSelection();
|
||||
}
|
||||
|
@ -506,7 +518,7 @@ namespace IDE.ui
|
|||
}
|
||||
}
|
||||
|
||||
public bool FindNext(int32 dir, bool isSelection, ErrorReportType errorType)
|
||||
public Result<Range> FindNext(int32 dir, bool isSelection, ErrorReportType errorType)
|
||||
{
|
||||
var editContent = mEditWidget.Content;
|
||||
|
||||
|
@ -514,7 +526,7 @@ namespace IDE.ui
|
|||
mFindEditWidget.GetText(findText);
|
||||
sLastSearchString.Set(findText);
|
||||
if (findText.Length == 0)
|
||||
return false;
|
||||
return .Err;
|
||||
|
||||
String findTextLower = scope String(findText);
|
||||
findTextLower.ToLower();
|
||||
|
@ -610,7 +622,7 @@ namespace IDE.ui
|
|||
|
||||
mCurFindIdx = mCurFindStart + 1;
|
||||
mCurFindCount = 0;
|
||||
return false;
|
||||
return .Err;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -623,7 +635,7 @@ namespace IDE.ui
|
|||
|
||||
mCurFindIdx = mCurFindStart - 1;
|
||||
mCurFindCount = 0;
|
||||
return false;
|
||||
return .Err;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -646,7 +658,7 @@ namespace IDE.ui
|
|||
}
|
||||
|
||||
mCurFindIdx = nextIdx;
|
||||
return true;
|
||||
return Range(mCurFindIdx, mCurFindIdx + findText.Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -668,7 +680,7 @@ namespace IDE.ui
|
|||
ShowDoneError(errorType);
|
||||
mCurFindCount = 0;
|
||||
}
|
||||
return false;
|
||||
return .Err;
|
||||
}
|
||||
|
||||
mCurFindIdx = -1;
|
||||
|
|
|
@ -4622,11 +4622,12 @@ namespace IDE.ui
|
|||
}
|
||||
}
|
||||
|
||||
/// summary = "Hey This is a summary"
|
||||
/// param.keyCode = "Keycode of pressed key"
|
||||
/// param.isRepeat = "Whether the key is repeated"
|
||||
public override void KeyDown(KeyCode keyCode, bool isRepeat)
|
||||
{
|
||||
public override void HandleKey(KeyCode keyCode, KeyFlags keyFlags, bool isRepeat)
|
||||
{
|
||||
bool shiftDown = keyFlags.HasFlag(.Shift);
|
||||
bool ctrlDown = keyFlags.HasFlag(.Ctrl);
|
||||
bool altDown = keyFlags.HasFlag(.Alt);
|
||||
|
||||
mIgnoreKeyChar = false;
|
||||
mEmbedSelected = null;
|
||||
|
||||
|
@ -4638,7 +4639,7 @@ namespace IDE.ui
|
|||
(autoCompleteRequireControl) &&
|
||||
(!gApp.mSettings.mTutorialsFinished.mCtrlCursor))
|
||||
{
|
||||
if (mWidgetWindow.IsKeyDown(.Control))
|
||||
if (ctrlDown)
|
||||
{
|
||||
if ((DarkTooltipManager.sTooltip != null) && (DarkTooltipManager.sTooltip.mAllowMouseOutside))
|
||||
DarkTooltipManager.CloseTooltip();
|
||||
|
@ -4660,12 +4661,12 @@ namespace IDE.ui
|
|||
Thread.Sleep(300);
|
||||
}*/
|
||||
|
||||
/*if ((keyCode == KeyCode.Space) && (mWidgetWindow.IsKeyDown(KeyCode.Control)))
|
||||
{
|
||||
/*if ((keyCode == KeyCode.Space) && (mWidgetWindow.IsKeyDown(KeyCode.Control)))
|
||||
{
|
||||
//Debug.WriteLine("CursorPos: {0}", CursorTextPos);
|
||||
ShowAutoComplete();
|
||||
return;
|
||||
}*/
|
||||
return;
|
||||
}*/
|
||||
|
||||
if (keyCode == KeyCode.Apps)
|
||||
{
|
||||
|
@ -4674,28 +4675,28 @@ namespace IDE.ui
|
|||
return;
|
||||
}
|
||||
|
||||
if ((keyCode == KeyCode.Escape) && (mAutoComplete != null) && (mAutoComplete.IsShowing()))
|
||||
{
|
||||
mAutoComplete.Close();
|
||||
return;
|
||||
}
|
||||
if ((keyCode == KeyCode.Escape) && (mAutoComplete != null) && (mAutoComplete.IsShowing()))
|
||||
{
|
||||
mAutoComplete.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((keyCode == KeyCode.Escape) && (mOnEscape != null) && (mOnEscape()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((keyCode == KeyCode.Escape) && (mOnEscape != null) && (mOnEscape()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((keyCode == KeyCode.Escape) && (CurSelection != null) && (CurSelection.Value.HasSelection))
|
||||
{
|
||||
CurSelection = null;
|
||||
}
|
||||
if ((keyCode == KeyCode.Escape) && (CurSelection != null) && (CurSelection.Value.HasSelection))
|
||||
{
|
||||
CurSelection = null;
|
||||
}
|
||||
|
||||
if (((keyCode == KeyCode.Up) || (keyCode == KeyCode.Down) || (keyCode == KeyCode.PageUp) || (keyCode == KeyCode.PageDown)))
|
||||
{
|
||||
if ((IsPrimaryTextCursor()) && ((!autoCompleteRequireControl) || (mWidgetWindow.IsKeyDown(KeyCode.Control))))
|
||||
if (((keyCode == KeyCode.Up) || (keyCode == KeyCode.Down) || (keyCode == KeyCode.PageUp) || (keyCode == KeyCode.PageDown)))
|
||||
{
|
||||
if ((IsPrimaryTextCursor()) && ((!autoCompleteRequireControl) || (ctrlDown)))
|
||||
{
|
||||
if ((mAutoComplete != null) && (mAutoComplete.IsShowing()))
|
||||
{
|
||||
if ((mAutoComplete != null) && (mAutoComplete.IsShowing()))
|
||||
{
|
||||
bool wantListCursors = false;
|
||||
|
||||
if (mAutoComplete.mAutoCompleteListWidget != null)
|
||||
|
@ -4704,37 +4705,37 @@ namespace IDE.ui
|
|||
wantListCursors = true;
|
||||
}
|
||||
|
||||
if (wantListCursors)
|
||||
{
|
||||
int32 pageSize = (int32)(mAutoComplete.mAutoCompleteListWidget.mScrollContentContainer.mHeight / mAutoComplete.mAutoCompleteListWidget.mItemSpacing - 0.5f);
|
||||
int32 moveDir = 0;
|
||||
switch (keyCode)
|
||||
{
|
||||
case KeyCode.Up: moveDir = -1;
|
||||
case KeyCode.Down: moveDir = 1;
|
||||
case KeyCode.PageUp: moveDir = -pageSize;
|
||||
case KeyCode.PageDown: moveDir = pageSize;
|
||||
if (wantListCursors)
|
||||
{
|
||||
int32 pageSize = (int32)(mAutoComplete.mAutoCompleteListWidget.mScrollContentContainer.mHeight / mAutoComplete.mAutoCompleteListWidget.mItemSpacing - 0.5f);
|
||||
int32 moveDir = 0;
|
||||
switch (keyCode)
|
||||
{
|
||||
case KeyCode.Up: moveDir = -1;
|
||||
case KeyCode.Down: moveDir = 1;
|
||||
case KeyCode.PageUp: moveDir = -pageSize;
|
||||
case KeyCode.PageDown: moveDir = pageSize;
|
||||
default:
|
||||
}
|
||||
mAutoComplete.mAutoCompleteListWidget.SelectDirection(moveDir);
|
||||
}
|
||||
else if (mAutoComplete.mInvokeWidget != null)
|
||||
{
|
||||
}
|
||||
mAutoComplete.mAutoCompleteListWidget.SelectDirection(moveDir);
|
||||
}
|
||||
else if (mAutoComplete.mInvokeWidget != null)
|
||||
{
|
||||
// Close the list if we had !wantListCursors
|
||||
if (mAutoComplete.mInvokeWidget.SelectDirection(((keyCode == KeyCode.Up) || (keyCode == KeyCode.PageUp)) ? -1 : 1))
|
||||
if (mAutoComplete.mInvokeWidget.SelectDirection(((keyCode == KeyCode.Up) || (keyCode == KeyCode.PageUp)) ? -1 : 1))
|
||||
{
|
||||
mAutoComplete?.CloseListWindow();
|
||||
mAutoComplete?.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disabled window-scroll code for ctrl+up/ctrl+down when autocomplete is not up
|
||||
if (mWidgetWindow.IsKeyDown(KeyCode.Control))
|
||||
if (ctrlDown)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mSourceViewPanel?.mRenameSymbolDialog?.mKind == .Rename)
|
||||
{
|
||||
|
@ -4765,7 +4766,7 @@ namespace IDE.ui
|
|||
|
||||
if (wantCursorPos != -1)
|
||||
{
|
||||
if (mWidgetWindow.IsKeyDown(.Shift))
|
||||
if (shiftDown)
|
||||
{
|
||||
if (CurSelection == null)
|
||||
CurSelection = .(CursorTextPos, wantCursorPos);
|
||||
|
@ -4780,43 +4781,43 @@ namespace IDE.ui
|
|||
}
|
||||
}
|
||||
|
||||
//var lineAndColumn = CursorLineAndColumn;
|
||||
//var lineAndColumn = CursorLineAndColumn;
|
||||
|
||||
int prevCursorPos;
|
||||
TryGetCursorTextPos(out prevCursorPos);
|
||||
int prevTextLength = mData.mTextLength;
|
||||
base.KeyDown(keyCode, isRepeat);
|
||||
int prevCursorPos;
|
||||
TryGetCursorTextPos(out prevCursorPos);
|
||||
int prevTextLength = mData.mTextLength;
|
||||
base.HandleKey(keyCode, keyFlags, isRepeat);
|
||||
|
||||
if ((IsPrimaryTextCursor()) && (mAutoComplete != null) &&
|
||||
if ((IsPrimaryTextCursor()) && (mAutoComplete != null) &&
|
||||
(keyCode != .Control) &&
|
||||
(keyCode != .Shift))
|
||||
{
|
||||
{
|
||||
mAutoComplete.MarkDirty();
|
||||
bool isCursorInRange = prevCursorPos == CursorTextPos;
|
||||
if (mAutoComplete.mInvokeSrcPositions != null)
|
||||
{
|
||||
isCursorInRange = (CursorTextPos > mAutoComplete.mInvokeSrcPositions[0]) &&
|
||||
(CursorTextPos <= mAutoComplete.mInvokeSrcPositions[mAutoComplete.mInvokeSrcPositions.Count - 1]);
|
||||
}
|
||||
bool isCursorInRange = prevCursorPos == CursorTextPos;
|
||||
if (mAutoComplete.mInvokeSrcPositions != null)
|
||||
{
|
||||
isCursorInRange = (CursorTextPos > mAutoComplete.mInvokeSrcPositions[0]) &&
|
||||
(CursorTextPos <= mAutoComplete.mInvokeSrcPositions[mAutoComplete.mInvokeSrcPositions.Count - 1]);
|
||||
}
|
||||
|
||||
bool wasNormalTyping =
|
||||
((isCursorInRange) && (prevTextLength == mData.mTextLength))/* ||
|
||||
((prevCursorPos + 1 == CursorTextPos) && (prevTextLength + 1 == mTextLength)) ||
|
||||
((prevCursorPos - 1 == CursorTextPos) && (prevTextLength - 1 == mTextLength))*/;
|
||||
bool wasNormalTyping =
|
||||
((isCursorInRange) && (prevTextLength == mData.mTextLength))/* ||
|
||||
((prevCursorPos + 1 == CursorTextPos) && (prevTextLength + 1 == mTextLength)) ||
|
||||
((prevCursorPos - 1 == CursorTextPos) && (prevTextLength - 1 == mTextLength))*/;
|
||||
|
||||
/*if ((lineAndColumn.mColumn != CursorLineAndColumn.mColumn) && (prevTextLength == mTextLength))
|
||||
wasNormalTyping = false; // Moved into virtual space*/
|
||||
/*if ((lineAndColumn.mColumn != CursorLineAndColumn.mColumn) && (prevTextLength == mTextLength))
|
||||
wasNormalTyping = false; // Moved into virtual space*/
|
||||
|
||||
if (!wasNormalTyping)
|
||||
{
|
||||
mAutoComplete.CloseInvoke();
|
||||
}
|
||||
if (!wasNormalTyping)
|
||||
{
|
||||
mAutoComplete.CloseInvoke();
|
||||
}
|
||||
else if ((keyCode == .Right) || (keyCode == .Left))
|
||||
{
|
||||
mAutoComplete.CloseListWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReplaceWord(int leftIdx, int rightIdx, String origWord, String newWord)
|
||||
{
|
||||
|
|
|
@ -188,6 +188,20 @@ namespace IDE.ui
|
|||
|
||||
return base.WantsUnfocus();
|
||||
}
|
||||
|
||||
public override void KeyDown(KeyDownEvent keyEvent)
|
||||
{
|
||||
if (keyEvent.mKeyCode == .Escape)
|
||||
{
|
||||
if (mPanel.mQuickFind.mWidgetWindow != null)
|
||||
{
|
||||
mPanel.mQuickFind.Close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
base.KeyDown(keyEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public class TrackedTextElementView
|
||||
|
@ -7743,5 +7757,58 @@ namespace IDE.ui
|
|||
mExplicitEmitTypes.Add(new .(typeName));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddSelectionToNextFindMatch(bool createCursor = true, bool exhaustiveSearch = false)
|
||||
{
|
||||
var ewc = mEditWidget.mEditWidgetContent as SourceEditWidgetContent;
|
||||
|
||||
if (mQuickFind != null)
|
||||
{
|
||||
int usedCursorCount = 0;
|
||||
for (var range in mQuickFind.mFoundRanges)
|
||||
{
|
||||
EditWidgetContent.TextCursor cursor = null;
|
||||
if (@range.Index < ewc.mTextCursors.Count)
|
||||
{
|
||||
cursor = ewc.mTextCursors[@range.Index];
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor = new EditWidgetContent.TextCursor(-1);
|
||||
ewc.mTextCursors.Add(cursor);
|
||||
}
|
||||
|
||||
usedCursorCount++;
|
||||
|
||||
EditSelection wantSel = .(range.Start, range.End);
|
||||
if (wantSel == cursor.mSelection)
|
||||
continue;
|
||||
|
||||
cursor.mCursorTextPos = (.)range.End;
|
||||
cursor.mSelection = wantSel;
|
||||
break;
|
||||
}
|
||||
|
||||
if (usedCursorCount > 0)
|
||||
{
|
||||
while (ewc.mTextCursors.Count > usedCursorCount)
|
||||
{
|
||||
var cursor = ewc.mTextCursors.PopBack();
|
||||
delete cursor;
|
||||
}
|
||||
}
|
||||
|
||||
mEditWidget.SetFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
ewc.AddSelectionToNextFindMatch(createCursor, exhaustiveSearch);
|
||||
}
|
||||
|
||||
public void MoveLastSelectionToNextFindMatch()
|
||||
{
|
||||
var ewc = mEditWidget.mEditWidgetContent as SourceEditWidgetContent;
|
||||
ewc.MoveLastSelectionToNextFindMatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue