diff options
author | delthas <delthas@dille.cc> | 2022-03-29 19:23:36 +0200 |
---|---|---|
committer | delthas <delthas@dille.cc> | 2022-04-12 18:01:39 +0200 |
commit | 7a86dff763bff9dcf1ddb14a5db4bd590c13af4a (patch) | |
tree | 8b1ab4534297f959c3611bca376e36322211d49d /commands.go | |
parent | Add a 15s keepalive to connections (diff) |
Implement SEARCH
Also refactor ui/ to support overlays, temporary anonmyous buffers.
See: https://github.com/emersion/soju/pull/39
Diffstat (limited to 'commands.go')
-rw-r--r-- | commands.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/commands.go b/commands.go index 10ae19e..03e999a 100644 --- a/commands.go +++ b/commands.go @@ -167,6 +167,13 @@ func init() { Desc: "remove effect of a ban from the user", Handle: commandDoUnban, }, + "SEARCH": { + AllowHome: true, + MaxArgs: 1, + Usage: "<text>", + Desc: "searches messages in a target", + Handle: commandDoSearch, + }, } } @@ -579,6 +586,21 @@ func commandDoUnban(app *App, args []string) (err error) { return nil } +func commandDoSearch(app *App, args []string) (err error) { + if len(args) == 0 { + app.win.CloseOverlay() + return nil + } + text := args[0] + netID, channel := app.win.CurrentBuffer() + s := app.sessions[netID] + if s == nil { + return errOffline + } + s.Search(channel, text) + return nil +} + // implemented from https://golang.org/src/strings/strings.go?s=8055:8085#L310 func fieldsN(s string, n int) []string { s = strings.TrimSpace(s) |