aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/tui
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-09-20 11:47:04 +0800
committerGitHub <noreply@github.com>2022-09-20 11:47:04 +0800
commita0e6e767a617d79983ac4982850dee6d95ed5b56 (patch)
tree6ca1b61512b8becb6a4cdcf8246c933a3ae4c50a /src/nvim/tui
parent875b58e0941ef62a75992ce0e6496bb7879e0bbe (diff)
downloadrneovim-a0e6e767a617d79983ac4982850dee6d95ed5b56.tar.gz
rneovim-a0e6e767a617d79983ac4982850dee6d95ed5b56.tar.bz2
rneovim-a0e6e767a617d79983ac4982850dee6d95ed5b56.zip
fix(tui): handle padding requirements for visual bell (#20238)
Diffstat (limited to 'src/nvim/tui')
-rw-r--r--src/nvim/tui/tui.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c
index fd92873508..5a331463e3 100644
--- a/src/nvim/tui/tui.c
+++ b/src/nvim/tui/tui.c
@@ -1616,7 +1616,7 @@ static void unibi_goto(UI *ui, int row, int col)
memset(&vars, 0, sizeof(vars)); \
data->cork = true; \
retry: \
- unibi_format(vars, vars + 26, str, data->params, out, ui, NULL, NULL); \
+ unibi_format(vars, vars + 26, str, data->params, out, ui, pad, ui); \
if (data->overflow) { \
data->bufpos = orig_pos; \
flush_buf(ui); \
@@ -1647,6 +1647,7 @@ static void out(void *ctx, const char *str, size_t len)
if (len > available) {
if (data->cork) {
+ // Called by unibi_format(): avoid flush_buf() halfway an escape sequence.
data->overflow = true;
return;
} else {
@@ -1658,6 +1659,30 @@ static void out(void *ctx, const char *str, size_t len)
data->bufpos += len;
}
+/// Called by unibi_format() for padding instructions.
+/// The following parameter descriptions are extracted from unibi_format(3) and terminfo(5).
+///
+/// @param ctx the same as `ctx2` passed to unibi_format()
+/// @param delay the delay in tenths of milliseconds
+/// @param scale padding is proportional to the number of lines affected
+/// @param force padding is mandatory
+static void pad(void *ctx, size_t delay, int scale FUNC_ATTR_UNUSED, int force)
+{
+ if (!force) {
+ return;
+ }
+
+ UI *ui = ctx;
+ TUIData *data = ui->data;
+
+ if (data->overflow) {
+ return;
+ }
+
+ flush_buf(ui);
+ loop_uv_run(data->loop, (int)(delay / 10), false);
+}
+
static void unibi_set_if_empty(unibi_term *ut, enum unibi_string str, const char *val)
{
if (!unibi_get_str(ut, str)) {