aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-04-22 20:56:31 +0200
committerbfredl <bjorn.linse@gmail.com>2022-05-02 22:19:41 +0200
commitad63b94b03c166f37bda477db6cbac2a9583d586 (patch)
tree49ee0ca3d359e52630d7e30e5dbb5a53275640b1 /src/nvim/api
parent619c8f4b9143e4dea0fb967ccdce594e14956ed3 (diff)
downloadrneovim-ad63b94b03c166f37bda477db6cbac2a9583d586.tar.gz
rneovim-ad63b94b03c166f37bda477db6cbac2a9583d586.tar.bz2
rneovim-ad63b94b03c166f37bda477db6cbac2a9583d586.zip
refactor(ui): simplify stdin handling
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/ui.c16
-rw-r--r--src/nvim/api/vim.c32
2 files changed, 16 insertions, 32 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 997f0c218a..f449ccc3c7 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -283,6 +283,22 @@ static void ui_set_option(UI *ui, bool init, String name, Object value, Error *e
return;
}
+ if (strequal(name.data, "stdin_fd")) {
+ if (value.type != kObjectTypeInteger || value.data.integer < 0) {
+ api_set_error(error, kErrorTypeValidation, "stdin_fd must be a non-negative Integer");
+ return;
+ }
+
+ if (starting != NO_SCREEN) {
+ api_set_error(error, kErrorTypeValidation,
+ "stdin_fd can only be used with first attached ui");
+ return;
+ }
+
+ stdin_fd = (int)value.data.integer;
+ return;
+ }
+
// LEGACY: Deprecated option, use `ext_cmdline` instead.
bool is_popupmenu = strequal(name.data, "popupmenu_external");
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 9c34c912c0..061653c5af 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -2661,35 +2661,3 @@ end:
xfree(cmdline);
return result;
}
-
-/// Invokes the nvim server to read from stdin when it is not a tty
-///
-/// It enables functionalities like:
-/// - echo "1f u c4n r34d th1s u r34lly n33d t0 g37 r357"| nvim -
-/// - cat path/to/a/file | nvim -
-/// It has to be called before |nvim_ui_attach()| is called in order
-/// to ensure proper functioning.
-///
-/// @param channel_id: The channel id of the GUI-client
-/// @param filedesc: The file descriptor of the GUI-client process' stdin
-/// @param implicit: Tells if read_stdin call is implicit.
-/// i.e for cases like `echo xxx | nvim`
-/// @param[out] err Error details, if any
-void nvim_read_stdin(uint64_t channel_id, Integer filedesc, Error *err)
-FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY
-{
- if (starting != NO_SCREEN) {
- api_set_error(err, kErrorTypeValidation,
- "nvim_read_stdin must be called before nvim_ui_attach");
- return;
- }
- if (filedesc < 0) {
- api_set_error(err, kErrorTypeValidation,
- "file descriptor must be non-negative");
- return;
- }
-
- stdin_filedesc = (int)filedesc;
- implicit_readstdin = implicit;
- return;
-}