Hello, @Moosems !
First of all, I would like to thank you and all contributors for this amazing repository that's making my python text editor, Pytext, become true.
I'm opening this issue to discuss about a contribution to TkLineNums, to add tilde chars.
If you don't know what a tilde char is, I will show you an example with Vim:
![intro-vim-unix-text-editor-every-hacker-should-be-familiar-with w1456](https://private-user-images.githubusercontent.com/133379234/297761640-3ecbdc45-eca9-4c67-b2e0-c7b24901a956.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTc1MTA0NzQsIm5iZiI6MTcxNzUxMDE3NCwicGF0aCI6Ii8xMzMzNzkyMzQvMjk3NzYxNjQwLTNlY2JkYzQ1LWVjYTktNGM2Ny1iMmUwLWM3YjI0OTAxYTk1Ni5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjA0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYwNFQxNDA5MzRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kNTU4NTI0NzVhNzMwZTZmOTYxYTM1NzFhMDkwMTNmZGYxNzNiNTk4ZTc0M2RkOGFlNGQwYjA4OGVjMWFmNjE5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.smt5_KF5-ac64ee4_3AtDzY_wl75vVhBtnIutNjAv9Y)
The "~" chars are tilde chars. They represent non-lines in the line counter. In the current TkLineNums, tilde chars are not customizable and, if a line index is not existent, it is just ignored.
I changed your code so user can add a custom tilde char to its TkLineNums instance.
Example in my current code:
self.line_counter = TkLineNumbers(master, self, justify="right", colors=("#e3ba68", "#1D1E1E"),tilde="~", bd=0)
![image](https://private-user-images.githubusercontent.com/133379234/297762495-9c52fb38-db0f-4e0b-b260-d78673cab592.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTc1MTA0NzQsIm5iZiI6MTcxNzUxMDE3NCwicGF0aCI6Ii8xMzMzNzkyMzQvMjk3NzYyNDk1LTljNTJmYjM4LWRiMGYtNGUwYi1iMjYwLWQ3ODY3M2NhYjU5Mi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjA0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYwNFQxNDA5MzRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04ZTczNzk4MzhhZThmNjY3YTg3NGZkZjkwNzY0OWMzZTZmNWJiMTMyYWY4YjY0ODI2MmJiYWU0NWRhMWFlMTJjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.NTnqnOVhRIw3lT7N_uIzY6VnqQc0cyNRp_ckZBuZEIc)
If user doesn't provide a tilde parameter, It will be None. In this case, TkLineNums will work normally, so projects that already use TkLineNums won't break.
def __init__(
self: TkLineNumbers,
master: Misc,
textwidget: Text,
justify: str = "left",
# None means take colors from text widget (default).
# Otherwise it is a function that takes no arguments and returns (fg, bg) tuple.
colors: Callable[[], tuple[str, str]] | tuple[str, str] | None = None,
tilde: str | None = None,
*args,
**kwargs,
) -> None:
I hope you like my idea and my contribution is already done, It just needs to pull-request. Please, tell my what do you think about this new TkLineNums functionality.
Best regards!