aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-04-01 10:05:29 +0300
committerTulir Asokan <tulir@maunium.net>2018-04-02 13:47:20 +0300
commitdd89fa621d6824edf96c61e47099f1c6ad0bfd09 (patch)
treedcdd2b703c6476979eac25cffb6b8302cb444422 /ui
parentc6e9f498a4d4c12460c73d8d3358742ed60b7816 (diff)
Improve debug output options
Diffstat (limited to 'ui')
-rw-r--r--ui/debug/debug.go44
1 files changed, 38 insertions, 6 deletions
diff --git a/ui/debug/debug.go b/ui/debug/debug.go
index a87d64c..3f47980 100644
--- a/ui/debug/debug.go
+++ b/ui/debug/debug.go
@@ -35,10 +35,12 @@ type Printer interface {
type Pane struct {
*tview.TextView
Height int
+ Width int
num int
}
var Default Printer
+var RedirectAllExt bool
func NewPane() *Pane {
pane := tview.NewTextView()
@@ -52,6 +54,7 @@ func NewPane() *Pane {
return &Pane{
TextView: pane,
Height: 35,
+ Width: 80,
num: 0,
}
}
@@ -69,20 +72,49 @@ func (db *Pane) WriteString(text string) {
fmt.Fprintf(db, "[%d] %s", db.num, text)
}
-func (db *Pane) Wrap(main tview.Primitive) tview.Primitive {
- return tview.NewGrid().SetRows(0, db.Height).SetColumns(0).
- AddItem(main, 0, 0, 1, 1, 1, 1, true).
- AddItem(db, 1, 0, 1, 1, 1, 1, false)
+type PaneSide int
+
+const (
+ Top PaneSide = iota
+ Bottom
+ Left
+ Right
+)
+
+func (db *Pane) Wrap(main tview.Primitive, side PaneSide) tview.Primitive {
+ rows, columns := []int{0}, []int{0}
+ mainRow, mainColumn, paneRow, paneColumn := 0, 0, 0, 0
+ switch side {
+ case Top:
+ rows = []int{db.Height, 0}
+ mainRow = 1
+ case Bottom:
+ rows = []int{0, db.Height}
+ paneRow = 1
+ case Left:
+ columns = []int{db.Width, 0}
+ mainColumn = 1
+ case Right:
+ columns = []int{0, db.Width}
+ paneColumn = 1
+ }
+ return tview.NewGrid().SetRows(rows...).SetColumns(columns...).
+ AddItem(main, mainRow, mainColumn, 1, 1, 1, 1, true).
+ AddItem(db, paneRow, paneColumn, 1, 1, 1, 1, false)
}
func Printf(text string, args ...interface{}) {
- if Default != nil {
+ if RedirectAllExt {
+ ExtPrintf(text, args...)
+ } else if Default != nil {
Default.Printf(text, args...)
}
}
func Print(text ...interface{}) {
- if Default != nil {
+ if RedirectAllExt {
+ ExtPrint(text...)
+ } else if Default != nil {
Default.Print(text...)
}
}