forked from x/icebergs
opt some
This commit is contained in:
parent
b77ef72cc6
commit
e93b45073b
@ -96,7 +96,10 @@ func init() {
|
|||||||
m.Push("ip", strings.TrimSuffix(ls[1], ")"))
|
m.Push("ip", strings.TrimSuffix(ls[1], ")"))
|
||||||
}
|
}
|
||||||
|
|
||||||
t, _ := time.ParseInLocation("2006 Jan 2 15:04", "2020 "+ls[0], time.Local)
|
t, e := time.ParseInLocation("2006 Jan 2 15:04", "2020 "+ls[0], time.Local)
|
||||||
|
if e != nil {
|
||||||
|
t, _ = time.ParseInLocation("2006-01-02 15:04", ls[0], time.Local)
|
||||||
|
}
|
||||||
m.Push("begin", t.Format("2006-01-02 15:04:05"))
|
m.Push("begin", t.Format("2006-01-02 15:04:05"))
|
||||||
d := time.Since(t)
|
d := time.Since(t)
|
||||||
d = d / time.Millisecond * time.Millisecond
|
d = d / time.Millisecond * time.Millisecond
|
||||||
|
@ -205,8 +205,11 @@ func (f *Frame) parse(m *ice.Message, line string) string {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行命令
|
if strings.HasPrefix(line, "<") {
|
||||||
msg.Cmdy(ls[0], ls[1:])
|
msg.Resultv(line)
|
||||||
|
} else if msg.Cmdy(ls[0], ls[1:]); strings.HasPrefix(msg.Result(), "warn: ") && m.Option("render") == "raw" {
|
||||||
|
msg.Resultv(line)
|
||||||
|
}
|
||||||
|
|
||||||
// 渲染引擎
|
// 渲染引擎
|
||||||
_args, _ := msg.Optionv(ice.MSG_ARGS).([]interface{})
|
_args, _ := msg.Optionv(ice.MSG_ARGS).([]interface{})
|
||||||
|
@ -132,7 +132,7 @@ func init() {
|
|||||||
m.Echo(`<fieldset><legend>%s(%s)</legend><form></form></fieldset>`, arg[0], arg[1])
|
m.Echo(`<fieldset><legend>%s(%s)</legend><form></form></fieldset>`, arg[0], arg[1])
|
||||||
}},
|
}},
|
||||||
RENDER.Frame: {Hand: func(m *ice.Message, arg ...string) {
|
RENDER.Frame: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(`<iframe src=%s width=800 height=400 ></iframe>`, arg[0])
|
m.Echo(`<iframe src=%s class="story" data-type="iframe" width=800 height=400 ></iframe>`, arg[0])
|
||||||
}},
|
}},
|
||||||
RENDER.Button: {Hand: func(m *ice.Message, arg ...string) {
|
RENDER.Button: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
m.Echo(`<input type="button" value="%s">`, arg[0])
|
m.Echo(`<input type="button" value="%s">`, arg[0])
|
||||||
|
@ -112,8 +112,8 @@ func (b *Label) Init(m *ice.Message, arg ...string) Chart {
|
|||||||
|
|
||||||
// 解析数据
|
// 解析数据
|
||||||
b.max = map[int]int{}
|
b.max = map[int]int{}
|
||||||
for _, v := range kit.Split(arg[0], "\n") {
|
for _, v := range strings.Split(arg[0], "\n") {
|
||||||
l := kit.Split(v)
|
l := kit.Split(v, " ", " ")
|
||||||
for i, v := range l {
|
for i, v := range l {
|
||||||
switch data := kit.Parse(nil, "", kit.Split(v)...).(type) {
|
switch data := kit.Parse(nil, "", kit.Split(v)...).(type) {
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
@ -135,6 +135,10 @@ func (b *Label) Init(m *ice.Message, arg ...string) Chart {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
func (b *Label) Draw(m *ice.Message, x, y int) Chart {
|
func (b *Label) Draw(m *ice.Message, x, y int) Chart {
|
||||||
|
m.Debug("arg %v", m.Option("order"))
|
||||||
|
order, _ := kit.Parse(nil, "", kit.Split(m.Option("order"))...).(map[string]interface{})
|
||||||
|
m.Debug("order", order)
|
||||||
|
|
||||||
top := y
|
top := y
|
||||||
for _, line := range b.data {
|
for _, line := range b.data {
|
||||||
left := x
|
left := x
|
||||||
@ -147,6 +151,19 @@ func (b *Label) Draw(m *ice.Message, x, y int) Chart {
|
|||||||
MarginX: b.MarginX,
|
MarginX: b.MarginX,
|
||||||
MarginY: b.MarginY,
|
MarginY: b.MarginY,
|
||||||
}
|
}
|
||||||
|
if order != nil {
|
||||||
|
if w := kit.Int(kit.Value(order, "index")); w != 0 && i%w == 0 {
|
||||||
|
for k, v := range order {
|
||||||
|
switch k {
|
||||||
|
case "fg":
|
||||||
|
item.FontColor = kit.Format(v)
|
||||||
|
case "bg":
|
||||||
|
item.BackGround = kit.Format(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch data := kit.Parse(nil, "", kit.Split(text)...).(type) {
|
switch data := kit.Parse(nil, "", kit.Split(text)...).(type) {
|
||||||
case map[string]interface{}:
|
case map[string]interface{}:
|
||||||
item.Init(m, kit.Select(text, data["text"])).Data(m, data)
|
item.Init(m, kit.Select(text, data["text"])).Data(m, data)
|
||||||
|
@ -44,11 +44,14 @@ func reply(m *ice.Message, cmd string, arg ...string) bool {
|
|||||||
m.Sort("time", "time_r")
|
m.Sort("time", "time_r")
|
||||||
|
|
||||||
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
if len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
||||||
|
m.Option("_display", "table")
|
||||||
|
if m.Option(nfs.DIR_DEEP) == "true" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
// 目录列表
|
// 目录列表
|
||||||
m.Option(nfs.DIR_REG, "")
|
m.Option(nfs.DIR_REG, "")
|
||||||
m.Option(nfs.DIR_TYPE, "dir")
|
m.Option(nfs.DIR_TYPE, "dir")
|
||||||
m.Cmdy(nfs.DIR, kit.Select("./", arg, 0))
|
m.Cmdy(nfs.DIR, kit.Select("./", arg, 0))
|
||||||
m.Option("_display", "table")
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
"github.com/shylinux/icebergs/base/ctx"
|
"github.com/shylinux/icebergs/base/ctx"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
"github.com/shylinux/icebergs/base/nfs"
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
"github.com/shylinux/icebergs/base/ssh"
|
"github.com/shylinux/icebergs/base/ssh"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
@ -125,6 +126,12 @@ func _chart_show(m *ice.Message, kind, name, text string, arg ...string) {
|
|||||||
for i := 0; i < len(arg)-1; i++ {
|
for i := 0; i < len(arg)-1; i++ {
|
||||||
m.Option(arg[i], arg[i+1])
|
m.Option(arg[i], arg[i+1])
|
||||||
}
|
}
|
||||||
|
if m.Option("fg") != "" {
|
||||||
|
m.Option("stroke", m.Option("fg"))
|
||||||
|
}
|
||||||
|
if m.Option("bg") != "" {
|
||||||
|
m.Option("fill", m.Option("bg"))
|
||||||
|
}
|
||||||
|
|
||||||
// 计算尺寸
|
// 计算尺寸
|
||||||
chart.Init(m, text)
|
chart.Init(m, text)
|
||||||
@ -247,6 +254,14 @@ func _video_show(m *ice.Message, name, text string, arg ...string) {
|
|||||||
_option(m, VIDEO, name, text, arg...)
|
_option(m, VIDEO, name, text, arg...)
|
||||||
m.Render(ice.RENDER_TEMPLATE, m.Conf(VIDEO, "meta.template"))
|
m.Render(ice.RENDER_TEMPLATE, m.Conf(VIDEO, "meta.template"))
|
||||||
}
|
}
|
||||||
|
func _baidu_show(m *ice.Message, name, text string, arg ...string) {
|
||||||
|
_option(m, BAIDU, name, text, arg...)
|
||||||
|
m.Cmdy(mdb.RENDER, web.RENDER.Frame, kit.Format("https://baidu.com/s?wd=%s", text))
|
||||||
|
}
|
||||||
|
func _other_show(m *ice.Message, name, text string, arg ...string) {
|
||||||
|
_option(m, OTHER, name, text, arg...)
|
||||||
|
m.Cmdy(mdb.RENDER, web.RENDER.Frame, text)
|
||||||
|
}
|
||||||
|
|
||||||
func _word_show(m *ice.Message, name string, arg ...string) {
|
func _word_show(m *ice.Message, name string, arg ...string) {
|
||||||
m.Set(ice.MSG_RESULT)
|
m.Set(ice.MSG_RESULT)
|
||||||
@ -273,6 +288,9 @@ const (
|
|||||||
IMAGE = "image"
|
IMAGE = "image"
|
||||||
VIDEO = "video"
|
VIDEO = "video"
|
||||||
|
|
||||||
|
BAIDU = "baidu"
|
||||||
|
OTHER = "other"
|
||||||
|
|
||||||
PREMENU = "premenu"
|
PREMENU = "premenu"
|
||||||
CHAPTER = "chapter"
|
CHAPTER = "chapter"
|
||||||
SECTION = "section"
|
SECTION = "section"
|
||||||
@ -335,6 +353,9 @@ func init() {
|
|||||||
_brief_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
_brief_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
}},
|
}},
|
||||||
REFER: {Name: "refer name `[name url]...`", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
REFER: {Name: "refer name `[name url]...`", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) == 1 {
|
||||||
|
arg = []string{"", arg[0]}
|
||||||
|
}
|
||||||
_refer_show(m, arg[0], arg[1], arg[2:]...)
|
_refer_show(m, arg[0], arg[1], arg[2:]...)
|
||||||
}},
|
}},
|
||||||
SPARK: {Name: "spark [name] text", Help: "感悟", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
SPARK: {Name: "spark [name] text", Help: "感悟", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
@ -349,6 +370,9 @@ func init() {
|
|||||||
}},
|
}},
|
||||||
|
|
||||||
CHART: {Name: "chart label|chain name text arg...", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
CHART: {Name: "chart label|chain name text arg...", Help: "图表", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) == 2 {
|
||||||
|
arg = []string{arg[0], "", arg[1]}
|
||||||
|
}
|
||||||
_chart_show(m, arg[0], arg[1], arg[2], arg[3:]...)
|
_chart_show(m, arg[0], arg[1], arg[2], arg[3:]...)
|
||||||
}},
|
}},
|
||||||
FIELD: {Name: "field name cmd", Help: "插件", Action: map[string]*ice.Action{
|
FIELD: {Name: "field name cmd", Help: "插件", Action: map[string]*ice.Action{
|
||||||
@ -410,6 +434,19 @@ func init() {
|
|||||||
_video_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
_video_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
}},
|
}},
|
||||||
|
|
||||||
|
BAIDU: {Name: "baidu word", Help: "百度", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) == 1 {
|
||||||
|
arg = []string{"", arg[0]}
|
||||||
|
}
|
||||||
|
_baidu_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
|
}},
|
||||||
|
OTHER: {Name: "other word", Help: "网页", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
if len(arg) == 1 {
|
||||||
|
arg = []string{"", arg[0]}
|
||||||
|
}
|
||||||
|
_other_show(m, arg[0], kit.Select(arg[0], arg[1]), arg[2:]...)
|
||||||
|
}},
|
||||||
|
|
||||||
WORD: {Name: "word path=demo/hi.shy auto", Help: "语言文字", Meta: kit.Dict(
|
WORD: {Name: "word path=demo/hi.shy auto", Help: "语言文字", Meta: kit.Dict(
|
||||||
"display", "/plugin/local/wiki/word.js",
|
"display", "/plugin/local/wiki/word.js",
|
||||||
), Action: map[string]*ice.Action{
|
), Action: map[string]*ice.Action{
|
||||||
|
@ -7,4 +7,11 @@ refer "官网" `
|
|||||||
插件 chrome://extensions
|
插件 chrome://extensions
|
||||||
`
|
`
|
||||||
|
|
||||||
|
chapter "应用"
|
||||||
|
section "启动本地应用"
|
||||||
|
refer `
|
||||||
|
终端 terminal://
|
||||||
|
博客 https://www.cnblogs.com/lymvv/p/8431238.html
|
||||||
|
`
|
||||||
|
other "https://www.cnblogs.com/lymvv/p/8431238.html"
|
||||||
|
baidu "html"
|
||||||
|
7
misc/git/git.shy
Normal file
7
misc/git/git.shy
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
title "git"
|
||||||
|
|
||||||
|
refer "官网" `
|
||||||
|
官网 https://git-scm.com/
|
||||||
|
文档 https://git-scm.com/docs
|
||||||
|
源码 https://github.com/git/git
|
||||||
|
`
|
@ -3,6 +3,8 @@ package vim
|
|||||||
import (
|
import (
|
||||||
ice "github.com/shylinux/icebergs"
|
ice "github.com/shylinux/icebergs"
|
||||||
"github.com/shylinux/icebergs/base/cli"
|
"github.com/shylinux/icebergs/base/cli"
|
||||||
|
"github.com/shylinux/icebergs/base/mdb"
|
||||||
|
"github.com/shylinux/icebergs/base/nfs"
|
||||||
"github.com/shylinux/icebergs/base/web"
|
"github.com/shylinux/icebergs/base/web"
|
||||||
"github.com/shylinux/icebergs/core/code"
|
"github.com/shylinux/icebergs/core/code"
|
||||||
kit "github.com/shylinux/toolkits"
|
kit "github.com/shylinux/toolkits"
|
||||||
@ -26,6 +28,15 @@ var Index = &ice.Context{Name: "vim", Help: "编辑器",
|
|||||||
"--enable-luainterp=yes",
|
"--enable-luainterp=yes",
|
||||||
"--enable-cscope=yes",
|
"--enable-cscope=yes",
|
||||||
}, "history", "vim.history",
|
}, "history", "vim.history",
|
||||||
|
"plug", kit.Dict(
|
||||||
|
"prefix", kit.Dict(
|
||||||
|
"\"", "comment",
|
||||||
|
),
|
||||||
|
"keyword", kit.Dict(
|
||||||
|
"highlight", "keyword",
|
||||||
|
"syntax", "keyword",
|
||||||
|
),
|
||||||
|
),
|
||||||
)},
|
)},
|
||||||
},
|
},
|
||||||
Commands: map[string]*ice.Command{
|
Commands: map[string]*ice.Command{
|
||||||
@ -50,6 +61,14 @@ var Index = &ice.Context{Name: "vim", Help: "编辑器",
|
|||||||
}
|
}
|
||||||
}}))
|
}}))
|
||||||
}},
|
}},
|
||||||
|
VIM: {Name: VIM, Help: "vim", Action: map[string]*ice.Action{
|
||||||
|
mdb.PLUGIN: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Echo(m.Conf(VIM, "meta.plug"))
|
||||||
|
}},
|
||||||
|
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
|
m.Cmdy(nfs.CAT, path.Join(arg[2], arg[1]))
|
||||||
|
}},
|
||||||
|
}},
|
||||||
code.INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
code.INSTALL: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
p := path.Join(m.Conf("install", "meta.path"), m.Conf("vim", "meta.version"))
|
p := path.Join(m.Conf("install", "meta.path"), m.Conf("vim", "meta.version"))
|
||||||
if _, e := os.Stat(p); e != nil {
|
if _, e := os.Stat(p); e != nil {
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
title "vim"
|
title "vim"
|
||||||
|
|
||||||
refer "官网" `
|
refer "官网" `
|
||||||
官网 https://www.vim.org/
|
官网 https://www.vim.org
|
||||||
下载 https://www.vim.org/download.php
|
源码 https://github.com/vim/vim
|
||||||
源码 ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2
|
文档 http://vimdoc.sourceforge.net/htmldoc/usr_toc.html
|
||||||
`
|
`
|
||||||
|
|
||||||
spark terminal
|
field "启动配置" web.code.inner args `[ etc/conf/ vimrc ]`
|
||||||
|
|
||||||
|
chapter "配置"
|
||||||
|
|
||||||
|
chapter "插件"
|
||||||
|
|
||||||
|
refer `
|
||||||
|
插件管理器 https://github.com/junegunn/vim-plug
|
||||||
|
`
|
||||||
|
section "状态栏"
|
||||||
|
refer `
|
||||||
|
插件管理器 https://github.com/vim-airline/vim-airline
|
||||||
|
`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user