aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/arabic.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-09-19 14:30:02 +0200
committerbfredl <bjorn.linse@gmail.com>2023-10-08 15:22:45 +0200
commitddef39299f357d3131644647379e88a69749bf40 (patch)
tree617b46a628180bf4fa5cc56ba8de20b876810163 /src/nvim/arabic.c
parent5db076c7ccfef6732516074252ac4b21b12fc629 (diff)
downloadrneovim-ddef39299f357d3131644647379e88a69749bf40.tar.gz
rneovim-ddef39299f357d3131644647379e88a69749bf40.tar.bz2
rneovim-ddef39299f357d3131644647379e88a69749bf40.zip
refactor(grid): do arabic shaping in one place
The 'arabicshape' feature of vim is a transformation of unicode text to make arabic and some related scripts look better at display time. In particular the content of a cell will be adjusted depending on the (original) content of the cells just before and after it. This is implemented by the arabic_shape() function in nvim. Before this commit, shaping was invoked in four different contexts: - when rendering buffer text in win_line() - in line_putchar() for rendering virtual text - as part of grid_line_puts, used by messages and statuslines and similar - as part of draw_cmdline() for drawing the cmdline This replaces all these with a post-processing step in grid_put_linebuf(), which has become the entry point for all text rendering after recent refactors. An aim of this is to make the handling of multibyte text yet simpler. One of the main reasons multibyte chars needs to be "parsed" into codepoint arrays of composing chars is so that these could be inspected for the purpose of shaping. This can likely be vastly simplified in many contexts where only the total length (in bytes) and width of composed char is needed.
Diffstat (limited to 'src/nvim/arabic.c')
-rw-r--r--src/nvim/arabic.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c
index bab77a4a84..9dbb2c06e1 100644
--- a/src/nvim/arabic.c
+++ b/src/nvim/arabic.c
@@ -297,13 +297,12 @@ static int A_is_valid(int c)
}
// Do Arabic shaping on character "c". Returns the shaped character.
-// out: "ccp" points to the first byte of the character to be shaped.
// in/out: "c1p" points to the first composing char for "c".
// in: "prev_c" is the previous character (not shaped)
// in: "prev_c1" is the first composing char for the previous char
// (not shaped)
// in: "next_c" is the next character (not shaped).
-int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int next_c)
+int arabic_shape(int c, int *c1p, int prev_c, int prev_c1, int next_c)
{
// Deal only with Arabic character, pass back all others
if (!A_is_ok(c)) {
@@ -347,14 +346,6 @@ int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int next_c)
curr_c = c;
}
- if ((curr_c != c) && (ccp != NULL)) {
- char buf[MB_MAXBYTES + 1];
-
- // Update the first byte of the character
- utf_char2bytes(curr_c, buf);
- *ccp = (uint8_t)buf[0];
- }
-
// Return the shaped character
return curr_c;
}