Remove unnecessary Frame from layout
MODIFY
internal/ui/window.go
internal/ui/window.go
@@ -215,6 +215,7 @@ func NewWindow(discord *discordgo.Session) (*Window, error) {
messageToSend := window.messageInput.GetText()
window.messageInput.SetText("")
+ if len(messageToSend) != 0 {
guild, discordError := window.session.State.Guild(window.selectedGuild.ID)
if discordError == nil {
@@ -255,10 +256,14 @@ func NewWindow(discord *discordgo.Session) (*Window, error) {
} else {
go discord.ChannelMessageSend(window.selectedChannel.ID, messageToSend)
}
+ } else {
+ dialog := tview.NewModal()
+ window.app.SetRoot(dialog, false)
}
return nil
}
+ }
return event
})
@@ -278,19 +283,11 @@ func NewWindow(discord *discordgo.Session) (*Window, error) {
window.rootContainer = tview.NewFlex()
window.rootContainer.SetDirection(tview.FlexColumn)
- window.rootContainer.SetBorderPadding(-1, -1, 0, 0)
-
- window.RefreshLayout()
+ window.rootContainer.SetTitleAlign(tview.AlignCenter)
- if config.GetConfig().ShowFrame {
- frame := tview.NewFrame(window.rootContainer)
- frame.SetBorder(true)
- frame.SetTitleAlign(tview.AlignCenter)
- frame.SetTitle("Cordless")
- app.SetRoot(frame, true)
- } else {
app.SetRoot(window.rootContainer, true)
- }
+
+ window.RefreshLayout()
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Rune() == 'U' &&
@@ -335,19 +332,31 @@ func NewWindow(discord *discordgo.Session) (*Window, error) {
return &window, nil
}
+//RefreshLayout removes and adds the main parts of the layout
+//so that the ones that are disabled by settings do not show up.
func (window *Window) RefreshLayout() {
window.rootContainer.RemoveItem(window.leftArea)
window.rootContainer.RemoveItem(window.chatArea)
window.rootContainer.RemoveItem(window.userContainer)
window.rootContainer.AddItem(window.leftArea, 0, 7, true)
- if config.GetConfig().ShowUserContainer {
+
+ conf := config.GetConfig()
+ if conf.ShowUserContainer {
window.rootContainer.AddItem(window.chatArea, 0, 20, false)
window.rootContainer.AddItem(window.userContainer, 0, 6, false)
} else {
window.rootContainer.AddItem(window.chatArea, 0, 26, false)
}
+ if conf.ShowFrame {
+ window.rootContainer.SetTitle("Cordless")
+ window.rootContainer.SetBorder(true)
+ } else {
+ window.rootContainer.SetTitle("")
+ window.rootContainer.SetBorder(false)
+ }
+
window.app.ForceDraw()
}

Remove unnecessary Frame from layout