Add raw command to view raw terminal esc codes

This commit is contained in:
Zachary Yedidia
2017-11-29 01:06:16 -05:00
parent acd42df13c
commit bdb699211a
7 changed files with 51 additions and 7 deletions

View File

@@ -57,6 +57,7 @@ func init() {
"TabSwitch": TabSwitch,
"MemUsage": MemUsage,
"Retab": Retab,
"Raw": Raw,
}
}
@@ -113,6 +114,7 @@ func DefaultCommands() map[string]StrCommand {
"tabswitch": {"TabSwitch", []Completion{NoCompletion}},
"memusage": {"MemUsage", []Completion{NoCompletion}},
"retab": {"Retab", []Completion{NoCompletion}},
"raw": {"Raw", []Completion{NoCompletion}},
}
}
@@ -203,6 +205,26 @@ func Retab(args []string) {
CurView().Retab(true)
}
func Raw(args []string) {
buf := NewBufferFromString("", "Raw events")
view := NewView(buf)
view.Buf.Insert(view.Cursor.Loc, "Warning: Showing raw event escape codes\n")
view.Buf.Insert(view.Cursor.Loc, "Use CtrlQ to exit\n")
view.Type = vtRaw
tab := NewTabFromView(view)
tab.SetNum(len(tabs))
tabs = append(tabs, tab)
curTab = len(tabs) - 1
if len(tabs) == 2 {
for _, t := range tabs {
for _, v := range t.views {
v.ToggleTabbar()
}
}
}
}
// TabSwitch switches to a given tab either by name or by number
func TabSwitch(args []string) {
if len(args) > 0 {