glirc-2.40.1: Console IRC client
Copyright(c) Eric Mertens 2016
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Client.State

Description

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

Synopsis

Client state type

data ClientState Source #

All state information for the IRC client

Constructors

ClientState 

Fields

Lenses

clientConnection Source #

Arguments

:: Applicative f 
=> Text

network

-> LensLike' f ClientState NetworkState 

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

Client operations

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

Construct an initial ClientState using default values.

clientFilter :: ClientState -> (a -> Text) -> [a] -> [a] Source #

clientNetworkPalette :: ClientState -> NetworkPalette Source #

Generates the NetworkPalette for the current focus.

clientToggleHideMeta :: ClientState -> ClientState Source #

Toggle the hide metadata setting for the focused window.

channelUserList Source #

Arguments

:: Text

network

-> Identifier

channel

-> ClientState 
-> [Identifier]

nicks

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.

identIgnored Source #

Arguments

:: UserInfo

target user

-> ClientState

client state

-> Bool

is ignored

Predicate for nicknames to determine if messages should be ignored.

clientFirstLine :: ClientState -> String Source #

The full top-most line that would be executed

clientLine Source #

Arguments

:: ClientState 
-> (Int, String)

line number, line content

The line under the cursor in the edit box.

abortNetwork Source #

Arguments

:: Text

network

-> ClientState 
-> IO ClientState 

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

addConnection Source #

Arguments

:: Int

attempts

-> Maybe UTCTime

optional disconnect time

-> Maybe Int

STS upgrade port

-> Text

network name

-> ClientState 
-> IO ClientState 

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

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

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

clientTick :: ClientState -> ClientState Source #

Function applied to the client state every redraw.

applyMessageToClientState Source #

Arguments

:: ZonedTime

timestamp

-> IrcMsg

message received

-> Text

network name

-> NetworkState

network connection state

-> ClientState

client state

-> ([RawIrcMsg], ClientState)

response , updated 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.

clientAutoconnects :: ClientState -> [Text] Source #

Returns the list of network names that requested autoconnection.

clientActiveCommand Source #

Arguments

:: ClientState

client state

-> Maybe (String, String)

command name and argument string

Compute the command and arguments currently in the textbox.

clientExtraFocuses :: ClientState -> [(Focus, Subfocus)] Source #

List of extra focuses to display as split windows

currentNickCompletionMode :: ClientState -> WordCompletionMode Source #

Returns the WordCompletionMode associated with the current network.

Add messages to buffers

recordChannelMessage Source #

Arguments

:: Text

network

-> Identifier

channel

-> 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

recordError Source #

Arguments

:: ZonedTime

now

-> Text

network

-> Text

error message

-> ClientState

client state

-> ClientState 

recordIrcMessage Source #

Arguments

:: Text

network

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

Record a message in the windows corresponding to the given target

Focus manipulation

changeFocus Source #

Arguments

:: 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 #

Arguments

:: 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.

advanceNetworkFocus :: 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 #

Arguments

:: Char

window name

-> ClientState 
-> ClientState 

Jump the focus directly to a window based on its zero-based index while ignoring hidden windows.

setExtraFocus :: [(Focus, Subfocus)] -> ClientState -> ClientState Source #

Unified logic for assigning to the extra focuses field that activates and deactivates windows as needed.

Scrolling

scrollClient :: Int -> ClientState -> ClientState Source #

Scroll the current buffer to show newer messages

Extensions

data ExtensionState Source #

State of the extension API including loaded extensions and the mechanism used to support reentry into the Haskell runtime from the C API.

When executing inside an extension the mvar will contain the client state and the ID of the running extension.