Skip to content

Commit

Permalink
Change terminfo update logic, and update
Browse files Browse the repository at this point in the history
Using the tagged releases in the ncurses repository isn't actually a
good idea, since it fails to capture the patch releases made
subsequently.

Instead, we switch to grabbing the latest version and recording which
patch release it is. Normally, there would be a danger of grabbing
un-released changes, however this doesn't seem like an actual risk in
this case given how the ncurses repo seems to operate.
  • Loading branch information
tecosaur committed Feb 13, 2024
1 parent 003172d commit 1a76ed4
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions base/terminfo_data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ awk '/^#=run/{flag=1;next}/=#/{flag=0}flag{gsub(/__FILE__/,"\"'"$0"'\"");print}'
julia --startup-file=no -E 'readchomp("/dev/fd/0") |> Meta.parse |> eval' && echo "Done"; exit
=#

#=run
begin
const NCURSES_VERSION = "6.3"
=#

"""
struct TermCapability
Expand All @@ -38,19 +33,25 @@ struct TermCapability
end

#=run
begin
using Downloads
version_info = IOBuffer()
standard_caps = IOBuffer()
user_caps = IOBuffer()
Downloads.download("https://raw.githubusercontent.com/mirror/ncurses/v$NCURSES_VERSION/include/Caps", standard_caps)
Downloads.download("https://raw.githubusercontent.com/mirror/ncurses/v$NCURSES_VERSION/include/Caps-ncurses", user_caps)
Downloads.download("https://raw.githubusercontent.com/mirror/ncurses/master/VERSION", version_info)
Downloads.download("https://raw.githubusercontent.com/mirror/ncurses/master/include/Caps", standard_caps)
Downloads.download("https://raw.githubusercontent.com/mirror/ncurses/master/include/Caps-ncurses", user_caps)
const TERM_FLAGS = NTuple{3, String}[]
const TERM_NUMBERS = NTuple{3, String}[]
const TERM_STRINGS = NTuple{3, String}[]
const TERM_USER = NTuple{3, String}[]
_, ncurses_version, ncurses_date = split(read(seekstart(version_info), String))
for line in eachline(seekstart(standard_caps))
startswith(line, '#') && continue
components = split(line, '\t', keepempty=false)
Expand Down Expand Up @@ -98,11 +99,12 @@ const SENTINEL = "\n## GENERATED CODE BEYOND THIS POINT ##"
const PREAMBLE = readuntil(__FILE__, SENTINEL, keep=true)
out = IOBuffer()
write(out, PREAMBLE, "\n\n# Terminfo Capabilities as of NCurses $NCURSES_VERSION\n")
write(out, PREAMBLE, "\n\n# Terminfo Capabilities as of NCurses $ncurses_version-$ncurses_date\n",
"const NCURSES_VERSION = v\"$ncurses_version.$ncurses_date\"\n")
for (ftype, list) in [("flag", TERM_FLAGS), ("number", TERM_NUMBERS), ("string", TERM_STRINGS)]
print(out, "\n\"\"\"\n\
Ordered list of known terminal capability $ftype fields, as of NCurses $NCURSES_VERSION.\n\
Ordered list of known terminal capability $ftype fields, as of NCurses $ncurses_version-$ncurses_date.\n\
\"\"\"\n\
const TERM_$(uppercase(ftype))S = [")
namepad = maximum(textwidth, getindex.(list, 1)) + 1
Expand All @@ -129,14 +131,15 @@ function getcustomalias(allterms::Vector{NTuple{3, String}}, type, short, descri
"Su" => ":can_style_underline",
"csl" => ":clear_status_line",
"Ms" => ":set_host_clipboard",
"Tc" => ":truecolor")
"Tc" => ":truecolor",
"XF" => ":xterm_focus")
if startswith(short, 'k') && !occursin("keypad", description)
return ":key_" * replace(lowercase(description), r"[^a-z]" => '_')
end
return get(specific_aliases, short, "nothing")
end
print(out, "\n\"\"\"\nTerminfo extensions that NCurses $NCURSES_VERSION is aware of.\n\"\"\"",
print(out, "\n\"\"\"\nTerminfo extensions that NCurses $ncurses_version-$ncurses_date is aware of.\n\"\"\"",
"\nconst TERM_USER = Dict{Tuple{DataType, Symbol}, Union{Tuple{Nothing, String}, Tuple{Symbol, String}}}(")
shortpad = maximum(textwidth, getindex.(TERM_USER, 2)) + 1
for (type, short, description) in TERM_USER
Expand All @@ -153,10 +156,11 @@ end

## GENERATED CODE BEYOND THIS POINT ##

# Terminfo Capabilities as of NCurses 6.3
# Terminfo Capabilities as of NCurses 6.4-20230311
const NCURSES_VERSION = v"6.4.20230311"

"""
Ordered list of known terminal capability flag fields, as of NCurses 6.3.
Ordered list of known terminal capability flag fields, as of NCurses 6.4-20230311.
"""
const TERM_FLAGS = [
TermCapability(:auto_left_margin, :bw, "cub1 wraps from column 0 to last column"),
Expand Down Expand Up @@ -206,7 +210,7 @@ const TERM_FLAGS = [
]

"""
Ordered list of known terminal capability number fields, as of NCurses 6.3.
Ordered list of known terminal capability number fields, as of NCurses 6.4-20230311.
"""
const TERM_NUMBERS = [
TermCapability(:columns, :cols, "number of columns in a line"),
Expand Down Expand Up @@ -251,7 +255,7 @@ const TERM_NUMBERS = [
]

"""
Ordered list of known terminal capability string fields, as of NCurses 6.3.
Ordered list of known terminal capability string fields, as of NCurses 6.4-20230311.
"""
const TERM_STRINGS = [
TermCapability(:back_tab, :cbt, "back tab (P)"),
Expand Down Expand Up @@ -671,7 +675,7 @@ const TERM_STRINGS = [
]

"""
Terminfo extensions that NCurses 6.3 is aware of.
Terminfo extensions that NCurses 6.4-20230311 is aware of.
"""
const TERM_USER = Dict{Tuple{DataType, Symbol}, Union{Tuple{Nothing, String}, Tuple{Symbol, String}}}(
(Int, :CO ) => (nothing, "number of indexed colors overlaying RGB space"),
Expand Down Expand Up @@ -719,6 +723,15 @@ const TERM_USER = Dict{Tuple{DataType, Symbol}, Union{Tuple{Nothing, String}, Tu
(String, :Ss) => (:set_cursor_style, "change the cursor style."),
(String, :rmxx) => (:exit_strikeout_mode, "reset ECMA-48 strikeout/crossed-out attributes."),
(String, :smxx) => (:enter_strikeout_mode, "set ECMA-48 strikeout/crossed-out attributes."),
(String, :BD) => (nothing, "disables bracketed paste"),
(String, :BE) => (nothing, "enables bracketed paste"),
(String, :PE) => (nothing, "is sent after pasted text"),
(String, :PS) => (nothing, "is sent before pasted text"),
(String, :RV) => (nothing, "report terminal secondary device attributes"),
(String, :XR) => (nothing, "report terminal version as a free-format string."),
(Bool, :XF) => (:xterm_focus, "terminal supports xterm focus in/out"),
(String, :rv) => (nothing, "response to RV, regular expression"),
(String, :xr) => (nothing, "response to XR, regular expression"),
(String, :csl) => (:clear_status_line, "clear status line"),
(String, :kDC3) => (:key_alt_delete_character, "alt delete-character"),
(String, :kDC4) => (:key_shift_alt_delete_character, "shift+alt delete-character"),
Expand Down Expand Up @@ -776,5 +789,8 @@ const TERM_USER = Dict{Tuple{DataType, Symbol}, Union{Tuple{Nothing, String}, Tu
(String, :kb1) => (nothing, "vt220-keypad extensions"),
(String, :kb3) => (nothing, "vt220-keypad extensions"),
(String, :kc2) => (nothing, "vt220-keypad extensions"),
(String, :kxIN) => (:key_mouse_response_on_focus_in, "mouse response on focus-in"),
(String, :kxOUT) => (:key_mouse_response_on_focus_out, "mouse response on focus-out"),
(Bool, :Tc) => (:truecolor, "tmux extension to indicate 24-bit truecolor support"),
(Bool, :Su) => (:can_style_underline, "kitty extension to indicate styled underline support"),
)

0 comments on commit 1a76ed4

Please sign in to comment.