Merge #9401 from justinmk/pr-win-erw7

This commit is contained in:
Justin M. Keyes 2018-12-30 23:54:23 +01:00 committed by GitHub
commit 725da1feeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 838 additions and 60 deletions

View File

@ -26,6 +26,10 @@ readonly -A entries=(
[tmux-256color]=tmux_256colour_terminfo
[vte-256color]=vte_256colour_terminfo
[xterm-256color]=xterm_256colour_terminfo
[cygwin]=cygwin_terminfo
[win32con]=win32con_terminfo
[conemu]=conemu_terminfo
[vtpcon]=vtpcon_terminfo
)
db="$(mktemp -du)"
@ -47,7 +51,7 @@ gunzip -f terminfo.src.gz
# Build terminfo database
#
print_bold '[*] Build terminfo database\n'
tic -x -o "$db" terminfo.src
cat terminfo.src scripts/windows.ti | tic -x -o "$db" -
rm -f terminfo.src
#
@ -72,18 +76,19 @@ EOF
for term in $sorted_terms; do
path="$(find "$db" -name "$term")"
if [[ -z $path ]]; then
echo "Not found: $term. Skipping." 1>&2
if [ -z "$path" ]; then
>&2 echo "Not found: $term. Skipping."
continue
fi
echo
printf '\n'
infocmp -L -1 -A "$db" "$term" | sed -e '1d' -e 's#^#// #' | tr '\t' ' '
echo "static const int8_t ${entries[$term]}[] = {"
echo -n " "; od -v -t d1 < "$path" | cut -c9- | xargs | tr ' ' ','
echo "};"
printf 'static const int8_t %s[] = {\n' "${entries[$term]}"
printf ' '
od -v -t d1 < "$path" | cut -c9- | xargs | tr ' ' ',' | tr -d '\n'
printf ' // NOLINT\n};\n'
done >> "$target"
cat > "$target" <<EOF
cat >> "$target" <<EOF
#endif // NVIM_TUI_TERMINFO_DEFS_H
EOF
print_bold 'done\n'

71
scripts/windows.ti Normal file
View File

