Fix help page
This commit is contained in:
parent
0320f2877e
commit
c8f10dcc55
@ -19,7 +19,7 @@ type Chat struct {
|
|||||||
Offset int
|
Offset int
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateChat is the constructor for the Chat struct
|
// CreateChatComponent is the constructor for the Chat struct
|
||||||
func CreateChatComponent(inputHeight int) *Chat {
|
func CreateChatComponent(inputHeight int) *Chat {
|
||||||
chat := &Chat{
|
chat := &Chat{
|
||||||
List: termui.NewList(),
|
List: termui.NewList(),
|
||||||
@ -307,21 +307,25 @@ func (c *Chat) MessageToCells(msg Message) []termui.Cell {
|
|||||||
|
|
||||||
// Help shows the usage and key bindings in the chat pane
|
// Help shows the usage and key bindings in the chat pane
|
||||||
func (c *Chat) Help(usage string, cfg *config.Config) {
|
func (c *Chat) Help(usage string, cfg *config.Config) {
|
||||||
help := []Message{
|
msgUsage := Message{
|
||||||
Message{
|
ID: fmt.Sprintf("%d", time.Now().UnixNano()),
|
||||||
Content: usage,
|
Content: usage,
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for mode, mapping := range cfg.KeyMap {
|
c.Messages[msgUsage.ID] = msgUsage
|
||||||
help = append(
|
|
||||||
help,
|
|
||||||
Message{
|
|
||||||
Content: fmt.Sprintf("%s", strings.ToUpper(mode)),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
help = append(help, Message{Content: ""})
|
for mode, mapping := range cfg.KeyMap {
|
||||||
|
msgMode := Message{
|
||||||
|
ID: fmt.Sprintf("%d", time.Now().UnixNano()),
|
||||||
|
Content: fmt.Sprintf("%s", strings.ToUpper(mode)),
|
||||||
|
}
|
||||||
|
c.Messages[msgMode.ID] = msgMode
|
||||||
|
|
||||||
|
msgNewline := Message{
|
||||||
|
ID: fmt.Sprintf("%d", time.Now().UnixNano()),
|
||||||
|
Content: "",
|
||||||
|
}
|
||||||
|
c.Messages[msgNewline.ID] = msgNewline
|
||||||
|
|
||||||
var keys []string
|
var keys []string
|
||||||
for k := range mapping {
|
for k := range mapping {
|
||||||
@ -330,18 +334,14 @@ func (c *Chat) Help(usage string, cfg *config.Config) {
|
|||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
help = append(
|
msgKey := Message{
|
||||||
help,
|
ID: fmt.Sprintf("%d", time.Now().UnixNano()),
|
||||||
Message{
|
Content: fmt.Sprintf(" %-12s%-15s", k, mapping[k]),
|
||||||
Content: fmt.Sprintf(" %-12s%-15s", k, mapping[k]),
|
}
|
||||||
},
|
c.Messages[msgKey.ID] = msgKey
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
help = append(help, Message{Content: ""})
|
msgNewline.ID = fmt.Sprintf("%d", time.Now().UnixNano())
|
||||||
}
|
c.Messages[msgNewline.ID] = msgNewline
|
||||||
|
|
||||||
for _, msg := range help {
|
|
||||||
c.Messages[msg.ID] = msg
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,6 +500,7 @@ func actionScrollDownChat(ctx *context.AppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func actionHelp(ctx *context.AppContext) {
|
func actionHelp(ctx *context.AppContext) {
|
||||||
|
ctx.View.Chat.ClearMessages()
|
||||||
ctx.View.Chat.Help(ctx.Usage, ctx.Config)
|
ctx.View.Chat.Help(ctx.Usage, ctx.Config)
|
||||||
termui.Render(ctx.View.Chat)
|
termui.Render(ctx.View.Chat)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user