2020-09-08 02:49:25 +02:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
2022-03-06 21:44:02 +01:00
|
|
|
"maunium.net/go/mauview"
|
2020-09-13 16:16:47 +02:00
|
|
|
"maunium.net/go/tcell"
|
2020-09-08 02:49:25 +02:00
|
|
|
|
2022-03-06 21:44:02 +01:00
|
|
|
"maunium.net/go/gomuks/config"
|
2020-09-08 02:49:25 +02:00
|
|
|
)
|
|
|
|
|
2020-09-13 16:16:47 +02:00
|
|
|
const helpText = `# General
|
|
|
|
/help - Show this help dialog.
|
2020-09-08 02:49:25 +02:00
|
|
|
/quit - Quit gomuks.
|
|
|
|
/clearcache - Clear cache and quit gomuks.
|
|
|
|
/logout - Log out of Matrix.
|
|
|
|
/toggle <thing> - Temporary command to toggle various UI features.
|
2022-03-06 21:44:30 +01:00
|
|
|
Run /toggle without arguments to see the list of toggles.
|
2020-09-08 02:49:25 +02:00
|
|
|
|
2020-11-01 17:24:37 +01:00
|
|
|
# Media
|
|
|
|
/download [path] - Downloads file from selected message.
|
|
|
|
/open [path] - Download file from selected message and open it with xdg-open.
|
|
|
|
/upload <path> - Upload the file at the given path to the current room.
|
|
|
|
|
2020-09-08 02:49:25 +02:00
|
|
|
# Sending special messages
|
|
|
|
/me <message> - Send an emote message.
|
|
|
|
/notice <message> - Send a notice (generally used for bot messages).
|
2020-09-13 16:16:47 +02:00
|
|
|
/rainbow <message> - Send rainbow text.
|
2020-09-08 02:49:25 +02:00
|
|
|
/rainbowme <message> - Send rainbow text in an emote.
|
|
|
|
/reply [text] - Reply to the selected message.
|
|
|
|
/react <reaction> - 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 <user id> - View the device list of a user.
|
|
|
|
/device <user id> <device id> - Show info about a specific device.
|
|
|
|
/unverify <user id> <device id> - Un-verify a device.
|
|
|
|
/blacklist <user id> <device id> - Blacklist a device.
|
2021-02-24 11:12:21 +01:00
|
|
|
/verify <user id> - Verify a user with in-room verification. Probably broken.
|
|
|
|
/verify-device <user id> <device id> [fingerprint]
|
2020-09-08 02:49:25 +02:00
|
|
|
- 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 <file> - Import encryption keys
|
|
|
|
/export <file> - Export encryption keys
|
|
|
|
/export-room <file> - Export encryption keys for the current room.
|
|
|
|
|
|
|
|
# Rooms
|
|
|
|
/pm <user id> <...> - Create a private chat with the given user(s).
|
|
|
|
/create [room name] - Create a room.
|
|
|
|
|
|
|
|
/join <room> [server] - Join a room.
|
|
|
|
/accept - Accept the invite.
|
|
|
|
/reject - Reject the invite.
|
|
|
|
|
|
|
|
/invite <user id> - Invite the given user to the room.
|
|
|
|
/roomnick <name> - Change your per-room displayname.
|
|
|
|
/tag <tag> <priority> - Add the room to <tag>.
|
|
|
|
/untag <tag> - Remove the room from <tag>.
|
|
|
|
/tags - List the tags the room is in.
|
|
|
|
/alias <act> <name> - Add or remove local addresses.
|
|
|
|
|
|
|
|
/leave - Leave the current room.
|
|
|
|
/kick <user id> [reason] - Kick a user.
|
|
|
|
/ban <user id> [reason] - Ban a user.
|
|
|
|
/unban <user id> - Unban a user.`
|
|
|
|
|
2020-09-13 16:16:47 +02:00
|
|
|
type HelpModal struct {
|
|
|
|
mauview.FocusableComponent
|
|
|
|
parent *MainView
|
|
|
|
}
|
2020-09-08 02:49:25 +02:00
|
|
|
|
2020-09-13 16:16:47 +02:00
|
|
|
func NewHelpModal(parent *MainView) *HelpModal {
|
|
|
|
hm := &HelpModal{parent: parent}
|
2020-09-08 02:49:25 +02:00
|
|
|
|
2020-09-13 16:16:47 +02:00
|
|
|
text := mauview.NewTextView().
|
2020-09-08 02:49:25 +02:00
|
|
|
SetText(helpText).
|
|
|
|
SetScrollable(true).
|
2021-04-04 00:09:27 +02:00
|
|
|
SetWrap(false).
|
|
|
|
SetTextColor(tcell.ColorDefault)
|
2020-09-08 02:49:25 +02:00
|
|
|
|
2020-09-13 16:16:47 +02:00
|
|
|
box := mauview.NewBox(text).
|
2020-09-08 02:49:25 +02:00
|
|
|
SetBorder(true).
|
|
|
|
SetTitle("Help").
|
|
|
|
SetBlurCaptureFunc(func() bool {
|
|
|
|
hm.parent.HideModal()
|
|
|
|
return true
|
|
|
|
})
|
2020-09-13 16:16:47 +02:00
|
|
|
box.Focus()
|
2020-09-08 02:49:25 +02:00
|
|
|
|
2020-09-13 16:16:47 +02:00
|
|
|
hm.FocusableComponent = mauview.FractionalCenter(box, 42, 10, 0.5, 0.5)
|
2020-09-08 02:49:25 +02:00
|
|
|
|
|
|
|
return hm
|
|
|
|
}
|
|
|
|
|
|
|
|
func (hm *HelpModal) OnKeyEvent(event mauview.KeyEvent) bool {
|
2021-12-07 14:18:59 +01:00
|
|
|
kb := config.Keybind{
|
|
|
|
Key: event.Key(),
|
|
|
|
Ch: event.Rune(),
|
|
|
|
Mod: event.Modifiers(),
|
|
|
|
}
|
2022-03-06 21:44:02 +01:00
|
|
|
// TODO unhardcode q
|
|
|
|
if hm.parent.config.Keybindings.Modal[kb] == "cancel" || event.Rune() == 'q' {
|
2020-09-13 16:16:47 +02:00
|
|
|
hm.parent.HideModal()
|
2020-09-08 02:49:25 +02:00
|
|
|
return true
|
|
|
|
}
|
2020-09-13 16:16:47 +02:00
|
|
|
return hm.FocusableComponent.OnKeyEvent(event)
|
2020-09-08 02:49:25 +02:00
|
|
|
}
|