package ui import ( "maunium.net/go/mauview" "maunium.net/go/tcell" "maunium.net/go/gomuks/config" ) const helpText = `# General /help - Show this help dialog. /quit - Quit gomuks. /clearcache - Clear cache and quit gomuks. /logout - Log out of Matrix. /toggle - Temporary command to toggle various UI features. Run /toggle without arguments to see the list of toggles. # Media /download [path] - Downloads file from selected message. /open [path] - Download file from selected message and open it with xdg-open. /upload - Upload the file at the given path to the current room. # Sending special messages /me - Send an emote message. /notice - Send a notice (generally used for bot messages). /rainbow - Send rainbow text. /rainbowme - Send rainbow text in an emote. /reply [text] - Reply to the selected message. /react - React to the selected message. /redact [reason] - Redact the selected message. /edit - Edit the selected message. # Encryption /fingerprint - View the fingerprint of your device. /devices - View the device list of a user. /device - Show info about a specific device. /unverify - Un-verify a device. /blacklist - Blacklist a device. /verify - Verify a user with in-room verification. Probably broken. /verify-device [fingerprint] - Verify a device. If the fingerprint is not provided, interactive emoji verification will be started. /reset-session - Reset the outbound Megolm session in the current room. /import - Import encryption keys /export - Export encryption keys /export-room - Export encryption keys for the current room. # Rooms /pm <...> - Create a private chat with the given user(s). /create [room name] - Create a room. /join [server] - Join a room. /accept - Accept the invite. /reject - Reject the invite. /invite - Invite the given user to the room. /roomnick - Change your per-room displayname. /tag - Add the room to . /untag - Remove the room from . /tags - List the tags the room is in. /alias - Add or remove local addresses. /leave - Leave the current room. /kick [reason] - Kick a user. /ban [reason] - Ban a user. /unban - Unban a user.` type HelpModal struct { mauview.FocusableComponent parent *MainView } func NewHelpModal(parent *MainView) *HelpModal { hm := &HelpModal{parent: parent} text := mauview.NewTextView(). SetText(helpText). SetScrollable(true). SetWrap(false). SetTextColor(tcell.ColorDefault) box := mauview.NewBox(text). SetBorder(true). SetTitle("Help"). SetBlurCaptureFunc(func() bool { hm.parent.HideModal() return true }) box.Focus() hm.FocusableComponent = mauview.FractionalCenter(box, 42, 10, 0.5, 0.5) return hm } func (hm *HelpModal) OnKeyEvent(event mauview.KeyEvent) bool { kb := config.Keybind{ Key: event.Key(), Ch: event.Rune(), Mod: event.Modifiers(), } // TODO unhardcode q if hm.parent.config.Keybindings.Modal[kb] == "cancel" || event.Rune() == 'q' { hm.parent.HideModal() return true } return hm.FocusableComponent.OnKeyEvent(event) }