|
@@ -42,14 +42,7 @@ func (uv *MangekyoUserView) makeTree() {
|
|
|
Description: v.Description,
|
|
|
}
|
|
|
end := &hhc_ast.SDTNode_End{
|
|
|
- Exec: func(ectx *hhc_ast.ExecUserContext) {
|
|
|
- fview := v.GetViewNameFunc
|
|
|
- fprompt := v.GetPromptFunc
|
|
|
- ftitle := v.GetTitleFunc
|
|
|
- ectx.ChangeView(fview(uv.ctx))
|
|
|
- ectx.ChangePrompt(fprompt(uv.ctx))
|
|
|
- ectx.ChangeTitle(ftitle(uv.ctx))
|
|
|
- },
|
|
|
+ Exec: uv.getViewChangeExecFunc(v),
|
|
|
}
|
|
|
cmd.AddEnd(end)
|
|
|
uv.treeroot.AddCommand(cmd)
|
|
@@ -90,6 +83,15 @@ func (uv *MangekyoUserView) addCommands() {
|
|
|
c_disp_termwidth.AddEnd(c_disp_termwidth_end)
|
|
|
c_disp.AddSubCommand(c_disp_termwidth)
|
|
|
uv.treeroot.AddCommand(c_disp)
|
|
|
+ c_exit := &hhc_ast.SDTNode_Command{
|
|
|
+ Name: "exit",
|
|
|
+ Description: "Disconnect this session.",
|
|
|
+ }
|
|
|
+ c_exit_end := &hhc_ast.SDTNode_End{
|
|
|
+ Exec: uv.execExit,
|
|
|
+ }
|
|
|
+ c_exit.AddEnd(c_exit_end)
|
|
|
+ uv.treeroot.AddCommand(c_exit)
|
|
|
}
|
|
|
|
|
|
func (uv *MangekyoUserView) execDispTermwidth(ctx *hhc_ast.ExecUserContext) {
|
|
@@ -119,3 +121,18 @@ func (uv *MangekyoUserView) execTermwidth(ctx *hhc_ast.ExecUserContext) {
|
|
|
uv.cli.SetTerminalWidth(n)
|
|
|
ctx.ResultPrintSingleLineString(fmt.Sprintf("Terminal width set to %d.", n))
|
|
|
}
|
|
|
+
|
|
|
+func (uv *MangekyoUserView) execExit(ctx *hhc_ast.ExecUserContext) {
|
|
|
+ uv.ctx.GetConn().Close()
|
|
|
+}
|
|
|
+
|
|
|
+func (uv *MangekyoUserView) getViewChangeExecFunc(v MangekyoCustomViewPortalCommandDefine) func(ectx *hhc_ast.ExecUserContext) {
|
|
|
+ return func(ectx *hhc_ast.ExecUserContext) {
|
|
|
+ fview := v.GetViewNameFunc
|
|
|
+ fprompt := v.GetPromptFunc
|
|
|
+ ftitle := v.GetTitleFunc
|
|
|
+ ectx.ChangeView(fview(uv.ctx))
|
|
|
+ ectx.ChangePrompt(fprompt(uv.ctx))
|
|
|
+ ectx.ChangeTitle(ftitle(uv.ctx))
|
|
|
+ }
|
|
|
+}
|