1
0
forked from x/ContextOS

add support wuhuan

This commit is contained in:
shaoying 2020-01-26 18:04:00 +08:00
parent 2b28848b15
commit 2e989b8505
8 changed files with 44 additions and 4 deletions

View File

@ -127,7 +127,7 @@ endfun
fun! ShyComplete(firststart, base)
if a:firststart | let line = getline('.') | let start = col('.') - 1
" 命令位置
if match(trim(line), "ice ") == 0 | return match(line, "ice ") | endif
if match(line, '\s*ice ') == 0 | return match(line, "ice ") | endif
" 符号位置
if line[start-1] !~ '\a' | return start - 1 | end
" 单词位置
@ -155,7 +155,7 @@ fun! ShyCome(buf, row, action, extra)
let a:extra["count"] = 0
endif
" 刷新命令
for line in reverse(split(trim(ShySend({"cmd": "trans", "arg": getbufline(a:buf, a:row)[0]})), "\n"))
for line in reverse(split(ShySend({"cmd": "trans", "arg": getbufline(a:buf, a:row)[0]}), "\n"))
call appendbufline(a:buf, a:row, line)
let a:extra["count"] += 1
endfor
@ -169,12 +169,19 @@ fun! ShyUpdate(timer)
call ShyCome(what["buf"], what["row"], what["action"], what)
endfun
fun! ShyComes(action)
" 低配命令
if !exists("appendbufline")
for line in reverse(split(ShySend({"cmd": "trans", "arg": getline(".")}), "\n"))
call append(".", line)
endfor
return
endif
if !exists("b:timer") | let b:timer = -1 | endif
" 清除定时
if b:timer > 0 | call timer_stop(b:timer) | let b:timer = -2 | return | endif
" 添加定时
let b:timer = timer_start(1000, funcref('ShyUpdate'), {"repeat": -1})
let g:ShyComeList[b:timer] = {"buf": bufname(), "row": line("."), "pre": getline("."), "action": a:action, "count": 0}
let g:ShyComeList[b:timer] = {"buf": bufname("."), "row": line("."), "pre": getline("."), "action": a:action, "count": 0}
call ShyLog("new timer", b:timer)
endfun

View File

View File

7
go.mod
View File

@ -2,9 +2,14 @@ module miss
go 1.13
require github.com/shylinux/icebergs v0.1.9
require (
github.com/shylinux/contexts v0.0.0-00010101000000-000000000000 // indirect
github.com/shylinux/icebergs v0.1.9
github.com/shylinux/toolkits v0.1.0
)
replace (
github.com/shylinux/contexts => ./
github.com/shylinux/icebergs => ../icebergs
github.com/shylinux/toolkits => ../toolkits
)

1
go.sum
View File

@ -2,6 +2,7 @@ github.com/gomarkdown/markdown v0.0.0-20200112043221-ec51d717629d h1:Qw3Ku+gg4x3
github.com/gomarkdown/markdown v0.0.0-20200112043221-ec51d717629d/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/shylinux/contexts v0.0.0-20200121121314-2b28848b15ea h1:xmFZmpT3RMt4JnmxSwJ9M552SaiCC8DufYVadssbuS8=
github.com/shylinux/icebergs v0.1.12 h1:pUWWp4p5rF1JT7lcbaBlCJOWzwjPYDzmWcO9+nrNsfs=
github.com/shylinux/icebergs v0.1.12/go.mod h1:/gccR5uyFaaml8CBSD4BfHmIPOK6QlaFp3sK4eOiv4s=
github.com/shylinux/toolkits v0.1.0 h1:7ghnVEjuwLf7zBsyeR37ahm2gaOKIyjSw9F9Pp9oTBU=

View File

@ -12,6 +12,8 @@ import (
_ "github.com/shylinux/icebergs/misc/mp"
_ "github.com/shylinux/icebergs/misc/pi"
_ "github.com/shylinux/icebergs/misc/wx"
_ "github.com/shylinux/contexts/src/support/wuhan"
)
func main() {

View File

@ -0,0 +1,24 @@
package wuhan
import (
"github.com/shylinux/icebergs"
"github.com/shylinux/icebergs/base/cli"
"github.com/shylinux/toolkits"
)
var Index = &ice.Context{Name: "wuhan", Help: "武汉加油",
Caches: map[string]*ice.Cache{},
Configs: map[string]*ice.Config{
"wuhan": {Name: "wuhan", Help: "武汉", Value: kit.Data(kit.MDB_SHORT, "name")},
},
Commands: map[string]*ice.Command{
ice.ICE_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
ice.ICE_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {}},
"wuhan": {Name: "wuhan", Help: "武汉", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
m.Echo("hello world")
}},
},
}
func init() { cli.Index.Register(Index, nil) }

View File

@ -0,0 +1 @@
# {{title "wuhan"}}