Mercurial > vim
diff src/channel.c @ 22077:335365fcbb60 v8.2.1588
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Commit: https://github.com/vim/vim/commit/077cc7aa0e0c431e97795612374fe17fe7c88803
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Sep 4 16:35:35 2020 +0200
patch 8.2.1588: cannot read back the prompt of a prompt buffer
Problem: Cannot read back the prompt of a prompt buffer.
Solution: Add prompt_getprompt(). (Ben Jackson, closes https://github.com/vim/vim/issues/6851)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 04 Sep 2020 16:45:04 +0200 |
parents | d9acf1e1c799 |
children | 2cc0de1e05a6 |
line wrap: on
line diff
--- a/src/channel.c +++ b/src/channel.c @@ -6368,6 +6368,29 @@ f_prompt_setinterrupt(typval_T *argvars, 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 */