From a5445d0fdad5b3d2d67709f00c93d4e5bf35c0c7 Mon Sep 17 00:00:00 2001 From: totem4 Date: Thu, 21 Sep 2023 21:08:09 +0200 Subject: [PATCH] fix vim9 script --- vim9/autoload/banana.vim | 18 +++++------------- vim9/plugin/banana.vim | 8 ++++++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/vim9/autoload/banana.vim b/vim9/autoload/banana.vim index 6ff926f..dddbe05 100644 --- a/vim9/autoload/banana.vim +++ b/vim9/autoload/banana.vim @@ -11,26 +11,18 @@ endif g:autoloaded_Banana = 1 export def Enc() - if line("'<") > 0 - call ReplSel(Dec2Ban(GetSel())) - else - call EncLine() - endif + call ReplSel(Dec2Ban(GetSel())) enddef -def EncLine() +export def EncLine() call setline('.', substitute(getline('.'), '\d\d*', '\=toupper(Doban(submatch(0)))', 'g')) enddef export def Dec() - if line("'<") > 0 - call ReplSel(Ban2Dec(GetSel())) - else - call DecLine() - endif + call ReplSel(Ban2Dec(GetSel())) enddef -def DecLine() +export def DecLine() call setline('.', substitute(getline('.'), '\C\u\u*', '\=Unban(tolower(submatch(0)))', 'g')) 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_lst = split(new_str, '\n') call setline(lstart, new_str_lst) - delmarks < > + setcursorcharpos(lstart, cstart) enddef def Dec2Ban(text: string): string diff --git a/vim9/plugin/banana.vim b/vim9/plugin/banana.vim index ff8d340..8d470f7 100644 --- a/vim9/plugin/banana.vim +++ b/vim9/plugin/banana.vim @@ -21,9 +21,13 @@ endif import autoload 'banana.vim' -noremap