mirror of
https://github.com/vim/vim.git
synced 2025-09-02 21:13:50 -04:00
updated for version 7.2-109
This commit is contained in:
parent
f69d9a354b
commit
28e8d27868
@ -4175,9 +4175,6 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
be able to execute Normal mode commands.
|
be able to execute Normal mode commands.
|
||||||
This is the opposite of the 'keymap' option, where characters are
|
This is the opposite of the 'keymap' option, where characters are
|
||||||
mapped in Insert mode.
|
mapped in Insert mode.
|
||||||
This only works for 8-bit characters. The value of 'langmap' may be
|
|
||||||
specified with multi-byte characters (e.g., UTF-8), but only the lower
|
|
||||||
8 bits of each character will be used.
|
|
||||||
|
|
||||||
Example (for Greek, in UTF-8): *greek* >
|
Example (for Greek, in UTF-8): *greek* >
|
||||||
:set langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz
|
:set langmap=ΑA,ΒB,ΨC,ΔD,ΕE,ΦF,ΓG,ΗH,ΙI,ΞJ,ΚK,ΛL,ΜM,ΝN,ΟO,ΠP,QQ,ΡR,ΣS,ΤT,ΘU,ΩV,WW,ΧX,ΥY,ΖZ,αa,βb,ψc,δd,εe,φf,γg,ηh,ιi,ξj,κk,λl,μm,νn,οo,πp,qq,ρr,σs,τt,θu,ωv,ςw,χx,υy,ζz
|
||||||
|
@ -7703,9 +7703,7 @@ ins_reg()
|
|||||||
*/
|
*/
|
||||||
++no_mapping;
|
++no_mapping;
|
||||||
regname = plain_vgetc();
|
regname = plain_vgetc();
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
LANGMAP_ADJUST(regname, TRUE);
|
LANGMAP_ADJUST(regname, TRUE);
|
||||||
#endif
|
|
||||||
if (regname == Ctrl_R || regname == Ctrl_O || regname == Ctrl_P)
|
if (regname == Ctrl_R || regname == Ctrl_O || regname == Ctrl_P)
|
||||||
{
|
{
|
||||||
/* Get a third key for literal register insertion */
|
/* Get a third key for literal register insertion */
|
||||||
@ -7714,9 +7712,7 @@ ins_reg()
|
|||||||
add_to_showcmd_c(literally);
|
add_to_showcmd_c(literally);
|
||||||
#endif
|
#endif
|
||||||
regname = plain_vgetc();
|
regname = plain_vgetc();
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
LANGMAP_ADJUST(regname, TRUE);
|
LANGMAP_ADJUST(regname, TRUE);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
--no_mapping;
|
--no_mapping;
|
||||||
|
|
||||||
|
26
src/macros.h
26
src/macros.h
@ -127,15 +127,31 @@
|
|||||||
#ifdef FEAT_LANGMAP
|
#ifdef FEAT_LANGMAP
|
||||||
/*
|
/*
|
||||||
* Adjust chars in a language according to 'langmap' option.
|
* Adjust chars in a language according to 'langmap' option.
|
||||||
* NOTE that there is NO overhead if 'langmap' is not set; but even
|
* NOTE that there is no noticeable overhead if 'langmap' is not set.
|
||||||
* when set we only have to do 2 ifs and an array lookup.
|
* When set the overhead for characters < 256 is small.
|
||||||
* Don't apply 'langmap' if the character comes from the Stuff buffer.
|
* Don't apply 'langmap' if the character comes from the Stuff buffer.
|
||||||
* The do-while is just to ignore a ';' after the macro.
|
* The do-while is just to ignore a ';' after the macro.
|
||||||
*/
|
*/
|
||||||
# define LANGMAP_ADJUST(c, condition) do { \
|
# ifdef FEAT_MBYTE
|
||||||
if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0 && (c) < 256) \
|
# define LANGMAP_ADJUST(c, condition) \
|
||||||
c = langmap_mapchar[c]; \
|
do { \
|
||||||
|
if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0) \
|
||||||
|
{ \
|
||||||
|
if ((c) < 256) \
|
||||||
|
c = langmap_mapchar[c]; \
|
||||||
|
else \
|
||||||
|
c = langmap_adjust_mb(c); \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
# else
|
||||||
|
# define LANGMAP_ADJUST(c, condition) \
|
||||||
|
do { \
|
||||||
|
if (*p_langmap && (condition) && !KeyStuffed && (c) >= 0 && (c) < 256) \
|
||||||
|
c = langmap_mapchar[c]; \
|
||||||
|
} while (0)
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define LANGMAP_ADJUST(c, condition) /* nop */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
15
src/normal.c
15
src/normal.c
@ -651,10 +651,7 @@ normal_cmd(oap, toplevel)
|
|||||||
* Get the command character from the user.
|
* Get the command character from the user.
|
||||||
*/
|
*/
|
||||||
c = safe_vgetc();
|
c = safe_vgetc();
|
||||||
|
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
LANGMAP_ADJUST(c, TRUE);
|
LANGMAP_ADJUST(c, TRUE);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEAT_VISUAL
|
#ifdef FEAT_VISUAL
|
||||||
/*
|
/*
|
||||||
@ -744,9 +741,7 @@ getcount:
|
|||||||
}
|
}
|
||||||
++no_zero_mapping; /* don't map zero here */
|
++no_zero_mapping; /* don't map zero here */
|
||||||
c = plain_vgetc();
|
c = plain_vgetc();
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
LANGMAP_ADJUST(c, TRUE);
|
LANGMAP_ADJUST(c, TRUE);
|
||||||
#endif
|
|
||||||
--no_zero_mapping;
|
--no_zero_mapping;
|
||||||
if (ctrl_w)
|
if (ctrl_w)
|
||||||
{
|
{
|
||||||
@ -769,9 +764,7 @@ getcount:
|
|||||||
++no_mapping;
|
++no_mapping;
|
||||||
++allow_keys; /* no mapping for nchar, but keys */
|
++allow_keys; /* no mapping for nchar, but keys */
|
||||||
c = plain_vgetc(); /* get next character */
|
c = plain_vgetc(); /* get next character */
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
LANGMAP_ADJUST(c, TRUE);
|
LANGMAP_ADJUST(c, TRUE);
|
||||||
#endif
|
|
||||||
--no_mapping;
|
--no_mapping;
|
||||||
--allow_keys;
|
--allow_keys;
|
||||||
#ifdef FEAT_CMDL_INFO
|
#ifdef FEAT_CMDL_INFO
|
||||||
@ -959,9 +952,7 @@ getcount:
|
|||||||
* "gr", "g'" and "g`".
|
* "gr", "g'" and "g`".
|
||||||
*/
|
*/
|
||||||
ca.nchar = plain_vgetc();
|
ca.nchar = plain_vgetc();
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
LANGMAP_ADJUST(ca.nchar, TRUE);
|
LANGMAP_ADJUST(ca.nchar, TRUE);
|
||||||
#endif
|
|
||||||
#ifdef FEAT_CMDL_INFO
|
#ifdef FEAT_CMDL_INFO
|
||||||
need_flushbuf |= add_to_showcmd(ca.nchar);
|
need_flushbuf |= add_to_showcmd(ca.nchar);
|
||||||
#endif
|
#endif
|
||||||
@ -1062,10 +1053,8 @@ getcount:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
/* adjust chars > 127, except after "tTfFr" commands */
|
/* adjust chars > 127, except after "tTfFr" commands */
|
||||||
LANGMAP_ADJUST(*cp, !lang);
|
LANGMAP_ADJUST(*cp, !lang);
|
||||||
#endif
|
|
||||||
#ifdef FEAT_RIGHTLEFT
|
#ifdef FEAT_RIGHTLEFT
|
||||||
/* adjust Hebrew mapped char */
|
/* adjust Hebrew mapped char */
|
||||||
if (p_hkmap && lang && KeyTyped)
|
if (p_hkmap && lang && KeyTyped)
|
||||||
@ -4630,9 +4619,7 @@ nv_zet(cap)
|
|||||||
++no_mapping;
|
++no_mapping;
|
||||||
++allow_keys; /* no mapping for nchar, but allow key codes */
|
++allow_keys; /* no mapping for nchar, but allow key codes */
|
||||||
nchar = plain_vgetc();
|
nchar = plain_vgetc();
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
LANGMAP_ADJUST(nchar, TRUE);
|
LANGMAP_ADJUST(nchar, TRUE);
|
||||||
#endif
|
|
||||||
--no_mapping;
|
--no_mapping;
|
||||||
--allow_keys;
|
--allow_keys;
|
||||||
#ifdef FEAT_CMDL_INFO
|
#ifdef FEAT_CMDL_INFO
|
||||||
@ -4988,9 +4975,7 @@ dozet:
|
|||||||
++no_mapping;
|
++no_mapping;
|
||||||
++allow_keys; /* no mapping for nchar, but allow key codes */
|
++allow_keys; /* no mapping for nchar, but allow key codes */
|
||||||
nchar = plain_vgetc();
|
nchar = plain_vgetc();
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
LANGMAP_ADJUST(nchar, TRUE);
|
LANGMAP_ADJUST(nchar, TRUE);
|
||||||
#endif
|
|
||||||
--no_mapping;
|
--no_mapping;
|
||||||
--allow_keys;
|
--allow_keys;
|
||||||
#ifdef FEAT_CMDL_INFO
|
#ifdef FEAT_CMDL_INFO
|
||||||
|
116
src/option.c
116
src/option.c
@ -10153,25 +10153,110 @@ wc_use_keyname(varp, wcp)
|
|||||||
|
|
||||||
#ifdef FEAT_LANGMAP
|
#ifdef FEAT_LANGMAP
|
||||||
/*
|
/*
|
||||||
* Any character has an equivalent character. This is used for keyboards that
|
* Any character has an equivalent 'langmap' character. This is used for
|
||||||
* have a special language mode that sends characters above 128 (although
|
* keyboards that have a special language mode that sends characters above
|
||||||
* other characters can be translated too).
|
* 128 (although other characters can be translated too). The "to" field is a
|
||||||
|
* Vim command character. This avoids having to switch the keyboard back to
|
||||||
|
* ASCII mode when leaving Insert mode.
|
||||||
|
*
|
||||||
|
* langmap_mapchar[] maps any of 256 chars to an ASCII char used for Vim
|
||||||
|
* commands.
|
||||||
|
* When FEAT_MBYTE is defined langmap_mapga.ga_data is a sorted table of
|
||||||
|
* langmap_entry_T. This does the same as langmap_mapchar[] for characters >=
|
||||||
|
* 256.
|
||||||
*/
|
*/
|
||||||
|
# ifdef FEAT_MBYTE
|
||||||
|
/*
|
||||||
|
* With multi-byte support use growarray for 'langmap' chars >= 256
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int from;
|
||||||
|
int to;
|
||||||
|
} langmap_entry_T;
|
||||||
|
|
||||||
|
static garray_T langmap_mapga;
|
||||||
|
static void langmap_set_entry __ARGS((int from, int to));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* char_u langmap_mapchar[256];
|
* Search for an entry in "langmap_mapga" for "from". If found set the "to"
|
||||||
* Normally maps each of the 128 upper chars to an <128 ascii char; used to
|
* field. If not found insert a new entry at the appropriate location.
|
||||||
* "translate" native lang chars in normal mode or some cases of
|
|
||||||
* insert mode without having to tediously switch lang mode back&forth.
|
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
|
langmap_set_entry(from, to)
|
||||||
|
int from;
|
||||||
|
int to;
|
||||||
|
{
|
||||||
|
langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
|
||||||
|
int a = 0;
|
||||||
|
int b = langmap_mapga.ga_len;
|
||||||
|
|
||||||
|
/* Do a binary search for an existing entry. */
|
||||||
|
while (a != b)
|
||||||
|
{
|
||||||
|
int i = (a + b) / 2;
|
||||||
|
int d = entries[i].from - from;
|
||||||
|
|
||||||
|
if (d == 0)
|
||||||
|
{
|
||||||
|
entries[i].to = to;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (d < 0)
|
||||||
|
a = i + 1;
|
||||||
|
else
|
||||||
|
b = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ga_grow(&langmap_mapga, 1) != OK)
|
||||||
|
return; /* out of memory */
|
||||||
|
|
||||||
|
/* insert new entry at position "a" */
|
||||||
|
entries = (langmap_entry_T *)(langmap_mapga.ga_data) + a;
|
||||||
|
mch_memmove(entries + 1, entries,
|
||||||
|
(langmap_mapga.ga_len - a) * sizeof(langmap_entry_T));
|
||||||
|
++langmap_mapga.ga_len;
|
||||||
|
entries[0].from = from;
|
||||||
|
entries[0].to = to;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Apply 'langmap' to multi-byte character "c" and return the result.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
langmap_adjust_mb(c)
|
||||||
|
int c;
|
||||||
|
{
|
||||||
|
langmap_entry_T *entries = (langmap_entry_T *)(langmap_mapga.ga_data);
|
||||||
|
int a = 0;
|
||||||
|
int b = langmap_mapga.ga_len;
|
||||||
|
|
||||||
|
while (a != b)
|
||||||
|
{
|
||||||
|
int i = (a + b) / 2;
|
||||||
|
int d = entries[i].from - c;
|
||||||
|
|
||||||
|
if (d == 0)
|
||||||
|
return entries[i].to; /* found matching entry */
|
||||||
|
if (d < 0)
|
||||||
|
a = i + 1;
|
||||||
|
else
|
||||||
|
b = i;
|
||||||
|
}
|
||||||
|
return c; /* no entry found, return "c" unmodified */
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
langmap_init()
|
langmap_init()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) /* we init with a-one-to one map */
|
for (i = 0; i < 256; i++)
|
||||||
langmap_mapchar[i] = i;
|
langmap_mapchar[i] = i; /* we init with a one-to-one map */
|
||||||
|
# ifdef FEAT_MBYTE
|
||||||
|
ga_init2(&langmap_mapga, sizeof(langmap_entry_T), 8);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -10185,7 +10270,10 @@ langmap_set()
|
|||||||
char_u *p2;
|
char_u *p2;
|
||||||
int from, to;
|
int from, to;
|
||||||
|
|
||||||
langmap_init(); /* back to one-to-one map first */
|
#ifdef FEAT_MBYTE
|
||||||
|
ga_clear(&langmap_mapga); /* clear the previous map first */
|
||||||
|
#endif
|
||||||
|
langmap_init(); /* back to one-to-one map */
|
||||||
|
|
||||||
for (p = p_langmap; p[0] != NUL; )
|
for (p = p_langmap; p[0] != NUL; )
|
||||||
{
|
{
|
||||||
@ -10235,7 +10323,13 @@ langmap_set()
|
|||||||
transchar(from));
|
transchar(from));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
langmap_mapchar[from & 255] = to;
|
|
||||||
|
#ifdef FEAT_MBYTE
|
||||||
|
if (from >= 256)
|
||||||
|
langmap_set_entry(from, to);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
langmap_mapchar[from & 255] = to;
|
||||||
|
|
||||||
/* Advance to next pair */
|
/* Advance to next pair */
|
||||||
mb_ptr_adv(p);
|
mb_ptr_adv(p);
|
||||||
|
@ -44,6 +44,7 @@ void set_imsearch_global __ARGS((void));
|
|||||||
void set_context_in_set_cmd __ARGS((expand_T *xp, char_u *arg, int opt_flags));
|
void set_context_in_set_cmd __ARGS((expand_T *xp, char_u *arg, int opt_flags));
|
||||||
int ExpandSettings __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
|
int ExpandSettings __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file));
|
||||||
int ExpandOldSetting __ARGS((int *num_file, char_u ***file));
|
int ExpandOldSetting __ARGS((int *num_file, char_u ***file));
|
||||||
|
int langmap_adjust_mb __ARGS((int c));
|
||||||
int has_format_option __ARGS((int x));
|
int has_format_option __ARGS((int x));
|
||||||
int shortmess __ARGS((int x));
|
int shortmess __ARGS((int x));
|
||||||
void vimrc_found __ARGS((char_u *fname, char_u *envname));
|
void vimrc_found __ARGS((char_u *fname, char_u *envname));
|
||||||
|
@ -676,6 +676,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
109,
|
||||||
/**/
|
/**/
|
||||||
108,
|
108,
|
||||||
/**/
|
/**/
|
||||||
|
@ -594,9 +594,7 @@ wingotofile:
|
|||||||
++allow_keys; /* no mapping for xchar, but allow key codes */
|
++allow_keys; /* no mapping for xchar, but allow key codes */
|
||||||
if (xchar == NUL)
|
if (xchar == NUL)
|
||||||
xchar = plain_vgetc();
|
xchar = plain_vgetc();
|
||||||
#ifdef FEAT_LANGMAP
|
|
||||||
LANGMAP_ADJUST(xchar, TRUE);
|
LANGMAP_ADJUST(xchar, TRUE);
|
||||||
#endif
|
|
||||||
--no_mapping;
|
--no_mapping;
|
||||||
--allow_keys;
|
--allow_keys;
|
||||||
#ifdef FEAT_CMDL_INFO
|
#ifdef FEAT_CMDL_INFO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user