2018-02-12 15:10:09 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# usage: ./scripts/update_terminfo.sh
|
|
|
|
#
|
|
|
|
# This script does:
|
|
|
|
#
|
|
|
|
# 1. Download Dickey's terminfo.src
|
|
|
|
# 2. Compile temporary terminfo database from terminfo.src
|
|
|
|
# 3. Use database to generate src/nvim/tui/terminfo_defs.h
|
|
|
|
#
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
url='https://invisible-island.net/datafiles/current/terminfo.src.gz'
|
|
|
|
target='src/nvim/tui/terminfo_defs.h'
|
|
|
|
|
|
|
|
readonly -A entries=(
|
|
|
|
[ansi]=ansi_terminfo
|
|
|
|
[interix]=interix_8colour_terminfo
|
|
|
|
[iterm2]=iterm_256colour_terminfo
|
|
|
|
[linux]=linux_16colour_terminfo
|
|
|
|
[putty-256color]=putty_256colour_terminfo
|
|
|
|
[rxvt-256color]=rxvt_256colour_terminfo
|
|
|
|
[screen-256color]=screen_256colour_terminfo
|
|
|
|
[st-256color]=st_256colour_terminfo
|
|
|
|
[tmux-256color]=tmux_256colour_terminfo
|
|
|
|
[vte-256color]=vte_256colour_terminfo
|
|
|
|
[xterm-256color]=xterm_256colour_terminfo
|
2018-05-31 11:04:45 -07:00
|
|
|
[cygwin]=cygwin_terminfo
|
2018-10-24 03:57:53 -07:00
|
|
|
[win32con]=win32con_terminfo
|
|
|
|
[conemu]=conemu_terminfo
|
|
|
|
[vtpcon]=vtpcon_terminfo
|
2018-02-12 15:10:09 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
db="$(mktemp -du)"
|
|
|
|
|
|
|
|
print_bold() {
|
2022-10-30 05:50:41 -07:00
|
|
|
printf "\\e[1m%b\\e[0m" "$*"
|
2018-02-12 15:10:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
cd "$(git rev-parse --show-toplevel)"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Get terminfo.src
|
|
|
|
#
|
|
|
|
print_bold '[*] Get terminfo.src\n'
|
|
|
|
curl -O "$url"
|
|
|
|
gunzip -f terminfo.src.gz
|
|
|
|
|
|
|
|
#
|
|
|
|
# Build terminfo database
|
|
|
|
#
|
|
|
|
print_bold '[*] Build terminfo database\n'
|
2018-10-24 03:57:53 -07:00
|
|
|
cat terminfo.src scripts/windows.ti | tic -x -o "$db" -
|
2018-02-12 15:10:09 -07:00
|
|
|
rm -f terminfo.src
|
|
|
|
|
|
|
|
#
|
|
|
|
# Write src/nvim/tui/terminfo_defs.h
|
|
|
|
#
|
|
|
|
print_bold "[*] Writing $target... "
|
|
|
|
sorted_terms="$(echo "${!entries[@]}" | tr ' ' '\n' | sort | xargs)"
|
|
|
|
|
|
|
|
cat > "$target" <<EOF
|
2022-05-15 16:45:34 -07:00
|
|
|
// uncrustify:off
|
|
|
|
|
2018-08-11 07:06:57 -07:00
|
|
|
// Generated by scripts/update_terminfo.sh and $(tic -V)
|
|
|
|
|
2023-11-10 04:23:42 -07:00
|
|
|
#pragma once
|
2018-08-11 07:06:57 -07:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2018-02-12 15:10:09 -07:00
|
|
|
EOF
|
|
|
|
|
|
|
|
for term in $sorted_terms; do
|
|
|
|
path="$(find "$db" -name "$term")"
|
2018-12-28 07:46:47 -07:00
|
|
|
if [ -z "$path" ]; then
|
|
|
|
>&2 echo "Not found: $term. Skipping."
|
2018-02-12 15:10:09 -07:00
|
|
|
continue
|
|
|
|
fi
|
2018-12-28 07:46:47 -07:00
|
|
|
printf '\n'
|
2024-03-27 19:23:07 -07:00
|
|
|
infocmp -L -x -1 -A "$db" "$term" | sed -e '1d' -e 's#^#// #' | tr '\t' ' '
|
2018-12-28 07:46:47 -07:00
|
|
|
printf 'static const int8_t %s[] = {\n' "${entries[$term]}"
|
|
|
|
printf ' '
|
2022-05-15 16:45:34 -07:00
|
|
|
od -v -t d1 < "$path" | cut -c9- | xargs | tr ' ' ','
|
|
|
|
printf '};\n'
|
2018-02-12 15:10:09 -07:00
|
|
|
done >> "$target"
|
|
|
|
|
|
|
|
print_bold 'done\n'
|