fix vim9 script

master
Totem4 Totem4 1 year ago
parent 0e4028d4e3
commit a5445d0fda

@ -11,26 +11,18 @@ endif
g:autoloaded_Banana = 1 g:autoloaded_Banana = 1
export def Enc() export def Enc()
if line("'<") > 0 call ReplSel(Dec2Ban(GetSel()))
call ReplSel(Dec2Ban(GetSel()))
else
call EncLine()
endif
enddef enddef
def EncLine() export def EncLine()
call setline('.', substitute(getline('.'), '\d\d*', '\=toupper(Doban(submatch(0)))', 'g')) call setline('.', substitute(getline('.'), '\d\d*', '\=toupper(Doban(submatch(0)))', 'g'))
enddef enddef
export def Dec() export def Dec()
if line("'<") > 0 call ReplSel(Ban2Dec(GetSel()))
call ReplSel(Ban2Dec(GetSel()))
else
call DecLine()
endif
enddef enddef
def DecLine() export def DecLine()
call setline('.', substitute(getline('.'), '\C\u\u*', '\=Unban(tolower(submatch(0)))', 'g')) call setline('.', substitute(getline('.'), '\C\u\u*', '\=Unban(tolower(submatch(0)))', 'g'))
enddef enddef
@ -105,7 +97,7 @@ def ReplSel(str: string)
var new_str = slice(lines[0], 0, cstart - 1) .. str .. lines[-1][cend : ] var new_str = slice(lines[0], 0, cstart - 1) .. str .. lines[-1][cend : ]
var new_str_lst = split(new_str, '\n') var new_str_lst = split(new_str, '\n')
call setline(lstart, new_str_lst) call setline(lstart, new_str_lst)
delmarks < > setcursorcharpos(lstart, cstart)
enddef enddef
def Dec2Ban(text: string): string def Dec2Ban(text: string): string

@ -21,9 +21,13 @@ endif
import autoload 'banana.vim' import autoload 'banana.vim'
noremap <silent> <unique> <script> <Plug>BananaEnc nnoremap <silent> <unique> <script> <Plug>BananaEnc
\ :call <SID>banana.EncLine()<CR>
nnoremap <silent> <unique> <script> <Plug>BananaDec
\ :call <SID>banana.DecLine()<CR>
vnoremap <silent> <unique> <script> <Plug>BananaEnc
\ :call <SID>banana.Enc()<CR> \ :call <SID>banana.Enc()<CR>
noremap <silent> <unique> <script> <Plug>BananaDec vnoremap <silent> <unique> <script> <Plug>BananaDec
\ :call <SID>banana.Dec()<CR> \ :call <SID>banana.Dec()<CR>
&cpo = keepcpo &cpo = keepcpo

Loading…
Cancel
Save