mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-23 18:18:00 +02:00
Merge pull request #2136 from MineBill/line-spacing
Add a 'Line Height' options that allows changing the the line height of the text editor.
This commit is contained in:
commit
4ada557f64
5 changed files with 49 additions and 23 deletions
|
@ -98,6 +98,7 @@ namespace IDE.ui
|
|||
category.mTextColor = Color.Mult(DarkTheme.COLOR_TEXT, cHeaderColor);
|
||||
AddPropertiesItem(category, "Font", "mFonts");
|
||||
AddPropertiesItem(category, "Font Size", "mFontSize");
|
||||
AddPropertiesItem(category, "Line Height", "mLineHeight");
|
||||
AddPropertiesItem(category, "Autocomplete", "mAutoCompleteShowKind");
|
||||
AddPropertiesItem(category, "Autocomplete Require Control", "mAutoCompleteRequireControl");
|
||||
AddPropertiesItem(category, "Autocomplete Require Tab", "mAutoCompleteRequireTab");
|
||||
|
|
|
@ -858,6 +858,7 @@ namespace IDE.ui
|
|||
SetFont(IDEApp.sApp.mCodeFont, true, true);
|
||||
//SetFont(DarkTheme.sDarkTheme.mSmallFont, false, false);
|
||||
|
||||
mLineHeight = Math.Clamp(gApp.mSettings.mEditorSettings.mLineHeight, 0.125f, 10.0f);
|
||||
mWantsTabsAsSpaces = gApp.mSettings.mEditorSettings.mTabsOrSpaces == .Spaces;
|
||||
mTabLength = gApp.mSettings.mEditorSettings.mTabSize;
|
||||
mTabSize = mFont.GetWidth(scope String(' ', gApp.mSettings.mEditorSettings.mTabSize));
|
||||
|
@ -1211,11 +1212,12 @@ namespace IDE.ui
|
|||
if ((flags & ~(uint8)SourceElementFlags.Skipped) == 0)
|
||||
return;
|
||||
|
||||
let lineSpacing = Math.Round(mFont.GetLineSpacing() * mLineHeight);
|
||||
if ((flags & (uint8)SourceElementFlags.SymbolReference) != 0)
|
||||
{
|
||||
bool isRenameSymbol = (IDEApp.sApp.mSymbolReferenceHelper != null) && (IDEApp.sApp.mSymbolReferenceHelper.mKind == SymbolReferenceHelper.Kind.Rename);
|
||||
using (g.PushColor(isRenameSymbol ? (uint32)0x28FFFFFF : (uint32)0x18FFFFFF))
|
||||
g.FillRect(x, y, width, mFont.GetLineSpacing());
|
||||
g.FillRect(x, y, width, lineSpacing);
|
||||
|
||||
DrawSectionFlagsOver(g, x, y, width, (uint8)(flags & ~(uint8)SourceElementFlags.SymbolReference));
|
||||
return;
|
||||
|
@ -1224,7 +1226,7 @@ namespace IDE.ui
|
|||
if ((flags & (uint8)SourceElementFlags.Find_CurrentSelection) != 0)
|
||||
{
|
||||
using (g.PushColor(0x504C575C))
|
||||
g.FillRect(x, y, width, mFont.GetLineSpacing());
|
||||
g.FillRect(x, y, width, lineSpacing);
|
||||
|
||||
DrawSectionFlagsOver(g, x, y, width, (uint8)(flags & ~(uint8)(SourceElementFlags.Find_CurrentSelection | .Find_Matches)));
|
||||
return;
|
||||
|
@ -1233,7 +1235,7 @@ namespace IDE.ui
|
|||
if ((flags & (uint8)SourceElementFlags.Find_Matches) != 0)
|
||||
{
|
||||
using (g.PushColor(0x50D0C090))
|
||||
g.FillRect(x, y, width, mFont.GetLineSpacing());
|
||||
g.FillRect(x, y, width, lineSpacing);
|
||||
|
||||
DrawSectionFlagsOver(g, x, y, width, (uint8)(flags & ~(uint8)SourceElementFlags.Find_Matches));
|
||||
return;
|
||||
|
@ -1277,7 +1279,7 @@ namespace IDE.ui
|
|||
if (underlineColor != 0)
|
||||
{
|
||||
using (g.PushColor(underlineColor))
|
||||
gApp.DrawSquiggle(g, x, y, width);
|
||||
gApp.DrawSquiggle(g, x, y + GetTextOffset(), width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5853,7 +5855,7 @@ namespace IDE.ui
|
|||
}
|
||||
orderedEmitEmbeds.Sort(scope (lhs, rhs) => lhs.line <=> rhs.line);
|
||||
|
||||
float fontHeight = mFont.GetLineSpacing();
|
||||
float fontHeight = Math.Round(mFont.GetLineSpacing() * mLineHeight);
|
||||
int prevJumpIdx = -1;
|
||||
float jumpCoordSpacing = GetJumpCoordSpacing();
|
||||
|
||||
|
@ -6432,8 +6434,10 @@ namespace IDE.ui
|
|||
let height = mFont.GetHeight() + GS!(2);
|
||||
using (g.PushColor(DarkTheme.COLOR_CHAR_PAIR_HILITE))
|
||||
{
|
||||
g.FillRect(x1, y1, charWidth, height);
|
||||
g.FillRect(x2, y2, charWidth, height);
|
||||
float offset = GetTextOffset();
|
||||
|
||||
g.FillRect(x1, y1 + offset, charWidth, height);
|
||||
g.FillRect(x2, y2 + offset, charWidth, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4550,7 +4550,7 @@ namespace IDE.ui
|
|||
{
|
||||
float editX = GetEditX();
|
||||
|
||||
float lineSpacing = ewc.mFont.GetLineSpacing();
|
||||
float lineSpacing = Math.Round(ewc.mFont.GetLineSpacing() * ewc.mLineHeight);
|
||||
int cursorLineNumber = mEditWidget.mEditWidgetContent.CursorLineAndColumn.mLine;
|
||||
bool hiliteCurrentLine = mEditWidget.mHasFocus;
|
||||
|
||||
|
@ -4719,6 +4719,8 @@ namespace IDE.ui
|
|||
}*/
|
||||
}
|
||||
|
||||
float offset = ewc.GetTextOffset();
|
||||
|
||||
if ((gApp.mSettings.mEditorSettings.mShowLineNumbers) && (mEmbedKind == .None))
|
||||
{
|
||||
String lineStr = scope String(16);
|
||||
|
@ -4748,7 +4750,7 @@ namespace IDE.ui
|
|||
default: lineStr.AppendF("{0}", lineIdx + 1);
|
||||
}
|
||||
using (g.PushColor(DarkTheme.COLOR_TEXT))
|
||||
g.DrawString(lineStr, 0, GS!(2) + ewc.mLineCoords[lineIdx], FontAlign.Right, editX - GS!(14));
|
||||
g.DrawString(lineStr, 0, GS!(2) + ewc.mLineCoords[lineIdx] + offset, FontAlign.Right, editX - GS!(14));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4787,7 +4789,7 @@ namespace IDE.ui
|
|||
{
|
||||
using (g.PushColor(0xFFA5A5A5))
|
||||
{
|
||||
g.FillRect(editX - (int)GS!(7.5f), ewc.mLineCoords[lineIdx] - (int)GS!(0.5f), (int)GS!(1.5f), lineSpacing);
|
||||
g.FillRect(editX - (int)GS!(7.5f), ewc.mLineCoords[lineIdx] - offset - (int)GS!(0.5f), (int)GS!(1.5f), lineSpacing + offset);
|
||||
g.FillRect(editX - (int)GS!(7.5f), ewc.mLineCoords[lineIdx] + lineSpacing - (int)GS!(1.5f), GS!(5), (int)GS!(1.5f));
|
||||
}
|
||||
}
|
||||
|
@ -4859,7 +4861,7 @@ namespace IDE.ui
|
|||
mLinePointerDrawData.mUpdateCnt = gApp.mUpdateCnt;
|
||||
mLinePointerDrawData.mDebuggerContinueIdx = gApp.mDebuggerContinueIdx;
|
||||
g.Draw(img, mEditWidget.mX - GS!(20) - sDrawLeftAdjust,
|
||||
0 + ewc.GetLineY(lineNum, 0));
|
||||
0 + ewc.GetLineY(lineNum, 0) + ewc.GetTextOffset());
|
||||
}
|
||||
|
||||
if (mMousePos != null && mIsDraggingLinePointer)
|
||||
|
@ -4869,7 +4871,7 @@ namespace IDE.ui
|
|||
{
|
||||
using (g.PushColor(0x7FFFFFFF))
|
||||
g.Draw(img, mEditWidget.mX - GS!(20) - sDrawLeftAdjust,
|
||||
0 + ewc.GetLineY(dragLineNum, 0));
|
||||
0 + ewc.GetLineY(dragLineNum, 0) + ewc.GetTextOffset());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7556,7 +7558,7 @@ namespace IDE.ui
|
|||
SourceEditWidgetContent ewc = (.)mEditWidget.Content;
|
||||
Rect linePointerRect = .(
|
||||
mEditWidget.mX - GS!(20) - sDrawLeftAdjust,
|
||||
0 + ewc.GetLineY(mLinePointerDrawData.mLine, 0),
|
||||
0 + ewc.GetLineY(mLinePointerDrawData.mLine, 0) + ewc.GetTextOffset(),
|
||||
GS!(15),
|
||||
GS!(15)
|
||||
);
|
||||
|
@ -7573,7 +7575,7 @@ namespace IDE.ui
|
|||
else if (mIsDraggingLinePointer)
|
||||
{
|
||||
SourceEditWidgetContent ewc = (.)mEditWidget.Content;
|
||||
float linePos = ewc.GetLineY(GetLineAt(0, mMousePos.Value.y), 0);
|
||||
float linePos = ewc.GetLineY(GetLineAt(0, mMousePos.Value.y), 0) + ewc.GetTextOffset();
|
||||
Rect visibleRange = mEditWidget.GetVisibleContentRange();
|
||||
|
||||
if (visibleRange.Top > linePos)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue