mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
updates for line renderer
This commit is contained in:
parent
171fa9128d
commit
57a8e49d73
2
db/migrations/000003_renderer.down.sql
Normal file
2
db/migrations/000003_renderer.down.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE line DROP COLUMN renderer;
|
||||
|
2
db/migrations/000003_renderer.up.sql
Normal file
2
db/migrations/000003_renderer.up.sql
Normal file
@ -0,0 +1,2 @@
|
||||
ALTER TABLE line ADD COLUMN renderer varchar(50) NOT NULL DEFAULT '';
|
||||
|
@ -1197,7 +1197,7 @@ func makeStaticCmd(ctx context.Context, metaCmd string, ids resolvedIds, cmdStr
|
||||
}
|
||||
|
||||
func addLineForCmd(ctx context.Context, metaCmd string, shouldFocus bool, ids resolvedIds, cmd *sstore.CmdType) (*sstore.ModelUpdate, error) {
|
||||
rtnLine, err := sstore.AddCmdLine(ctx, ids.SessionId, ids.WindowId, DefaultUserId, cmd)
|
||||
rtnLine, err := sstore.AddCmdLine(ctx, ids.SessionId, ids.WindowId, DefaultUserId, cmd, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1885,7 +1885,7 @@ func LineSetHeightCommand(ctx context.Context, pk *scpacket.FeCommandPacketType)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("/line:setheight invalid height val: %v", err)
|
||||
}
|
||||
if heightVal > 1000 {
|
||||
if heightVal > 10000 {
|
||||
return nil, fmt.Errorf("/line:setheight invalid height val (too large): %d", heightVal)
|
||||
}
|
||||
err = sstore.UpdateLineHeight(ctx, lineId, heightVal)
|
||||
@ -2051,6 +2051,14 @@ func LineShowCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sst
|
||||
if cmd.RtnState {
|
||||
buf.WriteString(fmt.Sprintf(" %-15s %s\n", "rtnstate", "true"))
|
||||
}
|
||||
stat, _ := sstore.StatCmdPtyFile(ctx, cmd.SessionId, cmd.CmdId)
|
||||
if stat == nil {
|
||||
buf.WriteString(fmt.Sprintf(" %-15s %s\n", "file", "-"))
|
||||
} else {
|
||||
fileDataStr := fmt.Sprintf("v%d data=%d offset=%d max=%s", stat.Version, stat.DataSize, stat.FileOffset, scbase.NumFormatB2(stat.MaxSize))
|
||||
buf.WriteString(fmt.Sprintf(" %-15s %s\n", "file", stat.Location))
|
||||
buf.WriteString(fmt.Sprintf(" %-15s %s\n", "file-data", fileDataStr))
|
||||
}
|
||||
}
|
||||
update := sstore.ModelUpdate{
|
||||
Info: &sstore.InfoMsgType{
|
||||
|
@ -687,8 +687,8 @@ func InsertLine(ctx context.Context, line *LineType, cmd *CmdType) error {
|
||||
query = `SELECT nextlinenum FROM window WHERE sessionid = ? AND windowid = ?`
|
||||
nextLineNum := tx.GetInt(query, line.SessionId, line.WindowId)
|
||||
line.LineNum = int64(nextLineNum)
|
||||
query = `INSERT INTO line ( sessionid, windowid, userid, lineid, ts, linenum, linenumtemp, linelocal, linetype, text, cmdid, ephemeral, contentheight, star, archived)
|
||||
VALUES (:sessionid,:windowid,:userid,:lineid,:ts,:linenum,:linenumtemp,:linelocal,:linetype,:text,:cmdid,:ephemeral,:contentheight,:star,:archived)`
|
||||
query = `INSERT INTO line ( sessionid, windowid, userid, lineid, ts, linenum, linenumtemp, linelocal, linetype, text, cmdid, renderer, ephemeral, contentheight, star, archived)
|
||||
VALUES (:sessionid,:windowid,:userid,:lineid,:ts,:linenum,:linenumtemp,:linelocal,:linetype,:text,:cmdid,:renderer,:ephemeral,:contentheight,:star,:archived)`
|
||||
tx.NamedExecWrap(query, line)
|
||||
query = `UPDATE window SET nextlinenum = ? WHERE sessionid = ? AND windowid = ?`
|
||||
tx.ExecWrap(query, nextLineNum+1, line.SessionId, line.WindowId)
|
||||
|
@ -24,6 +24,14 @@ func CreateCmdPtyFile(ctx context.Context, sessionId string, cmdId string, maxSi
|
||||
return f.Close()
|
||||
}
|
||||
|
||||
func StatCmdPtyFile(ctx context.Context, sessionId string, cmdId string) (*cirfile.Stat, error) {
|
||||
ptyOutFileName, err := scbase.PtyOutFile(sessionId, cmdId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cirfile.StatCirFile(ctx, ptyOutFileName)
|
||||
}
|
||||
|
||||
func AppendToCmdPtyBlob(ctx context.Context, sessionId string, cmdId string, data []byte, pos int64) (*PtyDataUpdate, error) {
|
||||
if pos < 0 {
|
||||
return nil, fmt.Errorf("invalid seek pos '%d' in AppendToCmdPtyBlob", pos)
|
||||
|
@ -643,6 +643,7 @@ type LineType struct {
|
||||
LineNumTemp bool `json:"linenumtemp,omitempty"`
|
||||
LineLocal bool `json:"linelocal"`
|
||||
LineType string `json:"linetype"`
|
||||
Renderer string `json:"renderer,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
CmdId string `json:"cmdid,omitempty"`
|
||||
Ephemeral bool `json:"ephemeral,omitempty"`
|
||||
@ -825,7 +826,7 @@ func CmdFromMap(m map[string]interface{}) *CmdType {
|
||||
return &cmd
|
||||
}
|
||||
|
||||
func makeNewLineCmd(sessionId string, windowId string, userId string, cmdId string) *LineType {
|
||||
func makeNewLineCmd(sessionId string, windowId string, userId string, cmdId string, renderer string) *LineType {
|
||||
rtn := &LineType{}
|
||||
rtn.SessionId = sessionId
|
||||
rtn.WindowId = windowId
|
||||
@ -836,6 +837,7 @@ func makeNewLineCmd(sessionId string, windowId string, userId string, cmdId stri
|
||||
rtn.LineType = LineTypeCmd
|
||||
rtn.CmdId = cmdId
|
||||
rtn.ContentHeight = LineNoHeight
|
||||
rtn.Renderer = renderer
|
||||
return rtn
|
||||
}
|
||||
|
||||
@ -862,8 +864,8 @@ func AddCommentLine(ctx context.Context, sessionId string, windowId string, user
|
||||
return rtnLine, nil
|
||||
}
|
||||
|
||||
func AddCmdLine(ctx context.Context, sessionId string, windowId string, userId string, cmd *CmdType) (*LineType, error) {
|
||||
rtnLine := makeNewLineCmd(sessionId, windowId, userId, cmd.CmdId)
|
||||
func AddCmdLine(ctx context.Context, sessionId string, windowId string, userId string, cmd *CmdType, renderer string) (*LineType, error) {
|
||||
rtnLine := makeNewLineCmd(sessionId, windowId, userId, cmd.CmdId, renderer)
|
||||
err := InsertLine(ctx, rtnLine, cmd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user