Mercurial > vim
comparison src/farsi.c @ 10745:265268ea1adc v8.0.0262
patch 8.0.0262: Farsi support is barely tested
commit https://github.com/vim/vim/commit/ddf662a1c86ef0b4bd0c55c5f0aa192ebd6d9a5e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 29 17:59:12 2017 +0100
patch 8.0.0262: Farsi support is barely tested
Problem: Farsi support is barely tested.
Solution: Add more tests for Farsi. Clean up the code.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 29 Jan 2017 18:00:05 +0100 |
parents | 4aead6a9b7a9 |
children | b8a79277269a |
comparison
equal
deleted
inserted
replaced
10744:f49773e0c392 | 10745:265268ea1adc |
---|---|
13 | 13 |
14 #include "vim.h" | 14 #include "vim.h" |
15 | 15 |
16 #if defined(FEAT_FKMAP) || defined(PROTO) | 16 #if defined(FEAT_FKMAP) || defined(PROTO) |
17 | 17 |
18 static int toF_Xor_X_(int c); | |
19 static int F_is_TyE(int c); | |
20 static int F_is_TyC_TyD(int c); | |
21 static int F_is_TyB_TyC_TyD(int src, int offset); | 18 static int F_is_TyB_TyC_TyD(int src, int offset); |
22 static int toF_TyB(int c); | |
23 static void put_curr_and_l_to_X(int c); | |
24 static void put_and_redo(int c); | |
25 static void chg_c_toX_orX(void); | |
26 static void chg_c_to_X_orX_(void); | |
27 static void chg_c_to_X_or_X(void); | |
28 static void chg_l_to_X_orX_(void); | |
29 static void chg_l_toXor_X(void); | |
30 static void chg_r_to_Xor_X_(void); | |
31 static int toF_leading(int c); | |
32 static int toF_Rjoin(int c); | |
33 static int canF_Ljoin(int c); | |
34 static int canF_Rjoin(int c); | |
35 static int F_isterm(int c); | |
36 static int toF_ending(int c); | |
37 static void lrswapbuf(char_u *buf, int len); | |
38 | 19 |
39 /* | 20 /* |
40 * Convert the given Farsi character into a _X or _X_ type | 21 * Convert the given Farsi character into a _X or _X_ type |
41 */ | 22 */ |
42 static int | 23 static int |
43 toF_Xor_X_(int c) | 24 toF_Xor_X_(int c) |
44 { | 25 { |
45 int tempc; | 26 int tempc; |
46 | 27 |
103 return 0; | 84 return 0; |
104 } | 85 } |
105 | 86 |
106 /* | 87 /* |
107 * Convert the given Farsi character into Farsi capital character. | 88 * Convert the given Farsi character into Farsi capital character. |
108 */ | 89 */ |
109 static int | 90 static int |
110 toF_TyA(int c) | 91 toF_TyA(int c) |
111 { | 92 { |
112 switch (c) | 93 switch (c) |
113 { | 94 { |
154 | 135 |
155 /* | 136 /* |
156 * Is the character under the cursor+offset in the given buffer a join type. | 137 * Is the character under the cursor+offset in the given buffer a join type. |
157 * That is a character that is combined with the others. | 138 * That is a character that is combined with the others. |
158 * Note: the offset is used only for command line buffer. | 139 * Note: the offset is used only for command line buffer. |
159 */ | 140 */ |
160 static int | 141 static int |
161 F_is_TyB_TyC_TyD(int src, int offset) | 142 F_is_TyB_TyC_TyD(int src, int offset) |
162 { | 143 { |
163 int c; | 144 int c; |
164 | 145 |
205 return FALSE; | 186 return FALSE; |
206 } | 187 } |
207 | 188 |
208 /* | 189 /* |
209 * Is the Farsi character one of the terminating only type. | 190 * Is the Farsi character one of the terminating only type. |
210 */ | 191 */ |
211 static int | 192 static int |
212 F_is_TyE(int c) | 193 F_is_TyE(int c) |
213 { | 194 { |
214 switch (c) | 195 switch (c) |
215 { | 196 { |
228 return FALSE; | 209 return FALSE; |
229 } | 210 } |
230 | 211 |
231 /* | 212 /* |
232 * Is the Farsi character one of the none leading type. | 213 * Is the Farsi character one of the none leading type. |
233 */ | 214 */ |
234 static int | 215 static int |
235 F_is_TyC_TyD(int c) | 216 F_is_TyC_TyD(int c) |
236 { | 217 { |
237 switch (c) | 218 switch (c) |
238 { | 219 { |
252 return FALSE; | 233 return FALSE; |
253 } | 234 } |
254 | 235 |
255 /* | 236 /* |
256 * Convert a none leading Farsi char into a leading type. | 237 * Convert a none leading Farsi char into a leading type. |
257 */ | 238 */ |
258 static int | 239 static int |
259 toF_TyB(int c) | 240 toF_TyB(int c) |
260 { | 241 { |
261 switch (c) | 242 switch (c) |
262 { | 243 { |
273 case YEE_: return YEE; | 254 case YEE_: return YEE; |
274 } | 255 } |
275 return c; | 256 return c; |
276 } | 257 } |
277 | 258 |
259 | |
260 static void | |
261 put_and_redo(int c) | |
262 { | |
263 pchar_cursor(c); | |
264 AppendCharToRedobuff(K_BS); | |
265 AppendCharToRedobuff(c); | |
266 } | |
267 | |
278 /* | 268 /* |
279 * Overwrite the current redo and cursor characters + left adjust. | 269 * Overwrite the current redo and cursor characters + left adjust. |
280 */ | 270 */ |
281 static void | 271 static void |
282 put_curr_and_l_to_X(int c) | 272 put_curr_and_l_to_X(int c) |
283 { | 273 { |
284 int tempc; | 274 int tempc; |
285 | 275 |
310 } | 300 } |
311 | 301 |
312 put_and_redo(c); | 302 put_and_redo(c); |
313 } | 303 } |
314 | 304 |
315 static void | |
316 put_and_redo(int c) | |
317 { | |
318 pchar_cursor(c); | |
319 AppendCharToRedobuff(K_BS); | |
320 AppendCharToRedobuff(c); | |
321 } | |
322 | |
323 /* | 305 /* |
324 * Change the char. under the cursor to a X_ or X type | 306 * Change the char. under the cursor to a X_ or X type |
325 */ | 307 */ |
326 static void | 308 static void |
327 chg_c_toX_orX(void) | 309 chg_c_toX_orX(void) |
328 { | 310 { |
329 int tempc, curc; | 311 int tempc, curc; |
330 | 312 |
444 put_and_redo(tempc); | 426 put_and_redo(tempc); |
445 } | 427 } |
446 | 428 |
447 /* | 429 /* |
448 * Change the char. under the cursor to a _X_ or X_ type | 430 * Change the char. under the cursor to a _X_ or X_ type |
449 */ | 431 */ |
450 | |
451 static void | 432 static void |
452 chg_c_to_X_orX_(void) | 433 chg_c_to_X_orX_(void) |
453 { | 434 { |
454 int tempc; | 435 int tempc; |
455 | 436 |
496 put_and_redo(tempc); | 477 put_and_redo(tempc); |
497 } | 478 } |
498 | 479 |
499 /* | 480 /* |
500 * Change the char. under the cursor to a _X_ or _X type | 481 * Change the char. under the cursor to a _X_ or _X type |
501 */ | 482 */ |
502 static void | 483 static void |
503 chg_c_to_X_or_X (void) | 484 chg_c_to_X_or_X(void) |
504 { | 485 { |
505 int tempc; | 486 int tempc; |
506 | 487 |
507 tempc = gchar_cursor(); | 488 tempc = gchar_cursor(); |
508 | 489 |
527 put_and_redo(tempc); | 508 put_and_redo(tempc); |
528 } | 509 } |
529 | 510 |
530 /* | 511 /* |
531 * Change the character left to the cursor to a _X_ or X_ type | 512 * Change the character left to the cursor to a _X_ or X_ type |
532 */ | 513 */ |
533 static void | 514 static void |
534 chg_l_to_X_orX_(void) | 515 chg_l_to_X_orX_(void) |
535 { | 516 { |
536 int tempc; | 517 int tempc; |
537 | 518 |
595 dec_cursor(); | 576 dec_cursor(); |
596 } | 577 } |
597 | 578 |
598 /* | 579 /* |
599 * Change the character left to the cursor to a X or _X type | 580 * Change the character left to the cursor to a X or _X type |
600 */ | 581 */ |
601 | |
602 static void | 582 static void |
603 chg_l_toXor_X (void) | 583 chg_l_toXor_X(void) |
604 { | 584 { |
605 int tempc; | 585 int tempc; |
606 | 586 |
607 if (curwin->w_cursor.col != 0 && | 587 if (curwin->w_cursor.col != 0 && |
608 (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) | 588 (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) |
664 dec_cursor(); | 644 dec_cursor(); |
665 } | 645 } |
666 | 646 |
667 /* | 647 /* |
668 * Change the character right to the cursor to a _X or _X_ type | 648 * Change the character right to the cursor to a _X or _X_ type |
669 */ | 649 */ |
670 | |
671 static void | 650 static void |
672 chg_r_to_Xor_X_(void) | 651 chg_r_to_Xor_X_(void) |
673 { | 652 { |
674 int tempc, c; | 653 int tempc, c; |
675 | 654 |
689 } | 668 } |
690 } | 669 } |
691 | 670 |
692 /* | 671 /* |
693 * Map Farsi keyboard when in fkmap mode. | 672 * Map Farsi keyboard when in fkmap mode. |
694 */ | 673 */ |
695 | |
696 int | 674 int |
697 fkmap(int c) | 675 fkmap(int c) |
698 { | 676 { |
699 int tempc; | 677 int tempc; |
700 static int revins; | 678 int insert_mode = (State & INSERT); |
679 static int revins = 0; | |
701 | 680 |
702 if (IS_SPECIAL(c)) | 681 if (IS_SPECIAL(c)) |
703 return c; | 682 return c; |
704 | 683 |
705 if (VIM_ISDIGIT(c) || ((c == '.' || c == '+' || c == '-' || | 684 if (insert_mode) |
706 c == '^' || c == '%' || c == '#' || c == '=') && revins)) | 685 { |
707 { | 686 if (VIM_ISDIGIT(c) || ((c == '.' || c == '+' || c == '-' || |
708 if (!revins) | 687 c == '^' || c == '%' || c == '#' || c == '=') && revins)) |
709 { | 688 { |
710 if (curwin->w_cursor.col) | 689 /* Numbers are entered left-to-right. */ |
690 if (!revins) | |
711 { | 691 { |
712 if (!p_ri) | 692 if (curwin->w_cursor.col) |
713 dec_cursor(); | 693 { |
714 | 694 if (!p_ri) |
715 chg_c_toX_orX (); | 695 dec_cursor(); |
716 chg_l_toXor_X (); | 696 |
717 | 697 chg_c_toX_orX (); |
718 if (!p_ri) | 698 chg_l_toXor_X (); |
719 inc_cursor(); | 699 |
700 if (!p_ri) | |
701 inc_cursor(); | |
702 } | |
720 } | 703 } |
704 | |
705 arrow_used = TRUE; | |
706 (void)stop_arrow(); | |
707 | |
708 if (!curwin->w_p_rl && revins) | |
709 inc_cursor(); | |
710 | |
711 ++revins; | |
712 p_ri = 1; | |
721 } | 713 } |
722 | 714 else if (revins) |
723 arrow_used = TRUE; | |
724 (void)stop_arrow(); | |
725 | |
726 if (!curwin->w_p_rl && revins) | |
727 inc_cursor(); | |
728 | |
729 ++revins; | |
730 p_ri=1; | |
731 } | |
732 else | |
733 { | |
734 if (revins) | |
735 { | 715 { |
716 /* Stop entering number. */ | |
736 arrow_used = TRUE; | 717 arrow_used = TRUE; |
737 (void)stop_arrow(); | 718 (void)stop_arrow(); |
738 | 719 |
739 revins = 0; | 720 revins = 0; |
740 if (curwin->w_p_rl) | 721 if (curwin->w_p_rl) |
771 } | 752 } |
772 | 753 |
773 if (!revins) | 754 if (!revins) |
774 { | 755 { |
775 if (curwin->w_p_rl) | 756 if (curwin->w_p_rl) |
776 p_ri=0; | 757 p_ri = 0; |
777 if (!curwin->w_p_rl) | 758 if (!curwin->w_p_rl) |
778 p_ri=1; | 759 p_ri = 1; |
779 } | 760 } |
780 | 761 |
781 if ((c < 0x100) && (isalpha(c) || c == '&' || c == '^' || c == ';' || | 762 if ((c < 0x100) && (isalpha(c) || c == '&' || c == '^' || c == ';' || |
782 c == '\''|| c == ',' || c == '[' || | 763 c == '\''|| c == ',' || c == '[' || |
783 c == ']' || c == '{' || c == '}' )) | 764 c == ']' || c == '{' || c == '}')) |
784 chg_r_to_Xor_X_(); | 765 chg_r_to_Xor_X_(); |
785 | 766 |
786 tempc = 0; | 767 tempc = 0; |
787 | 768 |
788 switch (c) | 769 switch (c) |
842 case 'W': | 823 case 'W': |
843 case 'Y': | 824 case 'Y': |
844 case NL: | 825 case NL: |
845 case TAB: | 826 case TAB: |
846 | 827 |
847 if (p_ri && c == NL && curwin->w_cursor.col) | 828 if (p_ri && c == NL && curwin->w_cursor.col && insert_mode) |
848 { | 829 { |
849 /* | 830 /* |
850 * If the char before the cursor is _X_ or X_ do not change | 831 * If the char before the cursor is _X_ or X_ do not change |
851 * the one under the cursor with X type. | 832 * the one under the cursor with X type. |
852 */ | 833 */ |
853 | |
854 dec_cursor(); | 834 dec_cursor(); |
855 | 835 |
856 if (F_isalpha(gchar_cursor())) | 836 if (F_isalpha(gchar_cursor())) |
857 { | 837 { |
858 inc_cursor(); | 838 inc_cursor(); |
918 case '?': return F_QUESTION; | 898 case '?': return F_QUESTION; |
919 case ' ': return F_BLANK; | 899 case ' ': return F_BLANK; |
920 } | 900 } |
921 break; | 901 break; |
922 } | 902 } |
923 if (!p_ri) | 903 |
924 dec_cursor(); | 904 if (insert_mode) |
925 | |
926 switch ((tempc = gchar_cursor())) | |
927 { | 905 { |
928 case _BE: | 906 if (!p_ri) |
929 case _PE: | 907 dec_cursor(); |
930 case _TE: | 908 |
931 case _SE: | 909 switch ((tempc = gchar_cursor())) |
932 case _JIM: | 910 { |
933 case _CHE: | 911 case _BE: |
934 case _HE_J: | 912 case _PE: |
935 case _XE: | 913 case _TE: |
936 case _SIN: | 914 case _SE: |
937 case _SHIN: | 915 case _JIM: |
938 case _SAD: | 916 case _CHE: |
939 case _ZAD: | 917 case _HE_J: |
940 case _FE: | 918 case _XE: |
941 case _GHAF: | 919 case _SIN: |
942 case _KAF: | 920 case _SHIN: |
943 case _KAF_H: | 921 case _SAD: |
944 case _GAF: | 922 case _ZAD: |
945 case _LAM: | 923 case _FE: |
946 case _MIM: | 924 case _GHAF: |
947 case _NOON: | 925 case _KAF: |
948 case _HE: | 926 case _KAF_H: |
949 case _HE_: | 927 case _GAF: |
950 case _TA: | 928 case _LAM: |
951 case _ZA: | 929 case _MIM: |
952 put_curr_and_l_to_X(toF_TyA(tempc)); | 930 case _NOON: |
953 break; | 931 case _HE: |
954 case _AYN: | 932 case _HE_: |
955 case _AYN_: | 933 case _TA: |
956 | 934 case _ZA: |
957 if (!p_ri) | 935 put_curr_and_l_to_X(toF_TyA(tempc)); |
958 if (!curwin->w_cursor.col) | 936 break; |
959 { | 937 case _AYN: |
960 put_curr_and_l_to_X(AYN); | 938 case _AYN_: |
961 break; | 939 |
962 } | 940 if (!p_ri) |
963 | 941 if (!curwin->w_cursor.col) |
964 if (p_ri) | 942 { |
965 inc_cursor(); | 943 put_curr_and_l_to_X(AYN); |
966 else | 944 break; |
967 dec_cursor(); | 945 } |
968 | 946 |
969 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | 947 if (p_ri) |
970 tempc = AYN_; | 948 inc_cursor(); |
971 else | 949 else |
972 tempc = AYN; | 950 dec_cursor(); |
973 | 951 |
974 if (p_ri) | 952 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) |
975 dec_cursor(); | 953 tempc = AYN_; |
976 else | 954 else |
977 inc_cursor(); | 955 tempc = AYN; |
978 | 956 |
979 put_curr_and_l_to_X(tempc); | 957 if (p_ri) |
980 | 958 dec_cursor(); |
981 break; | 959 else |
982 case _GHAYN: | 960 inc_cursor(); |
983 case _GHAYN_: | 961 |
984 | 962 put_curr_and_l_to_X(tempc); |
985 if (!p_ri) | 963 |
986 if (!curwin->w_cursor.col) | 964 break; |
987 { | 965 case _GHAYN: |
988 put_curr_and_l_to_X(GHAYN); | 966 case _GHAYN_: |
989 break; | 967 |
990 } | 968 if (!p_ri) |
991 | 969 if (!curwin->w_cursor.col) |
992 if (p_ri) | 970 { |
993 inc_cursor(); | 971 put_curr_and_l_to_X(GHAYN); |
994 else | 972 break; |
995 dec_cursor(); | 973 } |
996 | 974 |
997 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | 975 if (p_ri) |
998 tempc = GHAYN_; | 976 inc_cursor(); |
999 else | 977 else |
1000 tempc = GHAYN; | 978 dec_cursor(); |
1001 | 979 |
1002 if (p_ri) | 980 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) |
1003 dec_cursor(); | 981 tempc = GHAYN_; |
1004 else | 982 else |
1005 inc_cursor(); | 983 tempc = GHAYN; |
1006 | 984 |
1007 put_curr_and_l_to_X(tempc); | 985 if (p_ri) |
1008 break; | 986 dec_cursor(); |
1009 case _YE: | 987 else |
1010 case _IE: | 988 inc_cursor(); |
1011 case _YEE: | 989 |
1012 if (!p_ri) | 990 put_curr_and_l_to_X(tempc); |
1013 if (!curwin->w_cursor.col) | 991 break; |
1014 { | 992 case _YE: |
1015 put_curr_and_l_to_X((tempc == _YE ? YE : | 993 case _IE: |
1016 (tempc == _IE ? IE : YEE))); | 994 case _YEE: |
1017 break; | 995 if (!p_ri) |
1018 } | 996 if (!curwin->w_cursor.col) |
1019 | 997 { |
1020 if (p_ri) | 998 put_curr_and_l_to_X((tempc == _YE ? YE : |
1021 inc_cursor(); | 999 (tempc == _IE ? IE : YEE))); |
1022 else | 1000 break; |
1023 dec_cursor(); | 1001 } |
1024 | 1002 |
1025 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | 1003 if (p_ri) |
1026 tempc = (tempc == _YE ? YE_ : | 1004 inc_cursor(); |
1027 (tempc == _IE ? IE_ : YEE_)); | 1005 else |
1028 else | 1006 dec_cursor(); |
1029 tempc = (tempc == _YE ? YE : | 1007 |
1030 (tempc == _IE ? IE : YEE)); | 1008 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) |
1031 | 1009 tempc = (tempc == _YE ? YE_ : |
1032 if (p_ri) | 1010 (tempc == _IE ? IE_ : YEE_)); |
1033 dec_cursor(); | 1011 else |
1034 else | 1012 tempc = (tempc == _YE ? YE : |
1035 inc_cursor(); | 1013 (tempc == _IE ? IE : YEE)); |
1036 | 1014 |
1037 put_curr_and_l_to_X(tempc); | 1015 if (p_ri) |
1038 break; | 1016 dec_cursor(); |
1017 else | |
1018 inc_cursor(); | |
1019 | |
1020 put_curr_and_l_to_X(tempc); | |
1021 break; | |
1039 } | 1022 } |
1040 | 1023 |
1041 if (!p_ri) | 1024 if (!p_ri) |
1042 inc_cursor(); | 1025 inc_cursor(); |
1043 | 1026 } |
1044 tempc = 0; | 1027 |
1045 | 1028 tempc = 0; |
1046 switch (c) | 1029 |
1047 { | 1030 switch (c) |
1048 case '0': return FARSI_0; | 1031 { |
1049 case '1': return FARSI_1; | 1032 case '0': return FARSI_0; |
1050 case '2': return FARSI_2; | 1033 case '1': return FARSI_1; |
1051 case '3': return FARSI_3; | 1034 case '2': return FARSI_2; |
1052 case '4': return FARSI_4; | 1035 case '3': return FARSI_3; |
1053 case '5': return FARSI_5; | 1036 case '4': return FARSI_4; |
1054 case '6': return FARSI_6; | 1037 case '5': return FARSI_5; |
1055 case '7': return FARSI_7; | 1038 case '6': return FARSI_6; |
1056 case '8': return FARSI_8; | 1039 case '7': return FARSI_7; |
1057 case '9': return FARSI_9; | 1040 case '8': return FARSI_8; |
1058 case 'B': return F_PSP; | 1041 case '9': return FARSI_9; |
1059 case 'E': return JAZR_N; | 1042 case 'B': return F_PSP; |
1060 case 'F': return ALEF_D_H; | 1043 case 'E': return JAZR_N; |
1061 case 'H': return ALEF_A; | 1044 case 'F': return ALEF_D_H; |
1062 case 'I': return TASH; | 1045 case 'H': return ALEF_A; |
1063 case 'K': return F_LQUOT; | 1046 case 'I': return TASH; |
1064 case 'L': return F_RQUOT; | 1047 case 'K': return F_LQUOT; |
1065 case 'M': return HAMZE; | 1048 case 'L': return F_RQUOT; |
1066 case 'O': return '['; | 1049 case 'M': return HAMZE; |
1067 case 'P': return ']'; | 1050 case 'O': return '['; |
1068 case 'Q': return OO; | 1051 case 'P': return ']'; |
1069 case 'R': return MAD_N; | 1052 case 'Q': return OO; |
1070 case 'T': return OW; | 1053 case 'R': return MAD_N; |
1071 case 'U': return MAD; | 1054 case 'T': return OW; |
1072 case 'W': return OW_OW; | 1055 case 'U': return MAD; |
1073 case 'Y': return JAZR; | 1056 case 'W': return OW_OW; |
1074 case '`': return F_PCN; | 1057 case 'Y': return JAZR; |
1075 case '!': return F_EXCL; | 1058 case '`': return F_PCN; |
1076 case '@': return F_COMMA; | 1059 case '!': return F_EXCL; |
1077 case '#': return F_DIVIDE; | 1060 case '@': return F_COMMA; |
1078 case '$': return F_CURRENCY; | 1061 case '#': return F_DIVIDE; |
1079 case '%': return F_PERCENT; | 1062 case '$': return F_CURRENCY; |
1080 case '^': return F_MUL; | 1063 case '%': return F_PERCENT; |
1081 case '&': return F_BCOMMA; | 1064 case '^': return F_MUL; |
1082 case '*': return F_STAR; | 1065 case '&': return F_BCOMMA; |
1083 case '(': return F_LPARENT; | 1066 case '*': return F_STAR; |
1084 case ')': return F_RPARENT; | 1067 case '(': return F_LPARENT; |
1085 case '-': return F_MINUS; | 1068 case ')': return F_RPARENT; |
1086 case '_': return F_UNDERLINE; | 1069 case '-': return F_MINUS; |
1087 case '=': return F_EQUALS; | 1070 case '_': return F_UNDERLINE; |
1088 case '+': return F_PLUS; | 1071 case '=': return F_EQUALS; |
1089 case '\\': return F_BSLASH; | 1072 case '+': return F_PLUS; |
1090 case '|': return F_PIPE; | 1073 case '\\': return F_BSLASH; |
1091 case ':': return F_DCOLON; | 1074 case '|': return F_PIPE; |
1092 case '"': return F_SEMICOLON; | 1075 case ':': return F_DCOLON; |
1093 case '.': return F_PERIOD; | 1076 case '"': return F_SEMICOLON; |
1094 case '/': return F_SLASH; | 1077 case '.': return F_PERIOD; |
1095 case '<': return F_LESS; | 1078 case '/': return F_SLASH; |
1096 case '>': return F_GREATER; | 1079 case '<': return F_LESS; |
1097 case '?': return F_QUESTION; | 1080 case '>': return F_GREATER; |
1098 case ' ': return F_BLANK; | 1081 case '?': return F_QUESTION; |
1099 } | 1082 case ' ': return F_BLANK; |
1100 break; | 1083 } |
1084 break; | |
1101 | 1085 |
1102 case 'a': | 1086 case 'a': |
1103 tempc = _SHIN; | 1087 tempc = _SHIN; |
1104 break; | 1088 break; |
1105 case 'A': | 1089 case 'A': |
1106 tempc = WAW_H; | 1090 tempc = WAW_H; |
1107 break; | 1091 break; |
1108 case 'b': | 1092 case 'b': |
1109 tempc = ZAL; | 1093 tempc = ZAL; |
1110 break; | 1094 break; |
1111 case 'c': | 1095 case 'c': |
1112 tempc = ZE; | 1096 tempc = ZE; |
1113 break; | 1097 break; |
1114 case 'C': | 1098 case 'C': |
1115 tempc = JE; | 1099 tempc = JE; |
1116 break; | 1100 break; |
1117 case 'd': | 1101 case 'd': |
1118 tempc = _YE; | 1102 tempc = _YE; |
1119 break; | 1103 break; |
1120 case 'D': | 1104 case 'D': |
1121 tempc = _YEE; | 1105 tempc = _YEE; |
1122 break; | 1106 break; |
1123 case 'e': | 1107 case 'e': |
1124 tempc = _SE; | 1108 tempc = _SE; |
1125 break; | 1109 break; |
1126 case 'f': | 1110 case 'f': |
1127 tempc = _BE; | 1111 tempc = _BE; |
1128 break; | 1112 break; |
1129 case 'g': | 1113 case 'g': |
1130 tempc = _LAM; | 1114 tempc = _LAM; |
1131 break; | 1115 break; |
1132 case 'G': | 1116 case 'G': |
1133 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | 1117 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) |
1134 { | 1118 { |
1135 | 1119 |
1136 if (gchar_cursor() == _LAM) | 1120 if (gchar_cursor() == _LAM) |
1228 | 1212 |
1229 if (!p_ri) | 1213 if (!p_ri) |
1230 inc_cursor(); | 1214 inc_cursor(); |
1231 break; | 1215 break; |
1232 case 'j': | 1216 case 'j': |
1233 tempc = _TE; | 1217 tempc = _TE; |
1234 break; | 1218 break; |
1235 case 'J': | 1219 case 'J': |
1236 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | 1220 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) |
1237 { | 1221 { |
1238 if (p_ri) | 1222 if (p_ri) |
1258 if (!p_ri) | 1242 if (!p_ri) |
1259 inc_cursor(); | 1243 inc_cursor(); |
1260 | 1244 |
1261 return tempc; | 1245 return tempc; |
1262 case 'k': | 1246 case 'k': |
1263 tempc = _NOON; | 1247 tempc = _NOON; |
1264 break; | 1248 break; |
1265 case 'l': | 1249 case 'l': |
1266 tempc = _MIM; | 1250 tempc = _MIM; |
1267 break; | 1251 break; |
1268 case 'm': | 1252 case 'm': |
1269 tempc = _PE; | 1253 tempc = _PE; |
1270 break; | 1254 break; |
1271 case 'n': | 1255 case 'n': |
1272 case 'N': | 1256 case 'N': |
1273 tempc = DAL; | 1257 tempc = DAL; |
1274 break; | 1258 break; |
1275 case 'o': | 1259 case 'o': |
1276 tempc = _XE; | 1260 tempc = _XE; |
1277 break; | 1261 break; |
1278 case 'p': | 1262 case 'p': |
1279 tempc = _HE_J; | 1263 tempc = _HE_J; |
1280 break; | 1264 break; |
1281 case 'q': | 1265 case 'q': |
1282 tempc = _ZAD; | 1266 tempc = _ZAD; |
1283 break; | 1267 break; |
1284 case 'r': | 1268 case 'r': |
1285 tempc = _GHAF; | 1269 tempc = _GHAF; |
1286 break; | 1270 break; |
1287 case 's': | 1271 case 's': |
1288 tempc = _SIN; | 1272 tempc = _SIN; |
1289 break; | 1273 break; |
1290 case 'S': | 1274 case 'S': |
1291 tempc = _IE; | 1275 tempc = _IE; |
1292 break; | 1276 break; |
1293 case 't': | 1277 case 't': |
1294 tempc = _FE; | 1278 tempc = _FE; |
1295 break; | 1279 break; |
1296 case 'u': | 1280 case 'u': |
1297 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | 1281 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) |
1298 { | 1282 { |
1299 if (!p_ri && !F_is_TyE(tempc)) | 1283 if (!p_ri && !F_is_TyE(tempc)) |
1300 chg_c_to_X_orX_ (); | 1284 chg_c_to_X_orX_ (); |
1301 if (p_ri) | 1285 if (p_ri) |
1302 chg_c_to_X_or_X (); | 1286 chg_c_to_X_or_X (); |
1303 | 1287 |
1304 } | 1288 } |
1305 | 1289 |
1306 if (!p_ri && !curwin->w_cursor.col) | 1290 if (!p_ri && !curwin->w_cursor.col) |
1307 return _AYN; | 1291 return _AYN; |
1308 | 1292 |
1309 if (!p_ri) | 1293 if (!p_ri) |
1310 dec_cursor(); | 1294 dec_cursor(); |
1311 | 1295 |
1312 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | 1296 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) |
1313 tempc = _AYN_; | 1297 tempc = _AYN_; |
1314 else | 1298 else |
1315 tempc = _AYN; | 1299 tempc = _AYN; |
1316 | 1300 |
1317 if (!p_ri) | 1301 if (!p_ri) |
1318 inc_cursor(); | 1302 inc_cursor(); |
1319 break; | 1303 break; |
1320 case 'v': | 1304 case 'v': |
1321 case 'V': | 1305 case 'V': |
1322 tempc = RE; | 1306 tempc = RE; |
1323 break; | 1307 break; |
1324 case 'w': | 1308 case 'w': |
1325 tempc = _SAD; | 1309 tempc = _SAD; |
1326 break; | 1310 break; |
1327 case 'x': | 1311 case 'x': |
1328 case 'X': | 1312 case 'X': |
1329 tempc = _TA; | 1313 tempc = _TA; |
1330 break; | 1314 break; |
1331 case 'y': | 1315 case 'y': |
1332 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | 1316 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) |
1333 { | 1317 { |
1334 if (!p_ri && !F_is_TyE(tempc)) | 1318 if (!p_ri && !F_is_TyE(tempc)) |
1352 if (!p_ri) | 1336 if (!p_ri) |
1353 inc_cursor(); | 1337 inc_cursor(); |
1354 | 1338 |
1355 break; | 1339 break; |
1356 case 'z': | 1340 case 'z': |
1357 tempc = _ZA; | 1341 tempc = _ZA; |
1358 break; | 1342 break; |
1359 case 'Z': | 1343 case 'Z': |
1360 tempc = _KAF_H; | 1344 tempc = _KAF_H; |
1361 break; | 1345 break; |
1362 case ';': | 1346 case ';': |
1363 tempc = _KAF; | 1347 tempc = _KAF; |
1364 break; | 1348 break; |
1365 case '\'': | 1349 case '\'': |
1366 tempc = _GAF; | 1350 tempc = _GAF; |
1367 break; | 1351 break; |
1368 case ',': | 1352 case ',': |
1369 tempc = WAW; | 1353 tempc = WAW; |
1370 break; | 1354 break; |
1371 case '[': | 1355 case '[': |
1372 tempc = _JIM; | 1356 tempc = _JIM; |
1373 break; | 1357 break; |
1374 case ']': | 1358 case ']': |
1375 tempc = _CHE; | 1359 tempc = _CHE; |
1376 break; | 1360 break; |
1377 } | 1361 } |
1378 | 1362 |
1379 if ((F_isalpha(tempc) || F_isdigit(tempc))) | 1363 if (F_isalpha(tempc) || F_isdigit(tempc)) |
1380 { | 1364 { |
1381 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | 1365 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) |
1382 { | 1366 { |
1383 if (!p_ri && !F_is_TyE(tempc)) | 1367 if (!p_ri && !F_is_TyE(tempc)) |
1384 chg_c_to_X_orX_ (); | 1368 chg_c_to_X_orX_(); |
1385 if (p_ri) | 1369 if (p_ri) |
1386 chg_c_to_X_or_X (); | 1370 chg_c_to_X_or_X(); |
1387 } | 1371 } |
1388 | 1372 |
1389 if (curwin->w_cursor.col) | 1373 if (curwin->w_cursor.col) |
1390 { | 1374 { |
1391 if (!p_ri) | 1375 if (!p_ri) |
1392 dec_cursor(); | 1376 dec_cursor(); |
1393 | 1377 |
1394 if (F_is_TyE(tempc)) | 1378 if (F_is_TyE(tempc)) |
1395 chg_l_toXor_X (); | 1379 chg_l_toXor_X(); |
1396 else | 1380 else |
1397 chg_l_to_X_orX_ (); | 1381 chg_l_to_X_orX_(); |
1398 | 1382 |
1399 if (!p_ri) | 1383 if (!p_ri) |
1400 inc_cursor(); | 1384 inc_cursor(); |
1401 } | 1385 } |
1402 } | 1386 } |
1405 return c; | 1389 return c; |
1406 } | 1390 } |
1407 | 1391 |
1408 /* | 1392 /* |
1409 * Convert a none leading Farsi char into a leading type. | 1393 * Convert a none leading Farsi char into a leading type. |
1410 */ | 1394 */ |
1411 static int | 1395 static int |
1412 toF_leading(int c) | 1396 toF_leading(int c) |
1413 { | 1397 { |
1414 switch (c) | 1398 switch (c) |
1415 { | 1399 { |
1459 return c; | 1443 return c; |
1460 } | 1444 } |
1461 | 1445 |
1462 /* | 1446 /* |
1463 * Convert a given Farsi char into right joining type. | 1447 * Convert a given Farsi char into right joining type. |
1464 */ | 1448 */ |
1465 static int | 1449 static int |
1466 toF_Rjoin(int c) | 1450 toF_Rjoin(int c) |
1467 { | 1451 { |
1468 switch (c) | 1452 switch (c) |
1469 { | 1453 { |
1515 return c; | 1499 return c; |
1516 } | 1500 } |
1517 | 1501 |
1518 /* | 1502 /* |
1519 * Can a given Farsi character join via its left edj. | 1503 * Can a given Farsi character join via its left edj. |
1520 */ | 1504 */ |
1521 static int | 1505 static int |
1522 canF_Ljoin(int c) | 1506 canF_Ljoin(int c) |
1523 { | 1507 { |
1524 switch (c) | 1508 switch (c) |
1525 { | 1509 { |
1589 return FALSE; | 1573 return FALSE; |
1590 } | 1574 } |
1591 | 1575 |
1592 /* | 1576 /* |
1593 * Can a given Farsi character join via its right edj. | 1577 * Can a given Farsi character join via its right edj. |
1594 */ | 1578 */ |
1595 static int | 1579 static int |
1596 canF_Rjoin(int c) | 1580 canF_Rjoin(int c) |
1597 { | 1581 { |
1598 switch (c) | 1582 switch (c) |
1599 { | 1583 { |
1617 | 1601 |
1618 } | 1602 } |
1619 | 1603 |
1620 /* | 1604 /* |
1621 * is a given Farsi character a terminating type. | 1605 * is a given Farsi character a terminating type. |
1622 */ | 1606 */ |
1623 static int | 1607 static int |
1624 F_isterm(int c) | 1608 F_isterm(int c) |
1625 { | 1609 { |
1626 switch (c) | 1610 switch (c) |
1627 { | 1611 { |
1644 return FALSE; | 1628 return FALSE; |
1645 } | 1629 } |
1646 | 1630 |
1647 /* | 1631 /* |
1648 * Convert the given Farsi character into a ending type . | 1632 * Convert the given Farsi character into a ending type . |
1649 */ | 1633 */ |
1650 static int | 1634 static int |
1651 toF_ending(int c) | 1635 toF_ending(int c) |
1652 { | 1636 { |
1653 switch (c) | 1637 switch (c) |
1654 { | 1638 { |
1689 return c; | 1673 return c; |
1690 } | 1674 } |
1691 | 1675 |
1692 /* | 1676 /* |
1693 * Convert the Farsi 3342 standard into Farsi VIM. | 1677 * Convert the Farsi 3342 standard into Farsi VIM. |
1694 */ | 1678 */ |
1695 static void | 1679 static void |
1696 conv_to_pvim(void) | 1680 conv_to_pvim(void) |
1697 { | 1681 { |
1698 char_u *ptr; | 1682 char_u *ptr; |
1699 int lnum, llen, i; | 1683 int lnum, llen, i; |