Skip to content

Commit

Permalink
Support vty 6
Browse files Browse the repository at this point in the history
  • Loading branch information
glguy committed Nov 3, 2023
1 parent cef581c commit e298c4c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion config-schema
Submodule config-schema updated 1 files
+1 −1 config-value
1 change: 1 addition & 0 deletions exec/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions glirc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/Client/EventLoop.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) ->
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/Client/Hook/Matterbridge.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e298c4c

Please sign in to comment.