mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-25 16:58:06 +08:00
add m.Grow
This commit is contained in:
parent
be8170efe1
commit
e4cb179b40
10
Makefile
10
Makefile
@ -17,6 +17,16 @@ prepare:
|
|||||||
@go get github.com/skip2/go-qrcode
|
@go get github.com/skip2/go-qrcode
|
||||||
@go get gopkg.in/gomail.v2
|
@go get gopkg.in/gomail.v2
|
||||||
|
|
||||||
|
gotags:
|
||||||
|
gotags -f golang.tags -R $(GOROOT)/src
|
||||||
|
tags:
|
||||||
|
gotags -f ctx.tags -R src
|
||||||
|
tool:
|
||||||
|
go get github.com/nsf/gocode
|
||||||
|
go get github.com/jstemmer/gotags
|
||||||
|
go get github.com/bradfitz/goimports
|
||||||
|
go get github.com/Go-zh/tools/cmd/gopls
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
GOPATH=$(PWD):$(GOPATH) GOOS=linux $(BUILD)$(TARGET).linux.$(shell go env GOARCH) $(BENCH)
|
GOPATH=$(PWD):$(GOPATH) GOOS=linux $(BUILD)$(TARGET).linux.$(shell go env GOARCH) $(BENCH)
|
||||||
linux_arm:
|
linux_arm:
|
||||||
|
@ -4,21 +4,33 @@ let ctx_head = "Content-Type: application/json"
|
|||||||
let ctx_sid = ""
|
let ctx_sid = ""
|
||||||
|
|
||||||
fun! ShyPost(arg)
|
fun! ShyPost(arg)
|
||||||
|
let a:arg["buf"] = bufname("%")
|
||||||
let a:arg["pwd"] = getcwd()
|
let a:arg["pwd"] = getcwd()
|
||||||
let a:arg["sid"] = g:ctx_sid
|
let a:arg["sid"] = g:ctx_sid
|
||||||
return system("curl -s '" . g:ctx_url . "' -H '" . g:ctx_head . "' -d '" . json_encode(a:arg) . "' 2>/dev/null")
|
for k in keys(a:arg)
|
||||||
|
let a:arg[k] = substitute(a:arg[k], "'", "XXXXXsingleXXXXX", "g")
|
||||||
|
endfor
|
||||||
|
|
||||||
|
let data = json_encode(a:arg)
|
||||||
|
return system("curl -s '" . g:ctx_url . "' -H '" . g:ctx_head . "' -d '" . data . "' 2>/dev/null")
|
||||||
|
endfun
|
||||||
|
|
||||||
|
fun! ShySync(target)
|
||||||
|
if bufname("%") == "ControlP"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if a:target == "exec"
|
||||||
|
call ShyPost({"cmd": "exec", "arg": getcmdline()})
|
||||||
|
elseif a:target == "insert"
|
||||||
|
call ShyPost({"cmd": "insert", "arg": getreg("."), "row": line("."), "col": col(".")})
|
||||||
|
else
|
||||||
|
let cmd = {"marks": "marks", "tags": "tags", "fixs": "clist", "bufs": "buffers", "regs": "registers"}
|
||||||
|
call ShyPost({"cmd": "sync", "arg": a:target, "sub": execute(cmd[a:target])})
|
||||||
|
endif
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
fun! Shy(action, target)
|
fun! Shy(action, target)
|
||||||
if g:ctx_sid == ""
|
|
||||||
call ShyLogin()
|
|
||||||
endif
|
|
||||||
let arg = {"arg": a:target, "cmd": a:action}
|
let arg = {"arg": a:target, "cmd": a:action}
|
||||||
if a:action == "sync"
|
|
||||||
let cmd = {"tags": "tags", "fixs": "clist", "bufs": "buffers", "regs": "registers", "marks": "marks"}
|
|
||||||
let arg[a:target] = execute(cmd[a:target])
|
|
||||||
endif
|
|
||||||
|
|
||||||
let cmd = ShyPost(arg)
|
let cmd = ShyPost(arg)
|
||||||
if cmd != ""
|
if cmd != ""
|
||||||
let arg["res"] = execute(cmd)
|
let arg["res"] = execute(cmd)
|
||||||
@ -26,6 +38,26 @@ fun! Shy(action, target)
|
|||||||
endif
|
endif
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
|
fun! ShyCheck(target)
|
||||||
|
if a:target == "exec"
|
||||||
|
let cmd = getcmdline()
|
||||||
|
if cmd != ""
|
||||||
|
call ShySync("exec")
|
||||||
|
if getcmdline() == "w"
|
||||||
|
call ShySync("tags")
|
||||||
|
call ShySync("regs")
|
||||||
|
call ShySync("marks")
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
elseif a:target == "fixs"
|
||||||
|
if len(getqflist()) > 1
|
||||||
|
copen
|
||||||
|
call ShySync("fixs")
|
||||||
|
else
|
||||||
|
cclose
|
||||||
|
end
|
||||||
|
end
|
||||||
|
endfun
|
||||||
fun! ShyLogout()
|
fun! ShyLogout()
|
||||||
call Shy("logout", "")
|
call Shy("logout", "")
|
||||||
endfun
|
endfun
|
||||||
@ -33,23 +65,41 @@ fun! ShyLogin()
|
|||||||
let arg = {"cmd": "login", "pid": getpid(), "pane": $TMUX_PANE, "hostname": hostname(), "username": $USER}
|
let arg = {"cmd": "login", "pid": getpid(), "pane": $TMUX_PANE, "hostname": hostname(), "username": $USER}
|
||||||
let g:ctx_sid = ShyPost(arg)
|
let g:ctx_sid = ShyPost(arg)
|
||||||
endfun
|
endfun
|
||||||
autocmd VimEnter * call ShyLogin()
|
|
||||||
|
call ShyLogin()
|
||||||
autocmd VimLeave * call ShyLogout()
|
autocmd VimLeave * call ShyLogout()
|
||||||
|
autocmd InsertLeave * call ShySync("insert")
|
||||||
|
autocmd CmdlineLeave * call ShyCheck("exec")
|
||||||
|
autocmd QuickFixCmdPost * call ShyCheck("fixs")
|
||||||
|
|
||||||
autocmd BufReadPost * call Shy("read", expand("<afile>"))
|
autocmd BufReadPost * call Shy("read", expand("<afile>")) | call ShySync("bufs")
|
||||||
autocmd BufWritePre * call Shy("write", expand("<afile>"))
|
autocmd BufWritePre * call Shy("write", expand("<afile>"))
|
||||||
autocmd BufUnload * call Shy("close", expand("<afile>"))
|
" autocmd BufUnload * call Shy("close", expand("<afile>")) | call ShySync("bufs")
|
||||||
|
" autocmd CmdlineLeave *
|
||||||
|
call ShySync("tags")
|
||||||
|
|
||||||
autocmd BufWritePost * call Shy("sync", "tags")
|
|
||||||
autocmd BufWritePost * call Shy("sync", "fixs")
|
|
||||||
autocmd BufWritePost * call Shy("sync", "bufs")
|
|
||||||
autocmd BufWritePost * call Shy("sync", "regs")
|
|
||||||
|
|
||||||
|
" autocmd CompleteDone * call Shy("sync", "regs")
|
||||||
|
" autocmd InsertEnter * call Shy("sync", "regs")
|
||||||
|
" autocmd CmdlineEnter * call Shy("sync", "regs")
|
||||||
" autocmd BufWinEnter * call Shy("enter", expand("<afile>"))
|
" autocmd BufWinEnter * call Shy("enter", expand("<afile>"))
|
||||||
" autocmd WinEnter * call Shy("enter", expand("<afile>"))
|
" autocmd WinEnter * call Shy("enter", expand("<afile>"))
|
||||||
" autocmd WinLeave * call Shy("leave", expand("<afile>"))
|
" autocmd WinLeave * call Shy("leave", expand("<afile>"))
|
||||||
"
|
|
||||||
" autocmd InsertEnter * call Shy("line", getcurpos()[1])
|
|
||||||
" autocmd CursorMoved * call Shy("line", getcurpos()[1])
|
" autocmd CursorMoved * call Shy("line", getcurpos()[1])
|
||||||
|
|
||||||
" autocmd InsertCharPre * call Shy("char", v:char)
|
" autocmd InsertCharPre * call Shy("char", v:char)
|
||||||
|
"
|
||||||
|
" let g:colorscheme=1
|
||||||
|
" let g:colorlist = [ "ron", "torte", "darkblue", "peachpuff" ]
|
||||||
|
" function! ColorNext()
|
||||||
|
" if g:colorscheme >= len(g:colorlist)
|
||||||
|
" let g:colorscheme = 0
|
||||||
|
" endif
|
||||||
|
" let g:scheme = g:colorlist[g:colorscheme]
|
||||||
|
" exec "colorscheme " . g:scheme
|
||||||
|
" let g:colorscheme = g:colorscheme+1
|
||||||
|
" endfunction
|
||||||
|
" call ColorNext()
|
||||||
|
" command! NN call ColorNext()<CR>
|
||||||
|
" command! RR wa | source ~/.vimrc |e
|
||||||
|
" command! SS mksession! etc/session.vim
|
||||||
|
|
||||||
|
191
etc/conf/vimrc
191
etc/conf/vimrc
@ -7,143 +7,103 @@
|
|||||||
"}}}
|
"}}}
|
||||||
"加载插件"{{{
|
"加载插件"{{{
|
||||||
call plug#begin()
|
call plug#begin()
|
||||||
Plug 'vim-scripts/tComment'
|
" Plug 'vim-scripts/matrix.vim--Yang'
|
||||||
Plug 'tpope/vim-fugitive'
|
|
||||||
Plug 'airblade/vim-gitgutter'
|
|
||||||
Plug 'vim-airline/vim-airline'
|
Plug 'vim-airline/vim-airline'
|
||||||
Plug 'vim-airline/vim-airline-themes'
|
Plug 'airblade/vim-gitgutter'
|
||||||
Plug 'ntpeters/vim-better-whitespace'
|
|
||||||
Plug 'easymotion/vim-easymotion'
|
|
||||||
|
|
||||||
Plug 'gcmt/taboo.vim'
|
|
||||||
set sessionoptions+=tabpages,globals
|
|
||||||
|
|
||||||
" Plug 'vim-scripts/taglist.vim'
|
|
||||||
let g:Tlist_WinWidth=45
|
|
||||||
let g:Tlist_Exit_OnlyWindow=1
|
|
||||||
let g:Tlist_Enable_Fold_Column=0
|
|
||||||
nnoremap <F2> :TlistToggle<CR>
|
|
||||||
|
|
||||||
Plug 'scrooloose/nerdtree'
|
Plug 'scrooloose/nerdtree'
|
||||||
let g:NERDTreeWinPos="right"
|
let g:NERDTreeWinPos="right"
|
||||||
nnoremap <F4> :NERDTreeToggle<CR>
|
Plug 'mbbill/echofunc'
|
||||||
|
|
||||||
Plug 'kien/ctrlp.vim'
|
Plug 'kien/ctrlp.vim'
|
||||||
let g:ctrlp_cmd='CtrlPBuffer'
|
let g:ctrlp_cmd='CtrlPBuffer'
|
||||||
|
Plug 'vim-scripts/tComment'
|
||||||
Plug 'rking/ag.vim'
|
Plug 'tpope/vim-fugitive'
|
||||||
nnoremap <C-G> :Ag <C-R>=expand("<cword>")<CR><CR>
|
Plug 'gcmt/taboo.vim'
|
||||||
|
|
||||||
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
|
||||||
nnoremap <C-N> :FZF -q <C-R>=expand("<cword>")<CR><CR>
|
|
||||||
|
|
||||||
Plug 'benmills/vimux'
|
|
||||||
let mapleader=";"
|
|
||||||
nnoremap <Leader>; :VimuxPromptCommand<CR>
|
|
||||||
" nnoremap <Leader>j :VimuxZoomRunner<CR>
|
|
||||||
" nnoremap <Leader>l :VimuxRunLastCommand<CR>
|
|
||||||
" nnoremap <Leader>vx :VimuxInterruptRunner<CR>
|
|
||||||
|
|
||||||
Plug 'fatih/vim-go'
|
Plug 'fatih/vim-go'
|
||||||
|
Plug 'fatih/vim-go'
|
||||||
|
let g:go_version_warning=0
|
||||||
Plug 'chr4/nginx.vim'
|
Plug 'chr4/nginx.vim'
|
||||||
Plug 'othree/html5.vim'
|
Plug 'othree/html5.vim'
|
||||||
Plug 'godlygeek/tabular'
|
|
||||||
Plug 'plasticboy/vim-markdown'
|
Plug 'plasticboy/vim-markdown'
|
||||||
Plug 'vim-scripts/python.vim'
|
|
||||||
|
|
||||||
Plug 'mbbill/echofunc'
|
" Plug 'vim-airline/vim-airline-themes'
|
||||||
Plug 'vim-syntastic/syntastic'
|
" Plug 'ntpeters/vim-better-whitespace'
|
||||||
let g:syntastic_quiet_messages = { "regex": [
|
" Plug 'easymotion/vim-easymotion'
|
||||||
\ "Missing module docstring",
|
"
|
||||||
\ "Missing class docstring",
|
" set sessionoptions+=tabpages,globals
|
||||||
\ "Missing method docstring",
|
"
|
||||||
\ "Missing function docstring",
|
" let g:Tlist_WinWidth=45
|
||||||
\ "Invalid class name",
|
" let g:Tlist_Exit_OnlyWindow=1
|
||||||
\ "Invalid method name",
|
" let g:Tlist_Enable_Fold_Column=0
|
||||||
\ "Invalid function name",
|
" nnoremap <F2> :TlistToggle<CR>
|
||||||
\ "Invalid constant name",
|
"
|
||||||
\ "Invalid variable name",
|
" Plug 'rking/ag.vim'
|
||||||
\ "Method could be a function",
|
" nnoremap <C-G> :Ag <C-R>=expand("<cword>")<CR><CR>
|
||||||
\ "Too many instance attributes",
|
"
|
||||||
\ "Wrong continued indentation",
|
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
||||||
\ "Too many lines in module",
|
" nnoremap <C-N> :FZF -q <C-R>=expand("<cword>")<CR><CR>
|
||||||
\ "Too many arguments",
|
"
|
||||||
\ "Too many local variables",
|
" Plug 'godlygeek/tabular'
|
||||||
\ "Too many branches",
|
" Plug 'vim-scripts/python.vim'
|
||||||
\ "Too many statements",
|
"
|
||||||
\ "Too many return statements",
|
" Plug 'vim-syntastic/syntastic'
|
||||||
\ "Line Too Long",
|
" Plug 'Valloric/YouCompleteMe'
|
||||||
\ "defined outside __init__",
|
" let g:ycm_confirm_extra_conf=1
|
||||||
\ "Catching too general exception Exception",
|
" let g:syntastic_enable_signs=1
|
||||||
\ ] }
|
" let g:ycm_python_binary_path='/usr/bin/python'
|
||||||
|
" nnoremap gd :YcmCompleter GoToDeclaration<CR>
|
||||||
Plug 'Valloric/YouCompleteMe'
|
" nnoremap gD :YcmCompleter GoToReferences<CR>
|
||||||
let g:ycm_confirm_extra_conf=1
|
"
|
||||||
let g:syntastic_enable_signs=1
|
|
||||||
let g:ycm_python_binary_path='/usr/bin/python'
|
|
||||||
nnoremap gd :YcmCompleter GoToDeclaration<CR>
|
|
||||||
nnoremap gD :YcmCompleter GoToReferences<CR>
|
|
||||||
|
|
||||||
Plug 'vim-scripts/matrix.vim--Yang'
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
"}}}
|
"}}}
|
||||||
" 基本配置"{{{
|
" 基本配置"{{{
|
||||||
|
set cc=80
|
||||||
|
set nowrap
|
||||||
set number
|
set number
|
||||||
set relativenumber
|
set relativenumber
|
||||||
set cursorline
|
set cursorline
|
||||||
set cursorcolumn
|
set cursorcolumn
|
||||||
set ruler
|
|
||||||
set showcmd
|
|
||||||
set showmode
|
|
||||||
set cc=80
|
|
||||||
set nowrap
|
|
||||||
set scrolloff=3
|
set scrolloff=3
|
||||||
|
|
||||||
set tabstop=4
|
set t_Co=256
|
||||||
set shiftwidth=4
|
set mouse=a
|
||||||
set cindent
|
|
||||||
set expandtab
|
|
||||||
set backspace=indent,eol,start
|
|
||||||
|
|
||||||
set showmatch
|
" 缓存
|
||||||
set matchtime=2
|
set hidden
|
||||||
set foldenable
|
set autowrite
|
||||||
set foldmethod=marker
|
set encoding=utf-8
|
||||||
|
|
||||||
|
" 搜索
|
||||||
set hlsearch
|
set hlsearch
|
||||||
set incsearch
|
set incsearch
|
||||||
set nowrapscan
|
set nowrapscan
|
||||||
set smartcase
|
set smartcase
|
||||||
set ignorecase
|
set ignorecase
|
||||||
|
|
||||||
set hidden
|
set showmatch
|
||||||
set autowrite
|
set matchtime=2
|
||||||
set encoding=utf-8
|
|
||||||
set mouse=a
|
|
||||||
|
|
||||||
" colorscheme darkblue
|
" 缩进
|
||||||
" colorscheme default
|
set cindent
|
||||||
set t_Co=256
|
set expandtab
|
||||||
|
set tabstop=4
|
||||||
|
set shiftwidth=4
|
||||||
|
set backspace=indent,eol,start
|
||||||
|
|
||||||
|
" 折叠
|
||||||
|
set foldenable
|
||||||
|
set foldmethod=marker
|
||||||
"}}}
|
"}}}
|
||||||
"快捷键映射"{{{
|
"快捷键映射"{{{
|
||||||
nnoremap <C-H> <C-W>h
|
nnoremap <C-H> <C-W>h
|
||||||
nnoremap <C-J> <C-W>j
|
nnoremap <C-J> <C-W>j
|
||||||
nnoremap <C-K> <C-W>k
|
nnoremap <C-K> <C-W>k
|
||||||
nnoremap <C-L> <C-W>l
|
nnoremap <C-L> <C-W>l
|
||||||
" nnoremap <C-M> :make<CR>
|
|
||||||
nnoremap <Space> :
|
nnoremap <Space> :
|
||||||
|
|
||||||
nnoremap j gj
|
|
||||||
nnoremap k gk
|
|
||||||
|
|
||||||
" nnoremap <C-M> :make<CR>
|
|
||||||
" inoremap <C-M> <ESC>:make<CR>i
|
|
||||||
|
|
||||||
nnoremap df :FZF<CR>
|
|
||||||
inoremap df _
|
|
||||||
inoremap jk <Esc>
|
|
||||||
cnoremap jk <CR>
|
cnoremap jk <CR>
|
||||||
cnoremap wa wa<CR>
|
cnoremap wa wa<CR>
|
||||||
|
inoremap jk <Esc>
|
||||||
"}}}
|
"}}}
|
||||||
" 编程配置{{{
|
" 编程配置{{{
|
||||||
set keywordprg=man\ -a
|
set keywordprg=man\ -a
|
||||||
@ -155,6 +115,8 @@ function! Config(type)
|
|||||||
if a:type == "go"
|
if a:type == "go"
|
||||||
set foldmethod=syntax
|
set foldmethod=syntax
|
||||||
set foldnestmax=3
|
set foldnestmax=3
|
||||||
|
set tags+=ctx.tags,golang.tags
|
||||||
|
" autocmd BufWritePost *.go !goimports -w <afile>
|
||||||
elseif a:type == "shy"
|
elseif a:type == "shy"
|
||||||
set filetype=shy
|
set filetype=shy
|
||||||
set commentstring=#%s
|
set commentstring=#%s
|
||||||
@ -178,8 +140,6 @@ function! Config(type)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
autocmd BufReadPost * normal `"
|
|
||||||
|
|
||||||
autocmd BufNewFile,BufReadPost *.go call Config("go")
|
autocmd BufNewFile,BufReadPost *.go call Config("go")
|
||||||
autocmd BufNewFile,BufReadPost *.shy call Config("shy")
|
autocmd BufNewFile,BufReadPost *.shy call Config("shy")
|
||||||
autocmd BufNewFile,BufReadPost *.tmpl call Config("tmpl")
|
autocmd BufNewFile,BufReadPost *.tmpl call Config("tmpl")
|
||||||
@ -191,36 +151,17 @@ autocmd BufNewFile,BufReadPost *.wxss call Config("css")
|
|||||||
autocmd BufNewFile,BufReadPost *.txt call Config("txt")
|
autocmd BufNewFile,BufReadPost *.txt call Config("txt")
|
||||||
autocmd BufNewFile,BufReadPost *.js call Config("js")
|
autocmd BufNewFile,BufReadPost *.js call Config("js")
|
||||||
|
|
||||||
command! RR wa | source ~/.vimrc |e
|
autocmd BufReadPost * normal `"
|
||||||
command! SS mksession! etc/session.vim
|
|
||||||
|
source ~/context/etc/conf/auto.vim
|
||||||
|
|
||||||
if filereadable("~/.vim_local")
|
if filereadable("~/.vim_local")
|
||||||
source ~/.vim_local
|
source ~/.vim_local
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let g:colorscheme=1
|
cnoremap RR :source ~/.vimrc<CR>
|
||||||
let g:colorlist = [ "ron", "torte", "darkblue", "peachpuff" ]
|
nnoremap <C-G> :copen<CR> :grep -rn
|
||||||
function! ColorNext()
|
|
||||||
if g:colorscheme >= len(g:colorlist)
|
|
||||||
let g:colorscheme = 0
|
|
||||||
endif
|
|
||||||
let g:scheme = g:colorlist[g:colorscheme]
|
|
||||||
exec "colorscheme " . g:scheme
|
|
||||||
let g:colorscheme = g:colorscheme+1
|
|
||||||
endfunction
|
|
||||||
call ColorNext()
|
|
||||||
command! NN call ColorNext()<CR>
|
|
||||||
|
|
||||||
function! BenchCode(cmd, arg)
|
|
||||||
let l:line = "web.code." . a:cmd . " " . join(a:arg, " ")
|
|
||||||
exe "silent !bench " l:line
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
colorscheme torte
|
||||||
highlight Comment cterm=reverse ctermfg=yellow
|
highlight Comment cterm=reverse ctermfg=yellow
|
||||||
|
|
||||||
source ~/context/etc/conf/auto.vim
|
|
||||||
|
|
||||||
|
|
||||||
" autocmd BufReadPost * call BenchCode("counter", ["nopen", 1])
|
|
||||||
" autocmd BufWritePost * call BenchCode("counter", ["nsave", 1])
|
|
||||||
"}}}
|
"}}}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package ctx
|
package ctx
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/csv"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"sort"
|
|
||||||
"toolkit"
|
"toolkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -503,3 +503,78 @@ func (m *Message) ToHTML(style string) string {
|
|||||||
}
|
}
|
||||||
return strings.Join(result, "")
|
return strings.Join(result, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Message) Grow(key string, args interface{}, data interface{}) interface{} {
|
||||||
|
cache := m.Confm(key, args)
|
||||||
|
if cache == nil {
|
||||||
|
cache = map[string]interface{}{}
|
||||||
|
}
|
||||||
|
meta, ok := cache["meta"].(map[string]interface{})
|
||||||
|
if !ok {
|
||||||
|
meta = map[string]interface{}{}
|
||||||
|
}
|
||||||
|
list, _ := cache["list"].([]interface{})
|
||||||
|
|
||||||
|
list = append(list, data)
|
||||||
|
if len(list) > kit.Int(kit.Select(m.Conf("cache", "limit"), meta["limit"])) {
|
||||||
|
offset := kit.Int(meta["offset"])
|
||||||
|
least := kit.Int(kit.Select(m.Conf("cache", "least"), meta["least"]))
|
||||||
|
|
||||||
|
name := kit.Select(m.Option("cache.store"), meta["store"])
|
||||||
|
f, e := os.OpenFile(name, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)
|
||||||
|
m.Assert(e)
|
||||||
|
defer f.Close()
|
||||||
|
s, e := f.Stat()
|
||||||
|
m.Assert(e)
|
||||||
|
|
||||||
|
keys := []string{}
|
||||||
|
w := csv.NewWriter(f)
|
||||||
|
if s.Size() == 0 {
|
||||||
|
for k := range list[0].(map[string]interface{}) {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
w.Write(keys)
|
||||||
|
w.Flush()
|
||||||
|
s, e = f.Stat()
|
||||||
|
} else {
|
||||||
|
r := csv.NewReader(f)
|
||||||
|
keys, e = r.Read()
|
||||||
|
}
|
||||||
|
|
||||||
|
record, _ := meta["record"].([]interface{})
|
||||||
|
meta["record"] = append(record, map[string]interface{}{
|
||||||
|
"time": m.Time(),
|
||||||
|
"offset": offset,
|
||||||
|
"position": s.Size(),
|
||||||
|
})
|
||||||
|
|
||||||
|
end := len(list) - least
|
||||||
|
for i, v := range list {
|
||||||
|
if i >= end {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
val := v.(map[string]interface{})
|
||||||
|
|
||||||
|
values := []string{}
|
||||||
|
for _, k := range keys {
|
||||||
|
values = append(values, kit.Format(val[k]))
|
||||||
|
}
|
||||||
|
w.Write(values)
|
||||||
|
|
||||||
|
if i < least {
|
||||||
|
list[i] = list[end+i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Log("info", "save %s offset %v+%v", name, offset, end)
|
||||||
|
meta["offset"] = offset + end
|
||||||
|
list = list[:least]
|
||||||
|
w.Flush()
|
||||||
|
}
|
||||||
|
cache["meta"] = meta
|
||||||
|
cache["list"] = list
|
||||||
|
m.Conf(key, args, cache)
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
@ -329,7 +329,6 @@ func (m *Message) Sort(key string, arg ...string) *Message {
|
|||||||
}
|
}
|
||||||
func (m *Message) Split(str string, arg ...string) *Message {
|
func (m *Message) Split(str string, arg ...string) *Message {
|
||||||
c := byte(kit.Select(" ", arg, 0)[0])
|
c := byte(kit.Select(" ", arg, 0)[0])
|
||||||
|
|
||||||
lines := strings.Split(str, "\n")
|
lines := strings.Split(str, "\n")
|
||||||
|
|
||||||
pos := []int{}
|
pos := []int{}
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package nfs
|
package nfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"contexts/ctx"
|
|
||||||
"toolkit"
|
|
||||||
|
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"contexts/ctx"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
@ -21,6 +19,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"toolkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NFS struct {
|
type NFS struct {
|
||||||
|
@ -3,6 +3,7 @@ package code
|
|||||||
import (
|
import (
|
||||||
"contexts/ctx"
|
"contexts/ctx"
|
||||||
"contexts/web"
|
"contexts/web"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@ -27,7 +28,7 @@ CMD sh bin/boot.sh
|
|||||||
var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
||||||
Caches: map[string]*ctx.Cache{},
|
Caches: map[string]*ctx.Cache{},
|
||||||
Configs: map[string]*ctx.Config{
|
Configs: map[string]*ctx.Config{
|
||||||
"login": &ctx.Config{Name: "login", Value: map[string]interface{}{"check": false, "local": true, "expire": "720h"}, Help: "用户登录"},
|
"login": {Name: "login", Value: map[string]interface{}{"check": false, "local": true, "expire": "720h"}, Help: "用户登录"},
|
||||||
"prefix": {Name: "prefix", Help: "外部命令", Value: map[string]interface{}{
|
"prefix": {Name: "prefix", Help: "外部命令", Value: map[string]interface{}{
|
||||||
"zsh": []interface{}{"cli.system", "zsh"},
|
"zsh": []interface{}{"cli.system", "zsh"},
|
||||||
"tmux": []interface{}{"cli.system", "tmux"},
|
"tmux": []interface{}{"cli.system", "tmux"},
|
||||||
@ -56,6 +57,11 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
"terminal": map[string]interface{}{},
|
"terminal": map[string]interface{}{},
|
||||||
"history": map[string]interface{}{},
|
"history": map[string]interface{}{},
|
||||||
}},
|
}},
|
||||||
|
"cache": {Name: "flow", Help: "记录", Value: map[string]interface{}{
|
||||||
|
"store": "hi.csv",
|
||||||
|
"limit": 6,
|
||||||
|
"least": 3,
|
||||||
|
}},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ctx.Command{
|
Commands: map[string]*ctx.Command{
|
||||||
"/zsh": {Name: "/zsh", Help: "终端", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"/zsh": {Name: "/zsh", Help: "终端", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
@ -82,9 +88,10 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
return
|
return
|
||||||
|
|
||||||
case "historys":
|
case "historys":
|
||||||
|
m.Option("cache.store", "hi.csv")
|
||||||
name := m.Option("sid")
|
name := m.Option("sid")
|
||||||
vs := strings.SplitN(strings.TrimSpace(m.Option("arg")), " ", 2)
|
vs := strings.SplitN(strings.TrimSpace(m.Option("arg")), " ", 2)
|
||||||
m.Conf("zsh", []string{"history", name, "-2"}, map[string]interface{}{
|
m.Grow("zsh", []string{"history", name}, map[string]interface{}{
|
||||||
"sid": name,
|
"sid": name,
|
||||||
"time": m.Time(),
|
"time": m.Time(),
|
||||||
"index": vs[0],
|
"index": vs[0],
|
||||||
@ -93,13 +100,14 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
})
|
})
|
||||||
|
|
||||||
case "history":
|
case "history":
|
||||||
|
m.Option("cache.store", "hi.csv")
|
||||||
switch path.Base(m.Option("SHELL")) {
|
switch path.Base(m.Option("SHELL")) {
|
||||||
case "zsh":
|
case "zsh":
|
||||||
m.Option("arg", strings.SplitN(m.Option("arg"), ";", 2)[1])
|
m.Option("arg", strings.SplitN(m.Option("arg"), ";", 2)[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
name := m.Option("sid")
|
name := m.Option("sid")
|
||||||
m.Conf("zsh", []string{"history", name, "-2"}, map[string]interface{}{
|
m.Grow("zsh", []string{"history", name}, map[string]interface{}{
|
||||||
"sid": name,
|
"sid": name,
|
||||||
"time": m.Time(),
|
"time": m.Time(),
|
||||||
"cmd": m.Option("arg"),
|
"cmd": m.Option("arg"),
|
||||||
@ -115,13 +123,25 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
Help: "终端", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
Help: "终端", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
p, arg := kit.Select(".", arg[0]), arg[1:]
|
p, arg := kit.Select(".", arg[0]), arg[1:]
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
|
case "prune":
|
||||||
|
ps := []string{}
|
||||||
|
m.Confm("zsh", []string{"terminal"}, func(key string, value map[string]interface{}) {
|
||||||
|
if kit.Format(value["status"]) == "logout" {
|
||||||
|
ps = append(ps, key)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
for _, v := range ps {
|
||||||
|
m.Log("info", "prune zsh %v %v", v, kit.Formats(m.Conf("zsh", []string{"terminal", v})))
|
||||||
|
m.Confv("zsh", []string{"terminal", v}, "")
|
||||||
|
}
|
||||||
|
fallthrough
|
||||||
case "terminal":
|
case "terminal":
|
||||||
m.Confm("zsh", "terminal", func(key string, value map[string]interface{}) {
|
m.Confm("zsh", "terminal", func(key string, value map[string]interface{}) {
|
||||||
m.Push([]string{"time", "sid", "status", "pwd", "pid", "pane", "hostname", "username"}, value)
|
m.Push([]string{"time", "sid", "status", "pwd", "pid", "pane", "hostname", "username"}, value)
|
||||||
})
|
})
|
||||||
m.Sort("time", "time_r").Table()
|
m.Sort("time", "time_r").Table()
|
||||||
case "history":
|
case "history":
|
||||||
m.Confm("zsh", "history", func(key string, index int, value map[string]interface{}) {
|
m.Confm("zsh", "history", func(key string, meta map[string]interface{}, index int, value map[string]interface{}) {
|
||||||
if len(arg) > 1 && !strings.HasPrefix(key, arg[1]) {
|
if len(arg) > 1 && !strings.HasPrefix(key, arg[1]) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -135,17 +155,6 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
} else {
|
} else {
|
||||||
m.Sort("time", "time_r").Table()
|
m.Sort("time", "time_r").Table()
|
||||||
}
|
}
|
||||||
case "prune":
|
|
||||||
ps := []string{}
|
|
||||||
m.Confm("zsh", []string{"terminal"}, func(key string, value map[string]interface{}) {
|
|
||||||
if kit.Format(value["status"]) == "logout" {
|
|
||||||
ps = append(ps, key)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
for _, v := range ps {
|
|
||||||
m.Log("info", "prune zsh %v %v", v, kit.Formats(m.Conf("zsh", []string{"terminal", v})))
|
|
||||||
m.Confv("zsh", []string{"terminal", v}, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
case "init":
|
case "init":
|
||||||
m.Cmd("cli.system", m.Confv("package", "upadte"))
|
m.Cmd("cli.system", m.Confv("package", "upadte"))
|
||||||
@ -439,7 +448,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"git": {Name: "git init|diff|status|commit|branch|pull|push|sum", Help: "版本", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"git": {Name: "git init|diff|status|commit|branch|remote|pull|push|sum", Help: "版本", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
prefix, arg := append(kit.Trans(m.Confv("prefix", "git")), "cmd_dir", kit.Select(".", arg[0])), arg[1:]
|
prefix, arg := append(kit.Trans(m.Confv("prefix", "git")), "cmd_dir", kit.Select(".", arg[0])), arg[1:]
|
||||||
|
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
@ -474,7 +483,6 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
}
|
}
|
||||||
for _, v := range strings.Split(m.Cmdx(prefix, "branch", "-v"), "\n") {
|
for _, v := range strings.Split(m.Cmdx(prefix, "branch", "-v"), "\n") {
|
||||||
if len(v) > 0 {
|
if len(v) > 0 {
|
||||||
m.Log("fuck", "waht %v --", v)
|
|
||||||
m.Push("tags", v[:2])
|
m.Push("tags", v[:2])
|
||||||
vs := strings.SplitN(strings.TrimSpace(v[2:]), " ", 2)
|
vs := strings.SplitN(strings.TrimSpace(v[2:]), " ", 2)
|
||||||
m.Push("branch", vs[0])
|
m.Push("branch", vs[0])
|
||||||
@ -484,6 +492,9 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Table()
|
m.Table()
|
||||||
|
case "remote":
|
||||||
|
m.Cmdy(prefix, "remote", "-v", "cmd_parse", "cut", " ", "3", "remote url tag")
|
||||||
|
|
||||||
case "push":
|
case "push":
|
||||||
m.Cmdy(prefix, "push")
|
m.Cmdy(prefix, "push")
|
||||||
case "sum":
|
case "sum":
|
||||||
@ -563,8 +574,21 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
|
"tags": {Name: "tags", Help: "代码索引", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
m.Cmdy("cli.system", "gotags", "-f", kit.Select("tags", arg, 1), "-R", kit.Select("src", arg, 0))
|
||||||
|
return
|
||||||
|
}},
|
||||||
"vim": {Name: "vim", Help: "编辑器", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"vim": {Name: "vim", Help: "编辑器", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
|
case "ctag":
|
||||||
|
if f, p, e := kit.Create("etc/conf/tags"); m.Assert(e) {
|
||||||
|
defer f.Close()
|
||||||
|
for k, _ := range c.Commands {
|
||||||
|
fmt.Fprintf(f, "%s\t%s\t/\"%s\": {Name/\n", k, "../../src/examples/code/code.go", k)
|
||||||
|
}
|
||||||
|
m.Echo(p)
|
||||||
|
}
|
||||||
|
|
||||||
case "editor":
|
case "editor":
|
||||||
m.Confm("vim", "editor", func(key string, value map[string]interface{}) {
|
m.Confm("vim", "editor", func(key string, value map[string]interface{}) {
|
||||||
m.Push([]string{"time", "sid", "status", "pwd", "pid", "pane", "hostname", "username"}, value)
|
m.Push([]string{"time", "sid", "status", "pwd", "pid", "pane", "hostname", "username"}, value)
|
||||||
@ -584,12 +608,24 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
for _, v := range ps {
|
for _, v := range ps {
|
||||||
for _, k := range []string{"editor", "tag", "fix", "buffer", "register"} {
|
for _, k := range []string{"editor", "exec", "tag", "fix", "buffer", "register"} {
|
||||||
m.Log("info", "prune vim %v %v %v", k, v, kit.Formats(m.Conf("vim", []string{k, v})))
|
m.Log("info", "prune vim %v %v %v", k, v, kit.Formats(m.Conf("vim", []string{k, v})))
|
||||||
m.Confv("vim", []string{k, v}, "")
|
m.Confv("vim", []string{k, v}, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "cmds":
|
||||||
|
m.Confm("vim", "exec", func(meta map[string]interface{}, index int, value map[string]interface{}) {
|
||||||
|
value["sid"] = kit.Format(value["sid"])[:6]
|
||||||
|
m.Push([]string{"time", "sid", "cmd", "file", "pwd"}, value)
|
||||||
|
})
|
||||||
|
m.Sort("time", "time_r").Table()
|
||||||
|
case "txts":
|
||||||
|
m.Confm("vim", "insert", func(meta map[string]interface{}, index int, value map[string]interface{}) {
|
||||||
|
value["sid"] = kit.Format(value["sid"])[:6]
|
||||||
|
m.Push([]string{"time", "sid", "text", "line", "col", "file", "pwd"}, value)
|
||||||
|
})
|
||||||
|
m.Sort("time", "time_r").Table()
|
||||||
case "tags":
|
case "tags":
|
||||||
m.Confm("vim", "tag", func(key string, index int, value map[string]interface{}) {
|
m.Confm("vim", "tag", func(key string, index int, value map[string]interface{}) {
|
||||||
m.Push("sid", key[:6]).Push([]string{"tag", "line", "file"}, value)
|
m.Push("sid", key[:6]).Push([]string{"tag", "line", "file"}, value)
|
||||||
@ -597,23 +633,30 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
m.Table()
|
m.Table()
|
||||||
case "fixs":
|
case "fixs":
|
||||||
m.Confm("vim", "fix", func(key string, index int, value map[string]interface{}) {
|
m.Confm("vim", "fix", func(key string, index int, value map[string]interface{}) {
|
||||||
m.Push("sid", key[:6]).Push([]string{"id", "file", "line", "text"}, value)
|
m.Push("sid", key[:6]).Push([]string{"fix", "file", "line", "text"}, value)
|
||||||
})
|
})
|
||||||
m.Table()
|
m.Table()
|
||||||
case "bufs":
|
case "bufs":
|
||||||
m.Confm("vim", "buffer", func(key string, index int, value map[string]interface{}) {
|
m.Confm("vim", "buffer", func(key string, index int, value map[string]interface{}) {
|
||||||
m.Push("sid", key[:6]).Push([]string{"id", "tag", "name", "line"}, value)
|
m.Push("sid", key[:6]).Push([]string{"buf", "tag", "file", "line"}, value)
|
||||||
})
|
})
|
||||||
m.Table()
|
m.Table()
|
||||||
case "regs":
|
case "regs":
|
||||||
m.Confm("vim", "register", func(key string, index int, value map[string]interface{}) {
|
m.Confm("vim", "register", func(key string, index int, value map[string]interface{}) {
|
||||||
m.Push("sid", key[:6]).Push([]string{"name", "text"}, value)
|
m.Push("sid", key[:6]).Push([]string{"reg", "text"}, value)
|
||||||
|
})
|
||||||
|
m.Table()
|
||||||
|
case "marks":
|
||||||
|
m.Confm("vim", "mark", func(key string, index int, value map[string]interface{}) {
|
||||||
|
m.Push("sid", key[:6]).Push([]string{"mark", "line", "col", "file"}, value)
|
||||||
})
|
})
|
||||||
m.Table()
|
m.Table()
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}},
|
}},
|
||||||
"/vim": {Name: "/vim", Help: "编辑器", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
"/vim": {Name: "/vim", Help: "编辑器", Hand: func(m *ctx.Message, c *ctx.Context, key string, arg ...string) (e error) {
|
||||||
|
m.Option("arg", strings.Replace(m.Option("arg"), "XXXXXsingleXXXXX", "'", -1))
|
||||||
|
m.Option("sub", strings.Replace(m.Option("sub"), "XXXXXsingleXXXXX", "'", -1))
|
||||||
if !m.Has("res") {
|
if !m.Has("res") {
|
||||||
switch m.Option("cmd") {
|
switch m.Option("cmd") {
|
||||||
case "login":
|
case "login":
|
||||||
@ -650,16 +693,36 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
m.Conf("vim", []string{"opens", name, "pwd"}, m.Option("pwd"))
|
m.Conf("vim", []string{"opens", name, "pwd"}, m.Option("pwd"))
|
||||||
m.Conf("vim", []string{"opens", name, "sid"}, m.Option("sid"))
|
m.Conf("vim", []string{"opens", name, "sid"}, m.Option("sid"))
|
||||||
return
|
return
|
||||||
|
case "insert":
|
||||||
|
m.Option("cache.store", "he.csv")
|
||||||
|
m.Grow("vim", "insert", map[string]interface{}{
|
||||||
|
"time": m.Time(),
|
||||||
|
"sid": m.Option("sid"),
|
||||||
|
"text": m.Option("arg"),
|
||||||
|
"line": m.Option("row"),
|
||||||
|
"col": m.Option("col"),
|
||||||
|
"file": m.Option("buf"),
|
||||||
|
"pwd": m.Option("pwd"),
|
||||||
|
})
|
||||||
|
case "exec":
|
||||||
|
m.Option("cache.store", "he.csv")
|
||||||
|
m.Grow("vim", "exec", map[string]interface{}{
|
||||||
|
"time": m.Time(),
|
||||||
|
"sid": m.Option("sid"),
|
||||||
|
"cmd": m.Option("arg"),
|
||||||
|
"file": m.Option("buf"),
|
||||||
|
"pwd": m.Option("pwd"),
|
||||||
|
})
|
||||||
case "sync":
|
case "sync":
|
||||||
switch m.Option("arg") {
|
switch m.Option("arg") {
|
||||||
case "fixs":
|
case "fixs":
|
||||||
if m.Conf("vim", []string{"fix", m.Option("sid")}, ""); strings.HasPrefix(m.Option("fixs"), "\nError") {
|
if m.Conf("vim", []string{"fix", m.Option("sid")}, ""); strings.HasPrefix(m.Option("sub"), "\nError") {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
m.Split(strings.TrimPrefix(m.Option("fixs"), "\n"), " ", "3", "id file text").Table(func(index int, value map[string]string) {
|
m.Split(strings.TrimPrefix(m.Option("sub"), "\n"), " ", "3", "id file text").Table(func(index int, value map[string]string) {
|
||||||
vs := strings.Split(kit.Format(value["file"]), ":")
|
vs := strings.Split(kit.Format(value["file"]), ":")
|
||||||
m.Conf("vim", []string{"fix", m.Option("sid"), "-2"}, map[string]interface{}{
|
m.Conf("vim", []string{"fix", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||||
"id": value["id"],
|
"fix": value["id"],
|
||||||
"file": vs[0],
|
"file": vs[0],
|
||||||
"line": vs[1],
|
"line": vs[1],
|
||||||
"text": value["text"],
|
"text": value["text"],
|
||||||
@ -668,7 +731,7 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
m.Set("append").Set("result")
|
m.Set("append").Set("result")
|
||||||
case "tags":
|
case "tags":
|
||||||
m.Conf("vim", []string{"tag", m.Option("sid")}, "")
|
m.Conf("vim", []string{"tag", m.Option("sid")}, "")
|
||||||
m.Split(strings.TrimPrefix(m.Option("tags"), "\n"), " ", "6").Table(func(index int, value map[string]string) {
|
m.Split(strings.TrimPrefix(m.Option("sub"), "\n"), " ", "6").Table(func(index int, value map[string]string) {
|
||||||
m.Conf("vim", []string{"tag", m.Option("sid"), "-2"}, map[string]interface{}{
|
m.Conf("vim", []string{"tag", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||||
"tag": value["tag"],
|
"tag": value["tag"],
|
||||||
"line": value["line"],
|
"line": value["line"],
|
||||||
@ -678,24 +741,34 @@ var Index = &ctx.Context{Name: "code", Help: "代码中心",
|
|||||||
m.Set("append").Set("result")
|
m.Set("append").Set("result")
|
||||||
case "bufs":
|
case "bufs":
|
||||||
m.Conf("vim", []string{"buffer", m.Option("sid")}, "")
|
m.Conf("vim", []string{"buffer", m.Option("sid")}, "")
|
||||||
m.Split(strings.TrimSpace(m.Option("bufs")), " ", "5", "id tag name some line").Table(func(index int, value map[string]string) {
|
m.Split(strings.TrimSpace(m.Option("sub")), " ", "5", "id tag name some line").Table(func(index int, value map[string]string) {
|
||||||
m.Conf("vim", []string{"buffer", m.Option("sid"), "-2"}, map[string]interface{}{
|
m.Conf("vim", []string{"buffer", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||||
"id": value["id"],
|
"buf": value["id"],
|
||||||
"tag": value["tag"],
|
"tag": value["tag"],
|
||||||
"name": value["name"],
|
"file": value["name"],
|
||||||
"line": value["line"],
|
"line": value["line"],
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
m.Set("append").Set("result")
|
m.Set("append").Set("result")
|
||||||
case "regs":
|
case "regs":
|
||||||
m.Conf("vim", []string{"register", m.Option("sid")}, "")
|
m.Conf("vim", []string{"register", m.Option("sid")}, "")
|
||||||
m.Split(strings.TrimPrefix(m.Option("regs"), "\n--- Registers ---\n"), " ", "2", "name text").Table(func(index int, value map[string]string) {
|
m.Split(strings.TrimPrefix(m.Option("sub"), "\n--- Registers ---\n"), " ", "2", "name text").Table(func(index int, value map[string]string) {
|
||||||
m.Conf("vim", []string{"register", m.Option("sid"), "-2"}, map[string]interface{}{
|
m.Conf("vim", []string{"register", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||||
"text": strings.Replace(strings.Replace(value["text"], "^I", "\t", -1), "^J", "\n", -1),
|
"text": strings.Replace(strings.Replace(value["text"], "^I", "\t", -1), "^J", "\n", -1),
|
||||||
"name": strings.TrimPrefix(value["name"], "\""),
|
"reg": strings.TrimPrefix(value["name"], "\""),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
m.Set("append").Set("result")
|
m.Set("append").Set("result")
|
||||||
|
case "marks":
|
||||||
|
m.Conf("vim", []string{"mark", m.Option("sid")}, "")
|
||||||
|
m.Split(strings.TrimPrefix(m.Option("sub"), "\n"), " ", "4").Table(func(index int, value map[string]string) {
|
||||||
|
m.Conf("vim", []string{"mark", m.Option("sid"), "-2"}, map[string]interface{}{
|
||||||
|
"mark": value["mark"],
|
||||||
|
"line": value["line"],
|
||||||
|
"col": value["col"],
|
||||||
|
"file": value["file/text"],
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
|
@ -1,13 +1,19 @@
|
|||||||
kit shell "命令行" private "ssh._route" _ "context" "find" "web.code" "zsh" \
|
kit dir "目录" private "ssh._route" _ "context" "find" "web.code" "zsh" \
|
||||||
text "" name pod imports plugin_pod \
|
text "" name pod imports plugin_pod \
|
||||||
text "" name dir imports plugin_path action auto \
|
text "" name dir imports plugin_path action auto \
|
||||||
select "terminal" name cmd values list values find values tail values grep values init values terminal values history \
|
select "" name cmd values list values find values tail values grep values init action auto \
|
||||||
exports path path \
|
exports path path \
|
||||||
text "" name txt \
|
text "" name txt \
|
||||||
feature display editor \
|
feature display editor \
|
||||||
button "搜索" action auto \
|
button "搜索" action auto \
|
||||||
button "返回" cb Last
|
button "返回" cb Last
|
||||||
|
|
||||||
|
kit cli "命令行" private "web.code.zsh" \
|
||||||
|
text "" name dir imports plugin_path action auto \
|
||||||
|
select "terminal" values terminal values history action auto \
|
||||||
|
feature detail "prune" "复制" "下载" \
|
||||||
|
button "查看" action auto
|
||||||
|
|
||||||
kit clip "粘贴板" private "web.code.tmux" "" "" "" "buffer" \
|
kit clip "粘贴板" private "web.code.tmux" "" "" "" "buffer" \
|
||||||
text "" name tag imports plugin_buffer action auto \
|
text "" name tag imports plugin_buffer action auto \
|
||||||
text "" name txt \
|
text "" name txt \
|
||||||
@ -57,12 +63,12 @@ kit container "容器" private "web.code.docker" "container" \
|
|||||||
kit git "记录" private "ssh._route" _ "web.code.git" \
|
kit git "记录" private "ssh._route" _ "web.code.git" \
|
||||||
text "" name pod imports plugin_pod \
|
text "" name pod imports plugin_pod \
|
||||||
text "" name dir imports plugin_path action auto \
|
text "" name dir imports plugin_path action auto \
|
||||||
select "status" name cmd values diff values status values commit values branch values pull values push values sum values init \
|
select "status" name cmd values diff values status values commit values branch values remote values pull values push values sum values init \
|
||||||
exports branch branch \
|
exports branch branch \
|
||||||
button "查看" action auto
|
button "查看" action auto
|
||||||
|
|
||||||
kit vim "编辑器" private "ssh._route" _ "web.code.vim" \
|
kit vim "编辑器" private "ssh._route" _ "web.code.vim" \
|
||||||
text "" name pod imports plugin_pod \
|
text "" name pod imports plugin_pod \
|
||||||
select "bufs" name cmd values editor values opens values tags values fixs values bufs values regs \
|
select "bufs" name cmd values editor values opens values cmds values txts values tags values fixs values bufs values regs values marks \
|
||||||
button "查看" action auto
|
button "查看" action auto
|
||||||
|
|
||||||
|
@ -317,6 +317,15 @@ func Map(v interface{}, random string, args ...interface{}) map[string]interface
|
|||||||
fun(i, val)
|
fun(i, val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case func(map[string]interface{}, int, map[string]interface{}):
|
||||||
|
meta := value["meta"].(map[string]interface{})
|
||||||
|
list := value["list"].([]interface{})
|
||||||
|
|
||||||
|
for i := 0; i < len(list); i++ {
|
||||||
|
if val, ok := list[i].(map[string]interface{}); ok {
|
||||||
|
fun(meta, i, val)
|
||||||
|
}
|
||||||
|
}
|
||||||
case func(string, []interface{}):
|
case func(string, []interface{}):
|
||||||
for k, v := range value {
|
for k, v := range value {
|
||||||
if val, ok := v.([]interface{}); ok {
|
if val, ok := v.([]interface{}); ok {
|
||||||
@ -368,6 +377,23 @@ func Map(v interface{}, random string, args ...interface{}) map[string]interface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case func(string, map[string]interface{}, int, map[string]interface{}):
|
||||||
|
keys := make([]string, 0, len(value))
|
||||||
|
for k, _ := range value {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
for _, k := range keys {
|
||||||
|
v := value[k].(map[string]interface{})
|
||||||
|
meta := v["meta"].(map[string]interface{})
|
||||||
|
list := v["list"].([]interface{})
|
||||||
|
for i, v := range list {
|
||||||
|
if val, ok := v.(map[string]interface{}); ok {
|
||||||
|
fun(k, meta, i, val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TERM interface {
|
type TERM interface {
|
||||||
@ -51,11 +52,11 @@ func Create(p string) (*os.File, string, error) {
|
|||||||
func Split(str string, c byte, n int) []string {
|
func Split(str string, c byte, n int) []string {
|
||||||
res := []string{}
|
res := []string{}
|
||||||
for i, j := 0, 0; i < len(str); i++ {
|
for i, j := 0, 0; i < len(str); i++ {
|
||||||
if str[i] == c {
|
if str[i] == c || c == ' ' && unicode.IsSpace(rune(str[i])) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for j = i; j < len(str); j++ {
|
for j = i; j < len(str); j++ {
|
||||||
if str[j] == c {
|
if str[j] == c || c == ' ' && unicode.IsSpace(rune(str[j])) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1493,7 +1493,7 @@ function Output(plugin, type, msg, cb, target, option) {
|
|||||||
}, true)
|
}, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}}}]).input, text.focus(), text.setSelectionRange(0, -1)): output[meta[item]]? output[meta[item]](event): plugin.Run(event, [line[exports[1]].trim(), meta[item]||item], function(msg) {
|
}}}]).input, text.focus(), text.setSelectionRange(0, -1)): output[meta[item]]? output[meta[item]](event): plugin.Run(event, [(line[exports[1]]||"").trim(), meta[item]||item], function(msg) {
|
||||||
console.log(msg)
|
console.log(msg)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user