Add comment & binding for in-/decrease Todo-status
This commit is contained in:
parent
0178114c7f
commit
20afe48edd
@ -808,6 +808,78 @@ function! s:remove_cb(item) "{{{
|
||||
return item
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
"Increment checkbox between [ ] and [X]
|
||||
"in the lines of the given range
|
||||
function! vimwiki#lst#decrement_cb(from_line, to_line) "{{{
|
||||
let from_item = s:get_corresponding_item(a:from_line)
|
||||
if from_item.type == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let parent_items_of_lines = []
|
||||
|
||||
if from_item.cb != ''
|
||||
|
||||
"if from_line has CB, toggle it and set all siblings to the same new state
|
||||
let rate_first_line = s:get_rate(from_item)
|
||||
let n=len(g:vimwiki_listsyms_list)
|
||||
let new_rate = max([rate_first_line - 100/(n-1)-1, 0])
|
||||
|
||||
for cur_ln in range(from_item.lnum, a:to_line)
|
||||
let cur_item = s:get_item(cur_ln)
|
||||
if cur_item.type != 0 && cur_item.cb != ''
|
||||
call s:set_state_plus_children(cur_item, new_rate)
|
||||
let cur_parent_item = s:get_parent(cur_item)
|
||||
if index(parent_items_of_lines, cur_parent_item) == -1
|
||||
call insert(parent_items_of_lines, cur_parent_item)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
endif
|
||||
|
||||
for parent_item in parent_items_of_lines
|
||||
call s:update_state(parent_item)
|
||||
endfor
|
||||
|
||||
endfunction "}}}
|
||||
"Increment checkbox between [ ] and [X]
|
||||
"in the lines of the given range
|
||||
function! vimwiki#lst#increment_cb(from_line, to_line) "{{{
|
||||
let from_item = s:get_corresponding_item(a:from_line)
|
||||
if from_item.type == 0
|
||||
return
|
||||
endif
|
||||
|
||||
let parent_items_of_lines = []
|
||||
|
||||
if from_item.cb != ''
|
||||
|
||||
"if from_line has CB, toggle it and set all siblings to the same new state
|
||||
let rate_first_line = s:get_rate(from_item)
|
||||
let n=len(g:vimwiki_listsyms_list)
|
||||
let new_rate = min([rate_first_line + 100/(n-1)+1, 100])
|
||||
|
||||
for cur_ln in range(from_item.lnum, a:to_line)
|
||||
let cur_item = s:get_item(cur_ln)
|
||||
if cur_item.type != 0 && cur_item.cb != ''
|
||||
call s:set_state_plus_children(cur_item, new_rate)
|
||||
let cur_parent_item = s:get_parent(cur_item)
|
||||
if index(parent_items_of_lines, cur_parent_item) == -1
|
||||
call insert(parent_items_of_lines, cur_parent_item)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
endif
|
||||
|
||||
for parent_item in parent_items_of_lines
|
||||
call s:update_state(parent_item)
|
||||
endfor
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
"Toggles checkbox between [ ] and [X] or creates one
|
||||
"in the lines of the given range
|
||||
function! vimwiki#lst#toggle_cb(from_line, to_line) "{{{
|
||||
|
@ -295,6 +295,8 @@ command! -buffer -range -nargs=1 VimwikiChangeSymbolTo call vimwiki#lst#change_m
|
||||
command! -buffer -range -nargs=1 VimwikiListChangeSymbolI call vimwiki#lst#change_marker(<line1>, <line2>, <f-args>, 'i')
|
||||
command! -buffer -nargs=1 VimwikiChangeSymbolInListTo call vimwiki#lst#change_marker_in_list(<f-args>)
|
||||
command! -buffer -range VimwikiToggleListItem call vimwiki#lst#toggle_cb(<line1>, <line2>)
|
||||
command! -buffer -range VimwikiIncrementListItem call vimwiki#lst#increment_cb(<line1>, <line2>)
|
||||
command! -buffer -range VimwikiDecrementListItem call vimwiki#lst#decrement_cb(<line1>, <line2>)
|
||||
command! -buffer -range -nargs=+ VimwikiListChangeLvl call vimwiki#lst#change_level(<line1>, <line2>, <f-args>)
|
||||
command! -buffer -range VimwikiRemoveSingleCB call vimwiki#lst#remove_cb(<line1>, <line2>)
|
||||
command! -buffer VimwikiRemoveCBInList call vimwiki#lst#remove_cb_in_list()
|
||||
@ -445,6 +447,23 @@ nnoremap <silent><script><buffer>
|
||||
vnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiToggleListItem :VimwikiToggleListItem<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiIncrementListItem')
|
||||
nmap <silent><buffer> <M-+> <Plug>VimwikiIncrementListItem
|
||||
vmap <silent><buffer> <M-+> <Plug>VimwikiIncrementListItem
|
||||
endif
|
||||
if !hasmapto('<Plug>VimwikiDecrementListItem')
|
||||
nmap <silent><buffer> <M--> <Plug>VimwikiDecrementListItem
|
||||
vmap <silent><buffer> <M--> <Plug>VimwikiDecrementListItem
|
||||
endif
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiIncrementListItem :VimwikiIncrementListItem<CR>
|
||||
vnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiIncrementListItem :VimwikiIncrementListItem<CR>
|
||||
nnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDecrementListItem :VimwikiDecrementListItem<CR>
|
||||
vnoremap <silent><script><buffer>
|
||||
\ <Plug>VimwikiDecrementListItem :VimwikiDecrementListItem<CR>
|
||||
|
||||
if !hasmapto('<Plug>VimwikiDecreaseLvlSingleItem', 'i')
|
||||
imap <silent><buffer> <C-D>
|
||||
\ <Plug>VimwikiDecreaseLvlSingleItem
|
||||
|
Loading…
Reference in New Issue
Block a user