diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-02-17 10:54:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-17 10:54:00 +0100 |
commit | 33ce70c8833a4ee0422b8865c7438fe6676cdd6c (patch) | |
tree | a3c2c7b74745729773dbac16070d43db1c8f7d09 | |
parent | dc9dd8d664f2ffec3d199f96e4605cb0729497ec (diff) | |
download | rneovim-33ce70c8833a4ee0422b8865c7438fe6676cdd6c.tar.gz rneovim-33ce70c8833a4ee0422b8865c7438fe6676cdd6c.tar.bz2 rneovim-33ce70c8833a4ee0422b8865c7438fe6676cdd6c.zip |
vim-patch:8.1.0932: remove Farsi support (#9622)
Problem: Farsi support is outdated and unused.
Solution: Delete the Farsi support.
https://github.com/vim/vim/commit/14184a3133b9a6ee5f711d493c04e41ba4fa7c2f
-rw-r--r-- | runtime/doc/cmdline.txt | 9 | ||||
-rw-r--r-- | runtime/doc/eval.txt | 1 | ||||
-rw-r--r-- | runtime/doc/farsi.txt | 208 | ||||
-rw-r--r-- | runtime/doc/help.txt | 1 | ||||
-rw-r--r-- | runtime/doc/index.txt | 4 | ||||
-rw-r--r-- | runtime/doc/options.txt | 20 | ||||
-rw-r--r-- | runtime/doc/quickref.txt | 3 | ||||
-rw-r--r-- | runtime/doc/rileft.txt | 3 | ||||
-rw-r--r-- | runtime/doc/starting.txt | 3 | ||||
-rw-r--r-- | runtime/doc/various.txt | 1 | ||||
-rw-r--r-- | runtime/optwin.vim | 6 | ||||
-rw-r--r-- | src/nvim/buffer_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/charset.c | 17 | ||||
-rw-r--r-- | src/nvim/edit.c | 42 | ||||
-rw-r--r-- | src/nvim/eval.c | 1 | ||||
-rw-r--r-- | src/nvim/ex_cmds.c | 7 | ||||
-rw-r--r-- | src/nvim/ex_getln.c | 124 | ||||
-rw-r--r-- | src/nvim/farsi.c | 2076 | ||||
-rw-r--r-- | src/nvim/farsi.h | 174 | ||||
-rw-r--r-- | src/nvim/getchar.c | 14 | ||||
-rw-r--r-- | src/nvim/main.c | 19 | ||||
-rw-r--r-- | src/nvim/normal.c | 7 | ||||
-rw-r--r-- | src/nvim/option.c | 51 | ||||
-rw-r--r-- | src/nvim/option_defs.h | 2 | ||||
-rw-r--r-- | src/nvim/options.lua | 14 | ||||
-rw-r--r-- | src/nvim/screen.c | 4 | ||||
-rw-r--r-- | src/nvim/search.c | 22 | ||||
-rw-r--r-- | src/nvim/testdir/test_farsi.vim | 133 | ||||
-rw-r--r-- | src/nvim/window.c | 5 |
29 files changed, 63 insertions, 2910 deletions
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt index 3f22fcb504..47c4677b20 100644 --- a/runtime/doc/cmdline.txt +++ b/runtime/doc/cmdline.txt @@ -250,20 +250,13 @@ CTRL-A command-line completion (see |cmdline-completion|) CTRL-L command-line completion (see |cmdline-completion|) *c_CTRL-_* -CTRL-_ a - switch between Hebrew and English keyboard mode, which is +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 the 'allowrevins' option is set. See |rileft.txt|. - b - switch between Farsi and English keyboard mode, which is - private to the command-line and not related to fkmap. In - Farsi keyboard mode the characters are inserted in reverse - insert manner. This is useful when Farsi text entry is - required in the command-line, searches, abbreviations, etc. - See |farsi.txt|. - *c_CTRL-^* CTRL-^ Toggle the use of language |:lmap| mappings and/or Input Method. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 5dc282f6ba..38bbd66ea2 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -8488,7 +8488,6 @@ eval Compiled with expression evaluation support. Always ex_extra |+ex_extra|, always true now extra_search Compiled with support for |'incsearch'| and |'hlsearch'| -farsi Compiled with Farsi support |farsi|. file_in_path Compiled with support for |gf| and |<cfile>| filterpipe When 'shelltemp' is off pipes are used for shell read/write/filter commands diff --git a/runtime/doc/farsi.txt b/runtime/doc/farsi.txt deleted file mode 100644 index c5421137f8..0000000000 --- a/runtime/doc/farsi.txt +++ /dev/null @@ -1,208 +0,0 @@ -*farsi.txt* Nvim - - - VIM REFERENCE MANUAL by Mortaza Ghassab Shiran - - -Right to Left and Farsi Mapping for Vim *farsi* *Farsi* - -These functions have been made by Mortaza G. Shiran <shiran@jps.net> - - -Introduction ------------- -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. - -The commands, prompts and help files are not in Farsi, 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 none number character, 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 left-to-right and right-to-left via F8 function key. - -o Toggling between Farsi ISIR-3342 standard encoding and Vim Farsi via F9 - function key. Since this makes sense only for the text written in - right-to-left mode, this function is also supported only in right-to-left - mode. - - -Usage ------ -Prior to starting Vim, the environment in which Vim can run in Farsi mode, -must be set. In addition to installation of Farsi fonts, following points -refer to some of the system environments, which you may need to set: -Key code mapping, loading graphic card in ASCII screen mode, setting the IO -driver in 8 bit clean mode ... . - -o Setting the Farsi fonts - - + For Vim GUI set the 'guifont' to far-a01. This is done by entering - ':set guifont=far-a01' in the Vim window. - - You can have 'guifont' set to far-a01 by Vim during the Vim startup - by appending the ':set guifont=far-a01' into your vimrc file. - - Under the X Window environment, you can also start Vim with the - '-fn far-a01' option. - - + For Vim within a xterm, start a xterm with the Farsi fonts (e.g. - kterm -fn far-a01). Then start Vim inside the kterm. - - + For Vim under DOS, prior to the first usage of Vim, upload the Farsi - fonts by executing the far-a01.com fonts uploading program. - -o Farsi Keymapping Activation - - To activate the Farsi keymapping, set either 'altkeymap' or 'fkmap'. - This is done by entering ':set akm' or ':set fk' in the Vim window. - You can have 'altkeymap' or 'fkmap' set as default by appending ':set akm' - or ':set fk' in your vimrc file. - - To turn off the Farsi keymapping as a default second language keymapping, - reset the 'altkeymap' by entering ':set noakm'. - -o right-to-left Farsi Mode - - By default Vim starts in Left-to-right mode. Following are ways to change - the window orientation: - - + Start Vim with the -F option (e.g. vim -F ...). - - + Use the F8 function key to toggle between left-to-right and right-to-left. - - + 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 Vim in right-to-left - mode permanently. - -Encoding --------- - -The letter encoding used is the Vim extended ISIR-3342 standard with a built -in function to convert between Vim extended ISIR-3342 and ISIR-3342 standard. - -For document portability reasons, the letter encoding is kept the same across -different platforms (i.e. Unix, Windows, ...). - - -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 ISIR-3342 standard and Vim extended - ISIR-3342 (supported only in right-to-left mode). - - + Keyboard mapping is based on the Iranian ISIRI-2901 standard. - Following table shows the keyboard mapping while Farsi(akm) mode set: - - ------------------------------------- - ` 1 2 3 4 5 6 7 8 9 0 - = - ¢ ± ² ³ ´ µ ¶ · ¸ ¹ ° ½ - ------------------------------------- - ~ ! @ # $ % ^ & * ( ) _ + - ~ £ § ® ¤ ¥ ª ¬ è ¨ © é « - ------------------------------------- - q w e r t z u i o p [ ] - Ó Ò Æ Ù Ø Õ Ö à Ê É Ç ˆ - ------------------------------------- - Q W E R T Z U I O P { } - ÷ õ ô ó ò ý ð ö [ ] { } - ------------------------------------- - a s d f g h j k l ; ' \ - Ñ Ð á Ã Ü Á Å Þ Ý Ú Û ë - ------------------------------------- - A S D F G H J K L : " | - ù û þ ú ø À ü æ ç º » ê - ------------------------------------- - < y x c v b n m , . / - ¾ × Ô Î Í Ì Ë Ä ß ¦ ¯ - ------------------------------------- - > Y X C V B N M < > ? - ¼ ñ Ô Ï Í ¡ Ë Â ¾ ¼ ¿ - ------------------------------------- - -Note: - ¡ stands for Farsi PSP (break 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 cannot redo the last changes (using '.') after - entering numbers. - -o While in left-to-right mode 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 In command mode there is no support for entering numbers from left - to right and also for the sake of flexibility the keymapping logic is - restricted. - -o Under the X Window environment, if you want to run Vim within a xterm - terminal emulator and Farsi mode set, you need to have an ANSI compatible - xterm terminal emulator. This is because the letter codes above 128 decimal - have certain meanings in the standard xterm terminal emulator. - - Note: Under X Window environment, Vim GUI works fine in Farsi mode. - This eliminates the need of any xterm terminal emulator. - - -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 rileft.txt. - - vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/help.txt b/runtime/doc/help.txt index edecc655dd..7fcf08e2a1 100644 --- a/runtime/doc/help.txt +++ b/runtime/doc/help.txt @@ -137,7 +137,6 @@ Special issues ~ |mbyte.txt| multi-byte text support |mlang.txt| non-English language support |arabic.txt| Arabic language support and editing -|farsi.txt| Farsi (Persian) editing |hebrew.txt| Hebrew language support and editing |russian.txt| Russian language support and editing |ft_ada.txt| Ada (the programming language) support diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 63ded3152f..765f8ce3a1 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -92,7 +92,7 @@ tag char action in Insert mode ~ |i_CTRL-]| CTRL-] trigger abbreviation |i_CTRL-^| CTRL-^ toggle use of |:lmap| mappings |i_CTRL-_| CTRL-_ When 'allowrevins' set: change language - (Hebrew, Farsi) + (Hebrew) <Space> to '~' not used, except '0' and '^' followed by CTRL-D @@ -1029,7 +1029,7 @@ tag command action in Command-line editing mode ~ |c_CTRL-]| CTRL-] trigger abbreviation |c_CTRL-^| CTRL-^ toggle use of |:lmap| mappings |c_CTRL-_| CTRL-_ when 'allowrevins' set: change language - (Hebrew, Farsi) + (Hebrew) |c_<Del>| <Del> delete the character under the cursor |c_<Left>| <Left> cursor left diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 4177268780..505c0c5ea0 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -561,17 +561,6 @@ A jump table for the options with a short description can be found at |Q_op|. into reverse Insert mode, and don't know how to get out. See 'revins'. - *'altkeymap'* *'akm'* *'noaltkeymap'* *'noakm'* -'altkeymap' 'akm' boolean (default off) - global - When on, the second language is Farsi. In editing mode CTRL-_ toggles - the keyboard map between Farsi and English, when 'allowrevins' set. - - When off, the keyboard map toggles between Hebrew and English. This - is useful to start the Vim in native mode i.e. English (left-to-right - mode) and have default second language Farsi or Hebrew (right-to-left - mode). See |farsi.txt|. - *'ambiwidth'* *'ambw'* 'ambiwidth' 'ambw' string (default: "single") global @@ -2397,13 +2386,6 @@ A jump table for the options with a short description can be found at |Q_op|. matter. See the 'endofline' option. - *'fkmap'* *'fk'* *'nofkmap'* *'nofk'* -'fkmap' 'fk' boolean (default off) *E198* - global - When on, the keyboard is mapped for the Farsi character set. - Normally you would set 'allowrevins' and use CTRL-_ in insert mode to - toggle this option |i_CTRL-_|. See |farsi.txt|. - *'foldclose'* *'fcl'* 'foldclose' 'fcl' string (default "") global @@ -4635,7 +4617,7 @@ A jump table for the options with a short description can be found at |Q_op|. search "/" and "?" commands - This is useful for languages such as Hebrew, Arabic and Farsi. + This is useful for languages such as Hebrew and Arabic. The 'rightleft' option must be set for 'rightleftcmd' to take effect. *'ruler'* *'ru'* *'noruler'* *'noru'* diff --git a/runtime/doc/quickref.txt b/runtime/doc/quickref.txt index 98a5244345..da064ab89b 100644 --- a/runtime/doc/quickref.txt +++ b/runtime/doc/quickref.txt @@ -597,7 +597,6 @@ In Insert or Command-line mode: Short explanation of each option: *option-list* 'aleph' 'al' ASCII code of the letter Aleph (Hebrew) 'allowrevins' 'ari' allow CTRL-_ in Insert and Command-line mode -'altkeymap' 'akm' for default second language (Farsi/Hebrew) 'ambiwidth' 'ambw' what to do with Unicode chars of ambiguous width 'autochdir' 'acd' change directory to the file in the current window 'arabic' 'arab' for Arabic as a default second language @@ -688,7 +687,6 @@ Short explanation of each option: *option-list* 'filetype' 'ft' type of file, used for autocommands 'fillchars' 'fcs' characters to use for displaying special items 'fixendofline' 'fixeol' make sure last line in file has <EOL> -'fkmap' 'fk' Farsi keyboard mapping 'foldclose' 'fcl' close a fold when the cursor leaves it 'foldcolumn' 'fdc' width of the column used to indicate folds 'foldenable' 'fen' set to display all folds open @@ -1122,7 +1120,6 @@ Context-sensitive completion on the command-line: |-b| -b binary mode |-l| -l lisp mode |-A| -A Arabic mode ('arabic' is set) -|-F| -F Farsi mode ('fkmap' and 'rightleft' are set) |-H| -H Hebrew mode ('hkmap' and 'rightleft' are set) |-V| -V Verbose, give informative messages |-r| -r give list of swap files diff --git a/runtime/doc/rileft.txt b/runtime/doc/rileft.txt index 8fd67c9602..550a696de0 100644 --- a/runtime/doc/rileft.txt +++ b/runtime/doc/rileft.txt @@ -53,8 +53,7 @@ o No special terminal with right-to-left capabilities is required. The o Many languages use and require right-to-left support. These languages can quite easily be supported given the inclusion of their required keyboard mappings and some possible minor code change. Some of the - current supported languages include - |arabic.txt|, |farsi.txt| and - |hebrew.txt|. + current supported languages include - |arabic.txt| and |hebrew.txt|. Of Interest... diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 291f4b2086..88aa4121e4 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -231,9 +231,6 @@ argument. *-A* -A Arabic mode. Sets the 'arabic' option on. - *-F* --F Farsi mode. Sets the 'fkmap' and 'rightleft' options on. - *-H* -H Hebrew mode. Sets the 'hkmap' and 'rightleft' options on. diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index dbbafd1576..2b8ba56c28 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -330,7 +330,6 @@ N *+digraphs* |digraphs| *E196* N *+eval* expression evaluation |eval.txt| N *+ex_extra* always on now, used to be for Vim's extra Ex commands N *+extra_search* |'hlsearch'| and |'incsearch'| options. -B *+farsi* |farsi| language N *+file_in_path* |gf|, |CTRL-W_f| and |<cfile>| N *+find_in_path* include file searches: |[I|, |:isearch|, |CTRL-W_CTRL-I|, |:checkpath|, etc. diff --git a/runtime/optwin.vim b/runtime/optwin.vim index 2e9f4723dd..f3d7d3729b 100644 --- a/runtime/optwin.vim +++ b/runtime/optwin.vim @@ -1141,12 +1141,6 @@ if has("rightleft") call append("$", "hkmapp\tuse phonetic Hebrew keyboard mapping") call <SID>BinOptionG("hkp", &hkp) endif -if has("farsi") - call append("$", "altkeymap\tuse Farsi as the second language when 'revins' is set") - call <SID>BinOptionG("akm", &akm) - call append("$", "fkmap\tuse Farsi keyboard mapping") - call <SID>BinOptionG("fk", &fk) -endif if has("arabic") call append("$", "arabic\tprepare for editing Arabic text") call append("$", "\t(local to window)") diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 07d8ab2e0c..da1e3ce9c6 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -1189,8 +1189,6 @@ struct window_S { ScopeDictDictItem w_winvar; ///< Variable for "w:" dictionary. dict_T *w_vars; ///< Dictionary with w: variables. - int w_farsi; /* for the window dependent Farsi functions */ - /* * The w_prev_pcmark field is used to check whether we really did jump to * a new line after setting the w_pcmark. If not, then we revert to diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 08ecff149c..ddff93d83b 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -14,7 +14,6 @@ #include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/charset.h" -#include "nvim/farsi.h" #include "nvim/func_attr.h" #include "nvim/indent.h" #include "nvim/main.h" @@ -112,12 +111,6 @@ int buf_init_chartab(buf_T *buf, int global) g_chartab[c++] = 1 + CT_PRINT_CHAR; } - if (p_altkeymap) { - while (c < YE) { - g_chartab[c++] = 1 + CT_PRINT_CHAR; - } - } - while (c < 256) { if (c >= 0xa0) { // UTF-8: bytes 0xa0 - 0xff are printable (latin1) @@ -217,8 +210,7 @@ int buf_init_chartab(buf_T *buf, int global) // "C". if (!do_isalpha || mb_islower(c) - || mb_isupper(c) - || (p_altkeymap && (F_isalpha(c) || F_isdigit(c)))) { + || mb_isupper(c)) { if (i == 0) { // (re)set ID flag if (tilde) { @@ -230,9 +222,7 @@ int buf_init_chartab(buf_T *buf, int global) // (re)set printable // For double-byte we keep the cell width, so // that we can detect it from the first byte. - if (((c < ' ') - || (c > '~') - || (p_altkeymap && (F_isalpha(c) || F_isdigit(c))))) { + if (((c < ' ') || (c > '~'))) { if (tilde) { g_chartab[c] = (uint8_t)((g_chartab[c] & ~CT_CELL_MASK) + ((dy_flags & DY_UHEX) ? 4 : 2)); @@ -540,8 +530,7 @@ char_u *transchar(int c) c = K_SECOND(c); } - if ((!chartab_initialized && (((c >= ' ') && (c <= '~')) - || (p_altkeymap && F_ischar(c)))) + if ((!chartab_initialized && (((c >= ' ') && (c <= '~')))) || ((c <= 0xFF) && vim_isprintc_strict(c))) { // printable character transchar_buf[i] = (char_u)c; diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 62b35fa708..5a21c50fa6 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -21,7 +21,6 @@ #include "nvim/eval/typval.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" -#include "nvim/farsi.h" #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/getchar.h" @@ -342,13 +341,7 @@ static void insert_enter(InsertState *s) } if (s->cmdchar == 'R') { - if (p_fkmap && p_ri) { - beep_flush(); - EMSG(farsi_text_3); // encoded in Farsi - State = INSERT; - } else { - State = REPLACE; - } + State = REPLACE; } else if (s->cmdchar == 'V' || s->cmdchar == 'v') { State = VREPLACE; s->replaceState = VREPLACE; @@ -630,10 +623,6 @@ static int insert_execute(VimState *state, int key) s->c = hkmap(s->c); // Hebrew mode mapping } - if (p_fkmap && KeyTyped) { - s->c = fkmap(s->c); // Farsi mode mapping - } - // Special handling of keys while the popup menu is visible or wanted // and the cursor is still in the completed word. Only when there is // a match, skip this when no matches were found. @@ -5344,7 +5333,6 @@ insertchar ( && !ISSPECIAL(c) && MB_BYTE2LEN(c) == 1 && i < INPUT_BUFLEN - && !(p_fkmap && KeyTyped) // Farsi mode mapping moves cursor && (textwidth == 0 || (virtcol += byte2cells(buf[i - 1])) < (colnr_T)textwidth) && !(!no_abbr && !vim_iswordc(c) && vim_iswordc(buf[i - 1]))) { @@ -7379,19 +7367,7 @@ static void ins_ctrl_(void) undisplay_dollar(); } else revins_scol = -1; - 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; - (void)stop_arrow(); - p_fkmap = curwin->w_p_rl ^ p_ri; - if (p_fkmap && p_ri) - State = INSERT; - } else - p_hkmap = curwin->w_p_rl ^ p_ri; /* be consistent! */ + p_hkmap = curwin->w_p_rl ^ p_ri; // be consistent! showmode(); } @@ -7444,12 +7420,6 @@ static bool ins_start_select(int c) */ static void ins_insert(int replaceState) { - if (p_fkmap && p_ri) { - beep_flush(); - EMSG(farsi_text_3); /* encoded in Farsi */ - return; - } - set_vim_var_string(VV_INSERTMODE, ((State & REPLACE_FLAG) ? "i" : replaceState == VREPLACE ? "v" : "r"), 1); @@ -8423,12 +8393,10 @@ static bool ins_eol(int c) if (virtual_active() && curwin->w_cursor.coladd > 0) coladvance(getviscol()); - if (p_altkeymap && p_fkmap) - fkmap(NL); - /* NL in reverse insert will always start in the end of - * current line. */ - if (revins_on) + // NL in reverse insert will always start in the end of current line. + if (revins_on) { curwin->w_cursor.col += (colnr_T)STRLEN(get_cursor_pos_ptr()); + } AppendToRedobuff(NL_STR); bool i = open_line(FORWARD, diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d63e45d3c7..d18884ff07 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10667,7 +10667,6 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr) "eval", /* always present, of course! */ "ex_extra", "extra_search", - "farsi", "file_in_path", "filterpipe", "find_in_path", diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b3ac456979..0b57f9cc3a 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -30,7 +30,6 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/ex_getln.h" -#include "nvim/farsi.h" #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/getchar.h" @@ -3295,9 +3294,6 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, delimiter = *cmd++; // remember delimiter character has_second_delim = true; } else { // find the end of the regexp - if (p_altkeymap && curwin->w_p_rl) { - lrF_sub(cmd); - } which_pat = RE_LAST; // use last used regexp delimiter = *cmd++; // remember delimiter character pat = cmd; // remember start of search pat @@ -4298,9 +4294,6 @@ void ex_global(exarg_T *eap) *cmd++ = NUL; /* replace it with a NUL */ } - if (p_altkeymap && curwin->w_p_rl) - lrFswap(pat,0); - if (search_regcomp(pat, RE_BOTH, which_pat, SEARCH_HIS, ®match) == FAIL) { EMSG(_(e_invcmd)); return; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index d70b81409d..27bd23a668 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -27,7 +27,6 @@ #include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" -#include "nvim/farsi.h" #include "nvim/fileio.h" #include "nvim/func_attr.h" #include "nvim/getchar.h" @@ -221,7 +220,6 @@ static bool getln_interrupted_highlight = false; #endif static int cmd_hkmap = 0; // Hebrew mapping during command line -static int cmd_fkmap = 0; // Farsi mapping during command line /// Internal entry point for cmdline mode. /// @@ -421,8 +419,6 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) cmdmsg_rl = false; - cmd_fkmap = 0; - ExpandCleanup(&s->xpc); ccline.xpc = NULL; @@ -552,10 +548,6 @@ static int command_line_execute(VimState *state, int key) s->c = hkmap(s->c); } - if (cmd_fkmap) { - s->c = cmdl_fkmap(s->c); - } - if (cmdmsg_rl && !KeyStuffed) { // Invert horizontal movements and operations. Only when // typed by the user directly, not when the result of a @@ -1180,10 +1172,6 @@ static int command_line_handle_key(CommandLineState *s) case K_DEL: case K_KDEL: case Ctrl_W: - if (cmd_fkmap && s->c == K_BS) { - s->c = K_DEL; - } - if (s->c == K_KDEL) { s->c = K_DEL; } @@ -1279,13 +1267,7 @@ static int command_line_handle_key(CommandLineState *s) case K_INS: case K_KINS: - // if Farsi mode set, we are in reverse insert mode - - // Do not change the mode - if (cmd_fkmap) { - beep_flush(); - } else { - ccline.overstrike = !ccline.overstrike; - } + ccline.overstrike = !ccline.overstrike; ui_cursor_shape(); // may show different cursor shape return command_line_not_changed(s); @@ -1740,16 +1722,7 @@ static int command_line_handle_key(CommandLineState *s) if (!p_ari) { break; } - if (p_altkeymap) { - cmd_fkmap = !cmd_fkmap; - if (cmd_fkmap) { - // in Farsi always in Insert mode - ccline.overstrike = false; - } - } else { - // Hebrew is default - cmd_hkmap = !cmd_hkmap; - } + cmd_hkmap = !cmd_hkmap; return command_line_not_changed(s); default: @@ -3217,40 +3190,40 @@ void put_on_cmdline(char_u *str, int len, int redraw) msg_clr_eos(); msg_no_more = FALSE; } - /* - * If we are in Farsi command mode, the character input must be in - * Insert mode. So do not advance the cmdpos. - */ - if (!cmd_fkmap) { - if (KeyTyped) { - m = Columns * Rows; - if (m < 0) /* overflow, Columns or Rows at weird value */ - m = MAXCOL; - } else + if (KeyTyped) { + m = Columns * Rows; + if (m < 0) { // overflow, Columns or Rows at weird value m = MAXCOL; - for (i = 0; i < len; ++i) { - c = cmdline_charsize(ccline.cmdpos); - /* count ">" for a double-wide char that doesn't fit. */ - if (has_mbyte) - correct_cmdspos(ccline.cmdpos, c); - /* Stop cursor at the end of the screen, but do increment the - * insert position, so that entering a very long command - * works, even though you can't see it. */ - if (ccline.cmdspos + c < m) - ccline.cmdspos += c; - if (has_mbyte) { - c = (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1; - if (c > len - i - 1) - c = len - i - 1; - ccline.cmdpos += c; - i += c; + } + } else { + m = MAXCOL; + } + for (i = 0; i < len; i++) { + c = cmdline_charsize(ccline.cmdpos); + // count ">" for a double-wide char that doesn't fit. + if (has_mbyte) { + correct_cmdspos(ccline.cmdpos, c); + } + // Stop cursor at the end of the screen, but do increment the + // insert position, so that entering a very long command + // works, even though you can't see it. + if (ccline.cmdspos + c < m) { + ccline.cmdspos += c; + } + if (has_mbyte) { + c = (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos) - 1; + if (c > len - i - 1) { + c = len - i - 1; } - ++ccline.cmdpos; + ccline.cmdpos += c; + i += c; } + ccline.cmdpos++; } - if (redraw) + if (redraw) { msg_check(); + } } /* @@ -5999,37 +5972,12 @@ int hist_type2char(int type) return NUL; } -/* - * Write a character at the current cursor+offset position. - * It is directly written into the command buffer block. - */ -void cmd_pchar(int c, int offset) -{ - if (ccline.cmdpos + offset >= ccline.cmdlen || ccline.cmdpos + offset < 0) { - EMSG(_("E198: cmd_pchar beyond the command length")); - return; - } - ccline.cmdbuff[ccline.cmdpos + offset] = (char_u)c; - ccline.cmdbuff[ccline.cmdlen] = NUL; -} - -int cmd_gchar(int offset) -{ - if (ccline.cmdpos + offset >= ccline.cmdlen || ccline.cmdpos + offset < 0) { - /* EMSG(_("cmd_gchar beyond the command length")); */ - return NUL; - } - return (int)ccline.cmdbuff[ccline.cmdpos + offset]; -} - -/* - * Open a window on the current command line and history. Allow editing in - * the window. Returns when the window is closed. - * Returns: - * CR if the command is to be executed - * Ctrl_C if it is to be abandoned - * K_IGNORE if editing continues - */ +/// Open a window on the current command line and history. Allow editing in +/// the window. Returns when the window is closed. +/// Returns: +/// CR if the command is to be executed +/// Ctrl_C if it is to be abandoned +/// K_IGNORE if editing continues static int open_cmdwin(void) { struct cmdline_info save_ccline; diff --git a/src/nvim/farsi.c b/src/nvim/farsi.c deleted file mode 100644 index 3d714f0fa6..0000000000 --- a/src/nvim/farsi.c +++ /dev/null @@ -1,2076 +0,0 @@ -// This is an open source non-commercial project. Dear PVS-Studio, please check -// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com - -/// @file farsi.c -/// -/// Functions for Farsi language - -#include <assert.h> -#include <stdbool.h> - -#include "nvim/cursor.h" -#include "nvim/edit.h" -#include "nvim/ex_docmd.h" -#include "nvim/ex_eval.h" -#include "nvim/ex_getln.h" -#include "nvim/farsi.h" -#include "nvim/getchar.h" -#include "nvim/memline.h" -#include "nvim/message.h" -#include "nvim/misc1.h" -#include "nvim/screen.h" -#include "nvim/strings.h" -#include "nvim/vim.h" -#include "nvim/ascii.h" - - -#define SRC_EDT 0 -#define SRC_CMD 1 - -#define AT_CURSOR 0 - -// Special Farsi text messages - -const char_u farsi_text_1[] = { - YE_, _SIN, RE, ALEF_, _FE, ' ', 'V', 'I', 'M', ' ', F_HE, _BE, ' ', SHIN, RE, - _GAF, DAL, ' ', NOON, ALEF_, _YE, ALEF_, _PE, '\0' -}; - -const char_u farsi_text_2[] = { - YE_, _SIN, RE, ALEF_, _FE, ' ', FARSI_3, FARSI_3, FARSI_4, FARSI_2, ' ', DAL, - RE, ALEF, DAL, _NOON, ALEF_, _TE, _SIN, ALEF, ' ', F_HE, _BE, ' ', SHIN, RE, - _GAF, DAL, ' ', NOON, ALEF_, _YE, ALEF_, _PE, '\0' -}; - -const char_u farsi_text_3[] = { - DAL, WAW, _SHIN, _YE, _MIM, _NOON, ' ', YE_, _NOON, ALEF_, _BE, _YE, _TE, - _SHIN, _PE, ' ', 'R', 'E', 'P', 'L', 'A', 'C', 'E', ' ', NOON, ALEF_, _MIM, - RE, _FE, ZE, ALEF, ' ', 'R', 'E', 'V', 'E', 'R', 'S', 'E', ' ', 'I', 'N', 'S', - 'E', 'R', 'T', ' ', SHIN, WAW, RE, ' ', ALEF_, _BE, ' ', YE_, _SIN, RE, ALEF_, - _FE, ' ', RE, DAL, ' ', RE, ALEF_, _KAF, ' ', MIM, ALEF_, _GAF, _NOON, _HE, - '\0' -}; - -const char_u farsi_text_5[] = { - ' ', YE_, _SIN, RE, ALEF_, _FE, '\0' -}; - - -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "farsi.c.generated.h" -#endif - -/// Convert the given Farsi character into a _X or _X_ type -/// -/// @param c The character to convert. -/// -/// @return Farsi character converted to a _X or _X_ type. -static char_u toF_Xor_X_(int c) -{ - char_u tempc; - - switch (c) { - 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 AYN : tempc = _AYN ; break; - case AYN_ : tempc = _AYN_ ; break; - case GHAYN : tempc = _GHAYN ; break; - case GHAYN_ : tempc = _GHAYN_ ; break; - case FE : tempc = _FE ; break; - case GHAF : tempc = _GHAF ; break; - case KAF : tempc = _KAF ; break; - case GAF : tempc = _GAF ; break; - case LAM : tempc = _LAM ; break; - case MIM : tempc = _MIM ; break; - case NOON : tempc = _NOON ; break; - case YE : - case YE_ : tempc = _YE ; break; - case YEE : - case YEE_ : tempc = _YEE ; break; - case IE : - case IE_ : tempc = _IE ; break; - case F_HE : - tempc = _HE; - - if (p_ri - && (curwin->w_cursor.col + 1 - < (colnr_T)STRLEN(get_cursor_line_ptr()))) { - inc_cursor(); - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { - tempc = _HE_; - } - dec_cursor(); - } - - if (!p_ri && STRLEN(get_cursor_line_ptr())) { - dec_cursor(); - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { - tempc = _HE_; - } - inc_cursor(); - } - - break; - - default: - tempc = 0; - } - - return tempc; -} - -/// Convert the given Farsi character into Farsi capital character. -/// -/// @param c The character to convert. -/// -/// @return Character converted to the Farsi capital leter. -static char_u toF_TyA(char_u c) -{ - char_u tempc; - - switch (c) { - case ALEF_ : tempc = ALEF ; break; - case ALEF_U_H_ : tempc = ALEF_U_H ; break; - 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 _AYN : - case AYN_ : - case _AYN_ : tempc = AYN ; break; - case _GHAYN : - case GHAYN_ : - case _GHAYN_ : tempc = GHAYN ; break; - case _FE : tempc = FE ; break; - case _GHAF : tempc = GHAF ; break; - case _KAF : tempc = KAF ; break; - case _GAF : tempc = GAF ; break; - case _LAM : tempc = LAM ; break; - case _MIM : tempc = MIM ; break; - case _NOON : tempc = NOON ; break; - case _YE : - case YE_ : tempc = YE ; break; - case _YEE : - case YEE_ : tempc = YEE ; break; - case TEE_ : tempc = TEE ; break; - case _IE : - case IE_ : tempc = IE ; break; - case _HE : - case _HE_ : tempc = F_HE ; break; - default : tempc = c ; - } - - return tempc; -} - -/// 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. -/// -/// @param src -/// @param offset -/// -/// @return true if the character under the cursor+offset is a join type. -static bool F_is_TyB_TyC_TyD(int src, int 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. -/// -/// @param c The character to check. -/// -/// @return true if the Farsi character is one of the terminating only types. -static bool F_is_TyE(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. -/// -/// @param c The character to check. -/// -/// @return true if the Farsi character is one of the none-leading types. -static bool F_is_TyC_TyD(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. -/// -/// @param c The character to convert. -/// -/// @return The character converted into a leading type. -static char_u toF_TyB(int c) -{ - char_u tempc; - - switch (c) { - case ALEF_ : tempc = ALEF ; break; - case ALEF_U_H_ : tempc = ALEF_U_H ; break; - case _AYN_ : tempc = _AYN ; break; - case AYN_ : tempc = AYN ; break; // exception - there are many - case _GHAYN_ : tempc = _GHAYN ; break; - case GHAYN_ : tempc = GHAYN ; break; // exception - there are many - 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: - assert(c >= 0 && c <= UCHAR_MAX); - tempc = (char_u)c; - } - - return tempc; -} - -/// Overwrite the current redo and cursor characters + left adjust -/// -/// @param c -static void put_curr_and_l_to_X(char_u c) -{ - int tempc; - - if (curwin->w_p_rl && p_ri) { - return; - } - - if ((curwin->w_cursor.col < (colnr_T)STRLEN(get_cursor_line_ptr()))) { - if (!p_ri || curwin->w_cursor.col) { - if (p_ri) { - dec_cursor(); - } else { - inc_cursor(); - } - - if (F_is_TyC_TyD((tempc = gchar_cursor()))) { - pchar_cursor(toF_TyB(tempc)); - AppendCharToRedobuff(K_BS); - AppendCharToRedobuff(tempc); - } - - if (p_ri) { - inc_cursor(); - } else { - dec_cursor(); - } - } - } - - put_and_redo(c); -} - -static void put_and_redo(char_u c) -{ - pchar_cursor(c); - AppendCharToRedobuff(K_BS); - AppendCharToRedobuff(c); -} - -/// Change the char. under the cursor to a X_ or X type -static void chg_c_toX_orX(void) -{ - int curc; - char_u tempc; - - 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 = F_HE ; break; - case _YE : - case _IE : - case _YEE : - if (p_ri) { - inc_cursor(); - - if (F_is_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 (F_is_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) { - put_and_redo(tempc); - } -} - -/// Change the char. under the cursor to a _X_ or X_ type -static void chg_c_to_X_orX_(void) -{ - char_u 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) { - put_and_redo(tempc); - } -} - -/// Change the char. under the cursor to a _X_ or _X type -static void chg_c_to_X_or_X(void) -{ - int tempc; - - tempc = gchar_cursor(); - - if (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(get_cursor_line_ptr())) { - inc_cursor(); - if ((tempc == F_HE) && (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))) { - tempc = _HE_; - dec_cursor(); - put_and_redo((char_u)tempc); - return; - } - dec_cursor(); - } - - if ((tempc = toF_Xor_X_(tempc)) != 0) { - put_and_redo((char_u)tempc); - } -} - -/// Change the character left to the cursor to a _X_ or X_ type -static void chg_l_to_X_orX_(void) -{ - int tempc; - - if ((curwin->w_cursor.col != 0) - && (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(get_cursor_line_ptr()))) { - 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) { - put_and_redo((char_u)tempc); - } - - if (p_ri) { - inc_cursor(); - } else { - dec_cursor(); - } -} - -/// Change the character left to the cursor to a X or _X type -static void chg_l_toXor_X(void) -{ - char_u tempc; - - if ((curwin->w_cursor.col != 0) - && (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(get_cursor_line_ptr()))) { - 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) { - put_and_redo(tempc); - } - - if (p_ri) { - inc_cursor(); - } else { - dec_cursor(); - } -} - -/// Change the character right to the cursor to a _X or _X_ type -static void chg_r_to_Xor_X_(void) -{ - int tempc; - char_u c; - - if (curwin->w_cursor.col) { - if (!p_ri) { - dec_cursor(); - } - - tempc = gchar_cursor(); - if ((c = toF_Xor_X_(tempc)) != 0) { - put_and_redo(c); - } - - if (!p_ri) { - inc_cursor(); - } - } -} - -/// Map Farsi keyboard when in fkmap mode. -int fkmap(int c) -{ - int tempc; - int insert_mode = (State & INSERT); - static int revins = 0; - - if (IS_SPECIAL(c)) { - return c; - } - - if (insert_mode) { - if (ascii_isdigit(c) - || ((c == '.' - || c == '+' - || c == '-' - || c == '^' - || c == '%' - || c == '#' - || c == '=') - && revins)) { - // Numbers are entered left-to-right. - 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; - (void)stop_arrow(); - - if (!curwin->w_p_rl && revins) { - inc_cursor(); - } - - revins++; - p_ri = 1; - } else { - if (revins) { - // Stop entering number. - arrow_used = true; - (void)stop_arrow(); - - revins = 0; - if (curwin->w_p_rl) { - while ((F_isdigit(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 ((F_isdigit(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 (!F_isdigit(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 && insert_mode) { - // If the char before the cursor is _X_ or X_ do not change - // the one under the cursor with X type. - - dec_cursor(); - if (F_isalpha(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 (insert_mode) { - 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((char_u)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 (F_is_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((char_u)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 (F_is_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((char_u)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 (F_is_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((char_u)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(get_cursor_line_ptr())) { - 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; - } - dec_cursor(); - } - - if (gchar_cursor() == _LAM) { - chg_c_toX_orX(); - chg_l_toXor_X(); - tempc = ALEF_U_H; - } else if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { - tempc = ALEF_U_H_; - chg_l_toXor_X(); - } else { - tempc = ALEF_U_H; - } - - if (!p_ri) { - inc_cursor(); - } - - return tempc; - - case 'h': - if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) { - if (p_ri) { - chg_c_to_X_or_X(); - } - } - - if (!p_ri) { - if (!curwin->w_cursor.col) { - return ALEF; - } - dec_cursor(); - } - - if (gchar_cursor() == _LAM) { - chg_l_toXor_X(); - del_char(false); - AppendCharToRedobuff(K_BS); - - if (!p_ri) { - dec_cursor(); - } - - tempc = LA; - } else { - if (F_is_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(get_cursor_line_ptr())) { - if (!p_ri && !F_is_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 (F_is_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(get_cursor_line_ptr())) { - if (p_ri) { - chg_c_to_X_or_X(); - } - } - - if (!p_ri) { - if (!curwin->w_cursor.col) { - return TEE; - } - dec_cursor(); - } - - if (F_is_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(get_cursor_line_ptr())) { - if (!p_ri && !F_is_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 (F_is_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(get_cursor_line_ptr())) { - if (!p_ri && !F_is_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 (F_is_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 ((F_isalpha(tempc) || F_isdigit(tempc))) { - if (!curwin->w_cursor.col && STRLEN(get_cursor_line_ptr())) { - if (!p_ri && !F_is_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 (F_is_TyE(tempc)) { - chg_l_toXor_X(); - } else { - chg_l_to_X_orX_(); - } - - if (!p_ri) { - inc_cursor(); - } - } - } - - if (tempc) { - return tempc; - } - return c; -} - -/// Convert a none leading Farsi char into a leading type. -/// -/// @param c The character to convert. -/// -/// @return The non-leading Farsi character converted to a leading type. -static char_u toF_leading(char_u c) -{ - char_u tempc; - - switch (c) { - case ALEF_ : tempc = ALEF ; break; - case ALEF_U_H_ : tempc = ALEF_U_H ; break; - 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 AYN : - case AYN_ : - case _AYN_ : tempc = _AYN ; break; - case GHAYN : - case GHAYN_ : - case _GHAYN_ : tempc = _GHAYN ; break; - case FE : tempc = _FE ; break; - case GHAF : tempc = _GHAF ; break; - case KAF : tempc = _KAF ; break; - case GAF : tempc = _GAF ; break; - case LAM : tempc = _LAM ; break; - case MIM : tempc = _MIM ; break; - case NOON : tempc = _NOON ; break; - case _HE_ : - case F_HE : tempc = _HE ; break; - case YE : - case YE_ : tempc = _YE ; break; - case IE_ : - case IE : tempc = _IE ; break; - case YEE : - case YEE_ : tempc = _YEE ; break; - default : tempc = c; - } - - return tempc; -} - -/// Convert a given Farsi char into right joining type. -/// -/// @param c The character to convert. -/// -/// @return The Farsi character converted into a right joining type -static char_u toF_Rjoin(char_u c) -{ - char_u tempc; - - switch (c) { - case ALEF : tempc = ALEF_ ; break; - case ALEF_U_H : tempc = ALEF_U_H_ ; break; - 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 AYN : - case AYN_ : - case _AYN : tempc = _AYN_ ; break; - case GHAYN : - case GHAYN_ : - case _GHAYN_ : tempc = _GHAYN_ ; break; - case FE : tempc = _FE ; break; - case GHAF : tempc = _GHAF ; break; - case KAF : tempc = _KAF ; break; - case GAF : tempc = _GAF ; break; - case LAM : tempc = _LAM ; break; - case MIM : tempc = _MIM ; break; - case NOON : tempc = _NOON ; break; - case _HE : - case F_HE : tempc = _HE_ ; break; - case YE : - case YE_ : tempc = _YE ; break; - case IE_ : - case IE : tempc = _IE ; break; - case TEE : tempc = TEE_ ; break; - case YEE : - case YEE_ : tempc = _YEE ; break; - default : tempc = c ; - } - - return tempc; -} - -/// Can a given Farsi character join via its left edj. -/// -/// @param c The character to check. -/// -/// @return true if the character can join via its left edj. -static bool canF_Ljoin(char_u 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 F_HE: - case _HE: - case _HE_: - return true; - } - return false; -} - -/// Can a given Farsi character join via its right edj. -/// -/// @param c -/// -/// @return true if the character can join via its right edj. -static bool canF_Rjoin(char_u 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. -/// -/// @param c -/// -/// @return true if the character is a terminating type. -static bool F_isterm(char_u 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 an ending type. -/// -/// @param c The character to convert. -/// -/// @return The character converted into an ending type. -static char_u toF_ending(char_u c) -{ - char_u tempc; - - switch (c) { - 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 _AYN : tempc = AYN ; break; - case _AYN_ : tempc = AYN_ ; break; - case _GHAYN : tempc = GHAYN ; break; - case _GHAYN_ : tempc = GHAYN_ ; 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 _LAM : tempc = LAM ; break; - case _MIM : tempc = MIM ; break; - case _NOON : tempc = NOON ; break; - case _YE : tempc = YE_ ; break; - case YE_ : tempc = YE ; break; - case _YEE : tempc = YEE_ ; break; - case YEE_ : tempc = YEE ; break; - case TEE : tempc = TEE_ ; break; - case _IE : tempc = IE_ ; break; - case IE_ : tempc = IE ; break; - case _HE : - case _HE_ : tempc = F_HE ; break; - default : tempc = c ; - } - - return tempc; -} - -/// Convert the Farsi 3342 standard into Farsi VIM. -static void conv_to_pvim(void) -{ - char_u *ptr; - int lnum, llen, i; - - for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) { - ptr = ml_get((linenr_T)lnum); - llen = (int)STRLEN(ptr); - for (i = 0; i < llen - 1; i++) { - if (canF_Ljoin(ptr[i]) && canF_Rjoin(ptr[i + 1])) { - ptr[i] = toF_leading(ptr[i]); - i++; - - while (i < llen && canF_Rjoin(ptr[i])) { - ptr[i] = toF_Rjoin(ptr[i]); - if (F_isterm(ptr[i]) || !F_isalpha(ptr[i])) { - break; - } - i++; - } - - if (!F_isalpha(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_cmd("%s/\202\231/\232/ge"); - do_cmdline_cmd("%s/\201\231/\370\334/ge"); - - // Assume the screen has been messed up: clear it and redraw. - redraw_later(NOT_VALID); - MSG_ATTR((const char *)farsi_text_1, HL_ATTR(HLF_S)); -} - -/// Convert the Farsi VIM into Farsi 3342 standard. -static void conv_to_pstd(void) -{ - char_u *ptr; - int lnum, llen, i; - - // Following line contains Farsi encoded character. - do_cmdline_cmd("%s/\232/\202\231/ge"); - for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { - ptr = ml_get((linenr_T)lnum); - llen = (int)STRLEN(ptr); - for (i = 0; i < llen; i++) { - ptr[i] = toF_TyA(ptr[i]); - } - } - - // Assume the screen has been messed up: clear it and redraw. - redraw_later(NOT_VALID); - msg_attr((const char *)farsi_text_2, HL_ATTR(HLF_S)); -} - -/// left-right swap the characters in buf[len]. -/// -/// @param buf -/// @param len -static void lrswapbuf(char_u *buf, int len) -{ - char_u *s, *e; - char_u c; - - s = buf; - e = buf + len - 1; - while (e > s) { - c = *s; - *s = *e; - *e = c; - ++s; - --e; - } -} - -/// swap all the characters in reverse direction -/// -/// @param ibuf -/// -/// @return The buffer with the characters swapped. -char_u* lrswap(char_u *ibuf) -{ - if ((ibuf != NULL) && (*ibuf != NUL)) { - lrswapbuf(ibuf, (int)STRLEN(ibuf)); - } - return ibuf; -} - -/// swap all the Farsi characters in reverse direction -/// -/// @param cmdbuf -/// @param . -/// -/// @return The buffer with all Farsi characters swapped. -char_u* lrFswap(char_u *cmdbuf, int len) -{ - int i, cnt; - if (cmdbuf == NULL) { - return cmdbuf; - } - - if ((len == 0) && ((len = (int)STRLEN(cmdbuf)) == 0)) { - return cmdbuf; - } - - for (i = 0; i < len; i++) { - for (cnt = 0; i + cnt < len - && (F_isalpha(cmdbuf[i + cnt]) - || F_isdigit(cmdbuf[i + cnt]) - || cmdbuf[i + cnt] == ' '); ++cnt) { - } - - lrswapbuf(cmdbuf + i, cnt); - i += cnt; - } - return cmdbuf; -} - -/// Reverse the characters in the search path and substitute section -/// accordingly. -/// TODO: handle different separator characters. Use skip_regexp(). -/// -/// @param ibuf -/// -/// @return The buffer with the characters in the search path and substitute -/// section reversed. -char_u* lrF_sub(char_u *ibuf) -{ - char_u *p, *ep; - int i, cnt; - - p = ibuf; - - // Find the boundary of the search path - while (((p = vim_strchr(p + 1, '/')) != NULL) && p[-1] == '\\') { - // empty - } - - if (p == NULL) { - return ibuf; - } - - // Reverse the Farsi characters in the search path. - lrFswap(ibuf, (int)(p - ibuf)); - - // Now find the boundary of the substitute section - if ((ep = (char_u *)strrchr((char *)++p, '/')) != NULL) { - cnt = (int)(ep - p); - } else { - cnt = (int)STRLEN(p); - } - - // Reverse the characters in the substitute section and take care of '\' - for (i = 0; i < cnt - 1; i++) { - if (p[i] == '\\') { - p[i] = p[i + 1]; - p[++i] = '\\'; - } - } - - lrswapbuf(p, cnt); - return ibuf; -} - -/// Map Farsi keyboard when in cmd_fkmap mode. -/// -/// @param c -/// -/// @return The mapped character. -int cmdl_fkmap(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((char_u)tempc), AT_CURSOR); - break; - - case _AYN_: - cmd_pchar(AYN_, AT_CURSOR); - break; - - case _GHAYN_: - cmd_pchar(GHAYN_, AT_CURSOR); - break; - - case _IE: - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR + 1)) { - cmd_pchar(IE_, AT_CURSOR); - } else { - cmd_pchar(IE, AT_CURSOR); - } - break; - - case _YEE: - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR + 1)) { - cmd_pchar(YEE_, AT_CURSOR); - } else { - cmd_pchar(YEE, AT_CURSOR); - } - break; - - case _YE: - if (F_is_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 (F_is_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); - redrawcmdline(); - return K_IGNORE; - } - - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) { - return ALEF_; - } else { - return ALEF; - } - - case 'i': - if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) { - return _HE_; - } else { - return _HE; - } - - case 'j': - return _TE; - - case 'J': - if (F_is_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 (F_is_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 (F_is_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; -} - -/// F_isalpha returns true if 'c' is in the Farsi alphabet. -/// -/// @param c The character to check. -/// -/// @return true if 'c' is a Farsi alphabet character. -bool F_isalpha(int c) -{ - return (c >= TEE_ && c <= _YE) - || (c >= ALEF_A && c <= YE) - || (c >= _IE && c <= YE_); -} - -/// F_isdigit returns true if 'c' is a Farsi digit -/// -/// @param c The character to check. -/// -/// @return true if 'c' is a Farsi digit. -bool F_isdigit(int c) -{ - return c >= FARSI_0 && c <= FARSI_9; -} - -/// F_ischar returns true if 'c' is a Farsi character. -/// -/// @param c The character to check. -/// -/// @return true if 'c' is a Farsi character. -bool F_ischar(int c) -{ - return c >= TEE_ && c <= YE_; -} - -void farsi_f8(cmdarg_T *cap FUNC_ATTR_UNUSED) -{ - if (p_altkeymap) { - if (curwin->w_farsi & W_R_L) { - p_fkmap = 0; - do_cmdline_cmd("set norl"); - MSG(""); - } else { - p_fkmap = 1; - do_cmdline_cmd("set rl"); - MSG(""); - } - - curwin->w_farsi = curwin->w_farsi ^ W_R_L; - } -} - -void farsi_f9(cmdarg_T *cap FUNC_ATTR_UNUSED) -{ - if (p_altkeymap && curwin->w_p_rl) { - curwin->w_farsi = curwin->w_farsi ^ W_CONV; - if (curwin->w_farsi & W_CONV) { - conv_to_pvim(); - } else { - conv_to_pstd(); - } - } -} diff --git a/src/nvim/farsi.h b/src/nvim/farsi.h deleted file mode 100644 index 003ea140f2..0000000000 --- a/src/nvim/farsi.h +++ /dev/null @@ -1,174 +0,0 @@ -/// @file farsi.h -/// -/// Farsi characters are categorized 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) - -#ifndef NVIM_FARSI_H -#define NVIM_FARSI_H - -#include "nvim/normal.h" -#include "nvim/types.h" - -// Farsi character set definition - -// Begin of the non-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 non-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 F_HE 0xe0 // F_ added for name clash with Perl -#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 - -// definitions for the window dependent functions (w_farsi). -#define W_CONV 0x1 -#define W_R_L 0x2 - -// special Farsi text messages -extern const char_u farsi_text_1[]; -extern const char_u farsi_text_2[]; -extern const char_u farsi_text_3[]; -extern const char_u farsi_text_5[]; - - -#ifdef INCLUDE_GENERATED_DECLARATIONS -# include "farsi.h.generated.h" -#endif -#endif // NVIM_FARSI_H diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index b24acb5ebb..139bf7b802 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -25,7 +25,6 @@ #include "nvim/eval.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" -#include "nvim/farsi.h" #include "nvim/func_attr.h" #include "nvim/main.h" #include "nvim/mbyte.h" @@ -2689,16 +2688,9 @@ do_map ( } } - /* - * When in right-to-left mode and alternate keymap option set, - * reverse the character flow in the rhs in Farsi. - */ - if (p_altkeymap && curwin->w_p_rl) - lrswap(rhs); - - /* - * check arguments and translate function keys - */ + // + // check arguments and translate function keys + // if (haskey) { len = (int)STRLEN(keys); if (len > MAXMAPLEN) { /* maximum length of MAXMAPLEN chars */ diff --git a/src/nvim/main.c b/src/nvim/main.c index c0dea196fb..251a54ad5b 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -424,16 +424,10 @@ int main(int argc, char **argv) p_ut = 1; } - if (curwin->w_p_rl && p_altkeymap) { - p_hkmap = FALSE; /* Reset the Hebrew keymap mode */ - curwin->w_p_arab = FALSE; /* Reset the Arabic keymap mode */ - p_fkmap = TRUE; /* Set the Farsi keymap mode */ - } - - /* - * Read in registers, history etc, from the ShaDa file. - * This is where v:oldfiles gets filled. - */ + // + // Read in registers, history etc, from the ShaDa file. + // This is where v:oldfiles gets filled. + // if (*p_shada != NUL) { shada_read_everything(NULL, false, true); TIME_MSG("reading ShaDa"); @@ -915,11 +909,6 @@ static void command_line_scan(mparm_T *parmp) case 'f': { // "-f" GUI: run in foreground. break; } - case 'F': { // "-F" start in Farsi mode: rl + fkmap set. - p_fkmap = true; - set_option_value("rl", 1L, NULL, 0); - break; - } case '?': // "-?" give help message (for MS-Windows) case 'h': { // "-h" give help message usage(); diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d361d81ac7..d857d1a79e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -28,7 +28,6 @@ #include "nvim/ex_cmds2.h" #include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" -#include "nvim/farsi.h" #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/getchar.h" @@ -340,8 +339,6 @@ static const struct nv_cmd { { K_F1, nv_help, NV_NCW, 0 }, { K_XF1, nv_help, NV_NCW, 0 }, { K_SELECT, nv_select, 0, 0 }, - { K_F8, farsi_f8, 0, 0 }, - { K_F9, farsi_f9, 0, 0 }, { K_EVENT, nv_event, NV_KEEPREG, 0 }, { K_COMMAND, nv_colon, 0, 0 }, }; @@ -719,10 +716,6 @@ static void normal_get_additional_char(NormalState *s) if (p_hkmap && lang && KeyTyped) { *cp = hkmap(*cp); } - // adjust Farsi mapped char - if (p_fkmap && lang && KeyTyped) { - *cp = fkmap(*cp); - } } // When the next character is CTRL-\ a following CTRL-N means the diff --git a/src/nvim/option.c b/src/nvim/option.c index fc1fab834e..2346c84b54 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3945,51 +3945,6 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, if (errmsg != NULL) EMSG(_(errmsg)); } - } else if ((int *)varp == &p_altkeymap) { - if (old_value != p_altkeymap) { - if (!p_altkeymap) { - p_hkmap = p_fkmap; - p_fkmap = 0; - } else { - p_fkmap = p_hkmap; - p_hkmap = 0; - } - (void)init_chartab(); - } - } - - /* - * In case some second language keymapping options have changed, check - * and correct the setting in a consistent way. - */ - - /* - * If hkmap or fkmap are set, reset Arabic keymapping. - */ - if ((p_hkmap || p_fkmap) && p_altkeymap) { - p_altkeymap = p_fkmap; - curwin->w_p_arab = FALSE; - (void)init_chartab(); - } - - /* - * If hkmap set, reset Farsi keymapping. - */ - if (p_hkmap && p_altkeymap) { - p_altkeymap = 0; - p_fkmap = 0; - curwin->w_p_arab = FALSE; - (void)init_chartab(); - } - - /* - * If fkmap set, reset Hebrew keymapping. - */ - if (p_fkmap && !p_altkeymap) { - p_altkeymap = 1; - p_hkmap = 0; - curwin->w_p_arab = FALSE; - (void)init_chartab(); } if ((int *)varp == &curwin->w_p_arab) { @@ -4027,10 +3982,6 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, // Force-set the necessary keymap for arabic. set_option_value("keymap", 0L, "arabic", OPT_LOCAL); - p_altkeymap = 0; - p_hkmap = 0; - p_fkmap = 0; - (void)init_chartab(); } else { /* * 'arabic' is reset, handle various sub-settings. @@ -5664,8 +5615,6 @@ void win_copy_options(win_T *wp_from, win_T *wp_to) { copy_winopt(&wp_from->w_onebuf_opt, &wp_to->w_onebuf_opt); copy_winopt(&wp_from->w_allbuf_opt, &wp_to->w_allbuf_opt); - /* Is this right? */ - wp_to->w_farsi = wp_from->w_farsi; } /* diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index ccb0496495..6dc5e418fc 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -464,8 +464,6 @@ EXTERN int p_hls; // 'hlsearch' EXTERN long p_hi; // 'history' EXTERN int p_hkmap; // 'hkmap' EXTERN int p_hkmapp; // 'hkmapp' -EXTERN int p_fkmap; // 'fkmap' -EXTERN int p_altkeymap; // 'altkeymap' EXTERN int p_arshape; // 'arabicshape' EXTERN int p_icon; // 'icon' EXTERN char_u *p_iconstring; // 'iconstring' diff --git a/src/nvim/options.lua b/src/nvim/options.lua index b8f128103c..2398f9d61c 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -82,13 +82,6 @@ return { defaults={if_true={vi=false}} }, { - full_name='altkeymap', abbreviation='akm', - type='bool', scope={'global'}, - vi_def=true, - varname='p_altkeymap', - defaults={if_true={vi=false}} - }, - { full_name='ambiwidth', abbreviation='ambw', type='string', scope={'global'}, vi_def=true, @@ -822,13 +815,6 @@ return { defaults={if_true={vi=true}} }, { - full_name='fkmap', abbreviation='fk', - type='bool', scope={'global'}, - vi_def=true, - varname='p_fkmap', - defaults={if_true={vi=false}} - }, - { full_name='foldclose', abbreviation='fcl', type='string', list='onecomma', scope={'global'}, deny_duplicates=true, diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 5ac90ab601..81d463a70c 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -80,7 +80,6 @@ #include "nvim/ex_cmds2.h" #include "nvim/ex_getln.h" #include "nvim/edit.h" -#include "nvim/farsi.h" #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/indent.h" @@ -6499,9 +6498,6 @@ int showmode(void) if (p_hkmap) { MSG_PUTS_ATTR(_(" Hebrew"), attr); } - if (p_fkmap) { - MSG_PUTS_ATTR(farsi_text_5, attr); - } if (State & LANGMAP) { if (curwin->w_p_arab) { MSG_PUTS_ATTR(_(" Arabic"), attr); diff --git a/src/nvim/search.c b/src/nvim/search.c index 5f0ff96f95..d635763acc 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -21,7 +21,6 @@ #include "nvim/ex_cmds.h" #include "nvim/ex_cmds2.h" #include "nvim/ex_getln.h" -#include "nvim/farsi.h" #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/func_attr.h" @@ -1198,18 +1197,14 @@ int do_search( } } - if (p_altkeymap && curwin->w_p_rl) - lrFswap(searchstr,0); - c = searchit(curwin, curbuf, &pos, dirc == '/' ? FORWARD : BACKWARD, - searchstr, count, (spats[0].off.end * SEARCH_END - + (options & - (SEARCH_KEEP + SEARCH_PEEK + - SEARCH_HIS - + SEARCH_MSG + SEARCH_START - + ((pat != NULL && *pat == - ';') ? 0 : SEARCH_NOOF)))), - RE_LAST, (linenr_T)0, tm); + searchstr, count, + (spats[0].off.end * SEARCH_END + + (options + & (SEARCH_KEEP + SEARCH_PEEK + SEARCH_HIS + SEARCH_MSG + + SEARCH_START + + ((pat != NULL && *pat == ';') ? 0 : SEARCH_NOOF)))), + RE_LAST, (linenr_T)0, tm); if (dircp != NULL) *dircp = dirc; /* restore second '/' or '?' for normal_cmd() */ @@ -2470,9 +2465,6 @@ static int cls(void) int c; c = gchar_cursor(); - if (p_altkeymap && c == F_BLANK) { - return 0; - } if (c == ' ' || c == '\t' || c == NUL) { return 0; } diff --git a/src/nvim/testdir/test_farsi.vim b/src/nvim/testdir/test_farsi.vim deleted file mode 100644 index 9ff2653af4..0000000000 --- a/src/nvim/testdir/test_farsi.vim +++ /dev/null @@ -1,133 +0,0 @@ -" Simplistic testing of Farsi mode. -" Note: must be edited with latin1 encoding. - -if !has('farsi') || has('nvim') " Not supported in Nvim. #6192 - finish -endif -" Farsi uses a single byte encoding. -set enc=latin1 - -func Test_farsi_toggle() - new - - set altkeymap - call assert_equal(0, &fkmap) - call assert_equal(0, &rl) - call feedkeys("\<F8>", 'x') - call assert_equal(1, &fkmap) - call assert_equal(1, &rl) - call feedkeys("\<F8>", 'x') - call assert_equal(0, &fkmap) - call assert_equal(0, &rl) - - set rl - " conversion from Farsi 3342 to Farsi VIM. - call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), '')) - call feedkeys("\<F9>", 'x') - let exp = [0xfc, 0xf8, 0xc1, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - \ 0xc8, 0xc9, 0xca, 0xd0, 0xd1, 0xd2, 0xd3, 0xd6, - \ 0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd9, 0xda, - \ 0xdb, 0xdc, 0xdc, 0xc1, 0xdd, 0xde, 0xe0, 0xe0, - \ 0xe1, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, - \ 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, - \ 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - \ 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, - \ 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, - \ 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, - \ 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, - \ 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, - \ 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, - \ 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xfb, 0xfb, 0xfe, - \ 0xfe, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, - \ 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xe1, - \ ] - call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1)) - - " conversion from Farsi VIM to Farsi 3342. - call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), '')) - call feedkeys("\<F9>", 'x') - let exp = [0xfc, 0xf8, 0xc1, 0x83, 0x84, 0x85, 0x86, 0x87, - \ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x90, - \ 0x90, 0x90, 0x92, 0x93, 0x93, 0x95, 0x96, 0x97, - \ 0x98, 0xdc, 0x9a, 0x9b, 0x9c, 0x9e, 0x9e, 0xff, - \ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - \ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - \ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - \ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - \ 0xc0, 0xc1, 0xc2, 0x83, 0x84, 0x85, 0x86, 0x87, - \ 0x88, 0x89, 0x8a, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - \ 0x8b, 0x8c, 0x8d, 0x8e, 0xd4, 0xd5, 0x90, 0x93, - \ 0x95, 0x96, 0x97, 0x98, 0x99, 0x9b, 0x9c, 0xdf, - \ 0x9d, 0xff, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - \ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xec, 0xee, 0xef, - \ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - \ 0xf8, 0xf9, 0xfa, 0xec, 0x80, 0xfd, 0xee, 0xff, - \ ] - call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1)) - - bwipe! -endfunc - -func Test_farsi_map() - new - - set altkeymap - set rl - " RHS of mapping is reversed. - imap xyz abc - call feedkeys("axyz\<Esc>", 'tx') - call assert_equal('cba', getline(1)) - - set norl - iunmap xyz - set noaltkeymap - bwipe! -endfunc - -func Test_input_farsi() - new - setlocal rightleft fkmap - " numbers switch input direction - call feedkeys("aabc0123456789.+-^%#=xyz\<Esc>", 'tx') - call assert_equal("\x8cÌν®¥ª«¦¹¸·¶µ´³²±°Ô\x93Õ", getline('.')) - - " all non-number special chars with spaces - call feedkeys("oB E F H I K L M O P Q R T U W Y ` ! @ # $ % ^ & * () - _ = + \\ | : \" . / < > ? \<Esc>", 'tx') - call assert_equal("¡ ô ú À ö æ ç  [ ] ÷ ó ò ð õ ñ ¢ £ § ® ¤ ¥ ª ¬ è ¨© é ½ « ë ê º » ¦ ¯ ¾ ¼ ¿ ", getline('.')) - - " all non-number special chars without spaces - call feedkeys("oBEFHIKLMOPQRTUWY`!@#$%^&*()-_=+\\|:\"./<>?\<Esc>",'tx') - call assert_equal("¡ôúÀöæçÂ[]÷óòðõñ¢£§®¤¥ª¬è¨©é½«ë꺻¦¯¾¼¿", getline('.')) - - " all letter chars with spaces - call feedkeys("oa A b c C d D e f g G h i j J k l m n N o p q r s S t u v V w x X y z Z ; \ , [ ] \<Esc>", 'tx') - call assert_equal("Ñ ù Ì Î Ï á þ Æ Ã Ü ø Á à Å ü Þ Ý Ä Ë Ë Ê É Ó Ù Ð û Ø Ö Í Í Ò Ô Ô × Õ ý Ú ß Ç È ", getline('.')) - - " all letter chars without spaces - call feedkeys("oaAbcCdDefgGhijJklmnNopqrsStuvVwxXyzZ;\,[]\<Esc>", 'tx') - call assert_equal("\x8cùÌÎÏ\x9fî\x86\x83ÜøÁ\x9d\x85\x80\x9c\x9b\x84ËË\x8a\x89\x8e\x96\x8bì\x95\x90ÍÍ\x8dÔÔ\x93Õý\x97ß\x87\x88", getline('.')) - - bwipe! -endfunc - -func Test_command_line_farsi() - set allowrevins altkeymap - - " letter characters with spaces - call feedkeys(":\"\<C-_>a A b c C d D e f g G h i j J k l m n N o p q r s S t u v V w x X y z Z ; \\ , [ ]\<CR>", 'tx') - call assert_equal("\"\x88 Ç ß ë Ú Õ Õ × Ô Ô Ò Í Í Ö Ø û Ð Ù Ó É Ê Ë Ë Ä Ý Þ ü Å à Á ø Ü Ã Æ þ á Ï Î Ì ù Ñ", getreg(':')) - - " letter characters without spaces - call feedkeys(":\"\<C-_>aAbcCdDefgGhijJklmnNopqrsStuvVwxXyzZ;\\,[]\<CR>", 'tx') - call assert_equal("\"\x88\x87ßëÚÕÕ\x93ÔÔ\x8dÍÍ\x90\x95ì\x8b\x96\x8e\x89\x8aËË\x84\x9b\x9c\x80\x85\x9dÁøÜ\x83\x86î\x9fÏÎÌù\x8c", getreg(':')) - - " other characters with spaces - call feedkeys(":\"\<C-_>0 1 2 3 4 5 6 7 8 9 ` . ! \" $ % ^ & / () = \\ ? + - _ * : # ~ @ < > { } | B E F H I K L M O P Q R T U W Y\<CR>", 'tx') - call assert_equal("\"ñ õ ð ò ó ÷ ] [ Â ç æ ö À ú ô ¡ ê } { ¼ ¾ § ~ ® º è é « ¿ ë ½ ©¨ ¯ ¬ ª ¥ ¤ » £ ¦ ¢ ¹ ¸ · ¶ µ ´ ³ ² ± °", getreg(':')) - - " other characters without spaces - call feedkeys(":\"\<C-_>0123456789`.!\"$%^&/()=\\?+-_*:#~@<>{}|BEFHIKLMOPQRTUWY\<CR>", 'tx') - call assert_equal("\"ñõðòó÷][ÂçæöÀúô¡ê}{¼¾§~®ºè髿뽩¨¯¬ª¥¤»£¦¢¹¸·¶µ´³²±°", getreg(':')) - - set noallowrevins noaltkeymap -endfunc diff --git a/src/nvim/window.c b/src/nvim/window.c index 24fe529fd6..bb71b12aed 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -20,7 +20,6 @@ #include "nvim/ex_docmd.h" #include "nvim/ex_eval.h" #include "nvim/ex_getln.h" -#include "nvim/farsi.h" #include "nvim/fileio.h" #include "nvim/fold.h" #include "nvim/getchar.h" @@ -2934,10 +2933,6 @@ void win_init_empty(win_T *wp) wp->w_topline = 1; wp->w_topfill = 0; wp->w_botline = 2; - if (wp->w_p_rl) - wp->w_farsi = W_CONV + W_R_L; - else - wp->w_farsi = W_CONV; wp->w_s = &wp->w_buffer->b_s; } |