diff options
48 files changed, 2636 insertions, 2217 deletions
diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 4af13a3bbf..fa2f8f974a 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -826,6 +826,7 @@ nvim_eval_statusline({str}, {*opts}) *nvim_eval_statusline()* • maxwidth: (number) Maximum width of statusline. • fillchar: (string) Character to fill blank spaces in the statusline (see 'fillchars'). + Treated as single-width even if it isn't. • highlights: (boolean) Return highlight information. • use_tabline: (boolean) Evaluate tabline instead @@ -1547,6 +1548,11 @@ nvim_set_current_win({window}) *nvim_set_current_win()* nvim_set_hl({ns_id}, {name}, {*val}) *nvim_set_hl()* Sets a highlight group. + Note: Unlike the `:highlight` command which can update a + highlight group, this function completely replaces the + definition. For example: `nvim_set_hl(0, 'Visual', {})` will + clear the highlight group 'Visual'. + Parameters: ~ {ns_id} Namespace id for this highlight |nvim_create_namespace()|. Use 0 to set a @@ -1937,7 +1943,7 @@ nvim_buf_attach({buffer}, {send_buffer}, {opts}) *nvim_buf_attach()* • on_reload: Lua callback invoked on reload. The entire buffer content should be considered changed. Args: - • the string "detach" + • the string "reload" • buffer handle • utf_sizes: include UTF-32 and UTF-16 size @@ -2215,7 +2221,7 @@ nvim_buf_is_valid({buffer}) *nvim_buf_is_valid()* true if the buffer is valid, false otherwise. nvim_buf_line_count({buffer}) *nvim_buf_line_count()* - Gets the buffer line count + Returns the number of lines in the given buffer. Parameters: ~ {buffer} Buffer handle, or 0 for current buffer @@ -2582,6 +2588,35 @@ nvim_buf_set_extmark({buffer}, {ns_id}, {line}, {col}, {*opts}) not be placed if the line or column value is past the end of the buffer or end of the line respectively. Defaults to true. + • sign_text: string of length 1-2 used to + display in the sign column. Note: ranges are + unsupported and decorations are only applied + to start_row + • sign_hl_group: name of the highlight group + used to highlight the sign column text. Note: + ranges are unsupported and decorations are + only applied to start_row + • number_hl_group: name of the highlight group + used to highlight the number column. Note: + ranges are unsupported and decorations are + only applied to start_row + • line_hl_group: name of the highlight group + used to highlight the whole line. Note: ranges + are unsupported and decorations are only + applied to start_row + • cursorline_hl_group: name of the highlight + group used to highlight the line when the + cursor is on the same line as the mark and + 'cursorline' is enabled. Note: ranges are + unsupported and decorations are only applied + to start_row + • conceal: string which should be either empty + or a single character. Enable concealing + similar to |:syn-conceal|. When a character is + supplied it is used as |:syn-cchar|. + "hl_group" is used as highlight for the cchar + if provided, otherwise it defaults to + |hl-Conceal|. Return: ~ Id of the created/updated extmark @@ -2816,7 +2851,8 @@ nvim_win_set_buf({window}, {buffer}) *nvim_win_set_buf()* nvim_win_set_cursor({window}, {pos}) *nvim_win_set_cursor()* Sets the (1,0)-indexed cursor position in the window. - |api-indexing| + |api-indexing| This scrolls the window even if it is not the + current one. Parameters: ~ {window} Window handle, or 0 for current window @@ -3001,9 +3037,10 @@ nvim_open_win({buffer}, {enter}, {*config}) *nvim_open_win()* ">", "", "", "", "<" ] will only make vertical borders but not horizontal ones. By default, `FloatBorder` highlight is used, - which links to `VertSplit` when not defined. - It could also be specified by character: [ - {"+", "MyCorner"}, {"x", "MyBorder"} ]. + which links to `WinSeparator` when not + defined. It could also be specified by + character: [ {"+", "MyCorner"}, {"x", + "MyBorder"} ]. • noautocmd: If true then no buffer-related autocommand events such as |BufEnter|, diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 9eec23b7b7..14353662d1 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -8152,7 +8152,7 @@ taglist({expr} [, {filename}]) *taglist()* entry depends on the language specific kind values. Only available when using a tags file generated by - Exuberant ctags or hdrtag. + Universal/Exuberant ctags or hdrtag. static A file specific tag. Refer to |static-tag| for more information. More entries may be present, depending on the content of the diff --git a/runtime/doc/ft_ada.txt b/runtime/doc/ft_ada.txt index 771ccc3302..f6dfa708fb 100644 --- a/runtime/doc/ft_ada.txt +++ b/runtime/doc/ft_ada.txt @@ -89,9 +89,9 @@ file is opened and adds Ada related entries to the main and pop-up menu. *ft-ada-omni* The Ada omni-completions (|i_CTRL-X_CTRL-O|) uses tags database created either -by "gnat xref -v" or the "exuberant Ctags (http://ctags.sourceforge.net). The -complete function will automatically detect which tool was used to create the -tags file. +by "gnat xref -v" or the "Universal Ctags" (https://ctags.io). The complete +function will automatically detect which tool was used to create the tags +file. ------------------------------------------------------------------------------ 3.1 Omni Completion with "gnat xref" ~ @@ -125,18 +125,18 @@ NOTE: "gnat xref -v" is very tricky to use as it has almost no diagnostic 3.2 Omni Completion with "ctags"~ *ada-ctags* -Exuberant Ctags uses its own multi-language code parser. The parser is quite -fast, produces a lot of extra information (hence the name "Exuberant Ctags") -and can run on files which currently do not compile. +Universal/Exuberant Ctags use their own multi-language code parser. The +parser is quite fast, produces a lot of extra information and can run on files +which currently do not compile. -There are also lots of other Vim-tools which use exuberant Ctags. +There are also lots of other Vim-tools which use Universal/Exuberant Ctags. +Universal Ctags is preferred, Exuberant Ctags is no longer being developed. -You will need to install a version of the Exuberant Ctags which has Ada -support patched in. Such a version is available from the GNU Ada Project -(http://gnuada.sourceforge.net). +You will need to install Universal Ctags which is available from +https://ctags.io -The Ada parser for Exuberant Ctags is fairly new - don't expect complete -support yet. +The Ada parser for Universal/Exuberant Ctags is fairly new - don't expect +complete support yet. ============================================================================== 4. Compiler Support ~ diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt index d9aecfe4fd..cd6c2c8622 100644 --- a/runtime/doc/insert.txt +++ b/runtime/doc/insert.txt @@ -1342,11 +1342,16 @@ in 'runtimepath'. Thus for "java" it is autoload/javacomplete.vim. C *ft-c-omni* -Completion of C code requires a tags file. You should use Exuberant ctags, -because it adds extra information that is needed for completion. You can find -it here: http://ctags.sourceforge.net/ Version 5.6 or later is recommended. +Completion of C code requires a tags file. You should use Universal/ +Exuberant ctags, because it adds extra information that is needed for +completion. You can find it here: + Universal Ctags: https://ctags.io + Exuberant Ctags: http://ctags.sourceforge.net -For version 5.5.4 you should add a patch that adds the "typename:" field: +Universal Ctags is preferred, Exuberant Ctags is no longer being developed. + +For Exuberant ctags, version 5.6 or later is recommended. For version 5.5.4 +you should add a patch that adds the "typename:" field: ftp://ftp.vim.org/pub/vim/unstable/patches/ctags-5.5.4.patch A compiled .exe for MS-Windows can be found at: http://ctags.sourceforge.net/ @@ -1467,8 +1472,11 @@ will be suggested. All other elements are not placed in suggestion list. PHP *ft-php-omni* Completion of PHP code requires a tags file for completion of data from -external files and for class aware completion. You should use Exuberant ctags -version 5.5.4 or newer. You can find it here: http://ctags.sourceforge.net/ +external files and for class aware completion. You should use Universal/ +Exuberant ctags version 5.5.4 or newer. You can find it here: + + Universal Ctags: https://ctags.io + Exuberant Ctags: http://ctags.sourceforge.net Script completes: diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index a9ebcd27ae..9dfc65f999 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -686,7 +686,11 @@ formatexpr({opts}) *vim.lsp.formatexpr()* Provides an interface between the built-in client and a `formatexpr` function. - Currently only supports a single client. This can be set via `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will typically or in `on_attach` via vim.api.nvim_buf_set_option(bufnr, 'formatexpr , 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`. + Currently only supports a single client. This can be set via + `setlocal formatexpr=v:lua.vim.lsp.formatexpr()` but will + typically or in `on_attach` via + `vim.api.nvim_buf_set_option(bufnr, 'formatexpr', + 'v:lua.vim.lsp.formatexpr(#{timeout_ms:250})')`. Parameters: ~ {opts} table options for customizing the formatting @@ -1458,17 +1462,17 @@ extract_completion_items({result}) https://microsoft.github.io/language-server-protocol/specification#textDocument_completion get_effective_tabstop({bufnr}) *vim.lsp.util.get_effective_tabstop()* - Returns visual width of tabstop. + Returns indentation size. Parameters: ~ {bufnr} (optional, number): Buffer handle, defaults to current Return: ~ - (number) tabstop visual width + (number) indentation size See also: ~ - |softtabstop| + |shiftwidth| *vim.lsp.util.jump_to_location()* jump_to_location({location}, {offset_encoding}) diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 93386ddfe9..bd821c4f9e 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -1259,6 +1259,10 @@ vim.wo *vim.wo* ============================================================================== Lua module: vim *lua-vim* + *vim.connection_failure_errmsg()* +connection_failure_errmsg({consequence}) + TODO: Documentation + defer_fn({fn}, {timeout}) *vim.defer_fn()* Defers calling `fn` until `timeout` ms passes. @@ -1550,7 +1554,7 @@ startswith({s}, {prefix}) *vim.startswith()* tbl_add_reverse_lookup({o}) *vim.tbl_add_reverse_lookup()* Add the reverse lookup values to an existing table. For - example: tbl_add_reverse_lookup { A = 1 } == { [1] = 'A , A = 1 }` + example: `tbl_add_reverse_lookup { A = 1 } == { [1] = 'A', A = 1 }` Parameters: ~ {o} table The table to add the reverse to. @@ -1990,7 +1994,7 @@ set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* vim.keymap.set('n', 'asdf', require('jkl').my_fun) < - the require('jkl )` gets evaluated during this call in order to access the + the `require('jkl')` gets evaluated during this call in order to access the function. If you want to avoid this cost at startup you can wrap it in a function, for example: > diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index b2bbf5ddad..8323ec3e9d 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6333,9 +6333,10 @@ A jump table for the options with a short description can be found at |Q_op|. linear search can be avoided when case is ignored. Use a value of '2' in the "!_TAG_FILE_SORTED" line for this. A tag file can be case-fold sorted with the -f switch to "sort" in most unices, as in the command: - "sort -f -o tags tags". For "Exuberant ctags" version 5.x or higher - (at least 5.5) the --sort=foldcase switch can be used for this as - well. Note that case must be folded to uppercase for this to work. + "sort -f -o tags tags". For Universal ctags and Exuberant ctags + version 5.x or higher (at least 5.5) the --sort=foldcase switch can be + used for this as well. Note that case must be folded to uppercase for + this to work. By default, tag searches are case-sensitive. Case is ignored when 'ignorecase' is set and 'tagcase' is "followic", or when 'tagcase' is diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 0ff31e81ab..2af4ec1549 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -5363,11 +5363,12 @@ WARNING: The longer the tags file, the slower this will be, and the more memory Vim will consume. Only highlighting typedefs, unions and structs can be done too. For this you -must use Exuberant ctags (found at http://ctags.sf.net). +must use Universal Ctags (found at https://ctags.io) or Exuberant ctags (found +at http://ctags.sf.net). Put these lines in your Makefile: -# Make a highlight file for types. Requires Exuberant ctags and awk +# Make a highlight file for types. Requires Universal/Exuberant ctags and awk types: types.vim types.vim: *.[ch] ctags --c-kinds=gstu -o- *.[ch] |\ diff --git a/runtime/doc/tagsrch.txt b/runtime/doc/tagsrch.txt index 5a0d16d6b8..2485290667 100644 --- a/runtime/doc/tagsrch.txt +++ b/runtime/doc/tagsrch.txt @@ -544,7 +544,8 @@ also works. The <CR> and <NL> characters can never appear inside a line. The second format is new. It includes additional information in optional fields at the end of each line. It is backwards compatible with Vi. It is -only supported by new versions of ctags (such as Exuberant ctags). +only supported by new versions of ctags (such as Universal ctags or Exuberant +ctags). {tagname} The identifier. Normally the name of a function, but it can be any identifier. It cannot contain a <Tab>. diff --git a/runtime/doc/usr_29.txt b/runtime/doc/usr_29.txt index 3381d1870c..d8c556c281 100644 --- a/runtime/doc/usr_29.txt +++ b/runtime/doc/usr_29.txt @@ -33,10 +33,12 @@ following command: > ctags *.c "ctags" is a separate program. Most Unix systems already have it installed. -If you do not have it yet, you can find Exuberant ctags here: - +If you do not have it yet, you can find Universal/Exuberant ctags at: + http://ctags.io ~ http://ctags.sf.net ~ +Universal ctags is preferred, Exuberant ctags is no longer being developed. + Now when you are in Vim and you want to go to a function definition, you can jump to it by using the following command: > @@ -142,15 +144,15 @@ ONE TAGS FILE When Vim has to search many places for tags files, you can hear the disk rattling. It may get a bit slow. In that case it's better to spend this time while generating one big tags file. You might do this overnight. - This requires the Exuberant ctags program, mentioned above. It offers an -argument to search a whole directory tree: > + This requires the Universal or Exuberant ctags program, mentioned above. +It offers an argument to search a whole directory tree: > cd ~/proj ctags -R . -The nice thing about this is that Exuberant ctags recognizes various file -types. Thus this doesn't work just for C and C++ programs, also for Eiffel -and even Vim scripts. See the ctags documentation to tune this. +The nice thing about this is that Universal/Exuberant ctags recognizes various +file types. Thus this doesn't work just for C and C++ programs, also for +Eiffel and even Vim scripts. See the ctags documentation to tune this. Now you only need to tell Vim where your big tags file is: > :set tags=~/proj/tags @@ -232,7 +234,8 @@ A TAGS BROWSER Since CTRL-] takes you to the definition of the identifier under the cursor, you can use a list of identifier names as a table of contents. Here is an example. - First create a list of identifiers (this requires Exuberant ctags): > + First create a list of identifiers (this requires Universal or Exuberant +ctags): > ctags --c-types=f -f functions *.c diff --git a/runtime/ftplugin/liquid.vim b/runtime/ftplugin/liquid.vim index b211a884c6..f24ec4cbb2 100644 --- a/runtime/ftplugin/liquid.vim +++ b/runtime/ftplugin/liquid.vim @@ -1,7 +1,7 @@ " Vim filetype plugin " Language: Liquid " Maintainer: Tim Pope <vimNOSPAM@tpope.org> -" Last Change: 2010 May 21 +" Last Change: 2022 Mar 15 if exists('b:did_ftplugin') finish @@ -53,7 +53,7 @@ if has('gui_win32') endif if exists('loaded_matchit') - let b:match_words .= '\<\%(if\w*\|unless\|case\)\>:\<\%(elsif\|else\|when\)\>:\<end\%(if\w*\|unless\|case\)\>,\<\%(for\|tablerow\)\>:\%({%\s*\)\@<=empty\>:\<end\%(for\|tablerow\)\>,<\(capture\|comment\|highlight\)\>:\<end\1\>' + let b:match_words .= '\<\%(if\w*\|unless\|case\)\>:\<\%(elsif\|else\|when\)\>:\<end\%(if\w*\|unless\|case\)\>,\<\%(for\|tablerow\)\>:\%({%\s*\)\@<=empty\>:\<end\%(for\|tablerow\)\>,\<\(capture\|comment\|highlight\)\>:\<end\1\>' endif setlocal commentstring={%\ comment\ %}%s{%\ endcomment\ %} diff --git a/runtime/ftplugin/php.vim b/runtime/ftplugin/php.vim index 3ff0828ffe..2824a5853b 100644 --- a/runtime/ftplugin/php.vim +++ b/runtime/ftplugin/php.vim @@ -73,10 +73,11 @@ exe 'nno <buffer> <silent> ]] /' . escape(s:section, '|') . '/<CR>:nohls<CR>' exe 'ono <buffer> <silent> [[ ?' . escape(s:section, '|') . '?<CR>:nohls<CR>' exe 'ono <buffer> <silent> ]] /' . escape(s:section, '|') . '/<CR>:nohls<CR>' +setlocal suffixesadd=.php setlocal commentstring=/*%s*/ " Undo the stuff we changed. -let b:undo_ftplugin = "setlocal commentstring< include< omnifunc<" . +let b:undo_ftplugin = "setlocal suffixesadd< commentstring< include< omnifunc<" . \ " | unlet! b:browsefilter b:match_words | " . \ s:undo_ftplugin diff --git a/runtime/indent/bst.vim b/runtime/indent/bst.vim index 47e3058810..3dd8d711a8 100644 --- a/runtime/indent/bst.vim +++ b/runtime/indent/bst.vim @@ -1,20 +1,18 @@ " Vim indent file " Language: bst " Author: Tim Pope <vimNOSPAM@tpope.info> -" $Id: bst.vim,v 1.1 2007/05/05 18:11:12 vimboss Exp $ +" Last Change: 2022 Mar 15 if exists("b:did_indent") finish endif let b:did_indent = 1 -setlocal expandtab setlocal indentexpr=GetBstIndent(v:lnum) -"setlocal smartindent setlocal cinkeys& setlocal cinkeys-=0# setlocal indentkeys& -"setlocal indentkeys+=0% +let b:undo_indent = 'setlocal indentexpr< cinkeys< indentkeys<' " Only define the function once. if exists("*GetBstIndent") diff --git a/runtime/indent/haml.vim b/runtime/indent/haml.vim index baca1d49d9..acd99d9c7d 100644 --- a/runtime/indent/haml.vim +++ b/runtime/indent/haml.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Haml " Maintainer: Tim Pope <vimNOSPAM@tpope.org> -" Last Change: 2019 Dec 05 +" Last Change: 2022 Mar 15 if exists("b:did_indent") finish @@ -14,6 +14,8 @@ setlocal autoindent setlocal indentexpr=GetHamlIndent() setlocal indentkeys=o,O,*<Return>,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when +let b:undo_indent = "setl ai< inde< indk<" + " Only define the function once. if exists("*GetHamlIndent") finish diff --git a/runtime/indent/liquid.vim b/runtime/indent/liquid.vim index 7beb0388d1..6fc933797e 100644 --- a/runtime/indent/liquid.vim +++ b/runtime/indent/liquid.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Liquid " Maintainer: Tim Pope <vimNOSPAM@tpope.org> -" Last Change: 2017 Jun 13 +" Last Change: 2022 Mar 15 if exists('b:did_indent') finish @@ -29,17 +29,19 @@ let b:did_indent = 1 setlocal indentexpr=GetLiquidIndent() setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=endif,=endunless,=endifchanged,=endcase,=endfor,=endtablerow,=endcapture,=else,=elsif,=when,=empty +let b:undo_indent = "setl inde< indk<" + " Only define the function once. if exists('*GetLiquidIndent') finish endif -function! s:count(string,pattern) +function! s:count(string, pattern) abort let string = substitute(a:string,'\C'.a:pattern,"\n",'g') return strlen(substitute(string,"[^\n]",'','g')) endfunction -function! GetLiquidIndent(...) +function! GetLiquidIndent(...) abort if a:0 && a:1 == '.' let v:lnum = line('.') elseif a:0 && a:1 =~ '^\d' @@ -51,13 +53,14 @@ function! GetLiquidIndent(...) let lnum = prevnonblank(v:lnum-1) let line = getline(lnum) let cline = getline(v:lnum) - let line = substitute(line,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','') - let line .= matchstr(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+') - let cline = substitute(cline,'\C^\%(\s*{%\s*end\w*\s*%}\)\+','','') + let line = substitute(line,'\C^\%(\s*{%-\=\s*end\w*\s*-\=%}\)\+','','') + let line = substitute(line,'\C\%(\s*{%-\=\s*if.\+-\=%}.\+{%-\=\s*endif\s*-\=%}\)\+','','g') + let line .= matchstr(cline,'\C^\%(\s*{%-\=\s*end\w*\s*-\=%}\)\+') + let cline = substitute(cline,'\C^\%(\s*{%-\=\s*end\w*\s*-\=%}\)\+','','') let sw = shiftwidth() - let ind += sw * s:count(line,'{%\s*\%(if\|elsif\|else\|unless\|ifchanged\|case\|when\|for\|empty\|tablerow\|capture\)\>') - let ind -= sw * s:count(line,'{%\s*end\%(if\|unless\|ifchanged\|case\|for\|tablerow\|capture\)\>') - let ind -= sw * s:count(cline,'{%\s*\%(elsif\|else\|when\|empty\)\>') - let ind -= sw * s:count(cline,'{%\s*end\w*$') + let ind += sw * s:count(line,'{%-\=\s*\%(if\|elsif\|else\|unless\|ifchanged\|case\|when\|for\|empty\|tablerow\|capture\)\>') + let ind -= sw * s:count(line,'{%-\=\s*end\%(if\|unless\|ifchanged\|case\|for\|tablerow\|capture\)\>') + let ind -= sw * s:count(cline,'{%-\=\s*\%(elsif\|else\|when\|empty\)\>') + let ind -= sw * s:count(cline,'{%-\=\s*end\w*$') return ind endfunction diff --git a/runtime/indent/sass.vim b/runtime/indent/sass.vim index d6dbf3a8bb..8c0ecd0746 100644 --- a/runtime/indent/sass.vim +++ b/runtime/indent/sass.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Sass " Maintainer: Tim Pope <vimNOSPAM@tpope.org> -" Last Change: 2017 Jun 13 +" Last Change: 2022 Mar 15 if exists("b:did_indent") finish @@ -12,6 +12,8 @@ setlocal autoindent sw=2 et setlocal indentexpr=GetSassIndent() setlocal indentkeys=o,O,*<Return>,<:>,!^F +let b:undo_indent = "setl ai< inde< indk<" + " Only define the function once. if exists("*GetSassIndent") finish diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index 59ab3d7e1f..cec3891418 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -1894,16 +1894,16 @@ end function M.make_workspace_params(added, removed) return { event = { added = added; removed = removed; } } end ---- Returns visual width of tabstop. +--- Returns indentation size. --- ----@see |softtabstop| +---@see |shiftwidth| ---@param bufnr (optional, number): Buffer handle, defaults to current ----@returns (number) tabstop visual width +---@returns (number) indentation size function M.get_effective_tabstop(bufnr) validate { bufnr = {bufnr, 'n', true} } local bo = bufnr and vim.bo[bufnr] or vim.bo - local sts = bo.softtabstop - return (sts > 0 and sts) or (sts < 0 and bo.shiftwidth) or bo.tabstop + local sw = bo.shiftwidth + return (sw == 0 and bo.tabstop) or sw end --- Creates a `DocumentFormattingParams` object for the current buffer and cursor position. diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index b6f61cfb2e..e1ffd42a7f 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -274,7 +274,8 @@ local function on_line_impl(self, buf, line) { end_line = end_row, end_col = end_col, hl_group = hl, ephemeral = true, - priority = tonumber(metadata.priority) or 100 -- Low but leaves room below + priority = tonumber(metadata.priority) or 100, -- Low but leaves room below + conceal = metadata.conceal, }) end if start_row > line then diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index 49d9389773..71456e788d 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -4,10 +4,11 @@ " Copyright: Vim license applies, see ":help license" " Last Change: 2022 Jan 17 " -" WORK IN PROGRESS - Only the basics work -" Note: On MS-Windows you need a recent version of gdb. The one included with -" MingW is too old (7.6.1). -" I used version 7.12 from http://www.equation.com/servlet/equation.cmd?fa=gdb +" WORK IN PROGRESS - The basics works stable, more to come +" Note: In general you need at least GDB 7.12 because this provides the +" frame= response in MI thread-selected events we need to sync stack to file. +" The one included with "old" MingW is too old (7.6.1), you may upgrade it or +" use a newer version from http://www.equation.com/servlet/equation.cmd?fa=gdb " " There are two ways to run gdb: " - In a terminal window; used if possible, does not work on MS-Windows @@ -196,7 +197,7 @@ func s:CloseBuffers() endfunc func s:CheckGdbRunning() - if nvim_get_chan_info(s:gdb_job_id) == {} + if !s:running echoerr string(s:GetCommand()[0]) . ' exited unexpectedly' call s:CloseBuffers() return '' @@ -279,6 +280,8 @@ func s:StartDebug_term(dict) call s:CloseBuffers() return endif + let s:running = v:true + let s:starting = v:true let gdb_job_info = nvim_get_chan_info(s:gdb_job_id) let s:gdbbuf = gdb_job_info['buffer'] let s:gdbwin = win_getid(winnr()) @@ -354,6 +357,8 @@ func s:StartDebug_term(dict) sleep 10m endwhile + let s:starting = v:false + " Set the filetype, this can be used to add mappings. set filetype=termdebug @@ -662,6 +667,11 @@ func s:GetAsmAddr(msg) endfunc function s:EndTermDebug(job_id, exit_code, event) + let s:running = v:false + if s:starting + return + endif + if exists('#User#TermdebugStopPre') doauto <nomodeline> User TermdebugStopPre endif @@ -1026,7 +1036,7 @@ func s:Evaluate(range, arg) call s:SendEval(expr) endfunc -" get what is specified / under the cursor +" get what is specified / under the cursor func s:GetEvaluationExpression(range, arg) if a:arg != '' " user supplied evaluation diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim index e86e1b8669..2dc21f0b6a 100644 --- a/runtime/syntax/c.vim +++ b/runtime/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Dec 07 +" Last Change: 2022 Mar 17 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -245,8 +245,14 @@ syn match cWrongComTail display "\*/" syn keyword cOperator sizeof if exists("c_gnu") + syn keyword cType __label__ __complex__ syn keyword cStatement __asm__ - syn keyword cOperator typeof __real__ __imag__ + syn keyword cOperator __alignof__ + syn keyword cOperator typeof __typeof__ + syn keyword cOperator __real__ __imag__ + syn keyword cStorageClass __attribute__ __const__ __extension__ + syn keyword cStorageClass inline __inline__ + syn keyword cStorageClass __restrict__ __volatile__ __noreturn__ endif syn keyword cType int long short char void syn keyword cType signed unsigned float double @@ -270,16 +276,10 @@ if !exists("c_no_c99") " ISO C99 syn keyword cType intptr_t uintptr_t syn keyword cType intmax_t uintmax_t endif -if exists("c_gnu") - syn keyword cType __label__ __complex__ __volatile__ -endif syn keyword cTypedef typedef syn keyword cStructure struct union enum syn keyword cStorageClass static register auto volatile extern const -if exists("c_gnu") - syn keyword cStorageClass inline __attribute__ -endif if !exists("c_no_c99") && !s:in_cpp_family syn keyword cStorageClass inline restrict endif @@ -292,6 +292,7 @@ if !exists("c_no_c11") syn keyword cOperator _Static_assert static_assert syn keyword cStorageClass _Thread_local thread_local syn keyword cType char16_t char32_t + syn keyword cType max_align_t " C11 atomics (take down the shield wall!) syn keyword cType atomic_bool atomic_char atomic_schar atomic_uchar syn keyword Ctype atomic_short atomic_ushort atomic_int atomic_uint diff --git a/runtime/syntax/liquid.vim b/runtime/syntax/liquid.vim index 295a91775e..966b60f6f8 100644 --- a/runtime/syntax/liquid.vim +++ b/runtime/syntax/liquid.vim @@ -2,7 +2,7 @@ " Language: Liquid " Maintainer: Tim Pope <vimNOSPAM@tpope.org> " Filenames: *.liquid -" Last Change: 2013 May 30 +" Last Change: 2022 Mar 15 if exists('b:current_syntax') finish @@ -68,10 +68,10 @@ if !exists('s:subtype') unlet s:subtype endif -syn region liquidStatement matchgroup=liquidDelimiter start="{%" end="%}" contains=@liquidStatement containedin=ALLBUT,@liquidExempt keepend -syn region liquidExpression matchgroup=liquidDelimiter start="{{" end="}}" contains=@liquidExpression containedin=ALLBUT,@liquidExempt keepend -syn region liquidComment matchgroup=liquidDelimiter start="{%\s*comment\s*%}" end="{%\s*endcomment\s*%}" contains=liquidTodo,@Spell containedin=ALLBUT,@liquidExempt keepend -syn region liquidRaw matchgroup=liquidDelimiter start="{%\s*raw\s*%}" end="{%\s*endraw\s*%}" contains=TOP,@liquidExempt containedin=ALLBUT,@liquidExempt keepend +syn region liquidStatement matchgroup=liquidDelimiter start="{%-\=" end="-\=%}" contains=@liquidStatement containedin=ALLBUT,@liquidExempt keepend +syn region liquidExpression matchgroup=liquidDelimiter start="{{-\=" end="-\=}}" contains=@liquidExpression containedin=ALLBUT,@liquidExempt keepend +syn region liquidComment matchgroup=liquidDelimiter start="{%-\=\s*comment\s*-\=%}" end="{%-\=\s*endcomment\s*-\=%}" contains=liquidTodo,@Spell containedin=ALLBUT,@liquidExempt keepend +syn region liquidRaw matchgroup=liquidDelimiter start="{%-\=\s*raw\s*-\=%}" end="{%-\=\s*endraw\s*-\=%}" contains=TOP,@liquidExempt containedin=ALLBUT,@liquidExempt keepend syn cluster liquidExempt contains=liquidStatement,liquidExpression,liquidComment,liquidRaw,@liquidStatement,liquidYamlHead syn cluster liquidStatement contains=liquidConditional,liquidRepeat,liquidKeyword,@liquidExpression @@ -79,11 +79,11 @@ syn cluster liquidExpression contains=liquidOperator,liquidString,liquidNumber,l syn keyword liquidKeyword highlight nextgroup=liquidTypeHighlight skipwhite contained syn keyword liquidKeyword endhighlight contained -syn region liquidHighlight start="{%\s*highlight\s\+\w\+\s*%}" end="{% endhighlight %}" keepend +syn region liquidHighlight start="{%-\=\s*highlight\s\+\w\+\s*-\=%}" end="{%-\= endhighlight -\=%}" keepend for s:type in g:liquid_highlight_types exe 'syn match liquidTypeHighlight "\<'.matchstr(s:type,'[^=]*').'\>" contained' - exe 'syn region liquidHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' start="{%\s*highlight\s\+'.matchstr(s:type,'[^=]*').'\s*%}" end="{% endhighlight %}" keepend contains=@liquidHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') + exe 'syn region liquidHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' start="{%-\=\s*highlight\s\+'.matchstr(s:type,'[^=]*').'\s*-\=%}" end="{%-\= endhighlight -\=%}" keepend contains=@liquidHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') endfor unlet! s:type @@ -92,18 +92,18 @@ syn region liquidString matchgroup=liquidQuote start=+'+ end=+'+ contained syn match liquidNumber "-\=\<\d\+\>" contained syn match liquidFloat "-\=\<\d\+\>\.\.\@!\%(\d\+\>\)\=" contained syn keyword liquidBoolean true false contained -syn keyword liquidNull null nil contained +syn keyword liquidNull null nil blank contained syn match liquidEmpty "\<empty\>" contained syn keyword liquidOperator and or not contained syn match liquidPipe '|' contained skipwhite nextgroup=liquidFilter -syn keyword liquidFilter date capitalize downcase upcase first last join sort size strip_html strip_newlines newline_to_br replace replace_first remove remove_first truncate truncatewords prepend append minus plus times divided_by contained +syn keyword liquidFilter date capitalize downcase upcase escape escape_once first last join sort size where uniq strip_html strip_newlines newline_to_br replace replace_first remove remove_first slice split strip truncate truncatewords prepend append url_encode url_decode abs at_most at_least ceil divided_by floor minus plus round times modulo contained syn keyword liquidConditional if elsif else endif unless endunless case when endcase ifchanged endifchanged contained -syn keyword liquidRepeat for endfor tablerow endtablerow in contained -syn match liquidRepeat "\%({%\s*\)\@<=empty\>" contained -syn keyword liquidKeyword assign cycle include with contained +syn keyword liquidRepeat for endfor tablerow endtablerow in break continue limit offset reversed contained +syn match liquidRepeat "\%({%-\=\s*\)\@<=empty\>" contained +syn keyword liquidKeyword assign capture endcapture increasement decreasement cycle include with render contained syn keyword liquidForloop forloop nextgroup=liquidForloopDot contained syn match liquidForloopDot "\." nextgroup=liquidForloopAttribute contained diff --git a/runtime/syntax/sass.vim b/runtime/syntax/sass.vim index b51a0ae26b..8f41aba4f7 100644 --- a/runtime/syntax/sass.vim +++ b/runtime/syntax/sass.vim @@ -2,7 +2,7 @@ " Language: Sass " Maintainer: Tim Pope <vimNOSPAM@tpope.org> " Filenames: *.sass -" Last Change: 2019 Dec 05 +" Last Change: 2022 Mar 15 if exists("b:current_syntax") finish @@ -58,6 +58,7 @@ syn match sassAmpersand "&" " TODO: Arithmetic (including strings and concatenation) syn region sassMediaQuery matchgroup=sassMedia start="@media" end="[{};]\@=\|$" contains=sassMediaOperators +syn region sassKeyframe matchgroup=cssAtKeyword start=/@\(-[a-z]\+-\)\=keyframes\>/ end=";\|$" contains=cssVendor,cssComment nextgroup=cssDefinition syn keyword sassMediaOperators and not only contained syn region sassCharset start="@charset" end=";\|$" contains=scssComment,cssStringQ,cssStringQQ,cssURL,cssUnicodeEscape,cssMediaType syn region sassInclude start="@import" end=";\|$" contains=scssComment,cssStringQ,cssStringQQ,cssURL,cssUnicodeEscape,cssMediaType diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 9f0cadd5ce..18f7177489 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -52,7 +52,7 @@ /// whether a buffer is loaded. -/// Gets the buffer line count +/// Returns the number of lines in the given buffer. /// /// @param buffer Buffer handle, or 0 for current buffer /// @param[out] err Error details, if any diff --git a/src/nvim/api/extmark.c b/src/nvim/api/extmark.c index c02688a815..797b64e2af 100644 --- a/src/nvim/api/extmark.c +++ b/src/nvim/api/extmark.c @@ -467,6 +467,11 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id, Object start, Object e /// as the mark and 'cursorline' is enabled. /// Note: ranges are unsupported and decorations are only /// applied to start_row +/// - conceal: string which should be either empty or a single +/// character. Enable concealing similar to |:syn-conceal|. +/// When a character is supplied it is used as |:syn-cchar|. +/// "hl_group" is used as highlight for the cchar if provided, +/// otherwise it defaults to |hl-Conceal|. /// /// @param[out] err Error details, if any /// @return Id of the created/updated extmark @@ -563,6 +568,17 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer } } + if (opts->conceal.type == kObjectTypeString) { + String c = opts->conceal.data.string; + decor.conceal = true; + if (c.size) { + decor.conceal_char = utf_ptr2char((const char_u *)c.data); + } + } else if (HAS_KEY(opts->conceal)) { + api_set_error(err, kErrorTypeValidation, "conceal is not a String"); + goto error; + } + if (opts->virt_text.type == kObjectTypeArray) { decor.virt_text = parse_virt_text(opts->virt_text.data.array, err, &decor.virt_text_width); diff --git a/src/nvim/api/keysets.lua b/src/nvim/api/keysets.lua index 435e8195dd..b6264cdfab 100644 --- a/src/nvim/api/keysets.lua +++ b/src/nvim/api/keysets.lua @@ -27,6 +27,7 @@ return { "number_hl_group"; "line_hl_group"; "cursorline_hl_group"; + "conceal"; }; keymap = { "noremap"; diff --git a/src/nvim/api/private/converter.c b/src/nvim/api/private/converter.c index 82ec1ad0d8..a26383ec7d 100644 --- a/src/nvim/api/private/converter.c +++ b/src/nvim/api/private/converter.c @@ -65,8 +65,7 @@ typedef struct { #define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun) \ do { \ ufunc_T *fp = find_func(fun); \ - assert(fp != NULL); \ - if (fp->uf_cb == nlua_CFunction_func_call) { \ + if (fp != NULL && fp->uf_cb == nlua_CFunction_func_call) { \ LuaRef ref = api_new_luaref(((LuaCFunctionState *)fp->uf_cb_state)->lua_callable.func_ref); \ kvi_push(edata->stack, LUAREF_OBJ(ref)); \ } else { \ diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index b0267f5ed0..42e880dc19 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -126,7 +126,7 @@ /// [ "╔", "═" ,"╗", "║", "╝", "═", "╚", "║" ]. /// If the number of chars are less than eight, they will be repeated. Thus /// an ASCII border could be specified as -/// [ "/", "-", "\\", "|" ], +/// [ "/", "-", \"\\\\\", "|" ], /// or all chars the same as /// [ "x" ]. /// An empty string can be used to turn off a specific border, for instance, diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index df336d8703..a36f2c97b5 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -2013,6 +2013,7 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat) } AutoCmd *ac = acp->nextcmd; + bool oneshot = ac->once; if (p_verbose >= 9) { verbose_enter_scroll(); @@ -2024,7 +2025,13 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat) if (ac->exec.type == CALLABLE_CB) { typval_T argsin = TV_INITIAL_VALUE; typval_T rettv = TV_INITIAL_VALUE; - callback_call(&ac->exec.callable.cb, 0, &argsin, &rettv); + if (callback_call(&ac->exec.callable.cb, 0, &argsin, &rettv)) { + if (ac->exec.callable.cb.type == kCallbackLua) { + // If a Lua callback returns 'true' then the autocommand is removed + oneshot = true; + } + } + // TODO(tjdevries): // @@ -2042,7 +2049,7 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat) } // Remove one-shot ("once") autocmd in anticipation of its execution. - if (ac->once) { + if (oneshot) { aucmd_del(ac); } autocmd_nested = ac->nested; diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index fb709d12ff..a0f189ca38 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -312,6 +312,10 @@ next_mark: int attr = 0; size_t j = 0; + bool conceal = 0; + int conceal_char = 0; + int conceal_attr = 0; + for (size_t i = 0; i < kv_size(state->active); i++) { DecorRange item = kv_A(state->active, i); bool active = false, keep = true; @@ -336,6 +340,14 @@ next_mark: if (active && item.attr_id > 0) { attr = hl_combine_attr(attr, item.attr_id); } + if (active && item.decor.conceal) { + conceal = true; + if (item.start_row == state->row && item.start_col == col && item.decor.conceal_char) { + conceal_char = item.decor.conceal_char; + state->col_until = MIN(state->col_until, item.start_col); + conceal_attr = item.attr_id; + } + } if ((item.start_row == state->row && item.start_col <= col) && kv_size(item.decor.virt_text) && item.decor.virt_text_pos == kVTOverlay && item.win_col == -1) { @@ -349,6 +361,9 @@ next_mark: } kv_size(state->active) = j; state->current = attr; + state->conceal = conceal; + state->conceal_char = conceal_char; + state->conceal_attr = conceal_attr; return attr; } diff --git a/src/nvim/decoration.h b/src/nvim/decoration.h index 8df53caa0a..97ab218f86 100644 --- a/src/nvim/decoration.h +++ b/src/nvim/decoration.h @@ -47,6 +47,7 @@ struct Decoration { bool virt_text_hide; bool hl_eol; bool virt_lines_above; + bool conceal; // TODO(bfredl): style, etc DecorPriority priority; int col; // fixed col value, like win_col @@ -56,9 +57,13 @@ struct Decoration { int number_hl_id; int line_hl_id; int cursorline_hl_id; + // TODO(bfredl): in principle this should be a schar_T, but we + // probably want some kind of glyph cache for that.. + int conceal_char; }; -#define DECORATION_INIT { KV_INITIAL_VALUE, KV_INITIAL_VALUE, 0, kVTEndOfLine, kHlModeUnknown, \ - false, false, false, DECOR_PRIORITY_BASE, 0, 0, NULL, 0, 0, 0, 0 } +#define DECORATION_INIT { KV_INITIAL_VALUE, KV_INITIAL_VALUE, 0, kVTEndOfLine, \ + kHlModeUnknown, false, false, false, false, DECOR_PRIORITY_BASE, \ + 0, 0, NULL, 0, 0, 0, 0, 0 } typedef struct { int start_row; @@ -80,6 +85,10 @@ typedef struct { int col_until; int current; int eol_col; + + bool conceal; + int conceal_char; + int conceal_attr; } DecorState; EXTERN DecorState decor_state INIT(= { 0 }); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index af7c3d4985..7f937a3137 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -68,7 +68,6 @@ static char *e_illvar = N_("E461: Illegal variable name: %s"); static char *e_cannot_mod = N_("E995: Cannot modify existing variable"); static char *e_nowhitespace = N_("E274: No white space allowed before parenthesis"); -static char *e_invalwindow = N_("E957: Invalid window number"); static char *e_lock_unlock = N_("E940: Cannot lock or unlock variable %s"); static char *e_write2 = N_("E80: Error while writing: %s"); static char *e_string_list_or_blob_required = N_("E1098: String, List or Blob required"); @@ -7323,30 +7322,6 @@ void mapblock_fill_dict(dict_T *const dict, const mapblock_T *const mp, long buf tv_dict_add_allocated_str(dict, S_LEN("mode"), mapmode); } -int matchadd_dict_arg(typval_T *tv, const char **conceal_char, win_T **win) -{ - dictitem_T *di; - - if (tv->v_type != VAR_DICT) { - emsg(_(e_dictreq)); - return FAIL; - } - - if ((di = tv_dict_find(tv->vval.v_dict, S_LEN("conceal"))) != NULL) { - *conceal_char = tv_get_string(&di->di_tv); - } - - if ((di = tv_dict_find(tv->vval.v_dict, S_LEN("window"))) != NULL) { - *win = find_win_by_nr_or_id(&di->di_tv); - if (*win == NULL) { - emsg(_(e_invalwindow)); - return FAIL; - } - } - - return OK; -} - void return_register(int regname, typval_T *rettv) { char_u buf[2] = { regname, 0 }; @@ -7730,6 +7705,7 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co partial_T *partial; char_u *name; Array args = ARRAY_DICT_INIT; + Object rv; switch (callback->type) { case kCallbackFuncref: name = callback->data.funcref; @@ -7742,10 +7718,13 @@ bool callback_call(Callback *const callback, const int argcount_in, typval_T *co break; case kCallbackLua: - nlua_call_ref(callback->data.luaref, NULL, args, false, NULL); - - return false; - break; + rv = nlua_call_ref(callback->data.luaref, NULL, args, true, NULL); + switch (rv.type) { + case kObjectTypeBoolean: + return rv.data.boolean; + default: + return false; + } case kCallbackNone: return false; diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 6e98f229b2..7ee32ec8cd 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1124,7 +1124,7 @@ static void f_cindent(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } -static win_T *get_optional_window(typval_T *argvars, int idx) +win_T *get_optional_window(typval_T *argvars, int idx) { win_T *win = curwin; @@ -1138,16 +1138,6 @@ static win_T *get_optional_window(typval_T *argvars, int idx) return win; } -/// "clearmatches()" function -static void f_clearmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - win_T *win = get_optional_window(argvars, 0); - - if (win != NULL) { - clear_matches(win); - } -} - /// "col(string)" function static void f_col(typval_T *argvars, typval_T *rettv, FunPtr fptr) { @@ -3669,61 +3659,6 @@ static void f_getmarklist(typval_T *argvars, typval_T *rettv, FunPtr fptr) get_buf_local_marks(buf, rettv->vval.v_list); } -/// "getmatches()" function -static void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - matchitem_T *cur; - int i; - win_T *win = get_optional_window(argvars, 0); - - if (win == NULL) { - return; - } - - tv_list_alloc_ret(rettv, kListLenMayKnow); - cur = win->w_match_head; - while (cur != NULL) { - dict_T *dict = tv_dict_alloc(); - if (cur->match.regprog == NULL) { - // match added with matchaddpos() - for (i = 0; i < MAXPOSMATCH; i++) { - llpos_T *llpos; - char buf[30]; // use 30 to avoid compiler warning - - llpos = &cur->pos.pos[i]; - if (llpos->lnum == 0) { - break; - } - list_T *const l = tv_list_alloc(1 + (llpos->col > 0 ? 2 : 0)); - tv_list_append_number(l, (varnumber_T)llpos->lnum); - if (llpos->col > 0) { - tv_list_append_number(l, (varnumber_T)llpos->col); - tv_list_append_number(l, (varnumber_T)llpos->len); - } - int len = snprintf(buf, sizeof(buf), "pos%d", i + 1); - assert((size_t)len < sizeof(buf)); - tv_dict_add_list(dict, buf, (size_t)len, l); - } - } else { - tv_dict_add_str(dict, S_LEN("pattern"), (const char *)cur->pattern); - } - tv_dict_add_str(dict, S_LEN("group"), - (const char *)syn_id2name(cur->hlg_id)); - tv_dict_add_nr(dict, S_LEN("priority"), (varnumber_T)cur->priority); - tv_dict_add_nr(dict, S_LEN("id"), (varnumber_T)cur->id); - - if (cur->conceal_char) { - char buf[MB_MAXBYTES + 1]; - - buf[utf_char2bytes(cur->conceal_char, (char_u *)buf)] = NUL; - tv_dict_add_str(dict, S_LEN("conceal"), buf); - } - - tv_list_append_dict(rettv->vval.v_list, dict); - cur = cur->next; - } -} - /// "getmousepos()" function static void f_getmousepos(typval_T *argvars, typval_T *rettv, FunPtr fptr) { @@ -6108,133 +6043,6 @@ static void f_match(typval_T *argvars, typval_T *rettv, FunPtr fptr) find_some_match(argvars, rettv, kSomeMatch); } -/// "matchadd()" function -static void f_matchadd(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - char grpbuf[NUMBUFLEN]; - char patbuf[NUMBUFLEN]; - // group - const char *const grp = tv_get_string_buf_chk(&argvars[0], grpbuf); - // pattern - const char *const pat = tv_get_string_buf_chk(&argvars[1], patbuf); - // default priority - int prio = 10; - int id = -1; - bool error = false; - const char *conceal_char = NULL; - win_T *win = curwin; - - rettv->vval.v_number = -1; - - if (grp == NULL || pat == NULL) { - return; - } - if (argvars[2].v_type != VAR_UNKNOWN) { - prio = tv_get_number_chk(&argvars[2], &error); - if (argvars[3].v_type != VAR_UNKNOWN) { - id = tv_get_number_chk(&argvars[3], &error); - if (argvars[4].v_type != VAR_UNKNOWN - && matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL) { - return; - } - } - } - if (error) { - return; - } - if (id >= 1 && id <= 3) { - semsg(_("E798: ID is reserved for \":match\": %" PRId64), (int64_t)id); - return; - } - - rettv->vval.v_number = match_add(win, grp, pat, prio, id, NULL, conceal_char); -} - -static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - rettv->vval.v_number = -1; - - char buf[NUMBUFLEN]; - const char *const group = tv_get_string_buf_chk(&argvars[0], buf); - if (group == NULL) { - return; - } - - if (argvars[1].v_type != VAR_LIST) { - semsg(_(e_listarg), "matchaddpos()"); - return; - } - - list_T *l; - l = argvars[1].vval.v_list; - if (l == NULL) { - return; - } - - bool error = false; - int prio = 10; - int id = -1; - const char *conceal_char = NULL; - win_T *win = curwin; - - if (argvars[2].v_type != VAR_UNKNOWN) { - prio = tv_get_number_chk(&argvars[2], &error); - if (argvars[3].v_type != VAR_UNKNOWN) { - id = tv_get_number_chk(&argvars[3], &error); - if (argvars[4].v_type != VAR_UNKNOWN - && matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL) { - return; - } - } - } - if (error == true) { - return; - } - - // id == 3 is ok because matchaddpos() is supposed to substitute :3match - if (id == 1 || id == 2) { - semsg(_("E798: ID is reserved for \"match\": %" PRId64), (int64_t)id); - return; - } - - rettv->vval.v_number = match_add(win, group, NULL, prio, id, l, conceal_char); -} - -/// "matcharg()" function -static void f_matcharg(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - const int id = tv_get_number(&argvars[0]); - - tv_list_alloc_ret(rettv, (id >= 1 && id <= 3 - ? 2 - : 0)); - - if (id >= 1 && id <= 3) { - matchitem_T *const m = get_match(curwin, id); - - if (m != NULL) { - tv_list_append_string(rettv->vval.v_list, - (const char *)syn_id2name(m->hlg_id), -1); - tv_list_append_string(rettv->vval.v_list, (const char *)m->pattern, -1); - } else { - tv_list_append_string(rettv->vval.v_list, NULL, 0); - tv_list_append_string(rettv->vval.v_list, NULL, 0); - } - } -} - -/// "matchdelete()" function -static void f_matchdelete(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - win_T *win = get_optional_window(argvars, 1); - if (win == NULL) { - rettv->vval.v_number = -1; - } else { - rettv->vval.v_number = match_delete(win, - (int)tv_get_number(&argvars[0]), true); - } -} - /// "matchend()" function static void f_matchend(typval_T *argvars, typval_T *rettv, FunPtr fptr) { @@ -9121,109 +8929,6 @@ static void f_setloclist(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } -/// "setmatches()" function -static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - dict_T *d; - list_T *s = NULL; - win_T *win = get_optional_window(argvars, 1); - - rettv->vval.v_number = -1; - if (argvars[0].v_type != VAR_LIST) { - emsg(_(e_listreq)); - return; - } - if (win == NULL) { - return; - } - - list_T *const l = argvars[0].vval.v_list; - // To some extent make sure that we are dealing with a list from - // "getmatches()". - int li_idx = 0; - TV_LIST_ITER_CONST(l, li, { - if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT - || (d = TV_LIST_ITEM_TV(li)->vval.v_dict) == NULL) { - semsg(_("E474: List item %d is either not a dictionary " - "or an empty one"), li_idx); - return; - } - if (!(tv_dict_find(d, S_LEN("group")) != NULL - && (tv_dict_find(d, S_LEN("pattern")) != NULL - || tv_dict_find(d, S_LEN("pos1")) != NULL) - && tv_dict_find(d, S_LEN("priority")) != NULL - && tv_dict_find(d, S_LEN("id")) != NULL)) { - semsg(_("E474: List item %d is missing one of the required keys"), - li_idx); - return; - } - li_idx++; - }); - - clear_matches(win); - bool match_add_failed = false; - TV_LIST_ITER_CONST(l, li, { - int i = 0; - - d = TV_LIST_ITEM_TV(li)->vval.v_dict; - dictitem_T *const di = tv_dict_find(d, S_LEN("pattern")); - if (di == NULL) { - if (s == NULL) { - s = tv_list_alloc(9); - } - - // match from matchaddpos() - for (i = 1; i < 9; i++) { - char buf[30]; // use 30 to avoid compiler warning - snprintf(buf, sizeof(buf), "pos%d", i); - dictitem_T *const pos_di = tv_dict_find(d, buf, -1); - if (pos_di != NULL) { - if (pos_di->di_tv.v_type != VAR_LIST) { - return; - } - - tv_list_append_tv(s, &pos_di->di_tv); - tv_list_ref(s); - } else { - break; - } - } - } - - // Note: there are three number buffers involved: - // - group_buf below. - // - numbuf in tv_dict_get_string(). - // - mybuf in tv_get_string(). - // - // If you change this code make sure that buffers will not get - // accidentally reused. - char group_buf[NUMBUFLEN]; - const char *const group = tv_dict_get_string_buf(d, "group", group_buf); - const int priority = (int)tv_dict_get_number(d, "priority"); - const int id = (int)tv_dict_get_number(d, "id"); - dictitem_T *const conceal_di = tv_dict_find(d, S_LEN("conceal")); - const char *const conceal = (conceal_di != NULL - ? tv_get_string(&conceal_di->di_tv) - : NULL); - if (i == 0) { - if (match_add(win, group, - tv_dict_get_string(d, "pattern", false), - priority, id, NULL, conceal) != id) { - match_add_failed = true; - } - } else { - if (match_add(win, group, NULL, priority, id, s, conceal) != id) { - match_add_failed = true; - } - tv_list_unref(s); - s = NULL; - } - }); - if (!match_add_failed) { - rettv->vval.v_number = 0; - } -} - /// "setpos()" function static void f_setpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) { diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index c6089562f3..a5732a006d 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -250,8 +250,9 @@ void do_exmode(void) msg_scroll = save_msg_scroll; } -// Print the executed command for when 'verbose' is set. -// When "lnum" is 0 only print the command. +/// Print the executed command for when 'verbose' is set. +/// +/// @param lnum if 0, only print the command. static void msg_verbose_cmd(linenr_T lnum, char_u *cmd) FUNC_ATTR_NONNULL_ALL { @@ -271,9 +272,7 @@ static void msg_verbose_cmd(linenr_T lnum, char_u *cmd) no_wait_return--; } -/* - * Execute a simple command line. Used for translated commands like "*". - */ +/// Execute a simple command line. Used for translated commands like "*". int do_cmdline_cmd(const char *cmd) { return do_cmdline((char_u *)cmd, NULL, NULL, @@ -952,9 +951,7 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, void *cookie, int flags) return retval; } -/* - * Obtain a line when inside a ":while" or ":for" loop. - */ +/// Obtain a line when inside a ":while" or ":for" loop. static char_u *get_loop_line(int c, void *cookie, int indent, bool do_concat) { struct loop_cookie *cp = (struct loop_cookie *)cookie; @@ -986,9 +983,7 @@ static char_u *get_loop_line(int c, void *cookie, int indent, bool do_concat) return vim_strsave(wp->line); } -/* - * Store a line in "gap" so that a ":while" loop can execute it again. - */ +/// Store a line in "gap" so that a ":while" loop can execute it again. static void store_loop_line(garray_T *gap, char_u *line) { wcmd_T *p = GA_APPEND_VIA_PTR(wcmd_T, gap); @@ -1038,11 +1033,10 @@ void *getline_cookie(LineGetter fgetline, void *cookie) return cp; } -/* - * Helper function to apply an offset for buffer commands, i.e. ":bdelete", - * ":bwipeout", etc. - * Returns the buffer number. - */ +/// Helper function to apply an offset for buffer commands, i.e. ":bdelete", +/// ":bwipeout", etc. +/// +/// @return the buffer number. static int compute_buffer_local_count(int addr_type, int lnum, int offset) { buf_T *buf; @@ -1084,8 +1078,8 @@ static int compute_buffer_local_count(int addr_type, int lnum, int offset) return buf->b_fnum; } -// Return the window number of "win". -// When "win" is NULL return the number of windows. +/// @return the window number of "win" or, +/// the number of windows if "win" is NULL static int current_win_nr(const win_T *win) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { @@ -2049,18 +2043,20 @@ char *ex_errmsg(const char *const msg, const char_u *const arg) return ex_error_buf; } -// Parse and skip over command modifiers: -// - update eap->cmd -// - store flags in "cmdmod". -// - Set ex_pressedreturn for an empty command line. -// - set msg_silent for ":silent" -// - set 'eventignore' to "all" for ":noautocmd" -// - set p_verbose for ":verbose" -// - Increment "sandbox" for ":sandbox" -// When "skip_only" is true the global variables are not changed, except for -// "cmdmod". -// Return FAIL when the command is not to be executed. -// May set "errormsg" to an error message. +/// Parse and skip over command modifiers: +/// - update eap->cmd +/// - store flags in "cmdmod". +/// - Set ex_pressedreturn for an empty command line. +/// - set msg_silent for ":silent" +/// - set 'eventignore' to "all" for ":noautocmd" +/// - set p_verbose for ":verbose" +/// - Increment "sandbox" for ":sandbox" +/// +/// @param skip_only if true, the global variables are not changed, except for +/// "cmdmod". +/// @param[out] errormsg potential error message. +/// +/// @return FAIL when the command is not to be executed. int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only) { char_u *p; @@ -2319,7 +2315,7 @@ int parse_command_modifiers(exarg_T *eap, char **errormsg, bool skip_only) return OK; } -// Undo and free contents of "cmdmod". +/// Undo and free contents of "cmdmod". static void undo_cmdmod(const exarg_T *eap, int save_msg_scroll) FUNC_ATTR_NONNULL_ALL { @@ -2358,9 +2354,10 @@ static void undo_cmdmod(const exarg_T *eap, int save_msg_scroll) } -// Parse the address range, if any, in "eap". -// May set the last search pattern, unless "silent" is true. -// Return FAIL and set "errormsg" or return OK. +/// Parse the address range, if any, in "eap". +/// May set the last search pattern, unless "silent" is true. +/// +/// @return FAIL and set "errormsg" or return OK. int parse_cmd_address(exarg_T *eap, char **errormsg, bool silent) FUNC_ATTR_NONNULL_ALL { @@ -2552,11 +2549,9 @@ int checkforcmd(char_u **pp, char *cmd, int len) return FALSE; } -/* - * Append "cmd" to the error message in IObuff. - * Takes care of limiting the length and handling 0xa0, which would be - * invisible otherwise. - */ +/// Append "cmd" to the error message in IObuff. +/// Takes care of limiting the length and handling 0xa0, which would be +/// invisible otherwise. static void append_command(char_u *cmd) { char_u *s = cmd; @@ -2576,11 +2571,12 @@ static void append_command(char_u *cmd) *d = NUL; } -// Find an Ex command by its name, either built-in or user. -// Start of the name can be found at eap->cmd. -// Sets eap->cmdidx and returns a pointer to char after the command name. -// "full" is set to TRUE if the whole command name matched. -// Returns NULL for an ambiguous user command. +/// Find an Ex command by its name, either built-in or user. +/// Start of the name can be found at eap->cmd. +/// Sets eap->cmdidx and returns a pointer to char after the command name. +/// "full" is set to TRUE if the whole command name matched. +/// +/// @return NULL for an ambiguous user command. static char_u *find_command(exarg_T *eap, int *full) FUNC_ATTR_NONNULL_ARG(1) { @@ -2834,10 +2830,8 @@ static struct cmdmod { { "vertical", 4, false }, }; -/* - * Return length of a command modifier (including optional count). - * Return zero when it's not a modifier. - */ +/// @return length of a command modifier (including optional count) or, +/// zero when it's not a modifier. int modifier_len(char_u *cmd) { char_u *p = cmd; @@ -2861,11 +2855,9 @@ int modifier_len(char_u *cmd) return 0; } -/* - * Return > 0 if an Ex command "name" exists. - * Return 2 if there is an exact match. - * Return 3 if there is an ambiguous match. - */ +/// @return > 0 if an Ex command "name" exists or, +/// 2 if there is an exact match or, +/// 3 if there is an ambiguous match. int cmd_exists(const char *const name) { exarg_T ea; @@ -2902,7 +2894,7 @@ int cmd_exists(const char *const name) return ea.cmdidx == CMD_SIZE ? 0 : (full ? 2 : 1); } -// "fullcommand" function +/// "fullcommand" function void f_fullcommand(typval_T *argvars, typval_T *rettv, FunPtr fptr) { exarg_T ea; @@ -4192,9 +4184,7 @@ error: return lnum; } -/* - * Get flags from an Ex command argument. - */ +/// Get flags from an Ex command argument. static void get_flags(exarg_T *eap) { while (vim_strchr((char_u *)"lp#", *eap->arg) != NULL) { @@ -4229,10 +4219,9 @@ static void ex_script_ni(exarg_T *eap) } } -/* - * Check range in Ex command for validity. - * Return NULL when valid, error message when invalid. - */ +/// Check range in Ex command for validity. +/// +/// @return NULL when valid, error message when invalid. static char *invalid_range(exarg_T *eap) { buf_T *buf; @@ -4318,9 +4307,7 @@ static char *invalid_range(exarg_T *eap) return NULL; } -/* - * Correct the range for zero line number, if required. - */ +/// Correct the range for zero line number, if required. static void correct_range(exarg_T *eap) { if (!(eap->argt & EX_ZEROR)) { // zero in range not allowed @@ -4334,10 +4321,8 @@ static void correct_range(exarg_T *eap) } -/* - * For a ":vimgrep" or ":vimgrepadd" command return a pointer past the - * pattern. Otherwise return eap->arg. - */ +/// For a ":vimgrep" or ":vimgrepadd" command return a pointer past the +/// pattern. Otherwise return eap->arg. static char_u *skip_grep_pat(exarg_T *eap) { char_u *p = eap->arg; @@ -4354,10 +4339,8 @@ static char_u *skip_grep_pat(exarg_T *eap) return p; } -/* - * For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option - * in the command line, so that things like % get expanded. - */ +/// For the ":make" and ":grep" commands insert the 'makeprg'/'grepprg' option +/// in the command line, so that things like % get expanded. static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) { char_u *new_cmdline; @@ -4425,9 +4408,10 @@ static char_u *replace_makeprg(exarg_T *eap, char_u *p, char_u **cmdlinep) return p; } -// Expand file name in Ex command argument. -// When an error is detected, "errormsgp" is set to a non-NULL pointer. -// Return FAIL for failure, OK otherwise. +/// Expand file name in Ex command argument. +/// When an error is detected, "errormsgp" is set to a non-NULL pointer. +/// +/// @return FAIL for failure, OK otherwise. int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp) { int has_wildcards; // need to expand wildcards @@ -4595,13 +4579,12 @@ int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp) return OK; } -/* - * Replace part of the command line, keeping eap->cmd, eap->arg and - * eap->nextcmd correct. - * "src" points to the part that is to be replaced, of length "srclen". - * "repl" is the replacement string. - * Returns a pointer to the character after the replaced string. - */ +/// Replace part of the command line, keeping eap->cmd, eap->arg and +/// eap->nextcmd correct. +/// "src" points to the part that is to be replaced, of length "srclen". +/// "repl" is the replacement string. +/// +/// @return a pointer to the character after the replaced string. static char_u *repl_cmdline(exarg_T *eap, char_u *src, size_t srclen, char_u *repl, char_u **cmdlinep) { @@ -4647,9 +4630,7 @@ static char_u *repl_cmdline(exarg_T *eap, char_u *src, size_t srclen, char_u *re return src; } -/* - * Check for '|' to separate commands and '"' to start comments. - */ +/// Check for '|' to separate commands and '"' to start comments. void separate_nextcmd(exarg_T *eap) { char_u *p; @@ -4704,9 +4685,7 @@ void separate_nextcmd(exarg_T *eap) } } -/* - * get + command from ex argument - */ +/// get + command from ex argument static char_u *getargcmd(char_u **argp) { char_u *arg = *argp; @@ -4763,10 +4742,9 @@ int get_bad_opt(const char_u *p, exarg_T *eap) return OK; } -/* - * Get "++opt=arg" argument. - * Return FAIL or OK. - */ +/// Get "++opt=arg" argument. +/// +/// @return FAIL or OK. static int getargopt(exarg_T *eap) { char_u *arg = eap->arg + 2; @@ -4846,8 +4824,9 @@ static int getargopt(exarg_T *eap) } /// Handle the argument for a tabpage related ex command. -/// Returns a tabpage number. /// When an error is encountered then eap->errmsg is set. +/// +/// @return a tabpage number. static int get_tabpage_arg(exarg_T *eap) { int tab_number = 0; @@ -4936,17 +4915,13 @@ theend: return tab_number; } -/* - * ":abbreviate" and friends. - */ +/// ":abbreviate" and friends. static void ex_abbreviate(exarg_T *eap) { do_exmap(eap, TRUE); // almost the same as mapping } -/* - * ":map" and friends. - */ +/// ":map" and friends. static void ex_map(exarg_T *eap) { /* @@ -4961,25 +4936,19 @@ static void ex_map(exarg_T *eap) do_exmap(eap, FALSE); } -/* - * ":unmap" and friends. - */ +/// ":unmap" and friends. static void ex_unmap(exarg_T *eap) { do_exmap(eap, FALSE); } -/* - * ":mapclear" and friends. - */ +/// ":mapclear" and friends. static void ex_mapclear(exarg_T *eap) { map_clear_mode(eap->cmd, eap->arg, eap->forceit, false); } -/* - * ":abclear" and friends. - */ +/// ":abclear" and friends. static void ex_abclear(exarg_T *eap) { map_clear_mode(eap->cmd, eap->arg, true, true); @@ -4999,9 +4968,7 @@ static void ex_autocmd(exarg_T *eap) } } -/* - * ":doautocmd": Apply the automatic commands to the current buffer. - */ +/// ":doautocmd": Apply the automatic commands to the current buffer. static void ex_doautocmd(exarg_T *eap) { char_u *arg = eap->arg; @@ -5015,11 +4982,9 @@ static void ex_doautocmd(exarg_T *eap) } } -/* - * :[N]bunload[!] [N] [bufname] unload buffer - * :[N]bdelete[!] [N] [bufname] delete buffer from buffer list - * :[N]bwipeout[!] [N] [bufname] delete buffer really - */ +/// :[N]bunload[!] [N] [bufname] unload buffer +/// :[N]bdelete[!] [N] [bufname] delete buffer from buffer list +/// :[N]bwipeout[!] [N] [bufname] delete buffer really static void ex_bunload(exarg_T *eap) { eap->errmsg = do_bufdel(eap->cmdidx == CMD_bdelete ? DOBUF_DEL @@ -5029,10 +4994,8 @@ static void ex_bunload(exarg_T *eap) eap->addr_count, (int)eap->line1, (int)eap->line2, eap->forceit); } -/* - * :[N]buffer [N] to buffer N - * :[N]sbuffer [N] to buffer N - */ +/// :[N]buffer [N] to buffer N +/// :[N]sbuffer [N] to buffer N static void ex_buffer(exarg_T *eap) { if (*eap->arg) { @@ -5049,10 +5012,8 @@ static void ex_buffer(exarg_T *eap) } } -/* - * :[N]bmodified [N] to next mod. buffer - * :[N]sbmodified [N] to next mod. buffer - */ +/// :[N]bmodified [N] to next mod. buffer +/// :[N]sbmodified [N] to next mod. buffer static void ex_bmodified(exarg_T *eap) { goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); @@ -5061,10 +5022,8 @@ static void ex_bmodified(exarg_T *eap) } } -/* - * :[N]bnext [N] to next buffer - * :[N]sbnext [N] split and to next buffer - */ +/// :[N]bnext [N] to next buffer +/// :[N]sbnext [N] split and to next buffer static void ex_bnext(exarg_T *eap) { goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); @@ -5073,12 +5032,10 @@ static void ex_bnext(exarg_T *eap) } } -/* - * :[N]bNext [N] to previous buffer - * :[N]bprevious [N] to previous buffer - * :[N]sbNext [N] split and to previous buffer - * :[N]sbprevious [N] split and to previous buffer - */ +/// :[N]bNext [N] to previous buffer +/// :[N]bprevious [N] to previous buffer +/// :[N]sbNext [N] split and to previous buffer +/// :[N]sbprevious [N] split and to previous buffer static void ex_bprevious(exarg_T *eap) { goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); @@ -5087,12 +5044,10 @@ static void ex_bprevious(exarg_T *eap) } } -/* - * :brewind to first buffer - * :bfirst to first buffer - * :sbrewind split and to first buffer - * :sbfirst split and to first buffer - */ +/// :brewind to first buffer +/// :bfirst to first buffer +/// :sbrewind split and to first buffer +/// :sbfirst split and to first buffer static void ex_brewind(exarg_T *eap) { goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); @@ -5101,10 +5056,8 @@ static void ex_brewind(exarg_T *eap) } } -/* - * :blast to last buffer - * :sblast split and to last buffer - */ +/// :blast to last buffer +/// :sblast split and to last buffer static void ex_blast(exarg_T *eap) { goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); @@ -5118,10 +5071,8 @@ int ends_excmd(int c) FUNC_ATTR_CONST return c == NUL || c == '|' || c == '"' || c == '\n'; } -/* - * Return the next command, after the first '|' or '\n'. - * Return NULL if not found. - */ +/// @return the next command, after the first '|' or '\n' or, +/// NULL if not found. char_u *find_nextcmd(const char_u *p) { while (*p != '|' && *p != '\n') { @@ -5134,7 +5085,8 @@ char_u *find_nextcmd(const char_u *p) } /// Check if *p is a separator between Ex commands, skipping over white space. -/// Return NULL if it isn't, the following character if it is. +/// +/// @return NULL if it isn't, the following character if it is. char_u *check_nextcmd(char_u *p) { char_u *s = skipwhite(p); @@ -5150,9 +5102,10 @@ char_u *check_nextcmd(char_u *p) /// - and this is the last window /// - and forceit not used /// - and not repeated twice on a row -/// @return FAIL and give error message if 'message' TRUE, return OK otherwise /// /// @param message when FALSE check only, no messages +/// +/// @return FAIL and give error message if 'message' TRUE, return OK otherwise static int check_more(int message, bool forceit) { int n = ARGCOUNT - curwin->w_arg_idx - 1; @@ -5180,9 +5133,7 @@ static int check_more(int message, bool forceit) return OK; } -/* - * Function given to ExpandGeneric() to obtain the list of command names. - */ +/// Function given to ExpandGeneric() to obtain the list of command names. char_u *get_command_name(expand_T *xp, int idx) { if (idx >= CMD_SIZE) { @@ -5693,9 +5644,7 @@ invalid_count: static char e_complete_used_without_nargs[] = N_("E1208: -complete used without -nargs"); -/* - * ":command ..." - */ +/// ":command ..." static void ex_command(exarg_T *eap) { char_u *name; @@ -5749,10 +5698,8 @@ static void ex_command(exarg_T *eap) } } -/* - * ":comclear" - * Clear all user commands, global and for current buffer. - */ +/// ":comclear" +/// Clear all user commands, global and for current buffer. void ex_comclear(exarg_T *eap) { uc_clear(&ucmds); @@ -5768,9 +5715,7 @@ void free_ucmd(ucmd_T *cmd) NLUA_CLEAR_REF(cmd->uc_luaref); } -/* - * Clear all user commands for "gap". - */ +/// Clear all user commands for "gap". void uc_clear(garray_T *gap) { GA_DEEP_CLEAR(gap, ucmd_T, free_ucmd); @@ -5831,6 +5776,7 @@ static void ex_delcommand(exarg_T *eap) /// @param[out] start Start of the split /// @param[out] end End of the split /// @param[in] length Length of the string +/// /// @return false if it's the last split (don't call again), true otherwise (call again). bool uc_split_args_iter(const char_u *arg, int iter, int *start, int *end, int length) { @@ -5846,9 +5792,7 @@ bool uc_split_args_iter(const char_u *arg, int iter, int *start, int *end, int l return false; } -/* - * split and quote args for <f-args> - */ +/// split and quote args for <f-args> static char_u *uc_split_args(char_u *arg, size_t *lenp) { char_u *buf; @@ -6361,17 +6305,14 @@ static char_u *expand_user_command_name(int idx) { return get_user_commands(NULL, idx - CMD_SIZE); } -/* - * Function given to ExpandGeneric() to obtain the list of user address type names. - */ + +/// Function given to ExpandGeneric() to obtain the list of user address type names. char_u *get_user_cmd_addr_type(expand_T *xp, int idx) { return (char_u *)addr_type_complete[idx].name; } -/* - * Function given to ExpandGeneric() to obtain the list of user command names. - */ +/// Function given to ExpandGeneric() to obtain the list of user command names. char_u *get_user_commands(expand_T *xp FUNC_ATTR_UNUSED, int idx) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { @@ -6388,9 +6329,10 @@ char_u *get_user_commands(expand_T *xp FUNC_ATTR_UNUSED, int idx) return NULL; } -// Get the name of user command "idx". "cmdidx" can be CMD_USER or -// CMD_USER_BUF. -// Returns NULL if the command is not found. +/// Get the name of user command "idx". "cmdidx" can be CMD_USER or +/// CMD_USER_BUF. +/// +/// @return NULL if the command is not found. static char_u *get_user_command_name(int idx, int cmdidx) { if (cmdidx == CMD_USER && idx < ucmds.ga_len) { @@ -6407,10 +6349,8 @@ static char_u *get_user_command_name(int idx, int cmdidx) return NULL; } -/* - * Function given to ExpandGeneric() to obtain the list of user command - * attributes. - */ +/// Function given to ExpandGeneric() to obtain the list of user command +/// attributes. char_u *get_user_cmd_flags(expand_T *xp, int idx) { static char *user_cmd_flags[] = { "addr", "bang", "bar", @@ -6423,9 +6363,7 @@ char_u *get_user_cmd_flags(expand_T *xp, int idx) return (char_u *)user_cmd_flags[idx]; } -/* - * Function given to ExpandGeneric() to obtain the list of values for -nargs. - */ +/// Function given to ExpandGeneric() to obtain the list of values for -nargs. char_u *get_user_cmd_nargs(expand_T *xp, int idx) { static char *user_cmd_nargs[] = { "0", "1", "*", "?", "+" }; @@ -6436,9 +6374,7 @@ char_u *get_user_cmd_nargs(expand_T *xp, int idx) return (char_u *)user_cmd_nargs[idx]; } -/* - * Function given to ExpandGeneric() to obtain the list of values for -complete. - */ +/// Function given to ExpandGeneric() to obtain the list of values for -complete. char_u *get_user_cmd_complete(expand_T *xp, int idx) { if (idx >= (int)ARRAY_SIZE(command_complete)) { @@ -6452,9 +6388,7 @@ char_u *get_user_cmd_complete(expand_T *xp, int idx) } } -/* - * Parse address type argument - */ +/// Parse address type argument int parse_addr_type_arg(char_u *value, int vallen, cmd_addr_T *addr_type_arg) FUNC_ATTR_NONNULL_ALL { @@ -6481,13 +6415,12 @@ int parse_addr_type_arg(char_u *value, int vallen, cmd_addr_T *addr_type_arg) return OK; } -/* - * Parse a completion argument "value[vallen]". - * The detected completion goes in "*complp", argument type in "*argt". - * When there is an argument, for function and user defined completion, it's - * copied to allocated memory and stored in "*compl_arg". - * Returns FAIL if something is wrong. - */ +/// Parse a completion argument "value[vallen]". +/// The detected completion goes in "*complp", argument type in "*argt". +/// When there is an argument, for function and user defined completion, it's +/// copied to allocated memory and stored in "*compl_arg". +/// +/// @return FAIL if something is wrong. int parse_compl_arg(const char_u *value, int vallen, int *complp, uint32_t *argt, char_u **compl_arg) FUNC_ATTR_NONNULL_ALL @@ -6592,10 +6525,8 @@ static void ex_highlight(exarg_T *eap) } -/* - * Call this function if we thought we were going to exit, but we won't - * (because of an error). May need to restore the terminal mode. - */ +/// Call this function if we thought we were going to exit, but we won't +/// (because of an error). May need to restore the terminal mode. void not_exiting(void) { exiting = false; @@ -6630,8 +6561,8 @@ bool before_quit_autocmds(win_T *wp, bool quit_all, bool forceit) return false; } -// ":quit": quit current window, quit Vim if the last window is closed. -// ":{nr}quit": quit window {nr} +/// ":quit": quit current window, quit Vim if the last window is closed. +/// ":{nr}quit": quit window {nr} static void ex_quit(exarg_T *eap) { if (cmdwin_type != 0) { @@ -6731,9 +6662,7 @@ static void ex_quit_all(exarg_T *eap) not_exiting(); } -/* - * ":close": close current window, unless it is the last one - */ +/// ":close": close current window, unless it is the last one static void ex_close(exarg_T *eap) { win_T *win = NULL; @@ -6759,9 +6688,7 @@ static void ex_close(exarg_T *eap) } } -/* - * ":pclose": Close any preview window. - */ +/// ":pclose": Close any preview window. static void ex_pclose(exarg_T *eap) { FOR_ALL_WINDOWS_IN_TAB(win, curtab) { @@ -6812,10 +6739,8 @@ void ex_win_close(int forceit, win_T *win, tabpage_T *tp) } } -/* - * ":tabclose": close current tab page, unless it is the last one. - * ":tabclose N": close tab page N. - */ +/// ":tabclose": close current tab page, unless it is the last one. +/// ":tabclose N": close tab page N. static void ex_tabclose(exarg_T *eap) { tabpage_T *tp; @@ -6876,9 +6801,7 @@ static void ex_tabonly(exarg_T *eap) } } -/* - * Close the current tab page. - */ +/// Close the current tab page. void tabpage_close(int forceit) { // First close all the windows but the current one. If that worked then @@ -6894,12 +6817,10 @@ void tabpage_close(int forceit) } } -/* - * Close tab page "tp", which is not the current tab page. - * Note that autocommands may make "tp" invalid. - * Also takes care of the tab pages line disappearing when closing the - * last-but-one tab page. - */ +/// Close tab page "tp", which is not the current tab page. +/// Note that autocommands may make "tp" invalid. +/// Also takes care of the tab pages line disappearing when closing the +/// last-but-one tab page. void tabpage_close_other(tabpage_T *tp, int forceit) { int done = 0; @@ -6927,9 +6848,7 @@ void tabpage_close_other(tabpage_T *tp, int forceit) } } -/* - * ":only". - */ +/// ":only". static void ex_only(exarg_T *eap) { win_T *wp; @@ -6953,10 +6872,8 @@ static void ex_only(exarg_T *eap) close_others(TRUE, eap->forceit); } -/* - * ":all" and ":sall". - * Also used for ":tab drop file ..." after setting the argument list. - */ +/// ":all" and ":sall". +/// Also used for ":tab drop file ..." after setting the argument list. void ex_all(exarg_T *eap) { if (eap->addr_count == 0) { @@ -7011,7 +6928,7 @@ static void ex_stop(exarg_T *eap) apply_autocmds(EVENT_VIMRESUME, NULL, NULL, false, NULL); } -// ":exit", ":xit" and ":wq": Write file and quit the current window. +/// ":exit", ":xit" and ":wq": Write file and quit the current window. static void ex_exit(exarg_T *eap) { if (cmdwin_type != 0) { @@ -7047,9 +6964,7 @@ static void ex_exit(exarg_T *eap) } } -/* - * ":print", ":list", ":number". - */ +/// ":print", ":list", ":number". static void ex_print(exarg_T *eap) { if (curbuf->b_ml.ml_flags & ML_EMPTY) { @@ -7079,29 +6994,23 @@ static void ex_goto(exarg_T *eap) goto_byte(eap->line2); } -/* - * Clear an argument list: free all file names and reset it to zero entries. - */ +/// Clear an argument list: free all file names and reset it to zero entries. void alist_clear(alist_T *al) { #define FREE_AENTRY_FNAME(arg) xfree(arg->ae_fname) GA_DEEP_CLEAR(&al->al_ga, aentry_T, FREE_AENTRY_FNAME); } -/* - * Init an argument list. - */ +/// Init an argument list. void alist_init(alist_T *al) { ga_init(&al->al_ga, (int)sizeof(aentry_T), 5); } -/* - * Remove a reference from an argument list. - * Ignored when the argument list is the global one. - * If the argument list is no longer used by any window, free it. - */ +/// Remove a reference from an argument list. +/// Ignored when the argument list is the global one. +/// If the argument list is no longer used by any window, free it. void alist_unlink(alist_T *al) { if (al != &global_alist && --al->al_refcount <= 0) { @@ -7110,9 +7019,7 @@ void alist_unlink(alist_T *al) } } -/* - * Create a new argument list and use it for the current window. - */ +/// Create a new argument list and use it for the current window. void alist_new(void) { curwin->w_alist = xmalloc(sizeof(*curwin->w_alist)); @@ -7122,11 +7029,10 @@ void alist_new(void) } #if !defined(UNIX) -/* - * Expand the file names in the global argument list. - * If "fnum_list" is not NULL, use "fnum_list[fnum_len]" as a list of buffer - * numbers to be re-used. - */ + +/// Expand the file names in the global argument list. +/// If "fnum_list" is not NULL, use "fnum_list[fnum_len]" as a list of buffer +/// numbers to be re-used. void alist_expand(int *fnum_list, int fnum_len) { char_u **old_arg_files; @@ -7157,10 +7063,8 @@ void alist_expand(int *fnum_list, int fnum_len) } #endif -/* - * Set the argument list for the current window. - * Takes over the allocated files[] and the allocated fnames in it. - */ +/// Set the argument list for the current window. +/// Takes over the allocated files[] and the allocated fnames in it. void alist_set(alist_T *al, int count, char_u **files, int use_curbuf, int *fnum_list, int fnum_len) { int i; @@ -7224,9 +7128,8 @@ void alist_add(alist_T *al, char_u *fname, int set_fnum) } #if defined(BACKSLASH_IN_FILENAME) -/* - * Adjust slashes in file names. Called after 'shellslash' was set. - */ + +/// Adjust slashes in file names. Called after 'shellslash' was set. void alist_slash_adjust(void) { for (int i = 0; i < GARGCOUNT; ++i) { @@ -7272,27 +7175,23 @@ static void ex_recover(exarg_T *eap) recoverymode = false; } -/* - * Command modifier used in a wrong way. - */ +/// Command modifier used in a wrong way. static void ex_wrongmodifier(exarg_T *eap) { eap->errmsg = e_invcmd; } -/* - * :sview [+command] file split window with new file, read-only - * :split [[+command] file] split window with current or new file - * :vsplit [[+command] file] split window vertically with current or new file - * :new [[+command] file] split window with no or new file - * :vnew [[+command] file] split vertically window with no or new file - * :sfind [+command] file split window with file in 'path' - * - * :tabedit open new Tab page with empty window - * :tabedit [+command] file open new Tab page and edit "file" - * :tabnew [[+command] file] just like :tabedit - * :tabfind [+command] file open new Tab page and find "file" - */ +/// :sview [+command] file split window with new file, read-only +/// :split [[+command] file] split window with current or new file +/// :vsplit [[+command] file] split window vertically with current or new file +/// :new [[+command] file] split window with no or new file +/// :vnew [[+command] file] split vertically window with no or new file +/// :sfind [+command] file split window with file in 'path' +/// +/// :tabedit open new Tab page with empty window +/// :tabedit [+command] file open new Tab page and edit "file" +/// :tabnew [[+command] file] just like :tabedit +/// :tabfind [+command] file open new Tab page and find "file" void ex_splitview(exarg_T *eap) { win_T *old_curwin = curwin; @@ -7355,9 +7254,7 @@ theend: xfree(fname); } -/* - * Open a new tab page. - */ +/// Open a new tab page. void tabpage_new(void) { exarg_T ea; @@ -7369,9 +7266,7 @@ void tabpage_new(void) ex_splitview(&ea); } -/* - * :tabnext command - */ +/// :tabnext command static void ex_tabnext(exarg_T *eap) { int tab_number; @@ -7418,9 +7313,7 @@ static void ex_tabnext(exarg_T *eap) } } -/* - * :tabmove command - */ +/// :tabmove command static void ex_tabmove(exarg_T *eap) { int tab_number = get_tabpage_arg(eap); @@ -7429,9 +7322,7 @@ static void ex_tabmove(exarg_T *eap) } } -/* - * :tabs command: List tabs and their contents. - */ +/// :tabs command: List tabs and their contents. static void ex_tabs(exarg_T *eap) { int tabcount = 1; @@ -7477,10 +7368,8 @@ static void ex_tabs(exarg_T *eap) } -/* - * ":mode": - * If no argument given, get the screen size and redraw. - */ +/// ":mode": +/// If no argument given, get the screen size and redraw. static void ex_mode(exarg_T *eap) { if (*eap->arg == NUL) { @@ -7491,10 +7380,8 @@ static void ex_mode(exarg_T *eap) } } -/* - * ":resize". - * set, increment or decrement current window height - */ +/// ":resize". +/// set, increment or decrement current window height static void ex_resize(exarg_T *eap) { int n; @@ -7524,9 +7411,7 @@ static void ex_resize(exarg_T *eap) } } -/* - * ":find [+command] <file>" command. - */ +/// ":find [+command] <file>" command. static void ex_find(exarg_T *eap) { char_u *fname; @@ -7703,11 +7588,9 @@ static void ex_swapname(exarg_T *eap) } } -/* - * ":syncbind" forces all 'scrollbind' windows to have the same relative - * offset. - * (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) - */ +/// ":syncbind" forces all 'scrollbind' windows to have the same relative +/// offset. +/// (1998-11-02 16:21:01 R. Edward Ralston <eralston@computer.org>) static void ex_syncbind(exarg_T *eap) { win_T *save_curwin = curwin; @@ -7838,7 +7721,7 @@ void free_cd_dir(void) #endif -// Get the previous directory for the given chdir scope. +/// Get the previous directory for the given chdir scope. static char_u *get_prevdir(CdScope scope) { switch (scope) { @@ -8003,9 +7886,7 @@ void ex_cd(exarg_T *eap) } } -/* - * ":pwd". - */ +/// ":pwd". static void ex_pwd(exarg_T *eap) { if (os_dirname(NameBuff, MAXPATHL) == OK) { @@ -8030,9 +7911,7 @@ static void ex_pwd(exarg_T *eap) } } -/* - * ":=". - */ +/// ":=". static void ex_equal(exarg_T *eap) { smsg("%" PRId64, (int64_t)eap->line2); @@ -8063,9 +7942,7 @@ static void ex_sleep(exarg_T *eap) do_sleep(len); } -/* - * Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. - */ +/// Sleep for "msec" milliseconds, but keep checking for a CTRL-C every second. void do_sleep(long msec) { ui_flush(); // flush before waiting @@ -8101,9 +7978,7 @@ static void do_exmap(exarg_T *eap, int isabbrev) } } -/* - * ":winsize" command (obsolete). - */ +/// ":winsize" command (obsolete). static void ex_winsize(exarg_T *eap) { char_u *arg = eap->arg; @@ -8154,9 +8029,7 @@ static void ex_wincmd(exarg_T *eap) } } -/* - * Handle command that work like operators: ":delete", ":yank", ":>" and ":<". - */ +/// Handle command that work like operators: ":delete", ":yank", ":>" and ":<". static void ex_operators(exarg_T *eap) { oparg_T oa; @@ -8203,9 +8076,7 @@ static void ex_operators(exarg_T *eap) ex_may_print(eap); } -/* - * ":put". - */ +/// ":put". static void ex_put(exarg_T *eap) { // ":0put" works like ":1put!". @@ -8219,9 +8090,7 @@ static void ex_put(exarg_T *eap) PUT_LINE|PUT_CURSLINE); } -/* - * Handle ":copy" and ":move". - */ +/// Handle ":copy" and ":move". static void ex_copymove(exarg_T *eap) { long n = get_address(eap, &eap->arg, eap->addr_type, false, false, false, 1); @@ -8251,9 +8120,7 @@ static void ex_copymove(exarg_T *eap) ex_may_print(eap); } -/* - * Print the current line if flags were given to the Ex command. - */ +/// Print the current line if flags were given to the Ex command. void ex_may_print(exarg_T *eap) { if (eap->flags != 0) { @@ -8273,9 +8140,7 @@ static void ex_submagic(exarg_T *eap) p_magic = magic_save; } -/* - * ":join". - */ +/// ":join". static void ex_join(exarg_T *eap) { curwin->w_cursor.lnum = eap->line1; @@ -8294,9 +8159,7 @@ static void ex_join(exarg_T *eap) ex_may_print(eap); } -/* - * ":[addr]@r": execute register - */ +/// ":[addr]@r": execute register static void ex_at(exarg_T *eap) { int prev_len = typebuf.tb_len; @@ -8332,17 +8195,13 @@ static void ex_at(exarg_T *eap) } } -/* - * ":!". - */ +/// ":!". static void ex_bang(exarg_T *eap) { do_bang(eap->addr_count, eap, eap->forceit, true, true); } -/* - * ":undo". - */ +/// ":undo". static void ex_undo(exarg_T *eap) { if (eap->addr_count == 1) { // :undo 123 @@ -8408,9 +8267,7 @@ static void ex_later(exarg_T *eap) } } -/* - * ":redir": start/stop redirection. - */ +/// ":redir": start/stop redirection. static void ex_redir(exarg_T *eap) { char *mode; @@ -8551,7 +8408,7 @@ static void ex_redrawstatus(exarg_T *eap) ui_flush(); } -// ":redrawtabline": force redraw of the tabline +/// ":redrawtabline": force redraw of the tabline static void ex_redrawtabline(exarg_T *eap FUNC_ATTR_UNUSED) { const int r = RedrawingDisabled; @@ -8625,9 +8482,7 @@ FILE *open_exfile(char_u *fname, int forceit, char *mode) return fd; } -/* - * ":mark" and ":k". - */ +/// ":mark" and ":k". static void ex_mark(exarg_T *eap) { pos_T pos; @@ -8647,9 +8502,7 @@ static void ex_mark(exarg_T *eap) } } -/* - * Update w_topline, w_leftcol and the cursor position. - */ +/// Update w_topline, w_leftcol and the cursor position. void update_topline_cursor(void) { check_cursor(); // put cursor on valid line @@ -8660,8 +8513,9 @@ void update_topline_cursor(void) update_curswant(); } -// Save the current State and go to Normal mode. -// Return true if the typeahead could be saved. +/// Save the current State and go to Normal mode. +/// +/// @return true if the typeahead could be saved. bool save_current_state(save_state_T *sst) FUNC_ATTR_NONNULL_ALL { @@ -8713,9 +8567,7 @@ void restore_current_state(save_state_T *sst) ui_cursor_shape(); // may show different cursor shape } -/* - * ":normal[!] {commands}": Execute normal mode commands. - */ +/// ":normal[!] {commands}": Execute normal mode commands. static void ex_normal(exarg_T *eap) { if (curbuf->terminal && State & TERM_FOCUS) { @@ -8796,9 +8648,7 @@ static void ex_normal(exarg_T *eap) xfree(arg); } -/* - * ":startinsert", ":startreplace" and ":startgreplace" - */ +/// ":startinsert", ":startreplace" and ":startgreplace" static void ex_startinsert(exarg_T *eap) { if (eap->forceit) { @@ -8835,9 +8685,7 @@ static void ex_startinsert(exarg_T *eap) } } -/* - * ":stopinsert" - */ +/// ":stopinsert" static void ex_stopinsert(exarg_T *eap) { restart_edit = 0; @@ -8845,10 +8693,8 @@ static void ex_stopinsert(exarg_T *eap) clearmode(); } -/* - * Execute normal mode command "cmd". - * "remap" can be REMAP_NONE or REMAP_YES. - */ +/// Execute normal mode command "cmd". +/// "remap" can be REMAP_NONE or REMAP_YES. void exec_normal_cmd(char_u *cmd, int remap, bool silent) { // Stuff the argument into the typeahead buffer. @@ -8881,9 +8727,7 @@ static void ex_checkpath(exarg_T *eap) (linenr_T)1, (linenr_T)MAXLNUM); } -/* - * ":psearch" - */ +/// ":psearch" static void ex_psearch(exarg_T *eap) { g_do_tagpreview = p_pvh; @@ -8946,18 +8790,14 @@ static void ex_findpat(exarg_T *eap) } -/* - * ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. - */ +/// ":ptag", ":ptselect", ":ptjump", ":ptnext", etc. static void ex_ptag(exarg_T *eap) { g_do_tagpreview = p_pvh; // will be reset to 0 in ex_tag_cmd() ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name + 1); } -/* - * ":pedit" - */ +/// ":pedit" static void ex_pedit(exarg_T *eap) { win_T *curwin_save = curwin; @@ -8978,9 +8818,7 @@ static void ex_pedit(exarg_T *eap) g_do_tagpreview = 0; } -/* - * ":stag", ":stselect" and ":stjump". - */ +/// ":stag", ":stselect" and ":stjump". static void ex_stag(exarg_T *eap) { postponed_split = -1; @@ -8991,9 +8829,7 @@ static void ex_stag(exarg_T *eap) postponed_split_tab = 0; } -/* - * ":tag", ":tselect", ":tjump", ":tnext", etc. - */ +/// ":tag", ":tselect", ":tjump", ":tnext", etc. static void ex_tag(exarg_T *eap) { ex_tag_cmd(eap, cmdnames[eap->cmdidx].cmd_name); @@ -9062,11 +8898,9 @@ enum { // SPEC_CLIENT, }; -/* - * Check "str" for starting with a special cmdline variable. - * If found return one of the SPEC_ values and set "*usedlen" to the length of - * the variable. Otherwise return -1 and "*usedlen" is unchanged. - */ +/// Check "str" for starting with a special cmdline variable. +/// If found return one of the SPEC_ values and set "*usedlen" to the length of +/// the variable. Otherwise return -1 and "*usedlen" is unchanged. ssize_t find_cmdline_var(const char_u *src, size_t *usedlen) FUNC_ATTR_NONNULL_ALL { @@ -9379,11 +9213,9 @@ char_u *eval_vars(char_u *src, char_u *srcstart, size_t *usedlen, linenr_T *lnum return result; } -/* - * Concatenate all files in the argument list, separated by spaces, and return - * it in one allocated string. - * Spaces and backslashes in the file names are escaped with a backslash. - */ +/// Concatenate all files in the argument list, separated by spaces, and return +/// it in one allocated string. +/// Spaces and backslashes in the file names are escaped with a backslash. static char_u *arg_all(void) { int len; @@ -9442,11 +9274,9 @@ static char_u *arg_all(void) return retval; } -/* - * Expand the <sfile> string in "arg". - * - * Returns an allocated string, or NULL for any error. - */ +/// Expand the <sfile> string in "arg". +/// +/// @return an allocated string, or NULL for any error. char_u *expand_sfile(char_u *arg) { char *errormsg; @@ -9492,9 +9322,7 @@ char_u *expand_sfile(char_u *arg) return result; } -/* - * ":rshada" and ":wshada". - */ +/// ":rshada" and ":wshada". static void ex_shada(exarg_T *eap) { char_u *save_shada; @@ -9511,10 +9339,8 @@ static void ex_shada(exarg_T *eap) p_shada = save_shada; } -/* - * Make a dialog message in "buff[DIALOG_MSG_SIZE]". - * "format" must contain "%s". - */ +/// Make a dialog message in "buff[DIALOG_MSG_SIZE]". +/// "format" must contain "%s". void dialog_msg(char_u *buff, char *format, char_u *fname) { if (fname == NULL) { @@ -9523,9 +9349,7 @@ void dialog_msg(char_u *buff, char *format, char_u *fname) vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); } -/* - * ":behave {mswin,xterm}" - */ +/// ":behave {mswin,xterm}" static void ex_behave(exarg_T *eap) { if (STRCMP(eap->arg, "mswin") == 0) { @@ -9543,10 +9367,8 @@ static void ex_behave(exarg_T *eap) } } -/* - * Function given to ExpandGeneric() to obtain the possible arguments of the - * ":behave {mswin,xterm}" command. - */ +/// Function given to ExpandGeneric() to obtain the possible arguments of the +/// ":behave {mswin,xterm}" command. char_u *get_behave_arg(expand_T *xp, int idx) { if (idx == 0) { @@ -9558,8 +9380,8 @@ char_u *get_behave_arg(expand_T *xp, int idx) return NULL; } -// Function given to ExpandGeneric() to obtain the possible arguments of the -// ":messages {clear}" command. +/// Function given to ExpandGeneric() to obtain the possible arguments of the +/// ":messages {clear}" command. char_u *get_messages_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) { if (idx == 0) { @@ -9580,15 +9402,13 @@ static TriState filetype_detect = kNone; static TriState filetype_plugin = kNone; static TriState filetype_indent = kNone; -/* - * ":filetype [plugin] [indent] {on,off,detect}" - * on: Load the filetype.vim file to install autocommands for file types. - * off: Load the ftoff.vim file to remove all autocommands for file types. - * plugin on: load filetype.vim and ftplugin.vim - * plugin off: load ftplugof.vim - * indent on: load filetype.vim and indent.vim - * indent off: load indoff.vim - */ +/// ":filetype [plugin] [indent] {on,off,detect}" +/// on: Load the filetype.vim file to install autocommands for file types. +/// off: Load the ftoff.vim file to remove all autocommands for file types. +/// plugin on: load filetype.vim and ftplugin.vim +/// plugin off: load ftplugof.vim +/// indent on: load filetype.vim and indent.vim +/// indent off: load indoff.vim static void ex_filetype(exarg_T *eap) { char_u *arg = eap->arg; @@ -9714,79 +9534,13 @@ void set_no_hlsearch(bool flag) set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls); } -/* - * ":nohlsearch" - */ +/// ":nohlsearch" static void ex_nohlsearch(exarg_T *eap) { set_no_hlsearch(true); redraw_all_later(SOME_VALID); } -// ":[N]match {group} {pattern}" -// Sets nextcmd to the start of the next command, if any. Also called when -// skipping commands to find the next command. -static void ex_match(exarg_T *eap) -{ - char_u *p; - char_u *g = NULL; - char_u *end; - int c; - int id; - - if (eap->line2 <= 3) { - id = eap->line2; - } else { - emsg(e_invcmd); - return; - } - - // First clear any old pattern. - if (!eap->skip) { - match_delete(curwin, id, false); - } - - if (ends_excmd(*eap->arg)) { - end = eap->arg; - } else if ((STRNICMP(eap->arg, "none", 4) == 0 - && (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) { - end = eap->arg + 4; - } else { - p = skiptowhite(eap->arg); - if (!eap->skip) { - g = vim_strnsave(eap->arg, p - eap->arg); - } - p = skipwhite(p); - if (*p == NUL) { - // There must be two arguments. - xfree(g); - semsg(_(e_invarg2), eap->arg); - return; - } - end = skip_regexp(p + 1, *p, true, NULL); - if (!eap->skip) { - if (*end != NUL && !ends_excmd(*skipwhite(end + 1))) { - xfree(g); - eap->errmsg = e_trailing; - return; - } - if (*end != *p) { - xfree(g); - semsg(_(e_invarg2), p); - return; - } - - c = *end; - *end = NUL; - match_add(curwin, (const char *)g, (const char *)p + 1, 10, id, - NULL, NULL); - xfree(g); - *end = c; - } - } - eap->nextcmd = find_nextcmd(end); -} - static void ex_fold(exarg_T *eap) { if (foldManualAllowed(true)) { @@ -9816,8 +9570,8 @@ static void ex_folddo(exarg_T *eap) ml_clearmarked(); // clear rest of the marks } -// Returns true if the supplied Ex cmdidx is for a location list command -// instead of a quickfix command. +/// @return true if the supplied Ex cmdidx is for a location list command +/// instead of a quickfix command. bool is_loclist_cmd(int cmdidx) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index f342ada3db..ee78a79a97 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -2,18 +2,25 @@ // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com // highlight_group.c: code for managing highlight groups +// Includes highlighting matches +#include <stdbool.h> #include "nvim/autocmd.h" #include "nvim/api/private/helpers.h" #include "nvim/charset.h" #include "nvim/cursor_shape.h" +#include "nvim/eval/funcs.h" +#include "nvim/eval/typval.h" #include "nvim/ex_docmd.h" +#include "nvim/fold.h" #include "nvim/garray.h" #include "nvim/highlight.h" #include "nvim/highlight_group.h" #include "nvim/lua/executor.h" #include "nvim/map.h" +#include "nvim/memline.h" #include "nvim/option.h" +#include "nvim/regexp.h" #include "nvim/runtime.h" #include "nvim/screen.h" @@ -25,6 +32,9 @@ /// @} #define MAX_SYN_NAME 200 +#define SEARCH_HL_PRIORITY 0 + +static char *e_invalwindow = N_("E957: Invalid window number"); // builtin |highlight-groups| static garray_T highlight_ga = GA_EMPTY_INIT_VALUE; @@ -2797,3 +2807,1163 @@ int name_to_ctermcolor(const char *name) TriState bold = kNone; return lookup_color(i, false, &bold); } + +/// Add match to the match list of window 'wp'. The pattern 'pat' will be +/// highlighted with the group 'grp' with priority 'prio'. +/// Optionally, a desired ID 'id' can be specified (greater than or equal to 1). +/// +/// @param[in] id a desired ID 'id' can be specified +/// (greater than or equal to 1). -1 must be specified if no +/// particular ID is desired +/// @param[in] conceal_char pointer to conceal replacement char +/// @return ID of added match, -1 on failure. +static int match_add(win_T *wp, const char *const grp, const char *const pat, int prio, int id, + list_T *pos_list, const char *const conceal_char) + FUNC_ATTR_NONNULL_ARG(1, 2) +{ + matchitem_T *cur; + matchitem_T *prev; + matchitem_T *m; + int hlg_id; + regprog_T *regprog = NULL; + int rtype = SOME_VALID; + + if (*grp == NUL || (pat != NULL && *pat == NUL)) { + return -1; + } + if (id < -1 || id == 0) { + semsg(_("E799: Invalid ID: %" PRId64 + " (must be greater than or equal to 1)"), + (int64_t)id); + return -1; + } + if (id != -1) { + cur = wp->w_match_head; + while (cur != NULL) { + if (cur->id == id) { + semsg(_("E801: ID already taken: %" PRId64), (int64_t)id); + return -1; + } + cur = cur->next; + } + } + if ((hlg_id = syn_check_group(grp, strlen(grp))) == 0) { + return -1; + } + if (pat != NULL && (regprog = vim_regcomp((char_u *)pat, RE_MAGIC)) == NULL) { + semsg(_(e_invarg2), pat); + return -1; + } + + // Find available match ID. + while (id == -1) { + cur = wp->w_match_head; + while (cur != NULL && cur->id != wp->w_next_match_id) { + cur = cur->next; + } + if (cur == NULL) { + id = wp->w_next_match_id; + } + wp->w_next_match_id++; + } + + // Build new match. + m = xcalloc(1, sizeof(matchitem_T)); + m->id = id; + m->priority = prio; + m->pattern = pat == NULL ? NULL: (char_u *)xstrdup(pat); + m->hlg_id = hlg_id; + m->match.regprog = regprog; + m->match.rmm_ic = false; + m->match.rmm_maxcol = 0; + m->conceal_char = 0; + if (conceal_char != NULL) { + m->conceal_char = utf_ptr2char((const char_u *)conceal_char); + } + + // Set up position matches + if (pos_list != NULL) { + linenr_T toplnum = 0; + linenr_T botlnum = 0; + + int i = 0; + TV_LIST_ITER(pos_list, li, { + linenr_T lnum = 0; + colnr_T col = 0; + int len = 1; + bool error = false; + + if (TV_LIST_ITEM_TV(li)->v_type == VAR_LIST) { + const list_T *const subl = TV_LIST_ITEM_TV(li)->vval.v_list; + const listitem_T *subli = tv_list_first(subl); + if (subli == NULL) { + semsg(_("E5030: Empty list at position %d"), + (int)tv_list_idx_of_item(pos_list, li)); + goto fail; + } + lnum = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); + if (error) { + goto fail; + } + if (lnum <= 0) { + continue; + } + m->pos.pos[i].lnum = lnum; + subli = TV_LIST_ITEM_NEXT(subl, subli); + if (subli != NULL) { + col = (colnr_T)tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); + if (error) { + goto fail; + } + if (col < 0) { + continue; + } + subli = TV_LIST_ITEM_NEXT(subl, subli); + if (subli != NULL) { + len = (colnr_T)tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); + if (len < 0) { + continue; + } + if (error) { + goto fail; + } + } + } + m->pos.pos[i].col = col; + m->pos.pos[i].len = len; + } else if (TV_LIST_ITEM_TV(li)->v_type == VAR_NUMBER) { + if (TV_LIST_ITEM_TV(li)->vval.v_number <= 0) { + continue; + } + m->pos.pos[i].lnum = TV_LIST_ITEM_TV(li)->vval.v_number; + m->pos.pos[i].col = 0; + m->pos.pos[i].len = 0; + } else { + semsg(_("E5031: List or number required at position %d"), + (int)tv_list_idx_of_item(pos_list, li)); + goto fail; + } + if (toplnum == 0 || lnum < toplnum) { + toplnum = lnum; + } + if (botlnum == 0 || lnum >= botlnum) { + botlnum = lnum + 1; + } + i++; + if (i >= MAXPOSMATCH) { + break; + } + }); + + // Calculate top and bottom lines for redrawing area + if (toplnum != 0) { + if (wp->w_buffer->b_mod_set) { + if (wp->w_buffer->b_mod_top > toplnum) { + wp->w_buffer->b_mod_top = toplnum; + } + if (wp->w_buffer->b_mod_bot < botlnum) { + wp->w_buffer->b_mod_bot = botlnum; + } + } else { + wp->w_buffer->b_mod_set = true; + wp->w_buffer->b_mod_top = toplnum; + wp->w_buffer->b_mod_bot = botlnum; + wp->w_buffer->b_mod_xlines = 0; + } + m->pos.toplnum = toplnum; + m->pos.botlnum = botlnum; + rtype = VALID; + } + } + + // Insert new match. The match list is in ascending order with regard to + // the match priorities. + cur = wp->w_match_head; + prev = cur; + while (cur != NULL && prio >= cur->priority) { + prev = cur; + cur = cur->next; + } + if (cur == prev) { + wp->w_match_head = m; + } else { + prev->next = m; + } + m->next = cur; + + redraw_later(wp, rtype); + return id; + +fail: + xfree(m); + return -1; +} + +/// Delete match with ID 'id' in the match list of window 'wp'. +/// +/// @param perr print error messages if true. +static int match_delete(win_T *wp, int id, bool perr) +{ + matchitem_T *cur = wp->w_match_head; + matchitem_T *prev = cur; + int rtype = SOME_VALID; + + if (id < 1) { + if (perr) { + semsg(_("E802: Invalid ID: %" PRId64 + " (must be greater than or equal to 1)"), + (int64_t)id); + } + return -1; + } + while (cur != NULL && cur->id != id) { + prev = cur; + cur = cur->next; + } + if (cur == NULL) { + if (perr) { + semsg(_("E803: ID not found: %" PRId64), (int64_t)id); + } + return -1; + } + if (cur == prev) { + wp->w_match_head = cur->next; + } else { + prev->next = cur->next; + } + vim_regfree(cur->match.regprog); + xfree(cur->pattern); + if (cur->pos.toplnum != 0) { + if (wp->w_buffer->b_mod_set) { + if (wp->w_buffer->b_mod_top > cur->pos.toplnum) { + wp->w_buffer->b_mod_top = cur->pos.toplnum; + } + if (wp->w_buffer->b_mod_bot < cur->pos.botlnum) { + wp->w_buffer->b_mod_bot = cur->pos.botlnum; + } + } else { + wp->w_buffer->b_mod_set = true; + wp->w_buffer->b_mod_top = cur->pos.toplnum; + wp->w_buffer->b_mod_bot = cur->pos.botlnum; + wp->w_buffer->b_mod_xlines = 0; + } + rtype = VALID; + } + xfree(cur); + redraw_later(wp, rtype); + return 0; +} + +/// Delete all matches in the match list of window 'wp'. +void clear_matches(win_T *wp) +{ + matchitem_T *m; + + while (wp->w_match_head != NULL) { + m = wp->w_match_head->next; + vim_regfree(wp->w_match_head->match.regprog); + xfree(wp->w_match_head->pattern); + xfree(wp->w_match_head); + wp->w_match_head = m; + } + redraw_later(wp, SOME_VALID); +} + +/// Get match from ID 'id' in window 'wp'. +/// Return NULL if match not found. +matchitem_T *get_match(win_T *wp, int id) +{ + matchitem_T *cur = wp->w_match_head; + + while (cur != NULL && cur->id != id) { + cur = cur->next; + } + return cur; +} + +/// Init for calling prepare_search_hl(). +void init_search_hl(win_T *wp, match_T *search_hl) + FUNC_ATTR_NONNULL_ALL +{ + // Setup for match and 'hlsearch' highlighting. Disable any previous + // match + matchitem_T *cur = wp->w_match_head; + while (cur != NULL) { + cur->hl.rm = cur->match; + if (cur->hlg_id == 0) { + cur->hl.attr = 0; + } else { + cur->hl.attr = syn_id2attr(cur->hlg_id); + } + cur->hl.buf = wp->w_buffer; + cur->hl.lnum = 0; + cur->hl.first_lnum = 0; + // Set the time limit to 'redrawtime'. + cur->hl.tm = profile_setlimit(p_rdt); + cur = cur->next; + } + search_hl->buf = wp->w_buffer; + search_hl->lnum = 0; + search_hl->first_lnum = 0; + search_hl->attr = win_hl_attr(wp, HLF_L); + + // time limit is set at the toplevel, for all windows +} + +/// @param shl points to a match. Fill on match. +/// @param posmatch match positions +/// @param mincol minimal column for a match +/// +/// @return one on match, otherwise return zero. +static int next_search_hl_pos(match_T *shl, linenr_T lnum, posmatch_T *posmatch, colnr_T mincol) + FUNC_ATTR_NONNULL_ALL +{ + int i; + int found = -1; + + shl->lnum = 0; + for (i = posmatch->cur; i < MAXPOSMATCH; i++) { + llpos_T *pos = &posmatch->pos[i]; + + if (pos->lnum == 0) { + break; + } + if (pos->len == 0 && pos->col < mincol) { + continue; + } + if (pos->lnum == lnum) { + if (found >= 0) { + // if this match comes before the one at "found" then swap + // them + if (pos->col < posmatch->pos[found].col) { + llpos_T tmp = *pos; + + *pos = posmatch->pos[found]; + posmatch->pos[found] = tmp; + } + } else { + found = i; + } + } + } + posmatch->cur = 0; + if (found >= 0) { + colnr_T start = posmatch->pos[found].col == 0 + ? 0: posmatch->pos[found].col - 1; + colnr_T end = posmatch->pos[found].col == 0 + ? MAXCOL : start + posmatch->pos[found].len; + + shl->lnum = lnum; + shl->rm.startpos[0].lnum = 0; + shl->rm.startpos[0].col = start; + shl->rm.endpos[0].lnum = 0; + shl->rm.endpos[0].col = end; + shl->is_addpos = true; + posmatch->cur = found + 1; + return 1; + } + return 0; +} + +/// Search for a next 'hlsearch' or match. +/// Uses shl->buf. +/// Sets shl->lnum and shl->rm contents. +/// Note: Assumes a previous match is always before "lnum", unless +/// shl->lnum is zero. +/// Careful: Any pointers for buffer lines will become invalid. +/// +/// @param shl points to search_hl or a match +/// @param mincol minimal column for a match +/// @param cur to retrieve match positions if any +static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_T lnum, + colnr_T mincol, matchitem_T *cur) + FUNC_ATTR_NONNULL_ARG(2) +{ + linenr_T l; + colnr_T matchcol; + long nmatched = 0; + int save_called_emsg = called_emsg; + + // for :{range}s/pat only highlight inside the range + if (lnum < search_first_line || lnum > search_last_line) { + shl->lnum = 0; + return; + } + + if (shl->lnum != 0) { + // Check for three situations: + // 1. If the "lnum" is below a previous match, start a new search. + // 2. If the previous match includes "mincol", use it. + // 3. Continue after the previous match. + l = shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum; + if (lnum > l) { + shl->lnum = 0; + } else if (lnum < l || shl->rm.endpos[0].col > mincol) { + return; + } + } + + // Repeat searching for a match until one is found that includes "mincol" + // or none is found in this line. + called_emsg = false; + for (;;) { + // Stop searching after passing the time limit. + if (profile_passed_limit(shl->tm)) { + shl->lnum = 0; // no match found in time + break; + } + // Three situations: + // 1. No useful previous match: search from start of line. + // 2. Not Vi compatible or empty match: continue at next character. + // Break the loop if this is beyond the end of the line. + // 3. Vi compatible searching: continue at end of previous match. + if (shl->lnum == 0) { + matchcol = 0; + } else if (vim_strchr(p_cpo, CPO_SEARCH) == NULL + || (shl->rm.endpos[0].lnum == 0 + && shl->rm.endpos[0].col <= shl->rm.startpos[0].col)) { + char_u *ml; + + matchcol = shl->rm.startpos[0].col; + ml = ml_get_buf(shl->buf, lnum, false) + matchcol; + if (*ml == NUL) { + matchcol++; + shl->lnum = 0; + break; + } + matchcol += utfc_ptr2len(ml); + } else { + matchcol = shl->rm.endpos[0].col; + } + + shl->lnum = lnum; + if (shl->rm.regprog != NULL) { + // Remember whether shl->rm is using a copy of the regprog in + // cur->match. + bool regprog_is_copy = (shl != search_hl + && cur != NULL + && shl == &cur->hl + && cur->match.regprog == cur->hl.rm.regprog); + int timed_out = false; + + nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum, matchcol, + &(shl->tm), &timed_out); + // Copy the regprog, in case it got freed and recompiled. + if (regprog_is_copy) { + cur->match.regprog = cur->hl.rm.regprog; + } + if (called_emsg || got_int || timed_out) { + // Error while handling regexp: stop using this regexp. + if (shl == search_hl) { + // don't free regprog in the match list, it's a copy + vim_regfree(shl->rm.regprog); + set_no_hlsearch(true); + } + shl->rm.regprog = NULL; + shl->lnum = 0; + got_int = false; // avoid the "Type :quit to exit Vim" message + break; + } + } else if (cur != NULL) { + nmatched = next_search_hl_pos(shl, lnum, &(cur->pos), matchcol); + } + if (nmatched == 0) { + shl->lnum = 0; // no match found + break; + } + if (shl->rm.startpos[0].lnum > 0 + || shl->rm.startpos[0].col >= mincol + || nmatched > 1 + || shl->rm.endpos[0].col > mincol) { + shl->lnum += shl->rm.startpos[0].lnum; + break; // useful match found + } + + // Restore called_emsg for assert_fails(). + called_emsg = save_called_emsg; + } +} + +/// Advance to the match in window "wp" line "lnum" or past it. +void prepare_search_hl(win_T *wp, match_T *search_hl, linenr_T lnum) + FUNC_ATTR_NONNULL_ALL +{ + matchitem_T *cur; // points to the match list + match_T *shl; // points to search_hl or a match + bool shl_flag; // flag to indicate whether search_hl + // has been processed or not + + // When using a multi-line pattern, start searching at the top + // of the window or just after a closed fold. + // Do this both for search_hl and the match list. + cur = wp->w_match_head; + shl_flag = false; + while (cur != NULL || shl_flag == false) { + if (shl_flag == false) { + shl = search_hl; + shl_flag = true; + } else { + shl = &cur->hl; // -V595 + } + if (shl->rm.regprog != NULL + && shl->lnum == 0 + && re_multiline(shl->rm.regprog)) { + if (shl->first_lnum == 0) { + for (shl->first_lnum = lnum; + shl->first_lnum > wp->w_topline; + shl->first_lnum--) { + if (hasFoldingWin(wp, shl->first_lnum - 1, NULL, NULL, true, NULL)) { + break; + } + } + } + if (cur != NULL) { + cur->pos.cur = 0; + } + bool pos_inprogress = true; // mark that a position match search is + // in progress + int n = 0; + while (shl->first_lnum < lnum && (shl->rm.regprog != NULL + || (cur != NULL && pos_inprogress))) { + next_search_hl(wp, search_hl, shl, shl->first_lnum, (colnr_T)n, + shl == search_hl ? NULL : cur); + pos_inprogress = !(cur == NULL || cur->pos.cur == 0); + if (shl->lnum != 0) { + shl->first_lnum = shl->lnum + + shl->rm.endpos[0].lnum + - shl->rm.startpos[0].lnum; + n = shl->rm.endpos[0].col; + } else { + shl->first_lnum++; + n = 0; + } + } + } + if (shl != search_hl && cur != NULL) { + cur = cur->next; + } + } +} + +/// Prepare for 'hlsearch' and match highlighting in one window line. +/// Return true if there is such highlighting and set "search_attr" to the +/// current highlight attribute. +bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u **line, + match_T *search_hl, int *search_attr, bool *search_attr_from_match) +{ + matchitem_T *cur = wp->w_match_head; // points to the match list + match_T *shl; // points to search_hl or a match + bool shl_flag = false; // flag to indicate whether search_hl + // has been processed or not + bool area_highlighting = false; + + // Handle highlighting the last used search pattern and matches. + // Do this for both search_hl and the match list. + while (cur != NULL || !shl_flag) { + if (!shl_flag) { + shl = search_hl; + shl_flag = true; + } else { + shl = &cur->hl; // -V595 + } + shl->startcol = MAXCOL; + shl->endcol = MAXCOL; + shl->attr_cur = 0; + shl->is_addpos = false; + if (cur != NULL) { + cur->pos.cur = 0; + } + next_search_hl(wp, search_hl, shl, lnum, mincol, + shl == search_hl ? NULL : cur); + + // Need to get the line again, a multi-line regexp may have made it + // invalid. + *line = ml_get_buf(wp->w_buffer, lnum, false); + + if (shl->lnum != 0 && shl->lnum <= lnum) { + if (shl->lnum == lnum) { + shl->startcol = shl->rm.startpos[0].col; + } else { + shl->startcol = 0; + } + if (lnum == shl->lnum + shl->rm.endpos[0].lnum + - shl->rm.startpos[0].lnum) { + shl->endcol = shl->rm.endpos[0].col; + } else { + shl->endcol = MAXCOL; + } + // Highlight one character for an empty match. + if (shl->startcol == shl->endcol) { + if ((*line)[shl->endcol] != NUL) { + shl->endcol += utfc_ptr2len(*line + shl->endcol); + } else { + shl->endcol++; + } + } + if ((long)shl->startcol < mincol) { // match at leftcol + shl->attr_cur = shl->attr; + *search_attr = shl->attr; + *search_attr_from_match = shl != search_hl; + } + area_highlighting = true; + } + if (shl != search_hl && cur != NULL) { + cur = cur->next; + } + } + return area_highlighting; +} + +/// For a position in a line: Check for start/end of 'hlsearch' and other +/// matches. +/// After end, check for start/end of next match. +/// When another match, have to check for start again. +/// Watch out for matching an empty string! +/// Return the updated search_attr. +int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char_u **line, match_T *search_hl, + int *has_match_conc, int *match_conc, int lcs_eol_one, + bool *search_attr_from_match) +{ + matchitem_T *cur = wp->w_match_head; // points to the match list + match_T *shl; // points to search_hl or a match + bool shl_flag = false; // flag to indicate whether search_hl + // has been processed or not + int search_attr = 0; + + // Do this for 'search_hl' and the match list (ordered by priority). + while (cur != NULL || !shl_flag) { + if (!shl_flag + && (cur == NULL || cur->priority > SEARCH_HL_PRIORITY)) { + shl = search_hl; + shl_flag = true; + } else { + shl = &cur->hl; + } + if (cur != NULL) { + cur->pos.cur = 0; + } + bool pos_inprogress = true; // mark that a position match search is + // in progress + while (shl->rm.regprog != NULL + || (cur != NULL && pos_inprogress)) { + if (shl->startcol != MAXCOL + && col >= shl->startcol + && col < shl->endcol) { + int next_col = col + utfc_ptr2len(*line + col); + + if (shl->endcol < next_col) { + shl->endcol = next_col; + } + shl->attr_cur = shl->attr; + // Match with the "Conceal" group results in hiding + // the match. + if (cur != NULL + && shl != search_hl + && syn_name2id("Conceal") == cur->hlg_id) { + *has_match_conc = col == shl->startcol ? 2 : 1; + *match_conc = cur->conceal_char; + } else { + *has_match_conc = 0; + } + } else if (col == shl->endcol) { + shl->attr_cur = 0; + + next_search_hl(wp, search_hl, shl, lnum, col, + shl == search_hl ? NULL : cur); + pos_inprogress = !(cur == NULL || cur->pos.cur == 0); + + // Need to get the line again, a multi-line regexp + // may have made it invalid. + *line = ml_get_buf(wp->w_buffer, lnum, false); + + if (shl->lnum == lnum) { + shl->startcol = shl->rm.startpos[0].col; + if (shl->rm.endpos[0].lnum == 0) { + shl->endcol = shl->rm.endpos[0].col; + } else { + shl->endcol = MAXCOL; + } + + if (shl->startcol == shl->endcol) { + // highlight empty match, try again after it + shl->endcol += utfc_ptr2len(*line + shl->endcol); + } + + // Loop to check if the match starts at the + // current position + continue; + } + } + break; + } + if (shl != search_hl && cur != NULL) { + cur = cur->next; + } + } + + // Use attributes from match with highest priority among + // 'search_hl' and the match list. + *search_attr_from_match = false; + search_attr = search_hl->attr_cur; + cur = wp->w_match_head; + shl_flag = false; + while (cur != NULL || !shl_flag) { + if (!shl_flag + && (cur == NULL || cur->priority > SEARCH_HL_PRIORITY)) { + shl = search_hl; + shl_flag = true; + } else { + shl = &cur->hl; + } + if (shl->attr_cur != 0) { + search_attr = shl->attr_cur; + *search_attr_from_match = shl != search_hl; + } + if (shl != search_hl && cur != NULL) { + cur = cur->next; + } + } + // Only highlight one character after the last column. + if (*(*line + col) == NUL && (wp->w_p_list && lcs_eol_one == -1)) { + search_attr = 0; + } + return search_attr; +} + +bool get_prevcol_hl_flag(win_T *wp, match_T *search_hl, long curcol) +{ + long prevcol = curcol; + matchitem_T *cur; // points to the match list + + // we're not really at that column when skipping some text + if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol) { + prevcol++; + } + + if (!search_hl->is_addpos && prevcol == search_hl->startcol) { + return true; + } else { + cur = wp->w_match_head; + while (cur != NULL) { + if (!cur->hl.is_addpos && prevcol == cur->hl.startcol) { + return true; + } + cur = cur->next; + } + } + return false; +} + +/// Get highlighting for the char after the text in "char_attr" from 'hlsearch' +/// or match highlighting. +void get_search_match_hl(win_T *wp, match_T *search_hl, long col, int *char_attr) +{ + matchitem_T *cur = wp->w_match_head; // points to the match list + match_T *shl; // points to search_hl or a match + bool shl_flag = false; // flag to indicate whether search_hl + // has been processed or not + + *char_attr = search_hl->attr; + while (cur != NULL || !shl_flag) { + if (!shl_flag + && (cur == NULL || cur->priority > SEARCH_HL_PRIORITY)) { + shl = search_hl; + shl_flag = true; + } else { + shl = &cur->hl; + } + if (col - 1 == (long)shl->startcol + && (shl == search_hl || !shl->is_addpos)) { + *char_attr = shl->attr; + } + if (shl != search_hl && cur != NULL) { + cur = cur->next; + } + } +} + +static int matchadd_dict_arg(typval_T *tv, const char **conceal_char, win_T **win) +{ + dictitem_T *di; + + if (tv->v_type != VAR_DICT) { + emsg(_(e_dictreq)); + return FAIL; + } + + if ((di = tv_dict_find(tv->vval.v_dict, S_LEN("conceal"))) != NULL) { + *conceal_char = tv_get_string(&di->di_tv); + } + + if ((di = tv_dict_find(tv->vval.v_dict, S_LEN("window"))) != NULL) { + *win = find_win_by_nr_or_id(&di->di_tv); + if (*win == NULL) { + emsg(_(e_invalwindow)); + return FAIL; + } + } + + return OK; +} + +/// "clearmatches()" function +void f_clearmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + win_T *win = get_optional_window(argvars, 0); + + if (win != NULL) { + clear_matches(win); + } +} + +/// "getmatches()" function +void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + matchitem_T *cur; + int i; + win_T *win = get_optional_window(argvars, 0); + + if (win == NULL) { + return; + } + + tv_list_alloc_ret(rettv, kListLenMayKnow); + cur = win->w_match_head; + while (cur != NULL) { + dict_T *dict = tv_dict_alloc(); + if (cur->match.regprog == NULL) { + // match added with matchaddpos() + for (i = 0; i < MAXPOSMATCH; i++) { + llpos_T *llpos; + char buf[30]; // use 30 to avoid compiler warning + + llpos = &cur->pos.pos[i]; + if (llpos->lnum == 0) { + break; + } + list_T *const l = tv_list_alloc(1 + (llpos->col > 0 ? 2 : 0)); + tv_list_append_number(l, (varnumber_T)llpos->lnum); + if (llpos->col > 0) { + tv_list_append_number(l, (varnumber_T)llpos->col); + tv_list_append_number(l, (varnumber_T)llpos->len); + } + int len = snprintf(buf, sizeof(buf), "pos%d", i + 1); + assert((size_t)len < sizeof(buf)); + tv_dict_add_list(dict, buf, (size_t)len, l); + } + } else { + tv_dict_add_str(dict, S_LEN("pattern"), (const char *)cur->pattern); + } + tv_dict_add_str(dict, S_LEN("group"), + (const char *)syn_id2name(cur->hlg_id)); + tv_dict_add_nr(dict, S_LEN("priority"), (varnumber_T)cur->priority); + tv_dict_add_nr(dict, S_LEN("id"), (varnumber_T)cur->id); + + if (cur->conceal_char) { + char buf[MB_MAXBYTES + 1]; + + buf[utf_char2bytes(cur->conceal_char, (char_u *)buf)] = NUL; + tv_dict_add_str(dict, S_LEN("conceal"), buf); + } + + tv_list_append_dict(rettv->vval.v_list, dict); + cur = cur->next; + } +} + +/// "setmatches()" function +void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + dict_T *d; + list_T *s = NULL; + win_T *win = get_optional_window(argvars, 1); + + rettv->vval.v_number = -1; + if (argvars[0].v_type != VAR_LIST) { + emsg(_(e_listreq)); + return; + } + if (win == NULL) { + return; + } + + list_T *const l = argvars[0].vval.v_list; + // To some extent make sure that we are dealing with a list from + // "getmatches()". + int li_idx = 0; + TV_LIST_ITER_CONST(l, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT + || (d = TV_LIST_ITEM_TV(li)->vval.v_dict) == NULL) { + semsg(_("E474: List item %d is either not a dictionary " + "or an empty one"), li_idx); + return; + } + if (!(tv_dict_find(d, S_LEN("group")) != NULL + && (tv_dict_find(d, S_LEN("pattern")) != NULL + || tv_dict_find(d, S_LEN("pos1")) != NULL) + && tv_dict_find(d, S_LEN("priority")) != NULL + && tv_dict_find(d, S_LEN("id")) != NULL)) { + semsg(_("E474: List item %d is missing one of the required keys"), + li_idx); + return; + } + li_idx++; + }); + + clear_matches(win); + bool match_add_failed = false; + TV_LIST_ITER_CONST(l, li, { + int i = 0; + + d = TV_LIST_ITEM_TV(li)->vval.v_dict; + dictitem_T *const di = tv_dict_find(d, S_LEN("pattern")); + if (di == NULL) { + if (s == NULL) { + s = tv_list_alloc(9); + } + + // match from matchaddpos() + for (i = 1; i < 9; i++) { + char buf[30]; // use 30 to avoid compiler warning + snprintf(buf, sizeof(buf), "pos%d", i); + dictitem_T *const pos_di = tv_dict_find(d, buf, -1); + if (pos_di != NULL) { + if (pos_di->di_tv.v_type != VAR_LIST) { + return; + } + + tv_list_append_tv(s, &pos_di->di_tv); + tv_list_ref(s); + } else { + break; + } + } + } + + // Note: there are three number buffers involved: + // - group_buf below. + // - numbuf in tv_dict_get_string(). + // - mybuf in tv_get_string(). + // + // If you change this code make sure that buffers will not get + // accidentally reused. + char group_buf[NUMBUFLEN]; + const char *const group = tv_dict_get_string_buf(d, "group", group_buf); + const int priority = (int)tv_dict_get_number(d, "priority"); + const int id = (int)tv_dict_get_number(d, "id"); + dictitem_T *const conceal_di = tv_dict_find(d, S_LEN("conceal")); + const char *const conceal = (conceal_di != NULL + ? tv_get_string(&conceal_di->di_tv) + : NULL); + if (i == 0) { + if (match_add(win, group, + tv_dict_get_string(d, "pattern", false), + priority, id, NULL, conceal) != id) { + match_add_failed = true; + } + } else { + if (match_add(win, group, NULL, priority, id, s, conceal) != id) { + match_add_failed = true; + } + tv_list_unref(s); + s = NULL; + } + }); + if (!match_add_failed) { + rettv->vval.v_number = 0; + } +} + + +/// "matchadd()" function +void f_matchadd(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + char grpbuf[NUMBUFLEN]; + char patbuf[NUMBUFLEN]; + // group + const char *const grp = tv_get_string_buf_chk(&argvars[0], grpbuf); + // pattern + const char *const pat = tv_get_string_buf_chk(&argvars[1], patbuf); + // default priority + int prio = 10; + int id = -1; + bool error = false; + const char *conceal_char = NULL; + win_T *win = curwin; + + rettv->vval.v_number = -1; + + if (grp == NULL || pat == NULL) { + return; + } + if (argvars[2].v_type != VAR_UNKNOWN) { + prio = (int)tv_get_number_chk(&argvars[2], &error); + if (argvars[3].v_type != VAR_UNKNOWN) { + id = (int)tv_get_number_chk(&argvars[3], &error); + if (argvars[4].v_type != VAR_UNKNOWN + && matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL) { + return; + } + } + } + if (error) { + return; + } + if (id >= 1 && id <= 3) { + semsg(_("E798: ID is reserved for \":match\": %" PRId64), (int64_t)id); + return; + } + + rettv->vval.v_number = match_add(win, grp, pat, prio, id, NULL, conceal_char); +} + +/// "matchaddpo()" function +void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + rettv->vval.v_number = -1; + + char buf[NUMBUFLEN]; + const char *const group = tv_get_string_buf_chk(&argvars[0], buf); + if (group == NULL) { + return; + } + + if (argvars[1].v_type != VAR_LIST) { + semsg(_(e_listarg), "matchaddpos()"); + return; + } + + list_T *l; + l = argvars[1].vval.v_list; + if (l == NULL) { + return; + } + + bool error = false; + int prio = 10; + int id = -1; + const char *conceal_char = NULL; + win_T *win = curwin; + + if (argvars[2].v_type != VAR_UNKNOWN) { + prio = (int)tv_get_number_chk(&argvars[2], &error); + if (argvars[3].v_type != VAR_UNKNOWN) { + id = (int)tv_get_number_chk(&argvars[3], &error); + if (argvars[4].v_type != VAR_UNKNOWN + && matchadd_dict_arg(&argvars[4], &conceal_char, &win) == FAIL) { + return; + } + } + } + if (error == true) { + return; + } + + // id == 3 is ok because matchaddpos() is supposed to substitute :3match + if (id == 1 || id == 2) { + semsg(_("E798: ID is reserved for \"match\": %" PRId64), (int64_t)id); + return; + } + + rettv->vval.v_number = match_add(win, group, NULL, prio, id, l, conceal_char); +} + +/// "matcharg()" function +void f_matcharg(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + const int id = (int)tv_get_number(&argvars[0]); + + tv_list_alloc_ret(rettv, (id >= 1 && id <= 3 + ? 2 + : 0)); + + if (id >= 1 && id <= 3) { + matchitem_T *const m = get_match(curwin, id); + + if (m != NULL) { + tv_list_append_string(rettv->vval.v_list, + (const char *)syn_id2name(m->hlg_id), -1); + tv_list_append_string(rettv->vval.v_list, (const char *)m->pattern, -1); + } else { + tv_list_append_string(rettv->vval.v_list, NULL, 0); + tv_list_append_string(rettv->vval.v_list, NULL, 0); + } + } +} + +/// "matchdelete()" function +void f_matchdelete(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + win_T *win = get_optional_window(argvars, 1); + if (win == NULL) { + rettv->vval.v_number = -1; + } else { + rettv->vval.v_number = match_delete(win, + (int)tv_get_number(&argvars[0]), true); + } +} + +/// ":[N]match {group} {pattern}" +/// Sets nextcmd to the start of the next command, if any. Also called when +/// skipping commands to find the next command. +void ex_match(exarg_T *eap) +{ + char_u *p; + char_u *g = NULL; + char_u *end; + int c; + int id; + + if (eap->line2 <= 3) { + id = (int)eap->line2; + } else { + emsg(e_invcmd); + return; + } + + // First clear any old pattern. + if (!eap->skip) { + match_delete(curwin, id, false); + } + + if (ends_excmd(*eap->arg)) { + end = eap->arg; + } else if ((STRNICMP(eap->arg, "none", 4) == 0 + && (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) { + end = eap->arg + 4; + } else { + p = skiptowhite(eap->arg); + if (!eap->skip) { + g = vim_strnsave(eap->arg, (size_t)(p - eap->arg)); + } + p = skipwhite(p); + if (*p == NUL) { + // There must be two arguments. + xfree(g); + semsg(_(e_invarg2), eap->arg); + return; + } + end = skip_regexp(p + 1, *p, true, NULL); + if (!eap->skip) { + if (*end != NUL && !ends_excmd(*skipwhite(end + 1))) { + xfree(g); + eap->errmsg = e_trailing; + return; + } + if (*end != *p) { + xfree(g); + semsg(_(e_invarg2), p); + return; + } + + c = *end; + *end = NUL; + match_add(curwin, (const char *)g, (const char *)p + 1, 10, id, + NULL, NULL); + xfree(g); + *end = (char_u)c; + } + } + eap->nextcmd = find_nextcmd(end); +} + diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 0bb224c729..ef49a03660 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -477,8 +477,7 @@ static bool typval_conv_special = false; #define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun) \ do { \ ufunc_T *fp = find_func(fun); \ - assert(fp != NULL); \ - if (fp->uf_cb == nlua_CFunction_func_call) { \ + if (fp != NULL && fp->uf_cb == nlua_CFunction_func_call) { \ nlua_pushref(lstate, ((LuaCFunctionState *)fp->uf_cb_state)->lua_callable.func_ref); \ } else { \ TYPVAL_ENCODE_CONV_NIL(tv); \ diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 244a1881aa..fc66fb5f06 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2835,9 +2835,7 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append) curr->y_size = j; xfree(reg->y_array); } - if (curwin->w_p_rnu) { - redraw_later(curwin, SOME_VALID); // cursor moved to start - } + if (message) { // Display message about yank? if (yank_type == kMTCharWise && yanklines == 1) { yanklines = 0; diff --git a/src/nvim/po/ru.po b/src/nvim/po/ru.po index 3a96ece2fb..5d3e51b7e2 100644 --- a/src/nvim/po/ru.po +++ b/src/nvim/po/ru.po @@ -959,7 +959,6 @@ msgstr "E129: Требуется имя функции" #, c-format msgid "E128: Function name must start with a capital or \"s:\": %s" msgstr "E128: Имя функции должно начинаться с заглавной буквы или \"s:\": %s" -"двоеточие: %s" #: ../eval.c:17833 #, c-format @@ -1578,7 +1577,7 @@ msgstr "E494: Используйте w или w>>" #: ../ex_docmd.c:3454 msgid "E319: The command is not available in this version" -msgstr "E319: Извините, эта команда недоступна в данной версии" +msgstr "E319: Эта команда недоступна в данной версии" #: ../ex_docmd.c:3752 msgid "E172: Only one file name allowed" @@ -2055,7 +2054,7 @@ msgstr "E201: Автокоманды *ReadPre не должны изменять #: ../fileio.c:672 msgid "Nvim: Reading from stdin...\n" -msgstr "Vim: Чтение из стандартного потока ввода stdin...\n" +msgstr "Nvim: Чтение из стандартного потока ввода stdin...\n" #. Re-opening the original file failed! #: ../fileio.c:909 @@ -2427,7 +2426,7 @@ msgstr "--Удалено--" #: ../fileio.c:5732 #, c-format msgid "auto-removing autocommand: %s <buffer=%d>" -msgstr "авто-удаление автокоманды: %s <буффер=%d>" +msgstr "авто-удаление автокоманды: %s <буфер=%d>" #. the group doesn't exist #: ../fileio.c:5772 @@ -2666,11 +2665,11 @@ msgstr "E17: \"%s\" является каталогом" #: ../globals.h:1020 #, fuzzy msgid "E900: Invalid job id" -msgstr "E49: Недопустимый размер прокрутки" +msgstr "E900: Недопустимый идентификатор задания" #: ../globals.h:1021 msgid "E901: Job table is full" -msgstr "" +msgstr "E901: Таблица заданий переполнена" #: ../globals.h:1024 #, c-format @@ -2707,9 +2706,7 @@ msgstr "E477: ! не допускается" #: ../globals.h:1035 msgid "E25: Nvim does not have a built-in GUI" -msgstr "" -"E25: Возможность использования графического интерфейса выключена при " -"компиляции" +msgstr "E25: У Nvim нет встроенного графического интерфейса" #: ../globals.h:1036 #, c-format @@ -3351,10 +3348,10 @@ msgstr "E282: Невозможно выполнить чтение из \"%s\"" #: ../main.c:2149 msgid "" "\n" -"More info with: \"vim -h\"\n" +"More info with: \"" msgstr "" "\n" -"Дополнительная информация: \"vim -h\"\n" +"Дополнительная информация: \"" #: ../main.c:2178 msgid "[file ..] edit specified file(s)" @@ -4413,7 +4410,7 @@ msgstr "E663: В конце списка изменений" #: ../normal.c:7053 msgid "Type :quit<Enter> to exit Nvim" -msgstr "Введите :quit<Enter> для выхода из Vim" +msgstr "Введите :quit<Enter> для выхода из Nvim" #: ../ops.c:248 #, c-format @@ -4521,6 +4518,7 @@ msgid "" "lines" msgstr "" "E883: шаблон поиска и регистр выражения не могут содержать двух или более " +"строк" #: ../ops.c:5089 #, c-format @@ -6137,7 +6135,7 @@ msgstr "Vim: Ошибка чтения ввода, выход...\n" #: ../undo.c:379 #, fuzzy msgid "E881: Line count changed unexpectedly" -msgstr "E834: Неожиданно изменился счётчик строк" +msgstr "E881: Неожиданно изменился счётчик строк" #: ../undo.c:627 #, c-format diff --git a/src/nvim/regexp_bt.c b/src/nvim/regexp_bt.c index 1153b8ed33..7340957903 100644 --- a/src/nvim/regexp_bt.c +++ b/src/nvim/regexp_bt.c @@ -526,8 +526,6 @@ static void regmbc(int c) } } -#define REGMBC(x) regmbc(x); -#define CASEMBC(x) case x: /* * Produce the bytes for equivalence class "c". @@ -538,297 +536,465 @@ static void reg_equi_class(int c) { { switch (c) { - // Do not use '\300' style, it results in a negative number. - case 'A': case 0xc0: case 0xc1: case 0xc2: - case 0xc3: case 0xc4: case 0xc5: - CASEMBC(0x100) CASEMBC(0x102) CASEMBC(0x104) CASEMBC(0x1cd) - CASEMBC(0x1de) CASEMBC(0x1e0) CASEMBC(0x1ea2) - regmbc('A'); regmbc(0xc0); regmbc(0xc1); - regmbc(0xc2); regmbc(0xc3); regmbc(0xc4); - regmbc(0xc5); - REGMBC(0x100) REGMBC(0x102) REGMBC(0x104) - REGMBC(0x1cd) REGMBC(0x1de) REGMBC(0x1e0) - REGMBC(0x1ea2) + // Do not use '\300' style, it results in a negative number. + case 'A': case 0xc0: case 0xc1: case 0xc2: case 0xc3: case 0xc4: + case 0xc5: case 0x100: case 0x102: case 0x104: case 0x1cd: + case 0x1de: case 0x1e0: case 0x1fa: case 0x202: case 0x226: + case 0x23a: case 0x1e00: case 0x1ea0: case 0x1ea2: case 0x1ea4: + case 0x1ea6: case 0x1ea8: case 0x1eaa: case 0x1eac: case 0x1eae: + case 0x1eb0: case 0x1eb2: case 0x1eb4: case 0x1eb6: + regmbc('A'); regmbc(0xc0); regmbc(0xc1); regmbc(0xc2); + regmbc(0xc3); regmbc(0xc4); regmbc(0xc5); + regmbc(0x100); regmbc(0x102); regmbc(0x104); + regmbc(0x1cd); regmbc(0x1de); regmbc(0x1e0); + regmbc(0x1fa); regmbc(0x202); regmbc(0x226); + regmbc(0x23a); regmbc(0x1e00); regmbc(0x1ea0); + regmbc(0x1ea2); regmbc(0x1ea4); regmbc(0x1ea6); + regmbc(0x1ea8); regmbc(0x1eaa); regmbc(0x1eac); + regmbc(0x1eae); regmbc(0x1eb0); regmbc(0x1eb2); + regmbc(0x1eb4); regmbc(0x1eb6); return; - case 'B': CASEMBC(0x1e02) CASEMBC(0x1e06) - regmbc('B'); REGMBC(0x1e02) REGMBC(0x1e06) + case 'B': case 0x181: case 0x243: case 0x1e02: + case 0x1e04: case 0x1e06: + regmbc('B'); + regmbc(0x181); regmbc(0x243); regmbc(0x1e02); + regmbc(0x1e04); regmbc(0x1e06); return; case 'C': case 0xc7: - CASEMBC(0x106) CASEMBC(0x108) CASEMBC(0x10a) CASEMBC(0x10c) + case 0x106: case 0x108: case 0x10a: case 0x10c: case 0x187: + case 0x23b: case 0x1e08: case 0xa792: regmbc('C'); regmbc(0xc7); - REGMBC(0x106) REGMBC(0x108) REGMBC(0x10a) - REGMBC(0x10c) + regmbc(0x106); regmbc(0x108); regmbc(0x10a); + regmbc(0x10c); regmbc(0x187); regmbc(0x23b); + regmbc(0x1e08); regmbc(0xa792); return; - case 'D': CASEMBC(0x10e) CASEMBC(0x110) CASEMBC(0x1e0a) - CASEMBC(0x1e0e) CASEMBC(0x1e10) - regmbc('D'); REGMBC(0x10e) REGMBC(0x110) - REGMBC(0x1e0a) REGMBC(0x1e0e) REGMBC(0x1e10) + case 'D': case 0x10e: case 0x110: case 0x18a: + case 0x1e0a: case 0x1e0c: case 0x1e0e: case 0x1e10: + case 0x1e12: + regmbc('D'); regmbc(0x10e); regmbc(0x110); + regmbc(0x18a); regmbc(0x1e0a); regmbc(0x1e0c); + regmbc(0x1e0e); regmbc(0x1e10); regmbc(0x1e12); return; case 'E': case 0xc8: case 0xc9: case 0xca: case 0xcb: - CASEMBC(0x112) CASEMBC(0x114) CASEMBC(0x116) CASEMBC(0x118) - CASEMBC(0x11a) CASEMBC(0x1eba) CASEMBC(0x1ebc) + case 0x112: case 0x114: case 0x116: case 0x118: case 0x11a: + case 0x204: case 0x206: case 0x228: case 0x246: case 0x1e14: + case 0x1e16: case 0x1e18: case 0x1e1a: case 0x1e1c: + case 0x1eb8: case 0x1eba: case 0x1ebc: case 0x1ebe: + case 0x1ec0: case 0x1ec2: case 0x1ec4: case 0x1ec6: regmbc('E'); regmbc(0xc8); regmbc(0xc9); - regmbc(0xca); regmbc(0xcb); - REGMBC(0x112) REGMBC(0x114) REGMBC(0x116) - REGMBC(0x118) REGMBC(0x11a) REGMBC(0x1eba) - REGMBC(0x1ebc) + regmbc(0xca); regmbc(0xcb); regmbc(0x112); + regmbc(0x114); regmbc(0x116); regmbc(0x118); + regmbc(0x11a); regmbc(0x204); regmbc(0x206); + regmbc(0x228); regmbc(0x246); regmbc(0x1e14); + regmbc(0x1e16); regmbc(0x1e18); regmbc(0x1e1a); + regmbc(0x1e1c); regmbc(0x1eb8); regmbc(0x1eba); + regmbc(0x1ebc); regmbc(0x1ebe); regmbc(0x1ec0); + regmbc(0x1ec2); regmbc(0x1ec4); regmbc(0x1ec6); return; - case 'F': CASEMBC(0x1e1e) - regmbc('F'); REGMBC(0x1e1e) + case 'F': case 0x191: case 0x1e1e: case 0xa798: + regmbc('F'); regmbc(0x191); regmbc(0x1e1e); + regmbc(0xa798); return; - case 'G': CASEMBC(0x11c) CASEMBC(0x11e) CASEMBC(0x120) - CASEMBC(0x122) CASEMBC(0x1e4) CASEMBC(0x1e6) CASEMBC(0x1f4) - CASEMBC(0x1e20) - regmbc('G'); REGMBC(0x11c) REGMBC(0x11e) - REGMBC(0x120) REGMBC(0x122) REGMBC(0x1e4) - REGMBC(0x1e6) REGMBC(0x1f4) REGMBC(0x1e20) + case 'G': case 0x11c: case 0x11e: case 0x120: + case 0x122: case 0x193: case 0x1e4: case 0x1e6: + case 0x1f4: case 0x1e20: case 0xa7a0: + regmbc('G'); regmbc(0x11c); regmbc(0x11e); + regmbc(0x120); regmbc(0x122); regmbc(0x193); + regmbc(0x1e4); regmbc(0x1e6); regmbc(0x1f4); + regmbc(0x1e20); regmbc(0xa7a0); return; - case 'H': CASEMBC(0x124) CASEMBC(0x126) CASEMBC(0x1e22) - CASEMBC(0x1e26) CASEMBC(0x1e28) - regmbc('H'); REGMBC(0x124) REGMBC(0x126) - REGMBC(0x1e22) REGMBC(0x1e26) REGMBC(0x1e28) + case 'H': case 0x124: case 0x126: case 0x21e: + case 0x1e22: case 0x1e24: case 0x1e26: + case 0x1e28: case 0x1e2a: case 0x2c67: + regmbc('H'); regmbc(0x124); regmbc(0x126); + regmbc(0x21e); regmbc(0x1e22); regmbc(0x1e24); + regmbc(0x1e26); regmbc(0x1e28); regmbc(0x1e2a); + regmbc(0x2c67); return; case 'I': case 0xcc: case 0xcd: case 0xce: case 0xcf: - CASEMBC(0x128) CASEMBC(0x12a) CASEMBC(0x12c) CASEMBC(0x12e) - CASEMBC(0x130) CASEMBC(0x1cf) CASEMBC(0x1ec8) + case 0x128: case 0x12a: case 0x12c: case 0x12e: + case 0x130: case 0x197: case 0x1cf: case 0x208: + case 0x20a: case 0x1e2c: case 0x1e2e: case 0x1ec8: + case 0x1eca: regmbc('I'); regmbc(0xcc); regmbc(0xcd); - regmbc(0xce); regmbc(0xcf); - REGMBC(0x128) REGMBC(0x12a) REGMBC(0x12c) - REGMBC(0x12e) REGMBC(0x130) REGMBC(0x1cf) - REGMBC(0x1ec8) + regmbc(0xce); regmbc(0xcf); regmbc(0x128); + regmbc(0x12a); regmbc(0x12c); regmbc(0x12e); + regmbc(0x130); regmbc(0x197); regmbc(0x1cf); + regmbc(0x208); regmbc(0x20a); regmbc(0x1e2c); + regmbc(0x1e2e); regmbc(0x1ec8); regmbc(0x1eca); return; - case 'J': CASEMBC(0x134) - regmbc('J'); REGMBC(0x134) + case 'J': case 0x134: case 0x248: + regmbc('J'); regmbc(0x134); regmbc(0x248); return; - case 'K': CASEMBC(0x136) CASEMBC(0x1e8) CASEMBC(0x1e30) - CASEMBC(0x1e34) - regmbc('K'); REGMBC(0x136) REGMBC(0x1e8) - REGMBC(0x1e30) REGMBC(0x1e34) + case 'K': case 0x136: case 0x198: case 0x1e8: case 0x1e30: + case 0x1e32: case 0x1e34: case 0x2c69: case 0xa740: + regmbc('K'); regmbc(0x136); regmbc(0x198); + regmbc(0x1e8); regmbc(0x1e30); regmbc(0x1e32); + regmbc(0x1e34); regmbc(0x2c69); regmbc(0xa740); return; - case 'L': CASEMBC(0x139) CASEMBC(0x13b) CASEMBC(0x13d) - CASEMBC(0x13f) CASEMBC(0x141) CASEMBC(0x1e3a) - regmbc('L'); REGMBC(0x139) REGMBC(0x13b) - REGMBC(0x13d) REGMBC(0x13f) REGMBC(0x141) - REGMBC(0x1e3a) + case 'L': case 0x139: case 0x13b: case 0x13d: case 0x13f: + case 0x141: case 0x23d: case 0x1e36: case 0x1e38: + case 0x1e3a: case 0x1e3c: case 0x2c60: + regmbc('L'); regmbc(0x139); regmbc(0x13b); + regmbc(0x13d); regmbc(0x13f); regmbc(0x141); + regmbc(0x23d); regmbc(0x1e36); regmbc(0x1e38); + regmbc(0x1e3a); regmbc(0x1e3c); regmbc(0x2c60); return; - case 'M': CASEMBC(0x1e3e) CASEMBC(0x1e40) - regmbc('M'); REGMBC(0x1e3e) REGMBC(0x1e40) + case 'M': case 0x1e3e: case 0x1e40: case 0x1e42: + regmbc('M'); regmbc(0x1e3e); regmbc(0x1e40); + regmbc(0x1e42); return; case 'N': case 0xd1: - CASEMBC(0x143) CASEMBC(0x145) CASEMBC(0x147) CASEMBC(0x1e44) - CASEMBC(0x1e48) + case 0x143: case 0x145: case 0x147: case 0x1f8: + case 0x1e44: case 0x1e46: case 0x1e48: case 0x1e4a: + case 0xa7a4: regmbc('N'); regmbc(0xd1); - REGMBC(0x143) REGMBC(0x145) REGMBC(0x147) - REGMBC(0x1e44) REGMBC(0x1e48) + regmbc(0x143); regmbc(0x145); regmbc(0x147); + regmbc(0x1f8); regmbc(0x1e44); regmbc(0x1e46); + regmbc(0x1e48); regmbc(0x1e4a); regmbc(0xa7a4); return; - case 'O': case 0xd2: case 0xd3: case 0xd4: case 0xd5: - case 0xd6: case 0xd8: - CASEMBC(0x14c) CASEMBC(0x14e) CASEMBC(0x150) CASEMBC(0x1a0) - CASEMBC(0x1d1) CASEMBC(0x1ea) CASEMBC(0x1ec) CASEMBC(0x1ece) - regmbc('O'); regmbc(0xd2); regmbc(0xd3); - regmbc(0xd4); regmbc(0xd5); regmbc(0xd6); - regmbc(0xd8); - REGMBC(0x14c) REGMBC(0x14e) REGMBC(0x150) - REGMBC(0x1a0) REGMBC(0x1d1) REGMBC(0x1ea) - REGMBC(0x1ec) REGMBC(0x1ece) + case 'O': case 0xd2: case 0xd3: case 0xd4: case 0xd5: case 0xd6: + case 0xd8: case 0x14c: case 0x14e: case 0x150: case 0x19f: + case 0x1a0: case 0x1d1: case 0x1ea: case 0x1ec: case 0x1fe: + case 0x20c: case 0x20e: case 0x22a: case 0x22c: case 0x22e: + case 0x230: case 0x1e4c: case 0x1e4e: case 0x1e50: case 0x1e52: + case 0x1ecc: case 0x1ece: case 0x1ed0: case 0x1ed2: case 0x1ed4: + case 0x1ed6: case 0x1ed8: case 0x1eda: case 0x1edc: case 0x1ede: + case 0x1ee0: case 0x1ee2: + regmbc('O'); regmbc(0xd2); regmbc(0xd3); regmbc(0xd4); + regmbc(0xd5); regmbc(0xd6); regmbc(0xd8); + regmbc(0x14c); regmbc(0x14e); regmbc(0x150); + regmbc(0x19f); regmbc(0x1a0); regmbc(0x1d1); + regmbc(0x1ea); regmbc(0x1ec); regmbc(0x1fe); + regmbc(0x20c); regmbc(0x20e); regmbc(0x22a); + regmbc(0x22c); regmbc(0x22e); regmbc(0x230); + regmbc(0x1e4c); regmbc(0x1e4e); regmbc(0x1e50); + regmbc(0x1e52); regmbc(0x1ecc); regmbc(0x1ece); + regmbc(0x1ed0); regmbc(0x1ed2); regmbc(0x1ed4); + regmbc(0x1ed6); regmbc(0x1ed8); regmbc(0x1eda); + regmbc(0x1edc); regmbc(0x1ede); regmbc(0x1ee0); + regmbc(0x1ee2); return; - case 'P': case 0x1e54: case 0x1e56: - regmbc('P'); REGMBC(0x1e54) REGMBC(0x1e56) + case 'P': case 0x1a4: case 0x1e54: case 0x1e56: case 0x2c63: + regmbc('P'); regmbc(0x1a4); regmbc(0x1e54); + regmbc(0x1e56); regmbc(0x2c63); return; - case 'R': CASEMBC(0x154) CASEMBC(0x156) CASEMBC(0x158) - CASEMBC(0x1e58) CASEMBC(0x1e5e) - regmbc('R'); REGMBC(0x154) REGMBC(0x156) REGMBC(0x158) - REGMBC(0x1e58) REGMBC(0x1e5e) + case 'Q': case 0x24a: + regmbc('Q'); regmbc(0x24a); return; - case 'S': CASEMBC(0x15a) CASEMBC(0x15c) CASEMBC(0x15e) - CASEMBC(0x160) CASEMBC(0x1e60) - regmbc('S'); REGMBC(0x15a) REGMBC(0x15c) - REGMBC(0x15e) REGMBC(0x160) REGMBC(0x1e60) + case 'R': case 0x154: case 0x156: case 0x158: case 0x210: + case 0x212: case 0x24c: case 0x1e58: case 0x1e5a: + case 0x1e5c: case 0x1e5e: case 0x2c64: case 0xa7a6: + regmbc('R'); regmbc(0x154); regmbc(0x156); + regmbc(0x210); regmbc(0x212); regmbc(0x158); + regmbc(0x24c); regmbc(0x1e58); regmbc(0x1e5a); + regmbc(0x1e5c); regmbc(0x1e5e); regmbc(0x2c64); + regmbc(0xa7a6); return; - case 'T': CASEMBC(0x162) CASEMBC(0x164) CASEMBC(0x166) - CASEMBC(0x1e6a) CASEMBC(0x1e6e) - regmbc('T'); REGMBC(0x162) REGMBC(0x164) - REGMBC(0x166) REGMBC(0x1e6a) REGMBC(0x1e6e) + case 'S': case 0x15a: case 0x15c: case 0x15e: case 0x160: + case 0x218: case 0x1e60: case 0x1e62: case 0x1e64: + case 0x1e66: case 0x1e68: case 0x2c7e: case 0xa7a8: + regmbc('S'); regmbc(0x15a); regmbc(0x15c); + regmbc(0x15e); regmbc(0x160); regmbc(0x218); + regmbc(0x1e60); regmbc(0x1e62); regmbc(0x1e64); + regmbc(0x1e66); regmbc(0x1e68); regmbc(0x2c7e); + regmbc(0xa7a8); + return; + case 'T': case 0x162: case 0x164: case 0x166: case 0x1ac: + case 0x1ae: case 0x21a: case 0x23e: case 0x1e6a: case 0x1e6c: + case 0x1e6e: case 0x1e70: + regmbc('T'); regmbc(0x162); regmbc(0x164); + regmbc(0x166); regmbc(0x1ac); regmbc(0x23e); + regmbc(0x1ae); regmbc(0x21a); regmbc(0x1e6a); + regmbc(0x1e6c); regmbc(0x1e6e); regmbc(0x1e70); return; case 'U': case 0xd9: case 0xda: case 0xdb: case 0xdc: - CASEMBC(0x168) CASEMBC(0x16a) CASEMBC(0x16c) CASEMBC(0x16e) - CASEMBC(0x170) CASEMBC(0x172) CASEMBC(0x1af) CASEMBC(0x1d3) - CASEMBC(0x1ee6) + case 0x168: case 0x16a: case 0x16c: case 0x16e: + case 0x170: case 0x172: case 0x1af: case 0x1d3: + case 0x1d5: case 0x1d7: case 0x1d9: case 0x1db: + case 0x214: case 0x216: case 0x244: case 0x1e72: + case 0x1e74: case 0x1e76: case 0x1e78: case 0x1e7a: + case 0x1ee4: case 0x1ee6: case 0x1ee8: case 0x1eea: + case 0x1eec: case 0x1eee: case 0x1ef0: regmbc('U'); regmbc(0xd9); regmbc(0xda); - regmbc(0xdb); regmbc(0xdc); - REGMBC(0x168) REGMBC(0x16a) REGMBC(0x16c) - REGMBC(0x16e) REGMBC(0x170) REGMBC(0x172) - REGMBC(0x1af) REGMBC(0x1d3) REGMBC(0x1ee6) + regmbc(0xdb); regmbc(0xdc); regmbc(0x168); + regmbc(0x16a); regmbc(0x16c); regmbc(0x16e); + regmbc(0x170); regmbc(0x172); regmbc(0x1af); + regmbc(0x1d3); regmbc(0x1d5); regmbc(0x1d7); + regmbc(0x1d9); regmbc(0x1db); regmbc(0x214); + regmbc(0x216); regmbc(0x244); regmbc(0x1e72); + regmbc(0x1e74); regmbc(0x1e76); regmbc(0x1e78); + regmbc(0x1e7a); regmbc(0x1ee4); regmbc(0x1ee6); + regmbc(0x1ee8); regmbc(0x1eea); regmbc(0x1eec); + regmbc(0x1eee); regmbc(0x1ef0); return; - case 'V': CASEMBC(0x1e7c) - regmbc('V'); REGMBC(0x1e7c) + case 'V': case 0x1b2: case 0x1e7c: case 0x1e7e: + regmbc('V'); regmbc(0x1b2); regmbc(0x1e7c); + regmbc(0x1e7e); return; - case 'W': CASEMBC(0x174) CASEMBC(0x1e80) CASEMBC(0x1e82) - CASEMBC(0x1e84) CASEMBC(0x1e86) - regmbc('W'); REGMBC(0x174) REGMBC(0x1e80) - REGMBC(0x1e82) REGMBC(0x1e84) REGMBC(0x1e86) + case 'W': case 0x174: case 0x1e80: case 0x1e82: + case 0x1e84: case 0x1e86: case 0x1e88: + regmbc('W'); regmbc(0x174); regmbc(0x1e80); + regmbc(0x1e82); regmbc(0x1e84); regmbc(0x1e86); + regmbc(0x1e88); return; - case 'X': CASEMBC(0x1e8a) CASEMBC(0x1e8c) - regmbc('X'); REGMBC(0x1e8a) REGMBC(0x1e8c) + case 'X': case 0x1e8a: case 0x1e8c: + regmbc('X'); regmbc(0x1e8a); regmbc(0x1e8c); return; case 'Y': case 0xdd: - CASEMBC(0x176) CASEMBC(0x178) CASEMBC(0x1e8e) CASEMBC(0x1ef2) - CASEMBC(0x1ef6) CASEMBC(0x1ef8) - regmbc('Y'); regmbc(0xdd); - REGMBC(0x176) REGMBC(0x178) REGMBC(0x1e8e) - REGMBC(0x1ef2) REGMBC(0x1ef6) REGMBC(0x1ef8) + case 0x176: case 0x178: case 0x1b3: case 0x232: case 0x24e: + case 0x1e8e: case 0x1ef2: case 0x1ef6: case 0x1ef4: case 0x1ef8: + regmbc('Y'); regmbc(0xdd); regmbc(0x176); + regmbc(0x178); regmbc(0x1b3); regmbc(0x232); + regmbc(0x24e); regmbc(0x1e8e); regmbc(0x1ef2); + regmbc(0x1ef4); regmbc(0x1ef6); regmbc(0x1ef8); return; - case 'Z': CASEMBC(0x179) CASEMBC(0x17b) CASEMBC(0x17d) - CASEMBC(0x1b5) CASEMBC(0x1e90) CASEMBC(0x1e94) - regmbc('Z'); REGMBC(0x179) REGMBC(0x17b) - REGMBC(0x17d) REGMBC(0x1b5) REGMBC(0x1e90) - REGMBC(0x1e94) + case 'Z': case 0x179: case 0x17b: case 0x17d: case 0x1b5: + case 0x1e90: case 0x1e92: case 0x1e94: case 0x2c6b: + regmbc('Z'); regmbc(0x179); regmbc(0x17b); + regmbc(0x17d); regmbc(0x1b5); regmbc(0x1e90); + regmbc(0x1e92); regmbc(0x1e94); regmbc(0x2c6b); return; case 'a': case 0xe0: case 0xe1: case 0xe2: - case 0xe3: case 0xe4: case 0xe5: - CASEMBC(0x101) CASEMBC(0x103) CASEMBC(0x105) CASEMBC(0x1ce) - CASEMBC(0x1df) CASEMBC(0x1e1) CASEMBC(0x1ea3) + case 0xe3: case 0xe4: case 0xe5: case 0x101: case 0x103: + case 0x105: case 0x1ce: case 0x1df: case 0x1e1: case 0x1fb: + case 0x201: case 0x203: case 0x227: case 0x1d8f: case 0x1e01: + case 0x1e9a: case 0x1ea1: case 0x1ea3: case 0x1ea5: + case 0x1ea7: case 0x1ea9: case 0x1eab: case 0x1ead: + case 0x1eaf: case 0x1eb1: case 0x1eb3: case 0x1eb5: + case 0x1eb7: case 0x2c65: regmbc('a'); regmbc(0xe0); regmbc(0xe1); regmbc(0xe2); regmbc(0xe3); regmbc(0xe4); - regmbc(0xe5); - REGMBC(0x101) REGMBC(0x103) REGMBC(0x105) - REGMBC(0x1ce) REGMBC(0x1df) REGMBC(0x1e1) - REGMBC(0x1ea3) + regmbc(0xe5); regmbc(0x101); regmbc(0x103); + regmbc(0x105); regmbc(0x1ce); regmbc(0x1df); + regmbc(0x1e1); regmbc(0x1fb); regmbc(0x201); + regmbc(0x203); regmbc(0x227); regmbc(0x1d8f); + regmbc(0x1e01); regmbc(0x1e9a); regmbc(0x1ea1); + regmbc(0x1ea3); regmbc(0x1ea5); regmbc(0x1ea7); + regmbc(0x1ea9); regmbc(0x1eab); regmbc(0x1ead); + regmbc(0x1eaf); regmbc(0x1eb1); regmbc(0x1eb3); + regmbc(0x1eb5); regmbc(0x1eb7); regmbc(0x2c65); return; - case 'b': CASEMBC(0x1e03) CASEMBC(0x1e07) - regmbc('b'); REGMBC(0x1e03) REGMBC(0x1e07) + case 'b': case 0x180: case 0x253: case 0x1d6c: case 0x1d80: + case 0x1e03: case 0x1e05: case 0x1e07: + regmbc('b'); + regmbc(0x180); regmbc(0x253); regmbc(0x1d6c); + regmbc(0x1d80); regmbc(0x1e03); regmbc(0x1e05); + regmbc(0x1e07); return; case 'c': case 0xe7: - CASEMBC(0x107) CASEMBC(0x109) CASEMBC(0x10b) CASEMBC(0x10d) - regmbc('c'); regmbc(0xe7); - REGMBC(0x107) REGMBC(0x109) REGMBC(0x10b) - REGMBC(0x10d) + case 0x107: case 0x109: case 0x10b: case 0x10d: case 0x188: + case 0x23c: case 0x1e09: case 0xa793: case 0xa794: + regmbc('c'); regmbc(0xe7); regmbc(0x107); + regmbc(0x109); regmbc(0x10b); regmbc(0x10d); + regmbc(0x188); regmbc(0x23c); regmbc(0x1e09); + regmbc(0xa793); regmbc(0xa794); return; - case 'd': CASEMBC(0x10f) CASEMBC(0x111) CASEMBC(0x1e0b) - CASEMBC(0x1e0f) CASEMBC(0x1e11) - regmbc('d'); REGMBC(0x10f) REGMBC(0x111) - REGMBC(0x1e0b) REGMBC(0x1e0f) REGMBC(0x1e11) + case 'd': case 0x10f: case 0x111: case 0x257: case 0x1d6d: + case 0x1d81: case 0x1d91: case 0x1e0b: case 0x1e0d: + case 0x1e0f: case 0x1e11: case 0x1e13: + regmbc('d'); regmbc(0x10f); regmbc(0x111); + regmbc(0x257); regmbc(0x1d6d); regmbc(0x1d81); + regmbc(0x1d91); regmbc(0x1e0b); regmbc(0x1e0d); + regmbc(0x1e0f); regmbc(0x1e11); regmbc(0x1e13); return; case 'e': case 0xe8: case 0xe9: case 0xea: case 0xeb: - CASEMBC(0x113) CASEMBC(0x115) CASEMBC(0x117) CASEMBC(0x119) - CASEMBC(0x11b) CASEMBC(0x1ebb) CASEMBC(0x1ebd) + case 0x113: case 0x115: case 0x117: case 0x119: + case 0x11b: case 0x205: case 0x207: case 0x229: + case 0x247: case 0x1d92: case 0x1e15: case 0x1e17: + case 0x1e19: case 0x1e1b: case 0x1eb9: case 0x1ebb: + case 0x1e1d: case 0x1ebd: case 0x1ebf: case 0x1ec1: + case 0x1ec3: case 0x1ec5: case 0x1ec7: regmbc('e'); regmbc(0xe8); regmbc(0xe9); - regmbc(0xea); regmbc(0xeb); - REGMBC(0x113) REGMBC(0x115) REGMBC(0x117) - REGMBC(0x119) REGMBC(0x11b) REGMBC(0x1ebb) - REGMBC(0x1ebd) + regmbc(0xea); regmbc(0xeb); regmbc(0x113); + regmbc(0x115); regmbc(0x117); regmbc(0x119); + regmbc(0x11b); regmbc(0x205); regmbc(0x207); + regmbc(0x229); regmbc(0x247); regmbc(0x1d92); + regmbc(0x1e15); regmbc(0x1e17); regmbc(0x1e19); + regmbc(0x1e1b); regmbc(0x1e1d); regmbc(0x1eb9); + regmbc(0x1ebb); regmbc(0x1ebd); regmbc(0x1ebf); + regmbc(0x1ec1); regmbc(0x1ec3); regmbc(0x1ec5); + regmbc(0x1ec7); return; - case 'f': CASEMBC(0x1e1f) - regmbc('f'); REGMBC(0x1e1f) + case 'f': case 0x192: case 0x1d6e: case 0x1d82: + case 0x1e1f: case 0xa799: + regmbc('f'); regmbc(0x192); regmbc(0x1d6e); + regmbc(0x1d82); regmbc(0x1e1f); regmbc(0xa799); return; - case 'g': CASEMBC(0x11d) CASEMBC(0x11f) CASEMBC(0x121) - CASEMBC(0x123) CASEMBC(0x1e5) CASEMBC(0x1e7) CASEMBC(0x1f5) - CASEMBC(0x1e21) - regmbc('g'); REGMBC(0x11d) REGMBC(0x11f) - REGMBC(0x121) REGMBC(0x123) REGMBC(0x1e5) - REGMBC(0x1e7) REGMBC(0x1f5) REGMBC(0x1e21) + case 'g': case 0x11d: case 0x11f: case 0x121: case 0x123: + case 0x1e5: case 0x1e7: case 0x260: case 0x1f5: case 0x1d83: + case 0x1e21: case 0xa7a1: + regmbc('g'); regmbc(0x11d); regmbc(0x11f); + regmbc(0x121); regmbc(0x123); regmbc(0x1e5); + regmbc(0x1e7); regmbc(0x1f5); regmbc(0x260); + regmbc(0x1d83); regmbc(0x1e21); regmbc(0xa7a1); return; - case 'h': CASEMBC(0x125) CASEMBC(0x127) CASEMBC(0x1e23) - CASEMBC(0x1e27) CASEMBC(0x1e29) CASEMBC(0x1e96) - regmbc('h'); REGMBC(0x125) REGMBC(0x127) - REGMBC(0x1e23) REGMBC(0x1e27) REGMBC(0x1e29) - REGMBC(0x1e96) + case 'h': case 0x125: case 0x127: case 0x21f: case 0x1e23: + case 0x1e25: case 0x1e27: case 0x1e29: case 0x1e2b: + case 0x1e96: case 0x2c68: case 0xa795: + regmbc('h'); regmbc(0x125); regmbc(0x127); + regmbc(0x21f); regmbc(0x1e23); regmbc(0x1e25); + regmbc(0x1e27); regmbc(0x1e29); regmbc(0x1e2b); + regmbc(0x1e96); regmbc(0x2c68); regmbc(0xa795); return; case 'i': case 0xec: case 0xed: case 0xee: case 0xef: - CASEMBC(0x129) CASEMBC(0x12b) CASEMBC(0x12d) CASEMBC(0x12f) - CASEMBC(0x1d0) CASEMBC(0x1ec9) + case 0x129: case 0x12b: case 0x12d: case 0x12f: + case 0x1d0: case 0x209: case 0x20b: case 0x268: + case 0x1d96: case 0x1e2d: case 0x1e2f: case 0x1ec9: + case 0x1ecb: regmbc('i'); regmbc(0xec); regmbc(0xed); - regmbc(0xee); regmbc(0xef); - REGMBC(0x129) REGMBC(0x12b) REGMBC(0x12d) - REGMBC(0x12f) REGMBC(0x1d0) REGMBC(0x1ec9) + regmbc(0xee); regmbc(0xef); regmbc(0x129); + regmbc(0x12b); regmbc(0x12d); regmbc(0x12f); + regmbc(0x1d0); regmbc(0x209); regmbc(0x20b); + regmbc(0x268); regmbc(0x1d96); regmbc(0x1e2d); + regmbc(0x1e2f); regmbc(0x1ec9); regmbc(0x1ecb); return; - case 'j': CASEMBC(0x135) CASEMBC(0x1f0) - regmbc('j'); REGMBC(0x135) REGMBC(0x1f0) + case 'j': case 0x135: case 0x1f0: case 0x249: + regmbc('j'); regmbc(0x135); regmbc(0x1f0); + regmbc(0x249); return; - case 'k': CASEMBC(0x137) CASEMBC(0x1e9) CASEMBC(0x1e31) - CASEMBC(0x1e35) - regmbc('k'); REGMBC(0x137) REGMBC(0x1e9) - REGMBC(0x1e31) REGMBC(0x1e35) + case 'k': case 0x137: case 0x199: case 0x1e9: + case 0x1d84: case 0x1e31: case 0x1e33: case 0x1e35: + case 0x2c6a: case 0xa741: + regmbc('k'); regmbc(0x137); regmbc(0x199); + regmbc(0x1e9); regmbc(0x1d84); regmbc(0x1e31); + regmbc(0x1e33); regmbc(0x1e35); regmbc(0x2c6a); + regmbc(0xa741); return; - case 'l': CASEMBC(0x13a) CASEMBC(0x13c) CASEMBC(0x13e) - CASEMBC(0x140) CASEMBC(0x142) CASEMBC(0x1e3b) - regmbc('l'); REGMBC(0x13a) REGMBC(0x13c) - REGMBC(0x13e) REGMBC(0x140) REGMBC(0x142) - REGMBC(0x1e3b) + case 'l': case 0x13a: case 0x13c: case 0x13e: + case 0x140: case 0x142: case 0x19a: case 0x1e37: + case 0x1e39: case 0x1e3b: case 0x1e3d: case 0x2c61: + regmbc('l'); regmbc(0x13a); regmbc(0x13c); + regmbc(0x13e); regmbc(0x140); regmbc(0x142); + regmbc(0x19a); regmbc(0x1e37); regmbc(0x1e39); + regmbc(0x1e3b); regmbc(0x1e3d); regmbc(0x2c61); return; - case 'm': CASEMBC(0x1e3f) CASEMBC(0x1e41) - regmbc('m'); REGMBC(0x1e3f) REGMBC(0x1e41) + case 'm': case 0x1d6f: case 0x1e3f: case 0x1e41: case 0x1e43: + regmbc('m'); regmbc(0x1d6f); regmbc(0x1e3f); + regmbc(0x1e41); regmbc(0x1e43); return; - case 'n': case 0xf1: - CASEMBC(0x144) CASEMBC(0x146) CASEMBC(0x148) CASEMBC(0x149) - CASEMBC(0x1e45) CASEMBC(0x1e49) - regmbc('n'); regmbc(0xf1); - REGMBC(0x144) REGMBC(0x146) REGMBC(0x148) - REGMBC(0x149) REGMBC(0x1e45) REGMBC(0x1e49) + case 'n': case 0xf1: case 0x144: case 0x146: case 0x148: + case 0x149: case 0x1f9: case 0x1d70: case 0x1d87: + case 0x1e45: case 0x1e47: case 0x1e49: case 0x1e4b: + case 0xa7a5: + regmbc('n'); regmbc(0xf1); regmbc(0x144); + regmbc(0x146); regmbc(0x148); regmbc(0x149); + regmbc(0x1f9); regmbc(0x1d70); regmbc(0x1d87); + regmbc(0x1e45); regmbc(0x1e47); regmbc(0x1e49); + regmbc(0x1e4b); regmbc(0xa7a5); return; case 'o': case 0xf2: case 0xf3: case 0xf4: case 0xf5: - case 0xf6: case 0xf8: - CASEMBC(0x14d) CASEMBC(0x14f) CASEMBC(0x151) CASEMBC(0x1a1) - CASEMBC(0x1d2) CASEMBC(0x1eb) CASEMBC(0x1ed) CASEMBC(0x1ecf) + case 0xf6: case 0xf8: case 0x14d: case 0x14f: case 0x151: + case 0x1a1: case 0x1d2: case 0x1eb: case 0x1ed: case 0x1ff: + case 0x20d: case 0x20f: case 0x22b: case 0x22d: case 0x22f: + case 0x231: case 0x275: case 0x1e4d: case 0x1e4f: + case 0x1e51: case 0x1e53: case 0x1ecd: case 0x1ecf: + case 0x1ed1: case 0x1ed3: case 0x1ed5: case 0x1ed7: + case 0x1ed9: case 0x1edb: case 0x1edd: case 0x1edf: + case 0x1ee1: case 0x1ee3: regmbc('o'); regmbc(0xf2); regmbc(0xf3); regmbc(0xf4); regmbc(0xf5); regmbc(0xf6); - regmbc(0xf8); - REGMBC(0x14d) REGMBC(0x14f) REGMBC(0x151) - REGMBC(0x1a1) REGMBC(0x1d2) REGMBC(0x1eb) - REGMBC(0x1ed) REGMBC(0x1ecf) + regmbc(0xf8); regmbc(0x14d); regmbc(0x14f); + regmbc(0x151); regmbc(0x1a1); regmbc(0x1d2); + regmbc(0x1eb); regmbc(0x1ed); regmbc(0x1ff); + regmbc(0x20d); regmbc(0x20f); regmbc(0x22b); + regmbc(0x22d); regmbc(0x22f); regmbc(0x231); + regmbc(0x275); regmbc(0x1e4d); regmbc(0x1e4f); + regmbc(0x1e51); regmbc(0x1e53); regmbc(0x1ecd); + regmbc(0x1ecf); regmbc(0x1ed1); regmbc(0x1ed3); + regmbc(0x1ed5); regmbc(0x1ed7); regmbc(0x1ed9); + regmbc(0x1edb); regmbc(0x1edd); regmbc(0x1edf); + regmbc(0x1ee1); regmbc(0x1ee3); + return; + case 'p': case 0x1a5: case 0x1d71: case 0x1d88: case 0x1d7d: + case 0x1e55: case 0x1e57: + regmbc('p'); regmbc(0x1a5); regmbc(0x1d71); + regmbc(0x1d7d); regmbc(0x1d88); regmbc(0x1e55); + regmbc(0x1e57); return; - case 'p': CASEMBC(0x1e55) CASEMBC(0x1e57) - regmbc('p'); REGMBC(0x1e55) REGMBC(0x1e57) + case 'q': case 0x24b: case 0x2a0: + regmbc('q'); regmbc(0x24b); regmbc(0x2a0); return; - case 'r': CASEMBC(0x155) CASEMBC(0x157) CASEMBC(0x159) - CASEMBC(0x1e59) CASEMBC(0x1e5f) - regmbc('r'); REGMBC(0x155) REGMBC(0x157) REGMBC(0x159) - REGMBC(0x1e59) REGMBC(0x1e5f) + case 'r': case 0x155: case 0x157: case 0x159: case 0x211: + case 0x213: case 0x24d: case 0x27d: case 0x1d72: case 0x1d73: + case 0x1d89: case 0x1e59: case 0x1e5b: case 0x1e5d: case 0x1e5f: + case 0xa7a7: + regmbc('r'); regmbc(0x155); regmbc(0x157); + regmbc(0x159); regmbc(0x211); regmbc(0x213); + regmbc(0x24d); regmbc(0x1d72); regmbc(0x1d73); + regmbc(0x1d89); regmbc(0x1e59); regmbc(0x27d); + regmbc(0x1e5b); regmbc(0x1e5d); regmbc(0x1e5f); + regmbc(0xa7a7); return; - case 's': CASEMBC(0x15b) CASEMBC(0x15d) CASEMBC(0x15f) - CASEMBC(0x161) CASEMBC(0x1e61) - regmbc('s'); REGMBC(0x15b) REGMBC(0x15d) - REGMBC(0x15f) REGMBC(0x161) REGMBC(0x1e61) + case 's': case 0x15b: case 0x15d: case 0x15f: case 0x161: + case 0x1e61: case 0x219: case 0x23f: case 0x1d74: case 0x1d8a: + case 0x1e63: case 0x1e65: case 0x1e67: case 0x1e69: case 0xa7a9: + regmbc('s'); regmbc(0x15b); regmbc(0x15d); + regmbc(0x15f); regmbc(0x161); regmbc(0x23f); + regmbc(0x219); regmbc(0x1d74); regmbc(0x1d8a); + regmbc(0x1e61); regmbc(0x1e63); regmbc(0x1e65); + regmbc(0x1e67); regmbc(0x1e69); regmbc(0xa7a9); return; - case 't': CASEMBC(0x163) CASEMBC(0x165) CASEMBC(0x167) - CASEMBC(0x1e6b) CASEMBC(0x1e6f) CASEMBC(0x1e97) - regmbc('t'); REGMBC(0x163) REGMBC(0x165) REGMBC(0x167) - REGMBC(0x1e6b) REGMBC(0x1e6f) REGMBC(0x1e97) + case 't': case 0x163: case 0x165: case 0x167: case 0x1ab: + case 0x1ad: case 0x21b: case 0x288: case 0x1d75: case 0x1e6b: + case 0x1e6d: case 0x1e6f: case 0x1e71: case 0x1e97: case 0x2c66: + regmbc('t'); regmbc(0x163); regmbc(0x165); + regmbc(0x167); regmbc(0x1ab); regmbc(0x21b); + regmbc(0x1ad); regmbc(0x288); regmbc(0x1d75); + regmbc(0x1e6b); regmbc(0x1e6d); regmbc(0x1e6f); + regmbc(0x1e71); regmbc(0x1e97); regmbc(0x2c66); return; case 'u': case 0xf9: case 0xfa: case 0xfb: case 0xfc: - CASEMBC(0x169) CASEMBC(0x16b) CASEMBC(0x16d) CASEMBC(0x16f) - CASEMBC(0x171) CASEMBC(0x173) CASEMBC(0x1b0) CASEMBC(0x1d4) - CASEMBC(0x1ee7) + case 0x169: case 0x16b: case 0x16d: case 0x16f: + case 0x171: case 0x173: case 0x1b0: case 0x1d4: + case 0x1d6: case 0x1d8: case 0x1da: case 0x1dc: + case 0x215: case 0x217: case 0x289: case 0x1e73: + case 0x1d7e: case 0x1d99: case 0x1e75: case 0x1e77: + case 0x1e79: case 0x1e7b: case 0x1ee5: case 0x1ee7: + case 0x1ee9: case 0x1eeb: case 0x1eed: case 0x1eef: + case 0x1ef1: regmbc('u'); regmbc(0xf9); regmbc(0xfa); - regmbc(0xfb); regmbc(0xfc); - REGMBC(0x169) REGMBC(0x16b) REGMBC(0x16d) - REGMBC(0x16f) REGMBC(0x171) REGMBC(0x173) - REGMBC(0x1b0) REGMBC(0x1d4) REGMBC(0x1ee7) + regmbc(0xfb); regmbc(0xfc); regmbc(0x169); + regmbc(0x16b); regmbc(0x16d); regmbc(0x16f); + regmbc(0x171); regmbc(0x173); regmbc(0x1d6); + regmbc(0x1d8); regmbc(0x1da); regmbc(0x1dc); + regmbc(0x215); regmbc(0x217); regmbc(0x1b0); + regmbc(0x1d4); regmbc(0x289); regmbc(0x1d7e); + regmbc(0x1d99); regmbc(0x1e73); regmbc(0x1e75); + regmbc(0x1e77); regmbc(0x1e79); regmbc(0x1e7b); + regmbc(0x1ee5); regmbc(0x1ee7); regmbc(0x1ee9); + regmbc(0x1eeb); regmbc(0x1eed); regmbc(0x1eef); + regmbc(0x1ef1); return; - case 'v': CASEMBC(0x1e7d) - regmbc('v'); REGMBC(0x1e7d) + case 'v': case 0x28b: case 0x1d8c: case 0x1e7d: case 0x1e7f: + regmbc('v'); regmbc(0x28b); regmbc(0x1d8c); + regmbc(0x1e7d); regmbc(0x1e7f); return; - case 'w': CASEMBC(0x175) CASEMBC(0x1e81) CASEMBC(0x1e83) - CASEMBC(0x1e85) CASEMBC(0x1e87) CASEMBC(0x1e98) - regmbc('w'); REGMBC(0x175) REGMBC(0x1e81) - REGMBC(0x1e83) REGMBC(0x1e85) REGMBC(0x1e87) - REGMBC(0x1e98) + case 'w': case 0x175: case 0x1e81: case 0x1e83: + case 0x1e85: case 0x1e87: case 0x1e89: case 0x1e98: + regmbc('w'); regmbc(0x175); regmbc(0x1e81); + regmbc(0x1e83); regmbc(0x1e85); regmbc(0x1e87); + regmbc(0x1e89); regmbc(0x1e98); return; - case 'x': CASEMBC(0x1e8b) CASEMBC(0x1e8d) - regmbc('x'); REGMBC(0x1e8b) REGMBC(0x1e8d) + case 'x': case 0x1e8b: case 0x1e8d: + regmbc('x'); regmbc(0x1e8b); regmbc(0x1e8d); return; - case 'y': case 0xfd: case 0xff: - CASEMBC(0x177) CASEMBC(0x1e8f) CASEMBC(0x1e99) - CASEMBC(0x1ef3) CASEMBC(0x1ef7) CASEMBC(0x1ef9) + case 'y': case 0xfd: case 0xff: case 0x177: case 0x1b4: + case 0x233: case 0x24f: case 0x1e8f: case 0x1e99: case 0x1ef3: + case 0x1ef5: case 0x1ef7: case 0x1ef9: regmbc('y'); regmbc(0xfd); regmbc(0xff); - REGMBC(0x177) REGMBC(0x1e8f) REGMBC(0x1e99) - REGMBC(0x1ef3) REGMBC(0x1ef7) REGMBC(0x1ef9) + regmbc(0x177); regmbc(0x1b4); regmbc(0x233); + regmbc(0x24f); regmbc(0x1e8f); regmbc(0x1e99); + regmbc(0x1ef3); regmbc(0x1ef5); regmbc(0x1ef7); + regmbc(0x1ef9); return; - case 'z': CASEMBC(0x17a) CASEMBC(0x17c) CASEMBC(0x17e) - CASEMBC(0x1b6) CASEMBC(0x1e91) CASEMBC(0x1e95) - regmbc('z'); REGMBC(0x17a) REGMBC(0x17c) - REGMBC(0x17e) REGMBC(0x1b6) REGMBC(0x1e91) - REGMBC(0x1e95) + case 'z': case 0x17a: case 0x17c: case 0x17e: case 0x1b6: + case 0x1d76: case 0x1d8e: case 0x1e91: case 0x1e93: + case 0x1e95: case 0x2c6c: + regmbc('z'); regmbc(0x17a); regmbc(0x17c); + regmbc(0x17e); regmbc(0x1b6); regmbc(0x1d76); + regmbc(0x1d8e); regmbc(0x1e91); regmbc(0x1e93); + regmbc(0x1e95); regmbc(0x2c6c); return; } } diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 133858f113..7e316624f8 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -711,7 +711,6 @@ static int nfa_recognize_char_class(char_u *start, char_u *end, int extra_newl) static void nfa_emit_equi_class(int c) { #define EMIT2(c) EMIT(c); EMIT(NFA_CONCAT); -#define EMITMBC(c) EMIT(c); EMIT(NFA_CONCAT); { #define A_grave 0xc0 @@ -771,361 +770,518 @@ static void nfa_emit_equi_class(int c) #define y_diaeresis 0xff switch (c) { case 'A': case A_grave: case A_acute: case A_circumflex: - case A_virguilla: case A_diaeresis: case A_ring: - CASEMBC(0x100) CASEMBC(0x102) CASEMBC(0x104) - CASEMBC(0x1cd) CASEMBC(0x1de) CASEMBC(0x1e0) - CASEMBC(0x1ea2) - EMIT2('A'); EMIT2(A_grave); EMIT2(A_acute); - EMIT2(A_circumflex); EMIT2(A_virguilla); - EMIT2(A_diaeresis); EMIT2(A_ring); - EMITMBC(0x100) EMITMBC(0x102) EMITMBC(0x104) - EMITMBC(0x1cd) EMITMBC(0x1de) EMITMBC(0x1e0) - EMITMBC(0x1ea2) + case A_virguilla: case A_diaeresis: case A_ring: + case 0x100: case 0x102: case 0x104: case 0x1cd: + case 0x1de: case 0x1e0: case 0x1fa: case 0x200: + case 0x202: case 0x226: case 0x23a: case 0x1e00: + case 0x1ea0: case 0x1ea2: case 0x1ea4: case 0x1ea6: + case 0x1ea8: case 0x1eaa: case 0x1eac: case 0x1eae: + case 0x1eb0: case 0x1eb2: case 0x1eb4: case 0x1eb6: + EMIT2('A') EMIT2(A_grave) EMIT2(A_acute) + EMIT2(A_circumflex) EMIT2(A_virguilla) + EMIT2(A_diaeresis) EMIT2(A_ring) + EMIT2(0x100) EMIT2(0x102) EMIT2(0x104) + EMIT2(0x1cd) EMIT2(0x1de) EMIT2(0x1e0) + EMIT2(0x1fa) EMIT2(0x200) EMIT2(0x202) + EMIT2(0x226) EMIT2(0x23a) EMIT2(0x1e00) + EMIT2(0x1ea0) EMIT2(0x1ea2) EMIT2(0x1ea4) + EMIT2(0x1ea6) EMIT2(0x1ea8) EMIT2(0x1eaa) + EMIT2(0x1eac) EMIT2(0x1eae) EMIT2(0x1eb0) + EMIT2(0x1eb2) EMIT2(0x1eb6) EMIT2(0x1eb4) return; - case 'B': CASEMBC(0x1e02) CASEMBC(0x1e06) - EMIT2('B'); EMITMBC(0x1e02) EMITMBC(0x1e06) + case 'B': case 0x181: case 0x243: case 0x1e02: + case 0x1e04: case 0x1e06: + EMIT2('B') + EMIT2(0x181) EMIT2(0x243) EMIT2(0x1e02) + EMIT2(0x1e04) EMIT2(0x1e06) return; - case 'C': case C_cedilla: CASEMBC(0x106) CASEMBC(0x108) CASEMBC(0x10a) - CASEMBC(0x10c) - EMIT2('C'); EMIT2(C_cedilla); EMITMBC(0x106) EMITMBC(0x108) - EMITMBC(0x10a) EMITMBC(0x10c) + case 'C': case C_cedilla: case 0x106: case 0x108: + case 0x10a: case 0x10c: case 0x187: case 0x23b: + case 0x1e08: case 0xa792: + EMIT2('C') EMIT2(C_cedilla) + EMIT2(0x106) EMIT2(0x108) EMIT2(0x10a) + EMIT2(0x10c) EMIT2(0x187) EMIT2(0x23b) + EMIT2(0x1e08) EMIT2(0xa792) return; - case 'D': CASEMBC(0x10e) CASEMBC(0x110) CASEMBC(0x1e0a) - CASEMBC(0x1e0e) CASEMBC(0x1e10) - EMIT2('D'); EMITMBC(0x10e) EMITMBC(0x110) EMITMBC(0x1e0a) - EMITMBC(0x1e0e) EMITMBC(0x1e10) + case 'D': case 0x10e: case 0x110: case 0x18a: + case 0x1e0a: case 0x1e0c: case 0x1e0e: case 0x1e10: + case 0x1e12: + EMIT2('D') EMIT2(0x10e) EMIT2(0x110) EMIT2(0x18a) + EMIT2(0x1e0a) EMIT2(0x1e0c) EMIT2(0x1e0e) + EMIT2(0x1e10) EMIT2(0x1e12) return; case 'E': case E_grave: case E_acute: case E_circumflex: - case E_diaeresis: CASEMBC(0x112) CASEMBC(0x114) - CASEMBC(0x116) CASEMBC(0x118) CASEMBC(0x11a) - CASEMBC(0x1eba) CASEMBC(0x1ebc) - EMIT2('E'); EMIT2(E_grave); EMIT2(E_acute); - EMIT2(E_circumflex); EMIT2(E_diaeresis); - EMITMBC(0x112) EMITMBC(0x114) EMITMBC(0x116) - EMITMBC(0x118) EMITMBC(0x11a) EMITMBC(0x1eba) - EMITMBC(0x1ebc) + case E_diaeresis: case 0x112: case 0x114: case 0x116: + case 0x118: case 0x11a: case 0x204: case 0x206: + case 0x228: case 0x246: case 0x1e14: case 0x1e16: + case 0x1e18: case 0x1e1a: case 0x1e1c: case 0x1eb8: + case 0x1eba: case 0x1ebc: case 0x1ebe: case 0x1ec0: + case 0x1ec2: case 0x1ec4: case 0x1ec6: + EMIT2('E') EMIT2(E_grave) EMIT2(E_acute) + EMIT2(E_circumflex) EMIT2(E_diaeresis) + EMIT2(0x112) EMIT2(0x114) EMIT2(0x116) + EMIT2(0x118) EMIT2(0x11a) EMIT2(0x204) + EMIT2(0x206) EMIT2(0x228) EMIT2(0x246) + EMIT2(0x1e14) EMIT2(0x1e16) EMIT2(0x1e18) + EMIT2(0x1e1a) EMIT2(0x1e1c) EMIT2(0x1eb8) + EMIT2(0x1eba) EMIT2(0x1ebc) EMIT2(0x1ebe) + EMIT2(0x1ec0) EMIT2(0x1ec2) EMIT2(0x1ec4) + EMIT2(0x1ec6) return; - case 'F': CASEMBC(0x1e1e) - EMIT2('F'); EMITMBC(0x1e1e) + case 'F': case 0x191: case 0x1e1e: case 0xa798: + EMIT2('F') EMIT2(0x191) EMIT2(0x1e1e) EMIT2(0xa798) return; - case 'G': CASEMBC(0x11c) CASEMBC(0x11e) CASEMBC(0x120) - CASEMBC(0x122) CASEMBC(0x1e4) CASEMBC(0x1e6) - CASEMBC(0x1f4) CASEMBC(0x1e20) - EMIT2('G'); EMITMBC(0x11c) EMITMBC(0x11e) EMITMBC(0x120) - EMITMBC(0x122) EMITMBC(0x1e4) EMITMBC(0x1e6) - EMITMBC(0x1f4) EMITMBC(0x1e20) + case 'G': case 0x11c: case 0x11e: case 0x120: + case 0x122: case 0x193: case 0x1e4: case 0x1e6: + case 0x1f4: case 0x1e20: case 0xa7a0: + EMIT2('G') EMIT2(0x11c) EMIT2(0x11e) EMIT2(0x120) + EMIT2(0x122) EMIT2(0x193) EMIT2(0x1e4) + EMIT2(0x1e6) EMIT2(0x1f4) EMIT2(0x1e20) + EMIT2(0xa7a0) return; - case 'H': CASEMBC(0x124) CASEMBC(0x126) CASEMBC(0x1e22) - CASEMBC(0x1e26) CASEMBC(0x1e28) - EMIT2('H'); EMITMBC(0x124) EMITMBC(0x126) EMITMBC(0x1e22) - EMITMBC(0x1e26) EMITMBC(0x1e28) + case 'H': case 0x124: case 0x126: case 0x21e: + case 0x1e22: case 0x1e24: case 0x1e26: case 0x1e28: + case 0x1e2a: case 0x2c67: + EMIT2('H') EMIT2(0x124) EMIT2(0x126) EMIT2(0x21e) + EMIT2(0x1e22) EMIT2(0x1e24) EMIT2(0x1e26) + EMIT2(0x1e28) EMIT2(0x1e2a) EMIT2(0x2c67) return; case 'I': case I_grave: case I_acute: case I_circumflex: - case I_diaeresis: CASEMBC(0x128) CASEMBC(0x12a) - CASEMBC(0x12c) CASEMBC(0x12e) CASEMBC(0x130) - CASEMBC(0x1cf) CASEMBC(0x1ec8) - EMIT2('I'); EMIT2(I_grave); EMIT2(I_acute); - EMIT2(I_circumflex); EMIT2(I_diaeresis); - EMITMBC(0x128) EMITMBC(0x12a) - EMITMBC(0x12c) EMITMBC(0x12e) EMITMBC(0x130) - EMITMBC(0x1cf) EMITMBC(0x1ec8) + case I_diaeresis: case 0x128: case 0x12a: case 0x12c: + case 0x12e: case 0x130: case 0x197: case 0x1cf: + case 0x208: case 0x20a: case 0x1e2c: case 0x1e2e: + case 0x1ec8: case 0x1eca: + EMIT2('I') EMIT2(I_grave) EMIT2(I_acute) + EMIT2(I_circumflex) EMIT2(I_diaeresis) + EMIT2(0x128) EMIT2(0x12a) EMIT2(0x12c) + EMIT2(0x12e) EMIT2(0x130) EMIT2(0x197) + EMIT2(0x1cf) EMIT2(0x208) EMIT2(0x20a) + EMIT2(0x1e2c) EMIT2(0x1e2e) EMIT2(0x1ec8) + EMIT2(0x1eca) return; - case 'J': CASEMBC(0x134) - EMIT2('J'); EMITMBC(0x134) + case 'J': case 0x134: case 0x248: + EMIT2('J') EMIT2(0x134) EMIT2(0x248) return; - case 'K': CASEMBC(0x136) CASEMBC(0x1e8) CASEMBC(0x1e30) - CASEMBC(0x1e34) - EMIT2('K'); EMITMBC(0x136) EMITMBC(0x1e8) EMITMBC(0x1e30) - EMITMBC(0x1e34) + case 'K': case 0x136: case 0x198: case 0x1e8: case 0x1e30: + case 0x1e32: case 0x1e34: case 0x2c69: case 0xa740: + EMIT2('K') EMIT2(0x136) EMIT2(0x198) EMIT2(0x1e8) + EMIT2(0x1e30) EMIT2(0x1e32) EMIT2(0x1e34) + EMIT2(0x2c69) EMIT2(0xa740) return; - case 'L': CASEMBC(0x139) CASEMBC(0x13b) CASEMBC(0x13d) - CASEMBC(0x13f) CASEMBC(0x141) CASEMBC(0x1e3a) - EMIT2('L'); EMITMBC(0x139) EMITMBC(0x13b) EMITMBC(0x13d) - EMITMBC(0x13f) EMITMBC(0x141) EMITMBC(0x1e3a) + case 'L': case 0x139: case 0x13b: case 0x13d: + case 0x13f: case 0x141: case 0x23d: case 0x1e36: + case 0x1e38: case 0x1e3a: case 0x1e3c: case 0x2c60: + EMIT2('L') EMIT2(0x139) EMIT2(0x13b) + EMIT2(0x13d) EMIT2(0x13f) EMIT2(0x141) + EMIT2(0x23d) EMIT2(0x1e36) EMIT2(0x1e38) + EMIT2(0x1e3a) EMIT2(0x1e3c) EMIT2(0x2c60) return; - case 'M': CASEMBC(0x1e3e) CASEMBC(0x1e40) - EMIT2('M'); EMITMBC(0x1e3e) EMITMBC(0x1e40) + case 'M': case 0x1e3e: case 0x1e40: case 0x1e42: + EMIT2('M') EMIT2(0x1e3e) EMIT2(0x1e40) + EMIT2(0x1e42) return; - case 'N': case N_virguilla: CASEMBC(0x143) CASEMBC(0x145) - CASEMBC(0x147) CASEMBC(0x1e44) CASEMBC(0x1e48) - EMIT2('N'); EMIT2(N_virguilla); - EMITMBC(0x143) EMITMBC(0x145) - EMITMBC(0x147) EMITMBC(0x1e44) EMITMBC(0x1e48) + case 'N': case N_virguilla: + case 0x143: case 0x145: case 0x147: case 0x1f8: + case 0x1e44: case 0x1e46: case 0x1e48: case 0x1e4a: + case 0xa7a4: + EMIT2('N') EMIT2(N_virguilla) + EMIT2(0x143) EMIT2(0x145) EMIT2(0x147) + EMIT2(0x1f8) EMIT2(0x1e44) EMIT2(0x1e46) + EMIT2(0x1e48) EMIT2(0x1e4a) EMIT2(0xa7a4) return; case 'O': case O_grave: case O_acute: case O_circumflex: - case O_virguilla: case O_diaeresis: case O_slash: - CASEMBC(0x14c) CASEMBC(0x14e) CASEMBC(0x150) - CASEMBC(0x1a0) CASEMBC(0x1d1) CASEMBC(0x1ea) - CASEMBC(0x1ec) CASEMBC(0x1ece) - EMIT2('O'); EMIT2(O_grave); EMIT2(O_acute); - EMIT2(O_circumflex); EMIT2(O_virguilla); - EMIT2(O_diaeresis); EMIT2(O_slash); - EMITMBC(0x14c) EMITMBC(0x14e) EMITMBC(0x150) - EMITMBC(0x1a0) EMITMBC(0x1d1) EMITMBC(0x1ea) - EMITMBC(0x1ec) EMITMBC(0x1ece) + case O_virguilla: case O_diaeresis: case O_slash: + case 0x14c: case 0x14e: case 0x150: case 0x19f: + case 0x1a0: case 0x1d1: case 0x1ea: case 0x1ec: + case 0x1fe: case 0x20c: case 0x20e: case 0x22a: + case 0x22c: case 0x22e: case 0x230: case 0x1e4c: + case 0x1e4e: case 0x1e50: case 0x1e52: case 0x1ecc: + case 0x1ece: case 0x1ed0: case 0x1ed2: case 0x1ed4: + case 0x1ed6: case 0x1ed8: case 0x1eda: case 0x1edc: + case 0x1ede: case 0x1ee0: case 0x1ee2: + EMIT2('O') EMIT2(O_grave) EMIT2(O_acute) + EMIT2(O_circumflex) EMIT2(O_virguilla) + EMIT2(O_diaeresis) EMIT2(O_slash) + EMIT2(0x14c) EMIT2(0x14e) EMIT2(0x150) + EMIT2(0x19f) EMIT2(0x1a0) EMIT2(0x1d1) + EMIT2(0x1ea) EMIT2(0x1ec) EMIT2(0x1fe) + EMIT2(0x20c) EMIT2(0x20e) EMIT2(0x22a) + EMIT2(0x22c) EMIT2(0x22e) EMIT2(0x230) + EMIT2(0x1e4c) EMIT2(0x1e4e) EMIT2(0x1e50) + EMIT2(0x1e52) EMIT2(0x1ecc) EMIT2(0x1ece) + EMIT2(0x1ed0) EMIT2(0x1ed2) EMIT2(0x1ed4) + EMIT2(0x1ed6) EMIT2(0x1ed8) EMIT2(0x1eda) + EMIT2(0x1edc) EMIT2(0x1ede) EMIT2(0x1ee0) + EMIT2(0x1ee2) return; - case 'P': case 0x1e54: case 0x1e56: - EMIT2('P'); EMITMBC(0x1e54) EMITMBC(0x1e56) + case 'P': case 0x1a4: case 0x1e54: case 0x1e56: case 0x2c63: + EMIT2('P') EMIT2(0x1a4) EMIT2(0x1e54) EMIT2(0x1e56) + EMIT2(0x2c63) return; - case 'R': CASEMBC(0x154) CASEMBC(0x156) CASEMBC(0x158) - CASEMBC(0x1e58) CASEMBC(0x1e5e) - EMIT2('R'); EMITMBC(0x154) EMITMBC(0x156) EMITMBC(0x158) - EMITMBC(0x1e58) EMITMBC(0x1e5e) + case 'Q': case 0x24a: + EMIT2('Q') EMIT2(0x24a) return; - case 'S': CASEMBC(0x15a) CASEMBC(0x15c) CASEMBC(0x15e) - CASEMBC(0x160) CASEMBC(0x1e60) - EMIT2('S'); EMITMBC(0x15a) EMITMBC(0x15c) EMITMBC(0x15e) - EMITMBC(0x160) EMITMBC(0x1e60) + case 'R': case 0x154: case 0x156: case 0x158: case 0x210: + case 0x212: case 0x24c: case 0x1e58: case 0x1e5a: + case 0x1e5c: case 0x1e5e: case 0x2c64: case 0xa7a6: + EMIT2('R') EMIT2(0x154) EMIT2(0x156) EMIT2(0x158) + EMIT2(0x210) EMIT2(0x212) EMIT2(0x24c) EMIT2(0x1e58) + EMIT2(0x1e5a) EMIT2(0x1e5c) EMIT2(0x1e5e) EMIT2(0x2c64) + EMIT2(0xa7a6) return; - case 'T': CASEMBC(0x162) CASEMBC(0x164) CASEMBC(0x166) - CASEMBC(0x1e6a) CASEMBC(0x1e6e) - EMIT2('T'); EMITMBC(0x162) EMITMBC(0x164) EMITMBC(0x166) - EMITMBC(0x1e6a) EMITMBC(0x1e6e) + case 'S': case 0x15a: case 0x15c: case 0x15e: case 0x160: + case 0x218: case 0x1e60: case 0x1e62: case 0x1e64: + case 0x1e66: case 0x1e68: case 0x2c7e: case 0xa7a8: + EMIT2('S') EMIT2(0x15a) EMIT2(0x15c) EMIT2(0x15e) + EMIT2(0x160) EMIT2(0x218) EMIT2(0x1e60) EMIT2(0x1e62) + EMIT2(0x1e64) EMIT2(0x1e66) EMIT2(0x1e68) EMIT2(0x2c7e) + EMIT2(0xa7a8) + return; + + case 'T': case 0x162: case 0x164: case 0x166: case 0x1ac: + case 0x1ae: case 0x21a: case 0x23e: case 0x1e6a: case 0x1e6c: + case 0x1e6e: case 0x1e70: + EMIT2('T') EMIT2(0x162) EMIT2(0x164) EMIT2(0x166) + EMIT2(0x1ac) EMIT2(0x1ae) EMIT2(0x23e) EMIT2(0x21a) + EMIT2(0x1e6a) EMIT2(0x1e6c) EMIT2(0x1e6e) EMIT2(0x1e70) return; case 'U': case U_grave: case U_acute: case U_diaeresis: - case U_circumflex: CASEMBC(0x168) CASEMBC(0x16a) - CASEMBC(0x16c) CASEMBC(0x16e) CASEMBC(0x170) - CASEMBC(0x172) CASEMBC(0x1af) CASEMBC(0x1d3) - CASEMBC(0x1ee6) - EMIT2('U'); EMIT2(U_grave); EMIT2(U_acute); - EMIT2(U_diaeresis); EMIT2(U_circumflex); - EMITMBC(0x168) EMITMBC(0x16a) - EMITMBC(0x16c) EMITMBC(0x16e) EMITMBC(0x170) - EMITMBC(0x172) EMITMBC(0x1af) EMITMBC(0x1d3) - EMITMBC(0x1ee6) + case U_circumflex: case 0x168: case 0x16a: case 0x16c: + case 0x16e: case 0x170: case 0x172: case 0x1af: + case 0x1d3: case 0x1d5: case 0x1d7: case 0x1d9: + case 0x1db: case 0x214: case 0x216: case 0x244: + case 0x1e72: case 0x1e74: case 0x1e76: case 0x1e78: + case 0x1e7a: case 0x1ee4: case 0x1ee6: case 0x1ee8: + case 0x1eea: case 0x1eec: case 0x1eee: case 0x1ef0: + EMIT2('U') EMIT2(U_grave) EMIT2(U_acute) + EMIT2(U_diaeresis) EMIT2(U_circumflex) + EMIT2(0x168) EMIT2(0x16a) + EMIT2(0x16c) EMIT2(0x16e) EMIT2(0x170) + EMIT2(0x172) EMIT2(0x1af) EMIT2(0x1d3) + EMIT2(0x1d5) EMIT2(0x1d7) EMIT2(0x1d9) + EMIT2(0x1db) EMIT2(0x214) EMIT2(0x216) + EMIT2(0x244) EMIT2(0x1e72) EMIT2(0x1e74) + EMIT2(0x1e76) EMIT2(0x1e78) EMIT2(0x1e7a) + EMIT2(0x1ee4) EMIT2(0x1ee6) EMIT2(0x1ee8) + EMIT2(0x1eea) EMIT2(0x1eec) EMIT2(0x1eee) + EMIT2(0x1ef0) return; - case 'V': CASEMBC(0x1e7c) - EMIT2('V'); EMITMBC(0x1e7c) + case 'V': case 0x1b2: case 0x1e7c: case 0x1e7e: + EMIT2('V') EMIT2(0x1b2) EMIT2(0x1e7c) EMIT2(0x1e7e) return; - case 'W': CASEMBC(0x174) CASEMBC(0x1e80) CASEMBC(0x1e82) - CASEMBC(0x1e84) CASEMBC(0x1e86) - EMIT2('W'); EMITMBC(0x174) EMITMBC(0x1e80) EMITMBC(0x1e82) - EMITMBC(0x1e84) EMITMBC(0x1e86) + case 'W': case 0x174: case 0x1e80: case 0x1e82: case 0x1e84: + case 0x1e86: case 0x1e88: + EMIT2('W') EMIT2(0x174) EMIT2(0x1e80) EMIT2(0x1e82) + EMIT2(0x1e84) EMIT2(0x1e86) EMIT2(0x1e88) return; - case 'X': CASEMBC(0x1e8a) CASEMBC(0x1e8c) - EMIT2('X'); EMITMBC(0x1e8a) EMITMBC(0x1e8c) + case 'X': case 0x1e8a: case 0x1e8c: + EMIT2('X') EMIT2(0x1e8a) EMIT2(0x1e8c) return; - case 'Y': case Y_acute: CASEMBC(0x176) CASEMBC(0x178) - CASEMBC(0x1e8e) CASEMBC(0x1ef2) CASEMBC(0x1ef6) - CASEMBC(0x1ef8) - EMIT2('Y'); EMIT2(Y_acute); - EMITMBC(0x176) EMITMBC(0x178) - EMITMBC(0x1e8e) EMITMBC(0x1ef2) EMITMBC(0x1ef6) - EMITMBC(0x1ef8) + case 'Y': case Y_acute: case 0x176: case 0x178: + case 0x1b3: case 0x232: case 0x24e: case 0x1e8e: + case 0x1ef2: case 0x1ef4: case 0x1ef6: case 0x1ef8: + EMIT2('Y') EMIT2(Y_acute) + EMIT2(0x176) EMIT2(0x178) EMIT2(0x1b3) + EMIT2(0x232) EMIT2(0x24e) EMIT2(0x1e8e) + EMIT2(0x1ef2) EMIT2(0x1ef4) EMIT2(0x1ef6) + EMIT2(0x1ef8) return; - case 'Z': CASEMBC(0x179) CASEMBC(0x17b) CASEMBC(0x17d) - CASEMBC(0x1b5) CASEMBC(0x1e90) CASEMBC(0x1e94) - EMIT2('Z'); EMITMBC(0x179) EMITMBC(0x17b) EMITMBC(0x17d) - EMITMBC(0x1b5) EMITMBC(0x1e90) EMITMBC(0x1e94) + case 'Z': case 0x179: case 0x17b: case 0x17d: + case 0x1b5: case 0x1e90: case 0x1e92: case 0x1e94: + case 0x2c6b: + EMIT2('Z') EMIT2(0x179) EMIT2(0x17b) EMIT2(0x17d) + EMIT2(0x1b5) EMIT2(0x1e90) EMIT2(0x1e92) + EMIT2(0x1e94) EMIT2(0x2c6b) return; case 'a': case a_grave: case a_acute: case a_circumflex: - case a_virguilla: case a_diaeresis: case a_ring: - CASEMBC(0x101) CASEMBC(0x103) CASEMBC(0x105) - CASEMBC(0x1ce) CASEMBC(0x1df) CASEMBC(0x1e1) - CASEMBC(0x1ea3) - EMIT2('a'); EMIT2(a_grave); EMIT2(a_acute); - EMIT2(a_circumflex); EMIT2(a_virguilla); - EMIT2(a_diaeresis); EMIT2(a_ring); - EMITMBC(0x101) EMITMBC(0x103) EMITMBC(0x105) - EMITMBC(0x1ce) EMITMBC(0x1df) EMITMBC(0x1e1) - EMITMBC(0x1ea3) + case a_virguilla: case a_diaeresis: case a_ring: + case 0x101: case 0x103: case 0x105: case 0x1ce: + case 0x1df: case 0x1e1: case 0x1fb: case 0x201: + case 0x203: case 0x227: case 0x1d8f: case 0x1e01: + case 0x1e9a: case 0x1ea1: case 0x1ea3: case 0x1ea5: + case 0x1ea7: case 0x1ea9: case 0x1eab: case 0x1ead: + case 0x1eaf: case 0x1eb1: case 0x1eb3: case 0x1eb5: + case 0x1eb7: case 0x2c65: + EMIT2('a') EMIT2(a_grave) EMIT2(a_acute) + EMIT2(a_circumflex) EMIT2(a_virguilla) + EMIT2(a_diaeresis) EMIT2(a_ring) + EMIT2(0x101) EMIT2(0x103) EMIT2(0x105) + EMIT2(0x1ce) EMIT2(0x1df) EMIT2(0x1e1) + EMIT2(0x1fb) EMIT2(0x201) EMIT2(0x203) + EMIT2(0x227) EMIT2(0x1d8f) EMIT2(0x1e01) + EMIT2(0x1e9a) EMIT2(0x1ea1) EMIT2(0x1ea3) + EMIT2(0x1ea5) EMIT2(0x1ea7) EMIT2(0x1ea9) + EMIT2(0x1eab) EMIT2(0x1ead) EMIT2(0x1eaf) + EMIT2(0x1eb1) EMIT2(0x1eb3) EMIT2(0x1eb5) + EMIT2(0x1eb7) EMIT2(0x2c65) return; - case 'b': CASEMBC(0x1e03) CASEMBC(0x1e07) - EMIT2('b'); EMITMBC(0x1e03) EMITMBC(0x1e07) + case 'b': case 0x180: case 0x253: case 0x1d6c: case 0x1d80: + case 0x1e03: case 0x1e05: case 0x1e07: + EMIT2('b') EMIT2(0x180) EMIT2(0x253) EMIT2(0x1d6c) + EMIT2(0x1d80) EMIT2(0x1e03) EMIT2(0x1e05) EMIT2(0x1e07) return; - case 'c': case c_cedilla: CASEMBC(0x107) CASEMBC(0x109) - CASEMBC(0x10b) CASEMBC(0x10d) - EMIT2('c'); EMIT2(c_cedilla); - EMITMBC(0x107) EMITMBC(0x109) - EMITMBC(0x10b) EMITMBC(0x10d) + case 'c': case c_cedilla: case 0x107: case 0x109: case 0x10b: + case 0x10d: case 0x188: case 0x23c: case 0x1e09: case 0xa793: + case 0xa794: + EMIT2('c') EMIT2(c_cedilla) + EMIT2(0x107) EMIT2(0x109) EMIT2(0x10b) + EMIT2(0x10d) EMIT2(0x188) EMIT2(0x23c) + EMIT2(0x1e09) EMIT2(0xa793) EMIT2(0xa794) return; - case 'd': CASEMBC(0x10f) CASEMBC(0x111) CASEMBC(0x1e0b) - CASEMBC(0x1e0f) CASEMBC(0x1e11) - EMIT2('d'); EMITMBC(0x10f) EMITMBC(0x111) EMITMBC(0x1e0b) - EMITMBC(0x1e0f) EMITMBC(0x1e11) + case 'd': case 0x10f: case 0x111: case 0x257: case 0x1d6d: + case 0x1d81: case 0x1d91: case 0x1e0b: case 0x1e0d: case 0x1e0f: + case 0x1e11: case 0x1e13: + EMIT2('d') EMIT2(0x10f) EMIT2(0x111) + EMIT2(0x257) EMIT2(0x1d6d) EMIT2(0x1d81) + EMIT2(0x1d91) EMIT2(0x1e0b) EMIT2(0x1e0d) + EMIT2(0x1e0f) EMIT2(0x1e11) EMIT2(0x1e13) return; case 'e': case e_grave: case e_acute: case e_circumflex: - case e_diaeresis: CASEMBC(0x113) CASEMBC(0x115) - CASEMBC(0x117) CASEMBC(0x119) CASEMBC(0x11b) - CASEMBC(0x1ebb) CASEMBC(0x1ebd) - EMIT2('e'); EMIT2(e_grave); EMIT2(e_acute); - EMIT2(e_circumflex); EMIT2(e_diaeresis); - EMITMBC(0x113) EMITMBC(0x115) - EMITMBC(0x117) EMITMBC(0x119) EMITMBC(0x11b) - EMITMBC(0x1ebb) EMITMBC(0x1ebd) + case e_diaeresis: case 0x113: case 0x115: case 0x117: + case 0x119: case 0x11b: case 0x205: case 0x207: + case 0x229: case 0x247: case 0x1d92: case 0x1e15: + case 0x1e17: case 0x1e19: case 0x1e1b: case 0x1e1d: + case 0x1eb9: case 0x1ebb: case 0x1ebd: case 0x1ebf: + case 0x1ec1: case 0x1ec3: case 0x1ec5: case 0x1ec7: + EMIT2('e') EMIT2(e_grave) EMIT2(e_acute) + EMIT2(e_circumflex) EMIT2(e_diaeresis) + EMIT2(0x113) EMIT2(0x115) + EMIT2(0x117) EMIT2(0x119) EMIT2(0x11b) + EMIT2(0x205) EMIT2(0x207) EMIT2(0x229) + EMIT2(0x247) EMIT2(0x1d92) EMIT2(0x1e15) + EMIT2(0x1e17) EMIT2(0x1e19) EMIT2(0x1e1b) + EMIT2(0x1e1d) EMIT2(0x1eb9) EMIT2(0x1ebb) + EMIT2(0x1ebd) EMIT2(0x1ebf) EMIT2(0x1ec1) + EMIT2(0x1ec3) EMIT2(0x1ec5) EMIT2(0x1ec7) return; - case 'f': CASEMBC(0x1e1f) - EMIT2('f'); EMITMBC(0x1e1f) + case 'f': case 0x192: case 0x1d6e: case 0x1d82: + case 0x1e1f: case 0xa799: + EMIT2('f') EMIT2(0x192) EMIT2(0x1d6e) EMIT2(0x1d82) + EMIT2(0x1e1f) EMIT2(0xa799) return; - case 'g': CASEMBC(0x11d) CASEMBC(0x11f) CASEMBC(0x121) - CASEMBC(0x123) CASEMBC(0x1e5) CASEMBC(0x1e7) - CASEMBC(0x1f5) CASEMBC(0x1e21) - EMIT2('g'); EMITMBC(0x11d) EMITMBC(0x11f) EMITMBC(0x121) - EMITMBC(0x123) EMITMBC(0x1e5) EMITMBC(0x1e7) - EMITMBC(0x1f5) EMITMBC(0x1e21) + case 'g': case 0x11d: case 0x11f: case 0x121: case 0x123: + case 0x1e5: case 0x1e7: case 0x1f5: case 0x260: case 0x1d83: + case 0x1e21: case 0xa7a1: + EMIT2('g') EMIT2(0x11d) EMIT2(0x11f) EMIT2(0x121) + EMIT2(0x123) EMIT2(0x1e5) EMIT2(0x1e7) + EMIT2(0x1f5) EMIT2(0x260) EMIT2(0x1d83) + EMIT2(0x1e21) EMIT2(0xa7a1) return; - case 'h': CASEMBC(0x125) CASEMBC(0x127) CASEMBC(0x1e23) - CASEMBC(0x1e27) CASEMBC(0x1e29) CASEMBC(0x1e96) - EMIT2('h'); EMITMBC(0x125) EMITMBC(0x127) EMITMBC(0x1e23) - EMITMBC(0x1e27) EMITMBC(0x1e29) EMITMBC(0x1e96) + case 'h': case 0x125: case 0x127: case 0x21f: case 0x1e23: + case 0x1e25: case 0x1e27: case 0x1e29: case 0x1e2b: + case 0x1e96: case 0x2c68: case 0xa795: + EMIT2('h') EMIT2(0x125) EMIT2(0x127) EMIT2(0x21f) + EMIT2(0x1e23) EMIT2(0x1e25) EMIT2(0x1e27) + EMIT2(0x1e29) EMIT2(0x1e2b) EMIT2(0x1e96) + EMIT2(0x2c68) EMIT2(0xa795) return; case 'i': case i_grave: case i_acute: case i_circumflex: - case i_diaeresis: CASEMBC(0x129) CASEMBC(0x12b) - CASEMBC(0x12d) CASEMBC(0x12f) CASEMBC(0x1d0) - CASEMBC(0x1ec9) - EMIT2('i'); EMIT2(i_grave); EMIT2(i_acute); - EMIT2(i_circumflex); EMIT2(i_diaeresis); - EMITMBC(0x129) EMITMBC(0x12b) - EMITMBC(0x12d) EMITMBC(0x12f) EMITMBC(0x1d0) - EMITMBC(0x1ec9) + case i_diaeresis: case 0x129: case 0x12b: case 0x12d: + case 0x12f: case 0x1d0: case 0x209: case 0x20b: + case 0x268: case 0x1d96: case 0x1e2d: case 0x1e2f: + case 0x1ec9: case 0x1ecb: + EMIT2('i') EMIT2(i_grave) EMIT2(i_acute) + EMIT2(i_circumflex) EMIT2(i_diaeresis) + EMIT2(0x129) EMIT2(0x12b) EMIT2(0x12d) + EMIT2(0x12f) EMIT2(0x1d0) EMIT2(0x209) + EMIT2(0x20b) EMIT2(0x268) EMIT2(0x1d96) + EMIT2(0x1e2d) EMIT2(0x1e2f) EMIT2(0x1ec9) + EMIT2(0x1ecb) EMIT2(0x1ecb) return; - case 'j': CASEMBC(0x135) CASEMBC(0x1f0) - EMIT2('j'); EMITMBC(0x135) EMITMBC(0x1f0) + case 'j': case 0x135: case 0x1f0: case 0x249: + EMIT2('j') EMIT2(0x135) EMIT2(0x1f0) EMIT2(0x249) return; - case 'k': CASEMBC(0x137) CASEMBC(0x1e9) CASEMBC(0x1e31) - CASEMBC(0x1e35) - EMIT2('k'); EMITMBC(0x137) EMITMBC(0x1e9) EMITMBC(0x1e31) - EMITMBC(0x1e35) + case 'k': case 0x137: case 0x199: case 0x1e9: case 0x1d84: + case 0x1e31: case 0x1e33: case 0x1e35: case 0x2c6a: case 0xa741: + EMIT2('k') EMIT2(0x137) EMIT2(0x199) EMIT2(0x1e9) + EMIT2(0x1d84) EMIT2(0x1e31) EMIT2(0x1e33) + EMIT2(0x1e35) EMIT2(0x2c6a) EMIT2(0xa741) return; - case 'l': CASEMBC(0x13a) CASEMBC(0x13c) CASEMBC(0x13e) - CASEMBC(0x140) CASEMBC(0x142) CASEMBC(0x1e3b) - EMIT2('l'); EMITMBC(0x13a) EMITMBC(0x13c) EMITMBC(0x13e) - EMITMBC(0x140) EMITMBC(0x142) EMITMBC(0x1e3b) + case 'l': case 0x13a: case 0x13c: case 0x13e: case 0x140: + case 0x142: case 0x19a: case 0x1e37: case 0x1e39: case 0x1e3b: + case 0x1e3d: case 0x2c61: + EMIT2('l') EMIT2(0x13a) EMIT2(0x13c) + EMIT2(0x13e) EMIT2(0x140) EMIT2(0x142) + EMIT2(0x19a) EMIT2(0x1e37) EMIT2(0x1e39) + EMIT2(0x1e3b) EMIT2(0x1e3d) EMIT2(0x2c61) return; - case 'm': CASEMBC(0x1e3f) CASEMBC(0x1e41) - EMIT2('m'); EMITMBC(0x1e3f) EMITMBC(0x1e41) + case 'm': case 0x1d6f: case 0x1e3f: case 0x1e41: case 0x1e43: + EMIT2('m') EMIT2(0x1d6f) EMIT2(0x1e3f) + EMIT2(0x1e41) EMIT2(0x1e43) return; - case 'n': case n_virguilla: CASEMBC(0x144) CASEMBC(0x146) - CASEMBC(0x148) CASEMBC(0x149) CASEMBC(0x1e45) - CASEMBC(0x1e49) - EMIT2('n'); EMIT2(n_virguilla); - EMITMBC(0x144) EMITMBC(0x146) - EMITMBC(0x148) EMITMBC(0x149) EMITMBC(0x1e45) - EMITMBC(0x1e49) + case 'n': case n_virguilla: case 0x144: case 0x146: case 0x148: + case 0x149: case 0x1f9: case 0x1d70: case 0x1d87: case 0x1e45: + case 0x1e47: case 0x1e49: case 0x1e4b: case 0xa7a5: + EMIT2('n') EMIT2(n_virguilla) + EMIT2(0x144) EMIT2(0x146) EMIT2(0x148) + EMIT2(0x149) EMIT2(0x1f9) EMIT2(0x1d70) + EMIT2(0x1d87) EMIT2(0x1e45) EMIT2(0x1e47) + EMIT2(0x1e49) EMIT2(0x1e4b) EMIT2(0xa7a5) return; case 'o': case o_grave: case o_acute: case o_circumflex: - case o_virguilla: case o_diaeresis: case o_slash: - CASEMBC(0x14d) CASEMBC(0x14f) CASEMBC(0x151) - CASEMBC(0x1a1) CASEMBC(0x1d2) CASEMBC(0x1eb) - CASEMBC(0x1ed) CASEMBC(0x1ecf) - EMIT2('o'); EMIT2(o_grave); EMIT2(o_acute); - EMIT2(o_circumflex); EMIT2(o_virguilla); - EMIT2(o_diaeresis); EMIT2(o_slash); - EMITMBC(0x14d) EMITMBC(0x14f) EMITMBC(0x151) - EMITMBC(0x1a1) EMITMBC(0x1d2) EMITMBC(0x1eb) - EMITMBC(0x1ed) EMITMBC(0x1ecf) + case o_virguilla: case o_diaeresis: case o_slash: + case 0x14d: case 0x14f: case 0x151: case 0x1a1: + case 0x1d2: case 0x1eb: case 0x1ed: case 0x1ff: + case 0x20d: case 0x20f: case 0x22b: case 0x22d: + case 0x22f: case 0x231: case 0x275: case 0x1e4d: + case 0x1e4f: case 0x1e51: case 0x1e53: case 0x1ecd: + case 0x1ecf: case 0x1ed1: case 0x1ed3: case 0x1ed5: + case 0x1ed7: case 0x1ed9: case 0x1edb: case 0x1edd: + case 0x1edf: case 0x1ee1: case 0x1ee3: + EMIT2('o') EMIT2(o_grave) EMIT2(o_acute) + EMIT2(o_circumflex) EMIT2(o_virguilla) + EMIT2(o_diaeresis) EMIT2(o_slash) + EMIT2(0x14d) EMIT2(0x14f) EMIT2(0x151) + EMIT2(0x1a1) EMIT2(0x1d2) EMIT2(0x1eb) + EMIT2(0x1ed) EMIT2(0x1ff) EMIT2(0x20d) + EMIT2(0x20f) EMIT2(0x22b) EMIT2(0x22d) + EMIT2(0x22f) EMIT2(0x231) EMIT2(0x275) + EMIT2(0x1e4d) EMIT2(0x1e4f) EMIT2(0x1e51) + EMIT2(0x1e53) EMIT2(0x1ecd) EMIT2(0x1ecf) + EMIT2(0x1ed1) EMIT2(0x1ed3) EMIT2(0x1ed5) + EMIT2(0x1ed7) EMIT2(0x1ed9) EMIT2(0x1edb) + EMIT2(0x1edd) EMIT2(0x1edf) EMIT2(0x1ee1) + EMIT2(0x1ee3) + return; + + case 'p': case 0x1a5: case 0x1d71: case 0x1d7d: case 0x1d88: + case 0x1e55: case 0x1e57: + EMIT2('p') EMIT2(0x1a5) EMIT2(0x1d71) EMIT2(0x1d7d) + EMIT2(0x1d88) EMIT2(0x1e55) EMIT2(0x1e57) return; - case 'p': CASEMBC(0x1e55) CASEMBC(0x1e57) - EMIT2('p'); EMITMBC(0x1e55) EMITMBC(0x1e57) + case 'q': case 0x24b: case 0x2a0: + EMIT2('q') EMIT2(0x24b) EMIT2(0x2a0) return; - case 'r': CASEMBC(0x155) CASEMBC(0x157) CASEMBC(0x159) - CASEMBC(0x1e59) CASEMBC(0x1e5f) - EMIT2('r'); EMITMBC(0x155) EMITMBC(0x157) EMITMBC(0x159) - EMITMBC(0x1e59) EMITMBC(0x1e5f) + case 'r': case 0x155: case 0x157: case 0x159: case 0x211: + case 0x213: case 0x24d: case 0x27d: case 0x1d72: case 0x1d73: + case 0x1d89: case 0x1e59: case 0x1e5b: case 0x1e5d: case 0x1e5f: + case 0xa7a7: + EMIT2('r') EMIT2(0x155) EMIT2(0x157) EMIT2(0x159) + EMIT2(0x211) EMIT2(0x213) EMIT2(0x24d) EMIT2(0x27d) + EMIT2(0x1d72) EMIT2(0x1d73) EMIT2(0x1d89) EMIT2(0x1e59) + EMIT2(0x1e5b) EMIT2(0x1e5d) EMIT2(0x1e5f) EMIT2(0xa7a7) return; - case 's': CASEMBC(0x15b) CASEMBC(0x15d) CASEMBC(0x15f) - CASEMBC(0x161) CASEMBC(0x1e61) - EMIT2('s'); EMITMBC(0x15b) EMITMBC(0x15d) EMITMBC(0x15f) - EMITMBC(0x161) EMITMBC(0x1e61) + case 's': case 0x15b: case 0x15d: case 0x15f: case 0x161: + case 0x219: case 0x23f: case 0x1d74: case 0x1d8a: case 0x1e61: + case 0x1e63: case 0x1e65: case 0x1e67: case 0x1e69: case 0xa7a9: + EMIT2('s') EMIT2(0x15b) EMIT2(0x15d) EMIT2(0x15f) + EMIT2(0x161) EMIT2(0x219) EMIT2(0x23f) EMIT2(0x1d74) + EMIT2(0x1d8a) EMIT2(0x1e61) EMIT2(0x1e63) EMIT2(0x1e65) + EMIT2(0x1e67) EMIT2(0x1e69) EMIT2(0xa7a9) return; - case 't': CASEMBC(0x163) CASEMBC(0x165) CASEMBC(0x167) - CASEMBC(0x1e6b) CASEMBC(0x1e6f) CASEMBC(0x1e97) - EMIT2('t'); EMITMBC(0x163) EMITMBC(0x165) EMITMBC(0x167) - EMITMBC(0x1e6b) EMITMBC(0x1e6f) EMITMBC(0x1e97) + case 't': case 0x163: case 0x165: case 0x167: case 0x1ab: + case 0x1ad: case 0x21b: case 0x288: case 0x1d75: case 0x1e6b: + case 0x1e6d: case 0x1e6f: case 0x1e71: case 0x1e97: case 0x2c66: + EMIT2('t') EMIT2(0x163) EMIT2(0x165) EMIT2(0x167) + EMIT2(0x1ab) EMIT2(0x1ad) EMIT2(0x21b) EMIT2(0x288) + EMIT2(0x1d75) EMIT2(0x1e6b) EMIT2(0x1e6d) EMIT2(0x1e6f) + EMIT2(0x1e71) EMIT2(0x1e97) EMIT2(0x2c66) return; case 'u': case u_grave: case u_acute: case u_circumflex: - case u_diaeresis: CASEMBC(0x169) CASEMBC(0x16b) - CASEMBC(0x16d) CASEMBC(0x16f) CASEMBC(0x171) - CASEMBC(0x173) CASEMBC(0x1b0) CASEMBC(0x1d4) - CASEMBC(0x1ee7) - EMIT2('u'); EMIT2(u_grave); EMIT2(u_acute); - EMIT2(u_circumflex); EMIT2(u_diaeresis); - EMITMBC(0x169) EMITMBC(0x16b) - EMITMBC(0x16d) EMITMBC(0x16f) EMITMBC(0x171) - EMITMBC(0x173) EMITMBC(0x1b0) EMITMBC(0x1d4) - EMITMBC(0x1ee7) + case u_diaeresis: case 0x169: case 0x16b: case 0x16d: + case 0x16f: case 0x171: case 0x173: case 0x1b0: case 0x1d4: + case 0x1d6: case 0x1d8: case 0x1da: case 0x1dc: case 0x215: + case 0x217: case 0x289: case 0x1d7e: case 0x1d99: case 0x1e73: + case 0x1e75: case 0x1e77: case 0x1e79: case 0x1e7b: + case 0x1ee5: case 0x1ee7: case 0x1ee9: case 0x1eeb: + case 0x1eed: case 0x1eef: case 0x1ef1: + EMIT2('u') EMIT2(u_grave) EMIT2(u_acute) + EMIT2(u_circumflex) EMIT2(u_diaeresis) + EMIT2(0x169) EMIT2(0x16b) + EMIT2(0x16d) EMIT2(0x16f) EMIT2(0x171) + EMIT2(0x173) EMIT2(0x1d6) EMIT2(0x1d8) + EMIT2(0x215) EMIT2(0x217) EMIT2(0x1b0) + EMIT2(0x1d4) EMIT2(0x1da) EMIT2(0x1dc) + EMIT2(0x289) EMIT2(0x1e73) EMIT2(0x1d7e) + EMIT2(0x1d99) EMIT2(0x1e75) EMIT2(0x1e77) + EMIT2(0x1e79) EMIT2(0x1e7b) EMIT2(0x1ee5) + EMIT2(0x1ee7) EMIT2(0x1ee9) EMIT2(0x1eeb) + EMIT2(0x1eed) EMIT2(0x1eef) EMIT2(0x1ef1) return; - case 'v': CASEMBC(0x1e7d) - EMIT2('v'); EMITMBC(0x1e7d) + case 'v': case 0x28b: case 0x1d8c: case 0x1e7d: case 0x1e7f: + EMIT2('v') EMIT2(0x28b) EMIT2(0x1d8c) EMIT2(0x1e7d) + EMIT2(0x1e7f) return; - case 'w': CASEMBC(0x175) CASEMBC(0x1e81) CASEMBC(0x1e83) - CASEMBC(0x1e85) CASEMBC(0x1e87) CASEMBC(0x1e98) - EMIT2('w'); EMITMBC(0x175) EMITMBC(0x1e81) EMITMBC(0x1e83) - EMITMBC(0x1e85) EMITMBC(0x1e87) EMITMBC(0x1e98) + case 'w': case 0x175: case 0x1e81: case 0x1e83: case 0x1e85: + case 0x1e87: case 0x1e89: case 0x1e98: + EMIT2('w') EMIT2(0x175) EMIT2(0x1e81) EMIT2(0x1e83) + EMIT2(0x1e85) EMIT2(0x1e87) EMIT2(0x1e89) EMIT2(0x1e98) return; - case 'x': CASEMBC(0x1e8b) CASEMBC(0x1e8d) - EMIT2('x'); EMITMBC(0x1e8b) EMITMBC(0x1e8d) + case 'x': case 0x1e8b: case 0x1e8d: + EMIT2('x') EMIT2(0x1e8b) EMIT2(0x1e8d) return; - case 'y': case y_acute: case y_diaeresis: CASEMBC(0x177) - CASEMBC(0x1e8f) CASEMBC(0x1e99) CASEMBC(0x1ef3) - CASEMBC(0x1ef7) CASEMBC(0x1ef9) - EMIT2('y'); EMIT2(y_acute); EMIT2(y_diaeresis); - EMITMBC(0x177) - EMITMBC(0x1e8f) EMITMBC(0x1e99) EMITMBC(0x1ef3) - EMITMBC(0x1ef7) EMITMBC(0x1ef9) + case 'y': case y_acute: case y_diaeresis: case 0x177: + case 0x1b4: case 0x233: case 0x24f: case 0x1e8f: + case 0x1e99: case 0x1ef3: case 0x1ef5: case 0x1ef7: + case 0x1ef9: + EMIT2('y') EMIT2(y_acute) EMIT2(y_diaeresis) + EMIT2(0x177) EMIT2(0x1b4) EMIT2(0x233) EMIT2(0x24f) + EMIT2(0x1e8f) EMIT2(0x1e99) EMIT2(0x1ef3) + EMIT2(0x1ef5) EMIT2(0x1ef7) EMIT2(0x1ef9) return; - case 'z': CASEMBC(0x17a) CASEMBC(0x17c) CASEMBC(0x17e) - CASEMBC(0x1b6) CASEMBC(0x1e91) CASEMBC(0x1e95) - EMIT2('z'); EMITMBC(0x17a) EMITMBC(0x17c) EMITMBC(0x17e) - EMITMBC(0x1b6) EMITMBC(0x1e91) EMITMBC(0x1e95) + case 'z': case 0x17a: case 0x17c: case 0x17e: case 0x1b6: + case 0x1d76: case 0x1d8e: case 0x1e91: case 0x1e93: + case 0x1e95: case 0x2c6c: + EMIT2('z') EMIT2(0x17a) EMIT2(0x17c) EMIT2(0x17e) + EMIT2(0x1b6) EMIT2(0x1d76) EMIT2(0x1d8e) EMIT2(0x1e91) + EMIT2(0x1e93) EMIT2(0x1e95) EMIT2(0x2c6c) return; - /* default: character itself */ + // default: character itself } } EMIT2(c); #undef EMIT2 -#undef EMITMBC } /* diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 60de4e479e..83d555e584 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -164,7 +164,6 @@ static bool resizing = false; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "screen.c.generated.h" #endif -#define SEARCH_HL_PRIORITY 0 static char *provider_err = NULL; @@ -768,7 +767,7 @@ static void win_update(win_T *wp, DecorProviders *providers) redraw_win_signcol(wp); - init_search_hl(wp); + init_search_hl(wp, &search_hl); /* Force redraw when width of 'number' or 'relativenumber' column * changes. */ @@ -1533,7 +1532,7 @@ static void win_update(win_T *wp, DecorProviders *providers) // will draw "@ " lines below. row = wp->w_grid.Rows + 1; } else { - prepare_search_hl(wp, lnum); + prepare_search_hl(wp, &search_hl, lnum); // Let the syntax stuff know we skipped a few lines. if (syntax_last_parsed != 0 && syntax_last_parsed + 1 < lnum && syntax_present(wp)) { @@ -2095,13 +2094,6 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc int line_attr_save; int line_attr_lowprio = 0; // low-priority attribute for the line int line_attr_lowprio_save; - matchitem_T *cur; // points to the match list - match_T *shl; // points to search_hl or a match - bool shl_flag; // flag to indicate whether search_hl - // has been processed or not - bool prevcol_hl_flag; // flag to indicate whether prevcol - // equals startcol of search_hl or one - // of the matches int prev_c = 0; // previous Arabic character int prev_c1 = 0; // first composing char for prev_c @@ -2599,66 +2591,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc } } - /* - * Handle highlighting the last used search pattern and matches. - * Do this for both search_hl and the match list. - */ - cur = wp->w_match_head; - shl_flag = false; - while ((cur != NULL || !shl_flag) && !number_only - && !has_fold && !end_fill) { - if (!shl_flag) { - shl = &search_hl; - shl_flag = true; - } else { - shl = &cur->hl; // -V595 - } - shl->startcol = MAXCOL; - shl->endcol = MAXCOL; - shl->attr_cur = 0; - shl->is_addpos = false; - v = (ptr - line); - if (cur != NULL) { - cur->pos.cur = 0; - } - next_search_hl(wp, shl, lnum, (colnr_T)v, - shl == &search_hl ? NULL : cur); - - // Need to get the line again, a multi-line regexp may have made it - // invalid. - line = ml_get_buf(wp->w_buffer, lnum, false); - ptr = line + v; - - if (shl->lnum != 0 && shl->lnum <= lnum) { - if (shl->lnum == lnum) { - shl->startcol = shl->rm.startpos[0].col; - } else { - shl->startcol = 0; - } - if (lnum == shl->lnum + shl->rm.endpos[0].lnum - - shl->rm.startpos[0].lnum) { - shl->endcol = shl->rm.endpos[0].col; - } else { - shl->endcol = MAXCOL; - } - // Highlight one character for an empty match. - if (shl->startcol == shl->endcol) { - if (line[shl->endcol] != NUL) { - shl->endcol += utfc_ptr2len(line + shl->endcol); - } else { - ++shl->endcol; - } - } - if ((long)shl->startcol < v) { // match at leftcol - shl->attr_cur = shl->attr; - search_attr = shl->attr; - search_attr_from_match = shl != &search_hl; - } - area_highlighting = true; - } - if (shl != &search_hl && cur != NULL) { - cur = cur->next; - } + if (!number_only && !has_fold && !end_fill) { + v = ptr - line; + area_highlighting |= prepare_search_hl_line(wp, lnum, (colnr_T)v, + &line, &search_hl, &search_attr, + &search_attr_from_match); + ptr = line + v; // "line" may have been updated } unsigned off = 0; // Offset relative start of line @@ -2682,6 +2620,8 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc // Repeat for the whole displayed line. for (;;) { int has_match_conc = 0; ///< match wants to conceal + int decor_conceal = 0; + bool did_decrement_ptr = false; // Skip this quickly when working on the text. @@ -3011,115 +2951,13 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc } if (!n_extra) { - /* - * Check for start/end of search pattern match. - * After end, check for start/end of next match. - * When another match, have to check for start again. - * Watch out for matching an empty string! - * Do this for 'search_hl' and the match list (ordered by - * priority). - */ + // Check for start/end of 'hlsearch' and other matches. + // After end, check for start/end of next match. + // When another match, have to check for start again. v = (ptr - line); - cur = wp->w_match_head; - shl_flag = false; - while (cur != NULL || !shl_flag) { - if (!shl_flag - && (cur == NULL || cur->priority > SEARCH_HL_PRIORITY)) { - shl = &search_hl; - shl_flag = true; - } else { - shl = &cur->hl; - } - if (cur != NULL) { - cur->pos.cur = 0; - } - bool pos_inprogress = true; // mark that a position match search is - // in progress - while (shl->rm.regprog != NULL - || (cur != NULL && pos_inprogress)) { - if (shl->startcol != MAXCOL - && v >= (long)shl->startcol - && v < (long)shl->endcol) { - int tmp_col = v + utfc_ptr2len(ptr); - - if (shl->endcol < tmp_col) { - shl->endcol = tmp_col; - } - shl->attr_cur = shl->attr; - // Match with the "Conceal" group results in hiding - // the match. - if (cur != NULL - && shl != &search_hl - && syn_name2id("Conceal") == cur->hlg_id) { - has_match_conc = v == (long)shl->startcol ? 2 : 1; - match_conc = cur->conceal_char; - } else { - has_match_conc = 0; - } - } else if (v == (long)shl->endcol) { - shl->attr_cur = 0; - - next_search_hl(wp, shl, lnum, (colnr_T)v, - shl == &search_hl ? NULL : cur); - pos_inprogress = !(cur == NULL || cur->pos.cur == 0); - - // Need to get the line again, a multi-line regexp - // may have made it invalid. - line = ml_get_buf(wp->w_buffer, lnum, false); - ptr = line + v; - - if (shl->lnum == lnum) { - shl->startcol = shl->rm.startpos[0].col; - if (shl->rm.endpos[0].lnum == 0) { - shl->endcol = shl->rm.endpos[0].col; - } else { - shl->endcol = MAXCOL; - } - - if (shl->startcol == shl->endcol) { - // highlight empty match, try again after it - shl->endcol += utfc_ptr2len(line + shl->endcol); - } - - // Loop to check if the match starts at the - // current position - continue; - } - } - break; - } - if (shl != &search_hl && cur != NULL) { - cur = cur->next; - } - } - - /* Use attributes from match with highest priority among - * 'search_hl' and the match list. */ - search_attr_from_match = false; - search_attr = search_hl.attr_cur; - cur = wp->w_match_head; - shl_flag = false; - while (cur != NULL || !shl_flag) { - if (!shl_flag - && (cur == NULL || cur->priority > SEARCH_HL_PRIORITY)) { - shl = &search_hl; - shl_flag = true; - } else { - shl = &cur->hl; - } - if (shl->attr_cur != 0) { - search_attr = shl->attr_cur; - search_attr_from_match = shl != &search_hl; - } - if (shl != &search_hl && cur != NULL) { - cur = cur->next; - } - } - // Only highlight one character after the last column. - if (*ptr == NUL - && (wp->w_p_list && lcs_eol_one == -1)) { - search_attr = 0; - } + search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line, &search_hl, &has_match_conc, + &match_conc, lcs_eol_one, &search_attr_from_match); + ptr = line + v; // "line" may have been changed // Do not allow a conceal over EOL otherwise EOL will be missed // and bad things happen. @@ -3506,6 +3344,11 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc char_attr = hl_combine_attr(extmark_attr, char_attr); } } + + decor_conceal = decor_state.conceal; + if (decor_conceal && decor_state.conceal_char) { + decor_conceal = 2; // really?? + } } // Found last space before word: check for line break. @@ -3809,19 +3652,25 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc if (wp->w_p_cole > 0 && (wp != curwin || lnum != wp->w_cursor.lnum || conceal_cursor_line(wp)) - && ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0) + && ((syntax_flags & HL_CONCEAL) != 0 || has_match_conc > 0 || decor_conceal > 0) && !(lnum_in_visual_area && vim_strchr(wp->w_p_cocu, 'v') == NULL)) { char_attr = conceal_attr; - if ((prev_syntax_id != syntax_seqnr || has_match_conc > 1) + if ((prev_syntax_id != syntax_seqnr || has_match_conc > 1 || decor_conceal > 1) && (syn_get_sub_char() != NUL || (has_match_conc && match_conc) + || (decor_conceal && decor_state.conceal_char) || wp->w_p_cole == 1) && wp->w_p_cole != 3) { // First time at this concealed item: display one // character. if (has_match_conc && match_conc) { c = match_conc; + } else if (decor_conceal && decor_state.conceal_char) { + c = decor_state.conceal_char; + if (decor_state.conceal_attr) { + char_attr = decor_state.conceal_attr; + } } else if (syn_get_sub_char() != NUL) { c = syn_get_sub_char(); } else if (wp->w_p_lcs_chars.conceal != NUL) { @@ -3926,30 +3775,15 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc // At end of the text line or just after the last character. if (c == NUL && eol_hl_off == 0) { - long prevcol = (ptr - line) - 1; - - // we're not really at that column when skipping some text - if ((long)(wp->w_p_wrap ? wp->w_skipcol : wp->w_leftcol) > prevcol) { - prevcol++; - } + // flag to indicate whether prevcol equals startcol of search_hl or + // one of the matches + bool prevcol_hl_flag = get_prevcol_hl_flag(wp, &search_hl, + (long)(ptr - line) - 1); // Invert at least one char, used for Visual and empty line or // highlight match at end of line. If it's beyond the last // char on the screen, just overwrite that one (tricky!) Not // needed when a '$' was displayed for 'list'. - prevcol_hl_flag = false; - if (!search_hl.is_addpos && prevcol == (long)search_hl.startcol) { - prevcol_hl_flag = true; - } else { - cur = wp->w_match_head; - while (cur != NULL) { - if (!cur->hl.is_addpos && prevcol == (long)cur->hl.startcol) { - prevcol_hl_flag = true; - break; - } - cur = cur->next; - } - } if (wp->w_p_lcs_chars.eol == lcs_eol_one && ((area_attr != 0 && vcol == fromcol && (VIsual_mode != Ctrl_V @@ -3980,25 +3814,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc if (area_attr == 0 && !has_fold) { // Use attributes from match with highest priority among // 'search_hl' and the match list. - char_attr = search_hl.attr; - cur = wp->w_match_head; - shl_flag = false; - while (cur != NULL || !shl_flag) { - if (!shl_flag - && (cur == NULL || cur->priority > SEARCH_HL_PRIORITY)) { - shl = &search_hl; - shl_flag = true; - } else { - shl = &cur->hl; - } - if ((ptr - line) - 1 == (long)shl->startcol - && (shl == &search_hl || !shl->is_addpos)) { - char_attr = shl->attr; - } - if (shl != &search_hl && cur != NULL) { - cur = cur->next; - } - } + get_search_match_hl(wp, &search_hl, (long)(ptr - line), &char_attr); } int eol_attr = char_attr; @@ -6179,277 +5995,6 @@ static void end_search_hl(void) } -/* - * Init for calling prepare_search_hl(). - */ -static void init_search_hl(win_T *wp) - FUNC_ATTR_NONNULL_ALL -{ - // Setup for match and 'hlsearch' highlighting. Disable any previous - // match - matchitem_T *cur = wp->w_match_head; - while (cur != NULL) { - cur->hl.rm = cur->match; - if (cur->hlg_id == 0) { - cur->hl.attr = 0; - } else { - cur->hl.attr = syn_id2attr(cur->hlg_id); - } - cur->hl.buf = wp->w_buffer; - cur->hl.lnum = 0; - cur->hl.first_lnum = 0; - // Set the time limit to 'redrawtime'. - cur->hl.tm = profile_setlimit(p_rdt); - cur = cur->next; - } - search_hl.buf = wp->w_buffer; - search_hl.lnum = 0; - search_hl.first_lnum = 0; - search_hl.attr = win_hl_attr(wp, HLF_L); - - // time limit is set at the toplevel, for all windows -} - -/* - * Advance to the match in window "wp" line "lnum" or past it. - */ -static void prepare_search_hl(win_T *wp, linenr_T lnum) - FUNC_ATTR_NONNULL_ALL -{ - matchitem_T *cur; // points to the match list - match_T *shl; // points to search_hl or a match - bool shl_flag; // flag to indicate whether search_hl - // has been processed or not - - // When using a multi-line pattern, start searching at the top - // of the window or just after a closed fold. - // Do this both for search_hl and the match list. - cur = wp->w_match_head; - shl_flag = false; - while (cur != NULL || shl_flag == false) { - if (shl_flag == false) { - shl = &search_hl; - shl_flag = true; - } else { - shl = &cur->hl; // -V595 - } - if (shl->rm.regprog != NULL - && shl->lnum == 0 - && re_multiline(shl->rm.regprog)) { - if (shl->first_lnum == 0) { - for (shl->first_lnum = lnum; - shl->first_lnum > wp->w_topline; - shl->first_lnum--) { - if (hasFoldingWin(wp, shl->first_lnum - 1, NULL, NULL, true, NULL)) { - break; - } - } - } - if (cur != NULL) { - cur->pos.cur = 0; - } - bool pos_inprogress = true; // mark that a position match search is - // in progress - int n = 0; - while (shl->first_lnum < lnum && (shl->rm.regprog != NULL - || (cur != NULL && pos_inprogress))) { - next_search_hl(wp, shl, shl->first_lnum, (colnr_T)n, - shl == &search_hl ? NULL : cur); - pos_inprogress = !(cur == NULL || cur->pos.cur == 0); - if (shl->lnum != 0) { - shl->first_lnum = shl->lnum - + shl->rm.endpos[0].lnum - - shl->rm.startpos[0].lnum; - n = shl->rm.endpos[0].col; - } else { - ++shl->first_lnum; - n = 0; - } - } - } - if (shl != &search_hl && cur != NULL) { - cur = cur->next; - } - } -} - -/// Search for a next 'hlsearch' or match. -/// Uses shl->buf. -/// Sets shl->lnum and shl->rm contents. -/// Note: Assumes a previous match is always before "lnum", unless -/// shl->lnum is zero. -/// Careful: Any pointers for buffer lines will become invalid. -/// -/// @param shl points to search_hl or a match -/// @param mincol minimal column for a match -/// @param cur to retrieve match positions if any -static void next_search_hl(win_T *win, match_T *shl, linenr_T lnum, colnr_T mincol, - matchitem_T *cur) - FUNC_ATTR_NONNULL_ARG(2) -{ - linenr_T l; - colnr_T matchcol; - long nmatched = 0; - int save_called_emsg = called_emsg; - - // for :{range}s/pat only highlight inside the range - if (lnum < search_first_line || lnum > search_last_line) { - shl->lnum = 0; - return; - } - - if (shl->lnum != 0) { - // Check for three situations: - // 1. If the "lnum" is below a previous match, start a new search. - // 2. If the previous match includes "mincol", use it. - // 3. Continue after the previous match. - l = shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum; - if (lnum > l) { - shl->lnum = 0; - } else if (lnum < l || shl->rm.endpos[0].col > mincol) { - return; - } - } - - /* - * Repeat searching for a match until one is found that includes "mincol" - * or none is found in this line. - */ - called_emsg = FALSE; - for (;;) { - // Stop searching after passing the time limit. - if (profile_passed_limit(shl->tm)) { - shl->lnum = 0; // no match found in time - break; - } - // Three situations: - // 1. No useful previous match: search from start of line. - // 2. Not Vi compatible or empty match: continue at next character. - // Break the loop if this is beyond the end of the line. - // 3. Vi compatible searching: continue at end of previous match. - if (shl->lnum == 0) { - matchcol = 0; - } else if (vim_strchr(p_cpo, CPO_SEARCH) == NULL - || (shl->rm.endpos[0].lnum == 0 - && shl->rm.endpos[0].col <= shl->rm.startpos[0].col)) { - char_u *ml; - - matchcol = shl->rm.startpos[0].col; - ml = ml_get_buf(shl->buf, lnum, false) + matchcol; - if (*ml == NUL) { - ++matchcol; - shl->lnum = 0; - break; - } - matchcol += utfc_ptr2len(ml); - } else { - matchcol = shl->rm.endpos[0].col; - } - - shl->lnum = lnum; - if (shl->rm.regprog != NULL) { - // Remember whether shl->rm is using a copy of the regprog in - // cur->match. - bool regprog_is_copy = (shl != &search_hl - && cur != NULL - && shl == &cur->hl - && cur->match.regprog == cur->hl.rm.regprog); - int timed_out = false; - - nmatched = vim_regexec_multi(&shl->rm, win, shl->buf, lnum, matchcol, - &(shl->tm), &timed_out); - // Copy the regprog, in case it got freed and recompiled. - if (regprog_is_copy) { - cur->match.regprog = cur->hl.rm.regprog; - } - if (called_emsg || got_int || timed_out) { - // Error while handling regexp: stop using this regexp. - if (shl == &search_hl) { - // don't free regprog in the match list, it's a copy - vim_regfree(shl->rm.regprog); - set_no_hlsearch(true); - } - shl->rm.regprog = NULL; - shl->lnum = 0; - got_int = FALSE; // avoid the "Type :quit to exit Vim" message - break; - } - } else if (cur != NULL) { - nmatched = next_search_hl_pos(shl, lnum, &(cur->pos), matchcol); - } - if (nmatched == 0) { - shl->lnum = 0; // no match found - break; - } - if (shl->rm.startpos[0].lnum > 0 - || shl->rm.startpos[0].col >= mincol - || nmatched > 1 - || shl->rm.endpos[0].col > mincol) { - shl->lnum += shl->rm.startpos[0].lnum; - break; // useful match found - } - - // Restore called_emsg for assert_fails(). - called_emsg = save_called_emsg; - } -} - -/// @param shl points to a match. Fill on match. -/// @param posmatch match positions -/// @param mincol minimal column for a match -/// -/// @return one on match, otherwise return zero. -static int next_search_hl_pos(match_T *shl, linenr_T lnum, posmatch_T *posmatch, colnr_T mincol) - FUNC_ATTR_NONNULL_ALL -{ - int i; - int found = -1; - - shl->lnum = 0; - for (i = posmatch->cur; i < MAXPOSMATCH; i++) { - llpos_T *pos = &posmatch->pos[i]; - - if (pos->lnum == 0) { - break; - } - if (pos->len == 0 && pos->col < mincol) { - continue; - } - if (pos->lnum == lnum) { - if (found >= 0) { - // if this match comes before the one at "found" then swap - // them - if (pos->col < posmatch->pos[found].col) { - llpos_T tmp = *pos; - - *pos = posmatch->pos[found]; - posmatch->pos[found] = tmp; - } - } else { - found = i; - } - } - } - posmatch->cur = 0; - if (found >= 0) { - colnr_T start = posmatch->pos[found].col == 0 - ? 0: posmatch->pos[found].col - 1; - colnr_T end = posmatch->pos[found].col == 0 - ? MAXCOL : start + posmatch->pos[found].len; - - shl->lnum = lnum; - shl->rm.startpos[0].lnum = 0; - shl->rm.startpos[0].col = start; - shl->rm.endpos[0].lnum = 0; - shl->rm.endpos[0].col = end; - shl->is_addpos = true; - posmatch->cur = found + 1; - return 1; - } - return 0; -} - - /// Fill the grid from 'start_row' to 'end_row', from 'start_col' to 'end_col' /// with character 'c1' in first column followed by 'c2' in the other columns. /// Use attributes 'attr'. diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim index eab47dbccc..191cd948ac 100644 --- a/src/nvim/testdir/test_regexp_utf8.vim +++ b/src/nvim/testdir/test_regexp_utf8.vim @@ -1,21 +1,21 @@ " Tests for regexp in utf8 encoding func s:equivalence_test() - let str = "AÀÁÂÃÄÅĀĂĄǍǞǠẢ BḂḆ CÇĆĈĊČ DĎĐḊḎḐ EÈÉÊËĒĔĖĘĚẺẼ FḞ GĜĞĠĢǤǦǴḠ HĤĦḢḦḨ IÌÍÎÏĨĪĬĮİǏỈ JĴ KĶǨḰḴ LĹĻĽĿŁḺ MḾṀ NÑŃŅŇṄṈ OÒÓÔÕÖØŌŎŐƠǑǪǬỎ PṔṖ Q RŔŖŘṘṞ SŚŜŞŠṠ TŢŤŦṪṮ UÙÚÛÜŨŪŬŮŰŲƯǓỦ VṼ WŴẀẂẄẆ XẊẌ YÝŶŸẎỲỶỸ ZŹŻŽƵẐẔ aàáâãäåāăąǎǟǡả bḃḇ cçćĉċč dďđḋḏḑ eèéêëēĕėęěẻẽ fḟ gĝğġģǥǧǵḡ hĥħḣḧḩẖ iìíîïĩīĭįǐỉ jĵǰ kķǩḱḵ lĺļľŀłḻ mḿṁ nñńņňʼnṅṉ oòóôõöøōŏőơǒǫǭỏ pṕṗ q rŕŗřṙṟ sśŝşšṡ tţťŧṫṯẗ uùúûüũūŭůűųưǔủ vṽ wŵẁẃẅẇẘ xẋẍ yýÿŷẏẙỳỷỹ zźżžƶẑẕ" + let str = "AÀÁÂÃÄÅĀĂĄǍǞǠǺȂȦȺḀẠẢẤẦẨẪẬẮẰẲẴẶ BƁɃḂḄḆ CÇĆĈĊČƇȻḈꞒ DĎĐƊḊḌḎḐḒ EÈÉÊËĒĔĖĘĚȄȆȨɆḔḖḘḚḜẸẺẼẾỀỂỄỆ FƑḞꞘ GĜĞĠĢƓǤǦǴḠꞠ HĤĦȞḢḤḦḨḪⱧ IÌÍÎÏĨĪĬĮİƗǏȈȊḬḮỈỊ JĴɈ KĶƘǨḰḲḴⱩꝀ LĹĻĽĿŁȽḶḸḺḼⱠ MḾṀṂ NÑŃŅŇǸṄṆṈṊꞤ OÒÓÔÕÖØŌŎŐƟƠǑǪǬǾȌȎȪȬȮȰṌṎṐṒỌỎỐỒỔỖỘỚỜỞỠỢ PƤṔṖⱣ QɊ RŔŖŘȐȒɌṘṚṜṞⱤꞦ SŚŜŞŠȘṠṢṤṦṨⱾꞨ TŢŤŦƬƮȚȾṪṬṮṰ UÙÚÛÜŨŪŬŮŰƯǕǙǛǓǗȔȖɄṲṴṶṸṺỤỦỨỪỬỮỰ VƲṼṾ WŴẀẂẄẆẈ XẊẌ YÝŶŸƳȲɎẎỲỴỶỸ ZŹŻŽƵẐẒẔⱫ aàáâãäåāăąǎǟǡǻȃȧᶏḁẚạảấầẩẫậắằẳẵặⱥ bƀɓᵬᶀḃḅḇ cçćĉċčƈȼḉꞓꞔ dďđɗᵭᶁᶑḋḍḏḑḓ eèéêëēĕėęěȅȇȩɇᶒḕḗḙḛḝẹẻẽếềểễệ fƒᵮᶂḟꞙ gĝğġģǥǧǵɠᶃḡꞡ hĥħȟḣḥḧḩḫẖⱨꞕ iìíîïĩīĭįǐȉȋɨᶖḭḯỉị jĵǰɉ kķƙǩᶄḱḳḵⱪꝁ lĺļľŀłƚḷḹḻḽⱡ mᵯḿṁṃ nñńņňʼnǹᵰᶇṅṇṉṋꞥ oòóôõöøōŏőơǒǫǭǿȍȏȫȭȯȱɵṍṏṑṓọỏốồổỗộớờởỡợ pƥᵱᵽᶈṕṗ qɋʠ rŕŗřȑȓɍɽᵲᵳᶉṛṝṟꞧ sśŝşšșȿᵴᶊṡṣṥṧṩꞩ tţťŧƫƭțʈᵵṫṭṯṱẗⱦ uùúûüũūŭůűųǚǖưǔǘǜȕȗʉᵾᶙṳṵṷṹṻụủứừửữự vʋᶌṽṿ wŵẁẃẅẇẉẘ xẋẍ yýÿŷƴȳɏẏẙỳỵỷỹ zźżžƶᵶᶎẑẓẕⱬ" let groups = split(str) for group1 in groups - for c in split(group1, '\zs') - " next statement confirms that equivalence class matches every - " character in group - call assert_match('^[[=' . c . '=]]*$', group1) - for group2 in groups - if group2 != group1 - " next statement converts that equivalence class doesn't match - " character in any other group - call assert_equal(-1, match(group2, '[[=' . c . '=]]')) - endif + for c in split(group1, '\zs') + " next statement confirms that equivalence class matches every + " character in group + call assert_match('^[[=' .. c .. '=]]*$', group1) + for group2 in groups + if group2 != group1 + " next statement converts that equivalence class doesn't match + " character in any other group + call assert_equal(-1, match(group2, '[[=' .. c .. '=]]'), c) + endif + endfor endfor - endfor endfor endfunc @@ -223,7 +223,7 @@ endfunc func Test_reversed_range() for re in range(0, 2) exe 'set re=' . re - call assert_fails('call match("abc def", "[c-a]")', 'E944:') + call assert_fails('call match("abc def", "[c-a]")', 'E944:', re) endfor set re=0 endfunc diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 917847608a..24958ce041 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -115,34 +115,28 @@ static void tinput_done_event(void **argv) static void tinput_wait_enqueue(void **argv) { TermInput *input = argv[0]; - if (rbuffer_size(input->key_buffer) == 0 && input->paste == 3) { - // End streamed paste with an empty string. - const String keys = { .data = "", .size = 0 }; - String copy = copy_string(keys); - multiqueue_put(main_loop.events, tinput_paste_event, 3, - copy.data, copy.size, (intptr_t)input->paste); - } - RBUFFER_UNTIL_EMPTY(input->key_buffer, buf, len) { - const String keys = { .data = buf, .size = len }; - if (input->paste) { - String copy = copy_string(keys); - if (ui_client_channel_id) { - Array args = ARRAY_DICT_INIT; - ADD(args, STRING_OBJ(copy_string(keys))); // 'data' - ADD(args, BOOLEAN_OBJ(true)); // 'crlf' - ADD(args, INTEGER_OBJ(input->paste)); // 'phase' - rpc_send_event(ui_client_channel_id, "nvim_paste", args); - } else { - multiqueue_put(main_loop.events, tinput_paste_event, 3, - copy.data, copy.size, (intptr_t)input->paste); - } - if (input->paste == 1) { - // Paste phase: "continue" - input->paste = 2; - } - rbuffer_consumed(input->key_buffer, len); - rbuffer_reset(input->key_buffer); + if (input->paste) { // produce exactly one paste event + const size_t len = rbuffer_size(input->key_buffer); + String keys = { .data = xmallocz(len), .size = len }; + rbuffer_read(input->key_buffer, keys.data, len); + if (ui_client_channel_id) { + Array args = ARRAY_DICT_INIT; + ADD(args, STRING_OBJ(keys)); // 'data' + ADD(args, BOOLEAN_OBJ(true)); // 'crlf' + ADD(args, INTEGER_OBJ(input->paste)); // 'phase' + rpc_send_event(ui_client_channel_id, "nvim_paste", args); } else { + multiqueue_put(main_loop.events, tinput_paste_event, 3, + keys.data, keys.size, (intptr_t)input->paste); + } + if (input->paste == 1) { + // Paste phase: "continue" + input->paste = 2; + } + rbuffer_reset(input->key_buffer); + } else { // enqueue input for the main thread or Nvim server + RBUFFER_UNTIL_EMPTY(input->key_buffer, buf, len) { + const String keys = { .data = buf, .size = len }; size_t consumed; if (ui_client_channel_id) { Array args = ARRAY_DICT_INIT; diff --git a/src/nvim/window.c b/src/nvim/window.c index 8b9f1e024d..50a56056bf 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1082,7 +1082,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) } } } else { - hsep_height = global_stl_height() > 0 ? 1 : STATUS_HEIGHT; + hsep_height = STATUS_HEIGHT; layout = FR_COL; /* @@ -1374,8 +1374,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) } frame_new_height(curfrp, new_fr_height, flags & WSP_TOP, false); } else { - win_new_height(oldwin, oldwin_height - (new_size - + (global_stl_height() > 0 ? 1 : STATUS_HEIGHT))); + win_new_height(oldwin, oldwin_height - (new_size + STATUS_HEIGHT)); } if (before) { // new window above current one @@ -1643,7 +1642,7 @@ int make_windows(int count, bool vertical) // Each window needs at least 'winminheight' lines // If statusline isn't global, each window also needs a statusline maxcount = (curwin->w_height + curwin->w_hsep_height + curwin->w_status_height - - (p_wh - p_wmh)) / (p_wmh + (global_stl_height() > 0 ? 1 : STATUS_HEIGHT)); + - (p_wh - p_wmh)) / (p_wmh + STATUS_HEIGHT); } if (maxcount < 2) { @@ -2166,7 +2165,7 @@ static void win_equal_rec(win_T *next_curwin, bool current, frame_T *topfr, int totwincount -= wincount; } } else { // topfr->fr_layout == FR_COL - hsep_height = global_stl_height() > 0 ? 1 : STATUS_HEIGHT; + hsep_height = STATUS_HEIGHT; topfr->fr_width = width; topfr->fr_height = height; @@ -6953,286 +6952,6 @@ void restore_buffer(bufref_T *save_curbuf) } } - -/// Add match to the match list of window 'wp'. The pattern 'pat' will be -/// highlighted with the group 'grp' with priority 'prio'. -/// Optionally, a desired ID 'id' can be specified (greater than or equal to 1). -/// -/// @param[in] id a desired ID 'id' can be specified -/// (greater than or equal to 1). -1 must be specified if no -/// particular ID is desired -/// @param[in] conceal_char pointer to conceal replacement char -/// @return ID of added match, -1 on failure. -int match_add(win_T *wp, const char *const grp, const char *const pat, int prio, int id, - list_T *pos_list, const char *const conceal_char) - FUNC_ATTR_NONNULL_ARG(1, 2) -{ - matchitem_T *cur; - matchitem_T *prev; - matchitem_T *m; - int hlg_id; - regprog_T *regprog = NULL; - int rtype = SOME_VALID; - - if (*grp == NUL || (pat != NULL && *pat == NUL)) { - return -1; - } - if (id < -1 || id == 0) { - semsg(_("E799: Invalid ID: %" PRId64 - " (must be greater than or equal to 1)"), - (int64_t)id); - return -1; - } - if (id != -1) { - cur = wp->w_match_head; - while (cur != NULL) { - if (cur->id == id) { - semsg(_("E801: ID already taken: %" PRId64), (int64_t)id); - return -1; - } - cur = cur->next; - } - } - if ((hlg_id = syn_check_group(grp, strlen(grp))) == 0) { - return -1; - } - if (pat != NULL && (regprog = vim_regcomp((char_u *)pat, RE_MAGIC)) == NULL) { - semsg(_(e_invarg2), pat); - return -1; - } - - // Find available match ID. - while (id == -1) { - cur = wp->w_match_head; - while (cur != NULL && cur->id != wp->w_next_match_id) { - cur = cur->next; - } - if (cur == NULL) { - id = wp->w_next_match_id; - } - wp->w_next_match_id++; - } - - // Build new match. - m = xcalloc(1, sizeof(matchitem_T)); - m->id = id; - m->priority = prio; - m->pattern = pat == NULL ? NULL: (char_u *)xstrdup(pat); - m->hlg_id = hlg_id; - m->match.regprog = regprog; - m->match.rmm_ic = FALSE; - m->match.rmm_maxcol = 0; - m->conceal_char = 0; - if (conceal_char != NULL) { - m->conceal_char = utf_ptr2char((const char_u *)conceal_char); - } - - // Set up position matches - if (pos_list != NULL) { - linenr_T toplnum = 0; - linenr_T botlnum = 0; - - int i = 0; - TV_LIST_ITER(pos_list, li, { - linenr_T lnum = 0; - colnr_T col = 0; - int len = 1; - bool error = false; - - if (TV_LIST_ITEM_TV(li)->v_type == VAR_LIST) { - const list_T *const subl = TV_LIST_ITEM_TV(li)->vval.v_list; - const listitem_T *subli = tv_list_first(subl); - if (subli == NULL) { - semsg(_("E5030: Empty list at position %d"), - (int)tv_list_idx_of_item(pos_list, li)); - goto fail; - } - lnum = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); - if (error) { - goto fail; - } - if (lnum <= 0) { - continue; - } - m->pos.pos[i].lnum = lnum; - subli = TV_LIST_ITEM_NEXT(subl, subli); - if (subli != NULL) { - col = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); - if (error) { - goto fail; - } - if (col < 0) { - continue; - } - subli = TV_LIST_ITEM_NEXT(subl, subli); - if (subli != NULL) { - len = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); - if (len < 0) { - continue; - } - if (error) { - goto fail; - } - } - } - m->pos.pos[i].col = col; - m->pos.pos[i].len = len; - } else if (TV_LIST_ITEM_TV(li)->v_type == VAR_NUMBER) { - if (TV_LIST_ITEM_TV(li)->vval.v_number <= 0) { - continue; - } - m->pos.pos[i].lnum = TV_LIST_ITEM_TV(li)->vval.v_number; - m->pos.pos[i].col = 0; - m->pos.pos[i].len = 0; - } else { - semsg(_("E5031: List or number required at position %d"), - (int)tv_list_idx_of_item(pos_list, li)); - goto fail; - } - if (toplnum == 0 || lnum < toplnum) { - toplnum = lnum; - } - if (botlnum == 0 || lnum >= botlnum) { - botlnum = lnum + 1; - } - i++; - if (i >= MAXPOSMATCH) { - break; - } - }); - - // Calculate top and bottom lines for redrawing area - if (toplnum != 0) { - if (wp->w_buffer->b_mod_set) { - if (wp->w_buffer->b_mod_top > toplnum) { - wp->w_buffer->b_mod_top = toplnum; - } - if (wp->w_buffer->b_mod_bot < botlnum) { - wp->w_buffer->b_mod_bot = botlnum; - } - } else { - wp->w_buffer->b_mod_set = true; - wp->w_buffer->b_mod_top = toplnum; - wp->w_buffer->b_mod_bot = botlnum; - wp->w_buffer->b_mod_xlines = 0; - } - m->pos.toplnum = toplnum; - m->pos.botlnum = botlnum; - rtype = VALID; - } - } - - // Insert new match. The match list is in ascending order with regard to - // the match priorities. - cur = wp->w_match_head; - prev = cur; - while (cur != NULL && prio >= cur->priority) { - prev = cur; - cur = cur->next; - } - if (cur == prev) { - wp->w_match_head = m; - } else { - prev->next = m; - } - m->next = cur; - - redraw_later(wp, rtype); - return id; - -fail: - xfree(m); - return -1; -} - - -/// Delete match with ID 'id' in the match list of window 'wp'. -/// -/// @param perr print error messages if true. -int match_delete(win_T *wp, int id, bool perr) -{ - matchitem_T *cur = wp->w_match_head; - matchitem_T *prev = cur; - int rtype = SOME_VALID; - - if (id < 1) { - if (perr) { - semsg(_("E802: Invalid ID: %" PRId64 - " (must be greater than or equal to 1)"), - (int64_t)id); - } - return -1; - } - while (cur != NULL && cur->id != id) { - prev = cur; - cur = cur->next; - } - if (cur == NULL) { - if (perr) { - semsg(_("E803: ID not found: %" PRId64), (int64_t)id); - } - return -1; - } - if (cur == prev) { - wp->w_match_head = cur->next; - } else { - prev->next = cur->next; - } - vim_regfree(cur->match.regprog); - xfree(cur->pattern); - if (cur->pos.toplnum != 0) { - if (wp->w_buffer->b_mod_set) { - if (wp->w_buffer->b_mod_top > cur->pos.toplnum) { - wp->w_buffer->b_mod_top = cur->pos.toplnum; - } - if (wp->w_buffer->b_mod_bot < cur->pos.botlnum) { - wp->w_buffer->b_mod_bot = cur->pos.botlnum; - } - } else { - wp->w_buffer->b_mod_set = true; - wp->w_buffer->b_mod_top = cur->pos.toplnum; - wp->w_buffer->b_mod_bot = cur->pos.botlnum; - wp->w_buffer->b_mod_xlines = 0; - } - rtype = VALID; - } - xfree(cur); - redraw_later(wp, rtype); - return 0; -} - -/* - * Delete all matches in the match list of window 'wp'. - */ -void clear_matches(win_T *wp) -{ - matchitem_T *m; - - while (wp->w_match_head != NULL) { - m = wp->w_match_head->next; - vim_regfree(wp->w_match_head->match.regprog); - xfree(wp->w_match_head->pattern); - xfree(wp->w_match_head); - wp->w_match_head = m; - } - redraw_later(wp, SOME_VALID); -} - -/* - * Get match from ID 'id' in window 'wp'. - * Return NULL if match not found. - */ -matchitem_T *get_match(win_T *wp, int id) -{ - matchitem_T *cur = wp->w_match_head; - - while (cur != NULL && cur->id != id) { - cur = cur->next; - } - return cur; -} - - /// Check that "topfrp" and its children are at the right height. /// /// @param topfrp top frame pointer diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index 372cbf2c30..a58ca00a75 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -154,6 +154,34 @@ describe('autocmd api', function() eq(1, #aus, aus) end) end) + + it('removes an autocommand if the callback returns true', function() + meths.set_var("some_condition", false) + + exec_lua [[ + vim.api.nvim_create_autocmd("User", { + pattern = "Test", + desc = "A test autocommand", + callback = function() + return vim.g.some_condition + end, + }) + ]] + + meths.do_autocmd("User", {pattern = "Test"}) + eq({{ + buflocal = false, + command = 'A test autocommand', + desc = 'A test autocommand', + event = 'User', + id = 1, + once = false, + pattern = 'Test', + }}, meths.get_autocmds({event = "User", pattern = "Test"})) + meths.set_var("some_condition", true) + meths.do_autocmd("User", {pattern = "Test"}) + eq({}, meths.get_autocmds({event = "User", pattern = "Test"})) + end) end) describe('nvim_get_autocmds', function() diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index af6872760a..ed9d915954 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -6,6 +6,7 @@ local assert_alive = helpers.assert_alive local NIL = helpers.NIL local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq local command = helpers.command +local exec = helpers.exec local eval = helpers.eval local expect = helpers.expect local funcs = helpers.funcs @@ -1271,6 +1272,17 @@ describe('API', function() eq('Key is locked: lua', pcall_err(meths.del_var, 'lua')) eq('Key is locked: lua', pcall_err(meths.set_var, 'lua', 1)) + exec([[ + function Test() + endfunction + function s:Test() + endfunction + let g:Unknown_func = function('Test') + let g:Unknown_script_func = function('s:Test') + ]]) + eq(NIL, meths.get_var('Unknown_func')) + eq(NIL, meths.get_var('Unknown_script_func')) + -- Check if autoload works properly local pathsep = helpers.get_pathsep() local xconfig = 'Xhome' .. pathsep .. 'Xconfig' diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 5b4daf02ea..38cb54fbc6 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1043,6 +1043,17 @@ describe('lua stdlib', function() exec_lua([[vim.api.nvim_get_var('funcs').add()]]) eq(6, exec_lua([[return vim.api.nvim_get_var('funcs').get()]])) + exec([[ + function Test() + endfunction + function s:Test() + endfunction + let g:Unknown_func = function('Test') + let g:Unknown_script_func = function('s:Test') + ]]) + eq(NIL, exec_lua([[return vim.g.Unknown_func]])) + eq(NIL, exec_lua([[return vim.g.Unknown_script_func]])) + -- Check if autoload works properly local pathsep = helpers.get_pathsep() local xconfig = 'Xhome' .. pathsep .. 'Xconfig' @@ -1136,6 +1147,17 @@ describe('lua stdlib', function() exec_lua([[vim.api.nvim_buf_get_var(0, 'funcs').add()]]) eq(6, exec_lua([[return vim.api.nvim_buf_get_var(0, 'funcs').get()]])) + exec([[ + function Test() + endfunction + function s:Test() + endfunction + let b:Unknown_func = function('Test') + let b:Unknown_script_func = function('s:Test') + ]]) + eq(NIL, exec_lua([[return vim.b.Unknown_func]])) + eq(NIL, exec_lua([[return vim.b.Unknown_script_func]])) + exec_lua [[ vim.cmd "vnew" ]] @@ -1219,6 +1241,17 @@ describe('lua stdlib', function() exec_lua([[vim.api.nvim_win_get_var(0, 'funcs').add()]]) eq(6, exec_lua([[return vim.api.nvim_win_get_var(0, 'funcs').get()]])) + exec([[ + function Test() + endfunction + function s:Test() + endfunction + let w:Unknown_func = function('Test') + let w:Unknown_script_func = function('s:Test') + ]]) + eq(NIL, exec_lua([[return vim.w.Unknown_func]])) + eq(NIL, exec_lua([[return vim.w.Unknown_script_func]])) + exec_lua [[ vim.cmd "vnew" ]] diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index eab520948f..6cda9af0f4 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -2374,18 +2374,16 @@ describe('LSP', function() end) describe('lsp.util.get_effective_tabstop', function() - local function test_tabstop(tabsize, softtabstop) + local function test_tabstop(tabsize, shiftwidth) exec_lua(string.format([[ - vim.api.nvim_buf_set_option(0, 'softtabstop', %d) + vim.api.nvim_buf_set_option(0, 'shiftwidth', %d) vim.api.nvim_buf_set_option(0, 'tabstop', 2) - vim.api.nvim_buf_set_option(0, 'shiftwidth', 3) - ]], softtabstop)) + ]], shiftwidth)) eq(tabsize, exec_lua('return vim.lsp.util.get_effective_tabstop()')) end - it('with softtabstop = 1', function() test_tabstop(1, 1) end) - it('with softtabstop = 0', function() test_tabstop(2, 0) end) - it('with softtabstop = -1', function() test_tabstop(3, -1) end) + it('with shiftwidth = 1', function() test_tabstop(1, 1) end) + it('with shiftwidth = 0', function() test_tabstop(2, 0) end) end) describe('vim.lsp.buf.outgoing_calls', function() diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua index ed28d8a37d..5ec0a8a060 100644 --- a/test/functional/treesitter/highlight_spec.lua +++ b/test/functional/treesitter/highlight_spec.lua @@ -672,6 +672,46 @@ describe('treesitter highlighting', function() ]]} end) + it("supports conceal attribute", function() + if pending_c_parser(pending) then return end + insert(hl_text) + + -- conceal can be empty or a single cchar. + exec_lua [=[ + vim.opt.cole = 2 + local parser = vim.treesitter.get_parser(0, "c") + test_hl = vim.treesitter.highlighter.new(parser, {queries = {c = [[ + ("static" @keyword + (set! conceal "R")) + + ((identifier) @Identifier + (set! conceal "") + (eq? @Identifier "lstate")) + ]]}}) + ]=] + + screen:expect{grid=[[ + /// Schedule Lua callback on main loop's event queue | + {4:R} int nlua_schedule(lua_State *const ) | + { | + if (lua_type(, 1) != LUA_TFUNCTION | + || != ) { | + lua_pushliteral(, "vim.schedule: expected function"); | + return lua_error(); | + } | + | + LuaRef cb = nlua_ref(, 1); | + | + multiqueue_put(main_loop.events, nlua_schedule_event, | + 1, (void *)(ptrdiff_t)cb); | + return 0; | + ^} | + {1:~ }| + {1:~ }| + | + ]]} + end) + it("hl_map has the correct fallback behavior", function() exec_lua [[ local hl_map = vim.treesitter.highlighter.hl_map |