1
0
mirror of https://shylinux.com/x/icebergs synced 2025-06-26 18:37:29 +08:00
This commit is contained in:
shaoying 2020-10-09 20:14:11 +08:00
parent 210847ee8c
commit 133eff9527
6 changed files with 35 additions and 13 deletions

View File

@ -125,6 +125,13 @@ func init() {
w, h, e := terminal.GetSize(fd) w, h, e := terminal.GetSize(fd)
m.Assert(e) m.Assert(e)
fd1 := int(os.Stdout.Fd())
oldState1, err := terminal.MakeRaw(fd1)
if err != nil {
panic(err)
}
defer terminal.Restore(fd1, oldState1)
session.Stdin = os.Stdin session.Stdin = os.Stdin
session.Stdout = os.Stdout session.Stdout = os.Stdout
session.Stderr = os.Stderr session.Stderr = os.Stderr

View File

@ -170,7 +170,9 @@ func init() {
} }
m.Option(tcp.LISTEN_CB, func(c net.Conn) { m.Go(func() { _ssh_accept(m, kit.Hashs(m.Option(tcp.PORT)), c) }) }) m.Option(tcp.LISTEN_CB, func(c net.Conn) { m.Go(func() { _ssh_accept(m, kit.Hashs(m.Option(tcp.PORT)), c) }) })
m.Go(func() { m.Cmdy(tcp.SERVER, tcp.LISTEN, kit.MDB_NAME, SSH, tcp.PORT, m.Option(tcp.PORT)) }) m.Go(func() {
m.Cmdy(tcp.SERVER, tcp.LISTEN, kit.MDB_TYPE, SSH, kit.MDB_NAME, tcp.PORT, tcp.PORT, m.Option(tcp.PORT))
})
}}, }},
mdb.INSERT: {Name: "insert text:textarea", Help: "添加", Hand: func(m *ice.Message, arg ...string) { mdb.INSERT: {Name: "insert text:textarea", Help: "添加", Hand: func(m *ice.Message, arg ...string) {

View File

@ -23,13 +23,13 @@ type Conn struct {
func (c *Conn) Read(b []byte) (int, error) { func (c *Conn) Read(b []byte) (int, error) {
n, e := c.Conn.Read(b) n, e := c.Conn.Read(b)
c.s.nr += n c.s.nr += n
c.m.Conf(CLIENT, kit.Keys(kit.MDB_HASH, c.h, kit.MDB_META, "nread"), c.s.nr) // c.m.Conf(CLIENT, kit.Keys(kit.MDB_HASH, c.h, kit.MDB_META, "nread"), c.s.nr)
return n, e return n, e
} }
func (c *Conn) Write(b []byte) (int, error) { func (c *Conn) Write(b []byte) (int, error) {
n, e := c.Conn.Write(b) n, e := c.Conn.Write(b)
c.s.nw += n c.s.nw += n
c.m.Conf(CLIENT, kit.Keys(kit.MDB_HASH, c.h, kit.MDB_META, "nwrite"), c.s.nw) // c.m.Conf(CLIENT, kit.Keys(kit.MDB_HASH, c.h, kit.MDB_META, "nwrite"), c.s.nw)
return n, e return n, e
} }
func (c *Conn) Close() error { func (c *Conn) Close() error {

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/gorilla/websocket v1.4.2 github.com/gorilla/websocket v1.4.2
github.com/kr/pty v1.1.1 github.com/kr/pty v1.1.1
github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369 github.com/nareix/joy4 v0.0.0-20200507095837-05a4ffbb5369
github.com/shylinux/toolkits v0.1.8 github.com/shylinux/toolkits v0.1.9
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2 github.com/tuotoo/qrcode v0.0.0-20190222102259-ac9c44189bf2
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550

15
init.go
View File

@ -1,6 +1,8 @@
package ice package ice
import ( import (
"encoding/json"
kit "github.com/shylinux/toolkits" kit "github.com/shylinux/toolkits"
"os" "os"
@ -139,6 +141,16 @@ var Pulse = &Message{
} }
var wait = make(chan bool, 1) var wait = make(chan bool, 1)
func Init(file string) {
if f, e := os.Open(file); e == nil {
defer f.Close()
var data interface{}
json.NewDecoder(f).Decode(&data)
kit.Fetch(data, func(key string, value string) { Pulse.Option(key, value) })
}
}
func Run(arg ...string) string { func Run(arg ...string) string {
if len(arg) == 0 { if len(arg) == 0 {
arg = os.Args[1:] arg = os.Args[1:]
@ -164,13 +176,14 @@ func Run(arg ...string) string {
os.Exit(frame.code) os.Exit(frame.code)
default: default:
_log_disable = false _log_disable = os.Getenv("ctx_debug") != "true"
if Pulse.Cmdy(arg); Pulse.Result() == "" { if Pulse.Cmdy(arg); Pulse.Result() == "" {
Pulse.Table() Pulse.Table()
} }
if strings.TrimSpace(Pulse.Result()) == "" { if strings.TrimSpace(Pulse.Result()) == "" {
Pulse.Set(MSG_RESULT).Cmdy("cli.system", arg) Pulse.Set(MSG_RESULT).Cmdy("cli.system", arg)
} }
Pulse.Sleep("10ms")
} }
return Pulse.Result() return Pulse.Result()

16
misc.go
View File

@ -54,14 +54,6 @@ func (m *Message) Space(arg interface{}) []string {
return []string{"web.space", kit.Format(arg)} return []string{"web.space", kit.Format(arg)}
} }
var count = int32(0)
func (m *Message) AddCmd(cmd *Command) string {
name := fmt.Sprintf("_cb_%d", atomic.AddInt32(&count, 1))
m.target.Commands[name] = cmd
return kit.Keys(m.target.Cap(CTX_FOLLOW), name)
}
func (m *Message) PushRender(key, view, name string, arg ...string) *Message { func (m *Message) PushRender(key, view, name string, arg ...string) *Message {
if m.Option(MSG_USERUA) == "" { if m.Option(MSG_USERUA) == "" {
return m return m
@ -110,4 +102,12 @@ func (m *Message) PushPlugin(key string, arg ...string) *Message {
return m return m
} }
var count = int32(0)
func (m *Message) AddCmd(cmd *Command) string {
name := fmt.Sprintf("_cb_%d", atomic.AddInt32(&count, 1))
m.target.Commands[name] = cmd
return kit.Keys(m.target.Cap(CTX_FOLLOW), name)
}
var BinPack = map[string][]byte{} var BinPack = map[string][]byte{}