On Di, 08 Sep 2015, Christian Brabandt wrote:
>
> On Di, 08 Sep 2015, Christian Brabandt wrote:
>
> > Here is an updated patch, that addresses all mentioned points.
> > Attribution should go to lcd, as he did the main work.
>
> And this time, with the check for digraphs in the test not commented
> out.
Updated patch including new style test.
Best,
Christian
--
Die Liebe ist immer eine Art Wahnsinn, mehr oder minder schön.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/digraph.txt b/runtime/doc/digraph.txt
--- a/runtime/doc/digraph.txt
+++ b/runtime/doc/digraph.txt
@@ -28,10 +28,10 @@ 1. Defining digraphs *digraphs-defin
*E104* *E39*
:dig[raphs] {char1}{char2} {number} ...
Add digraph {char1}{char2} to the list. {number} is
- the decimal representation of the character. Normally
- it is the Unicode character, see |digraph-encoding|.
- Example: >
- :digr e: 235 a: 228
+ the (hexa-) decimal representation of the character.
+ Normally it is the Unicode character, see
+ |digraph-encoding|. Example: >
+ :dig e: 235 u: 0xFC
< Avoid defining a digraph with '_' (underscore) as the
first character, it has a special meaning in the
future.
@@ -100,9 +100,7 @@ For CTRL-K, there is one general digraph
{char} with the highest bit set. You can use this to enter meta-characters.
The <Esc> character cannot be part of a digraph. When hitting <Esc>, Vim
-stops digraph entry and ends Insert mode or Command-line mode, just like
-hitting an <Esc> out of digraph context. Use CTRL-V 155 to enter meta-ESC
-(CSI).
+stops digraph entry. Use CTRL-V 155 to enter meta-ESC (CSI).
If you accidentally typed an 'a' that should be an 'e', you will type 'a' <BS>
'e'. But that is a digraph, so you will not get what you want. To correct
diff --git a/src/digraph.c b/src/digraph.c
--- a/src/digraph.c
+++ b/src/digraph.c
@@ -2188,7 +2188,8 @@ getdigraph(int char1, int char2, int met
putdigraph(char_u *str)
{
int char1, char2, n;
- int i;
+ int i, len;
+ unsigned long val;
digr_T *dp;
while (*str != NUL)
@@ -2214,7 +2215,9 @@ putdigraph(char_u *str)
EMSG(_(e_number_exp));
return;
}
- n = getdigits(&str);
+ vim_str2nr(str, NULL, &len, STR2NR_HEX, NULL, &val, 0);
+ n = (int)val;
+ str += len;
/* If the digraph already exists, replace the result. */
dp = (digr_T *)user_digraphs.ga_data;
diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim
--- a/src/testdir/test_alot.vim
+++ b/src/testdir/test_alot.vim
@@ -4,6 +4,7 @@
source test_backspace_opt.vim
source test_cursor_func.vim
source test_delete.vim
+source test_digraph.vim
source test_expand.vim
source test_glob2regpat.vim
source test_json.vim
diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_digraph.vim
@@ -0,0 +1,32 @@
+" Test for digraphs
+
+func! Test_digraph()
+ if !has("digraphs")
+ return
+ endif
+ " defining digraphs as decimal, and hex codes
+ " Note, octal mode is not supported, the last one is
+ " decimal 252 and NOT octal 17
+ set nocp
+ digraph 00 9216 ht 0x2409 el 0252
+ new
+ exe "norm! o\<c-k>00"
+ exe "norm! o\<c-k>el"
+ exe "norm! o\<c-k>ht"
+ " euro sign
+ exe "norm! o\<c-k>=e"
+ exe "norm! o\<c-k>Eu"
+ " Rubel
+ exe "norm! o\<c-k>R="
+ " Special case:
+ " 1) <space><char> adds highbit to char
+ exe "norm! o\<c-k> a"
+ " 2) <char1><char2> is the same as <char2><char1>
+ exe "norm! o\<c-k>:a"
+ exe "norm! o\<c-k>a:"
+ " 3) <esc> ends digraph mode (but not insert mode)
+ exe "norm! o\<c-k>a\<esc>z"
+ let a=getline(1,'$')
+ call assert_equal(['','â', 'ü', 'â', 'â¬', 'â¬', 'Ð ', 'á', 'ä', 'ä', 'z'],a)
+ set cp
+endfunc