From e298c4ca0a4d6506fdc940be9a601944925ca4a8 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Fri, 3 Nov 2023 15:33:11 -0700 Subject: [PATCH] Support vty 6 --- config-schema | 2 +- exec/Main.hs | 1 + glirc.cabal | 6 ++++-- src/Client/EventLoop.hs | 5 ++--- src/Client/Hook/Matterbridge.hs | 6 +++--- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/config-schema b/config-schema index a1664dad..a8425d6d 160000 --- a/config-schema +++ b/config-schema @@ -1 +1 @@ -Subproject commit a1664dad1a006561f966bfe694863974dac0163c +Subproject commit a8425d6d25cddad2501c0d62dd77101678677c0c diff --git a/exec/Main.hs b/exec/Main.hs index 3d04d791..a9b143b3 100644 --- a/exec/Main.hs +++ b/exec/Main.hs @@ -17,6 +17,7 @@ import Data.Text (Text) import System.Exit import System.IO import Graphics.Vty +import Graphics.Vty.Platform.Unix (mkVty) import Client.Configuration import Client.EventLoop diff --git a/glirc.cabal b/glirc.cabal index 16e76267..5de13370 100644 --- a/glirc.cabal +++ b/glirc.cabal @@ -40,7 +40,9 @@ executable glirc default-language: Haskell2010 -- Constraints can be found on the library itself - build-depends: base, glirc, lens, text, vty + build-depends: + base, glirc, lens, text, vty, + vty-unix ^>=0.1.0.0, if os(Linux) ld-options: -Wl,--dynamic-list=exec/linux_exported_symbols.txt @@ -195,7 +197,7 @@ library unix >=2.7 && <2.9, unordered-containers >=0.2.11 && <0.3, vector >=0.11 && <0.14, - vty >=5.35 && <5.39, + vty ^>=6.0, test-suite test type: exitcode-stdio-1.0 diff --git a/src/Client/EventLoop.hs b/src/Client/EventLoop.hs index 8aa36088..336b950c 100644 --- a/src/Client/EventLoop.hs +++ b/src/Client/EventLoop.hs @@ -58,7 +58,6 @@ import Data.Time.Format.ISO8601 (formatParseM, iso8601Format) import Data.Traversable (for) import GHC.IO.Exception (IOErrorType(..), ioe_type) import Graphics.Vty -import Graphics.Vty.Input.Events ( InternalEvent(..) ) import Hookup (ConnectionFailure(..)) import Irc.Codes (pattern RPL_STARTTLS) import Irc.Message (IrcMsg(Reply, Notice), cookIrcMsg, msgTarget) @@ -86,7 +85,7 @@ getEvent vty st = do timer <- prepareTimer atomically (asum [timer, vtyEvent, networkEvents, threadJoin]) where - vtyEvent = VtyEvent <$> readTChan (_eventChannel (inputIface vty)) + vtyEvent = VtyEvent <$> readTChan (eventChannel (inputIface vty)) networkEvents = do xs <- for (HashMap.toList (view clientConnections st)) $ \(network, conn) -> @@ -155,7 +154,7 @@ eventLoop vty st = eventLoop vty =<< doTimerEvent networkId action st' VtyEvent (InputEvent vtyEvent) -> traverse_ (eventLoop vty) =<< doVtyEvent vty vtyEvent st' - VtyEvent ResumeAfterSignal -> + VtyEvent ResumeAfterInterrupt -> eventLoop vty =<< updateTerminalSize vty st NetworkEvents networkEvents -> eventLoop vty =<< foldM doNetworkEvent st' networkEvents diff --git a/src/Client/Hook/Matterbridge.hs b/src/Client/Hook/Matterbridge.hs index c436a6d7..eea0662d 100644 --- a/src/Client/Hook/Matterbridge.hs +++ b/src/Client/Hook/Matterbridge.hs @@ -54,9 +54,9 @@ remap nick chanfilter ircmsg = remap' :: MbMsg -> UserInfo -> Identifier -> Text -> MessageResult remap' mbmsg ui chan msg = - case msg =~ ("^<([^>]+)> (.*)$"::Text) of - [_,nick,msg']:_ -> RemapMessage (newmsg mbmsg (fakeUser nick ui) chan msg') - _ -> PassMessage + case msg =~ ("^(\x03\&[0-9]{2})?<([^>]+)> \x0f?(.*)$"::Text) of + [_,_,nick,msg']:_ -> RemapMessage (newmsg mbmsg (fakeUser nick ui) chan msg') + _ -> PassMessage newmsg :: MbMsg -> Source -> Identifier -> Text -> IrcMsg newmsg Msg src chan msg = Privmsg src chan msg