From 1229bea12e0d469e241008c61042b8e1d794447c Mon Sep 17 00:00:00 2001 From: PangPangPangPangPang <446964321@qq.com> Date: Thu, 5 Nov 2020 17:15:36 +0800 Subject: [PATCH] add 'ignore_case' config --- MANUAL.md | 11 ++++++----- autoload/quickui/context.vim | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/MANUAL.md b/MANUAL.md index 30f1704..c407cf9 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -2,7 +2,7 @@ QuickUI is fully customizable, and can be easily configurated. -# Content +# Content @@ -252,7 +252,9 @@ open the context menu: quickui#context#open(content, opts) ``` -Parameter `content` is a list of `[text, command]` items. `opts` is a dictionary of options, has similar options in `listbox`. +Parameter `content` is a list of `[text, command]` items. `opts` is a dictionary of options, has similar options in `listbox` but an additional option: + +- `ignore_case`: ignore case of the keyword, default 1. **Sample code**: @@ -404,8 +406,8 @@ There is a builtin buffer switcher using `listbox`, open it by: call quickui#tools#list_buffer('e') -or - +or + call quickui#tools#list_buffer('tabedit') Then `hjkl` to navigate, `enter`/`space` to switch buffer and `ESC`/`CTRL+[` to quit: @@ -550,4 +552,3 @@ It is time for me to bring these ideas to reality, just start from this plugin. ## Credit like vim-quickui? Follow the repository on [GitHub](https://github.com/skywind3000/vim-quickui) and vote for it on [vim.org](https://www.vim.org/scripts/script.php?script_id=5845). And if you're feeling especially charitable, follow skywind3000 on [Twitter](https://twitter.com/skywind3000) and [GitHub](https://github.com/skywind3000). - diff --git a/autoload/quickui/context.vim b/autoload/quickui/context.vim index cf49d2c..127bc87 100644 --- a/autoload/quickui/context.vim +++ b/autoload/quickui/context.vim @@ -132,7 +132,7 @@ function! s:vim_create_context(textlist, opts) let hwnd.hotkey = {} for item in hwnd.items if item.enable != 0 && item.key_pos >= 0 - let key = tolower(item.key_char) + let key = ignore_case ? tolower(item.key_char) : item.key_char if get(a:opts, 'reserve', 0) == 0 let hwnd.hotkey[key] = item.index elseif get(g:, 'quickui_protect_hjkl', 0) != 0 @@ -491,6 +491,7 @@ endfunc "---------------------------------------------------------------------- function! s:nvim_create_context(textlist, opts) let border = get(a:opts, 'border', g:quickui#style#border) + let ignore_case = get(a:opts, 'ignore_case', 1) let hwnd = quickui#context#compile(a:textlist, border) let bid = quickui#core#scratch_buffer('context', hwnd.image) let hwnd.bid = bid @@ -519,7 +520,7 @@ function! s:nvim_create_context(textlist, opts) let hwnd.hotkey = {} for item in hwnd.items if item.enable != 0 && item.key_pos >= 0 - let key = tolower(item.key_char) + let key = ignore_case ? tolower(item.key_char) : item.key_char if get(a:opts, 'reserve', 0) == 0 let hwnd.hotkey[key] = item.index elseif get(g:, 'quickui_protect_hjkl', 0) != 0