Debian Codegraph @

ui/help-modal.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 package ui
2
3 import (
4 "go.mau.fi/mauview"
•5 "github.com/gdamore/tcell/v2"
6
7 "maunium.net/go/gomuks/config"
8 )
9
10 const helpText = `# General
11 /help - Show this help dialog.
12 /quit - Quit gomuks.
13 /clearcache - Clear cache and quit gomuks.
14 /logout - Log out of Matrix.
15 /toggle <thing> - Temporary command to toggle various UI features.
16 Run /toggle without arguments to see the list of toggles.
17
18 # Media
19 /download [path] - Downloads file from selected message.
20 /open [path] - Download file from selected message and open it with xdg-open.
21 /upload <path> - Upload the file at the given path to the current room.
22
23 # Sending special messages
24 /me <message> - Send an emote message.
25 /notice <message> - Send a notice (generally used for bot messages).
26 /rainbow <message> - Send rainbow text.
27 /rainbowme <message> - Send rainbow text in an emote.
28 /reply [text] - Reply to the selected message.
29 /react <reaction> - React to the selected message.
30 /redact [reason] - Redact the selected message.
31 /edit - Edit the selected message.
32
33 # Encryption
34 /fingerprint - View the fingerprint of your device.
35
36 /devices <user id> - View the device list of a user.
37 /device <user id> <device id> - Show info about a specific device.
38 /unverify <user id> <device id> - Un-verify a device.
39 /blacklist <user id> <device id> - Blacklist a device.
40 /verify <user id> - Verify a user with in-room verification. Probably broken.
41 /verify-device <user id> <device id> [fingerprint]
42 - Verify a device. If the fingerprint is not provided,
43 interactive emoji verification will be started.
44 /reset-session - Reset the outbound Megolm session in the current room.
45
46 /import <file> - Import encryption keys
47 /export <file> - Export encryption keys
48 /export-room <file> - Export encryption keys for the current room.
49
50 /cross-signing <subcommand> [...]
51 - Cross-signing commands. Somewhat experimental.
52 Run without arguments for help. (alias: /cs)
53 /ssss <subcommand> [...]
54 - Secure Secret Storage (and Sharing) commands. Very experimental.
55 Run without arguments for help.
56
57 # Rooms
58 /pm <user id> <...> - Create a private chat with the given user(s).
59 /create [room name] - Create a room.
60
61 /join <room> [server] - Join a room.
62 /accept - Accept the invite.
63 /reject - Reject the invite.
64
65 /invite <user id> - Invite the given user to the room.
66 /roomnick <name> - Change your per-room displayname.
67 /tag <tag> <priority> - Add the room to <tag>.
68 /untag <tag> - Remove the room from <tag>.
69 /tags - List the tags the room is in.
70 /alias <act> <name> - Add or remove local addresses.
71
72 /leave - Leave the current room.
73 /kick <user id> [reason] - Kick a user.
74 /ban <user id> [reason] - Ban a user.
75 /unban <user id> - Unban a user.`
76
77 type HelpModal struct {
78 mauview.FocusableComponent
79 parent *MainView
80 }
81
82 func NewHelpModal(parent *MainView) *HelpModal {
83 hm := &HelpModal{parent: parent}
84
85 text := mauview.NewTextView().
86 SetText(helpText).
87 SetScrollable(true).
88 SetWrap(false).
89 SetTextColor(tcell.ColorDefault)
90
91 box := mauview.NewBox(text).
92 SetBorder(true).
93 SetTitle("Help").
94 SetBlurCaptureFunc(func() bool {
95 hm.parent.HideModal()
96 return true
97 })
98 box.Focus()
99
100 hm.FocusableComponent = mauview.FractionalCenter(box, 42, 10, 0.5, 0.5)
101
102 return hm
103 }
104
105 func (hm *HelpModal) OnKeyEvent(event mauview.KeyEvent) bool {
106 kb := config.Keybind{
107 Key: event.Key(),
108 Ch: event.Rune(),
109 Mod: event.Modifiers(),
110 }
111 // TODO unhardcode q
112 if hm.parent.config.Keybindings.Modal[kb] == "cancel" || event.Rune() == 'q' {
113 hm.parent.HideModal()
114 return true
115 }
116 return hm.FocusableComponent.OnKeyEvent(event)
117 }