diff --git a/components/debug.go b/components/debug.go index 17928ea..22f44f9 100644 --- a/components/debug.go +++ b/components/debug.go @@ -3,45 +3,48 @@ package components import "github.com/erroneousboat/termui" type Debug struct { - Par *termui.Par + Par *termui.Par + List *termui.List } -func CreateDebugComponent() *Debug { +func CreateDebugComponent(inputHeight int) *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 } // Buffer implements interface termui.Bufferer func (d *Debug) Buffer() termui.Buffer { - return d.Par.Buffer() + return d.List.Buffer() } // GetHeight implements interface termui.GridBufferer func (d *Debug) GetHeight() int { - return d.Par.Block.GetHeight() + return d.List.Block.GetHeight() } // SetWidth implements interface termui.GridBufferer func (d *Debug) SetWidth(w int) { - d.Par.SetWidth(w) + d.List.SetWidth(w) } // SetX implements interface termui.GridBufferer func (d *Debug) SetX(x int) { - d.Par.SetX(x) + d.List.SetX(x) } // SetY implements interface termui.GridBufferer func (d *Debug) SetY(y int) { - d.Par.SetY(y) + d.List.SetY(y) } -// SetText will set the text of the Debug component -func (d *Debug) SetText(text string) { - d.Par.Text = text +// Println will add the text to the Debug component +func (d *Debug) Println(text string) { + d.List.Items = append(d.List.Items, text) + termui.Render(d) } diff --git a/components/mode.go b/components/mode.go index aa65f70..799a5eb 100644 --- a/components/mode.go +++ b/components/mode.go @@ -80,3 +80,18 @@ func (m *Mode) SetX(x int) { func (m *Mode) SetY(y int) { 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) +} diff --git a/context/context.go b/context/context.go index 1db9e00..7d2dbe6 100644 --- a/context/context.go +++ b/context/context.go @@ -48,12 +48,12 @@ func CreateAppContext(flgConfig string, flgDebug bool) (*AppContext, error) { termui.Body.AddRows( termui.NewRow( 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.NewCol(config.SidebarWidth, 0, view.Mode), - termui.NewCol(config.MainWidth-1, 0, view.Input), - termui.NewCol(1, 0, view.Debug), + termui.NewCol(config.MainWidth, 0, view.Input), ), ) } else { diff --git a/handlers/event.go b/handlers/event.go index 74048ab..15b3770 100644 --- a/handlers/event.go +++ b/handlers/event.go @@ -238,20 +238,17 @@ func actionQuit(ctx *context.AppContext) { func actionInsertMode(ctx *context.AppContext) { ctx.Mode = context.InsertMode - ctx.View.Mode.Par.Text = "INSERT" - termui.Render(ctx.View.Mode) + ctx.View.Mode.SetInsertMode() } func actionCommandMode(ctx *context.AppContext) { ctx.Mode = context.CommandMode - ctx.View.Mode.Par.Text = "NORMAL" - termui.Render(ctx.View.Mode) + ctx.View.Mode.SetCommandMode() } func actionSearchMode(ctx *context.AppContext) { ctx.Mode = context.SearchMode - ctx.View.Mode.Par.Text = "SEARCH" - termui.Render(ctx.View.Mode) + ctx.View.Mode.SetSearchMode() } func actionGetMessages(ctx *context.AppContext) { diff --git a/views/view.go b/views/view.go index f892c36..cdf81e5 100644 --- a/views/view.go +++ b/views/view.go @@ -38,7 +38,7 @@ func CreateView(svc *service.SlackService) *View { chat.SetMessages(slackMsgs) // Debug: create the component - debug := components.CreateDebugComponent() + debug := components.CreateDebugComponent(input.Par.Height) // Mode: create the component mode := components.CreateModeComponent()