mirror of
https://shylinux.com/x/ContextOS
synced 2025-04-26 09:14:06 +08:00
opt nfs
This commit is contained in:
parent
5c3a4d5eb4
commit
5655767aac
@ -1456,6 +1456,7 @@ type CTX struct {
|
|||||||
var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{},
|
var Index = &Context{Name: "ctx", Help: "模块中心", Server: &CTX{},
|
||||||
Caches: map[string]*Cache{
|
Caches: map[string]*Cache{
|
||||||
"begin_time": &Cache{Name: "begin_time", Value: "", Help: "启动时间"},
|
"begin_time": &Cache{Name: "begin_time", Value: "", Help: "启动时间"},
|
||||||
|
"goos": &Cache{Name: "goos", Value: "linux", Help: "启动时间"},
|
||||||
"nserver": &Cache{Name: "nserver", Value: "0", Help: "服务数量"},
|
"nserver": &Cache{Name: "nserver", Value: "0", Help: "服务数量"},
|
||||||
"ncontext": &Cache{Name: "ncontext", Value: "0", Help: "模块数量"},
|
"ncontext": &Cache{Name: "ncontext", Value: "0", Help: "模块数量"},
|
||||||
"nmessage": &Cache{Name: "nmessage", Value: "1", Help: "消息数量"},
|
"nmessage": &Cache{Name: "nmessage", Value: "1", Help: "消息数量"},
|
||||||
@ -3250,6 +3251,7 @@ func (ctx *CTX) Begin(m *Message, arg ...string) Server {
|
|||||||
m.target.root = m.target
|
m.target.root = m.target
|
||||||
m.root = m
|
m.root = m
|
||||||
m.Cap("begin_time", m.Time())
|
m.Cap("begin_time", m.Time())
|
||||||
|
m.Cap("goos", runtime.GOOS)
|
||||||
for _, msg := range m.Search("") {
|
for _, msg := range m.Search("") {
|
||||||
msg.target.root = m.target
|
msg.target.root = m.target
|
||||||
if msg.target == m.target {
|
if msg.target == m.target {
|
||||||
|
@ -335,15 +335,38 @@ func (nfs *NFS) View(buf []string, top int, height int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nfs *NFS) Read(p []byte) (n int, err error) {
|
func (nfs *NFS) Read(p []byte) (n int, err error) {
|
||||||
if nfs.Caps("windows") || !nfs.Caps("termbox") || nfs.Confs("term_simple") {
|
m := nfs.Context.Message()
|
||||||
|
if !m.Caps("termbox") {
|
||||||
return nfs.in.Read(p)
|
return nfs.in.Read(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]rune, 0, 1024)
|
what := make([]rune, 0, 1024)
|
||||||
rest := make([]rune, 0, 1024)
|
|
||||||
|
|
||||||
back := buf
|
for {
|
||||||
|
switch ev := termbox.PollEvent(); ev.Type {
|
||||||
|
case termbox.EventKey:
|
||||||
|
switch ev.Key {
|
||||||
|
case termbox.KeyCtrlC:
|
||||||
|
case termbox.KeyCtrlJ:
|
||||||
|
b := []byte(string(what))
|
||||||
|
n = len(b)
|
||||||
|
copy(p, b)
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
m.Log("bench", "event %v", ev.Ch)
|
||||||
|
what = append(what, ev.Ch)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
back := make([]rune, 0, 1024)
|
||||||
|
rest := make([]rune, 0, 1024)
|
||||||
|
buf := back
|
||||||
|
|
||||||
history := nfs.Context.Message().Confv("history").([]interface{})
|
history := nfs.Context.Message().Confv("history").([]interface{})
|
||||||
his := len(history)
|
his := len(history)
|
||||||
@ -527,7 +550,6 @@ func (nfs *NFS) Read(p []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nfs *NFS) prompt(arg ...string) string {
|
func (nfs *NFS) prompt(arg ...string) string {
|
||||||
m := nfs.Context.Message()
|
m := nfs.Context.Message()
|
||||||
target, _ := m.Optionv("ps_target").(*ctx.Context)
|
target, _ := m.Optionv("ps_target").(*ctx.Context)
|
||||||
@ -629,6 +651,11 @@ func (nfs *NFS) Start(m *ctx.Message, arg ...string) bool {
|
|||||||
|
|
||||||
if nfs.in = m.Optionv("in").(*os.File); m.Has("out") {
|
if nfs.in = m.Optionv("in").(*os.File); m.Has("out") {
|
||||||
nfs.out = m.Optionv("out").(*os.File)
|
nfs.out = m.Optionv("out").(*os.File)
|
||||||
|
if m.Cap("goos") != "windows" {
|
||||||
|
termbox.Init()
|
||||||
|
defer termbox.Close()
|
||||||
|
nfs.Caches["termbox"] = &ctx.Cache{Value: "true"}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
line, bio := "", bufio.NewScanner(nfs)
|
line, bio := "", bufio.NewScanner(nfs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user