-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Terminfo parser #50797
Terminfo parser #50797
Conversation
This is part of the groundwork for styled printing of StyledStrings.
One extra complication probably worth thinking about: with this, do we want to bundle a terminfo file (likely |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with a couple small nits
fec3fe1
to
15801b5
Compare
Thanks for the review Jameson 🙂. |
TermCapability(:kf61, :key_f61, "F61 function key"), | ||
TermCapability(:kf62, :key_f62, "F62 function key"), | ||
TermCapability(:kf63, :key_f63, "F63 function key"), | ||
TermCapability(:el1, :clr_bol, "Clear to beginning of line"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lowercase from here to the end, or is this intentional too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're talking about the inconsistent capitalization with the description strings, that's a consequence of the source I copied from.
15801b5
to
aafa946
Compare
aafa946
to
7925e17
Compare
At this point, short of any last-minute major issues, I think this should be good to go :) |
I'm rather confused by the test errors, depending on the platform it's:
So uh, I guess I'll leave this PR alone and hope. |
That said, I see what the |
201b203
to
192e32e
Compare
Ok, I think ignoring the spurious faliures there's one genuine one to address. the Windows i686 Mingw-32 entry, which has:
Not sure what's going on / what to do with this though. |
48db274
to
46ab691
Compare
Ok, now it looks like there are just libgit2 errors?? |
Implement a terminfo parser, and use it to replace the tput calls. While tput calls are fairly safe, given tput it part of the UNIX specification, it's nice to remove a system dependency and call one less executable. More crucially, switching to parsing terminfo ourselves makes it much more convenient to check terminfo capabilities. A try-catch wrapped success(`tput termcap`) call can now be replaced with a simple haskey(current_terminfo, :termcap) or get(current_terminfo, :termcap, false) as appropriate. This is part of the groundwork for styled printing of StyledStrings.
The terminfo files are taken from my local device, and the assertions are generated from the current terminfo implementation but have been partially manually checked for correctness. As such, this is mainly a barrier against potential implementation drift in the future, as unlikely as it may be.
The idea is still sound, but the REPL stdlib is not available in Base, and REPL.Terminals.raw! is non-trivial. Since this is the final fallback, and it's also been a bit flakey on various terminal emulators, we'll just remove it for now.
46ab691
to
2205231
Compare
Looks like force pushing with a trivial tweak to re-trigger CI makes the libgit2 issue go away, I'm guessing it was just transient. |
Thanks guys for giving this a look and helping me get the last few niggles sorted :) |
Oh I'm SO looking forward to better terminal string styling in Base! |
Thanks for your work on this @tecosaur! Very exciting progress |
Oh, I do see https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#git-recommendations-for-pull-request-reviewers, but it would have been nice if this was not-squashed. I generally put effort into nice discrete commits with descriptive messages — I rebase changes into the appropriate commit for the sake of a nice history. As it stands, I see those commits and the messages I wrote have been entirely lost, and the commit data is clobbered with GitHub's generated data. I don't think this is a big deal with this PR, but with say the styled strings PR I think it's very much worth keeping the commits I've curated. |
There is the |
That's nice, is there any way for that to automatically be applied to my PRs since I can't add labels myself? |
While looking at #51399 I was wondering if terminfo could be it's own standard library? |
It depends on how the |
Oh, I suppose I can just rebase and deal with the merge conflict if needed. |
Yeah I am more and more convinced that the rendering should be in the Client/REPL. |
What about stacktrace printing? |
IMO fancy stacktrace printing also belongs in the REPL. in a non-interactive mode, our stacktraces shouldn't have color or abreviate or do anything else fancy. |
Cool, 👍 sounds reasonable to me — just want to make sure we're all on the same page regarding what this means. It would be good to actually organise a triage-y call about StyledStrings and printing at an hour that's actually sane for me 😅. |
Why wouldn't you want to have colors for the stacktrace when you are executing a file? |
Currently colored printing outside the REPL is opt-in. E.g. try:
We mostly do that because their are many places where colored output will make the logs hard to read. |
Ah my mistake I had done |
I don't have on
I do agree that the later two should be colored by default, if the terminal supports it and there is no |
This PR is about obtaining information about the current terminal by inspecting the relevant terminfo file instead of calling
|
This was part of #49586, but it has been spun out so it an be discussed separately and once merged simplify #49586 a bit.
This introduces a pure-Julia terminfo parser, which means that:
tput
I am hoping this can be considered and (hopefully) merged in the near future 🙂.
Oh, and I think it's fun to note that it looks like this may well be the most concise standards-compliant Terminfo parsers in existence.