1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-23 18:18:00 +02:00

Added option to highlight current line when editing source files

This commit is contained in:
blat-blatnik 2022-01-07 01:49:20 +01:00
parent 5053cace5c
commit 28a0d118e5
5 changed files with 29 additions and 4 deletions

View file

@ -22,6 +22,7 @@ namespace Beefy.theme.dark
public bool mWantsCheckScrollPosition;
public uint32 mViewWhiteSpaceColor;
public bool mScrollToStartOnLostFocus;
public bool mHiliteCurrentLine;
protected static uint32[] sDefaultColors = new uint32[] ( Color.White ) ~ delete _;
@ -480,9 +481,20 @@ namespace Beefy.theme.dark
}
if (aX != -1)
{
{
if (mHiliteCurrentLine && selStartIdx == selEndIdx)
{
float totalLineWidth = mEditWidget.mWidth - mTextInsets.mLeft - mTextInsets.mRight - 1;
if (mEditWidget.mVertScrollbar != null)
totalLineWidth -= mEditWidget.mVertScrollbar.Width;
float thickness = 2 * (lineSpacing / 18);
using (g.PushColor(DarkTheme.COLOR_CURRENT_LINE_HILITE))
g.OutlineRect(0, curY, totalLineWidth, lineSpacing + thickness, thickness);
}
float brightness = (float)Math.Cos(Math.Max(0.0f, mCursorBlinkTicks - 20) / 9.0f);
brightness = Math.Max(0, Math.Min(1.0f, brightness * 2.0f + 1.6f));
brightness = Math.Clamp(brightness * 2.0f + 1.6f, 0, 1);
if (mEditWidget.mVertPos.IsMoving)
brightness = 0; // When we animate a pgup or pgdn, it's weird seeing the cursor scrolling around
@ -503,7 +515,7 @@ namespace Beefy.theme.dark
}
else
{
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness))))
using (g.PushColor(Color.Mult(cursorColor, Color.Get(brightness))))
g.FillRect(aX, curY, Math.Max(1.0f, GS!(1)), lineSpacing);
}
drewCursor = true;

View file

@ -191,6 +191,7 @@ namespace Beefy.theme.dark
public static uint32 COLOR_SELECTED_OUTLINE = 0xFFCFAE11;
public static uint32 COLOR_MENU_FOCUSED = 0xFFE5A910;
public static uint32 COLOR_MENU_SELECTED = 0xFFCB9B80;
public static uint32 COLOR_CURRENT_LINE_HILITE = 0xFF4C4C54;
public static float sScale = 1.0f;
public static int32 sSrcImgScale = 1;

View file

@ -6097,6 +6097,7 @@ namespace IDE
//mEditWidget.mVertScrollbar.mScrollIncrement = editWidgetContent.mFont.GetLineSpacing();
editWidgetContent.mHiliteColor = 0xFF384858;
editWidgetContent.mUnfocusedHiliteColor = 0x80384858;
editWidgetContent.mHiliteCurrentLine = mSettings.mEditorSettings.mHiliteCurrentLine;
return editWidget;
}

View file

@ -324,6 +324,7 @@ namespace IDE
public Color mBuildError = 0xFFFF8080;
public Color mBuildWarning = 0xFFFFFF80;
public Color mVisibleWhiteSpace = 0xFF9090C0;
public Color mCurrentLineHilite = 0xFF4C4C54;
public void Deserialize(StructuredData sd)
{
@ -348,6 +349,7 @@ namespace IDE
GetColor("WorkspaceFailedText", ref mWorkspaceFailedText);
GetColor("WorkspaceManualIncludeText", ref mWorkspaceManualIncludeText);
GetColor("WorkspaceIgnoredText", ref mWorkspaceIgnoredText);
GetColor("CurrentLineHilite", ref mCurrentLineHilite);
GetColor("Code", ref mCode);
GetColor("Keyword", ref mKeyword);
@ -411,6 +413,7 @@ namespace IDE
DarkTheme.COLOR_SELECTED_OUTLINE = mSelectedOutline;
DarkTheme.COLOR_MENU_FOCUSED = mMenuFocused;
DarkTheme.COLOR_MENU_SELECTED = mMenuSelected;
DarkTheme.COLOR_CURRENT_LINE_HILITE = mCurrentLineHilite;
}
}
@ -616,6 +619,7 @@ namespace IDE
public bool mFuzzyAutoComplete = false;
public bool mShowLocatorAnim = true;
public bool mHiliteCursorReferences = true;
public bool mHiliteCurrentLine = true;
public bool mLockEditing;
public LockWhileDebuggingKind mLockEditingWhenDebugging = .WhenNotHotSwappable;// Only applicable for
// non-Beef sources
@ -644,6 +648,7 @@ namespace IDE
sd.Add("FuzzyAutoComplete", mFuzzyAutoComplete);
sd.Add("ShowLocatorAnim", mShowLocatorAnim);
sd.Add("HiliteCursorReferences", mHiliteCursorReferences);
sd.Add("HiliteCurrentLine", mHiliteCurrentLine);
sd.Add("LockEditing", mLockEditing);
sd.Add("LockEditingWhenDebugging", mLockEditingWhenDebugging);
sd.Add("PerforceAutoCheckout", mPerforceAutoCheckout);
@ -675,6 +680,7 @@ namespace IDE
sd.Get("FuzzyAutoComplete", ref mFuzzyAutoComplete);
sd.Get("ShowLocatorAnim", ref mShowLocatorAnim);
sd.Get("HiliteCursorReferences", ref mHiliteCursorReferences);
sd.Get("HiliteCurrentLine", ref mHiliteCurrentLine);
sd.Get("LockEditing", ref mLockEditing);
sd.Get("LockEditingWhenDebugging", ref mLockEditingWhenDebugging);
sd.Get("PerforceAutoCheckout", ref mPerforceAutoCheckout);
@ -1189,6 +1195,10 @@ namespace IDE
}
}
for (let value in gApp.mFileEditData.Values)
if (value.mEditWidget != null)
((SourceEditWidgetContent)value.mEditWidget.Content).mHiliteCurrentLine = gApp.mSettings.mEditorSettings.mHiliteCurrentLine;
if (!mWakaTimeKey.IsEmpty)
{
if (gApp.mWakaTime == null)

View file

@ -101,6 +101,7 @@ namespace IDE.ui
AddPropertiesItem(category, "Fuzzy Autocomplete", "mFuzzyAutoComplete");
AddPropertiesItem(category, "Show Locator Animation", "mShowLocatorAnim");
AddPropertiesItem(category, "Hilite Symbol at Cursor", "mHiliteCursorReferences");
AddPropertiesItem(category, "Hilite Current Line", "mHiliteCurrentLine");
(?, propEntry) = AddPropertiesItem(category, "Spell Check", "mSpellCheckEnabled");
var resetButton = new DarkButton();
@ -128,7 +129,7 @@ namespace IDE.ui
AddPropertiesItem(category, "Format on Save", "mFormatOnSave");
AddPropertiesItem(category, "Sync with Workspace Panel", "mSyncWithWorkspacePanel");
AddPropertiesItem(category, "Wrap Comments at Column", "mWrapCommentsAt");
category.Open(true, true);
}