summaryrefslogtreecommitdiffstats
path: root/src/channel.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-04 16:35:35 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-04 16:35:35 +0200
commit077cc7aa0e0c431e97795612374fe17fe7c88803 (patch)
tree80843d4928d91ca5f9d4c38d37807e0eb17bc4be /src/channel.c
parenteadee486c70946ad0e1746d77898d6f4f4acc817 (diff)
patch 8.2.1588: cannot read back the prompt of a prompt bufferv8.2.1588
Problem: Cannot read back the prompt of a prompt buffer. Solution: Add prompt_getprompt(). (Ben Jackson, closes #6851)
Diffstat (limited to 'src/channel.c')
-rw-r--r--src/channel.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/channel.c b/src/channel.c
index 1a899e8aa8..5bf561e220 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -6368,6 +6368,29 @@ f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv UNUSED)
set_callback(&buf->b_prompt_interrupt, &callback);
}
+
+/*
+ * "prompt_getprompt({buffer})" function
+ */
+ void
+f_prompt_getprompt(typval_T *argvars, typval_T *rettv)
+{
+ buf_T *buf;
+
+ // return an empty string by default, e.g. it's not a prompt buffer
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
+
+ buf = tv_get_buf_from_arg(&argvars[0]);
+ if (buf == NULL)
+ return;
+
+ if (!bt_prompt(buf))
+ return;
+
+ rettv->vval.v_string = vim_strsave(buf_prompt_text(buf));
+}
+
/*
* "prompt_setprompt({buffer}, {text})" function
*/