@ -0,0 +1,71 @@
libuv+basekey|vt100 base function key for libuv,
kb2=\E[G, kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
kdch1=\E[3~, kend=\E[4~, kf1=\E[[A, kf10=\E[21~,
kf11=\E[23~, kf12=\E[24~, kf13=\E[25~, kf14=\E[26~,
kf15=\E[28~, kf16=\E[29~, kf17=\E[31~, kf18=\E[32~,
kf19=\E[33~, kf2=\E[[B, kf20=\E[34~, kf3=\E[[C, kf4=\E[[D,
kf5=\E[[E, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
khome=\E[1~, kich1=\E[2~, knp=\E[6~, kpp=\E[5~,
libuv+exkey|vt100 extend function key for libuv,
kf21=\E[23$, kf22=\E[24$, kf23=\E[11\^, kf24=\E[12\^,
kf25=\E[13\^, kf26=\E[14\^, kf27=\E[15\^, kf28=\E[17\^,
kf29=\E[18\^, kf30=\E[19\^, kf31=\E[20\^, kf32=\E[21\^,
kf33=\E[23\^, kf34=\E[24\^, kf35=\E[25\^, kf36=\E[26\^,
kf41=\E[32\^, kf42=\E[33\^, kf43=\E[34\^, kf44=\E[23@,
kf37=\E[28\^, kf38=\E[29\^, kf39=\E[31\^, kf45=\E[24@,
kDC=\E[3;2~, kEND=\E[4;2~, kHOM=\E[1;2~, kIC=\E[2;2~,
kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C,
win32con|ANSI emulation for libuv on legacy console,
hs@, fsl@, tsl@, xon@, acsc@, rmacs@, smacs@, dch@, dch1@, dl@, dl1@,
ich@, ich1@, il@, il1@, ind@, invis@, ri@, rmir@, rs1@, rmul@, smir@,
smul@, smpch@, u6@, u7@, u8@, u9@,
sgr=\E[0%?%p1%t;7%;%?%p3%t;7%;%?%p6%t;1%;m, sgr0=\E[0m,
Se=\E[0 q, Ss=\E[%p1%d q,
use=cygwin, use=libuv+exkey,
conemu|ANIS X3.64 and Xterm 256 colors for ConEmu with libuv,
ccc@, mc5i@, xenl@, acsc@, rmacs@, smacs@, blink@, cbt@,
cvvis@, cnorm=\E[?25h, dim@, flash@, hts@, initc@, invis@, is2@,
kf46@, kf47@, kf48@, kf49@, kf50@, kf51@, kf52@, kf53@, kf54@,
kf55@, kf56@, kf57@, kf58@, kf59@, kf60@, kf61@, kf62@, kf63@, kmous@,
mc0@, mc4@, mc5@, meml@, memu@, oc@, rmam@, rmcup=\E[?1049l,
smcup=\E[?1049h, rmir@, rmkx@, rmm@, rs1@, rs2@,
setab=\E[48;5;%p1%dm, setaf=\E[38;5;%p1%dm,
sgr=\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p6%t;1%;m,
sgr0=\E[0m, smam@, smir@, smkx@, smm@, tbc@, u6@, u7@, u8@, u9@,
Cr@, Cs@, Ms@, XM@, kDC3@, kDC4@, kDC5@, kDC6@, kDC7@,
kDN@, kDN3@, kDN4@, kDN5@, kDN6@, kDN7@,
kEND3@, kEND4@, kEND5@, kEND6@, kEND7@,
kHOM3@, kHOM4@, kHOM5@, kHOM6@, kHOM7@,
kIC3@, kIC4@, kIC5@, kIC6@, kIC7@,
kLFT3@, kLFT4@, kLFT5@, kLFT6@, kLFT7@,
kNXT3@, kNXT4@, kNXT5@, kNXT6@, kNXT7@,
kPRV3@, kPRV4@, kPRV5@, kPRV6@, kPRV7@,
kRIT3@, kRIT4@, kRIT5@, kRIT6@, kRIT7@,
kUP3@, kUP4@, kUP5@, kUP6@, kUP7@, rmxx@, smxx@, xm@,
use=libuv+basekey, use=libuv+exkey, use=xterm+256color, use=xterm-new,
vtpcon|ANIS emulation for console virtual terminal sequence with libuv,
ccc@, mc5i@, xenl@, blink@, acsc=jjkkllmmnnqqttuuvvwwxx,
cvvis@, dim@, flash@,
initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E,
invis@, is2=\E[!p\E[?3l,
kf46@, kf47@, kf48@, kf49@, kf50@, kf51@, kf52@, kf53@, kf54@,
kf55@, kf56@, kf57@, kf58@, kf59@, kf60@, kf61@, kf62@, kf63@, kmous@,
mc0@, mc4@, mc5@, meml@, memu@, oc@, rmam@, rmcup=\E[?1049l,
smcup=\E[?1049h, rmir@, rmkx@, rmm@, rs1@, rs2@,
sgr=\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p6%t;1%;m,
sgr0=\E[0m, smam@, smir@, smkx@, smm@, tbc@, u6@, u7@, u8@, u9@,
Cr@, Cs@, Ms@, XM@, kDC3@, kDC4@, kDC5@, kDC6@, kDC7@,
kDN@, kDN3@, kDN4@, kDN5@, kDN6@, kDN7@,
kEND3@, kEND4@, kEND5@, kEND6@, kEND7@,
kHOM3@, kHOM4@, kHOM5@, kHOM6@, kHOM7@,
kIC3@, kIC4@, kIC5@, kIC6@, kIC7@,
kLFT3@, kLFT4@, kLFT5@, kLFT6@, kLFT7@,
kNXT3@, kNXT4@, kNXT5@, kNXT6@, kNXT7@,
kPRV3@, kPRV4@, kPRV5@, kPRV6@, kPRV7@,
kRIT3@, kRIT4@, kRIT5@, kRIT6@, kRIT7@,
kUP3@, kUP4@, kUP5@, kUP6@, kUP7@, rmxx@, smxx@, xm@,
use=libuv+basekey, use=libuv+exkey, use=xterm+256color, use=xterm-new,

View File

@ -955,13 +955,6 @@ void set_init_2(bool headless)
p_window = Rows - 1;
}
set_number_default("window", Rows - 1);
#if 0
// This bodges around problems that should be fixed in the TUI layer.
if (!headless && !os_term_is_nice()) {
set_string_option_direct((char_u *)"guicursor", -1, (char_u *)"",
OPT_GLOBAL, SID_NONE);
}
#endif
parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor'
(void)parse_printoptions(); // parse 'printoptions' default value
}

View File

@ -945,31 +945,6 @@ bool os_setenv_append_path(const char *fname)
return false;
}
/// Returns true if the terminal can be assumed to silently ignore unknown
/// control codes.
bool os_term_is_nice(void)
{
#if defined(__APPLE__) || defined(WIN32)
return true;
#else
const char *vte_version = os_getenv("VTE_VERSION");
if ((vte_version && atoi(vte_version) >= 3900)
|| os_getenv("KONSOLE_PROFILE_NAME")
|| os_getenv("KONSOLE_DBUS_SESSION")) {
return true;
}
const char *termprg = os_getenv("TERM_PROGRAM");
if (termprg && striequal(termprg, "iTerm.app")) {
return true;
}
const char *term = os_getenv("TERM");
if (term && strncmp(term, "rxvt", 4) == 0) {
return true;
}
return false;
#endif
}
/// Returns true if `sh` looks like it resolves to "cmd.exe".
bool os_shell_is_cmdexe(const char *sh)
FUNC_ATTR_NONNULL_ALL

60
src/nvim/os/tty.c Normal file
View File

@ -0,0 +1,60 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
//
// Terminal/console utils
//
#include "nvim/os/os.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/tty.c.generated.h"
#endif
#ifdef WIN32
# if !defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING)
# define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
# endif
/// Guesses the terminal-type. Calls SetConsoleMode() and uv_set_vterm_state()
/// if appropriate.
///
/// @param[in,out] term Name of the guessed terminal, statically-allocated
/// @param out_fd stdout file descriptor
void os_tty_guess_term(const char **term, int out_fd)
{
bool winpty = (os_getenv("NVIM") != NULL);
if (winpty) {
// Force TERM=win32con when running in winpty.
*term = "win32con";
uv_set_vterm_state(UV_UNSUPPORTED);
return;
}
bool conemu_ansi = strequal(os_getenv("ConEmuANSI"), "ON");
bool vtp = false;
HANDLE handle = (HANDLE)_get_osfhandle(out_fd);
DWORD dwMode;
if (handle != INVALID_HANDLE_VALUE && GetConsoleMode(handle, &dwMode)) {
dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
if (SetConsoleMode(handle, dwMode)) {
vtp = true;
}
}
if (*term == NULL) {
if (vtp) {
*term = "vtpcon";
} else if (conemu_ansi) {
*term = "conemu";
} else {
*term = "win32con";
}
}
if (conemu_ansi) {
uv_set_vterm_state(UV_SUPPORTED);
}
}
#endif

7
src/nvim/os/tty.h Normal file
View File

@ -0,0 +1,7 @@
#ifndef NVIM_OS_TTY_H
#define NVIM_OS_TTY_H
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "os/tty.h.generated.h"
#endif
#endif // NVIM_OS_TTY_H

View File

@ -105,6 +105,22 @@ static unibi_term *terminfo_builtin(const char *term, char **termname)
*termname = xstrdup("builtin_vte");
return unibi_from_mem((const char *)vte_256colour_terminfo,
sizeof vte_256colour_terminfo);
} else if (terminfo_is_term_family(term, "cygwin")) {
*termname = xstrdup("builtin_cygwin");
return unibi_from_mem((const char *)cygwin_terminfo,
sizeof cygwin_terminfo);
} else if (terminfo_is_term_family(term, "win32con")) {
*termname = xstrdup("builtin_win32con");
return unibi_from_mem((const char *)win32con_terminfo,
sizeof win32con_terminfo);
} else if (terminfo_is_term_family(term, "conemu")) {
*termname = xstrdup("builtin_conemu");
return unibi_from_mem((const char *)conemu_terminfo,
sizeof conemu_terminfo);
} else if (terminfo_is_term_family(term, "vtpcon")) {
*termname = xstrdup("builtin_vtpcon");
return unibi_from_mem((const char *)vtpcon_terminfo,
sizeof vtpcon_terminfo);
} else {
*termname = xstrdup("builtin_ansi");
return unibi_from_mem((const char *)ansi_terminfo,

File diff suppressed because one or more lines are too long

View File

@ -31,6 +31,7 @@
#include "nvim/event/signal.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/tty.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/ui_bridge.h"
@ -94,6 +95,7 @@ typedef struct {
bool can_change_scroll_region;
bool can_set_lr_margin;
bool can_set_left_right_margin;
bool can_scroll;
bool can_erase_chars;
bool immediate_wrap_after_last_column;
bool bce;
@ -211,8 +213,13 @@ static void terminfo_start(UI *ui)
data->out_fd = 1;
data->out_isatty = os_isatty(data->out_fd);
// Set up unibilium/terminfo.
const char *term = os_getenv("TERM");
#ifdef WIN32
os_tty_guess_term(&term, data->out_fd);
os_setenv("TERM", term, 1);
#endif
// Set up unibilium/terminfo.
data->ut = unibi_from_env();
char *termname = NULL;
if (!term || !data->ut) {
@ -246,9 +253,16 @@ static void terminfo_start(UI *ui)
data->can_set_left_right_margin =
!!unibi_get_str(data->ut, unibi_set_left_margin_parm)
&& !!unibi_get_str(data->ut, unibi_set_right_margin_parm);
data->can_scroll =
!!unibi_get_str(data->ut, unibi_delete_line)
&& !!unibi_get_str(data->ut, unibi_parm_delete_line)
&& !!unibi_get_str(data->ut, unibi_insert_line)
&& !!unibi_get_str(data->ut, unibi_parm_insert_line);
data->can_erase_chars = !!unibi_get_str(data->ut, unibi_erase_chars);
data->immediate_wrap_after_last_column =
terminfo_is_term_family(term, "cygwin")
terminfo_is_term_family(term, "conemu")
|| terminfo_is_term_family(term, "cygwin")
|| terminfo_is_term_family(term, "win32con")
|| terminfo_is_term_family(term, "interix");
data->bce = unibi_get_bool(data->ut, unibi_back_color_erase);
data->normlen = unibi_pre_fmt_str(data, unibi_cursor_normal,
@ -1044,11 +1058,12 @@ static void tui_grid_scroll(UI *ui, Integer g, Integer startrow, Integer endrow,
ugrid_scroll(grid, top, bot, left, right, (int)rows);
bool can_scroll = data->scroll_region_is_full_screen
|| (data->can_change_scroll_region
&& ((left == 0 && right == ui->width - 1)
|| data->can_set_lr_margin
|| data->can_set_left_right_margin));
bool can_scroll = data->can_scroll
&& (data->scroll_region_is_full_screen
|| (data->can_change_scroll_region
&& ((left == 0 && right == ui->width - 1)
|| data->can_set_lr_margin
|| data->can_set_left_right_margin)));
if (can_scroll) {
// Change terminal scroll region and move cursor to the top
@ -1499,6 +1514,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
bool mate_pretending_xterm = xterm && colorterm
&& strstr(colorterm, "mate-terminal");
bool true_xterm = xterm && !!xterm_version && !bsdvt;
bool cygwin = terminfo_is_term_family(term, "cygwin");
char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal);
if (fix_normal) {
@ -1687,6 +1703,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term,
|| iterm || iterm_pretending_xterm
|| teraterm // per TeraTerm "Supported Control Functions" doco
|| alacritty // https://github.com/jwilm/alacritty/pull/608
|| cygwin
// Some linux-type terminals implement the xterm extension.
// Example: console-terminal-emulator from the nosh toolset.
|| (linuxvt

View File

@ -772,6 +772,13 @@ describe("tui 'term' option", function()
end
end)
it('builtin terms', function()
-- These non-standard terminfos are always builtin.
assert_term('win32con', 'builtin_win32con')
assert_term('conemu', 'builtin_conemu')
assert_term('vtpcon', 'builtin_vtpcon')
end)
end)
-- These tests require `thelpers` because --headless/--embed

View File

@ -120,8 +120,13 @@ endif()
include(ExternalProject)
set(LIBUV_URL https://github.com/libuv/libuv/archive/v1.23.2.tar.gz)
set(LIBUV_SHA256 30af979c4f4b8d1b895ae6d115f7400c751542ccb9e656350fc89fda08d4eabd)
if(WIN32)
set(LIBUV_URL https://github.com/neovim/libuv/archive/0ed7feb71ca949f7a96ccb102481d17ea1bb5933.tar.gz)
set(LIBUV_SHA256 813fe763022f19878557c6fde311b6394fb9180caaaab0dd98d8704732234508)
else()
set(LIBUV_URL https://github.com/libuv/libuv/archive/v1.23.2.tar.gz)
set(LIBUV_SHA256 30af979c4f4b8d1b895ae6d115f7400c751542ccb9e656350fc89fda08d4eabd)
endif()
set(MSGPACK_URL https://github.com/msgpack/msgpack-c/releases/download/cpp-3.0.0/msgpack-3.0.0.tar.gz)
set(MSGPACK_SHA256 bfbb71b7c02f806393bc3cbc491b40523b89e64f83860c58e3e54af47de176e4)