Skip to content

Improve X-Axis Generation - #39

Merged
Lexer747 merged 9 commits into
mainfrom
synthace-dev
Jul 24, 2026
Merged

Lexer747 merged 9 commits into
mainfrom
synthace-dev

Conversation

@Synthace-Alex-Lewis

Copy link
Copy Markdown
Collaborator

Fixes #18

There was a few gotchas in the x-axis code I'd missed:

  • When following the origin padding and spans were over counted resulting in x-axis which were using too much space.
  • When many spans were shown at once the greedy algorithm confused concerns and remaining variable only decremented when a span was actually drawn, meaning the final span would not actually have any space left results in unused space.

This PR fixes the spans by properly de-coupling the allocation of spans to the tracking variable of the "budget" that is then allocated. cursorX is the new tracking variable which works in a similar way but with the new helper writePadding/xAxisDrawTimes it's now a subtle inversion of control that ensures that the span.Width is the source truth only done once and when written to the buffers it does not spill over it's allocation.

The following issue is fixed by the dedicated branch which now has a new comment:

// startX/endX drive plotting (full terminal), width drives label layout (drawable area only).

thus ensuring that span actually takes up the space it's allowed (accounting for the origin) instead of the raw terminal size.


Adds new tests for the following cases since it's clearly an area for regression.

Lexer747 pushed a commit that referenced this pull request Jul 19, 2026
I noticed on #39 that CI
didn't run because the base branch was `main`, this was the opposite of
what it was supposed to do. I think I originally got my `and` and `or`
mixed up.
@Synthace-Alex-Lewis
Synthace-Alex-Lewis force-pushed the synthace-dev branch 2 times, most recently from b5199fb to 24fe7cb Compare July 19, 2026 21:48
@Lexer747

Copy link
Copy Markdown
Owner

The following test cases do not look good. More work to do here.

@Lexer747
Lexer747 merged commit 8584948 into main Jul 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drawable Area Not Used

2 participants