diff -rcN vim-4.5/doc/Makefile vim-4.5.farsi/doc/Makefile *** vim-4.5/doc/Makefile Sat Aug 3 17:42:08 1996 --- vim-4.5.farsi/doc/Makefile Tue Feb 2 17:21:24 1993 *************** *** 1,7 **** DOCS = vim_ami.txt vim_arch.txt vim_diff.txt vim_digr.txt vim_dos.txt \ vim_help.txt vim_idx.txt vim_mac.txt vim_w32.txt vim_ref.txt \ vim_tips.txt vim_unix.txt vim_win.txt vim_gui.txt vim_40.txt \ ! vim_kcc.txt vim_rlh.txt vim_menu.txt vim_os2.txt vim_mint.txt all: vim_tags vim.man xxd.man ctags.man --- 1,8 ---- DOCS = vim_ami.txt vim_arch.txt vim_diff.txt vim_digr.txt vim_dos.txt \ vim_help.txt vim_idx.txt vim_mac.txt vim_w32.txt vim_ref.txt \ vim_tips.txt vim_unix.txt vim_win.txt vim_gui.txt vim_40.txt \ ! vim_kcc.txt vim_rlh.txt vim_menu.txt vim_os2.txt vim_mint.txt \ ! vim_fars.txt all: vim_tags vim.man xxd.man ctags.man diff -rcN vim-4.5/doc/vim_fars.txt vim-4.5.farsi/doc/vim_fars.txt *** vim-4.5/doc/vim_fars.txt Wed Dec 31 23:00:00 1969 --- vim-4.5.farsi/doc/vim_fars.txt Tue Feb 2 19:43:11 1993 *************** *** 0 **** --- 1,194 ---- + *vim_fars.txt* For Vim version 4.2. Last modification: 1996 Dec 19 + + Farsi Mapping for Vim *farsi* + ===================== + + + Introduction + ------------ + In order to use right-to-left and Farsi mapping support, it is necessary to + compile Vim with FKMAP section in the feature.h activated. In right-to-left + oriented files the characters appear on the screen from right to left. This + kind of file is most useful when writing Farsi documents, composing faxes or + writing Farsi memos. + + There is no Farsi commands, prompts and help files, therefore the user + interface remains the standard Vi interface. + + + Highlights + ---------- + o Editing left-to-right files as in the original Vim, no change. + + o Viewing and editing files in right-to-left windows. File orientation is + per window, so it is possible to view the same file in right-to-left and + left-to-right modes, simultaneously. + + o Compatibility to the original Vim. Almost all features work in + right-to-left mode (see Bugs below). + + o Changing keyboard mapping and reverse insert modes using a single + command. + + o Backing from reverse insert mode to the correct place in the file + (if possible). + + o While in Farsi mode, numbers are entered from left to right. Upon entering + a character (not a number), that character will be inserted just into the + left of the last number. + + o No special terminal with right-to-left capabilities is required. The + right-to-left changes are completely hardware independent. Only + Farsi font is necessary. + + o Farsi keymapping on the command line in reverse insert mode. + + o Toggling between from left-to-right and right-to-left via F8 function key. + + o Toggling between Farsi 3342 standard encoding and VIM Farsi via F9 function + key. Since this makes sence only for the text written in right-to-left mode, + this function is also supported only in right-to-left mode. + + o ALL enhancements depend on a compilation variable, FKMAP (Farsi Key Map), + so it is possible to compile Vim without this support. + + + Usage + ----- + Prior to starting the vim, the environment in which the vim-persian can run + properly must be set. Following points describe some environment settings + that may be needed: + Key code mapping, loading graphic card in ASCII screen mode, setting the IO + driver in 8 bit clean mode ... . + For details on environment setting, refer to Farsi-HOWTO-1.txt contained in + the Farsi-HOWTO-package.tar . + + o Farsi Keymapping Activation + + Entering 'set akm' or 'set fk' command while in editor command line mode, + activates the Farsi keymapping (akm/fk are the abbreviations for altkeymap/ + fkmap which stand for alternative keymap/farsi keymap). Note that + 'noaltkeymap' is the default setting and in this mode the Hebrew keymapping + is active. To set the Farsi keymapping permanently, put the 'set akm' line + in your '.vimrc' file. + + o Right-To-Left Mode + + By default vim starts in Left-to-Right mode. Following are ways to change + the window orientation: + + + Start the vim with -H option (e.g. vim -H ... ). + + + While in Left-to-Right mode, enter 'set rl' in the command line ('rl' is + the abbreviation for rightleft). + + + Put the 'set rl' line in your '.vimrc' file to start the vim in + Right-to-Left mode permanently. + + Encoding + -------- + + The Farsi 3342 standard defines only the codes for the capital letters, which + may be suitable for graphical environments. Since I wanted to be conformed + to the Farsi 3342 standard and had to fulfill the VIM requirements (which runs + in a none graphical as well as graphical environment). So I used the Farsi + 3342 standard and added new codes for joining (small) letters. In addition + a conversion function has built in, which allows converting between VIM Farsi + and Farsi 3342 standard via F9. + + A set of Farsi extended ASCII fonts are composed for both X environment + and ASCII screen mode (using graphic card). The letter codes will be the + same for different platforms (i.e. UNIX's, MS DOS, ...). In this release the + fonts available are suitable for LINUX, SUN-OS, DOS and maybe some other + platforms that I am not aware of by now. + + For details on the Farsi fonts and font installation, refer to + Farsi-HOWTO-1.txt contained in the Farsi-HOWTO-package.tar . + + o Keyboard + + + CTRL-_ in insert/replace modes toggles between Farsi(akm)/Latin + mode as follows: + + + CTRL-_ moves the cursor to the end of the typed text in edit mode. + + + CTRL-_ in command mode only toggles keyboard mapping between Farsi(akm)/ + Latin. The Farsi text is then entered in reverse insert mode. + + + F8 - Toggles between left-to-right and right-to-left. + + + F9 - Toggles the encoding between Farsi 3342 standard and VIM Farsi. + + + Following is the keyboard mapping while Farsi(akm) mode set (the + mapping is based on the Iranian standard 'ISIRI 2901' - hopefully right): + + ------------------------------------- + ` 1 2 3 4 5 6 7 8 9 0 - = + + ------------------------------------- + ~ ! @ # $ % ^ & * ( ) _ + + ~ + ------------------------------------- + q w e r t y u i o p [ ] + + ------------------------------------- + Q W E R T Y U I O P { } + [ ] { } + ------------------------------------- + a s d f g h j k l ; ' \ + + ------------------------------------- + A S D F G H J K L : " | + + ------------------------------------- + < z x c v b n m , . / + + ------------------------------------- + > Z X C V B N M < > ? + + ------------------------------------- + + Note: + stands for Farsi PSP (beark without space) + + stands for Farsi PCN (for HAMZE attribute ) + + Restrictions + ------------ + + o In insert/replace mode and fkmap (Farsi mode) set, CTRL-B is not + supported. + + o If you change the character mapping between Latin/Farsi, the redo buffer + will be reset (emptied). That is, redo is valid and will function (using '.') + only within the mode you are in. + + o While numbers are entered in Farsi mode, the redo buffer will be reset + (emptied). That is, you can not redo the last changes (using '.') after + entering numbers. + + o While in left-to-right and Farsi mode set, CTRL-R is not supported. + + o While in right-to-left mode, the search on 'Latin' pattern does not work, + except if you enter the Latin search pattern in reverse. + + o On the command line, there is no support for entering the numbers from left + to right and also for the sake of the flexibility the keymapping logic is + restricted. + + o Under the X window environment, if you want to run the vim-persian in a + xterm, you need to have an ANSI compatible xterm. This is because the + letter codes above 128 decimal have certain meanings in the standard xterm. + This is actually no problem, since under the X environment you can run the + vim-persian in its own Motif/Athena window with more comfort. + + + Bugs + ---- + While in insert/replace and Farsi mode set, if you repeatedly change the + cursor position (via cursor movement) and enter new text and then try to undo + the last change, the undo will lag one change behind. But as you continue to + undo, you will reach the original line of text. You can also use U to undo all + changes made in the current line. + + For more information about the bugs refer to vim_rlh.txt. diff -rcN vim-4.5/doc/vim_help.txt vim-4.5.farsi/doc/vim_help.txt *** vim-4.5/doc/vim_help.txt Sun Oct 6 17:51:28 1996 --- vim-4.5.farsi/doc/vim_help.txt Tue Feb 2 17:14:58 1993 *************** *** 65,70 **** --- 65,71 ---- |vim_gui.txt| about the Graphical User Interface |vim_w32.txt| Win-NT/95 |vim_rlh.txt| about right-to-left editing |vim_40.txt| about this version + |vim_fars.txt| about Farsi editing |vim_tags| all the tags you can jump to (index of tags) ------------------------------------------------------------------------------ diff -rcN vim-4.5/doc/vim_ref.txt vim-4.5.farsi/doc/vim_ref.txt *** vim-4.5/doc/vim_ref.txt Sun Oct 6 17:52:33 1996 --- vim-4.5.farsi/doc/vim_ref.txt Tue Feb 2 17:19:05 1993 *************** *** 338,346 **** -l Lisp mode. Sets the 'lisp' and 'showmatch' options on. *-H* ! -H Hebrew mode. Sets the 'hkmap' and 'rightleft' options on. ! (Only when compiled with LEFTRIGHT defined, otherwise Vim ! gives an error message and exits). {not in Vi} *-n* -n No swap file will be used. Recovery after a crash will be --- 338,352 ---- -l Lisp mode. Sets the 'lisp' and 'showmatch' options on. *-H* ! -H Hebrew/Farsi mode. deppending on whetere 'akm' in .vimrc ! file is set or not, sets the 'hkmap' or 'fkmap' and 'rightleft' ! options on. (Only when compiled with LEFTRIGHT or FKMAP ! defined, otherwise Vim gives an error message and exits). ! ! Normally -H start the vim in Hebrew mode but if the .vimrc ! file contains the 'set altkeymap', the default is overwritten ! and vim start in Farsi mode. ! {not in Vi} *-n* -n No swap file will be used. Recovery after a crash will be *************** *** 971,983 **** compiled with RIGHTLEFT (which is not the default). See |ins_reverse|. {not in Vi} *i_CTRL-_* ! CTRL-_ This key is only available if Vim was compiled with RIGHTLEFT. ! Its purpose is to switch between languages while in insert ! mode, as follows: ! - When in a rightleft window, revins and nohkmap are toggled, ! since English will likely be inserted in this case. ! - When in a norightleft window, revins and hkmap are toggled, ! since Hebrew will likely be inserted in this case. CTRL-_ moves the cursor to the end of the typed text, unlike CTRL-B which leaves the cursor in the same place. --- 977,991 ---- compiled with RIGHTLEFT (which is not the default). See |ins_reverse|. {not in Vi} *i_CTRL-_* ! CTRL-_ This key is only available if Vim was compiled with RIGHTLEFT ! or FKMAP. Its purpose is to switch between languages while in ! insert mode, as follows: ! - When in a rightleft window, revins and nohkmap or nofkmap are ! toggled, since English will likely be inserted in this case. ! - When in a norightleft window, revins and hkmap or fkmap are ! toggled, since Hebrew or Farsi (depending on whether ! altkeymap is set or not) will likely be inserted in this ! case. CTRL-_ moves the cursor to the end of the typed text, unlike CTRL-B which leaves the cursor in the same place. *************** *** 1500,1510 **** CTRL-L command line completion (see 4.4.2, |cmdline_completion|) *c_CTRL-_* ! CTRL-_ switch between Hebrew and English keyboard mode, which is ! private to the command line and not related to hkmap. ! This is useful when Hebrew text entry is required in the ! command line, searches, abbreviations, etc. Applies only if ! Vim is compiled with RIGHTLEFT. See |vim_rlh.txt|. The and keys take the current command line as a search string. The beginning of the next/previous command lines are compared with this --- 1508,1520 ---- CTRL-L command line completion (see 4.4.2, |cmdline_completion|) *c_CTRL-_* ! CTRL-_ switch between Hebrew and English or Farsi and English ! keyboard mode, which is private to the command line and not ! related to hkmap or fkmap. Hebrew/English or Farsi/English ! mapping depend on 'altkeymap' set or not. This is useful when ! Hebrew/Farsi text entry is required in the command line, ! searches, abbreviations, etc. Applies only if Vim is compiled ! with RIGHTLEFT or FKMAP. See |vim_rlh.txt| and |vim_fars.txt|. The and keys take the current command line as a search string. The beginning of the next/previous command lines are compared with this *************** *** 8267,8273 **** each of these histories (see |cmdline_editing|). *'hkmap'* *'hk'* *'nohkmap'* *'nohk'* ! hkmap (kh) toggle (default off) global {not in Vi} {Only available if Vim was compiled with RIGHTLEFT --- 8277,8283 ---- each of these histories (see |cmdline_editing|). *'hkmap'* *'hk'* *'nohkmap'* *'nohk'* ! hkmap (hk) toggle (default off) global {not in Vi} {Only available if Vim was compiled with RIGHTLEFT *************** *** 8275,8280 **** --- 8285,8314 ---- When on, the keyboard is mapped for the Hebrew character set. Normally you would use CTRL-_ in insert mode to toggle this option. See |vim_rlh.txt|. + + *'altkeymap'* *'akm'* + altkeymap (akm) toggle (default off) + global + {not in Vi} + {Only available if Vim was compiled with FKMAP + defined} + When on, the second language is Farsi and CTRL-_ in insert mode + toggles the keyboard map between Farsi and English. + When off, which is the default, the keyboard map toggles between + Hebrew and English. This is useful to start the vim in native mode + (English for left-to-right and Farsi/Hebrew for right-to-left) and + having a default second language. + See |vim_fars.txt|. + + *'fkmap'* *'fk'* *'nofkmap'* *'nofk'* + fkmap (fk) toggle (default off) + global + {not in Vi} + {Only available if Vim was compiled with FKMAP + defined} + When on, the keyboard is mapped for the Farsi character set. + Normally you would use CTRL-_ in insert mode to toggle this option. + See |vim_fars.txt|. *'icon'* *'noicon'* icon toggle (default off, on when title can be restored) diff -rcN vim-4.5/src/Makefile vim-4.5.farsi/src/Makefile *** vim-4.5/src/Makefile Sun Oct 6 18:09:17 1996 --- vim-4.5.farsi/src/Makefile Tue Feb 2 23:16:57 1993 *************** *** 899,916 **** buffer.o: buffer.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h charset.o: charset.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ ! term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h cmdcmds.o: cmdcmds.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h cmdline.o: cmdline.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h cmdtab.h \ ! ops.h csearch.o: csearch.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h digraph.o: digraph.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h edit.o: edit.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ ! macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h fileio.o: fileio.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h getchar.o: getchar.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ --- 899,916 ---- buffer.o: buffer.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h charset.o: charset.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ ! term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h farsi.h cmdcmds.o: cmdcmds.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h cmdline.o: cmdline.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h cmdtab.h \ ! ops.h farsi.h csearch.o: csearch.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h digraph.o: digraph.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h edit.o: edit.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ ! macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h farsi.h fileio.o: fileio.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h getchar.o: getchar.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ *************** *** 932,938 **** misccmds.o: misccmds.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h normal.o: normal.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ ! macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h ops.o: ops.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h option.o: option.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ --- 932,938 ---- misccmds.o: misccmds.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h \ term.h macros.h structs.h gui.h globals.h proto.h regexp.h option.h normal.o: normal.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ ! macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h farsi.h ops.o: ops.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h option.o: option.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ *************** *** 948,954 **** screen.o: screen.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h search.o: search.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ ! macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h tables.o: tables.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h tag.o: tag.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ --- 948,954 ---- screen.o: screen.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h search.o: search.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ ! macros.h structs.h gui.h globals.h proto.h regexp.h option.h ops.h farsi.h tables.o: tables.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ macros.h structs.h gui.h globals.h proto.h regexp.h option.h tag.o: tag.c vim.h config.h feature.h unix.h osdef.h ascii.h keymap.h term.h \ diff -rcN vim-4.5/src/charset.c vim-4.5.farsi/src/charset.c *** vim-4.5/src/charset.c Sun Jun 9 20:35:01 1996 --- vim-4.5.farsi/src/charset.c Tue Feb 2 16:11:15 1993 *************** *** 11,16 **** --- 11,20 ---- #include "proto.h" #include "option.h" + #ifdef FKMAP + #include "farsi.h" + #endif + /* * chartab[] is used * - to quickly recognize ID characters *************** *** 54,59 **** --- 58,70 ---- chartab[c++] = 2; while (c <= '~') chartab[c++] = 1; + #ifdef FKMAP + if (p_altkeymap) + { + while (c < YE) + chartab[c++] = 1; + } + #endif while (c < 256) chartab[c++] = 2; *************** *** 129,136 **** --- 140,155 ---- } while (c <= c2) { + #ifdef FKMAP + if (p_altkeymap) + if (!do_isalpha || isalpha(c) || isFalpha(c) || isFdigit(c)) + goto fkmark_1; + #endif if (!do_isalpha || isalpha(c)) { + #ifdef FKMAP + fkmark_1: + #endif if (i == 0) /* (re)set ID flag */ { if (tilde) *************** *** 140,146 **** --- 159,173 ---- } else if (i == 1) /* set printable to 1 or 2 */ { + #ifdef FKMAP + if (p_altkeymap) + if (c < ' ' || c > '~' || isFalpha(c)|| isFdigit(c)) + goto fkmark_2; + #endif if (c < ' ' || c > '~') + #ifdef FKMAP + fkmark_2: + #endif chartab[c] = (chartab[c] & ~CHAR_MASK) + (tilde ? 2 : 1); } *************** *** 216,224 **** --- 243,262 ---- i = 2; c = K_SECOND(c); } + + #ifdef FKMAP + if (p_altkeymap) + if ((!chartab_initialized && c >= ' ' && c <= '~') || + (!chartab_initialized && isFchar(c) ) || + (chartab[c] & CHAR_MASK) == 1) /* printable character */ + goto fkmark_3; + #endif if ((!chartab_initialized && c >= ' ' && c <= '~') || (chartab[c] & CHAR_MASK) == 1) /* printable character */ { + #ifdef FKMAP + fkmark_3: + #endif buf[i] = c; buf[i + 1] = NUL; } *************** *** 547,549 **** --- 585,621 ---- *cursor = vcol + head; /* cursor at start */ } } + + #ifdef FKMAP + /* + * isFalpha returns TRUE if 'c' is a Farsi alphabet + */ + int + isFalpha(c) + int c; + { + return (( c >= TEE_ && c <= _YE) || + ( c >= ALEF_A && c <= YE) || + ( c >= _IE && c <= YE_)); + } + + /* + * isFdigit returns TRUE if 'c' is a Farsi digit + */ + int + isFdigit(c) + int c; + { + return (( c >= FARSI_0 && c <= FARSI_9 )); + } + + /* + * isFchar returns TRUE if 'c' is a Farsi character. + */ + int + isFchar(c) + int c; + { + return (( c >= TEE_ && c <= YE_)); + } + #endif diff -rcN vim-4.5/src/cmdline.c vim-4.5.farsi/src/cmdline.c *** vim-4.5/src/cmdline.c Thu Oct 3 19:19:04 1996 --- vim-4.5.farsi/src/cmdline.c Tue Feb 2 16:11:24 1993 *************** *** 50,55 **** --- 50,58 ---- #ifdef RIGHTLEFT static int cmd_hkmap = 0; /* Hebrew mapping during command line */ + #ifdef FKMAP + static int cmd_fkmap = 0; /* Farsi mapping during command line */ + #endif #endif static void init_history __ARGS((void)); *************** *** 80,85 **** --- 83,89 ---- static int ExpandFromContext __ARGS((char_u *, int *, char_u ***, int, int)); static int ExpandCommands __ARGS((regexp *, int *, char_u ***)); + /* * init_history() - initialize the command line history */ *************** *** 296,301 **** --- 300,309 ---- #ifdef RIGHTLEFT if (cmd_hkmap) c = hkmap(c); + #ifdef FKMAP + if (cmd_fkmap) /* If Farsi keymap mode is set */ + c = cmdl_fkmap(c); + #endif #endif } *************** *** 370,375 **** --- 378,388 ---- case Ctrl('H'): case K_DEL: case Ctrl('W'): + #ifdef FKMAP + if (cmd_fkmap) + if (c == K_BS) + c = K_DEL; + #endif /* * delete current character is the same as backspace on next * character, except at end of line *************** *** 408,413 **** --- 421,433 ---- goto cmdline_changed; case K_INS: + #ifdef FKMAP + /* if Farsi mode set, we are in reverse insert mode - + Do not change the mode */ + if (cmd_fkmap) + beep_flush(); + else + #endif overstrike = !overstrike; /* should change shape of cursor */ goto cmdline_not_changed; *************** *** 469,474 **** --- 489,501 ---- while (c == K_S_LEFT && cmdbuff[cmdpos - 1] != ' '); goto cmdline_not_changed; + #ifdef FKMAP + #ifndef USE_MOUSE + case K_IGNORE: /* Ignore entered Farsi key */ + goto cmdline_not_changed; + #endif + #endif + #ifdef USE_MOUSE case K_MIDDLEDRAG: case K_MIDDLERELEASE: *************** *** 702,707 **** --- 729,744 ---- #ifdef RIGHTLEFT case Ctrl('_'): /* CTRL-_: switch language mode */ + + #ifdef FKMAP + if (p_altkeymap) + { + cmd_fkmap = !cmd_fkmap; + if(cmd_fkmap) + overstrike = FALSE; /* in Farsi always in insert mode */ + } + else /* Hebrew is default */ + #endif cmd_hkmap = !cmd_hkmap; goto cmdline_not_changed; #endif *************** *** 869,877 **** --- 906,926 ---- vim_memmove(cmdbuff + cmdpos, str, (size_t)len); if (redraw) msg_outtrans_len(cmdbuff + cmdpos, cmdlen - cmdpos); + + #ifdef FKMAP + /* + ** If we are in Farsi command mode, the character input must be in + ** insert mode. So do not advance the cmdpos. + */ + if (!cmd_fkmap) + { + #endif cmdpos += len; while (len--) cmdspos += charsize(str[len]); + #ifdef FKMAP + } + #endif } if (redraw) msg_check(); *************** *** 5542,5544 **** --- 5591,6414 ---- } } #endif /* VIMINFO */ + + #ifdef FKMAP + #include "farsi.h" + + /* + ** Convert a none leading Farsi char into a leading type. + */ + int + toF_leading(c) + 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; + case KAF: return _KAF; + case GAF: return _GAF; + case LAM: return _LAM; + case MIM: return _MIM; + case NOON: return _NOON; + + case _HE_: + case HE: return _HE; + + case YE: + case YE_: return _YE; + + case IE_: + case IE: return _IE; + + case YEE: + case YEE_: return _YEE; + } + return c; + } + + /* + ** Convert a given Farsi char into right joining type. + */ + int + toF_Rjoin(c) + 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; + case KAF: return _KAF; + case GAF: return _GAF; + case LAM: return _LAM; + case MIM: return _MIM; + case NOON: return _NOON; + + case _HE: + case HE: return _HE_; + + case YE: + case YE_: return _YE; + + case IE_: + case IE: return _IE; + + case TEE: return TEE_; + + case YEE: + case YEE_: return _YEE; + } + return c; + } + + /* + ** Can a given Farsi character join via its left edj. + */ + int + canF_Ljoin(c) + int c ; + { + switch(c) { + case _BE: + case BE: + case PE: + case _PE: + case TE: + case _TE: + case SE: + case _SE: + case JIM: + case _JIM: + case CHE: + case _CHE: + case HE_J: + case _HE_J: + case XE: + case _XE: + case SIN: + case _SIN: + case SHIN: + case _SHIN: + case SAD: + case _SAD: + case ZAD: + case _ZAD: + case _TA: + case _ZA: + case AYN: + case _AYN: + case _AYN_: + case AYN_: + case GHAYN: + case GHAYN_: + case _GHAYN_: + case _GHAYN: + case FE: + case _FE: + case GHAF: + case _GHAF: + case _KAF_H: + case KAF: + case _KAF: + case GAF: + case _GAF: + case LAM: + case _LAM: + case MIM: + case _MIM: + case NOON: + case _NOON: + case IE: + case _IE: + case IE_: + case YE: + case _YE: + case YE_: + case YEE: + case _YEE: + case YEE_: + case HE: + case _HE: + case _HE_: + return TRUE; + } + return FALSE; + } + + /* + ** Can a given Farsi character join via its right edj. + */ + int + canF_Rjoin(c) + int c ; + { + switch(c) + { + case ALEF: + case ALEF_: + case ALEF_U_H: + case ALEF_U_H_: + case DAL: + case ZAL: + case RE: + case JE: + case ZE: + case TEE: + case TEE_: + case WAW: + case WAW_H: + return TRUE; + } + + return canF_Ljoin(c); + + } + + /* + ** is a given Farsi character a terminating type. + */ + int + isF_term(c) + int c ; + { + switch(c) + { + case ALEF: + case ALEF_: + case ALEF_U_H: + case ALEF_U_H_: + case DAL: + case ZAL: + case RE: + case JE: + case ZE: + case WAW: + case WAW_H: + case TEE: + case TEE_: + return TRUE; + } + + return FALSE; + } + + /* + ** Convert the given Farsi character into a ending type . + */ + int + toF_ending(c) + 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 HE; + } + return c; + } + + /* + ** Convert the Farsi 3342 standard into Farsi VIM. + */ + void + conv_to_pvim() + { + char_u *ptr; + int lnum, llen, i; + + for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) + { + ptr = ml_get(lnum); + + llen = STRLEN(ptr); + + for ( i = 0; i < llen-1; i++) + { + if (canF_Ljoin(ptr[i]) && canF_Rjoin(ptr[i+1])) + { + ptr[i] = toF_leading(ptr[i]); + ++i; + + while(canF_Rjoin(ptr[i]) && (i < llen)) + { + ptr[i] = toF_Rjoin(ptr[i]); + if (isF_term(ptr[i]) || !isFalpha(ptr[i])) + break; + ++i; + } + if (!isFalpha(ptr[i]) || !canF_Rjoin(ptr[i])) + ptr[i-1] = toF_ending(ptr[i-1]); + } + else + ptr[i] = toF_TyA(ptr[i]); + } + } + + /* + ** Following lines contains Farsi encoded character. + */ + + do_cmdline("%s///g", FALSE, FALSE); + do_cmdline("%s///g", FALSE, FALSE); + + updateScreen(CLEAR); + start_highlight(); + MSG("͂VIM͘ˠނ"); + stop_highlight(); + } + + /* + ** Convert the Farsi VIM into Farsi 3342 standad. + */ + void + conv_to_pstd() + { + char_u *ptr; + int lnum, llen, i; + + /* + ** Following line contains Farsi encoded character. + */ + + do_cmdline("%s///g", FALSE, FALSE); + + for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) + { + ptr = ml_get(lnum); + + llen = STRLEN(ptr); + + for ( i = 0; i < llen; i++) + { + ptr[i] = toF_TyA(ptr[i]); + + } + } + + updateScreen(CLEAR); + + /* + ** Following line contains Farsi encoded character. + */ + + start_highlight(); + MSG("͂˜͘ˠނ"); + stop_highlight(); + } + + /* + ** swap all the characters in reverse direction + */ + char_u + *lrswap(ibuf) + char_u *ibuf; + { + char_u *tmpbuf; + int i,j,len; + + if (ibuf == NULL) + return ibuf; + + len=j=STRLEN(ibuf); + + if (!len || (tmpbuf = (char_u *)malloc(len+1)) == NULL) + return ibuf; + + STRCPY(tmpbuf, ibuf); + + i=0; + while (len) + ibuf[i++]=tmpbuf[--len]; + + free(tmpbuf); + return ibuf; + } + + /* + ** swap all the Farsi characters in reverse direction + */ + + char_u + *lrFswap(cmdbuf, len) + char_u *cmdbuf; + int len; + { + char_u *tmpbuf; + int i,cnt; + + if (cmdbuf == NULL) + return cmdbuf; + + if (!len) + len=STRLEN(cmdbuf); + + if (!len || (tmpbuf = (char_u *)malloc(len)) == NULL) + return cmdbuf; + + for ( i=0; i= cmdlen || cmdpos+offset < 0) + { + EMSG("cmd_pchar beyond the command length"); + return ; + } + + cmdbuff[cmdpos+offset]=(char_u)c; + } + + int + cmd_gchar(offset) + int offset; + { + if (cmdpos+offset >= cmdlen || cmdpos+offset < 0) + { + /* EMSG("cmd_gchar beyond the command length"); */ + return NUL; + } + + return (int)cmdbuff[cmdpos+offset]; + } + + /* + * Map Farsi keyboard when in cmd_fkmap mode. + */ + int + cmdl_fkmap(c) + int c; + { + int tempc; + + switch(c) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '`': + case ' ': + case '.': + case '!': + case '"': + case '$': + case '%': + case '^': + case '&': + case '/': + case '(': + case ')': + case '=': + case '\\': + case '?': + case '+': + case '-': + case '_': + case '*': + case ':': + case '#': + case '~': + case '@': + case '<': + case '>': + case '{': + case '}': + case '|': + case 'B': + case 'E': + case 'F': + case 'H': + case 'I': + case 'K': + case 'L': + case 'M': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'T': + case 'U': + case 'W': + case 'Y': + case NL: + case TAB: + + switch((tempc = cmd_gchar(AT_CURSOR))) { + case _BE: + case _PE: + case _TE: + case _SE: + case _JIM: + case _CHE: + case _HE_J: + case _XE: + case _SIN: + case _SHIN: + case _SAD: + case _ZAD: + case _AYN: + case _GHAYN: + case _FE: + case _GHAF: + case _KAF: + case _GAF: + case _LAM: + case _MIM: + case _NOON: + case _HE: + case _HE_: + cmd_pchar(toF_TyA(tempc), AT_CURSOR); + break; + case _AYN_: + cmd_pchar(AYN_, AT_CURSOR); + break; + case _GHAYN_: + cmd_pchar(GHAYN_, AT_CURSOR); + break; + case _IE: + if (isF_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1)) + cmd_pchar(IE_, AT_CURSOR); + else + cmd_pchar(IE, AT_CURSOR); + break; + case _YEE: + if (isF_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1)) + cmd_pchar(YEE_, AT_CURSOR); + else + cmd_pchar(YEE, AT_CURSOR); + break; + case _YE: + if (isF_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1)) + cmd_pchar(YE_, AT_CURSOR); + else + cmd_pchar(YE, AT_CURSOR); + } + + switch(c) + { + case '0': return FARSI_0; + case '1': return FARSI_1; + case '2': return FARSI_2; + case '3': return FARSI_3; + case '4': return FARSI_4; + case '5': return FARSI_5; + case '6': return FARSI_6; + case '7': return FARSI_7; + case '8': return FARSI_8; + case '9': return FARSI_9; + case 'B': return F_PSP; + case 'E': return JAZR_N; + case 'F': return ALEF_D_H; + case 'H': return ALEF_A; + case 'I': return TASH; + case 'K': return F_LQUOT; + case 'L': return F_RQUOT; + case 'M': return HAMZE; + case 'O': return '['; + case 'P': return ']'; + case 'Q': return OO; + case 'R': return MAD_N; + case 'T': return OW; + case 'U': return MAD; + case 'W': return OW_OW; + case 'Y': return JAZR; + case '`': return F_PCN; + case '!': return F_EXCL; + case '@': return F_COMMA; + case '#': return F_DIVIDE; + case '$': return F_CURRENCY; + case '%': return F_PERCENT; + case '^': return F_MUL; + case '&': return F_BCOMMA; + case '*': return F_STAR; + case '(': return F_LPARENT; + case ')': return F_RPARENT; + case '-': return F_MINUS; + case '_': return F_UNDERLINE; + case '=': return F_EQUALS; + case '+': return F_PLUS; + case '\\': return F_BSLASH; + case '|': return F_PIPE; + case ':': return F_DCOLON; + case '"': return F_SEMICOLON; + case '.': return F_PERIOD; + case '/': return F_SLASH; + case '<': return F_LESS; + case '>': return F_GREATER; + case '?': return F_QUESTION; + case ' ': return F_BLANK; + } + + break; + + case 'a': return _SHIN; + case 'A': return WAW_H; + case 'b': return ZAL; + case 'c': return ZE; + case 'C': return JE; + case 'd': return _YE; + case 'D': return _YEE; + case 'e': return _SE; + 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; + } + + if (isF_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) + return ALEF_U_H_; + else + return ALEF_U_H; + case 'h': + if (cmd_gchar(AT_CURSOR) == _LAM ) + { + cmd_pchar(LA, AT_CURSOR); + redrawcmd(); + return K_IGNORE; + } + + if (isF_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) + return ALEF_; + else + return ALEF; + case 'i': + if (isF_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) + return _HE_; + else + return _HE; + case 'j': return _TE; + case 'J': + if (isF_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) + return TEE_; + else + return TEE; + case 'k': return _NOON; + case 'l': return _MIM; + case 'm': return _PE; + case 'n': + case 'N': return DAL; + case 'o': return _XE; + case 'p': return _HE_J; + case 'q': return _ZAD; + case 'r': return _GHAF; + case 's': return _SIN; + case 'S': return _IE; + case 't': return _FE; + case 'u': + if (isF_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) + return _AYN_; + else + return _AYN; + case 'v': + case 'V': return RE; + case 'w': return _SAD; + case 'x': + case 'X': return _TA; + case 'y': + if (isF_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) + return _GHAYN_; + else + return _GHAYN; + case 'z': + case 'Z': return _ZA; + case ';': return _KAF; + case '\'': return _GAF; + case ',': return WAW; + case '[': return _JIM; + case ']': return _CHE; + } + + return c; + } + #endif + diff -rcN vim-4.5/src/csearch.c vim-4.5.farsi/src/csearch.c *** vim-4.5/src/csearch.c Sat Sep 7 14:58:22 1996 --- vim-4.5.farsi/src/csearch.c Tue Feb 2 16:02:14 1993 *************** *** 78,83 **** --- 78,89 ---- sub_nsubs = 0; sub_nlines = 0; } + #ifdef FKMAP /* reverse the flow of the Farsi characters */ + if (p_altkeymap && curwin->w_p_rl) + { + lrF_sub(cmd); + } + #endif if (use_old == 2) which_pat = RE_LAST; /* use last used regexp */ *************** *** 593,598 **** --- 599,610 ---- *cmd++ = NUL; /* replace it with a NUL */ } + #ifdef FKMAP /* when in Farsi mode, reverse the character flow */ + if (p_altkeymap && curwin->w_p_rl) + { + lrFswap(pat,0); + } + #endif if ((prog = myregcomp(pat, RE_BOTH, which_pat, SEARCH_HIS)) == NULL) { emsg(e_invcmd); diff -rcN vim-4.5/src/edit.c vim-4.5.farsi/src/edit.c *** vim-4.5/src/edit.c Thu Oct 3 19:32:24 1996 --- vim-4.5.farsi/src/edit.c Tue Feb 2 16:11:38 1993 *************** *** 16,21 **** --- 16,25 ---- #include "option.h" #include "ops.h" /* for op_type */ + #ifdef FKMAP + #include "farsi.h" + #endif + #ifdef INSERT_EXPAND /* * definitions used for CTRL-X submode *************** *** 161,166 **** --- 165,182 ---- } if (initstr == 'R') + #ifdef FKMAP + if (p_fkmap && p_ri) + { + beep_flush(); + /* + ** Following sentence is encoded in Farsi + */ + EMSG("ߌ REPLACE ނ͕ REVERSE INSERT ͂͠ˠ݂͂"); + State = INSERT; + } + else + #endif State = REPLACE; else State = INSERT; *************** *** 314,319 **** --- 330,339 ---- #ifdef RIGHTLEFT if (p_hkmap && KeyTyped) c = hkmap(c); /* Hebrew mode mapping */ + #ifdef FKMAP + if (p_fkmap && KeyTyped) + c = fkmap(c); /* Farsi mode mapping */ + #endif #endif #ifdef INSERT_EXPAND *************** *** 519,524 **** --- 539,556 ---- if (State == REPLACE) State = INSERT; else + #ifdef FKMAP + if (p_fkmap && p_ri) + { + beep_flush(); + /* + ** Following sentence is encoded in Farsi + */ + EMSG("ߌ REPLACE ނ͕ REVERSE INSERT ͂͠ˠ݂͂"); + State = INSERT; + } + else + #endif State = REPLACE; AppendCharToRedobuff(K_INS); showmode(); *************** *** 662,667 **** --- 694,710 ---- #ifdef RIGHTLEFT case Ctrl('B'): /* toggle reverse insert mode */ + #ifdef FKMAP + if (p_fkmap && KeyTyped) + { + beep_flush(); + /* + ** Following sentence is encoded in Farsi + */ + EMSG("ߌ ނ͕ ͂ˠ݂͂"); + break; + } + #endif p_ri = !p_ri; revins = (State == INSERT && p_ri); if (revins) *************** *** 685,690 **** --- 728,749 ---- } else revinsscol = -1; + #ifdef FKMAP + if (p_altkeymap) + { + /* + ** to be consistent also for redo command, using '.' + ** set arrow_used to true and stop it - causing to redo + ** characters entered in one mode (normal/reverse insert). + */ + arrow_used = TRUE; + stop_arrow(); + p_fkmap = curwin->w_p_rl ^ p_ri; + if (p_fkmap && p_ri) + State = INSERT; + } + else + #endif p_hkmap = curwin->w_p_rl ^ p_ri; /* be consistent! */ showmode(); break; *************** *** 1250,1255 **** --- 1309,1318 ---- if (State == REPLACE) replace_push(NUL); #ifdef RIGHTLEFT + #ifdef FKMAP + if (p_altkeymap && p_fkmap) + fkmap(NL); + #endif /* NL in reverse insert will allways start in the end of * current line. */ if (revins) *************** *** 2785,2790 **** --- 2848,2857 ---- c = vgetc(); if (p_hkmap && KeyTyped) c = hkmap(c); /* Hebrew mode mapping */ + #ifdef FKMAP + if (p_fkmap && KeyTyped) + c = fkmap(c); /* Farsi mode mapping */ + #endif p[i++] = c; #else p[i++] = vgetc(); *************** *** 3629,3633 **** --- 3696,5146 ---- } return c - 'a' + p_aleph; + } + #endif + + #ifdef FKMAP + + /* + ** Convert the given Farsi character into a _X or _X_ type + */ + int + toF_Xor_X_(c) + int c ; + { + int tempc; + + 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 HE: + tempc = _HE; + + if (p_ri && (curwin->w_cursor.col+1 < STRLEN(ml_get_curline()))) + { + inc_cursor(); + + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = _HE_; + + dec_cursor(); + } + if (!p_ri && STRLEN(ml_get_curline())) + { + dec_cursor(); + + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = _HE_; + + inc_cursor(); + } + + return tempc; + } + return 0; + } + + /* + ** Convert the given Farsi character into Farsi capital character . + */ + int + toF_TyA(c) + 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 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. + */ + int + isF_TyB_TyC_TyD(src, offset) + int src, offset ; + { + int c ; + + if ( src == SRC_EDT) + c = gchar_cursor(); + else + c = cmd_gchar(AT_CURSOR+offset); + + switch(c) { + case _LAM: + case _BE: + case _PE: + case _TE: + case _SE: + case _JIM: + case _CHE: + case _HE_J: + case _XE: + case _SIN: + case _SHIN: + case _SAD: + case _ZAD: + case _TA: + case _ZA: + case _AYN: + case _AYN_: + case _GHAYN: + case _GHAYN_: + case _FE: + case _GHAF: + case _KAF: + case _KAF_H: + case _GAF: + case _MIM: + case _NOON: + case _YE: + case _YEE: + case _IE: + case _HE_: + case _HE: + return TRUE; + } + return FALSE; + } + + /* + ** Is the Farsi character one of the terminating only type. + */ + int + isF_TyE(c) + int c ; + { + switch(c) { + case ALEF_A: + case ALEF_D_H: + case DAL: + case ZAL: + case RE: + case ZE: + case JE: + case WAW: + case WAW_H: + case HAMZE: + return TRUE; + } + return FALSE; + } + + /* + ** Is the Farsi character one of the none leading type. + */ + int + isF_TyC_TyD(c) + int c ; + { + switch(c) { + case ALEF_: + case ALEF_U_H_: + case _AYN_: + case AYN_: + case _GHAYN_: + case GHAYN_: + case _HE_: + case YE_: + case IE_: + case TEE_: + case YEE_: + return TRUE; + } + return FALSE; + } + + /* + ** Convert a none leading Farsi char into a leading type. + */ + int + toF_TyB(c) + int c ; + { + 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; + case GHAYN_: return GHAYN; /* exception - there are many of them */ + case _HE_: return _HE; + case YE_: return YE; + case IE_: return IE; + case TEE_: return TEE; + case YEE_: return YEE; + } + return c; + } + + /* + ** Overwrite the current redo and cursor characters + left adjust + */ + + void + put_curr_and_l_to_X(c) + int c; + { + int tempc; + + if (curwin->w_p_rl && p_ri) + return; + + if ( (curwin->w_cursor.col < STRLEN(ml_get_curline()))) + { + if ((p_ri && curwin->w_cursor.col) || !p_ri) + { + if (p_ri) + dec_cursor(); + else + inc_cursor(); + + if (isF_TyC_TyD((tempc = gchar_cursor()))) + { + pchar_cursor(toF_TyB(tempc)); + AppendCharToRedobuff(K_BS); + AppendCharToRedobuff(tempc); + } + + if (p_ri) + inc_cursor(); + else + dec_cursor(); + } + } + + pchar_cursor(c); + AppendCharToRedobuff(K_BS); + AppendCharToRedobuff(c); + } + + /* + ** Change the char. under the cursor to a X_ or X type + */ + + void + chg_c_toX_orX () + { + int tempc, curc; + + switch((curc = gchar_cursor())) { + case _BE: + tempc = BE; + break; + case _PE: + tempc = PE; + break; + case _TE: + tempc = TE; + break; + case _SE: + tempc = SE; + break; + case _JIM: + tempc = JIM; + break; + case _CHE: + tempc = CHE; + break; + case _HE_J: + tempc = HE_J; + break; + case _XE: + tempc = XE; + break; + case _SIN: + tempc = SIN; + break; + case _SHIN: + tempc = SHIN; + break; + case _SAD: + tempc = SAD; + break; + case _ZAD: + tempc = ZAD; + break; + case _FE: + tempc = FE; + break; + case _GHAF: + tempc = GHAF; + break; + case _KAF_H: + case _KAF: + tempc = KAF; + break; + case _GAF: + tempc = GAF; + break; + case _AYN: + tempc = AYN; + break; + case _AYN_: + tempc = AYN_; + break; + case _GHAYN: + tempc = GHAYN; + break; + case _GHAYN_: + tempc = GHAYN_; + break; + case _LAM: + tempc = LAM; + break; + case _MIM: + tempc = MIM; + break; + case _NOON: + tempc = NOON; + break; + case _HE: + case _HE_: + tempc = HE; + break; + case _YE: + case _IE: + case _YEE: + if (p_ri) + { + inc_cursor(); + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = (curc == _YE ? YE_ : + (curc == _IE ? IE_ : YEE_)); + else + tempc = (curc == _YE ? YE : + (curc == _IE ? IE : YEE)); + dec_cursor(); + } + else + { + if (curwin->w_cursor.col) + { + dec_cursor(); + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = (curc == _YE ? YE_ : + (curc == _IE ? IE_ : YEE_)); + else + tempc = (curc == _YE ? YE : + (curc == _IE ? IE : YEE)); + inc_cursor(); + } + else + tempc = (curc == _YE ? YE : + (curc == _IE ? IE : YEE)); + } + break; + default: + tempc = 0; + } + + if ( tempc ) + { + pchar_cursor(tempc); + AppendCharToRedobuff(K_BS); + AppendCharToRedobuff(tempc); + } + } + + /* + ** Change the char. under the cursor to a _X_ or X_ type + */ + + void + chg_c_to_X_orX_ () + { + int tempc; + + switch(gchar_cursor()) { + case ALEF: + tempc = ALEF_; + break; + case ALEF_U_H: + tempc = ALEF_U_H_; + break; + case _AYN: + tempc = _AYN_; + break; + case AYN: + tempc = AYN_; + break; + case _GHAYN: + tempc = _GHAYN_; + break; + case GHAYN: + tempc = GHAYN_; + break; + case _HE: + tempc = _HE_; + break; + case YE: + tempc = YE_; + break; + case IE: + tempc = IE_; + break; + case TEE: + tempc = TEE_; + break; + case YEE: + tempc = YEE_; + break; + default: + tempc = 0; + } + + if ( tempc ) + { + pchar_cursor(tempc); + AppendCharToRedobuff(K_BS); + AppendCharToRedobuff(tempc); + } + + } + + /* + ** Change the char. under the cursor to a _X_ or _X type + */ + void + chg_c_to_X_or_X () + { + int tempc; + + tempc = gchar_cursor(); + + if (curwin->w_cursor.col+1 < STRLEN(ml_get_curline())) + { + inc_cursor(); + + if ((tempc == HE) && (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))) + { + tempc = _HE_; + + dec_cursor(); + + pchar_cursor(tempc); + AppendCharToRedobuff(K_BS); + AppendCharToRedobuff(tempc); + return; + } + + dec_cursor(); + } + + if ((tempc = toF_Xor_X_(tempc))) + { + pchar_cursor(tempc); + AppendCharToRedobuff(K_BS); + AppendCharToRedobuff(tempc); + } + } + + /* + ** Change the charcter left to the cursor to a _X_ or X_ type + */ + + void + chg_l_to_X_orX_ () + { + int tempc; + + if (!curwin->w_cursor.col && + (curwin->w_cursor.col+1 == STRLEN(ml_get_curline()))) + return; + + if (!curwin->w_cursor.col && p_ri) + return; + + if (p_ri) + dec_cursor(); + else + inc_cursor(); + + switch(gchar_cursor()) { + case ALEF: + tempc = ALEF_; + break; + case ALEF_U_H: + tempc = ALEF_U_H_; + break; + case _AYN: + tempc = _AYN_; + break; + case AYN: + tempc = AYN_; + break; + case _GHAYN: + tempc = _GHAYN_; + break; + case GHAYN: + tempc = GHAYN_; + break; + case _HE: + tempc = _HE_; + break; + case YE: + tempc = YE_; + break; + case IE: + tempc = IE_; + break; + case TEE: + tempc = TEE_; + break; + case YEE: + tempc = YEE_; + break; + default: + tempc = 0; + } + + if ( tempc ) + { + pchar_cursor(tempc); + AppendCharToRedobuff(K_BS); + AppendCharToRedobuff(tempc); + } + + if (p_ri) + inc_cursor(); + else + dec_cursor(); + } + + /* + ** Change the charcter left to the cursor to a X or _X type + */ + + void + chg_l_toXor_X () + { + int tempc; + + if (!curwin->w_cursor.col && + (curwin->w_cursor.col+1 == STRLEN(ml_get_curline()))) + return; + + if (!curwin->w_cursor.col && p_ri) + return; + + if (p_ri) + dec_cursor(); + else + inc_cursor(); + + switch(gchar_cursor()) { + case ALEF_: + tempc = ALEF; + break; + case ALEF_U_H_: + tempc = ALEF_U_H; + break; + case _AYN_: + tempc = _AYN; + break; + case AYN_: + tempc = AYN; + break; + case _GHAYN_: + tempc = _GHAYN; + break; + case GHAYN_: + tempc = GHAYN; + break; + case _HE_: + tempc = _HE; + break; + case YE_: + tempc = YE; + break; + case IE_: + tempc = IE; + break; + case TEE_: + tempc = TEE; + break; + case YEE_: + tempc = YEE; + break; + default: + tempc = 0; + } + + if ( tempc ) + { + pchar_cursor(tempc); + AppendCharToRedobuff(K_BS); + AppendCharToRedobuff(tempc); + } + + if (p_ri) + inc_cursor(); + else + dec_cursor(); + } + + /* + ** Change the charcter right to the cursor to a _X or _X_ type + */ + + void + chg_r_to_Xor_X_() + { + int tempc, c; + + if (curwin->w_cursor.col) + { + if (!p_ri) + dec_cursor(); + + tempc = gchar_cursor(); + + if ((c = toF_Xor_X_(tempc))) + { + pchar_cursor(c); + AppendCharToRedobuff(K_BS); + AppendCharToRedobuff(c); + } + + if (!p_ri) + inc_cursor(); + + } + } + + /* + ** Map Farsi keyboard when in fkmap mode. + */ + + int + fkmap(c) + int c; + { + int tempc; + static int revins; + + cursupdate(); + + if (isdigit(c) || ((c == '.' || c == '+' || c == '-' || + c == '^' || c == '%' || c == '#' || c == '=') && revins)) + { + if (!revins) + { + if (curwin->w_cursor.col) + { + if (!p_ri) + dec_cursor(); + + chg_c_toX_orX (); + chg_l_toXor_X (); + + if (!p_ri) + inc_cursor(); + } + } + + arrow_used = TRUE; + stop_arrow(); + + if (!curwin->w_p_rl && revins) + inc_cursor(); + + ++revins; + p_ri=1; + } + else + { + if (revins) + { + arrow_used = TRUE; + stop_arrow(); + + revins=0; + tempc = gchar_cursor(); + if (curwin->w_p_rl) + { + while ((isFdigit(gchar_cursor()) || + (gchar_cursor() == F_PERIOD || + gchar_cursor() == F_PLUS || + gchar_cursor() == F_MINUS || + gchar_cursor() == F_MUL || + gchar_cursor() == F_DIVIDE || + gchar_cursor() == F_PERCENT || + gchar_cursor() == F_EQUALS)) && gchar_cursor()!= NUL) + ++curwin->w_cursor.col; + } + else + { + if (curwin->w_cursor.col) + while ((isFdigit(gchar_cursor()) || + (gchar_cursor() == F_PERIOD || + gchar_cursor() == F_PLUS || + gchar_cursor() == F_MINUS || + gchar_cursor() == F_MUL || + gchar_cursor() == F_DIVIDE || + gchar_cursor() == F_PERCENT || + gchar_cursor() == F_EQUALS)) && --curwin->w_cursor.col); + + if (!isFdigit(gchar_cursor())) + ++curwin->w_cursor.col; + } + } + } + + if (!revins) + { + if (curwin->w_p_rl) + p_ri=0; + if (!curwin->w_p_rl) + p_ri=1; + } + + if ((c < 0x100) && (isalpha(c) || c == '&' || c == '^' || c == ';' || + c == '\''|| c == ',' || c == '[' || + c == ']' || c == '{' || c == '}' )) + chg_r_to_Xor_X_(); + + tempc = 0; + + switch(c) { + case '`': + case ' ': + case '.': + case '!': + case '"': + case '$': + case '%': + case '^': + case '&': + case '/': + case '(': + case ')': + case '=': + case '\\': + case '?': + case '+': + case '-': + case '_': + case '*': + case ':': + case '#': + case '~': + case '@': + case '<': + case '>': + case '{': + case '}': + case '|': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'B': + case 'E': + case 'F': + case 'H': + case 'I': + case 'K': + case 'L': + case 'M': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'T': + case 'U': + case 'W': + case 'Y': + case NL: + case TAB: + + 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(); + + if (isFalpha(gchar_cursor())) + { + inc_cursor(); + return NL; + } + + inc_cursor(); + } + + if (!p_ri) + if (!curwin->w_cursor.col) + { + switch(c) + { + case '0': return FARSI_0; + case '1': return FARSI_1; + case '2': return FARSI_2; + case '3': return FARSI_3; + case '4': return FARSI_4; + case '5': return FARSI_5; + case '6': return FARSI_6; + case '7': return FARSI_7; + case '8': return FARSI_8; + case '9': return FARSI_9; + case 'B': return F_PSP; + case 'E': return JAZR_N; + case 'F': return ALEF_D_H; + case 'H': return ALEF_A; + case 'I': return TASH; + case 'K': return F_LQUOT; + case 'L': return F_RQUOT; + case 'M': return HAMZE; + case 'O': return '['; + case 'P': return ']'; + case 'Q': return OO; + case 'R': return MAD_N; + case 'T': return OW; + case 'U': return MAD; + case 'W': return OW_OW; + case 'Y': return JAZR; + case '`': return F_PCN; + case '!': return F_EXCL; + case '@': return F_COMMA; + case '#': return F_DIVIDE; + case '$': return F_CURRENCY; + case '%': return F_PERCENT; + case '^': return F_MUL; + case '&': return F_BCOMMA; + case '*': return F_STAR; + case '(': return F_LPARENT; + case ')': return F_RPARENT; + case '-': return F_MINUS; + case '_': return F_UNDERLINE; + case '=': return F_EQUALS; + case '+': return F_PLUS; + case '\\': return F_BSLASH; + case '|': return F_PIPE; + case ':': return F_DCOLON; + case '"': return F_SEMICOLON; + case '.': return F_PERIOD; + case '/': return F_SLASH; + case '<': return F_LESS; + case '>': return F_GREATER; + case '?': return F_QUESTION; + case ' ': return F_BLANK; + } + break; + } + if (!p_ri) + dec_cursor(); + + switch((tempc = gchar_cursor())) { + case _BE: + case _PE: + case _TE: + case _SE: + case _JIM: + case _CHE: + case _HE_J: + case _XE: + case _SIN: + case _SHIN: + case _SAD: + case _ZAD: + case _FE: + case _GHAF: + case _KAF: + case _KAF_H: + case _GAF: + case _LAM: + case _MIM: + case _NOON: + case _HE: + case _HE_: + case _TA: + case _ZA: + put_curr_and_l_to_X(toF_TyA(tempc)); + break; + case _AYN: + case _AYN_: + + if (!p_ri) + if (!curwin->w_cursor.col) + { + put_curr_and_l_to_X(AYN); + break; + } + + if (p_ri) + inc_cursor(); + else + dec_cursor(); + + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = AYN_; + else + tempc = AYN; + + if (p_ri) + dec_cursor(); + else + inc_cursor(); + + put_curr_and_l_to_X(tempc); + + break; + case _GHAYN: + case _GHAYN_: + + if (!p_ri) + if (!curwin->w_cursor.col) + { + put_curr_and_l_to_X(GHAYN); + break; + } + + if (p_ri) + inc_cursor(); + else + dec_cursor(); + + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = GHAYN_; + else + tempc = GHAYN; + + if (p_ri) + dec_cursor(); + else + inc_cursor(); + + put_curr_and_l_to_X(tempc); + break; + case _YE: + case _IE: + case _YEE: + if (!p_ri) + if (!curwin->w_cursor.col) + { + put_curr_and_l_to_X((tempc == _YE ? YE : + (tempc == _IE ? IE : YEE))); + break; + } + + if (p_ri) + inc_cursor(); + else + dec_cursor(); + + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = (tempc == _YE ? YE_ : + (tempc == _IE ? IE_ : YEE_)); + else + tempc = (tempc == _YE ? YE : + (tempc == _IE ? IE : YEE)); + + if (p_ri) + dec_cursor(); + else + inc_cursor(); + + put_curr_and_l_to_X(tempc); + break; + } + + if (!p_ri) + inc_cursor(); + + tempc = 0; + + switch(c) + { + case '0': return FARSI_0; + case '1': return FARSI_1; + case '2': return FARSI_2; + case '3': return FARSI_3; + case '4': return FARSI_4; + case '5': return FARSI_5; + case '6': return FARSI_6; + case '7': return FARSI_7; + case '8': return FARSI_8; + case '9': return FARSI_9; + case 'B': return F_PSP; + case 'E': return JAZR_N; + case 'F': return ALEF_D_H; + case 'H': return ALEF_A; + case 'I': return TASH; + case 'K': return F_LQUOT; + case 'L': return F_RQUOT; + case 'M': return HAMZE; + case 'O': return '['; + case 'P': return ']'; + case 'Q': return OO; + case 'R': return MAD_N; + case 'T': return OW; + case 'U': return MAD; + case 'W': return OW_OW; + case 'Y': return JAZR; + case '`': return F_PCN; + case '!': return F_EXCL; + case '@': return F_COMMA; + case '#': return F_DIVIDE; + case '$': return F_CURRENCY; + case '%': return F_PERCENT; + case '^': return F_MUL; + case '&': return F_BCOMMA; + case '*': return F_STAR; + case '(': return F_LPARENT; + case ')': return F_RPARENT; + case '-': return F_MINUS; + case '_': return F_UNDERLINE; + case '=': return F_EQUALS; + case '+': return F_PLUS; + case '\\': return F_BSLASH; + case '|': return F_PIPE; + case ':': return F_DCOLON; + case '"': return F_SEMICOLON; + case '.': return F_PERIOD; + case '/': return F_SLASH; + case '<': return F_LESS; + case '>': return F_GREATER; + case '?': return F_QUESTION; + case ' ': return F_BLANK; + } + break; + + 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) + if (!curwin->w_cursor.col) + return ALEF_U_H; + + if (!p_ri) + dec_cursor(); + + if (gchar_cursor() == _LAM) + { + chg_c_toX_orX (); + chg_l_toXor_X (); + tempc = ALEF_U_H; + } + else + if (isF_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(); + + return tempc; + case 'h': + if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) + { + if (p_ri) + chg_c_to_X_or_X (); + + } + + if (!p_ri) + if (!curwin->w_cursor.col) + return ALEF; + + if (!p_ri) + dec_cursor(); + + if (gchar_cursor() == _LAM) + { + chg_l_toXor_X (); + delchar(FALSE); + AppendCharToRedobuff(K_BS); + + if (!p_ri) + dec_cursor(); + + tempc = LA; + } + else + { + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + { + tempc = ALEF_; + chg_l_toXor_X (); + } + else + tempc = ALEF; + } + + if (!p_ri) + inc_cursor(); + + return tempc; + case 'i': + if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) + { + if (!p_ri && !isF_TyE(tempc)) + chg_c_to_X_orX_ (); + if (p_ri) + chg_c_to_X_or_X (); + + } + + if (!p_ri && !curwin->w_cursor.col) + return _HE; + + if (!p_ri) + dec_cursor(); + + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = _HE_; + else + tempc = _HE; + + if (!p_ri) + inc_cursor(); + break; + case 'j': + tempc = _TE; + break; + case 'J': + if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) + { + if (p_ri) + chg_c_to_X_or_X (); + + } + + if (!p_ri) + if (!curwin->w_cursor.col) + return TEE; + + if (!p_ri) + dec_cursor(); + + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + { + tempc = TEE_; + chg_l_toXor_X (); + } + else + tempc = TEE; + + if (!p_ri) + inc_cursor(); + + return tempc; + case 'k': + tempc = _NOON; + break; + case 'l': + tempc = _MIM; + break; + case 'm': + tempc = _PE; + break; + case 'n': + case 'N': + tempc = DAL; + break; + case 'o': + tempc = _XE; + break; + case 'p': + tempc = _HE_J; + break; + case 'q': + tempc = _ZAD; + break; + case 'r': + tempc = _GHAF; + break; + case 's': + tempc = _SIN; + break; + case 'S': + tempc = _IE; + break; + case 't': + tempc = _FE; + break; + case 'u': + if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) + { + if (!p_ri && !isF_TyE(tempc)) + chg_c_to_X_orX_ (); + if (p_ri) + chg_c_to_X_or_X (); + + } + + if (!p_ri && !curwin->w_cursor.col) + return _AYN; + + if (!p_ri) + dec_cursor(); + + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = _AYN_; + else + tempc = _AYN; + + if (!p_ri) + inc_cursor(); + break; + case 'v': + case 'V': + tempc = RE; + break; + case 'w': + tempc = _SAD; + break; + case 'x': + case 'X': + tempc = _TA; + break; + case 'y': + if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) + { + if (!p_ri && !isF_TyE(tempc)) + chg_c_to_X_orX_ (); + if (p_ri) + chg_c_to_X_or_X (); + + } + + if (!p_ri && !curwin->w_cursor.col) + return _GHAYN; + + if (!p_ri) + dec_cursor(); + + if (isF_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + tempc = _GHAYN_; + else + tempc = _GHAYN; + + if (!p_ri) + inc_cursor(); + + break; + case 'z': + tempc = _ZA; + break; + case 'Z': + tempc = _KAF_H; + break; + case ';': + tempc = _KAF; + break; + case '\'': + tempc = _GAF; + break; + case ',': + tempc = WAW; + break; + case '[': + tempc = _JIM; + break; + case ']': + tempc = _CHE; + break; + } + + if ((isFalpha(tempc) || isFdigit(tempc))) + { + if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) + { + if (!p_ri && !isF_TyE(tempc)) + chg_c_to_X_orX_ (); + if (p_ri) + chg_c_to_X_or_X (); + } + + if (curwin->w_cursor.col) + { + if (!p_ri) + dec_cursor(); + + if (isF_TyE(tempc)) + chg_l_toXor_X (); + else + chg_l_to_X_orX_ (); + + if (!p_ri) + inc_cursor(); + } + } + if (tempc) + return tempc; + return c; } #endif diff -rcN vim-4.5/src/farsi.h vim-4.5.farsi/src/farsi.h *** vim-4.5/src/farsi.h Wed Dec 31 23:00:00 1969 --- vim-4.5.farsi/src/farsi.h Tue Feb 2 16:10:17 1993 *************** *** 0 **** --- 1,180 ---- + /* + ** Farsi characters are catagorized into following types: + ** + ** TyA (for capital letter representation) + ** TyB (for types that look like _X e.g. AYN) + ** TyC (for types that look like X_ e.g. YE_) + ** TyD (for types that look like _X_ e.g. _AYN_) + ** TyE (for types that look like X e.g. RE) + */ + + /* + ** Farsi character set definition + */ + + /* + ** Begin of the none standard part + */ + + #define TEE_ 0x80 + #define ALEF_U_H_ 0x81 + #define ALEF_ 0x82 + #define _BE 0x83 + #define _PE 0x84 + #define _TE 0x85 + #define _SE 0x86 + #define _JIM 0x87 + #define _CHE 0x88 + #define _HE_J 0x89 + #define _XE 0x8a + #define _SIN 0x8b + #define _SHIN 0x8c + #define _SAD 0x8d + #define _ZAD 0x8e + #define _AYN 0x8f + #define _AYN_ 0x90 + #define AYN_ 0x91 + #define _GHAYN 0x92 + #define _GHAYN_ 0x93 + #define GHAYN_ 0x94 + #define _FE 0x95 + #define _GHAF 0x96 + #define _KAF 0x97 + #define _GAF 0x98 + #define _LAM 0x99 + #define LA 0x9a + #define _MIM 0x9b + #define _NOON 0x9c + #define _HE 0x9d + #define _HE_ 0x9e + #define _YE 0x9f + #define _IE 0xec + #define IE_ 0xed + #define IE 0xfb + #define _YEE 0xee + #define YEE_ 0xef + #define YE_ 0xff + + /* + ** End of the none standard part + */ + + /* + ** Standard part + */ + + #define F_BLANK 0xa0 /* Farsi ' ' (SP) character */ + #define F_PSP 0xa1 /* PSP for capitalizing of a character */ + #define F_PCN 0xa2 /* PCN for redefining of the hamye meaning */ + #define F_EXCL 0xa3 /* Farsi ! character */ + #define F_CURRENCY 0xa4 /* Farsi Rial character */ + #define F_PERCENT 0xa5 /* Farsi % character */ + #define F_PERIOD 0xa6 /* Farsi '.' character */ + #define F_COMMA 0xa7 /* Farsi ',' character */ + #define F_LPARENT 0xa8 /* Farsi '(' character */ + #define F_RPARENT 0xa9 /* Farsi ')' character */ + #define F_MUL 0xaa /* Farsi 'x' character */ + #define F_PLUS 0xab /* Farsi '+' character */ + #define F_BCOMMA 0xac /* Farsi comma character */ + #define F_MINUS 0xad /* Farsi '-' character */ + #define F_DIVIDE 0xae /* Farsi divide (/) character */ + #define F_SLASH 0xaf /* Farsi '/' character */ + + #define FARSI_0 0xb0 + #define FARSI_1 0xb1 + #define FARSI_2 0xb2 + #define FARSI_3 0xb3 + #define FARSI_4 0xb4 + #define FARSI_5 0xb5 + #define FARSI_6 0xb6 + #define FARSI_7 0xb7 + #define FARSI_8 0xb8 + #define FARSI_9 0xb9 + + #define F_DCOLON 0xba /* Farsi ':' character */ + #define F_SEMICOLON 0xbb /* Farsi ';' character */ + #define F_GREATER 0xbc /* Farsi '>' character */ + #define F_EQUALS 0xbd /* Farsi '=' character */ + #define F_LESS 0xbe /* Farsi '<' character */ + #define F_QUESTION 0xbf /* Farsi ? character */ + + #define ALEF_A 0xc0 + #define ALEF 0xc1 + #define HAMZE 0xc2 + #define BE 0xc3 + #define PE 0xc4 + #define TE 0xc5 + #define SE 0xc6 + #define JIM 0xc7 + #define CHE 0xc8 + #define HE_J 0xc9 + #define XE 0xca + #define DAL 0xcb + #define ZAL 0xcc + #define RE 0xcd + #define ZE 0xce + #define JE 0xcf + #define SIN 0xd0 + #define SHIN 0xd1 + #define SAD 0xd2 + #define ZAD 0xd3 + #define _TA 0xd4 + #define _ZA 0xd5 + #define AYN 0xd6 + #define GHAYN 0xd7 + #define FE 0xd8 + #define GHAF 0xd9 + #define KAF 0xda + #define GAF 0xdb + #define LAM 0xdc + #define MIM 0xdd + #define NOON 0xde + #define WAW 0xdf + #define HE 0xe0 + #define YE 0xe1 + #define TEE 0xfc + #define _KAF_H 0xfd + #define YEE 0xfe + + #define F_LBRACK 0xe2 /* Farsi '[' character */ + #define F_RBRACK 0xe3 /* Farsi ']' character */ + #define F_LBRACE 0xe4 /* Farsi '{' character */ + #define F_RBRACE 0xe5 /* Farsi '}' character */ + #define F_LQUOT 0xe6 /* Farsi left quotation character */ + #define F_RQUOT 0xe7 /* Farsi right quotation character */ + #define F_STAR 0xe8 /* Farsi '*' character */ + #define F_UNDERLINE 0xe9 /* Farsi '_' character */ + #define F_PIPE 0xea /* Farsi '|' character */ + #define F_BSLASH 0xeb /* Farsi '\' character */ + + #define MAD 0xf0 + #define JAZR 0xf1 + #define OW 0xf2 + #define MAD_N 0xf3 + #define JAZR_N 0xf4 + #define OW_OW 0xf5 + #define TASH 0xf6 + #define OO 0xf7 + #define ALEF_U_H 0xf8 + #define WAW_H 0xf9 + #define ALEF_D_H 0xfa + + /* + ** global definitions + ** ================== + */ + + #define SRC_EDT 0 + #define SRC_CMD 1 + + #define AT_CURSOR 0 + + /* + ** definitions for the window dependent functions (w_p_pers). + */ + + #define W_CONV 0x1 + #define W_R_L 0x2 + + + /*--*/ diff -rcN vim-4.5/src/feature.h vim-4.5.farsi/src/feature.h *** vim-4.5/src/feature.h Sat Oct 5 13:21:09 1996 --- vim-4.5.farsi/src/feature.h Tue Feb 2 17:06:30 1993 *************** *** 265,267 **** --- 265,279 ---- #if 0 # define NO_ARP #endif + + /* + * FKMAP When defined: Farsi (Persian language) Keymap support + * Takes some code. + */ + #if 0 + # ifndef RIGHTLEFT + # define RIGHTLEFT + # endif + # define FKMAP + #endif + diff -rcN vim-4.5/src/getchar.c vim-4.5.farsi/src/getchar.c *** vim-4.5/src/getchar.c Wed Sep 11 19:18:24 1996 --- vim-4.5.farsi/src/getchar.c Tue Feb 2 16:07:03 1993 *************** *** 1808,1813 **** --- 1808,1823 ---- retval = 4; /* no mem */ goto theend; } + #ifdef FKMAP + /* + ** when in right-to-left mode and alternate keymap option set, + ** reverse the character flow in the arg in Farsi. + */ + if (p_altkeymap && curwin->w_p_rl ) + { + lrswap(arg); + } + #endif mp->m_keys = strsave(keys); mp->m_str = strsave(arg); if (mp->m_keys == NULL || mp->m_str == NULL) diff -rcN vim-4.5/src/main.c vim-4.5.farsi/src/main.c *** vim-4.5/src/main.c Thu Oct 3 19:33:34 1996 --- vim-4.5.farsi/src/main.c Tue Feb 2 16:07:22 1993 *************** *** 743,748 **** --- 743,756 ---- */ set_init_3(); + #ifdef FKMAP + if (curwin->w_p_rl && p_altkeymap) + { + p_hkmap = FALSE; /* Reset the Hebrew keymap mode */ + p_fkmap = TRUE; /* Set the Farsi keymap mode */ + } + #endif + #ifdef USE_GUI if (gui.starting) { diff -rcN vim-4.5/src/normal.c vim-4.5.farsi/src/normal.c *** vim-4.5/src/normal.c Mon Oct 7 16:50:00 1996 --- vim-4.5.farsi/src/normal.c Tue Feb 2 16:11:55 1993 *************** *** 16,21 **** --- 16,25 ---- #include "proto.h" #include "option.h" + #ifdef FKMAP + #include "farsi.h" + #endif + #undef EXTERN #undef INIT #define EXTERN *************** *** 218,223 **** --- 222,231 ---- #ifdef RIGHTLEFT if (p_hkmap && strchr("tTfFr", c) && KeyTyped) /* Hebrew mapped char */ nchar = hkmap(nchar); + #ifdef FKMAP + if (p_fkmap && strchr("tTfFr", c) && KeyTyped) /* Farsi mapped char */ + nchar = fkmap(nchar); + #endif #endif --no_mapping; --allow_keys; *************** *** 2202,2208 **** --- 2210,2246 ---- clearop(); vim_beep(); break; + #ifdef FKMAP + case K_F8: + if (p_altkeymap) + { + curwin->w_p_pers = curwin->w_p_pers ^ W_R_L; + if (curwin->w_p_pers & W_R_L) + { + p_fkmap=0; + do_cmdline("set norl", FALSE, TRUE); + MSG(""); + } + else + { + p_fkmap=1; + do_cmdline("set rl", FALSE, TRUE); + MSG(""); + } + break; + } + case K_F9: + if (p_altkeymap && curwin->w_p_rl) + { + curwin->w_p_pers = curwin->w_p_pers ^ W_CONV; + if (curwin->w_p_pers & W_CONV) + conv_to_pvim(); + else + conv_to_pstd(); + break; + } + #endif default: /* not a known command */ clearopbeep(); break; diff -rcN vim-4.5/src/option.c vim-4.5.farsi/src/option.c *** vim-4.5/src/option.c Wed Oct 2 19:48:20 1996 --- vim-4.5.farsi/src/option.c Tue Feb 2 16:07:45 1993 *************** *** 272,277 **** --- 272,283 ---- #ifdef RIGHTLEFT {"hkmap", "hk", P_BOOL, (char_u *)&p_hkmap, (char_u *)FALSE}, + #ifdef FKMAP + {"fkmap", "fk", P_BOOL, (char_u *)&p_fkmap, + (char_u *)FALSE}, + {"altkeymap", "akm", P_BOOL, (char_u *)&p_altkeymap, + (char_u *)FALSE}, + #endif #endif {"icon", NULL, P_BOOL, (char_u *)&p_icon, (char_u *)FALSE}, *************** *** 1120,1125 **** --- 1126,1136 ---- int did_show = FALSE; /* already showed one value */ WIN *wp; + #ifdef FKMAP + char_u old_akm; /* previous value if p_altkeymap*/ + old_akm = p_altkeymap; + #endif + if (*arg == NUL) { showoptions(0); *************** *** 1980,1985 **** --- 1991,2038 ---- if (p_ea && !oldea) win_equal(curwin, FALSE); updateScreen(CURSUPD); + #ifdef FKMAP + /* + ** In case some second language keymapping options have changed, check + ** and correct the setting in a consistent way. + */ + if (old_akm != p_altkeymap) + if (!p_altkeymap) + { + p_hkmap=p_fkmap; + p_fkmap=0; + init_chartab(); + } + else + { + p_fkmap=p_hkmap; + p_hkmap=0; + init_chartab(); + } + + /* + ** If hkmap set, reset Farsi keymapping. + */ + + if (p_hkmap && p_altkeymap) + { + p_altkeymap=0; + p_fkmap=0; + init_chartab(); + } + + /* + ** If fkmap set, reset Hebrew keymapping. + */ + + if (p_fkmap && !p_altkeymap) + { + p_altkeymap=1; + p_hkmap=0; + init_chartab(); + } + + #endif return (errcnt == 0 ? OK : FAIL); } diff -rcN vim-4.5/src/option.h vim-4.5.farsi/src/option.h *** vim-4.5/src/option.h Wed Sep 25 17:44:32 1996 --- vim-4.5.farsi/src/option.h Tue Feb 2 16:10:01 1993 *************** *** 157,162 **** --- 157,166 ---- EXTERN long p_hi; /* command line history size */ #ifdef RIGHTLEFT EXTERN int p_hkmap; /* Hebrew keyboard map */ + #ifdef FKMAP + EXTERN int p_fkmap; /* Farsi keyboard map */ + EXTERN int p_altkeymap; /* alternative keyboard map Hebrew/Farsi */ + #endif #endif EXTERN int p_icon; /* put file name in icon if possible */ EXTERN int p_ic; /* ignore case in searches */ diff -rcN vim-4.5/src/proto/charset.pro vim-4.5.farsi/src/proto/charset.pro *** vim-4.5/src/proto/charset.pro Sun Oct 6 17:55:28 1996 --- vim-4.5.farsi/src/proto/charset.pro Mon Jan 18 10:15:01 1993 *************** *** 15,17 **** --- 15,22 ---- int lbr_chartabsize __PARMS((unsigned char *s, colnr_t col)); int win_lbr_chartabsize __PARMS((WIN *wp, unsigned char *s, colnr_t col, int *head)); void getvcol __PARMS((WIN *wp, FPOS *pos, colnr_t *start, colnr_t *cursor, colnr_t *end)); + #ifdef FKMAP + int isFalpha __PARMS((int c)); + int isFdigit __PARMS((int c)); + int isFchar __PARMS((int c)); + #endif diff -rcN vim-4.5/src/proto/cmdline.pro vim-4.5.farsi/src/proto/cmdline.pro *** vim-4.5/src/proto/cmdline.pro Sun Oct 6 17:55:37 1996 --- vim-4.5.farsi/src/proto/cmdline.pro Wed Jan 27 13:43:00 1993 *************** *** 22,24 **** --- 22,35 ---- int read_viminfo_history __PARMS((char_u *line, FILE *fp)); void finish_viminfo_history __PARMS((void)); void write_viminfo_history __PARMS((FILE *fp)); + + #ifdef FKMAP + char_u *lrswap __PARMS((char_u *ibuf)); + char_u *lrFswap __PARMS((char_u *cmdbuf, int len)); + char_u *lrF_sub __PARMS((char_u *ibuf)); + void cmd_pchar __PARMS((int c, int offset)); + int cmd_gchar __PARMS((int offset)); + int cmdl_fkmap __PARMS((int c)); + void conv_to_pvim __PARMS((void)); + void conv_to_pstd __PARMS((void)); + #endif diff -rcN vim-4.5/src/proto/edit.pro vim-4.5.farsi/src/proto/edit.pro *** vim-4.5/src/proto/edit.pro Sun Oct 6 17:55:51 1996 --- vim-4.5.farsi/src/proto/edit.pro Mon Jan 18 10:15:01 1993 *************** *** 21,23 **** --- 21,28 ---- void fixthisline __PARMS((int (*get_the_indent)(void))); int in_cinkeys __PARMS((int keytyped, int when, int line_is_empty)); int hkmap __PARMS((int c)); + #ifdef FKMAP + int fkmap __PARMS((int c)); + int isF_TyB_TyC_TyD __PARMS((int src, int offset)); + int toF_TyA __PARMS((int c)); + #endif diff -rcN vim-4.5/src/screen.c vim-4.5.farsi/src/screen.c *** vim-4.5/src/screen.c Wed Oct 2 19:37:30 1996 --- vim-4.5.farsi/src/screen.c Tue Feb 2 16:08:44 1993 *************** *** 3019,3024 **** --- 3019,3031 ---- #ifdef RIGHTLEFT if (p_hkmap) MSG_OUTSTR(" Hebrew"); + #ifdef FKMAP + /* + ** Following sentence is encoded in Farsi + */ + if (p_fkmap) + MSG_OUTSTR(" ͂"); + #endif #endif if ((State & INSERT) && p_paste) MSG_OUTSTR(" (paste)"); diff -rcN vim-4.5/src/search.c vim-4.5.farsi/src/search.c *** vim-4.5/src/search.c Wed Sep 11 17:31:32 1996 --- vim-4.5.farsi/src/search.c Tue Feb 2 16:12:07 1993 *************** *** 15,20 **** --- 15,24 ---- #include "option.h" #include "ops.h" /* for op_inclusive */ + #ifdef FKMAP + #include "farsi.h" + #endif + /* modified Henry Spencer's regular expression routines */ #include "regexp.h" *************** *** 688,693 **** --- 692,703 ---- } } + #ifdef FKMAP /* when in Farsi mode, reverse the character flow */ + if (p_altkeymap && curwin->w_p_rl) + { + lrFswap(searchstr,0); + } + #endif c = searchit(&pos, dirc == '/' ? FORWARD : BACKWARD, searchstr, count, lastend + (options & (SEARCH_KEEP + SEARCH_HIS + SEARCH_MSG + SEARCH_START + *************** *** 1734,1739 **** --- 1744,1754 ---- register int c; c = gchar_cursor(); + #ifdef FKMAP /* when 'akm' (Farsi mode), take care of Farsi blank */ + if (p_altkeymap) + if (c == F_BLANK) + return 0; + #endif if (c == ' ' || c == '\t' || c == NUL) return 0; diff -rcN vim-4.5/src/structs.h vim-4.5.farsi/src/structs.h *** vim-4.5/src/structs.h Sun Jun 9 20:34:58 1996 --- vim-4.5.farsi/src/structs.h Wed Jan 27 15:38:54 1993 *************** *** 514,519 **** --- 514,522 ---- w_p_nu, #ifdef RIGHTLEFT w_p_rl, + #ifdef FKMAP + w_p_pers, /* for the window depentent Presian functions */ + #endif #endif w_p_wrap, w_p_lbr;