mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Made Free Cursor Movement a setting (default false)
This commit is contained in:
parent
a81f76ffcd
commit
562b565f49
4 changed files with 45 additions and 22 deletions
|
@ -739,6 +739,7 @@ namespace Beefy.widgets
|
|||
StartSelection();
|
||||
|
||||
MoveCursorToCoord(x, y);
|
||||
ClampCursor();
|
||||
|
||||
//PrintF("~TestStruct() %d\n", mInner.mVal1);
|
||||
|
||||
|
@ -808,6 +809,7 @@ namespace Beefy.widgets
|
|||
if ((mMouseDown) && (mMouseFlags == .Left))
|
||||
{
|
||||
MoveCursorToCoord(x, y);
|
||||
ClampCursor();
|
||||
SelectToCursor();
|
||||
}
|
||||
}
|
||||
|
@ -2151,6 +2153,9 @@ namespace Beefy.widgets
|
|||
CursorLineAndColumn = LineAndColumn(lineAndColumn.mLine, lineAndColumn.mColumn + 1);
|
||||
EnsureCursorVisible(true, false, false);
|
||||
CursorMoved();
|
||||
|
||||
ClampCursor();
|
||||
if (lineAndColumn != CursorLineAndColumn)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2223,8 +2228,6 @@ namespace Beefy.widgets
|
|||
|
||||
if (mWidgetWindow.IsKeyDown(KeyCode.Control))
|
||||
{
|
||||
//mEditWidget.Resize(mEditWidget.mX, mEditWidget.mY, mEditWidget.mWidth, mEditWidget.mHeight + aDir);
|
||||
|
||||
mEditWidget.VertScrollTo(mEditWidget.mVertPos.mDest + aDir * mEditWidget.mScrollContentContainer.mHeight * 0.25f);
|
||||
EnsureCursorVisible(false);
|
||||
return;
|
||||
|
@ -2238,11 +2241,9 @@ namespace Beefy.widgets
|
|||
float cursorX;
|
||||
float cursorY;
|
||||
GetTextCoordAtCursor(out cursorX, out cursorY);
|
||||
mCursorWantX = cursorX;
|
||||
//mCursorWantX = cursorX;
|
||||
}
|
||||
|
||||
//if (!mAllowVirtualCursor)
|
||||
{
|
||||
lineIdx += aDir;
|
||||
|
||||
float wantedX = mCursorWantX;
|
||||
|
@ -2252,16 +2253,11 @@ namespace Beefy.widgets
|
|||
GetTextCoordAtLineChar(lineIdx, 0, out aX, out aY);
|
||||
MoveCursorToCoord(mCursorWantX, aY);
|
||||
|
||||
ClampCursor();
|
||||
|
||||
// Restore old desired X
|
||||
mCursorWantX = wantedX;
|
||||
}
|
||||
/*else
|
||||
{
|
||||
mCursorBlinkTicks = 0;
|
||||
var prevLineAndColumn = CursorLineAndColumn;
|
||||
CursorLineAndColumn = LineAndColumn(Math.Max(0, prevLineAndColumn.mLine + aDir), prevLineAndColumn.mColumn);
|
||||
CursorMoved();
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
if (didSelectionMove)
|
||||
|
|
|
@ -318,6 +318,7 @@ namespace IDE
|
|||
public bool mPerforceAutoCheckout = true;
|
||||
public bool mSpellCheckEnabled = true;
|
||||
public bool mShowLineNumbers = true;
|
||||
public bool mFreeCursorMovement;
|
||||
|
||||
public void Serialize(StructuredData sd)
|
||||
{
|
||||
|
@ -338,6 +339,7 @@ namespace IDE
|
|||
sd.Add("PerforceAutoCheckout", mPerforceAutoCheckout);
|
||||
sd.Add("SpellCheckEnabled", mSpellCheckEnabled);
|
||||
sd.Add("ShowLineNumbers", mShowLineNumbers);
|
||||
sd.Add("FreeCursorMovement", mFreeCursorMovement);
|
||||
|
||||
using (sd.CreateObject("Colors"))
|
||||
mColors.Serialize(sd);
|
||||
|
@ -364,6 +366,7 @@ namespace IDE
|
|||
sd.Get("PerforceAutoCheckout", ref mPerforceAutoCheckout);
|
||||
sd.Get("SpellCheckEnabled", ref mSpellCheckEnabled);
|
||||
sd.Get("ShowLineNumbers", ref mShowLineNumbers);
|
||||
sd.Get("FreeCursorMovement", ref mFreeCursorMovement);
|
||||
|
||||
using (sd.Open("Colors"))
|
||||
mColors.Deserialize(sd);
|
||||
|
|
|
@ -103,6 +103,7 @@ namespace IDE.ui
|
|||
});
|
||||
|
||||
AddPropertiesItem(category, "Show Line Numbers", "mShowLineNumbers");
|
||||
AddPropertiesItem(category, "Free Cursor Movement", "mFreeCursorMovement");
|
||||
|
||||
category.Open(true, true);
|
||||
|
||||
|
|
|
@ -3409,6 +3409,29 @@ namespace IDE.ui
|
|||
IDEApp.sApp.mSymbolReferenceHelper.SourceUpdateText(this, index);
|
||||
}
|
||||
|
||||
public override void ClampCursor()
|
||||
{
|
||||
base.ClampCursor();
|
||||
|
||||
if (mVirtualCursorPos == null)
|
||||
return;
|
||||
if (gApp.mSettings.mEditorSettings.mFreeCursorMovement)
|
||||
return;
|
||||
|
||||
int line;
|
||||
int lineChar;
|
||||
GetCursorLineChar(out line, out lineChar);
|
||||
|
||||
float wantWidth = 0;
|
||||
int virtualEnd = GetLineEndColumn(line, false, false, false, false, &wantWidth);
|
||||
|
||||
String curLineStr = scope String();
|
||||
GetLineText(line, curLineStr);
|
||||
int32 lineEnd = (int32)curLineStr.Length;
|
||||
|
||||
mVirtualCursorPos.ValueRef.mColumn = (.)Math.Min(mVirtualCursorPos.Value.mColumn, Math.Max(virtualEnd, lineEnd));
|
||||
}
|
||||
|
||||
public override void PhysCursorMoved()
|
||||
{
|
||||
//Debug.WriteLine("Cursor moved {0} {1}", CursorLineAndColumn.mLine, CursorLineAndColumn.mColumn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue