Add new command for togglnig the channnel header
MODIFY
internal/app.go
internal/app.go
@@ -57,6 +57,7 @@ func Run() {
}
window.RegisterCommand("fixlayout", commands.FixLayout)
+ window.RegisterCommand("chatheader", commands.ChatHeader)
runError := window.Run()
if runError != nil {

ADD
internal/commands/chatheader.go
+package commands
+
+import (
+ "fmt"
+ "io"
+ "strconv"
+
+ "github.com/Bios-Marcel/cordless/internal/config"
+ "github.com/Bios-Marcel/cordless/internal/ui"
+)
+
+func ChatHeader(writer io.Writer, window *ui.Window, parameters []string) {
+ if len(parameters) == 1 {
+ choice, parseError := strconv.ParseBool(parameters[0])
+ if parseError != nil {
+ printHelp(writer)
+ return
+ }
+
+ config.GetConfig().ShowChatHeader = choice
+ window.RefreshLayout()
+
+ persistError := config.PersistConfig()
+ if persistError != nil {
+ fmt.Fprintf(writer, "Error saving configuration: %s\n", persistError.Error())
+ return
+ }
+
+ if choice {
+ fmt.Fprintln(writer, "Chatheader has been enabled")
+ } else {
+ fmt.Fprintln(writer, "Chatheader has been disabled")
+ }
+ } else {
+ printHelp(writer)
+ }
+}
+
+func printHelp(writer io.Writer) {
+ fmt.Fprintf(writer, "Usage: chatheader <true/false>\n")
+}

MODIFY
internal/config/config.go
internal/config/config.go
@@ -27,6 +27,7 @@ var (
currentConfig = Config{
Times: HourMinuteAndSeconds,
ShowUserContainer: true,
+ ShowChatHeader: true,
ShowFrame: true,
UseFixedLayout: false,
FixedSizeLeft: 12,
@@ -46,6 +47,10 @@ type Config struct {
//layout or not.
ShowUserContainer bool
+ //ShowChatHeader decides wether the box above the chat will be shown
+ //or not.
+ ShowChatHeader bool
+
//ShowFrame decides wether the application will have a border and a title.
ShowFrame bool

MODIFY
internal/ui/window.go
internal/ui/window.go
@@ -726,9 +726,19 @@ func (window *Window) RefreshLayout() {
}
}
+ window.chatArea.RemoveItem(window.channelTitle)
+ window.chatArea.RemoveItem(window.messageContainer)
+ window.chatArea.RemoveItem(window.messageInput)
window.chatArea.RemoveItem(window.commandInput)
window.chatArea.RemoveItem(window.commandOutput)
+ if conf.ShowChatHeader {
+ window.chatArea.AddItem(window.channelTitle, 3, 0, false)
+ }
+
+ window.chatArea.AddItem(window.messageContainer, 0, 1, false)
+ window.chatArea.AddItem(window.messageInput, 3, 0, false)
+
if window.commandMode {
window.chatArea.AddItem(window.commandOutput, 0, 1, false)
window.chatArea.AddItem(window.commandInput, 3, 0, false)

Add new command for togglnig the channnel header