1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-19 08:30:25 +02:00

Made Free Cursor Movement a setting (default false)

This commit is contained in:
Brian Fiete 2020-05-04 11:44:43 -07:00
parent a81f76ffcd
commit 562b565f49
4 changed files with 45 additions and 22 deletions

View file

@ -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);

View file

@ -103,6 +103,7 @@ namespace IDE.ui
});
AddPropertiesItem(category, "Show Line Numbers", "mShowLineNumbers");
AddPropertiesItem(category, "Free Cursor Movement", "mFreeCursorMovement");
category.Open(true, true);

View file

@ -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);