mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
win: support :terminal
This commit is contained in:
parent
a797856755
commit
4b1f21de75
@ -436,6 +436,7 @@ if(WIN32)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Network.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Network.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Svg.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Svg.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Widgets.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Widgets.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/winpty.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/
|
||||||
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/platforms/qwindows.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/platforms/
|
COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/platforms/qwindows.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/platforms/
|
||||||
)
|
)
|
||||||
|
@ -2,30 +2,53 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "nvim/vim.h"
|
||||||
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
|
#include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8
|
||||||
#include "nvim/os/pty_process_win.h"
|
#include "nvim/os/pty_process_win.h"
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "os/pty_process_win.c.generated.h"
|
# include "os/pty_process_win.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused)
|
static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
uv_async_t *finish_async = (uv_async_t *)context;
|
PtyProcess *ptyproc =
|
||||||
uv_async_send(finish_async);
|
(PtyProcess *)((uv_handle_t *)wait_eof_timer->data);
|
||||||
|
Process *proc = (Process *)ptyproc;
|
||||||
|
|
||||||
|
if (!uv_is_readable(proc->out->uvstream)) {
|
||||||
|
uv_timer_stop(&ptyproc->wait_eof_timer);
|
||||||
|
pty_process_finish2(ptyproc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pty_process_spawn(PtyProcess *ptyproc)
|
static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
PtyProcess *ptyproc = (PtyProcess *)context;
|
||||||
|
Process *proc = (Process *)ptyproc;
|
||||||
|
|
||||||
|
uv_timer_init(&proc->loop->uv, &ptyproc->wait_eof_timer);
|
||||||
|
ptyproc->wait_eof_timer.data = (void *)ptyproc;
|
||||||
|
uv_timer_start(&ptyproc->wait_eof_timer, wait_eof_timer_cb, 200, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
int pty_process_spawn(PtyProcess *ptyproc)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
Process *proc = (Process *)ptyproc;
|
Process *proc = (Process *)ptyproc;
|
||||||
bool success = false;
|
int status = 0;
|
||||||
winpty_error_ptr_t err = NULL;
|
winpty_error_ptr_t err = NULL;
|
||||||
winpty_config_t *cfg = NULL;
|
winpty_config_t *cfg = NULL;
|
||||||
winpty_spawn_config_t *spawncfg = NULL;
|
winpty_spawn_config_t *spawncfg = NULL;
|
||||||
winpty_t *wp = NULL;
|
winpty_t *wp = NULL;
|
||||||
char *in_name = NULL, *out_name = NULL;
|
char *in_name = NULL, *out_name = NULL;
|
||||||
HANDLE process_handle = NULL;
|
HANDLE process_handle = NULL;
|
||||||
|
uv_connect_t *in_req = NULL, *out_req = NULL;
|
||||||
|
wchar_t *cmdline = NULL, *cwd = NULL;
|
||||||
|
|
||||||
assert(proc->in && proc->out && !proc->err);
|
assert(proc->in && proc->out && !proc->err);
|
||||||
|
|
||||||
@ -33,52 +56,70 @@ bool pty_process_spawn(PtyProcess *ptyproc)
|
|||||||
WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err))) {
|
WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err))) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
winpty_config_set_initial_size(cfg, ptyproc->width, ptyproc->height);
|
winpty_config_set_initial_size(
|
||||||
|
cfg,
|
||||||
|
ptyproc->width,
|
||||||
|
ptyproc->height);
|
||||||
|
|
||||||
if (!(wp = winpty_open(cfg, &err))) {
|
if (!(wp = winpty_open(cfg, &err))) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
in_name = utf16_to_utf8(winpty_conin_name(wp));
|
if ((status = utf16_to_utf8(winpty_conin_name(wp), &in_name))) {
|
||||||
out_name = utf16_to_utf8(winpty_conout_name(wp));
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if ((status = utf16_to_utf8(winpty_conout_name(wp), &out_name))) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
in_req = xmalloc(sizeof(uv_connect_t));
|
||||||
|
out_req = xmalloc(sizeof(uv_connect_t));
|
||||||
uv_pipe_connect(
|
uv_pipe_connect(
|
||||||
xmalloc(sizeof(uv_connect_t)),
|
in_req,
|
||||||
&proc->in->uv.pipe,
|
&proc->in->uv.pipe,
|
||||||
in_name,
|
in_name,
|
||||||
pty_process_connect_cb);
|
pty_process_connect_cb);
|
||||||
uv_pipe_connect(
|
uv_pipe_connect(
|
||||||
xmalloc(sizeof(uv_connect_t)),
|
out_req,
|
||||||
&proc->out->uv.pipe,
|
&proc->out->uv.pipe,
|
||||||
out_name,
|
out_name,
|
||||||
pty_process_connect_cb);
|
pty_process_connect_cb);
|
||||||
|
|
||||||
// XXX: Provide the correct ptyprocess parameters (at least, the cmdline...
|
if (proc->cwd != NULL && (status = utf8_to_utf16(proc->cwd, &cwd))) {
|
||||||
// probably cwd too? what about environ?)
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if ((status = build_cmdline(proc->argv, &cmdline))) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
if (!(spawncfg = winpty_spawn_config_new(
|
if (!(spawncfg = winpty_spawn_config_new(
|
||||||
WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN,
|
WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN,
|
||||||
L"C:\\Windows\\System32\\cmd.exe",
|
NULL, cmdline, cwd, NULL, &err))) {
|
||||||
L"C:\\Windows\\System32\\cmd.exe",
|
|
||||||
NULL, NULL,
|
|
||||||
&err))) {
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (!winpty_spawn(wp, spawncfg, &process_handle, NULL, NULL, &err)) {
|
if (!winpty_spawn(wp, spawncfg, &process_handle, NULL, NULL, &err)) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
proc->pid = GetProcessId(process_handle);
|
||||||
|
|
||||||
uv_async_init(&proc->loop->uv, &ptyproc->finish_async, pty_process_finish2);
|
if (!RegisterWaitForSingleObject(
|
||||||
if (!RegisterWaitForSingleObject(&ptyproc->finish_wait, process_handle,
|
&ptyproc->finish_wait,
|
||||||
pty_process_finish1, &ptyproc->finish_async, INFINITE, 0)) {
|
process_handle, pty_process_finish1, ptyproc,
|
||||||
|
INFINITE, WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE)) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (in_req->handle || out_req->handle) {
|
||||||
|
uv_run(&proc->loop->uv, UV_RUN_ONCE);
|
||||||
|
}
|
||||||
|
|
||||||
ptyproc->wp = wp;
|
ptyproc->wp = wp;
|
||||||
ptyproc->process_handle = process_handle;
|
ptyproc->process_handle = process_handle;
|
||||||
wp = NULL;
|
wp = NULL;
|
||||||
process_handle = NULL;
|
process_handle = NULL;
|
||||||
success = true;
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
if (err != NULL) {
|
||||||
|
status = (int)winpty_error_code(err);
|
||||||
|
}
|
||||||
winpty_error_free(err);
|
winpty_error_free(err);
|
||||||
winpty_config_free(cfg);
|
winpty_config_free(cfg);
|
||||||
winpty_spawn_config_free(spawncfg);
|
winpty_spawn_config_free(spawncfg);
|
||||||
@ -88,7 +129,11 @@ cleanup:
|
|||||||
if (process_handle != NULL) {
|
if (process_handle != NULL) {
|
||||||
CloseHandle(process_handle);
|
CloseHandle(process_handle);
|
||||||
}
|
}
|
||||||
return success;
|
xfree(in_req);
|
||||||
|
xfree(out_req);
|
||||||
|
xfree(cmdline);
|
||||||
|
xfree(cwd);
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pty_process_resize(PtyProcess *ptyproc, uint16_t width,
|
void pty_process_resize(PtyProcess *ptyproc, uint16_t width,
|
||||||
@ -105,17 +150,10 @@ void pty_process_close(PtyProcess *ptyproc)
|
|||||||
{
|
{
|
||||||
Process *proc = (Process *)ptyproc;
|
Process *proc = (Process *)ptyproc;
|
||||||
|
|
||||||
ptyproc->is_closing = true;
|
|
||||||
pty_process_close_master(ptyproc);
|
pty_process_close_master(ptyproc);
|
||||||
|
|
||||||
uv_handle_t *finish_async_handle = (uv_handle_t *)&ptyproc->finish_async;
|
if (proc->internal_close_cb) {
|
||||||
if (ptyproc->finish_wait != NULL) {
|
proc->internal_close_cb(proc);
|
||||||
// Use INVALID_HANDLE_VALUE to block until either the wait is cancelled
|
|
||||||
// or the callback has signalled the uv_async_t.
|
|
||||||
UnregisterWaitEx(ptyproc->finish_wait, INVALID_HANDLE_VALUE);
|
|
||||||
uv_close(finish_async_handle, pty_process_finish_closing);
|
|
||||||
} else {
|
|
||||||
pty_process_finish_closing(finish_async_handle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,57 +171,123 @@ void pty_process_teardown(Loop *loop)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns a string freeable with xfree. Never returns NULL (OOM is a fatal
|
static void pty_process_connect_cb(uv_connect_t *req, int status)
|
||||||
// error). Windows appears to replace invalid UTF-16 code points (i.e.
|
|
||||||
// unpaired surrogates) using U+FFFD (the replacement character).
|
|
||||||
static char *utf16_to_utf8(LPCWSTR str)
|
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
int len = WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL);
|
assert(status == 0);
|
||||||
assert(len >= 1); // Even L"" has a non-zero length due to NUL terminator.
|
req->handle = NULL;
|
||||||
char *ret = xmalloc(len);
|
}
|
||||||
int len2 = WideCharToMultiByte(CP_UTF8, 0, str, -1, ret, len, NULL, NULL);
|
|
||||||
assert(len == len2);
|
static void pty_process_finish2(PtyProcess *ptyproc)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
Process *proc = (Process *)ptyproc;
|
||||||
|
|
||||||
|
UnregisterWaitEx(ptyproc->finish_wait, NULL);
|
||||||
|
uv_close((uv_handle_t *)&ptyproc->wait_eof_timer, NULL);
|
||||||
|
|
||||||
|
DWORD exit_code = 0;
|
||||||
|
GetExitCodeProcess(ptyproc->process_handle, &exit_code);
|
||||||
|
proc->status = (int)exit_code;
|
||||||
|
|
||||||
|
CloseHandle(ptyproc->process_handle);
|
||||||
|
ptyproc->process_handle = NULL;
|
||||||
|
|
||||||
|
proc->internal_exit_cb(proc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int build_cmdline(char **argv, wchar_t **cmdline)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
|
{
|
||||||
|
char *args = NULL;
|
||||||
|
size_t args_len = 0, argc = 0;
|
||||||
|
int ret;
|
||||||
|
QUEUE q;
|
||||||
|
QUEUE_INIT(&q);
|
||||||
|
|
||||||
|
while (*argv) {
|
||||||
|
arg_T *arg = xmalloc(sizeof(arg_T));
|
||||||
|
arg->arg = (char *)xmalloc(strlen(*argv) * 2 + 3);
|
||||||
|
quote_cmd_arg(arg->arg, *argv);
|
||||||
|
args_len += strlen(arg->arg);
|
||||||
|
QUEUE_INIT(&arg->node);
|
||||||
|
QUEUE_INSERT_TAIL(&q, &arg->node);
|
||||||
|
argc++;
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
|
args_len += argc;
|
||||||
|
args = xmalloc(args_len);
|
||||||
|
*args = NUL;
|
||||||
|
while (1) {
|
||||||
|
QUEUE *head = QUEUE_HEAD(&q);
|
||||||
|
QUEUE_REMOVE(head);
|
||||||
|
arg_T *arg = QUEUE_DATA(head, arg_T, node);
|
||||||
|
xstrlcat(args, arg->arg, args_len);
|
||||||
|
xfree(arg->arg);
|
||||||
|
xfree(arg);
|
||||||
|
if (QUEUE_EMPTY(&q)) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
xstrlcat(args, " ", args_len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = utf8_to_utf16(args, cmdline);
|
||||||
|
xfree(args);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pty_process_connect_cb(uv_connect_t *req, int status)
|
// Emulate quote_cmd_arg of libuv and quotes command line arguments
|
||||||
|
static void quote_cmd_arg(char *target, const char *source)
|
||||||
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
assert(status == 0);
|
size_t len = strlen(source);
|
||||||
xfree(req);
|
size_t i;
|
||||||
}
|
bool quote_hit = true;
|
||||||
|
char *start = target;
|
||||||
|
char tmp;
|
||||||
|
|
||||||
static void pty_process_finish2(uv_async_t *finish_async)
|
if (len == 0) {
|
||||||
{
|
*(target++) = '"';
|
||||||
PtyProcess *ptyproc =
|
*(target++) = '"';
|
||||||
(PtyProcess *)((char *)finish_async - offsetof(PtyProcess, finish_async));
|
*target = NUL;
|
||||||
Process *proc = (Process *)ptyproc;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ptyproc->is_closing) {
|
if (NULL == strpbrk(source, " \t\"")) {
|
||||||
// If pty_process_close has already been called, be consistent and never
|
strcpy(target, source);
|
||||||
// call the internal_exit callback.
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD exit_code = 0;
|
if (NULL == strpbrk(source, "\"\\")) {
|
||||||
GetExitCodeProcess(ptyproc->process_handle, &exit_code);
|
*(target++) = '"';
|
||||||
proc->status = exit_code;
|
strncpy(target, source, len);
|
||||||
|
target += len;
|
||||||
|
*(target++) = '"';
|
||||||
|
*target = NUL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (proc->internal_exit_cb) {
|
*(target++) = NUL;
|
||||||
proc->internal_exit_cb(proc);
|
*(target++) = '"';
|
||||||
|
for (i = len; i > 0; --i) {
|
||||||
|
*(target++) = source[i - 1];
|
||||||
|
|
||||||
|
if (quote_hit && source[i - 1] == '\\') {
|
||||||
|
*(target++) = '\\';
|
||||||
|
} else if (source[i - 1] == '"') {
|
||||||
|
quote_hit = true;
|
||||||
|
*(target++) = '\\';
|
||||||
|
} else {
|
||||||
|
quote_hit = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
*target = '"';
|
||||||
|
while (start < target) {
|
||||||
static void pty_process_finish_closing(uv_handle_t *finish_async)
|
tmp = *start;
|
||||||
{
|
*start = *target;
|
||||||
PtyProcess *ptyproc =
|
*target = tmp;
|
||||||
(PtyProcess *)((char *)finish_async - offsetof(PtyProcess, finish_async));
|
start++;
|
||||||
Process *proc = (Process *)ptyproc;
|
target--;
|
||||||
|
|
||||||
if (ptyproc->process_handle != NULL) {
|
|
||||||
CloseHandle(ptyproc->process_handle);
|
|
||||||
ptyproc->process_handle = NULL;
|
|
||||||
}
|
|
||||||
if (proc->internal_close_cb) {
|
|
||||||
proc->internal_close_cb(proc);
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
@ -5,19 +5,24 @@
|
|||||||
|
|
||||||
#include <winpty.h>
|
#include <winpty.h>
|
||||||
|
|
||||||
#include "nvim/event/libuv_process.h"
|
#include "nvim/event/process.h"
|
||||||
|
#include "nvim/lib/queue.h"
|
||||||
|
|
||||||
typedef struct pty_process {
|
typedef struct pty_process {
|
||||||
Process process;
|
Process process;
|
||||||
char *term_name;
|
char *term_name;
|
||||||
uint16_t width, height;
|
uint16_t width, height;
|
||||||
winpty_t *wp;
|
winpty_t *wp;
|
||||||
uv_async_t finish_async;
|
|
||||||
HANDLE finish_wait;
|
HANDLE finish_wait;
|
||||||
HANDLE process_handle;
|
HANDLE process_handle;
|
||||||
bool is_closing;
|
uv_timer_t wait_eof_timer;
|
||||||
} PtyProcess;
|
} PtyProcess;
|
||||||
|
|
||||||
|
typedef struct arg_S {
|
||||||
|
char *arg;
|
||||||
|
QUEUE node;
|
||||||
|
} arg_T;
|
||||||
|
|
||||||
static inline PtyProcess pty_process_init(Loop *loop, void *data)
|
static inline PtyProcess pty_process_init(Loop *loop, void *data)
|
||||||
{
|
{
|
||||||
PtyProcess rv;
|
PtyProcess rv;
|
||||||
@ -26,10 +31,8 @@ static inline PtyProcess pty_process_init(Loop *loop, void *data)
|
|||||||
rv.width = 80;
|
rv.width = 80;
|
||||||
rv.height = 24;
|
rv.height = 24;
|
||||||
rv.wp = NULL;
|
rv.wp = NULL;
|
||||||
// XXX: Zero rv.finish_async somehow?
|
|
||||||
rv.finish_wait = NULL;
|
rv.finish_wait = NULL;
|
||||||
rv.process_handle = NULL;
|
rv.process_handle = NULL;
|
||||||
rv.is_closing = false;
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,10 +15,12 @@ uv_tty_t tty;
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
bool owns_tty(void)
|
bool owns_tty(void)
|
||||||
{
|
{
|
||||||
HWND consoleWnd = GetConsoleWindow();
|
/* XXX: We need to make proper detect owns tty */
|
||||||
DWORD dwProcessId;
|
/* HWND consoleWnd = GetConsoleWindow(); */
|
||||||
GetWindowThreadProcessId(consoleWnd, &dwProcessId);
|
/* DWORD dwProcessId; */
|
||||||
return GetCurrentProcessId() == dwProcessId;
|
/* GetWindowThreadProcessId(consoleWnd, &dwProcessId); */
|
||||||
|
/* return GetCurrentProcessId() == dwProcessId; */
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -54,16 +56,18 @@ static void sig_handler(int signum)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static void sigwinch_cb(uv_signal_t *handle, int signum)
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
uv_tty_t out;
|
||||||
|
uv_tty_init(uv_default_loop(), &out, fileno(stdout), 0);
|
||||||
|
uv_tty_get_winsize(&out, &width, &height);
|
||||||
|
fprintf(stderr, "rows: %d, cols: %d\n", height, width);
|
||||||
|
uv_close((uv_handle_t *)&out, NULL);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// static void sigwinch_cb(uv_signal_t *handle, int signum)
|
|
||||||
// {
|
|
||||||
// int width, height;
|
|
||||||
// uv_tty_t *tty = handle->data;
|
|
||||||
// uv_tty_get_winsize(tty, &width, &height);
|
|
||||||
// fprintf(stderr, "rows: %d, cols: %d\n", height, width);
|
|
||||||
// }
|
|
||||||
|
|
||||||
static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf)
|
static void alloc_cb(uv_handle_t *handle, size_t suggested, uv_buf_t *buf)
|
||||||
{
|
{
|
||||||
buf->len = BUF_SIZE;
|
buf->len = BUF_SIZE;
|
||||||
@ -88,7 +92,7 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf)
|
|||||||
uv_loop_t write_loop;
|
uv_loop_t write_loop;
|
||||||
uv_loop_init(&write_loop);
|
uv_loop_init(&write_loop);
|
||||||
uv_tty_t out;
|
uv_tty_t out;
|
||||||
uv_tty_init(&write_loop, &out, 1, 0);
|
uv_tty_init(&write_loop, &out, fileno(stdout), 0);
|
||||||
uv_write_t req;
|
uv_write_t req;
|
||||||
uv_buf_t b = {.base = buf->base, .len = (size_t)cnt};
|
uv_buf_t b = {.base = buf->base, .len = (size_t)cnt};
|
||||||
uv_write(&req, STRUCT_CAST(uv_stream_t, &out), &b, 1, NULL);
|
uv_write(&req, STRUCT_CAST(uv_stream_t, &out), &b, 1, NULL);
|
||||||
@ -149,7 +153,11 @@ int main(int argc, char **argv)
|
|||||||
uv_prepare_init(uv_default_loop(), &prepare);
|
uv_prepare_init(uv_default_loop(), &prepare);
|
||||||
uv_prepare_start(&prepare, prepare_cb);
|
uv_prepare_start(&prepare, prepare_cb);
|
||||||
// uv_tty_t tty;
|
// uv_tty_t tty;
|
||||||
|
#ifndef WIN32
|
||||||
uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1);
|
uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1);
|
||||||
|
#else
|
||||||
|
uv_tty_init(uv_default_loop(), &tty, fileno(stdin), 1);
|
||||||
|
#endif
|
||||||
uv_tty_set_mode(&tty, UV_TTY_MODE_RAW);
|
uv_tty_set_mode(&tty, UV_TTY_MODE_RAW);
|
||||||
tty.data = &interrupted;
|
tty.data = &interrupted;
|
||||||
uv_read_start(STRUCT_CAST(uv_stream_t, &tty), alloc_cb, read_cb);
|
uv_read_start(STRUCT_CAST(uv_stream_t, &tty), alloc_cb, read_cb);
|
||||||
@ -160,15 +168,17 @@ int main(int argc, char **argv)
|
|||||||
sa.sa_handler = sig_handler;
|
sa.sa_handler = sig_handler;
|
||||||
sigaction(SIGHUP, &sa, NULL);
|
sigaction(SIGHUP, &sa, NULL);
|
||||||
sigaction(SIGWINCH, &sa, NULL);
|
sigaction(SIGWINCH, &sa, NULL);
|
||||||
// uv_signal_t sigwinch_watcher;
|
#else
|
||||||
// uv_signal_init(uv_default_loop(), &sigwinch_watcher);
|
uv_signal_t sigwinch_watcher;
|
||||||
// sigwinch_watcher.data = &tty;
|
uv_signal_init(uv_default_loop(), &sigwinch_watcher);
|
||||||
// uv_signal_start(&sigwinch_watcher, sigwinch_cb, SIGWINCH);
|
uv_signal_start(&sigwinch_watcher, sigwinch_cb, SIGWINCH);
|
||||||
#endif
|
#endif
|
||||||
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
// XXX: Without this the SIGHUP handler is skipped on some systems.
|
// XXX: Without this the SIGHUP handler is skipped on some systems.
|
||||||
sleep(100);
|
sleep(100);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,6 @@ local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.s
|
|||||||
local eq, neq = helpers.eq, helpers.neq
|
local eq, neq = helpers.eq, helpers.neq
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
describe('terminal buffer', function()
|
describe('terminal buffer', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
@ -72,6 +70,7 @@ describe('terminal buffer', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('cannot be modified directly', function()
|
it('cannot be modified directly', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
feed('<c-\\><c-n>dd')
|
feed('<c-\\><c-n>dd')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
tty ready |
|
tty ready |
|
||||||
@ -160,6 +159,7 @@ describe('terminal buffer', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('handles loss of focus gracefully', function()
|
it('handles loss of focus gracefully', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
-- Change the statusline to avoid printing the file name, which varies.
|
-- Change the statusline to avoid printing the file name, which varies.
|
||||||
nvim('set_option', 'statusline', '==========')
|
nvim('set_option', 'statusline', '==========')
|
||||||
feed_command('set laststatus=0')
|
feed_command('set laststatus=0')
|
||||||
@ -205,7 +205,7 @@ describe('terminal buffer', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('No heap-buffer-overflow when using', function()
|
describe('No heap-buffer-overflow when using', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
local testfilename = 'Xtestfile-functional-terminal-buffers_spec'
|
local testfilename = 'Xtestfile-functional-terminal-buffers_spec'
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
|
@ -7,8 +7,6 @@ local feed_command = helpers.feed_command
|
|||||||
local hide_cursor = thelpers.hide_cursor
|
local hide_cursor = thelpers.hide_cursor
|
||||||
local show_cursor = thelpers.show_cursor
|
local show_cursor = thelpers.show_cursor
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
describe('terminal cursor', function()
|
describe('terminal cursor', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@ local Screen = require('test.functional.ui.screen')
|
|||||||
local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim
|
local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim
|
||||||
local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq
|
local nvim_dir, source, eq = helpers.nvim_dir, helpers.source, helpers.eq
|
||||||
local feed_command, eval = helpers.feed_command, helpers.eval
|
local feed_command, eval = helpers.feed_command, helpers.eval
|
||||||
|
local iswin = helpers.iswin
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
describe(':terminal', function()
|
describe(':terminal', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
@ -174,10 +174,15 @@ describe(':terminal (with fake shell)', function()
|
|||||||
eq('term://', string.match(eval('bufname("%")'), "^term://"))
|
eq('term://', string.match(eval('bufname("%")'), "^term://"))
|
||||||
helpers.feed([[<C-\><C-N>]])
|
helpers.feed([[<C-\><C-N>]])
|
||||||
feed_command([[find */shadacat.py]])
|
feed_command([[find */shadacat.py]])
|
||||||
eq('scripts/shadacat.py', eval('bufname("%")'))
|
if iswin() then
|
||||||
|
eq('scripts\\shadacat.py', eval('bufname("%")'))
|
||||||
|
else
|
||||||
|
eq('scripts/shadacat.py', eval('bufname("%")'))
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('works with gf', function()
|
it('works with gf', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
terminal_with_fake_shell([[echo "scripts/shadacat.py"]])
|
terminal_with_fake_shell([[echo "scripts/shadacat.py"]])
|
||||||
wait()
|
wait()
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
@ -30,10 +30,14 @@ local function clear_attrs() feed_termcode('[0;10m') end
|
|||||||
-- mouse
|
-- mouse
|
||||||
local function enable_mouse() feed_termcode('[?1002h') end
|
local function enable_mouse() feed_termcode('[?1002h') end
|
||||||
local function disable_mouse() feed_termcode('[?1002l') end
|
local function disable_mouse() feed_termcode('[?1002l') end
|
||||||
|
local function wait_sigwinch()
|
||||||
|
helpers.sleep(1000)
|
||||||
|
hide_cursor()
|
||||||
|
show_cursor()
|
||||||
|
end
|
||||||
|
|
||||||
local default_command = '["'..nvim_dir..'/tty-test'..'"]'
|
local default_command = '["'..nvim_dir..'/tty-test'..'"]'
|
||||||
|
|
||||||
|
|
||||||
local function screen_setup(extra_rows, command, cols)
|
local function screen_setup(extra_rows, command, cols)
|
||||||
extra_rows = extra_rows and extra_rows or 0
|
extra_rows = extra_rows and extra_rows or 0
|
||||||
command = command and command or default_command
|
command = command and command or default_command
|
||||||
@ -112,5 +116,6 @@ return {
|
|||||||
clear_attrs = clear_attrs,
|
clear_attrs = clear_attrs,
|
||||||
enable_mouse = enable_mouse,
|
enable_mouse = enable_mouse,
|
||||||
disable_mouse = disable_mouse,
|
disable_mouse = disable_mouse,
|
||||||
|
wait_sigwinch = wait_sigwinch,
|
||||||
screen_setup = screen_setup
|
screen_setup = screen_setup
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
|
|||||||
local nvim_dir, command = helpers.nvim_dir, helpers.command
|
local nvim_dir, command = helpers.nvim_dir, helpers.command
|
||||||
local eq, eval = helpers.eq, helpers.eval
|
local eq, eval = helpers.eq, helpers.eval
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
describe('terminal window highlighting', function()
|
describe('terminal window highlighting', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
@ -55,6 +53,7 @@ describe('terminal window highlighting', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local function pass_attrs()
|
local function pass_attrs()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
screen:expect(sub([[
|
screen:expect(sub([[
|
||||||
tty ready |
|
tty ready |
|
||||||
{NUM:text}text{10: } |
|
{NUM:text}text{10: } |
|
||||||
@ -69,6 +68,7 @@ describe('terminal window highlighting', function()
|
|||||||
it('will pass the corresponding attributes', pass_attrs)
|
it('will pass the corresponding attributes', pass_attrs)
|
||||||
|
|
||||||
it('will pass the corresponding attributes on scrollback', function()
|
it('will pass the corresponding attributes on scrollback', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
pass_attrs()
|
pass_attrs()
|
||||||
local lines = {}
|
local lines = {}
|
||||||
for i = 1, 8 do
|
for i = 1, 8 do
|
||||||
@ -145,6 +145,7 @@ describe('terminal window highlighting with custom palette', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('will use the custom color', function()
|
it('will use the custom color', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
thelpers.set_fg(3)
|
thelpers.set_fg(3)
|
||||||
thelpers.feed_data('text')
|
thelpers.feed_data('text')
|
||||||
thelpers.clear_attrs()
|
thelpers.clear_attrs()
|
||||||
|
@ -4,8 +4,6 @@ local clear, eq, eval = helpers.clear, helpers.eq, helpers.eval
|
|||||||
local feed, nvim = helpers.feed, helpers.nvim
|
local feed, nvim = helpers.feed, helpers.nvim
|
||||||
local feed_data = thelpers.feed_data
|
local feed_data = thelpers.feed_data
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
describe('terminal mouse', function()
|
describe('terminal mouse', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
@ -67,6 +65,7 @@ describe('terminal mouse', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('will forward mouse clicks to the program', function()
|
it('will forward mouse clicks to the program', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
feed('<LeftMouse><1,2>')
|
feed('<LeftMouse><1,2>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
line27 |
|
line27 |
|
||||||
@ -80,6 +79,7 @@ describe('terminal mouse', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('will forward mouse scroll to the program', function()
|
it('will forward mouse scroll to the program', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
feed('<ScrollWheelUp><0,0>')
|
feed('<ScrollWheelUp><0,0>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
line27 |
|
line27 |
|
||||||
@ -94,6 +94,7 @@ describe('terminal mouse', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe('with a split window and other buffer', function()
|
describe('with a split window and other buffer', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
before_each(function()
|
before_each(function()
|
||||||
feed('<c-\\><c-n>:vsp<cr>')
|
feed('<c-\\><c-n>:vsp<cr>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
|
@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
|
|||||||
local thelpers = require('test.functional.terminal.helpers')
|
local thelpers = require('test.functional.terminal.helpers')
|
||||||
local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
|
local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
|
||||||
local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command
|
local feed, nvim_dir, feed_command = helpers.feed, helpers.nvim_dir, helpers.feed_command
|
||||||
|
local iswin, wait_sigwinch = helpers.iswin, thelpers.wait_sigwinch
|
||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local wait = helpers.wait
|
local wait = helpers.wait
|
||||||
@ -11,8 +12,6 @@ local curbufmeths = helpers.curbufmeths
|
|||||||
local nvim = helpers.nvim
|
local nvim = helpers.nvim
|
||||||
local feed_data = thelpers.feed_data
|
local feed_data = thelpers.feed_data
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
describe('terminal scrollback', function()
|
describe('terminal scrollback', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
@ -142,6 +141,9 @@ describe('terminal scrollback', function()
|
|||||||
describe('and the height is decreased by 1', function()
|
describe('and the height is decreased by 1', function()
|
||||||
local function will_hide_top_line()
|
local function will_hide_top_line()
|
||||||
screen:try_resize(screen._width, screen._height - 1)
|
screen:try_resize(screen._width, screen._height - 1)
|
||||||
|
if iswin() then
|
||||||
|
wait_sigwinch()
|
||||||
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
line2 |
|
line2 |
|
||||||
line3 |
|
line3 |
|
||||||
@ -158,6 +160,9 @@ describe('terminal scrollback', function()
|
|||||||
before_each(function()
|
before_each(function()
|
||||||
will_hide_top_line()
|
will_hide_top_line()
|
||||||
screen:try_resize(screen._width, screen._height - 2)
|
screen:try_resize(screen._width, screen._height - 2)
|
||||||
|
if iswin() then
|
||||||
|
wait_sigwinch()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('will hide the top 3 lines', function()
|
it('will hide the top 3 lines', function()
|
||||||
@ -184,9 +189,13 @@ describe('terminal scrollback', function()
|
|||||||
describe('and the height is decreased by 2', function()
|
describe('and the height is decreased by 2', function()
|
||||||
before_each(function()
|
before_each(function()
|
||||||
screen:try_resize(screen._width, screen._height - 2)
|
screen:try_resize(screen._width, screen._height - 2)
|
||||||
|
if iswin() then
|
||||||
|
wait_sigwinch()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function will_delete_last_two_lines()
|
local function will_delete_last_two_lines()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
tty ready |
|
tty ready |
|
||||||
rows: 4, cols: 30 |
|
rows: 4, cols: 30 |
|
||||||
@ -200,9 +209,13 @@ describe('terminal scrollback', function()
|
|||||||
it('will delete the last two empty lines', will_delete_last_two_lines)
|
it('will delete the last two empty lines', will_delete_last_two_lines)
|
||||||
|
|
||||||
describe('and then decreased by 1', function()
|
describe('and then decreased by 1', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
before_each(function()
|
before_each(function()
|
||||||
will_delete_last_two_lines()
|
will_delete_last_two_lines()
|
||||||
screen:try_resize(screen._width, screen._height - 1)
|
screen:try_resize(screen._width, screen._height - 1)
|
||||||
|
if iswin() then
|
||||||
|
wait_sigwinch()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('will delete the last line and hide the first', function()
|
it('will delete the last line and hide the first', function()
|
||||||
@ -245,6 +258,9 @@ describe('terminal scrollback', function()
|
|||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
screen:try_resize(screen._width, screen._height - 3)
|
screen:try_resize(screen._width, screen._height - 3)
|
||||||
|
if iswin() then
|
||||||
|
wait_sigwinch()
|
||||||
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
line4 |
|
line4 |
|
||||||
rows: 3, cols: 30 |
|
rows: 3, cols: 30 |
|
||||||
@ -257,6 +273,9 @@ describe('terminal scrollback', function()
|
|||||||
describe('and the height is increased by 1', function()
|
describe('and the height is increased by 1', function()
|
||||||
local function pop_then_push()
|
local function pop_then_push()
|
||||||
screen:try_resize(screen._width, screen._height + 1)
|
screen:try_resize(screen._width, screen._height + 1)
|
||||||
|
if iswin() then
|
||||||
|
wait_sigwinch()
|
||||||
|
end
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
line4 |
|
line4 |
|
||||||
rows: 3, cols: 30 |
|
rows: 3, cols: 30 |
|
||||||
@ -273,6 +292,9 @@ describe('terminal scrollback', function()
|
|||||||
pop_then_push()
|
pop_then_push()
|
||||||
eq(8, curbuf('line_count'))
|
eq(8, curbuf('line_count'))
|
||||||
screen:try_resize(screen._width, screen._height + 3)
|
screen:try_resize(screen._width, screen._height + 3)
|
||||||
|
if iswin() then
|
||||||
|
wait_sigwinch()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local function pop3_then_push1()
|
local function pop3_then_push1()
|
||||||
@ -303,10 +325,14 @@ describe('terminal scrollback', function()
|
|||||||
it('will pop 3 lines and then push one back', pop3_then_push1)
|
it('will pop 3 lines and then push one back', pop3_then_push1)
|
||||||
|
|
||||||
describe('and then by 4', function()
|
describe('and then by 4', function()
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
before_each(function()
|
before_each(function()
|
||||||
pop3_then_push1()
|
pop3_then_push1()
|
||||||
feed('Gi')
|
feed('Gi')
|
||||||
screen:try_resize(screen._width, screen._height + 4)
|
screen:try_resize(screen._width, screen._height + 4)
|
||||||
|
if iswin() then
|
||||||
|
wait_sigwinch()
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('will show all lines and leave a blank one at the end', function()
|
it('will show all lines and leave a blank one at the end', function()
|
||||||
@ -384,10 +410,20 @@ describe("'scrollback' option", function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
it('set to 0 behaves as 1', function()
|
it('set to 0 behaves as 1', function()
|
||||||
local screen = thelpers.screen_setup(nil, "['sh']", 30)
|
local screen
|
||||||
|
if iswin() then
|
||||||
|
screen = thelpers.screen_setup(nil,
|
||||||
|
"['powershell.exe', '-NoLogo', '-NoProfile', '-NoExit', '-Command', 'function global:prompt {return "..'"$"'.."}']", 30)
|
||||||
|
else
|
||||||
|
screen = thelpers.screen_setup(nil, "['sh']", 30)
|
||||||
|
end
|
||||||
|
|
||||||
curbufmeths.set_option('scrollback', 0)
|
curbufmeths.set_option('scrollback', 0)
|
||||||
feed_data('for i in $(seq 1 30); do echo "line$i"; done\n')
|
if iswin() then
|
||||||
|
feed_data('for($i=1;$i -le 30;$i++){Write-Host \"line$i\"}\r')
|
||||||
|
else
|
||||||
|
feed_data('for i in $(seq 1 30); do echo "line$i"; done\n')
|
||||||
|
end
|
||||||
screen:expect('line30 ', nil, nil, nil, true)
|
screen:expect('line30 ', nil, nil, nil, true)
|
||||||
retry(nil, nil, function() expect_lines(7) end)
|
retry(nil, nil, function() expect_lines(7) end)
|
||||||
|
|
||||||
@ -395,7 +431,13 @@ describe("'scrollback' option", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('deletes lines (only) if necessary', function()
|
it('deletes lines (only) if necessary', function()
|
||||||
local screen = thelpers.screen_setup(nil, "['sh']", 30)
|
local screen
|
||||||
|
if iswin() then
|
||||||
|
screen = thelpers.screen_setup(nil,
|
||||||
|
"['powershell.exe', '-NoLogo', '-NoProfile', '-NoExit', '-Command', 'function global:prompt {return "..'"$"'.."}']", 30)
|
||||||
|
else
|
||||||
|
screen = thelpers.screen_setup(nil, "['sh']", 30)
|
||||||
|
end
|
||||||
|
|
||||||
curbufmeths.set_option('scrollback', 200)
|
curbufmeths.set_option('scrollback', 200)
|
||||||
|
|
||||||
@ -403,7 +445,11 @@ describe("'scrollback' option", function()
|
|||||||
screen:expect('$', nil, nil, nil, true)
|
screen:expect('$', nil, nil, nil, true)
|
||||||
|
|
||||||
wait()
|
wait()
|
||||||
feed_data('for i in $(seq 1 30); do echo "line$i"; done\n')
|
if iswin() then
|
||||||
|
feed_data('for($i=1;$i -le 30;$i++){Write-Host \"line$i\"}\r')
|
||||||
|
else
|
||||||
|
feed_data('for i in $(seq 1 30); do echo "line$i"; done\n')
|
||||||
|
end
|
||||||
|
|
||||||
screen:expect('line30 ', nil, nil, nil, true)
|
screen:expect('line30 ', nil, nil, nil, true)
|
||||||
|
|
||||||
@ -416,7 +462,11 @@ describe("'scrollback' option", function()
|
|||||||
-- Terminal job data is received asynchronously, may happen before the
|
-- Terminal job data is received asynchronously, may happen before the
|
||||||
-- 'scrollback' option is synchronized with the internal sb_buffer.
|
-- 'scrollback' option is synchronized with the internal sb_buffer.
|
||||||
command('sleep 100m')
|
command('sleep 100m')
|
||||||
feed_data('for i in $(seq 1 40); do echo "line$i"; done\n')
|
if iswin() then
|
||||||
|
feed_data('for($i=1;$i -le 40;$i++){Write-Host \"line$i\"}\r')
|
||||||
|
else
|
||||||
|
feed_data('for i in $(seq 1 40); do echo "line$i"; done\n')
|
||||||
|
end
|
||||||
|
|
||||||
screen:expect('line40 ', nil, nil, nil, true)
|
screen:expect('line40 ', nil, nil, nil, true)
|
||||||
|
|
||||||
|
@ -3,8 +3,6 @@ local thelpers = require('test.functional.terminal.helpers')
|
|||||||
local feed, clear = helpers.feed, helpers.clear
|
local feed, clear = helpers.feed, helpers.clear
|
||||||
local wait = helpers.wait
|
local wait = helpers.wait
|
||||||
|
|
||||||
if helpers.pending_win32(pending) then return end
|
|
||||||
|
|
||||||
describe('terminal window', function()
|
describe('terminal window', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user