@@ -33,6 +33,8 @@ namespace Zep
33
33
{
34
34
35
35
const float ScrollBarSize = 17 .0f ;
36
+ const float UnderlineMargin = 1 .0f ;
37
+
36
38
ZepWindow::ZepWindow (ZepTabWindow& window, ZepBuffer* buffer)
37
39
: ZepComponent(window.GetEditor())
38
40
, m_tabWindow(window)
@@ -342,7 +344,7 @@ NVec2f ZepWindow::ArrangeLineMarkers(tRangeMarkers& markers)
342
344
{
343
345
// Account for markers
344
346
auto margins = DPI_VEC2 (GetEditor ().GetConfig ().widgetMargins );
345
- auto underlineHeight = DPI_Y (GetEditor ().GetConfig ().underlineHeight ) + DPI_Y (2 .0f );
347
+ auto underlineHeight = DPI_Y (GetEditor ().GetConfig ().underlineHeight ) + DPI_Y (UnderlineMargin * 2 .0f );
346
348
NVec2f height (0 .0f );
347
349
348
350
uint32_t lineWidgetCount = 0 ;
@@ -752,20 +754,37 @@ NRectf SquareRect(const NRectf& rc)
752
754
753
755
void ZepWindow::DisplayLineBackground (SpanInfo& lineInfo, ZepSyntax* pSyntax)
754
756
{
755
- auto cursorCL = BufferToDisplay ();
756
757
auto & display = GetEditor ().GetDisplay ();
757
758
758
759
auto widgetMargins = DPI_VEC2 (GetEditor ().GetConfig ().widgetMargins );
759
760
auto underlineHeight = DPI_Y (GetEditor ().GetConfig ().underlineHeight );
760
761
auto inlineMargins = DPI_VEC2 (GetEditor ().GetConfig ().inlineWidgetMargins );
761
-
762
762
auto screenPosX = m_textRegion->rect .Left () + m_xPad;
763
-
764
763
auto widgetMarkers = m_pBuffer->GetRangeMarkers (RangeMarkerType::Widget);
765
764
auto itrWidgetMarkers = widgetMarkers.begin ();
766
-
767
765
auto tipTimeSeconds = timer_get_elapsed_seconds (m_toolTipTimer);
768
766
767
+ NVec2f linePx = GetSpanPixelRange (lineInfo);
768
+
769
+ if (lineInfo.lineByteRange .ContainsLocation (GetBufferCursor ().Index ()))
770
+ {
771
+ // Note; We fill below the line for underlines for now, to make them standout in minimal mode
772
+ display.DrawRectFilled (
773
+ NRectf (
774
+ NVec2f (linePx.x , ToWindowY (lineInfo.yOffsetPx )),
775
+ NVec2f (linePx.y , ToWindowY (lineInfo.yOffsetPx + lineInfo.FullLineHeightPx () + lineInfo.lineWidgetHeights .y ))),
776
+ GetBlendedColor (ThemeColor::CursorLineBackground));
777
+ }
778
+ else
779
+ {
780
+ // Fill the background of the line
781
+ display.DrawRectFilled (
782
+ NRectf (
783
+ NVec2f (linePx.x , ToWindowY (lineInfo.yOffsetPx )),
784
+ NVec2f (linePx.y , ToWindowY (lineInfo.yOffsetPx + lineInfo.FullLineHeightPx () + lineInfo.lineWidgetHeights .y ))),
785
+ GetBlendedColor (ThemeColor::Background));
786
+ }
787
+
769
788
// Walk from the start of the line to the end of the line (in buffer chars)
770
789
for (auto & cp : lineInfo.lineCodePoints )
771
790
{
@@ -838,7 +857,8 @@ void ZepWindow::DisplayLineBackground(SpanInfo& lineInfo, ZepSyntax* pSyntax)
838
857
if (marker->displayType & RangeMarkerDisplayType::Underline)
839
858
{
840
859
float offset = lineInfo.yOffsetPx + lineInfo.FullLineHeightPx ();
841
- offset += marker->displayRow * (DPI_Y (2 .0f ) + underlineHeight) + 1 .0f ; // Margins & an extra line to seperate from background highlight
860
+ offset += marker->displayRow * (DPI_Y (UnderlineMargin * 2 ) + underlineHeight) + 1 .0f ; // Margins & an extra line to seperate from background highlight
861
+
842
862
display.DrawRectFilled (
843
863
NRectf (NVec2f (screenPosX, ToWindowY (offset)),
844
864
NVec2f (screenPosX + cp.size .x , ToWindowY (offset + underlineHeight))),
@@ -894,13 +914,13 @@ void ZepWindow::DisplayLineNumbers()
894
914
auto cursorCL = BufferToDisplay ();
895
915
auto & display = GetEditor ().GetDisplay ();
896
916
897
- if (m_indicatorRegion ->rect .Width () > 0 )
917
+ if (m_numberRegion ->rect .Width () > 0 )
898
918
{
899
919
for (long windowLine = m_visibleLineIndices.x ; windowLine < m_visibleLineIndices.y ; windowLine++)
900
920
{
901
921
auto & lineInfo = *m_windowLines[windowLine];
902
922
903
- if (!IsInsideTextRegion (NVec2i (0 , lineInfo.spanLineIndex )))
923
+ if (!IsInsideVisibleText (NVec2i (0 , lineInfo.spanLineIndex )))
904
924
return ;
905
925
906
926
auto cursorBufferLine = GetCursorLineInfo (cursorCL.y ).bufferLineNumber ;
@@ -959,6 +979,7 @@ void ZepWindow::DisplayLineNumbers()
959
979
}
960
980
}
961
981
982
+
962
983
// TODO: This function draws one char at a time. It could be more optimal at the expense of some
963
984
// complexity. Basically, I don't like the current implementation, but it works for now.
964
985
// The text is displayed acorrding to the region bounds and the display lineData
@@ -967,50 +988,31 @@ bool ZepWindow::DisplayLine(SpanInfo& lineInfo, int displayPass)
967
988
{
968
989
static const auto blankSpace = ' ' ;
969
990
970
- auto cursorCL = BufferToDisplay ();
971
- auto & display = GetEditor ().GetDisplay ();
972
- display.SetClipRect (m_bufferRegion->rect );
973
-
974
991
auto & buffer = GetBuffer ();
975
992
auto pMode = buffer.GetMode ();
976
993
if (!pMode)
977
994
{
978
995
return false ;
979
996
}
980
997
998
+ auto cursorCL = BufferToDisplay ();
999
+ auto & display = GetEditor ().GetDisplay ();
981
1000
auto pSyntax = m_pBuffer->GetSyntax ();
982
-
983
1001
auto cursorBlink = GetEditor ().GetCursorBlinkState ();
984
1002
auto cursorType = GetBuffer ().GetMode ()->GetCursorType ();
985
-
986
- auto defaultCharSize = GetEditor (). GetDisplay (). GetDefaultCharSize ();
1003
+ auto defaultCharSize = display. GetDefaultCharSize ();
1004
+ auto dotSize = display. GetDotSize ();
987
1005
auto whiteSpaceCol = m_pBuffer->GetTheme ().GetColor (ThemeColor::Whitespace);
988
-
989
1006
auto widgetMargins = DPI_VEC2 (GetEditor ().GetConfig ().widgetMargins );
990
1007
991
- auto dotSize = defaultCharSize / 8 .0f ;
992
- dotSize.x = std::min (dotSize.x , dotSize.y );
993
- dotSize.y = std::min (dotSize.x , dotSize.y );
994
- dotSize.x = std::max (1 .0f , dotSize.x );
995
- dotSize.y = std::max (1 .0f , dotSize.y );
996
-
997
1008
// Drawing commands for the whole line
998
1009
if (displayPass == WindowPass::Background)
999
1010
{
1000
1011
display.SetClipRect (m_textRegion->rect );
1001
1012
1002
- NVec2f linePx = GetSpanPixelRange (lineInfo);
1003
-
1004
- // Fill the background of the line
1005
- // TODO: Adjust pixelRenderRange
1006
- display.DrawRectFilled (
1007
- NRectf (
1008
- NVec2f (linePx.x , ToWindowY (lineInfo.yOffsetPx )),
1009
- NVec2f (linePx.y , ToWindowY (lineInfo.yOffsetPx + lineInfo.FullLineHeightPx ()))),
1010
- GetBlendedColor (ThemeColor::Background));
1011
-
1012
1013
DisplayLineBackground (lineInfo, pSyntax);
1013
1014
1015
+ /*
1014
1016
// Here we tell the syntax coloring about the active line
1015
1017
if (pSyntax)
1016
1018
{
@@ -1032,6 +1034,7 @@ bool ZepWindow::DisplayLine(SpanInfo& lineInfo, int displayPass)
1032
1034
}
1033
1035
}
1034
1036
}
1037
+ */
1035
1038
}
1036
1039
1037
1040
display.SetClipRect (m_textRegion->rect );
@@ -1192,7 +1195,7 @@ bool ZepWindow::DisplayLine(SpanInfo& lineInfo, int displayPass)
1192
1195
return true ;
1193
1196
}
1194
1197
1195
- bool ZepWindow::IsInsideTextRegion (NVec2i pos) const
1198
+ bool ZepWindow::IsInsideVisibleText (NVec2i pos) const
1196
1199
{
1197
1200
if (pos.y < m_visibleLineIndices.x || pos.y >= m_visibleLineIndices.y )
1198
1201
{
0 commit comments