mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 14:54:09 +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
|
@ -68,6 +68,7 @@ namespace Beefy.theme.dark
|
||||||
public Range? mLineRange;
|
public Range? mLineRange;
|
||||||
|
|
||||||
protected static uint32[] sDefaultColors = new uint32[] ( Color.White ) ~ delete _;
|
protected static uint32[] sDefaultColors = new uint32[] ( Color.White ) ~ delete _;
|
||||||
|
public static bool sDebugMultiCursor;
|
||||||
|
|
||||||
public float LineHeight => Math.Max(Math.Round(mFont.GetLineSpacing() * mLineHeightScale), 1);
|
public float LineHeight => Math.Max(Math.Round(mFont.GetLineSpacing() * mLineHeightScale), 1);
|
||||||
|
|
||||||
|
@ -573,7 +574,7 @@ namespace Beefy.theme.dark
|
||||||
|
|
||||||
bool drewCursor = false;
|
bool drewCursor = false;
|
||||||
|
|
||||||
void DrawCursor(float x, float y)
|
void DrawCursor(float x, float y, bool isSecondary = false)
|
||||||
{
|
{
|
||||||
if (mHiliteCurrentLine && selStartIdx == selEndIdx)
|
if (mHiliteCurrentLine && selStartIdx == selEndIdx)
|
||||||
{
|
{
|
||||||
|
@ -618,8 +619,18 @@ namespace Beefy.theme.dark
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
float cursorY = y + textYOffset;
|
||||||
|
float cursorHeight = fontLineSpacing;
|
||||||
|
float cursorWidth = Math.Max(1.0f, GS!(1));
|
||||||
|
|
||||||
|
if ((sDebugMultiCursor) && (mTextCursors.Count > 1))
|
||||||
|
{
|
||||||
|
if (isSecondary)
|
||||||
|
cursorColor.A = (.)(cursorColor.A * 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness))))
|
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness))))
|
||||||
g.FillRect(x, y + textYOffset, Math.Max(1.0f, GS!(1)), fontLineSpacing);
|
g.FillRect(x, cursorY, cursorWidth, cursorHeight);
|
||||||
}
|
}
|
||||||
drewCursor = true;
|
drewCursor = true;
|
||||||
}
|
}
|
||||||
|
@ -859,8 +870,7 @@ namespace Beefy.theme.dark
|
||||||
y = mLineCoords[eStartLine];
|
y = mLineCoords[eStartLine];
|
||||||
}
|
}
|
||||||
|
|
||||||
using (g.PushColor(0xFF80FFB3))
|
DrawCursor(x, y, true);
|
||||||
DrawCursor(x, y);
|
|
||||||
}
|
}
|
||||||
SetTextCursor(prevTextCursor);
|
SetTextCursor(prevTextCursor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2801,9 +2801,11 @@ namespace Beefy.widgets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void KeyDown(KeyCode keyCode, bool isRepeat)
|
public virtual void HandleKey(KeyCode keyCode, KeyFlags keyFlags, bool isRepeat)
|
||||||
{
|
{
|
||||||
base.KeyDown(keyCode, isRepeat);
|
bool shiftDown = keyFlags.HasFlag(.Shift);
|
||||||
|
bool ctrlDown = keyFlags.HasFlag(.Ctrl);
|
||||||
|
bool altDown = keyFlags.HasFlag(.Alt);
|
||||||
|
|
||||||
if (keyCode == KeyCode.Escape)
|
if (keyCode == KeyCode.Escape)
|
||||||
{
|
{
|
||||||
|
@ -2871,7 +2873,7 @@ namespace Beefy.widgets
|
||||||
{
|
{
|
||||||
bool doVirtualMove = true;
|
bool doVirtualMove = true;
|
||||||
|
|
||||||
if ((mWidgetWindow.IsKeyDown(KeyCode.Shift)) || (mWidgetWindow.IsKeyDown(KeyCode.Control)))
|
if ((shiftDown) || (ctrlDown))
|
||||||
doVirtualMove = false;
|
doVirtualMove = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2907,7 +2909,7 @@ namespace Beefy.widgets
|
||||||
|
|
||||||
|
|
||||||
wasMoveKey = true;
|
wasMoveKey = true;
|
||||||
SelectLeft(lineIdx, lineChar, mWidgetWindow.IsKeyDown(KeyCode.Control), mWidgetWindow.IsKeyDown(KeyCode.Alt));
|
SelectLeft(lineIdx, lineChar, ctrlDown, altDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2919,7 +2921,7 @@ namespace Beefy.widgets
|
||||||
{
|
{
|
||||||
bool doVirtualMove = true;
|
bool doVirtualMove = true;
|
||||||
|
|
||||||
if ((mWidgetWindow.IsKeyDown(KeyCode.Shift)) || (mWidgetWindow.IsKeyDown(KeyCode.Control)))
|
if ((shiftDown) || (ctrlDown))
|
||||||
doVirtualMove = false;
|
doVirtualMove = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2947,7 +2949,7 @@ namespace Beefy.widgets
|
||||||
}
|
}
|
||||||
|
|
||||||
wasMoveKey = true;
|
wasMoveKey = true;
|
||||||
SelectRight(lineIdx, lineChar, mWidgetWindow.IsKeyDown(KeyCode.Control), mWidgetWindow.IsKeyDown(KeyCode.Alt));
|
SelectRight(lineIdx, lineChar, ctrlDown, altDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2956,7 +2958,8 @@ namespace Beefy.widgets
|
||||||
case KeyCode.Down:
|
case KeyCode.Down:
|
||||||
{
|
{
|
||||||
int32 aDir = (keyCode == KeyCode.Up) ? -1 : 1;
|
int32 aDir = (keyCode == KeyCode.Up) ? -1 : 1;
|
||||||
if ((HasSelection()) && (!mWidgetWindow.IsKeyDown(KeyCode.Shift)))
|
|
||||||
|
if ((HasSelection()) && (!shiftDown))
|
||||||
{
|
{
|
||||||
if (mAllowVirtualCursor)
|
if (mAllowVirtualCursor)
|
||||||
{
|
{
|
||||||
|
@ -2972,7 +2975,7 @@ namespace Beefy.widgets
|
||||||
|
|
||||||
GetCursorLineChar(out lineIdx, out lineChar);
|
GetCursorLineChar(out lineIdx, out lineChar);
|
||||||
|
|
||||||
if (mWidgetWindow.IsKeyDown(KeyCode.Control))
|
if (ctrlDown)
|
||||||
{
|
{
|
||||||
mEditWidget.VertScrollTo(mEditWidget.mVertPos.mDest + aDir * mEditWidget.mScrollContentContainer.mHeight * 0.25f);
|
mEditWidget.VertScrollTo(mEditWidget.mVertPos.mDest + aDir * mEditWidget.mScrollContentContainer.mHeight * 0.25f);
|
||||||
EnsureCursorVisible(false);
|
EnsureCursorVisible(false);
|
||||||
|
@ -3028,7 +3031,7 @@ namespace Beefy.widgets
|
||||||
case KeyCode.Home:
|
case KeyCode.Home:
|
||||||
PrepareForCursorMove(-1);
|
PrepareForCursorMove(-1);
|
||||||
wasMoveKey = true;
|
wasMoveKey = true;
|
||||||
if (mWidgetWindow.IsKeyDown(KeyCode.Control))
|
if (ctrlDown)
|
||||||
CursorToStart();
|
CursorToStart();
|
||||||
else
|
else
|
||||||
CursorToLineStart(true);
|
CursorToLineStart(true);
|
||||||
|
@ -3037,7 +3040,7 @@ namespace Beefy.widgets
|
||||||
case KeyCode.End:
|
case KeyCode.End:
|
||||||
PrepareForCursorMove(1);
|
PrepareForCursorMove(1);
|
||||||
wasMoveKey = true;
|
wasMoveKey = true;
|
||||||
if (mWidgetWindow.IsKeyDown(KeyCode.Control))
|
if (ctrlDown)
|
||||||
{
|
{
|
||||||
CursorToEnd();
|
CursorToEnd();
|
||||||
}
|
}
|
||||||
|
@ -3185,7 +3188,7 @@ namespace Beefy.widgets
|
||||||
|
|
||||||
if (wasMoveKey)
|
if (wasMoveKey)
|
||||||
{
|
{
|
||||||
if (mWidgetWindow.IsKeyDown(KeyCode.Shift))
|
if (shiftDown)
|
||||||
{
|
{
|
||||||
if (!HasSelection())
|
if (!HasSelection())
|
||||||
{
|
{
|
||||||
|
@ -3201,6 +3204,12 @@ namespace Beefy.widgets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void KeyDown(KeyCode keyCode, bool isRepeat)
|
||||||
|
{
|
||||||
|
base.KeyDown(keyCode, isRepeat);
|
||||||
|
HandleKey(keyCode, mWidgetWindow.GetKeyFlags(true), isRepeat);
|
||||||
|
}
|
||||||
|
|
||||||
public float GetCursorScreenRelY()
|
public float GetCursorScreenRelY()
|
||||||
{
|
{
|
||||||
float cursorX;
|
float cursorX;
|
||||||
|
@ -4350,7 +4359,7 @@ namespace Beefy.widgets
|
||||||
return !((lhsSelection.mEndPos <= rhsSelection.mStartPos) || (rhsSelection.mEndPos <= lhsSelection.mStartPos));
|
return !((lhsSelection.mEndPos <= rhsSelection.mStartPos) || (rhsSelection.mEndPos <= lhsSelection.mStartPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSelectionToNextFindMatch(bool createCursor = true, bool exhaustiveSearch = false)
|
public virtual void AddSelectionToNextFindMatch(bool createCursor = true, bool exhaustiveSearch = false)
|
||||||
{
|
{
|
||||||
SetPrimaryTextCursor();
|
SetPrimaryTextCursor();
|
||||||
|
|
||||||
|
@ -4432,6 +4441,38 @@ namespace Beefy.widgets
|
||||||
{
|
{
|
||||||
AddSelectionToNextFindMatch(createCursor: false);
|
AddSelectionToNextFindMatch(createCursor: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddMultiCursor(int32 dir)
|
||||||
|
{
|
||||||
|
var refTextCursor = mCurrentTextCursor;
|
||||||
|
var refTextPos = CursorTextPos;
|
||||||
|
|
||||||
|
for (var cursor in mTextCursors)
|
||||||
|
{
|
||||||
|
SetTextCursor(cursor);
|
||||||
|
var textPos = CursorTextPos;
|
||||||
|
|
||||||
|
if (Math.Sign(textPos <=> refTextPos) == dir)
|
||||||
|
{
|
||||||
|
refTextCursor = cursor;
|
||||||
|
refTextPos = textPos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var newCursor = new TextCursor(-1, refTextCursor);
|
||||||
|
mTextCursors.Add(newCursor);
|
||||||
|
|
||||||
|
SetTextCursor(mTextCursors.Back);
|
||||||
|
var startCursorPos = CursorLineAndColumn;
|
||||||
|
HandleKey((dir < 0) ? .Up : .Down, .None, false);
|
||||||
|
bool moved = startCursorPos != CursorLineAndColumn;
|
||||||
|
SetPrimaryTextCursor();
|
||||||
|
if (!moved)
|
||||||
|
{
|
||||||
|
mTextCursors.Remove(newCursor);
|
||||||
|
delete newCursor;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class EditWidget : ScrollableWidget
|
public abstract class EditWidget : ScrollableWidget
|
||||||
|
|
|
@ -194,6 +194,9 @@ namespace IDE
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
Add("About", new => gApp.ShowAbout);
|
Add("About", new => gApp.ShowAbout);
|
||||||
|
Add("Add Selection to Next Find Match", new => gApp.Cmd_AddSelectionToNextFindMatch);
|
||||||
|
Add("Add Cursor Above", new => gApp.Cmd_AddCursorAbove);
|
||||||
|
Add("Add Cursor Below", new => gApp.Cmd_AddCursorBelow);
|
||||||
Add("Autocomplete", new => gApp.Cmd_ShowAutoComplete, .None);
|
Add("Autocomplete", new => gApp.Cmd_ShowAutoComplete, .None);
|
||||||
Add("Bookmark Next", new => gApp.Cmd_NextBookmark, .Editor);
|
Add("Bookmark Next", new => gApp.Cmd_NextBookmark, .Editor);
|
||||||
Add("Bookmark Prev", new => gApp.Cmd_PrevBookmark, .Editor);
|
Add("Bookmark Prev", new => gApp.Cmd_PrevBookmark, .Editor);
|
||||||
|
@ -340,7 +343,6 @@ 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("Add Selection to Next Find Match", new => gApp.Cmd_AddSelectionToNextFindMatch);
|
|
||||||
Add("Move Last Selection to Next Find Match", new => gApp.Cmd_MoveLastSelectionToNextFindMatch);
|
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);
|
||||||
|
|
|
@ -5965,13 +5965,25 @@ namespace IDE
|
||||||
[IDECommand]
|
[IDECommand]
|
||||||
public void Cmd_AddSelectionToNextFindMatch()
|
public void Cmd_AddSelectionToNextFindMatch()
|
||||||
{
|
{
|
||||||
GetActiveSourceEditWidgetContent()?.AddSelectionToNextFindMatch();
|
GetActiveSourceViewPanel()?.AddSelectionToNextFindMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[IDECommand]
|
[IDECommand]
|
||||||
public void Cmd_MoveLastSelectionToNextFindMatch()
|
public void Cmd_MoveLastSelectionToNextFindMatch()
|
||||||
{
|
{
|
||||||
GetActiveSourceEditWidgetContent()?.MoveLastSelectionToNextFindMatch();
|
GetActiveSourceViewPanel()?.MoveLastSelectionToNextFindMatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
[IDECommand]
|
||||||
|
public void Cmd_AddCursorAbove()
|
||||||
|
{
|
||||||
|
GetActiveSourceEditWidgetContent()?.AddMultiCursor(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[IDECommand]
|
||||||
|
public void Cmd_AddCursorBelow()
|
||||||
|
{
|
||||||
|
GetActiveSourceEditWidgetContent()?.AddMultiCursor(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateMenuItem_HasActivePanel(IMenu menu)
|
public void UpdateMenuItem_HasActivePanel(IMenu menu)
|
||||||
|
@ -8574,11 +8586,6 @@ namespace IDE
|
||||||
|
|
||||||
void SysKeyDown(KeyDownEvent evt)
|
void SysKeyDown(KeyDownEvent evt)
|
||||||
{
|
{
|
||||||
if (evt.mKeyCode != .Alt)
|
|
||||||
{
|
|
||||||
NOP!();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!evt.mKeyFlags.HeldKeys.HasFlag(.Alt))
|
if (!evt.mKeyFlags.HeldKeys.HasFlag(.Alt))
|
||||||
{
|
{
|
||||||
#if BF_PLATFORM_WINDOWS
|
#if BF_PLATFORM_WINDOWS
|
||||||
|
@ -8756,6 +8763,13 @@ namespace IDE
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((evt.mKeyCode == .Return) && (evt.mKeyFlags.HasFlag(.Alt)))
|
||||||
|
{
|
||||||
|
// Don't "beep" for any Enter key combinations
|
||||||
|
window.mFocusWidget?.KeyDown(evt);
|
||||||
|
evt.mHandled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SysKeyUp(KeyCode keyCode)
|
void SysKeyUp(KeyCode keyCode)
|
||||||
|
|
|
@ -859,6 +859,8 @@ namespace IDE
|
||||||
|
|
||||||
public void SetDefaults()
|
public void SetDefaults()
|
||||||
{
|
{
|
||||||
|
Add("Add Cursor Above", "Ctrl+Alt+Up");
|
||||||
|
Add("Add Cursor Below", "Ctrl+Alt+Down");
|
||||||
Add("Add Selection to Next Find Match", "Ctrl+D");
|
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");
|
||||||
|
@ -1255,7 +1257,7 @@ namespace IDE
|
||||||
{
|
{
|
||||||
sd.Add("WakaTimeKey", mWakaTimeKey);
|
sd.Add("WakaTimeKey", mWakaTimeKey);
|
||||||
sd.Add("EnableDevMode", mEnableDevMode);
|
sd.Add("EnableDevMode", mEnableDevMode);
|
||||||
sd.Add("DebugMultiCursor", mEditorSettings.mDebugMultiCursor);
|
sd.Add("DebugMultiCursor", DarkEditWidgetContent.sDebugMultiCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (sd.CreateObject("TutorialsFinished"))
|
using (sd.CreateObject("TutorialsFinished"))
|
||||||
|
@ -1356,7 +1358,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);
|
sd.Get("DebugMultiCursor", ref DarkEditWidgetContent.sDebugMultiCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (sd.Open("TutorialsFinished"))
|
using (sd.Open("TutorialsFinished"))
|
||||||
|
|
|
@ -87,12 +87,12 @@ namespace IDE.ui
|
||||||
bool mFoundMatches;
|
bool mFoundMatches;
|
||||||
public bool mIsShowingMatches = false;
|
public bool mIsShowingMatches = false;
|
||||||
static String sLastSearchString = new String() ~ delete _;
|
static String sLastSearchString = new String() ~ delete _;
|
||||||
|
public List<Range> mFoundRanges = new .() ~ delete _;
|
||||||
|
|
||||||
public bool mOwnsSelection;
|
public bool mOwnsSelection;
|
||||||
PersistentTextPosition mSelectionStart ~ { Debug.Assert(_ == null); };
|
PersistentTextPosition mSelectionStart ~ { Debug.Assert(_ == null); };
|
||||||
PersistentTextPosition mSelectionEnd ~ { Debug.Assert(_ == null); };
|
PersistentTextPosition mSelectionEnd ~ { Debug.Assert(_ == null); };
|
||||||
|
|
||||||
|
|
||||||
public this(Widget parent, EditWidget editWidget, bool isReplace)
|
public this(Widget parent, EditWidget editWidget, bool isReplace)
|
||||||
{
|
{
|
||||||
mPanel = parent as TextPanel;
|
mPanel = parent as TextPanel;
|
||||||
|
@ -394,6 +394,7 @@ namespace IDE.ui
|
||||||
mCurFindCount = 0;
|
mCurFindCount = 0;
|
||||||
//mSearchDidWrap = false;
|
//mSearchDidWrap = false;
|
||||||
|
|
||||||
|
mFoundRanges.Clear();
|
||||||
ClearFlags(true, true);
|
ClearFlags(true, true);
|
||||||
if (mSelectionStart != null)
|
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)
|
if (doSelect)
|
||||||
FindNext(1, true, ErrorReportType.None);
|
DoFindNext(true);
|
||||||
|
|
||||||
int32 curFindIdx = mCurFindIdx;
|
int32 curFindIdx = mCurFindIdx;
|
||||||
while (FindNext(1, false, ErrorReportType.None))
|
while (DoFindNext(false))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
mCurFindIdx = curFindIdx;
|
mCurFindIdx = curFindIdx;
|
||||||
|
@ -483,7 +495,7 @@ namespace IDE.ui
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FindNext(dir, true, showMessage ? ErrorReportType.MessageBox : ErrorReportType.Sound))
|
if (FindNext(dir, true, showMessage ? ErrorReportType.MessageBox : ErrorReportType.Sound) case .Ok)
|
||||||
{
|
{
|
||||||
ShowCurrentSelection();
|
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;
|
var editContent = mEditWidget.Content;
|
||||||
|
|
||||||
|
@ -514,7 +526,7 @@ namespace IDE.ui
|
||||||
mFindEditWidget.GetText(findText);
|
mFindEditWidget.GetText(findText);
|
||||||
sLastSearchString.Set(findText);
|
sLastSearchString.Set(findText);
|
||||||
if (findText.Length == 0)
|
if (findText.Length == 0)
|
||||||
return false;
|
return .Err;
|
||||||
|
|
||||||
String findTextLower = scope String(findText);
|
String findTextLower = scope String(findText);
|
||||||
findTextLower.ToLower();
|
findTextLower.ToLower();
|
||||||
|
@ -610,7 +622,7 @@ namespace IDE.ui
|
||||||
|
|
||||||
mCurFindIdx = mCurFindStart + 1;
|
mCurFindIdx = mCurFindStart + 1;
|
||||||
mCurFindCount = 0;
|
mCurFindCount = 0;
|
||||||
return false;
|
return .Err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -623,7 +635,7 @@ namespace IDE.ui
|
||||||
|
|
||||||
mCurFindIdx = mCurFindStart - 1;
|
mCurFindIdx = mCurFindStart - 1;
|
||||||
mCurFindCount = 0;
|
mCurFindCount = 0;
|
||||||
return false;
|
return .Err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +658,7 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
mCurFindIdx = nextIdx;
|
mCurFindIdx = nextIdx;
|
||||||
return true;
|
return Range(mCurFindIdx, mCurFindIdx + findText.Length);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -668,7 +680,7 @@ namespace IDE.ui
|
||||||
ShowDoneError(errorType);
|
ShowDoneError(errorType);
|
||||||
mCurFindCount = 0;
|
mCurFindCount = 0;
|
||||||
}
|
}
|
||||||
return false;
|
return .Err;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCurFindIdx = -1;
|
mCurFindIdx = -1;
|
||||||
|
|
|
@ -4622,11 +4622,12 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// summary = "Hey This is a summary"
|
public override void HandleKey(KeyCode keyCode, KeyFlags keyFlags, bool isRepeat)
|
||||||
/// param.keyCode = "Keycode of pressed key"
|
{
|
||||||
/// param.isRepeat = "Whether the key is repeated"
|
bool shiftDown = keyFlags.HasFlag(.Shift);
|
||||||
public override void KeyDown(KeyCode keyCode, bool isRepeat)
|
bool ctrlDown = keyFlags.HasFlag(.Ctrl);
|
||||||
{
|
bool altDown = keyFlags.HasFlag(.Alt);
|
||||||
|
|
||||||
mIgnoreKeyChar = false;
|
mIgnoreKeyChar = false;
|
||||||
mEmbedSelected = null;
|
mEmbedSelected = null;
|
||||||
|
|
||||||
|
@ -4638,7 +4639,7 @@ namespace IDE.ui
|
||||||
(autoCompleteRequireControl) &&
|
(autoCompleteRequireControl) &&
|
||||||
(!gApp.mSettings.mTutorialsFinished.mCtrlCursor))
|
(!gApp.mSettings.mTutorialsFinished.mCtrlCursor))
|
||||||
{
|
{
|
||||||
if (mWidgetWindow.IsKeyDown(.Control))
|
if (ctrlDown)
|
||||||
{
|
{
|
||||||
if ((DarkTooltipManager.sTooltip != null) && (DarkTooltipManager.sTooltip.mAllowMouseOutside))
|
if ((DarkTooltipManager.sTooltip != null) && (DarkTooltipManager.sTooltip.mAllowMouseOutside))
|
||||||
DarkTooltipManager.CloseTooltip();
|
DarkTooltipManager.CloseTooltip();
|
||||||
|
@ -4660,12 +4661,12 @@ namespace IDE.ui
|
||||||
Thread.Sleep(300);
|
Thread.Sleep(300);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/*if ((keyCode == KeyCode.Space) && (mWidgetWindow.IsKeyDown(KeyCode.Control)))
|
/*if ((keyCode == KeyCode.Space) && (mWidgetWindow.IsKeyDown(KeyCode.Control)))
|
||||||
{
|
{
|
||||||
//Debug.WriteLine("CursorPos: {0}", CursorTextPos);
|
//Debug.WriteLine("CursorPos: {0}", CursorTextPos);
|
||||||
ShowAutoComplete();
|
ShowAutoComplete();
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
if (keyCode == KeyCode.Apps)
|
if (keyCode == KeyCode.Apps)
|
||||||
{
|
{
|
||||||
|
@ -4674,28 +4675,28 @@ namespace IDE.ui
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((keyCode == KeyCode.Escape) && (mAutoComplete != null) && (mAutoComplete.IsShowing()))
|
if ((keyCode == KeyCode.Escape) && (mAutoComplete != null) && (mAutoComplete.IsShowing()))
|
||||||
{
|
{
|
||||||
mAutoComplete.Close();
|
mAutoComplete.Close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((keyCode == KeyCode.Escape) && (mOnEscape != null) && (mOnEscape()))
|
if ((keyCode == KeyCode.Escape) && (mOnEscape != null) && (mOnEscape()))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((keyCode == KeyCode.Escape) && (CurSelection != null) && (CurSelection.Value.HasSelection))
|
if ((keyCode == KeyCode.Escape) && (CurSelection != null) && (CurSelection.Value.HasSelection))
|
||||||
{
|
{
|
||||||
CurSelection = 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)))
|
||||||
{
|
{
|
||||||
if ((IsPrimaryTextCursor()) && ((!autoCompleteRequireControl) || (mWidgetWindow.IsKeyDown(KeyCode.Control))))
|
if ((IsPrimaryTextCursor()) && ((!autoCompleteRequireControl) || (ctrlDown)))
|
||||||
{
|
{
|
||||||
if ((mAutoComplete != null) && (mAutoComplete.IsShowing()))
|
if ((mAutoComplete != null) && (mAutoComplete.IsShowing()))
|
||||||
{
|
{
|
||||||
bool wantListCursors = false;
|
bool wantListCursors = false;
|
||||||
|
|
||||||
if (mAutoComplete.mAutoCompleteListWidget != null)
|
if (mAutoComplete.mAutoCompleteListWidget != null)
|
||||||
|
@ -4704,37 +4705,37 @@ namespace IDE.ui
|
||||||
wantListCursors = true;
|
wantListCursors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wantListCursors)
|
if (wantListCursors)
|
||||||
{
|
{
|
||||||
int32 pageSize = (int32)(mAutoComplete.mAutoCompleteListWidget.mScrollContentContainer.mHeight / mAutoComplete.mAutoCompleteListWidget.mItemSpacing - 0.5f);
|
int32 pageSize = (int32)(mAutoComplete.mAutoCompleteListWidget.mScrollContentContainer.mHeight / mAutoComplete.mAutoCompleteListWidget.mItemSpacing - 0.5f);
|
||||||
int32 moveDir = 0;
|
int32 moveDir = 0;
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
case KeyCode.Up: moveDir = -1;
|
case KeyCode.Up: moveDir = -1;
|
||||||
case KeyCode.Down: moveDir = 1;
|
case KeyCode.Down: moveDir = 1;
|
||||||
case KeyCode.PageUp: moveDir = -pageSize;
|
case KeyCode.PageUp: moveDir = -pageSize;
|
||||||
case KeyCode.PageDown: moveDir = pageSize;
|
case KeyCode.PageDown: moveDir = pageSize;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
mAutoComplete.mAutoCompleteListWidget.SelectDirection(moveDir);
|
mAutoComplete.mAutoCompleteListWidget.SelectDirection(moveDir);
|
||||||
}
|
}
|
||||||
else if (mAutoComplete.mInvokeWidget != null)
|
else if (mAutoComplete.mInvokeWidget != null)
|
||||||
{
|
{
|
||||||
// Close the list if we had !wantListCursors
|
// 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?.CloseListWindow();
|
||||||
mAutoComplete?.Update();
|
mAutoComplete?.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disabled window-scroll code for ctrl+up/ctrl+down when autocomplete is not up
|
// Disabled window-scroll code for ctrl+up/ctrl+down when autocomplete is not up
|
||||||
if (mWidgetWindow.IsKeyDown(KeyCode.Control))
|
if (ctrlDown)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSourceViewPanel?.mRenameSymbolDialog?.mKind == .Rename)
|
if (mSourceViewPanel?.mRenameSymbolDialog?.mKind == .Rename)
|
||||||
{
|
{
|
||||||
|
@ -4765,7 +4766,7 @@ namespace IDE.ui
|
||||||
|
|
||||||
if (wantCursorPos != -1)
|
if (wantCursorPos != -1)
|
||||||
{
|
{
|
||||||
if (mWidgetWindow.IsKeyDown(.Shift))
|
if (shiftDown)
|
||||||
{
|
{
|
||||||
if (CurSelection == null)
|
if (CurSelection == null)
|
||||||
CurSelection = .(CursorTextPos, wantCursorPos);
|
CurSelection = .(CursorTextPos, wantCursorPos);
|
||||||
|
@ -4780,43 +4781,43 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//var lineAndColumn = CursorLineAndColumn;
|
//var lineAndColumn = CursorLineAndColumn;
|
||||||
|
|
||||||
int prevCursorPos;
|
int prevCursorPos;
|
||||||
TryGetCursorTextPos(out prevCursorPos);
|
TryGetCursorTextPos(out prevCursorPos);
|
||||||
int prevTextLength = mData.mTextLength;
|
int prevTextLength = mData.mTextLength;
|
||||||
base.KeyDown(keyCode, isRepeat);
|
base.HandleKey(keyCode, keyFlags, isRepeat);
|
||||||
|
|
||||||
if ((IsPrimaryTextCursor()) && (mAutoComplete != null) &&
|
if ((IsPrimaryTextCursor()) && (mAutoComplete != null) &&
|
||||||
(keyCode != .Control) &&
|
(keyCode != .Control) &&
|
||||||
(keyCode != .Shift))
|
(keyCode != .Shift))
|
||||||
{
|
{
|
||||||
mAutoComplete.MarkDirty();
|
mAutoComplete.MarkDirty();
|
||||||
bool isCursorInRange = prevCursorPos == CursorTextPos;
|
bool isCursorInRange = prevCursorPos == CursorTextPos;
|
||||||
if (mAutoComplete.mInvokeSrcPositions != null)
|
if (mAutoComplete.mInvokeSrcPositions != null)
|
||||||
{
|
{
|
||||||
isCursorInRange = (CursorTextPos > mAutoComplete.mInvokeSrcPositions[0]) &&
|
isCursorInRange = (CursorTextPos > mAutoComplete.mInvokeSrcPositions[0]) &&
|
||||||
(CursorTextPos <= mAutoComplete.mInvokeSrcPositions[mAutoComplete.mInvokeSrcPositions.Count - 1]);
|
(CursorTextPos <= mAutoComplete.mInvokeSrcPositions[mAutoComplete.mInvokeSrcPositions.Count - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wasNormalTyping =
|
bool wasNormalTyping =
|
||||||
((isCursorInRange) && (prevTextLength == mData.mTextLength))/* ||
|
((isCursorInRange) && (prevTextLength == mData.mTextLength))/* ||
|
||||||
((prevCursorPos + 1 == CursorTextPos) && (prevTextLength + 1 == mTextLength)) ||
|
((prevCursorPos + 1 == CursorTextPos) && (prevTextLength + 1 == mTextLength)) ||
|
||||||
((prevCursorPos - 1 == CursorTextPos) && (prevTextLength - 1 == mTextLength))*/;
|
((prevCursorPos - 1 == CursorTextPos) && (prevTextLength - 1 == mTextLength))*/;
|
||||||
|
|
||||||
/*if ((lineAndColumn.mColumn != CursorLineAndColumn.mColumn) && (prevTextLength == mTextLength))
|
/*if ((lineAndColumn.mColumn != CursorLineAndColumn.mColumn) && (prevTextLength == mTextLength))
|
||||||
wasNormalTyping = false; // Moved into virtual space*/
|
wasNormalTyping = false; // Moved into virtual space*/
|
||||||
|
|
||||||
if (!wasNormalTyping)
|
if (!wasNormalTyping)
|
||||||
{
|
{
|
||||||
mAutoComplete.CloseInvoke();
|
mAutoComplete.CloseInvoke();
|
||||||
}
|
}
|
||||||
else if ((keyCode == .Right) || (keyCode == .Left))
|
else if ((keyCode == .Right) || (keyCode == .Left))
|
||||||
{
|
{
|
||||||
mAutoComplete.CloseListWindow();
|
mAutoComplete.CloseListWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplaceWord(int leftIdx, int rightIdx, String origWord, String newWord)
|
void ReplaceWord(int leftIdx, int rightIdx, String origWord, String newWord)
|
||||||
{
|
{
|
||||||
|
|
|
@ -188,6 +188,20 @@ namespace IDE.ui
|
||||||
|
|
||||||
return base.WantsUnfocus();
|
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
|
public class TrackedTextElementView
|
||||||
|
@ -7743,5 +7757,58 @@ namespace IDE.ui
|
||||||
mExplicitEmitTypes.Add(new .(typeName));
|
mExplicitEmitTypes.Add(new .(typeName));
|
||||||
return true;
|
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