From a7bb63c55dacfa822e1a24d041771d9e8d83a980 Mon Sep 17 00:00:00 2001 From: Jack Bracewell Date: Fri, 24 Mar 2017 16:36:46 +0000 Subject: Add ‘eob’ option to fillchars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This option allows configuring what character is shown on the empty lines at the end of a buffer, previously hardcoded to ‘~’ --- src/nvim/globals.h | 1 + src/nvim/option.c | 1 + src/nvim/screen.c | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 20e5353b51..f5ebaa9753 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -908,6 +908,7 @@ EXTERN int fill_vert INIT(= 9474); // │ EXTERN int fill_fold INIT(= 183); // · EXTERN int fill_diff INIT(= '-'); EXTERN int fill_msgsep INIT(= ' '); +EXTERN int fill_eob INIT(= '~'); /* Whether 'keymodel' contains "stopsel" and "startsel". */ EXTERN int km_stopsel INIT(= FALSE); diff --git a/src/nvim/option.c b/src/nvim/option.c index a7ee0ef28b..3c1a70e90d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3386,6 +3386,7 @@ static char_u *set_chars_option(char_u **varp) { &fill_fold, "fold" , 183 }, // · { &fill_diff, "diff" , '-' }, { &fill_msgsep, "msgsep", ' ' }, + { &fill_eob, "eob", '~' }, }; static struct charstab lcstab[] = { { &lcs_eol, "eol", NUL }, diff --git a/src/nvim/screen.c b/src/nvim/screen.c index cf9a72715b..80f7a32c07 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1532,9 +1532,9 @@ static void win_update(win_T *wp) } else if (dollar_vcol == -1) wp->w_botline = lnum; - /* make sure the rest of the screen is blank */ - /* put '~'s on rows that aren't part of the file. */ - win_draw_end(wp, '~', ' ', row, wp->w_height, HLF_EOB); + // make sure the rest of the screen is blank + // write the 'fill_eob' character to rows that aren't part of the file. + win_draw_end(wp, fill_eob, ' ', row, wp->w_height, HLF_EOB); } /* Reset the type of redrawing required, the window has been updated. */ -- cgit From 5442f0b6221946e482dec2cb82576f0ba38900fe Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 13 Jun 2018 18:21:25 +0200 Subject: fillchars: make checks more strict and improve tests --- src/nvim/option.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 3c1a70e90d..e65798e57a 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3438,16 +3438,20 @@ static char_u *set_chars_option(char_u **varp) && p[len] == ':' && p[len + 1] != NUL) { s = p + len + 1; - c1 = mb_ptr2char_adv((const char_u **)&s); - if (mb_char2cells(c1) > 1) { + + // TODO(bfredl): use schar_T representation and utfc_ptr2len + int c1len = utf_ptr2len(s); + c1 = mb_cptr2char_adv((const char_u **)&s); + if (mb_char2cells(c1) > 1 || (c1len == 1 && c1 > 127)) { continue; } if (tab[i].cp == &lcs_tab2) { if (*s == NUL) { continue; } - c2 = mb_ptr2char_adv((const char_u **)&s); - if (mb_char2cells(c2) > 1) { + int c2len = utf_ptr2len(s); + c2 = mb_cptr2char_adv((const char_u **)&s); + if (mb_char2cells(c2) > 1 || (c2len == 1 && c2 > 127)) { continue; } } -- cgit