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

[FEAT] TextArea relative line numbers #3382

Closed
TomJGooding opened this issue Sep 22, 2023 · 4 comments
Closed

[FEAT] TextArea relative line numbers #3382

TomJGooding opened this issue Sep 22, 2023 · 4 comments

Comments

@TomJGooding
Copy link
Contributor

Sorry, I'm going to bite the bullet and make the first feature request for the new TextArea!

Would you consider adding an option for relative/hybrid line numbers?

@github-actions
Copy link

We found the following entry in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review.

This is an automated reply, generated by FAQtory

@TomJGooding
Copy link
Contributor Author

I appreciate this feature request might be too niche. I've hacked together a custom TextArea class with a relative numbers option, which I'll share just for posterity (note you will need to copy and amend the existing render_line method).

class RnuTextArea(TextArea):
    relative_numbers: Reactive[bool] = reactive(False)

    @override
    def render_line(self, widget_y: int) -> Strip:
        # --snip--
            if not self.relative_numbers or line_index == cursor_row:
                line_number = line_index + 1
            else:
                line_number = abs(cursor_row - line_index)

            gutter = Text(
                f"{line_number:>{gutter_width_no_margin}}  ",
                style=gutter_style or "",
                end="",
            )
        # --snip--

@TomJGooding
Copy link
Contributor Author

Closing as stale as there doesn't seem to be any appetite for this.

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

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

No branches or pull requests

1 participant