glirc-2.15: Console IRC client

Copyright(c) Eric Mertens, 2016
Safe HaskellNone




This module provides the core logic of the IRC client. The client state tracks everything about the client.


Client state type

data ClientState Source #

All state information for the IRC client





clientConnection Source #


:: Applicative f 
=> Text


-> LensLike' f ClientState NetworkState 

Traversal for finding the NetworkState associated with a given network if that connection is currently active.

Client operations

withClientState :: Configuration -> (ClientState -> IO a) -> IO a Source #

Construct an initial ClientState using default values.

clientStartExtensions :: ClientState -> IO ClientState Source #

Start extensions after ensuring existing ones are stopped

clientPark :: ClientState -> (Ptr () -> IO a) -> IO (ClientState, a) Source #

clientMatcher :: ClientState -> Text -> Bool Source #

Construct a text matching predicate used to filter the message window.

consumeInput :: ClientState -> ClientState Source #

Add the textbox input to the edit history and clear the textbox.

currentCompletionList :: ClientState -> [Identifier] Source #

Returns the current network's channels and current channel's users.

ircIgnorable :: IrcMsg -> ClientState -> Maybe Identifier Source #

Predicate for messages that should be ignored based on the configurable ignore list

clientFirstLine :: ClientState -> String Source #

The full top-most line that would be executed

clientLine Source #


:: ClientState 
-> (Int, String)

line number, line content

The line under the cursor in the edit box.

abortNetwork Source #


:: Text


-> ClientState 
-> IO ClientState 

Forcefully terminate the connection currently associated with a given network name.

addConnection Source #


:: Int


-> Maybe UTCTime

optional disconnect time

-> Text

network name

-> ClientState 
-> IO ClientState 

Start a new connection. The delay is used for reconnections.

removeNetwork :: NetworkId -> ClientState -> (NetworkState, ClientState) Source #

Remove a network connection and unlink it from the network map. This operation assumes that the networkconnection exists and should only be applied once per connection.

clientTick :: ClientState -> ClientState Source #

Function applied to the client state every redraw.

applyMessageToClientState Source #


:: ZonedTime


-> IrcMsg

message recieved

-> NetworkId

message network

-> NetworkState

network connection state

-> ClientState 
-> ([RawIrcMsg], ClientState)

response , updated state

clientHighlights Source #


:: NetworkState

network state

-> ClientState

client state

-> HashSet Identifier

extra highlight identifiers

Compute the set of extra identifiers that should be highlighted given a particular network state.

clientWindowNames :: ClientState -> [Char] Source #

Produce the list of window names configured for the client.

clientPalette :: ClientState -> Palette Source #

Produce the list of window names configured for the client.

Add messages to buffers

recordChannelMessage Source #


:: Text


-> Identifier


-> ClientMessage 
-> ClientState 
-> ClientState 

Add a message to the window associated with a given channel

recordNetworkMessage :: ClientMessage -> ClientState -> ClientState Source #

Record a message on a network window

recordIrcMessage Source #


:: Text


-> MessageTarget 
-> ClientMessage 
-> ClientState 
-> ClientState 

Record a message in the windows corresponding to the given target

Focus manipulation

changeFocus Source #


:: Focus

new focus

-> ClientState

client state

-> ClientState 

Change the window focus to the given value, reset the subfocus to message view, reset the scroll, remember the previous focus if it changed.

changeSubfocus Source #


:: Subfocus

new subfocus

-> ClientState

client state

-> ClientState 

Change the subfocus to the given value, preserve the focus, reset the scroll.

returnFocus :: ClientState -> ClientState Source #

Return to previously focused window.

advanceFocus :: ClientState -> ClientState Source #

Step focus to the next window when on message view. Otherwise switch to message view.

retreatFocus :: ClientState -> ClientState Source #

Step focus to the previous window when on message view. Otherwise switch to message view.

jumpToActivity :: ClientState -> ClientState Source #

Jump the focus of the client to a buffer that has unread activity. Some events like errors or chat messages mentioning keywords are considered important and will be jumped to first.

jumpFocus Source #


:: Int

zero-based window index

-> ClientState 
-> ClientState 

Jump the focus directly to a window based on its zero-based index.


pageUp :: ClientState -> ClientState Source #

Scroll the current buffer to show older messages

pageDown :: ClientState -> ClientState Source #

Scroll the current buffer to show newer messages