summaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-03-29 19:23:36 +0200
committerdelthas <delthas@dille.cc>2022-04-12 18:01:39 +0200
commit7a86dff763bff9dcf1ddb14a5db4bd590c13af4a (patch)
tree8b1ab4534297f959c3611bca376e36322211d49d /app.go
parentAdd 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 'app.go')
-rw-r--r--app.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/app.go b/app.go
index c0f0112..e2fa566 100644
--- a/app.go
+++ b/app.go
@@ -565,6 +565,8 @@ func (app *App) handleKeyEvent(ev *tcell.EventKey) {
if ok {
app.typing()
}
+ case tcell.KeyEscape:
+ app.win.CloseOverlay()
case tcell.KeyCR, tcell.KeyLF:
netID, buffer := app.win.CurrentBuffer()
input := app.win.InputEnter()
@@ -599,6 +601,9 @@ func (app *App) handleKeyEvent(ev *tcell.EventKey) {
// requestHistory is a wrapper around irc.Session.RequestHistory to only request
// history when needed.
func (app *App) requestHistory() {
+ if app.win.HasOverlay() {
+ return
+ }
netID, buffer := app.win.CurrentBuffer()
s := app.sessions[netID]
if s == nil {
@@ -854,6 +859,17 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) {
if !bounds.IsZero() {
app.messageBounds[boundKey{netID, ev.Target}] = bounds
}
+ case irc.SearchEvent:
+ app.win.OpenOverlay()
+ lines := make([]ui.Line, 0, len(ev.Messages))
+ for _, m := range ev.Messages {
+ _, line, _ := app.formatMessage(s, m)
+ if line.IsZero() {
+ continue
+ }
+ lines = append(lines, line)
+ }
+ app.win.AddLines("", ui.Overlay, lines, nil)
case irc.ReadEvent:
app.win.SetRead(netID, ev.Target, ev.Timestamp)
case irc.BouncerNetworkEvent: