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

Improved terminfo parser #51198

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

tecosaur
Copy link
Contributor

@tecosaur tecosaur commented Sep 5, 2023

While the initial terminfo PR turned out fairly well (in my biased opinion anyway 😛), it could do with a few improvements. This is a draft PR to collect the work done so far and discuss what else should be done.

So far this fixes #51190 but not (yet) #51110. Across the 2873 terminfo files on my system, I currently see seven errors raised, all in the style of #51110 (for various screen.X terms).

The TermInfo struct has also been changed from

struct TermInfo
    names::Vector{String}
    flags::Int
    numbers::BitVector
    strings::BitVector
    extensions::Vector{Symbol}
    capabilities::Dict{Symbol, Union{Bool, Int, String}}
end

to

struct TermInfo
    names::Vector{String}
    flags::Dict{Symbol, Bool}
    numbers::Dict{Symbol, Int}
    strings::Dict{Symbol, String}
    extensions::Union{Nothing, Set{Symbol}}
end

So it's now not possible for get(::TermInfo, ::Symbol, default) to get a surprising type, with the following dedicated flag/number/string get methods.

This does slightly complicate haskey, keys, and getindex but I feel might be worth it overall? I'm interested in second opinions.

It would probably be nice to also add some more targeted test cases. We could probably use tic -x -o . for this?

@tecosaur
Copy link
Contributor Author

tecosaur commented Sep 5, 2023

Oh, for this too, please don't squash-merge this. I put effort into commit messages, and it makes me sad when github stomps on it and mangles some more of the commit data while it's at it.

@vchuravy vchuravy added the don't squash Don't squash merge label Sep 5, 2023
@tecosaur tecosaur force-pushed the terminfo-improvements branch 2 times, most recently from f1cb65a to 862c548 Compare September 5, 2023 15:26
@tecosaur
Copy link
Contributor Author

tecosaur commented Sep 5, 2023

Oh also, it would be good if anyone knew of any other terminfo parsers that we could easily test against, I've found it hard to locate anything easy to use.

@tecosaur tecosaur force-pushed the terminfo-improvements branch from 862c548 to b5e6ea3 Compare September 5, 2023 15:39
@vtjnash vtjnash marked this pull request as draft September 5, 2023 19:30
@vtjnash
Copy link
Member

vtjnash commented Sep 5, 2023

Converted this to a draft, since you described it as such. Comment when this is ready or convert it back to non-draft state.

@tecosaur tecosaur force-pushed the terminfo-improvements branch from b5e6ea3 to 7b071d4 Compare September 5, 2023 23:20
@brenhinkeller brenhinkeller added the display and printing Aesthetics and correctness of printed representations of objects. label Sep 15, 2023
@tecosaur tecosaur mentioned this pull request Sep 21, 2023
@tecosaur tecosaur force-pushed the terminfo-improvements branch from 7b071d4 to de26721 Compare September 26, 2023 11:52
@tecosaur
Copy link
Contributor Author

Took the need to rebase as an opportunity to remove more broadcasting, after it was raised as an annoyance in #51399 (comment).

@tecosaur tecosaur force-pushed the terminfo-improvements branch 2 times, most recently from 5f73406 to a84ddcb Compare September 26, 2023 12:03
@tecosaur
Copy link
Contributor Author

I haven't been able to figure out the linked bug, but it seems like this refactor fixes some problems people ran into on Slack, so maybe we should merge this for now as an improvement?

@tecosaur tecosaur marked this pull request as ready for review October 23, 2023 02:14
@christiangnrd
Copy link
Contributor

If #51110 is indeed fixed by #51399, this pull request can definitely move forward.

@tecosaur
Copy link
Contributor Author

I haven't been able to figure out the linked bug

I don't think #51399 has any bearing on the screen.xterm-256color bug, however as far as I am aware:

  • This PR improves the state of the terminfo parser, and resolves other issues people have raised with me on slack
  • This PR does not introduce any regressions

So I'm thinking we should merge this and keep on trying to work out exactly what is/should be going on with screen.xterm-256color. Ideally, generate a more comprehensive test set as well.

@christiangnrd
Copy link
Contributor

Starting from 2defa57, I am no longer able to reproduce #51110, but it reproduced in a127ab7, hence why I assumed it was fixed by #51399.

@tecosaur
Copy link
Contributor Author

If someone would be willing to review+merge this, or say why they think it shouldn't be yet, that would be much appreciated 🙏.

@PallHaraldsson
Copy link
Contributor

I don't know a lot about terminfo, is this mostly useful for the REPL (and non-Windows)? Can all of the terminfo functionality be excluded from the sysimage, until you do using REPL (it's now a stdlib)?

@tecosaur
Copy link
Contributor Author

I don't know a lot about terminfo, is this mostly useful for the REPL (and non-Windows)?

Pretty much. We want this for TTY output.

Can all of the terminfo functionality be excluded from the sysimage, until you do using REPL (it's now a stdlib)?

We'd actually need client.jl to become a stdlib (see #51350) and then this to become a stdlib (see #51618), but then I don't see why not.

I think this would be best discussed in a separate issue/PR though.

For now, this PR is just improving the current implementation. There are more (minor) improvements that I'd like to see made, but I don't want to let perfect be the enemy of the good (or here: better) which is why I'd like to see this "just merged".

@tecosaur tecosaur added the status: waiting for PR reviewer PR is complete and seems ready to merge. Has tests and news/compat if needed. CI failures unrelated. label Dec 28, 2023
@christiangnrd
Copy link
Contributor

Bump

@tecosaur tecosaur removed the don't squash Don't squash merge label Feb 1, 2024
@tecosaur
Copy link
Contributor Author

tecosaur commented Feb 4, 2024

This PR is still waiting for attention 🙂

This bundles up the following changes:

- Rejiged TermInfo struct
- Read the extended terminfo table using the same method as the
  non-extended table
- Use signed integer types for most numeric values, as per term(5)
- More robust get(::TermInfo, ...) methods
- Better match the terminfo(5) "Fetching Compiled Descriptions" behaviour
@vtjnash vtjnash force-pushed the terminfo-improvements branch from a84ddcb to 2b9d95c Compare February 5, 2024 20:49
@vtjnash vtjnash added merge me PR is reviewed. Merge when all tests are passing and removed status: waiting for PR reviewer PR is complete and seems ready to merge. Has tests and news/compat if needed. CI failures unrelated. labels Feb 5, 2024
@IanButterworth IanButterworth merged commit da8a441 into JuliaLang:master Feb 6, 2024
9 checks passed
@IanButterworth IanButterworth removed the merge me PR is reviewed. Merge when all tests are passing label Feb 6, 2024
@tecosaur tecosaur deleted the terminfo-improvements branch August 11, 2024 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

terminfo parser: extendedterminfo() results in conversion error for TERM=screen-256color
7 participants