Merge branch 'master' into cross-signing
This commit is contained in:
@ -18,6 +18,7 @@ package ui
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
@ -34,7 +35,6 @@ import (
|
||||
"unicode"
|
||||
|
||||
"github.com/lucasb-eyer/go-colorful"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/russross/blackfriday/v2"
|
||||
|
||||
"maunium.net/go/mautrix"
|
||||
@ -225,7 +225,7 @@ func readRoomAlias(cmd *Command) (alias id.RoomAlias, err error) {
|
||||
param := strings.Join(cmd.Args[1:], " ")
|
||||
if strings.ContainsRune(param, ':') {
|
||||
if param[0] != '#' {
|
||||
return "", errors.New("Full aliases must start with #")
|
||||
return "", errors.New("full aliases must start with #")
|
||||
}
|
||||
|
||||
alias = id.RoomAlias(param)
|
||||
@ -454,60 +454,8 @@ func cmdUnknownCommand(cmd *Command) {
|
||||
}
|
||||
|
||||
func cmdHelp(cmd *Command) {
|
||||
cmd.Reply(`# General
|
||||
/help - Show this "temporary" help message.
|
||||
/quit - Quit gomuks.
|
||||
/clearcache - Clear cache and quit gomuks.
|
||||
/logout - Log out of Matrix.
|
||||
/toggle <thing> - Temporary command to toggle various UI features.
|
||||
|
||||
Things: rooms, users, baremessages, images, typingnotif, unverified
|
||||
|
||||
# Sending special messages
|
||||
/me <message> - Send an emote message.
|
||||
/notice <message> - Send a notice (generally used for bot messages).
|
||||
/rainbow <message> - Send rainbow text (markdown not supported).
|
||||
/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.
|
||||
/verify <user id> <device id> [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 <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.`)
|
||||
view := cmd.MainView
|
||||
view.ShowModal(NewHelpModal(view))
|
||||
}
|
||||
|
||||
func cmdLeave(cmd *Command) {
|
||||
|
95
ui/help-modal.go
Normal file
95
ui/help-modal.go
Normal file
@ -0,0 +1,95 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"maunium.net/go/tcell"
|
||||
|
||||
"maunium.net/go/mauview"
|
||||
)
|
||||
|
||||
const helpText = `# General
|
||||
/help - Show this help dialog.
|
||||
/quit - Quit gomuks.
|
||||
/clearcache - Clear cache and quit gomuks.
|
||||
/logout - Log out of Matrix.
|
||||
/toggle <thing> - Temporary command to toggle various UI features.
|
||||
|
||||
# Sending special messages
|
||||
/me <message> - Send an emote message.
|
||||
/notice <message> - Send a notice (generally used for bot messages).
|
||||
/rainbow <message> - Send rainbow text.
|
||||
/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.
|
||||
/verify <user id> <device id> [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 <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.`
|
||||
|
||||
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)
|
||||
|
||||
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 {
|
||||
if event.Key() == tcell.KeyEscape || event.Rune() == 'q' {
|
||||
hm.parent.HideModal()
|
||||
return true
|
||||
}
|
||||
return hm.FocusableComponent.OnKeyEvent(event)
|
||||
}
|
@ -360,6 +360,7 @@ func (view *MessageView) SetSelected(message *messages.UIMessage) {
|
||||
|
||||
func (view *MessageView) handleMessageClick(message *messages.UIMessage, mod tcell.ModMask) bool {
|
||||
if msg, ok := message.Renderer.(*messages.FileMessage); ok && mod > 0 && !msg.Thumbnail.IsEmpty() {
|
||||
debug.Print("Opening thumbnail", msg.ThumbnailPath())
|
||||
open.Open(msg.ThumbnailPath())
|
||||
// No need to re-render
|
||||
return false
|
||||
|
@ -320,7 +320,7 @@ func (parser *htmlParser) syntaxHighlight(text, language string) Entity {
|
||||
func (parser *htmlParser) codeblockToEntity(node *html.Node) Entity {
|
||||
lang := "plaintext"
|
||||
// TODO allow disabling syntax highlighting
|
||||
if node.FirstChild.Type == html.ElementNode && node.FirstChild.Data == "code" {
|
||||
if node.FirstChild != nil && node.FirstChild.Type == html.ElementNode && node.FirstChild.Data == "code" {
|
||||
node = node.FirstChild
|
||||
attr := parser.getAttribute(node, "class")
|
||||
for _, class := range strings.Split(attr, " ") {
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/kyokomi/emoji"
|
||||
"github.com/kyokomi/emoji/v2"
|
||||
"github.com/mattn/go-runewidth"
|
||||
"github.com/zyedidia/clipboard"
|
||||
|
||||
@ -713,6 +713,7 @@ func (view *RoomView) Download(url id.ContentURI, file *attachment.EncryptedFile
|
||||
view.AddServiceMessage(fmt.Sprintf("File downloaded to %s", path))
|
||||
view.parent.parent.Render()
|
||||
if openFile {
|
||||
debug.Print("Opening file", path)
|
||||
open.Open(path)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user