terminal/command: Support for dumb terminal
Support for dumb terminal Fixes #252
This commit is contained in:
parent
af16cfa90b
commit
76b9aa03bb
@ -47,6 +47,8 @@ type Commands struct {
|
|||||||
client service.Client
|
client service.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var dumbTerminal = strings.ToLower(os.Getenv("TERM")) == "dumb"
|
||||||
|
|
||||||
// Returns a Commands struct with default commands defined.
|
// Returns a Commands struct with default commands defined.
|
||||||
func DebugCommands(client service.Client) *Commands {
|
func DebugCommands(client service.Client) *Commands {
|
||||||
c := &Commands{client: client}
|
c := &Commands{client: client}
|
||||||
@ -733,7 +735,11 @@ func printcontext(state *api.DebuggerState) error {
|
|||||||
}
|
}
|
||||||
if len(state.CurrentThread.File) == 0 {
|
if len(state.CurrentThread.File) == 0 {
|
||||||
fmt.Printf("Stopped at: 0x%x\n", state.CurrentThread.PC)
|
fmt.Printf("Stopped at: 0x%x\n", state.CurrentThread.PC)
|
||||||
fmt.Printf("\033[34m=>\033[0m no source available\n")
|
if dumbTerminal {
|
||||||
|
fmt.Printf("=> no source available\n")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("\033[34m=>\033[0m no source available\n")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
var fn *api.Function
|
var fn *api.Function
|
||||||
@ -817,10 +823,18 @@ func printfile(filename string, line int, showArrow bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var lineNum string
|
var lineNum string
|
||||||
if i < 10 {
|
if dumbTerminal {
|
||||||
lineNum = fmt.Sprintf("\033[34m%s %d\033[0m:\t", arrow, i)
|
if i < 10 {
|
||||||
|
lineNum = fmt.Sprintf("%s %d:\t", arrow, i)
|
||||||
|
} else {
|
||||||
|
lineNum = fmt.Sprintf("%s %d:\t", arrow, i)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
lineNum = fmt.Sprintf("\033[34m%s %d\033[0m:\t", arrow, i)
|
if i < 10 {
|
||||||
|
lineNum = fmt.Sprintf("\033[34m%s %d\033[0m:\t", arrow, i)
|
||||||
|
} else {
|
||||||
|
lineNum = fmt.Sprintf("\033[34m%s %d\033[0m:\t", arrow, i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
context = append(context, lineNum+line)
|
context = append(context, lineNum+line)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user