diff options
author | hlpr98 <hlpr98@gmail.com> | 2019-05-27 22:04:24 +0530 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2022-12-31 10:43:28 +0100 |
commit | 24488169564c39a506c235bf6a33b8e23a8cb528 (patch) | |
tree | 3b30c1fcc3b4ce2fef81d45eebe61baa4f0315ed /src/nvim/ui_client.c | |
parent | 4ace9e7e417fe26c8b73ff1d6042e6e4f3df9ebf (diff) | |
download | rneovim-24488169564c39a506c235bf6a33b8e23a8cb528.tar.gz rneovim-24488169564c39a506c235bf6a33b8e23a8cb528.tar.bz2 rneovim-24488169564c39a506c235bf6a33b8e23a8cb528.zip |
feat(tui): run TUI as external process
Diffstat (limited to 'src/nvim/ui_client.c')
-rw-r--r-- | src/nvim/ui_client.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index 27c63433a7..a56513f42f 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -9,6 +9,7 @@ #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" #include "nvim/globals.h" +#include "nvim/eval.h" #include "nvim/highlight.h" #include "nvim/log.h" #include "nvim/main.h" @@ -24,6 +25,31 @@ #endif // uncrustify:on +uint64_t ui_client_start_server(int argc, char **argv, bool pass_stdin) +{ + varnumber_T exit_status; + char **args = xmalloc(((size_t)(2 + argc)) * sizeof(char*)); + int args_idx = 0; + args[args_idx++] = xstrdup((const char*)get_vim_var_str(VV_PROGPATH)); + args[args_idx++] = xstrdup("--embed"); + for (int i = 1; i < argc; i++) { + args[args_idx++] = xstrdup(argv[i]); + } + args[args_idx++] = NULL; // last value of argv should be NULL + + Channel *channel = channel_job_start(args, CALLBACK_READER_INIT, + CALLBACK_READER_INIT, CALLBACK_NONE, + false, true, true, false, kChannelStdinPipe, + NULL, 0, 0, NULL, &exit_status); + if (pass_stdin && !stdin_isatty) { + close(0); + dup(2); + } + + ui_client_init(channel->id); + return channel->id;; +} + void ui_client_init(uint64_t chan) { Array args = ARRAY_DICT_INIT; @@ -35,6 +61,13 @@ void ui_client_init(uint64_t chan) PUT(opts, "ext_linegrid", BOOLEAN_OBJ(true)); PUT(opts, "ext_termcolors", BOOLEAN_OBJ(true)); + // TODO: PUT(opts, "term_name", STRING_OBJ(cstr_as_string(termname_local))); + PUT(opts, "term_colors", INTEGER_OBJ(t_colors)); + if (!is_remote_client) { + PUT(opts, "term_ttyin", INTEGER_OBJ(stdin_isatty)); + PUT(opts, "term_ttyout", INTEGER_OBJ(stdout_isatty)); + } + ADD(args, INTEGER_OBJ((int)width)); ADD(args, INTEGER_OBJ((int)height)); ADD(args, DICTIONARY_OBJ(opts)); |