mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Scope Prev/Next, other minor improvements
This commit is contained in:
parent
0154b75923
commit
9e009b134c
7 changed files with 115 additions and 4 deletions
|
@ -519,6 +519,13 @@ namespace Beefy.widgets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum DragSelectionKind
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Dragging,
|
||||||
|
ClickedInside
|
||||||
|
}
|
||||||
|
|
||||||
public Data mData ~ _.Deref(this);
|
public Data mData ~ _.Deref(this);
|
||||||
|
|
||||||
public Insets mTextInsets = new Insets() ~ delete _;
|
public Insets mTextInsets = new Insets() ~ delete _;
|
||||||
|
@ -540,6 +547,7 @@ namespace Beefy.widgets
|
||||||
public bool mJustInsertedCharPair; // Pressing backspace will delete last char8, even though cursor is between char8 pairs (ie: for brace pairs 'speculatively' inserted)
|
public bool mJustInsertedCharPair; // Pressing backspace will delete last char8, even though cursor is between char8 pairs (ie: for brace pairs 'speculatively' inserted)
|
||||||
public EditSelection? mSelection;
|
public EditSelection? mSelection;
|
||||||
public EditSelection? mDragSelectionUnion; // For double-clicking a word and then "dragging" the selection
|
public EditSelection? mDragSelectionUnion; // For double-clicking a word and then "dragging" the selection
|
||||||
|
public DragSelectionKind mDragSelectionKind;
|
||||||
public bool mIsReadOnly = false;
|
public bool mIsReadOnly = false;
|
||||||
public bool mWantsUndo = true;
|
public bool mWantsUndo = true;
|
||||||
public bool mIsMultiline = false;
|
public bool mIsMultiline = false;
|
||||||
|
@ -730,6 +738,8 @@ namespace Beefy.widgets
|
||||||
|
|
||||||
public override void MouseDown(float x, float y, int32 btn, int32 btnCount)
|
public override void MouseDown(float x, float y, int32 btn, int32 btnCount)
|
||||||
{
|
{
|
||||||
|
bool hadSelection = HasSelection();
|
||||||
|
|
||||||
base.MouseDown(x, y, btn, btnCount);
|
base.MouseDown(x, y, btn, btnCount);
|
||||||
mEditWidget.SetFocus();
|
mEditWidget.SetFocus();
|
||||||
|
|
||||||
|
@ -786,9 +796,13 @@ namespace Beefy.widgets
|
||||||
}
|
}
|
||||||
else if (!mWidgetWindow.IsKeyDown(KeyCode.Shift))
|
else if (!mWidgetWindow.IsKeyDown(KeyCode.Shift))
|
||||||
{
|
{
|
||||||
if ((btn != 0) && (mSelection != null) && (CursorTextPos >= mSelection.Value.MinPos) && (CursorTextPos <= mSelection.Value.MaxPos))
|
if ((mSelection != null) && (CursorTextPos >= mSelection.Value.MinPos) && (CursorTextPos <= mSelection.Value.MaxPos))
|
||||||
|
{
|
||||||
|
if (hadSelection)
|
||||||
{
|
{
|
||||||
// Leave selection
|
// Leave selection
|
||||||
|
mDragSelectionKind = .ClickedInside;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
StartSelection();
|
StartSelection();
|
||||||
|
@ -804,6 +818,9 @@ namespace Beefy.widgets
|
||||||
if (mMouseFlags == 0)
|
if (mMouseFlags == 0)
|
||||||
{
|
{
|
||||||
mDragSelectionUnion = null;
|
mDragSelectionUnion = null;
|
||||||
|
if (mDragSelectionKind == .ClickedInside)
|
||||||
|
mSelection = EditSelection();
|
||||||
|
mDragSelectionKind = .None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,6 +832,7 @@ namespace Beefy.widgets
|
||||||
{
|
{
|
||||||
MoveCursorToCoord(x, y);
|
MoveCursorToCoord(x, y);
|
||||||
ClampCursor();
|
ClampCursor();
|
||||||
|
if (mDragSelectionKind == .Dragging)
|
||||||
SelectToCursor();
|
SelectToCursor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2866,6 +2884,7 @@ namespace Beefy.widgets
|
||||||
|
|
||||||
public void StartSelection()
|
public void StartSelection()
|
||||||
{
|
{
|
||||||
|
mDragSelectionKind = .Dragging;
|
||||||
mSelection = EditSelection();
|
mSelection = EditSelection();
|
||||||
int textPos;
|
int textPos;
|
||||||
TryGetCursorTextPos(out textPos);
|
TryGetCursorTextPos(out textPos);
|
||||||
|
|
|
@ -70,6 +70,7 @@ namespace Beefy.widgets
|
||||||
[DesignEditable(SortName="0name")]
|
[DesignEditable(SortName="0name")]
|
||||||
public String Id { get { return mIdStr; } set { mIdStr = value; } }
|
public String Id { get { return mIdStr; } set { mIdStr = value; } }
|
||||||
|
|
||||||
|
public Event<delegate void(Widget)> mOnGotFocus ~ _.Dispose();
|
||||||
public Event<LostFocusHandler> mOnLostFocus ~ _.Dispose();
|
public Event<LostFocusHandler> mOnLostFocus ~ _.Dispose();
|
||||||
//public event MouseEventHandler mMouseMoveHandler;
|
//public event MouseEventHandler mMouseMoveHandler;
|
||||||
public Event<MouseEventHandler> mOnMouseDown ~ _.Dispose();
|
public Event<MouseEventHandler> mOnMouseDown ~ _.Dispose();
|
||||||
|
@ -390,6 +391,7 @@ namespace Beefy.widgets
|
||||||
{
|
{
|
||||||
Debug.Assert(!mHasFocus);
|
Debug.Assert(!mHasFocus);
|
||||||
mHasFocus = true;
|
mHasFocus = true;
|
||||||
|
mOnGotFocus(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void LostFocus()
|
public virtual void LostFocus()
|
||||||
|
|
|
@ -4808,6 +4808,20 @@ namespace IDE
|
||||||
mHistoryManager.NextHistory();
|
mHistoryManager.NextHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScopePrev()
|
||||||
|
{
|
||||||
|
var sewc = GetActiveSourceEditWidgetContent();
|
||||||
|
if (sewc != null)
|
||||||
|
sewc.ScopePrev();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScopeNext()
|
||||||
|
{
|
||||||
|
var sewc = GetActiveSourceEditWidgetContent();
|
||||||
|
if (sewc != null)
|
||||||
|
sewc.ScopeNext();
|
||||||
|
}
|
||||||
|
|
||||||
void ExitTest()
|
void ExitTest()
|
||||||
{
|
{
|
||||||
sExitTest = true;
|
sExitTest = true;
|
||||||
|
|
|
@ -485,6 +485,8 @@ namespace IDE
|
||||||
Add("Run Without Compiling", "Ctrl+Shift+F5");
|
Add("Run Without Compiling", "Ctrl+Shift+F5");
|
||||||
Add("Save All", "Ctrl+Shift+S");
|
Add("Save All", "Ctrl+Shift+S");
|
||||||
Add("Save File", "Ctrl+S");
|
Add("Save File", "Ctrl+S");
|
||||||
|
Add("Scope Prev", "Alt+Up");
|
||||||
|
Add("Scope Next", "Alt+Down");
|
||||||
Add("Set Next Statement", "Ctrl+Shift+F10");
|
Add("Set Next Statement", "Ctrl+Shift+F10");
|
||||||
Add("Show Auto Watches", "Ctrl+Alt+A");
|
Add("Show Auto Watches", "Ctrl+Alt+A");
|
||||||
Add("Show Autocomplete Panel", "Ctrl+Alt+U");
|
Add("Show Autocomplete Panel", "Ctrl+Alt+U");
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace IDE.ui
|
||||||
MakeEditable();
|
MakeEditable();
|
||||||
mEditWidget.mOnContentChanged.Add(new => NavigationBarChanged);
|
mEditWidget.mOnContentChanged.Add(new => NavigationBarChanged);
|
||||||
mEditWidget.mOnKeyDown.Add(new => EditKeyDownHandler);
|
mEditWidget.mOnKeyDown.Add(new => EditKeyDownHandler);
|
||||||
|
mEditWidget.mOnGotFocus.Add(new (widget) => mEditWidget.mEditWidgetContent.SelectAll());
|
||||||
mEditWidget.mEditWidgetContent.mWantsUndo = false;
|
mEditWidget.mEditWidgetContent.mWantsUndo = false;
|
||||||
mFocusDropdown = false;
|
mFocusDropdown = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,6 +383,13 @@ namespace IDE.ui
|
||||||
var bfSystem = IDEApp.sApp.mBfResolveSystem;
|
var bfSystem = IDEApp.sApp.mBfResolveSystem;
|
||||||
var bfCompiler = IDEApp.sApp.mBfResolveCompiler;
|
var bfCompiler = IDEApp.sApp.mBfResolveCompiler;
|
||||||
|
|
||||||
|
if (mGettingSymbolInfo)
|
||||||
|
{
|
||||||
|
gApp.Fail("Cannot rename symbols here");
|
||||||
|
mGettingSymbolInfo = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Assert(!mGettingSymbolInfo);
|
Debug.Assert(!mGettingSymbolInfo);
|
||||||
|
|
||||||
StopWork();
|
StopWork();
|
||||||
|
@ -855,7 +862,9 @@ namespace IDE.ui
|
||||||
if (mSourceViewPanel.[Friend]mWantsFullClassify)
|
if (mSourceViewPanel.[Friend]mWantsFullClassify)
|
||||||
hasWorkLeft = true;
|
hasWorkLeft = true;
|
||||||
if (mSourceViewPanel.HasDeferredResolveResults())
|
if (mSourceViewPanel.HasDeferredResolveResults())
|
||||||
|
{
|
||||||
hasWorkLeft = true;
|
hasWorkLeft = true;
|
||||||
|
}
|
||||||
if (!hasWorkLeft)
|
if (!hasWorkLeft)
|
||||||
{
|
{
|
||||||
StartWork();
|
StartWork();
|
||||||
|
|
|
@ -1521,6 +1521,70 @@ namespace IDE.ui
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ScopePrev()
|
||||||
|
{
|
||||||
|
int pos = CursorTextPos - 1;
|
||||||
|
int openCount = 0;
|
||||||
|
|
||||||
|
while (pos >= 0)
|
||||||
|
{
|
||||||
|
let c = mData.mText[pos].mChar;
|
||||||
|
let displayType = (SourceElementType)mData.mText[pos].mDisplayTypeId;
|
||||||
|
|
||||||
|
if (displayType == .Normal)
|
||||||
|
{
|
||||||
|
if (c == '{')
|
||||||
|
{
|
||||||
|
openCount--;
|
||||||
|
if (openCount <= 0)
|
||||||
|
{
|
||||||
|
CursorTextPos = pos;
|
||||||
|
EnsureCursorVisible();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (c == '}')
|
||||||
|
{
|
||||||
|
openCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pos--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ScopeNext()
|
||||||
|
{
|
||||||
|
int pos = CursorTextPos;
|
||||||
|
int openCount = 0;
|
||||||
|
|
||||||
|
while (pos < mData.mTextLength)
|
||||||
|
{
|
||||||
|
let c = mData.mText[pos].mChar;
|
||||||
|
let displayType = (SourceElementType)mData.mText[pos].mDisplayTypeId;
|
||||||
|
|
||||||
|
if (displayType == .Normal)
|
||||||
|
{
|
||||||
|
if (c == '}')
|
||||||
|
{
|
||||||
|
openCount--;
|
||||||
|
if (openCount <= 0)
|
||||||
|
{
|
||||||
|
CursorTextPos = pos + 1;
|
||||||
|
EnsureCursorVisible();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (c == '{')
|
||||||
|
{
|
||||||
|
openCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pos++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool IsTextSpanEmpty(int32 start, int32 length)
|
bool IsTextSpanEmpty(int32 start, int32 length)
|
||||||
{
|
{
|
||||||
for (int32 i = start; i < start + length; i++)
|
for (int32 i = start; i < start + length; i++)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue