1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

tui, created flex with message selection form

This commit is contained in:
postmannen 2022-01-18 12:12:25 +01:00
parent 348b7b2d63
commit 4d07bab7a2

16
tui.go
View file

@ -388,6 +388,7 @@ func drawMessageInputFields(p slideMessageEdit, m tuiMessage) {
// them later in the code.
type slideMessageEdit struct {
flex *tview.Flex
selectMessage *tview.Form
inputForm *tview.Form
outputForm *tview.TextView
logForm *tview.TextView
@ -399,6 +400,9 @@ func (t *tui) messageSlide(app *tview.Application) tview.Primitive {
p := slideMessageEdit{}
p.selectMessage = tview.NewForm()
p.selectMessage.SetBorder(true).SetTitle("Select Message").SetTitleAlign(tview.AlignLeft)
p.inputForm = tview.NewForm()
p.inputForm.SetBorder(true).SetTitle("Message input").SetTitleAlign(tview.AlignLeft)
@ -427,7 +431,13 @@ func (t *tui) messageSlide(app *tview.Application) tview.Primitive {
p.flex = tview.NewFlex().SetDirection(tview.FlexRow).
// Add a flex for the top windows with columns.
AddItem(tview.NewFlex().SetDirection(tview.FlexColumn).
AddItem(p.inputForm, 0, 10, false).
// Add a new flex for splitting output form horizontally.
AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
// Add the select message form.
AddItem(p.selectMessage, 0, 2, false).
// Add the input message form.
AddItem(p.inputForm, 0, 10, false),
0, 10, false).
// Add a new flex for splitting output form horizontally.
AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
// Add the message output form.
@ -484,13 +494,13 @@ func (t *tui) messageSlide(app *tview.Application) tview.Primitive {
p.inputForm.Clear(false)
// Add a self dropdown when selected since it is not a
// part of drawing the input fields function.
p.inputForm.AddFormItem(messageDropdown)
p.selectMessage.AddFormItem(messageDropdown)
fmt.Fprintf(p.logForm, " * message read: %v\n", m)
drawMessageInputFields(p, m)
})
// Clear the form.
p.inputForm.Clear(false)
p.inputForm.AddFormItem(messageDropdown)
p.selectMessage.AddFormItem(messageDropdown)
p.inputForm.AddButton("update message dropdown menu", func() {
// TODO: for message message dropdown