Skip to content

Commit

Permalink
script_editor.as: Fixed line numbers not clipped at the top.
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Sep 21, 2023
1 parent 872608a commit 776868e
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions resources/scripts/script_editor.as
Original file line number Diff line number Diff line change
Expand Up @@ -601,21 +601,25 @@ class ScriptEditorTab

vector2 linenumCursorBase = screenCursor+vector2(0.f, -scrollY);
ImDrawList@ drawlist = ImGui::GetWindowDrawList();
int bufferNumLines = int(this.bufferLinesMeta.length());
int bufferNumLines = int(this.bufferLinesMeta.length());

vector2 linenumCursor = linenumCursorBase;
float coarseClipBottomY = (screenCursor.y+textAreaSize.y)-ImGui::GetTextLineHeight()*0.6;
float coarseClipTopY = screenCursor.y-ImGui::GetTextLineHeight()*0.7;
bool inRegion = false;

for (int linenum = 1; linenum <= bufferNumLines; linenum++)
for (int lineIdx = 0; lineIdx < bufferNumLines; lineIdx++)
{
if (linenumCursor.y > coarseClipBottomY)
break; // coarse clipping
vector2 linenumCursor = linenumCursorBase + vector2(0, lineIdx*ImGui::GetTextLineHeight());

int lineIdx = linenum - 1;
// Coarse clipping
if (linenumCursor.y < coarseClipTopY)
continue;
if (linenumCursor.y > coarseClipBottomY)
break;

if (drawLineNumbers)
{
drawlist.AddText(linenumCursor, lineNumberColor, ""+linenum);
drawlist.AddText(linenumCursor, lineNumberColor, ""+(lineIdx+1));
linenumCursor.x += lineNumColumnWidth;
}

Expand Down Expand Up @@ -680,13 +684,7 @@ class ScriptEditorTab

linenumCursor.x += lineRegionMarkerColumnWidth;
}

// prepare new Line
linenumCursor.x = linenumCursorBase.x;
linenumCursor.y += ImGui::GetTextLineHeight();
}


}

void drawTextAreaErrors()
Expand Down

0 comments on commit 776868e

Please sign in to comment.