mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-22 21:42:49 +01:00
bump to 0.1.7, add line:set
This commit is contained in:
parent
5bc6f1fd6c
commit
5b74117bca
@ -162,6 +162,7 @@ func init() {
|
||||
registerCmdFn("line:purge", LinePurgeCommand)
|
||||
registerCmdFn("line:setheight", LineSetHeightCommand)
|
||||
registerCmdFn("line:view", LineViewCommand)
|
||||
registerCmdFn("line:set", LineSetCommand)
|
||||
|
||||
registerCmdFn("client", ClientCommand)
|
||||
registerCmdFn("client:show", ClientShowCommand)
|
||||
@ -2041,7 +2042,7 @@ func ScreenResizeCommand(ctx context.Context, pk *scpacket.FeCommandPacketType)
|
||||
}
|
||||
|
||||
func LineCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||
return nil, fmt.Errorf("/line requires a subcommand: %s", formatStrs([]string{"show", "star", "hide", "purge", "setheight"}, "or", false))
|
||||
return nil, fmt.Errorf("/line requires a subcommand: %s", formatStrs([]string{"show", "star", "hide", "purge", "setheight", "set"}, "or", false))
|
||||
}
|
||||
|
||||
func LineSetHeightCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||
@ -2072,6 +2073,47 @@ func LineSetHeightCommand(ctx context.Context, pk *scpacket.FeCommandPacketType)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func LineSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||
ids, err := resolveUiIds(ctx, pk, R_Session|R_Screen)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(pk.Args) != 1 {
|
||||
return nil, fmt.Errorf("/line:set requires 1 argument (linearg)")
|
||||
}
|
||||
lineArg := pk.Args[0]
|
||||
lineId, err := sstore.FindLineIdByArg(ctx, ids.SessionId, ids.ScreenId, lineArg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error looking up lineid: %v", err)
|
||||
}
|
||||
var varsUpdated []string
|
||||
if renderer, found := pk.Kwargs["renderer"]; found {
|
||||
if err = validateRenderer(renderer); err != nil {
|
||||
return nil, fmt.Errorf("invalid renderer value: %w", err)
|
||||
}
|
||||
err = sstore.UpdateLineRenderer(ctx, lineId, renderer)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error changing line renderer: %v", err)
|
||||
}
|
||||
varsUpdated = append(varsUpdated, "renderer")
|
||||
}
|
||||
if len(varsUpdated) == 0 {
|
||||
return nil, fmt.Errorf("/line:set requires a value to set: %s", formatStrs([]string{"renderer"}, "or", false))
|
||||
}
|
||||
updatedLine, err := sstore.GetLineById(ctx, ids.SessionId, ids.ScreenId, lineId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("/line:set cannot retrieve updated line: %v", err)
|
||||
}
|
||||
update := sstore.ModelUpdate{
|
||||
Line: updatedLine,
|
||||
Info: &sstore.InfoMsgType{
|
||||
InfoMsg: fmt.Sprintf("line updated %s", formatStrs(varsUpdated, "and", false)),
|
||||
TimeoutMs: 2000,
|
||||
},
|
||||
}
|
||||
return update, nil
|
||||
}
|
||||
|
||||
func LineViewCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||
if len(pk.Args) != 3 {
|
||||
return nil, fmt.Errorf("usage /line:view [session] [screen] [line]")
|
||||
|
@ -31,7 +31,7 @@ const PromptLockFile = "prompt.lock"
|
||||
const PromptDirName = "prompt"
|
||||
const PromptDevDirName = "prompt-dev"
|
||||
const PromptAppPathVarName = "PROMPT_APP_PATH"
|
||||
const PromptVersion = "v0.1.6"
|
||||
const PromptVersion = "v0.1.7"
|
||||
const PromptAuthKeyFileName = "prompt.authkey"
|
||||
const MShellVersion = "v0.2.0"
|
||||
|
||||
|
@ -1840,6 +1840,14 @@ func UpdateLineHeight(ctx context.Context, lineId string, heightVal int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateLineRenderer(ctx context.Context, lineId string, renderer string) error {
|
||||
return WithTx(ctx, func(tx *TxWrap) error {
|
||||
query := `UPDATE line SET renderer = ? WHERE lineid = ?`
|
||||
tx.Exec(query, renderer, lineId)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// can return nil, nil if line is not found
|
||||
func GetLineById(ctx context.Context, sessionId string, screenId string, lineId string) (*LineType, error) {
|
||||
var rtn *LineType
|
||||
|
Loading…
Reference in New Issue
Block a user