Update Debug component
This commit is contained in:
parent
e38115970d
commit
336bf288dd
@ -4,44 +4,47 @@ import "github.com/erroneousboat/termui"
|
|||||||
|
|
||||||
type Debug struct {
|
type Debug struct {
|
||||||
Par *termui.Par
|
Par *termui.Par
|
||||||
|
List *termui.List
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateDebugComponent() *Debug {
|
func CreateDebugComponent(inputHeight int) *Debug {
|
||||||
debug := &Debug{
|
debug := &Debug{
|
||||||
Par: termui.NewPar(""),
|
List: termui.NewList(),
|
||||||
}
|
}
|
||||||
|
|
||||||
debug.Par.Height = 3
|
debug.List.BorderLabel = "Debug"
|
||||||
|
debug.List.Height = termui.TermHeight() - inputHeight
|
||||||
|
|
||||||
return debug
|
return debug
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buffer implements interface termui.Bufferer
|
// Buffer implements interface termui.Bufferer
|
||||||
func (d *Debug) Buffer() termui.Buffer {
|
func (d *Debug) Buffer() termui.Buffer {
|
||||||
return d.Par.Buffer()
|
return d.List.Buffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHeight implements interface termui.GridBufferer
|
// GetHeight implements interface termui.GridBufferer
|
||||||
func (d *Debug) GetHeight() int {
|
func (d *Debug) GetHeight() int {
|
||||||
return d.Par.Block.GetHeight()
|
return d.List.Block.GetHeight()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWidth implements interface termui.GridBufferer
|
// SetWidth implements interface termui.GridBufferer
|
||||||
func (d *Debug) SetWidth(w int) {
|
func (d *Debug) SetWidth(w int) {
|
||||||
d.Par.SetWidth(w)
|
d.List.SetWidth(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetX implements interface termui.GridBufferer
|
// SetX implements interface termui.GridBufferer
|
||||||
func (d *Debug) SetX(x int) {
|
func (d *Debug) SetX(x int) {
|
||||||
d.Par.SetX(x)
|
d.List.SetX(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetY implements interface termui.GridBufferer
|
// SetY implements interface termui.GridBufferer
|
||||||
func (d *Debug) SetY(y int) {
|
func (d *Debug) SetY(y int) {
|
||||||
d.Par.SetY(y)
|
d.List.SetY(y)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetText will set the text of the Debug component
|
// Println will add the text to the Debug component
|
||||||
func (d *Debug) SetText(text string) {
|
func (d *Debug) Println(text string) {
|
||||||
d.Par.Text = text
|
d.List.Items = append(d.List.Items, text)
|
||||||
|
termui.Render(d)
|
||||||
}
|
}
|
||||||
|
@ -80,3 +80,18 @@ func (m *Mode) SetX(x int) {
|
|||||||
func (m *Mode) SetY(y int) {
|
func (m *Mode) SetY(y int) {
|
||||||
m.Par.SetY(y)
|
m.Par.SetY(y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Mode) SetInsertMode() {
|
||||||
|
m.Par.Text = "INSERT"
|
||||||
|
termui.Render(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Mode) SetCommandMode() {
|
||||||
|
m.Par.Text = "NORMAL"
|
||||||
|
termui.Render(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Mode) SetSearchMode() {
|
||||||
|
m.Par.Text = "SEARCH"
|
||||||
|
termui.Render(m)
|
||||||
|
}
|
||||||
|
@ -48,12 +48,12 @@ func CreateAppContext(flgConfig string, flgDebug bool) (*AppContext, error) {
|
|||||||
termui.Body.AddRows(
|
termui.Body.AddRows(
|
||||||
termui.NewRow(
|
termui.NewRow(
|
||||||
termui.NewCol(config.SidebarWidth, 0, view.Channels),
|
termui.NewCol(config.SidebarWidth, 0, view.Channels),
|
||||||
termui.NewCol(config.MainWidth, 0, view.Chat),
|
termui.NewCol(config.MainWidth-5, 0, view.Chat),
|
||||||
|
termui.NewCol(config.MainWidth-6, 0, view.Debug),
|
||||||
),
|
),
|
||||||
termui.NewRow(
|
termui.NewRow(
|
||||||
termui.NewCol(config.SidebarWidth, 0, view.Mode),
|
termui.NewCol(config.SidebarWidth, 0, view.Mode),
|
||||||
termui.NewCol(config.MainWidth-1, 0, view.Input),
|
termui.NewCol(config.MainWidth, 0, view.Input),
|
||||||
termui.NewCol(1, 0, view.Debug),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -238,20 +238,17 @@ func actionQuit(ctx *context.AppContext) {
|
|||||||
|
|
||||||
func actionInsertMode(ctx *context.AppContext) {
|
func actionInsertMode(ctx *context.AppContext) {
|
||||||
ctx.Mode = context.InsertMode
|
ctx.Mode = context.InsertMode
|
||||||
ctx.View.Mode.Par.Text = "INSERT"
|
ctx.View.Mode.SetInsertMode()
|
||||||
termui.Render(ctx.View.Mode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func actionCommandMode(ctx *context.AppContext) {
|
func actionCommandMode(ctx *context.AppContext) {
|
||||||
ctx.Mode = context.CommandMode
|
ctx.Mode = context.CommandMode
|
||||||
ctx.View.Mode.Par.Text = "NORMAL"
|
ctx.View.Mode.SetCommandMode()
|
||||||
termui.Render(ctx.View.Mode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func actionSearchMode(ctx *context.AppContext) {
|
func actionSearchMode(ctx *context.AppContext) {
|
||||||
ctx.Mode = context.SearchMode
|
ctx.Mode = context.SearchMode
|
||||||
ctx.View.Mode.Par.Text = "SEARCH"
|
ctx.View.Mode.SetSearchMode()
|
||||||
termui.Render(ctx.View.Mode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func actionGetMessages(ctx *context.AppContext) {
|
func actionGetMessages(ctx *context.AppContext) {
|
||||||
|
@ -38,7 +38,7 @@ func CreateView(svc *service.SlackService) *View {
|
|||||||
chat.SetMessages(slackMsgs)
|
chat.SetMessages(slackMsgs)
|
||||||
|
|
||||||
// Debug: create the component
|
// Debug: create the component
|
||||||
debug := components.CreateDebugComponent()
|
debug := components.CreateDebugComponent(input.Par.Height)
|
||||||
|
|
||||||
// Mode: create the component
|
// Mode: create the component
|
||||||
mode := components.CreateModeComponent()
|
mode := components.CreateModeComponent()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user