aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/digraph.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/digraph.c')
-rw-r--r--src/nvim/digraph.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index 218a3f0604..3329290634 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -1359,6 +1359,12 @@ static digr_T digraphdefault[] =
{ 'f', 't', 0xfb05 },
{ 's', 't', 0xfb06 },
+ // extra alternatives, easier to remember
+ { 'W', '`', 0x1e80 },
+ { 'w', '`', 0x1e81 },
+ { 'Y', '`', 0x1ef2 },
+ { 'y', '`', 0x1ef3 },
+
// Vim 5.x compatible digraphs that don't conflict with the above
{ '~', '!', 161 }, // ¡
{ 'c', '|', 162 }, // ¢
@@ -1391,7 +1397,7 @@ static digr_T digraphdefault[] =
{ 'O', '`', 210 }, // Ò
{ 'O', '^', 212 }, // Ô
{ 'O', '~', 213 }, // Õ
- { '/', '\\', 215 }, // × - multiplication symbol in ISO 8859-1
+ { '/', '\\', 215 }, // × - multiplication symbol in ISO 8859-1
{ 'U', '`', 217 }, // Ù
{ 'U', '^', 219 }, // Û
{ 'I', 'p', 222 }, // Þ
@@ -1442,6 +1448,33 @@ int do_digraph(int c)
return c;
}
+/// Find a digraph for "val". If found return the string to display it.
+/// If not found return NULL.
+char_u *get_digraph_for_char(int val)
+{
+ digr_T *dp;
+ static char_u r[3];
+
+ for (int use_defaults = 0; use_defaults <= 1; use_defaults++) {
+ if (use_defaults == 0) {
+ dp = (digr_T *)user_digraphs.ga_data;
+ } else {
+ dp = digraphdefault;
+ }
+ for (int i = 0;
+ use_defaults ? dp->char1 != NUL : i < user_digraphs.ga_len; i++) {
+ if (dp->result == val) {
+ r[0] = dp->char1;
+ r[1] = dp->char2;
+ r[2] = NUL;
+ return r;
+ }
+ dp++;
+ }
+ }
+ return NULL;
+}
+
/// Get a digraph. Used after typing CTRL-K on the command line or in normal
/// mode.
///
@@ -1520,34 +1553,6 @@ static int getexactdigraph(int char1, int char2, int meta_char)
}
}
- if ((retval != 0) && !enc_utf8) {
- char_u buf[6], *to;
- vimconv_T vc;
-
- // Convert the Unicode digraph to 'encoding'.
- int i = utf_char2bytes(retval, buf);
- retval = 0;
- vc.vc_type = CONV_NONE;
-
- if (convert_setup(&vc, (char_u *)"utf-8", p_enc) == OK) {
- vc.vc_fail = true;
- assert(i >= 0);
- size_t len = (size_t)i;
- to = string_convert(&vc, buf, &len);
-
- if (to != NULL) {
- retval = (*mb_ptr2char)(to);
- xfree(to);
- }
- (void)convert_setup(&vc, NULL, NULL);
- }
- }
-
- // Ignore multi-byte characters when not in multi-byte mode.
- if (!has_mbyte && (retval > 0xff)) {
- retval = 0;
- }
-
if (retval == 0) {
// digraph deleted or not found
if ((char1 == ' ') && meta_char) {
@@ -1654,8 +1659,7 @@ void listdigraphs(void)
tmp.result = getexactdigraph(tmp.char1, tmp.char2, FALSE);
if ((tmp.result != 0)
- && (tmp.result != tmp.char2)
- && (has_mbyte || (tmp.result <= 255))) {
+ && (tmp.result != tmp.char2)) {
printdigraph(&tmp);
}
dp++;
@@ -1668,9 +1672,6 @@ void listdigraphs(void)
os_breakcheck();
dp++;
}
- // clear screen, because some digraphs may be wrong, in which case we messed
- // up ScreenLines
- must_redraw = CLEAR;
}
static void printdigraph(digr_T *dp)
@@ -1708,7 +1709,7 @@ static void printdigraph(digr_T *dp)
if (utf_iscomposing(dp->result)) {
*p++ = ' ';
}
- p += (*mb_char2bytes)(dp->result, p);
+ p += utf_char2bytes(dp->result, p);
*p = NUL;
msg_outtrans_attr(buf, HL_ATTR(HLF_8));