Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pager friendly terminal formatting #1006

Merged

Conversation

walles
Copy link
Contributor

@walles walles commented Oct 2, 2024

Let's say a pager, like moar (uses Chroma for syntax highlighting) or less, shows a line in the middle of a file.

Unless that line starts with the correct formatting for the line, the pager would have to scan the whole file from the start to get the coloring of this single line right.

Before this PR, lines were not guaranteed to start with formatting, but could sometimes rely on formatting from the preceding lines.

With this change in place, lines can now stand by themselves, and paging will work better on Chroma's output.

Missing formatting at the start of the line would happen when a token had a linefeed in the middle.

Copy link
Owner

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, good idea!

@alecthomas alecthomas merged commit 876fb61 into alecthomas:master Oct 2, 2024
2 checks passed
@walles walles deleted the johan/pager-friendly-formatting branch October 3, 2024 04:53
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.

2 participants