Patch 7.4.1981
Problem: No testing for Farsi code.
Solution: Add a minimal test. Clean up Farsi code.
Files: src/farsi.c, src/Makefile, src/charset.c, src/normal.c,
src/proto/main.pro, src/testdir/Make_all.mak,
src/testdir/test_farsi.vim
*** ../vim-7.4.1980/src/farsi.c 2016-02-24 12:57:46.460114833 +0100
--- src/farsi.c 2016-07-02 18:23:43.154215729 +0200
***************
*** 35,41 ****
static void lrswapbuf(char_u *buf, int len);
/*
! ** Convert the given Farsi character into a _X or _X_ type
*/
static int
toF_Xor_X_(int c)
--- 35,41 ----
static void lrswapbuf(char_u *buf, int len);
/*
! * Convert the given Farsi character into a _X or _X_ type
*/
static int
toF_Xor_X_(int c)
***************
*** 44,104 ****
switch (c)
{
! case BE:
! return _BE;
! case PE:
! return _PE;
! case TE:
! return _TE;
! case SE:
! return _SE;
! case JIM:
! return _JIM;
! case CHE:
! return _CHE;
! case HE_J:
! return _HE_J;
! case XE:
! return _XE;
! case SIN:
! return _SIN;
! case SHIN:
! return _SHIN;
! case SAD:
! return _SAD;
! case ZAD:
! return _ZAD;
! case AYN:
! return _AYN;
! case AYN_:
! return _AYN_;
! case GHAYN:
! return _GHAYN;
! case GHAYN_:
! return _GHAYN_;
! case FE:
! return _FE;
! case GHAF:
! return _GHAF;
! case KAF:
! return _KAF;
! case GAF:
! return _GAF;
! case LAM:
! return _LAM;
! case MIM:
! return _MIM;
! case NOON:
! return _NOON;
case YE:
! case YE_:
! return _YE;
case YEE:
! case YEE_:
! return _YEE;
case IE:
! case IE_:
! return _IE;
case F_HE:
tempc = _HE;
--- 44,78 ----
switch (c)
{
! case BE: return _BE;
! case PE: return _PE;
! case TE: return _TE;
! case SE: return _SE;
! case JIM: return _JIM;
! case CHE: return _CHE;
! case HE_J: return _HE_J;
! case XE: return _XE;
! case SIN: return _SIN;
! case SHIN: return _SHIN;
! case SAD: return _SAD;
! case ZAD: return _ZAD;
! case AYN: return _AYN;
! case AYN_: return _AYN_;
! case GHAYN: return _GHAYN;
! case GHAYN_: return _GHAYN_;
! case FE: return _FE;
! case GHAF: return _GHAF;
! case KAF: return _KAF;
! case GAF: return _GAF;
! case LAM: return _LAM;
! case MIM: return _MIM;
! case NOON: return _NOON;
case YE:
! case YE_: return _YE;
case YEE:
! case YEE_: return _YEE;
case IE:
! case IE_: return _IE;
case F_HE:
tempc = _HE;
***************
*** 128,213 ****
}
/*
! ** Convert the given Farsi character into Farsi capital character .
*/
! int
! toF_TyA(int c )
{
switch (c)
{
! case ALEF_:
! return ALEF;
! case ALEF_U_H_:
! return ALEF_U_H;
! case _BE:
! return BE;
! case _PE:
! return PE;
! case _TE:
! return TE;
! case _SE:
! return SE;
! case _JIM:
! return JIM;
! case _CHE:
! return CHE;
! case _HE_J:
! return HE_J;
! case _XE:
! return XE;
! case _SIN:
! return SIN;
! case _SHIN:
! return SHIN;
! case _SAD:
! return SAD;
! case _ZAD:
! return ZAD;
case _AYN:
case AYN_:
! case _AYN_:
! return AYN;
case _GHAYN:
case GHAYN_:
! case _GHAYN_:
! return GHAYN;
! case _FE:
! return FE;
! case _GHAF:
! return GHAF;
! /* I am not sure what it is !!! case _KAF_H: */
! case _KAF:
! return KAF;
! case _GAF:
! return GAF;
! case _LAM:
! return LAM;
! case _MIM:
! return MIM;
! case _NOON:
! return NOON;
case _YE:
! case YE_:
! return YE;
case _YEE:
! case YEE_:
! return YEE;
! case TEE_:
! return TEE;
case _IE:
! case IE_:
! return IE;
case _HE:
! case _HE_:
! return F_HE;
}
return c;
}
/*
! ** Is the character under the cursor+offset in the given buffer a join type.
! ** That is a character that is combined with the others.
! ** Note: the offset is used only for command line buffer.
*/
static int
F_is_TyB_TyC_TyD(int src, int offset)
--- 102,159 ----
}
/*
! * Convert the given Farsi character into Farsi capital character.
*/
! static int
! toF_TyA(int c)
{
switch (c)
{
! case ALEF_: return ALEF;
! case ALEF_U_H_: return ALEF_U_H;
! case _BE: return BE;
! case _PE: return PE;
! case _TE: return TE;
! case _SE: return SE;
! case _JIM: return JIM;
! case _CHE: return CHE;
! case _HE_J: return HE_J;
! case _XE: return XE;
! case _SIN: return SIN;
! case _SHIN: return SHIN;
! case _SAD: return SAD;
! case _ZAD: return ZAD;
case _AYN:
case AYN_:
! case _AYN_: return AYN;
case _GHAYN:
case GHAYN_:
! case _GHAYN_: return GHAYN;
! case _FE: return FE;
! case _GHAF: return GHAF;
! /* I am not sure what it is !!! case _KAF_H: */
! case _KAF: return KAF;
! case _GAF: return GAF;
! case _LAM: return LAM;
! case _MIM: return MIM;
! case _NOON: return NOON;
case _YE:
! case YE_: return YE;
case _YEE:
! case YEE_: return YEE;
! case TEE_: return TEE;
case _IE:
! case IE_: return IE;
case _HE:
! case _HE_: return F_HE;
}
return c;
}
/*
! * Is the character under the cursor+offset in the given buffer a join type.
! * That is a character that is combined with the others.
! * Note: the offset is used only for command line buffer.
*/
static int
F_is_TyB_TyC_TyD(int src, int offset)
***************
*** 258,264 ****
}
/*
! ** Is the Farsi character one of the terminating only type.
*/
static int
F_is_TyE(int c)
--- 204,210 ----
}
/*
! * Is the Farsi character one of the terminating only type.
*/
static int
F_is_TyE(int c)
***************
*** 281,287 ****
}
/*
! ** Is the Farsi character one of the none leading type.
*/
static int
F_is_TyC_TyD(int c)
--- 227,233 ----
}
/*
! * Is the Farsi character one of the none leading type.
*/
static int
F_is_TyC_TyD(int c)
***************
*** 305,311 ****
}
/*
! ** Convert a none leading Farsi char into a leading type.
*/
static int
toF_TyB(int c)
--- 251,257 ----
}
/*
! * Convert a none leading Farsi char into a leading type.
*/
static int
toF_TyB(int c)
***************
*** 313,319 ****
switch (c)
{
case ALEF_: return ALEF;
! case ALEF_U_H_: return ALEF_U_H;
case _AYN_: return _AYN;
case AYN_: return AYN; /* exception - there are many of them */
case _GHAYN_: return _GHAYN;
--- 259,265 ----
switch (c)
{
case ALEF_: return ALEF;
! case ALEF_U_H_: return ALEF_U_H;
case _AYN_: return _AYN;
case AYN_: return AYN; /* exception - there are many of them */
case _GHAYN_: return _GHAYN;
***************
*** 328,334 ****
}
/*
! ** Overwrite the current redo and cursor characters + left adjust
*/
static void
put_curr_and_l_to_X(int c)
--- 274,280 ----
}
/*
! * Overwrite the current redo and cursor characters + left adjust.
*/
static void
put_curr_and_l_to_X(int c)
***************
*** 373,379 ****
}
/*
! ** Change the char. under the cursor to a X_ or X type
*/
static void
chg_c_toX_orX(void)
--- 319,325 ----
}
/*
! * Change the char. under the cursor to a X_ or X type
*/
static void
chg_c_toX_orX(void)
***************
*** 497,503 ****
}
/*
! ** Change the char. under the cursor to a _X_ or X_ type
*/
static void
--- 443,449 ----
}
/*
! * Change the char. under the cursor to a _X_ or X_ type
*/
static void
***************
*** 549,555 ****
}
/*
! ** Change the char. under the cursor to a _X_ or _X type
*/
static void
chg_c_to_X_or_X (void)
--- 495,501 ----
}
/*
! * Change the char. under the cursor to a _X_ or _X type
*/
static void
chg_c_to_X_or_X (void)
***************
*** 580,589 ****
}
/*
! ** Change the character left to the cursor to a _X_ or X_ type
*/
static void
! chg_l_to_X_orX_ (void)
{
int tempc;
--- 526,535 ----
}
/*
! * Change the character left to the cursor to a _X_ or X_ type
*/
static void
! chg_l_to_X_orX_(void)
{
int tempc;
***************
*** 648,654 ****
}
/*
! ** Change the character left to the cursor to a X or _X type
*/
static void
--- 594,600 ----
}
/*
! * Change the character left to the cursor to a X or _X type
*/
static void
***************
*** 717,723 ****
}
/*
! ** Change the character right to the cursor to a _X or _X_ type
*/
static void
--- 663,669 ----
}
/*
! * Change the character right to the cursor to a _X or _X_ type
*/
static void
***************
*** 742,748 ****
}
/*
! ** Map Farsi keyboard when in fkmap mode.
*/
int
--- 688,694 ----
}
/*
! * Map Farsi keyboard when in fkmap mode.
*/
int
***************
*** 899,906 ****
if (p_ri && c == NL && curwin->w_cursor.col)
{
/*
! ** If the char before the cursor is _X_ or X_ do not change
! ** the one under the cursor with X type.
*/
dec_cursor();
--- 845,852 ----
if (p_ri && c == NL && curwin->w_cursor.col)
{
/*
! * If the char before the cursor is _X_ or X_ do not change
! * the one under the cursor with X type.
*/
dec_cursor();
***************
*** 914,921 ****
inc_cursor();
}
! if (!p_ri)
! if (!curwin->w_cursor.col)
{
switch (c)
{
--- 860,866 ----
inc_cursor();
}
! if (!p_ri && !curwin->w_cursor.col)
{
switch (c)
{
***************
*** 1154,1196 ****
case 'a':
tempc = _SHIN;
! break;
case 'A':
tempc = WAW_H;
! break;
case 'b':
tempc = ZAL;
! break;
case 'c':
tempc = ZE;
! break;
case 'C':
tempc = JE;
! break;
case 'd':
tempc = _YE;
! break;
case 'D':
tempc = _YEE;
! break;
case 'e':
tempc = _SE;
! break;
case 'f':
tempc = _BE;
! break;
case 'g':
tempc = _LAM;
! break;
case 'G':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (gchar_cursor() == _LAM)
chg_c_toX_orX ();
! else
! if (p_ri)
! chg_c_to_X_or_X ();
}
if (!p_ri)
--- 1099,1140 ----
case 'a':
tempc = _SHIN;
! break;
case 'A':
tempc = WAW_H;
! break;
case 'b':
tempc = ZAL;
! break;
case 'c':
tempc = ZE;
! break;
case 'C':
tempc = JE;
! break;
case 'd':
tempc = _YE;
! break;
case 'D':
tempc = _YEE;
! break;
case 'e':
tempc = _SE;
! break;
case 'f':
tempc = _BE;
! break;
case 'g':
tempc = _LAM;
! break;
case 'G':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (gchar_cursor() == _LAM)
chg_c_toX_orX ();
! else if (p_ri)
! chg_c_to_X_or_X ();
}
if (!p_ri)
***************
*** 1204,1219 ****
{
chg_c_toX_orX ();
chg_l_toXor_X ();
! tempc = ALEF_U_H;
}
else
! if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))
! {
! tempc = ALEF_U_H_;
! chg_l_toXor_X ();
! }
! else
! tempc = ALEF_U_H;
if (!p_ri)
inc_cursor();
--- 1148,1162 ----
{
chg_c_toX_orX ();
chg_l_toXor_X ();
! tempc = ALEF_U_H;
! }
! else if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))
! {
! tempc = ALEF_U_H_;
! chg_l_toXor_X ();
}
else
! tempc = ALEF_U_H;
if (!p_ri)
inc_cursor();
***************
*** 1249,1259 ****
{
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))
{
! tempc = ALEF_;
chg_l_toXor_X ();
}
else
! tempc = ALEF;
}
if (!p_ri)
--- 1192,1202 ----
{
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))
{
! tempc = ALEF_;
chg_l_toXor_X ();
}
else
! tempc = ALEF;
}
if (!p_ri)
***************
*** 1261,1268 ****
return tempc;
case 'i':
! if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (!p_ri && !F_is_TyE(tempc))
chg_c_to_X_orX_ ();
if (p_ri)
--- 1204,1211 ----
return tempc;
case 'i':
! if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (!p_ri && !F_is_TyE(tempc))
chg_c_to_X_orX_ ();
if (p_ri)
***************
*** 1277,1285 ****
dec_cursor();
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))
! tempc = _HE_;
else
! tempc = _HE;
if (!p_ri)
inc_cursor();
--- 1220,1228 ----
dec_cursor();
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))
! tempc = _HE_;
else
! tempc = _HE;
if (!p_ri)
inc_cursor();
***************
*** 1289,1295 ****
break;
case 'J':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (p_ri)
chg_c_to_X_or_X ();
--- 1232,1238 ----
break;
case 'J':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (p_ri)
chg_c_to_X_or_X ();
***************
*** 1304,1314 ****
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))
{
! tempc = TEE_;
chg_l_toXor_X ();
}
else
! tempc = TEE;
if (!p_ri)
inc_cursor();
--- 1247,1257 ----
if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))
{
! tempc = TEE_;
chg_l_toXor_X ();
}
else
! tempc = TEE;
if (!p_ri)
inc_cursor();
***************
*** 1385,1391 ****
break;
case 'y':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (!p_ri && !F_is_TyE(tempc))
chg_c_to_X_orX_ ();
if (p_ri)
--- 1328,1334 ----
break;
case 'y':
if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (!p_ri && !F_is_TyE(tempc))
chg_c_to_X_orX_ ();
if (p_ri)
***************
*** 1434,1440 ****
if ((F_isalpha(tempc) || F_isdigit(tempc)))
{
if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (!p_ri && !F_is_TyE(tempc))
chg_c_to_X_orX_ ();
if (p_ri)
--- 1377,1383 ----
if ((F_isalpha(tempc) || F_isdigit(tempc)))
{
if (!curwin->w_cursor.col && STRLEN(ml_get_curline()))
! {
if (!p_ri && !F_is_TyE(tempc))
chg_c_to_X_orX_ ();
if (p_ri)
***************
*** 1461,1467 ****
}
/*
! ** Convert a none leading Farsi char into a leading type.
*/
static int
toF_leading(int c)
--- 1404,1410 ----
}
/*
! * Convert a none leading Farsi char into a leading type.
*/
static int
toF_leading(int c)
***************
*** 1515,1521 ****
}
/*
! ** Convert a given Farsi char into right joining type.
*/
static int
toF_Rjoin(int c)
--- 1458,1464 ----
}
/*
! * Convert a given Farsi char into right joining type.
*/
static int
toF_Rjoin(int c)
***************
*** 1571,1577 ****
}
/*
! ** Can a given Farsi character join via its left edj.
*/
static int
canF_Ljoin(int c)
--- 1514,1520 ----
}
/*
! * Can a given Farsi character join via its left edj.
*/
static int
canF_Ljoin(int c)
***************
*** 1645,1651 ****
}
/*
! ** Can a given Farsi character join via its right edj.
*/
static int
canF_Rjoin(int c)
--- 1588,1594 ----
}
/*
! * Can a given Farsi character join via its right edj.
*/
static int
canF_Rjoin(int c)
***************
*** 1673,1679 ****
}
/*
! ** is a given Farsi character a terminating type.
*/
static int
F_isterm(int c)
--- 1616,1622 ----
}
/*
! * is a given Farsi character a terminating type.
*/
static int
F_isterm(int c)
***************
*** 1700,1785 ****
}
/*
! ** Convert the given Farsi character into a ending type .
*/
static int
toF_ending(int c)
{
-
switch (c)
{
! case _BE:
! return BE;
! case _PE:
! return PE;
! case _TE:
! return TE;
! case _SE:
! return SE;
! case _JIM:
! return JIM;
! case _CHE:
! return CHE;
! case _HE_J:
! return HE_J;
! case _XE:
! return XE;
! case _SIN:
! return SIN;
! case _SHIN:
! return SHIN;
! case _SAD:
! return SAD;
! case _ZAD:
! return ZAD;
! case _AYN:
! return AYN;
! case _AYN_:
! return AYN_;
! case _GHAYN:
! return GHAYN;
! case _GHAYN_:
! return GHAYN_;
! case _FE:
! return FE;
! case _GHAF:
! return GHAF;
case _KAF_H:
! case _KAF:
! return KAF;
! case _GAF:
! return GAF;
! case _LAM:
! return LAM;
! case _MIM:
! return MIM;
! case _NOON:
! return NOON;
! case _YE:
! return YE_;
! case YE_:
! return YE;
! case _YEE:
! return YEE_;
! case YEE_:
! return YEE;
! case TEE:
! return TEE_;
! case _IE:
! return IE_;
! case IE_:
! return IE;
case _HE:
! case _HE_:
! return F_HE;
}
return c;
}
/*
! ** Convert the Farsi 3342 standard into Farsi VIM.
*/
! void
conv_to_pvim(void)
{
char_u *ptr;
--- 1643,1696 ----
}
/*
! * Convert the given Farsi character into a ending type .
*/
static int
toF_ending(int c)
{
switch (c)
{
! case _BE: return BE;
! case _PE: return PE;
! case _TE: return TE;
! case _SE: return SE;
! case _JIM: return JIM;
! case _CHE: return CHE;
! case _HE_J: return HE_J;
! case _XE: return XE;
! case _SIN: return SIN;
! case _SHIN: return SHIN;
! case _SAD: return SAD;
! case _ZAD: return ZAD;
! case _AYN: return AYN;
! case _AYN_: return AYN_;
! case _GHAYN: return GHAYN;
! case _GHAYN_: return GHAYN_;
! case _FE: return FE;
! case _GHAF: return GHAF;
case _KAF_H:
! case _KAF: return KAF;
! case _GAF: return GAF;
! case _LAM: return LAM;
! case _MIM: return MIM;
! case _NOON: return NOON;
! case _YE: return YE_;
! case YE_: return YE;
! case _YEE: return YEE_;
! case YEE_: return YEE;
! case TEE: return TEE_;
! case _IE: return IE_;
! case IE_: return IE;
case _HE:
! case _HE_: return F_HE;
}
return c;
}
/*
! * Convert the Farsi 3342 standard into Farsi VIM.
*/
! static void
conv_to_pvim(void)
{
char_u *ptr;
***************
*** 1791,1797 ****
llen = (int)STRLEN(ptr);
! for ( i = 0; i < llen-1; i++)
{
if (canF_Ljoin(ptr[i]) && canF_Rjoin(ptr[i+1]))
{
--- 1702,1708 ----
llen = (int)STRLEN(ptr);
! for (i = 0; i < llen-1; i++)
{
if (canF_Ljoin(ptr[i]) && canF_Rjoin(ptr[i+1]))
{
***************
*** 1817,1824 ****
* Following lines contains Farsi encoded character.
*/
! do_cmdline_cmd((char_u *)"%s/\202\231/\232/g");
! do_cmdline_cmd((char_u *)"%s/\201\231/\370\334/g");
/* Assume the screen has been messed up: clear it and redraw. */
redraw_later(CLEAR);
--- 1728,1735 ----
* Following lines contains Farsi encoded character.
*/
! do_cmdline_cmd((char_u *)"%s/\202\231/\232/ge");
! do_cmdline_cmd((char_u *)"%s/\201\231/\370\334/ge");
/* Assume the screen has been messed up: clear it and redraw. */
redraw_later(CLEAR);
***************
*** 1828,1834 ****
/*
* Convert the Farsi VIM into Farsi 3342 standard.
*/
! void
conv_to_pstd(void)
{
char_u *ptr;
--- 1739,1745 ----
/*
* Convert the Farsi VIM into Farsi 3342 standard.
*/
! static void
conv_to_pstd(void)
{
char_u *ptr;
***************
*** 1837,1856 ****
/*
* Following line contains Farsi encoded character.
*/
!
! do_cmdline_cmd((char_u *)"%s/\232/\202\231/g");
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum)
{
ptr = ml_get((linenr_T)lnum);
-
llen = (int)STRLEN(ptr);
! for ( i = 0; i < llen; i++)
! {
ptr[i] = toF_TyA(ptr[i]);
-
- }
}
/* Assume the screen has been messed up: clear it and redraw. */
--- 1748,1762 ----
/*
* Following line contains Farsi encoded character.
*/
! do_cmdline_cmd((char_u *)"%s/\232/\202\231/ge");
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum)
{
ptr = ml_get((linenr_T)lnum);
llen = (int)STRLEN(ptr);
! for (i = 0; i < llen; i++)
ptr[i] = toF_TyA(ptr[i]);
}
/* Assume the screen has been messed up: clear it and redraw. */
***************
*** 2148,2154 ****
case 'f': return _BE;
case 'g': return _LAM;
case 'G':
! if (cmd_gchar(AT_CURSOR) == _LAM )
{
cmd_pchar(LAM, AT_CURSOR);
return ALEF_U_H;
--- 2054,2060 ----
case 'f': return _BE;
case 'g': return _LAM;
case 'G':
! if (cmd_gchar(AT_CURSOR) == _LAM)
{
cmd_pchar(LAM, AT_CURSOR);
return ALEF_U_H;
***************
*** 2159,2165 ****
else
return ALEF_U_H;
case 'h':
! if (cmd_gchar(AT_CURSOR) == _LAM )
{
cmd_pchar(LA, AT_CURSOR);
redrawcmdline();
--- 2065,2071 ----
else
return ALEF_U_H;
case 'h':
! if (cmd_gchar(AT_CURSOR) == _LAM)
{
cmd_pchar(LA, AT_CURSOR);
redrawcmdline();
***************
*** 2215,2223 ****
case ',': return WAW;
case '[': return _JIM;
case ']': return _CHE;
! }
! return c;
}
/*
--- 2121,2129 ----
case ',': return WAW;
case '[': return _JIM;
case ']': return _CHE;
! }
! return c;
}
/*
***************
*** 2226,2232 ****
int
F_isalpha(int c)
{
! return (( c >= TEE_ && c <= _YE)
|| (c >= ALEF_A && c <= YE)
|| (c >= _IE && c <= YE_));
}
--- 2132,2138 ----
int
F_isalpha(int c)
{
! return ((c >= TEE_ && c <= _YE)
|| (c >= ALEF_A && c <= YE)
|| (c >= _IE && c <= YE_));
}
***************
*** 2246,2290 ****
int
F_ischar(int c)
{
! return (c >= TEE_ && c <= YE_);
}
void
! farsi_fkey(
! cmdarg_T *cap)
{
! int c = cap->cmdchar;
!
! if (c == K_F8)
{
! if (p_altkeymap)
{
! if (curwin->w_farsi & W_R_L)
! {
! p_fkmap = 0;
! do_cmdline_cmd((char_u *)"set norl");
! MSG("");
! }
! else
! {
! p_fkmap = 1;
! do_cmdline_cmd((char_u *)"set rl");
! MSG("");
! }
!
! curwin->w_farsi = curwin->w_farsi ^ W_R_L;
}
}
! if (c == K_F9)
{
! if (p_altkeymap && curwin->w_p_rl)
! {
! curwin->w_farsi = curwin->w_farsi ^ W_CONV;
! if (curwin->w_farsi & W_CONV)
! conv_to_pvim();
! else
! conv_to_pstd();
! }
}
}
--- 2152,2191 ----
int
F_ischar(int c)
{
! return (c >= TEE_ && c <= YE_);
}
void
! farsi_f8(cmdarg_T *cap UNUSED)
{
! if (p_altkeymap)
{
! if (curwin->w_farsi & W_R_L)
{
! p_fkmap = 0;
! do_cmdline_cmd((char_u *)"set norl");
! MSG("");
! }
! else
! {
! p_fkmap = 1;
! do_cmdline_cmd((char_u *)"set rl");
! MSG("");
}
+
+ curwin->w_farsi = curwin->w_farsi ^ W_R_L;
}
+ }
! void
! farsi_f9(cmdarg_T *cap UNUSED)
! {
! if (p_altkeymap && curwin->w_p_rl)
{
! curwin->w_farsi = curwin->w_farsi ^ W_CONV;
! if (curwin->w_farsi & W_CONV)
! conv_to_pvim();
! else
! conv_to_pstd();
}
}
*** ../vim-7.4.1980/src/Makefile 2016-07-01 17:17:13.266267111 +0200
--- src/Makefile 2016-07-02 16:16:27.500260457 +0200
***************
*** 2022,2027 ****
--- 2022,2028 ----
test_expand_dllpath \
test_expr \
test_expr_utf8 \
+ test_farsi \
test_feedkeys \
test_file_perm \
test_fnamemodify \
*** ../vim-7.4.1980/src/charset.c 2016-07-01 18:16:47.481936426 +0200
--- src/charset.c 2016-07-02 17:50:51.966663931 +0200
***************
*** 571,577 ****
(c >= ' ' && c <= '~')
#endif
#ifdef FEAT_FKMAP
! || F_ischar(c)
#endif
)) || (c < 256 && vim_isprintc_strict(c)))
{
--- 571,577 ----
(c >= ' ' && c <= '~')
#endif
#ifdef FEAT_FKMAP
! || (p_altkeymap && F_ischar(c))
#endif
)) || (c < 256 && vim_isprintc_strict(c)))
{
*** ../vim-7.4.1980/src/normal.c 2016-06-15 22:03:41.873190446 +0200
--- src/normal.c 2016-07-02 16:32:36.750205583 +0200
***************
*** 414,421 ****
{K_TABMENU, nv_tabmenu, 0, 0},
#endif
#ifdef FEAT_FKMAP
! {K_F8, farsi_fkey, 0, 0},
! {K_F9, farsi_fkey, 0, 0},
#endif
#ifdef FEAT_NETBEANS_INTG
{K_F21, nv_nbcmd, NV_NCH_ALW, 0},
--- 414,421 ----
{K_TABMENU, nv_tabmenu, 0, 0},
#endif
#ifdef FEAT_FKMAP
! {K_F8, farsi_f8, 0, 0},
! {K_F9, farsi_f9, 0, 0},
#endif
#ifdef FEAT_NETBEANS_INTG
{K_F21, nv_nbcmd, NV_NCH_ALW, 0},
*** ../vim-7.4.1980/src/proto/main.pro 2016-01-19 13:21:55.841334333 +0100
--- src/proto/main.pro 2016-07-02 16:56:18.969682675 +0200
***************
*** 10,19 ****
void server_to_input_buf(char_u *str);
char_u *eval_client_expr_to_string(char_u *expr);
char_u *serverConvert(char_u *client_enc, char_u *data, char_u **tofree);
- int toF_TyA(int c);
int fkmap(int c);
- void conv_to_pvim(void);
- void conv_to_pstd(void);
char_u *lrswap(char_u *ibuf);
char_u *lrFswap(char_u *cmdbuf, int len);
char_u *lrF_sub(char_u *ibuf);
--- 10,16 ----
***************
*** 21,26 ****
int F_isalpha(int c);
int F_isdigit(int c);
int F_ischar(int c);
! void farsi_fkey(cmdarg_T *cap);
int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int
next_c);
/* vim: set ft=c : */
--- 18,24 ----
int F_isalpha(int c);
int F_isdigit(int c);
int F_ischar(int c);
! void farsi_f8(cmdarg_T *cap);
! void farsi_f9(cmdarg_T *cap);
int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int
next_c);
/* vim: set ft=c : */
*** ../vim-7.4.1980/src/testdir/Make_all.mak 2016-07-01 17:17:13.298266645
+0200
--- src/testdir/Make_all.mak 2016-07-02 16:16:21.496347484 +0200
***************
*** 168,173 ****
--- 168,174 ----
test_cdo.res \
test_channel.res \
test_cmdline.res \
+ test_farsi.res \
test_hardcopy.res \
test_history.res \
test_increment.res \
*** ../vim-7.4.1980/src/testdir/test_farsi.vim 2016-07-02 18:24:23.585631957
+0200
--- src/testdir/test_farsi.vim 2016-07-02 18:05:28.710019868 +0200
***************
*** 0 ****
--- 1,84 ----
+ " Simplistic testing of Farsi mode.
+
+ if !has('farsi')
+ finish
+ endif
+ " Farsi uses a single byte encoding.
+ set enc=latin1
+
+ func Test_farsi_toggle()
+ new
+
+ set altkeymap
+ call assert_equal(0, &fkmap)
+ call assert_equal(0, &rl)
+ call feedkeys("\<F8>", 'x')
+ call assert_equal(1, &fkmap)
+ call assert_equal(1, &rl)
+ call feedkeys("\<F8>", 'x')
+ call assert_equal(0, &fkmap)
+ call assert_equal(0, &rl)
+
+ set rl
+ " conversion from Farsi 3342 to Farsi VIM.
+ call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), ''))
+ call feedkeys("\<F9>", 'x')
+ let exp = [0xfc, 0xf8, 0xc1, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ \ 0xc8, 0xc9, 0xca, 0xd0, 0xd1, 0xd2, 0xd3, 0xd6,
+ \ 0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd9, 0xda,
+ \ 0xdb, 0xdc, 0xdc, 0xc1, 0xdd, 0xde, 0xe0, 0xe0,
+ \ 0xe1, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+ \ 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae,
+ \ 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
+ \ 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe,
+ \ 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6,
+ \ 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce,
+ \ 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
+ \ 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
+ \ 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
+ \ 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xfb, 0xfb, 0xfe,
+ \ 0xfe, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
+ \ 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xe1,
+ \ ]
+ call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1))
+
+ " conversion from Farsi VIM to Farsi 3342.
+ call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), ''))
+ call feedkeys("\<F9>", 'x')
+ let exp = [0xfc, 0xf8, 0xc1, 0x83, 0x84, 0x85, 0x86, 0x87,
+ \ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x90,
+ \ 0x90, 0x90, 0x92, 0x93, 0x93, 0x95, 0x96, 0x97,
+ \ 0x98, 0xdc, 0x9a, 0x9b, 0x9c, 0x9e, 0x9e, 0xff,
+ \ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ \ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ \ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ \ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ \ 0xc0, 0xc1, 0xc2, 0x83, 0x84, 0x85, 0x86, 0x87,
+ \ 0x88, 0x89, 0x8a, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ \ 0x8b, 0x8c, 0x8d, 0x8e, 0xd4, 0xd5, 0x90, 0x93,
+ \ 0x95, 0x96, 0x97, 0x98, 0x99, 0x9b, 0x9c, 0xdf,
+ \ 0x9d, 0xff, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ \ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xec, 0xee, 0xef,
+ \ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ \ 0xf8, 0xf9, 0xfa, 0xec, 0x80, 0xfd, 0xee, 0xff,
+ \ ]
+ call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1))
+
+ bwipe!
+ endfunc
+
+ func Test_farsi_map()
+ new
+
+ set altkeymap
+ set rl
+ " RHS of mapping is reversed.
+ imap xyz abc
+ call feedkeys("axyz\<Esc>", 'tx')
+ call assert_equal('cba', getline(1))
+
+ set norl
+ iunmap xyz
+ set noaltkeymap
+ bwipe!
+ endfunc
*** ../vim-7.4.1980/src/version.c 2016-07-02 15:41:41.586523202 +0200
--- src/version.c 2016-07-02 16:15:58.908674888 +0200
***************
*** 760,761 ****
--- 760,763 ----
{ /* Add new patch number below this line */
+ /**/
+ 1981,
/**/
--
hundred-and-one symptoms of being an internet addict:
179. You wonder why your household garbage can doesn't have an
"empty recycle bin" button.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.