1 /* vi:set ts=8 sts=4 sw=4:
3 * VIM - Vi IMproved by Bram Moolenaar
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 * See README.txt for an overview of the Vim source code.
11 * farsi.c: functions for Farsi language
13 * Included by main.c, when FEAT_FKMAP is defined.
16 static int toF_Xor_X_
__ARGS((int c
));
17 static int F_is_TyE
__ARGS((int c
));
18 static int F_is_TyC_TyD
__ARGS((int c
));
19 static int F_is_TyB_TyC_TyD
__ARGS((int src
, int offset
));
20 static int toF_TyB
__ARGS((int c
));
21 static void put_curr_and_l_to_X
__ARGS((int c
));
22 static void put_and_redo
__ARGS((int c
));
23 static void chg_c_toX_orX
__ARGS((void));
24 static void chg_c_to_X_orX_
__ARGS((void));
25 static void chg_c_to_X_or_X
__ARGS((void));
26 static void chg_l_to_X_orX_
__ARGS((void));
27 static void chg_l_toXor_X
__ARGS((void));
28 static void chg_r_to_Xor_X_
__ARGS((void));
29 static int toF_leading
__ARGS((int c
));
30 static int toF_Rjoin
__ARGS((int c
));
31 static int canF_Ljoin
__ARGS((int c
));
32 static int canF_Rjoin
__ARGS((int c
));
33 static int F_isterm
__ARGS((int c
));
34 static int toF_ending
__ARGS((int c
));
35 static void lrswapbuf
__ARGS((char_u
*buf
, int len
));
38 ** Convert the given Farsi character into a _X or _X_ type
106 if (p_ri
&& (curwin
->w_cursor
.col
+ 1
107 < (colnr_T
)STRLEN(ml_get_curline())))
111 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
116 if (!p_ri
&& STRLEN(ml_get_curline()))
120 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
132 ** Convert the given Farsi character into Farsi capital character .
180 /* I am not sure what it is !!! case _KAF_H: */
210 ** Is the character under the cursor+offset in the given buffer a join type.
211 ** That is a character that is combined with the others.
212 ** Note: the offset is used only for command line buffer.
215 F_is_TyB_TyC_TyD(src
, offset
)
223 c
= cmd_gchar(AT_CURSOR
+offset
);
264 ** Is the Farsi character one of the terminating only type.
288 ** Is the Farsi character one of the none leading type.
313 ** Convert a none leading Farsi char into a leading type.
321 case ALEF_
: return ALEF
;
322 case ALEF_U_H_
: return ALEF_U_H
;
323 case _AYN_
: return _AYN
;
324 case AYN_
: return AYN
; /* exception - there are many of them */
325 case _GHAYN_
: return _GHAYN
;
326 case GHAYN_
: return GHAYN
; /* exception - there are many of them */
327 case _HE_
: return _HE
;
330 case TEE_
: return TEE
;
331 case YEE_
: return YEE
;
337 ** Overwrite the current redo and cursor characters + left adjust
340 put_curr_and_l_to_X(c
)
345 if (curwin
->w_p_rl
&& p_ri
)
348 if ((curwin
->w_cursor
.col
< (colnr_T
)STRLEN(ml_get_curline())))
350 if ((p_ri
&& curwin
->w_cursor
.col
) || !p_ri
)
357 if (F_is_TyC_TyD((tempc
= gchar_cursor())))
359 pchar_cursor(toF_TyB(tempc
));
360 AppendCharToRedobuff(K_BS
);
361 AppendCharToRedobuff(tempc
);
379 AppendCharToRedobuff(K_BS
);
380 AppendCharToRedobuff(c
);
384 ** Change the char. under the cursor to a X_ or X type
391 switch ((curc
= gchar_cursor()))
473 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
474 tempc
= (curc
== _YE
? YE_
:
475 (curc
== _IE
? IE_
: YEE_
));
477 tempc
= (curc
== _YE
? YE
:
478 (curc
== _IE
? IE
: YEE
));
483 if (curwin
->w_cursor
.col
)
486 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
487 tempc
= (curc
== _YE
? YE_
:
488 (curc
== _IE
? IE_
: YEE_
));
490 tempc
= (curc
== _YE
? YE
:
491 (curc
== _IE
? IE
: YEE
));
495 tempc
= (curc
== _YE
? YE
:
496 (curc
== _IE
? IE
: YEE
));
508 ** Change the char. under the cursor to a _X_ or X_ type
516 switch (gchar_cursor())
560 ** Change the char. under the cursor to a _X_ or _X type
567 tempc
= gchar_cursor();
569 if (curwin
->w_cursor
.col
+ 1 < (colnr_T
)STRLEN(ml_get_curline()))
573 if ((tempc
== F_HE
) && (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
)))
586 if ((tempc
= toF_Xor_X_(tempc
)) != 0)
591 ** Change the character left to the cursor to a _X_ or X_ type
598 if (curwin
->w_cursor
.col
!= 0 &&
599 (curwin
->w_cursor
.col
+ 1 == (colnr_T
)STRLEN(ml_get_curline())))
602 if (!curwin
->w_cursor
.col
&& p_ri
)
610 switch (gchar_cursor())
659 ** Change the character left to the cursor to a X or _X type
667 if (curwin
->w_cursor
.col
!= 0 &&
668 (curwin
->w_cursor
.col
+ 1 == (colnr_T
)STRLEN(ml_get_curline())))
671 if (!curwin
->w_cursor
.col
&& p_ri
)
679 switch (gchar_cursor())
728 ** Change the character right to the cursor to a _X or _X_ type
736 if (curwin
->w_cursor
.col
)
741 tempc
= gchar_cursor();
743 if ((c
= toF_Xor_X_(tempc
)) != 0)
753 ** Map Farsi keyboard when in fkmap mode.
766 if (VIM_ISDIGIT(c
) || ((c
== '.' || c
== '+' || c
== '-' ||
767 c
== '^' || c
== '%' || c
== '#' || c
== '=') && revins
))
771 if (curwin
->w_cursor
.col
)
787 if (!curwin
->w_p_rl
&& revins
)
803 while ((F_isdigit(gchar_cursor())
804 || (gchar_cursor() == F_PERIOD
805 || gchar_cursor() == F_PLUS
806 || gchar_cursor() == F_MINUS
807 || gchar_cursor() == F_MUL
808 || gchar_cursor() == F_DIVIDE
809 || gchar_cursor() == F_PERCENT
810 || gchar_cursor() == F_EQUALS
))
811 && gchar_cursor() != NUL
)
812 ++curwin
->w_cursor
.col
;
816 if (curwin
->w_cursor
.col
)
817 while ((F_isdigit(gchar_cursor())
818 || (gchar_cursor() == F_PERIOD
819 || gchar_cursor() == F_PLUS
820 || gchar_cursor() == F_MINUS
821 || gchar_cursor() == F_MUL
822 || gchar_cursor() == F_DIVIDE
823 || gchar_cursor() == F_PERCENT
824 || gchar_cursor() == F_EQUALS
))
825 && --curwin
->w_cursor
.col
)
828 if (!F_isdigit(gchar_cursor()))
829 ++curwin
->w_cursor
.col
;
842 if ((c
< 0x100) && (isalpha(c
) || c
== '&' || c
== '^' || c
== ';' ||
843 c
== '\''|| c
== ',' || c
== '[' ||
844 c
== ']' || c
== '{' || c
== '}' ))
908 if (p_ri
&& c
== NL
&& curwin
->w_cursor
.col
)
911 ** If the char before the cursor is _X_ or X_ do not change
912 ** the one under the cursor with X type.
917 if (F_isalpha(gchar_cursor()))
927 if (!curwin
->w_cursor
.col
)
931 case '0': return FARSI_0
;
932 case '1': return FARSI_1
;
933 case '2': return FARSI_2
;
934 case '3': return FARSI_3
;
935 case '4': return FARSI_4
;
936 case '5': return FARSI_5
;
937 case '6': return FARSI_6
;
938 case '7': return FARSI_7
;
939 case '8': return FARSI_8
;
940 case '9': return FARSI_9
;
941 case 'B': return F_PSP
;
942 case 'E': return JAZR_N
;
943 case 'F': return ALEF_D_H
;
944 case 'H': return ALEF_A
;
945 case 'I': return TASH
;
946 case 'K': return F_LQUOT
;
947 case 'L': return F_RQUOT
;
948 case 'M': return HAMZE
;
949 case 'O': return '[';
950 case 'P': return ']';
952 case 'R': return MAD_N
;
954 case 'U': return MAD
;
955 case 'W': return OW_OW
;
956 case 'Y': return JAZR
;
957 case '`': return F_PCN
;
958 case '!': return F_EXCL
;
959 case '@': return F_COMMA
;
960 case '#': return F_DIVIDE
;
961 case '$': return F_CURRENCY
;
962 case '%': return F_PERCENT
;
963 case '^': return F_MUL
;
964 case '&': return F_BCOMMA
;
965 case '*': return F_STAR
;
966 case '(': return F_LPARENT
;
967 case ')': return F_RPARENT
;
968 case '-': return F_MINUS
;
969 case '_': return F_UNDERLINE
;
970 case '=': return F_EQUALS
;
971 case '+': return F_PLUS
;
972 case '\\': return F_BSLASH
;
973 case '|': return F_PIPE
;
974 case ':': return F_DCOLON
;
975 case '"': return F_SEMICOLON
;
976 case '.': return F_PERIOD
;
977 case '/': return F_SLASH
;
978 case '<': return F_LESS
;
979 case '>': return F_GREATER
;
980 case '?': return F_QUESTION
;
981 case ' ': return F_BLANK
;
988 switch ((tempc
= gchar_cursor()))
1014 put_curr_and_l_to_X(toF_TyA(tempc
));
1020 if (!curwin
->w_cursor
.col
)
1022 put_curr_and_l_to_X(AYN
);
1031 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
1041 put_curr_and_l_to_X(tempc
);
1048 if (!curwin
->w_cursor
.col
)
1050 put_curr_and_l_to_X(GHAYN
);
1059 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
1069 put_curr_and_l_to_X(tempc
);
1075 if (!curwin
->w_cursor
.col
)
1077 put_curr_and_l_to_X((tempc
== _YE
? YE
:
1078 (tempc
== _IE
? IE
: YEE
)));
1087 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
1088 tempc
= (tempc
== _YE
? YE_
:
1089 (tempc
== _IE
? IE_
: YEE_
));
1091 tempc
= (tempc
== _YE
? YE
:
1092 (tempc
== _IE
? IE
: YEE
));
1099 put_curr_and_l_to_X(tempc
);
1110 case '0': return FARSI_0
;
1111 case '1': return FARSI_1
;
1112 case '2': return FARSI_2
;
1113 case '3': return FARSI_3
;
1114 case '4': return FARSI_4
;
1115 case '5': return FARSI_5
;
1116 case '6': return FARSI_6
;
1117 case '7': return FARSI_7
;
1118 case '8': return FARSI_8
;
1119 case '9': return FARSI_9
;
1120 case 'B': return F_PSP
;
1121 case 'E': return JAZR_N
;
1122 case 'F': return ALEF_D_H
;
1123 case 'H': return ALEF_A
;
1124 case 'I': return TASH
;
1125 case 'K': return F_LQUOT
;
1126 case 'L': return F_RQUOT
;
1127 case 'M': return HAMZE
;
1128 case 'O': return '[';
1129 case 'P': return ']';
1130 case 'Q': return OO
;
1131 case 'R': return MAD_N
;
1132 case 'T': return OW
;
1133 case 'U': return MAD
;
1134 case 'W': return OW_OW
;
1135 case 'Y': return JAZR
;
1136 case '`': return F_PCN
;
1137 case '!': return F_EXCL
;
1138 case '@': return F_COMMA
;
1139 case '#': return F_DIVIDE
;
1140 case '$': return F_CURRENCY
;
1141 case '%': return F_PERCENT
;
1142 case '^': return F_MUL
;
1143 case '&': return F_BCOMMA
;
1144 case '*': return F_STAR
;
1145 case '(': return F_LPARENT
;
1146 case ')': return F_RPARENT
;
1147 case '-': return F_MINUS
;
1148 case '_': return F_UNDERLINE
;
1149 case '=': return F_EQUALS
;
1150 case '+': return F_PLUS
;
1151 case '\\': return F_BSLASH
;
1152 case '|': return F_PIPE
;
1153 case ':': return F_DCOLON
;
1154 case '"': return F_SEMICOLON
;
1155 case '.': return F_PERIOD
;
1156 case '/': return F_SLASH
;
1157 case '<': return F_LESS
;
1158 case '>': return F_GREATER
;
1159 case '?': return F_QUESTION
;
1160 case ' ': return F_BLANK
;
1195 if (!curwin
->w_cursor
.col
&& STRLEN(ml_get_curline()))
1198 if (gchar_cursor() == _LAM
)
1206 if (!curwin
->w_cursor
.col
)
1212 if (gchar_cursor() == _LAM
)
1219 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
1232 if (!curwin
->w_cursor
.col
&& STRLEN(ml_get_curline()))
1240 if (!curwin
->w_cursor
.col
)
1246 if (gchar_cursor() == _LAM
)
1250 AppendCharToRedobuff(K_BS
);
1259 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
1273 if (!curwin
->w_cursor
.col
&& STRLEN(ml_get_curline()))
1275 if (!p_ri
&& !F_is_TyE(tempc
))
1282 if (!p_ri
&& !curwin
->w_cursor
.col
)
1288 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
1300 if (!curwin
->w_cursor
.col
&& STRLEN(ml_get_curline()))
1308 if (!curwin
->w_cursor
.col
)
1314 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
1361 if (!curwin
->w_cursor
.col
&& STRLEN(ml_get_curline()))
1363 if (!p_ri
&& !F_is_TyE(tempc
))
1370 if (!p_ri
&& !curwin
->w_cursor
.col
)
1376 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
1396 if (!curwin
->w_cursor
.col
&& STRLEN(ml_get_curline()))
1398 if (!p_ri
&& !F_is_TyE(tempc
))
1405 if (!p_ri
&& !curwin
->w_cursor
.col
)
1411 if (F_is_TyB_TyC_TyD(SRC_EDT
, AT_CURSOR
))
1443 if ((F_isalpha(tempc
) || F_isdigit(tempc
)))
1445 if (!curwin
->w_cursor
.col
&& STRLEN(ml_get_curline()))
1447 if (!p_ri
&& !F_is_TyE(tempc
))
1453 if (curwin
->w_cursor
.col
)
1458 if (F_is_TyE(tempc
))
1473 ** Convert a none leading Farsi char into a leading type.
1481 case ALEF_
: return ALEF
;
1482 case ALEF_U_H_
: return ALEF_U_H
;
1483 case BE
: return _BE
;
1484 case PE
: return _PE
;
1485 case TE
: return _TE
;
1486 case SE
: return _SE
;
1487 case JIM
: return _JIM
;
1488 case CHE
: return _CHE
;
1489 case HE_J
: return _HE_J
;
1490 case XE
: return _XE
;
1491 case SIN
: return _SIN
;
1492 case SHIN
: return _SHIN
;
1493 case SAD
: return _SAD
;
1494 case ZAD
: return _ZAD
;
1498 case _AYN_
: return _AYN
;
1502 case _GHAYN_
: return _GHAYN
;
1504 case FE
: return _FE
;
1505 case GHAF
: return _GHAF
;
1506 case KAF
: return _KAF
;
1507 case GAF
: return _GAF
;
1508 case LAM
: return _LAM
;
1509 case MIM
: return _MIM
;
1510 case NOON
: return _NOON
;
1513 case F_HE
: return _HE
;
1516 case YE_
: return _YE
;
1519 case IE
: return _IE
;
1522 case YEE_
: return _YEE
;
1528 ** Convert a given Farsi char into right joining type.
1536 case ALEF
: return ALEF_
;
1537 case ALEF_U_H
: return ALEF_U_H_
;
1538 case BE
: return _BE
;
1539 case PE
: return _PE
;
1540 case TE
: return _TE
;
1541 case SE
: return _SE
;
1542 case JIM
: return _JIM
;
1543 case CHE
: return _CHE
;
1544 case HE_J
: return _HE_J
;
1545 case XE
: return _XE
;
1546 case SIN
: return _SIN
;
1547 case SHIN
: return _SHIN
;
1548 case SAD
: return _SAD
;
1549 case ZAD
: return _ZAD
;
1553 case _AYN
: return _AYN_
;
1557 case _GHAYN_
: return _GHAYN_
;
1559 case FE
: return _FE
;
1560 case GHAF
: return _GHAF
;
1561 case KAF
: return _KAF
;
1562 case GAF
: return _GAF
;
1563 case LAM
: return _LAM
;
1564 case MIM
: return _MIM
;
1565 case NOON
: return _NOON
;
1568 case F_HE
: return _HE_
;
1571 case YE_
: return _YE
;
1574 case IE
: return _IE
;
1576 case TEE
: return TEE_
;
1579 case YEE_
: return _YEE
;
1585 ** Can a given Farsi character join via its left edj.
1660 ** Can a given Farsi character join via its right edj.
1684 return canF_Ljoin(c
);
1689 ** is a given Farsi character a terminating type.
1717 ** Convert the given Farsi character into a ending type .
1795 ** Convert the Farsi 3342 standard into Farsi VIM.
1803 for (lnum
= 1; lnum
<= curbuf
->b_ml
.ml_line_count
; ++lnum
)
1805 ptr
= ml_get((linenr_T
)lnum
);
1807 llen
= (int)STRLEN(ptr
);
1809 for ( i
= 0; i
< llen
-1; i
++)
1811 if (canF_Ljoin(ptr
[i
]) && canF_Rjoin(ptr
[i
+1]))
1813 ptr
[i
] = toF_leading(ptr
[i
]);
1816 while(canF_Rjoin(ptr
[i
]) && (i
< llen
))
1818 ptr
[i
] = toF_Rjoin(ptr
[i
]);
1819 if (F_isterm(ptr
[i
]) || !F_isalpha(ptr
[i
]))
1823 if (!F_isalpha(ptr
[i
]) || !canF_Rjoin(ptr
[i
]))
1824 ptr
[i
-1] = toF_ending(ptr
[i
-1]);
1827 ptr
[i
] = toF_TyA(ptr
[i
]);
1832 * Following lines contains Farsi encoded character.
1835 do_cmdline_cmd((char_u
*)"%s/\202\231/\232/g");
1836 do_cmdline_cmd((char_u
*)"%s/\201\231/\370\334/g");
1838 /* Assume the screen has been messed up: clear it and redraw. */
1839 redraw_later(CLEAR
);
1840 MSG_ATTR(farsi_text_1
, hl_attr(HLF_S
));
1844 * Convert the Farsi VIM into Farsi 3342 standad.
1853 * Following line contains Farsi encoded character.
1856 do_cmdline_cmd((char_u
*)"%s/\232/\202\231/g");
1858 for (lnum
= 1; lnum
<= curbuf
->b_ml
.ml_line_count
; ++lnum
)
1860 ptr
= ml_get((linenr_T
)lnum
);
1862 llen
= (int)STRLEN(ptr
);
1864 for ( i
= 0; i
< llen
; i
++)
1866 ptr
[i
] = toF_TyA(ptr
[i
]);
1871 /* Assume the screen has been messed up: clear it and redraw. */
1872 redraw_later(CLEAR
);
1873 MSG_ATTR(farsi_text_2
, hl_attr(HLF_S
));
1877 * left-right swap the characters in buf[len].
1901 * swap all the characters in reverse direction
1907 if (ibuf
!= NULL
&& *ibuf
!= NUL
)
1908 lrswapbuf(ibuf
, (int)STRLEN(ibuf
));
1913 * swap all the Farsi characters in reverse direction
1916 lrFswap(cmdbuf
, len
)
1925 if (len
== 0 && (len
= (int)STRLEN(cmdbuf
)) == 0)
1928 for (i
= 0; i
< len
; i
++)
1930 for (cnt
= 0; i
+ cnt
< len
1931 && (F_isalpha(cmdbuf
[i
+ cnt
])
1932 || F_isdigit(cmdbuf
[i
+ cnt
])
1933 || cmdbuf
[i
+ cnt
] == ' '); ++cnt
)
1936 lrswapbuf(cmdbuf
+ i
, cnt
);
1943 * Reverse the characters in the search path and substitute section
1945 * TODO: handle different separator characters. Use skip_regexp().
1956 /* Find the boundary of the search path */
1957 while (((p
= vim_strchr(p
+ 1, '/')) != NULL
) && p
[-1] == '\\')
1963 /* Reverse the Farsi characters in the search path. */
1964 lrFswap(ibuf
, (int)(p
-ibuf
));
1966 /* Now find the boundary of the substitute section */
1967 if ((ep
= (char_u
*)strrchr((char *)++p
, '/')) != NULL
)
1968 cnt
= (int)(ep
- p
);
1970 cnt
= (int)STRLEN(p
);
1972 /* Reverse the characters in the substitute section and take care of '\' */
1973 for (i
= 0; i
< cnt
-1; i
++)
1986 * Map Farsi keyboard when in cmd_fkmap mode.
2053 switch ((tempc
= cmd_gchar(AT_CURSOR
)))
2078 cmd_pchar(toF_TyA(tempc
), AT_CURSOR
);
2081 cmd_pchar(AYN_
, AT_CURSOR
);
2084 cmd_pchar(GHAYN_
, AT_CURSOR
);
2087 if (F_is_TyB_TyC_TyD(SRC_CMD
, AT_CURSOR
+1))
2088 cmd_pchar(IE_
, AT_CURSOR
);
2090 cmd_pchar(IE
, AT_CURSOR
);
2093 if (F_is_TyB_TyC_TyD(SRC_CMD
, AT_CURSOR
+1))
2094 cmd_pchar(YEE_
, AT_CURSOR
);
2096 cmd_pchar(YEE
, AT_CURSOR
);
2099 if (F_is_TyB_TyC_TyD(SRC_CMD
, AT_CURSOR
+1))
2100 cmd_pchar(YE_
, AT_CURSOR
);
2102 cmd_pchar(YE
, AT_CURSOR
);
2107 case '0': return FARSI_0
;
2108 case '1': return FARSI_1
;
2109 case '2': return FARSI_2
;
2110 case '3': return FARSI_3
;
2111 case '4': return FARSI_4
;
2112 case '5': return FARSI_5
;
2113 case '6': return FARSI_6
;
2114 case '7': return FARSI_7
;
2115 case '8': return FARSI_8
;
2116 case '9': return FARSI_9
;
2117 case 'B': return F_PSP
;
2118 case 'E': return JAZR_N
;
2119 case 'F': return ALEF_D_H
;
2120 case 'H': return ALEF_A
;
2121 case 'I': return TASH
;
2122 case 'K': return F_LQUOT
;
2123 case 'L': return F_RQUOT
;
2124 case 'M': return HAMZE
;
2125 case 'O': return '[';
2126 case 'P': return ']';
2127 case 'Q': return OO
;
2128 case 'R': return MAD_N
;
2129 case 'T': return OW
;
2130 case 'U': return MAD
;
2131 case 'W': return OW_OW
;
2132 case 'Y': return JAZR
;
2133 case '`': return F_PCN
;
2134 case '!': return F_EXCL
;
2135 case '@': return F_COMMA
;
2136 case '#': return F_DIVIDE
;
2137 case '$': return F_CURRENCY
;
2138 case '%': return F_PERCENT
;
2139 case '^': return F_MUL
;
2140 case '&': return F_BCOMMA
;
2141 case '*': return F_STAR
;
2142 case '(': return F_LPARENT
;
2143 case ')': return F_RPARENT
;
2144 case '-': return F_MINUS
;
2145 case '_': return F_UNDERLINE
;
2146 case '=': return F_EQUALS
;
2147 case '+': return F_PLUS
;
2148 case '\\': return F_BSLASH
;
2149 case '|': return F_PIPE
;
2150 case ':': return F_DCOLON
;
2151 case '"': return F_SEMICOLON
;
2152 case '.': return F_PERIOD
;
2153 case '/': return F_SLASH
;
2154 case '<': return F_LESS
;
2155 case '>': return F_GREATER
;
2156 case '?': return F_QUESTION
;
2157 case ' ': return F_BLANK
;
2162 case 'a': return _SHIN
;
2163 case 'A': return WAW_H
;
2164 case 'b': return ZAL
;
2165 case 'c': return ZE
;
2166 case 'C': return JE
;
2167 case 'd': return _YE
;
2168 case 'D': return _YEE
;
2169 case 'e': return _SE
;
2170 case 'f': return _BE
;
2171 case 'g': return _LAM
;
2173 if (cmd_gchar(AT_CURSOR
) == _LAM
)
2175 cmd_pchar(LAM
, AT_CURSOR
);
2179 if (F_is_TyB_TyC_TyD(SRC_CMD
, AT_CURSOR
))
2184 if (cmd_gchar(AT_CURSOR
) == _LAM
)
2186 cmd_pchar(LA
, AT_CURSOR
);
2191 if (F_is_TyB_TyC_TyD(SRC_CMD
, AT_CURSOR
))
2196 if (F_is_TyB_TyC_TyD(SRC_CMD
, AT_CURSOR
))
2200 case 'j': return _TE
;
2202 if (F_is_TyB_TyC_TyD(SRC_CMD
, AT_CURSOR
))
2206 case 'k': return _NOON
;
2207 case 'l': return _MIM
;
2208 case 'm': return _PE
;
2210 case 'N': return DAL
;
2211 case 'o': return _XE
;
2212 case 'p': return _HE_J
;
2213 case 'q': return _ZAD
;
2214 case 'r': return _GHAF
;
2215 case 's': return _SIN
;
2216 case 'S': return _IE
;
2217 case 't': return _FE
;
2219 if (F_is_TyB_TyC_TyD(SRC_CMD
, AT_CURSOR
))
2224 case 'V': return RE
;
2225 case 'w': return _SAD
;
2227 case 'X': return _TA
;
2229 if (F_is_TyB_TyC_TyD(SRC_CMD
, AT_CURSOR
))
2234 case 'Z': return _ZA
;
2235 case ';': return _KAF
;
2236 case '\'': return _GAF
;
2237 case ',': return WAW
;
2238 case '[': return _JIM
;
2239 case ']': return _CHE
;
2246 * F_isalpha returns TRUE if 'c' is a Farsi alphabet
2252 return (( c
>= TEE_
&& c
<= _YE
)
2253 || (c
>= ALEF_A
&& c
<= YE
)
2254 || (c
>= _IE
&& c
<= YE_
));
2258 * F_isdigit returns TRUE if 'c' is a Farsi digit
2264 return (c
>= FARSI_0
&& c
<= FARSI_9
);
2268 * F_ischar returns TRUE if 'c' is a Farsi character.
2274 return (c
>= TEE_
&& c
<= YE_
);
2281 int c
= cap
->cmdchar
;
2287 if (curwin
->w_farsi
& W_R_L
)
2290 do_cmdline_cmd((char_u
*)"set norl");
2296 do_cmdline_cmd((char_u
*)"set rl");
2300 curwin
->w_farsi
= curwin
->w_farsi
^ W_R_L
;
2306 if (p_altkeymap
&& curwin
->w_p_rl
)
2308 curwin
->w_farsi
= curwin
->w_farsi
^ W_CONV
;
2309 if (curwin
->w_farsi
& W_CONV
)