Copyright | (c) Eric Mertens 2016 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
This module provides the core logic of the IRC client. The client state tracks everything about the client.
Synopsis
- data ClientState = ClientState {
- _clientWindows :: !(Map Focus Window)
- _clientPrevFocus :: !Focus
- _clientActivityReturn :: !(Maybe Focus)
- _clientFocus :: !Focus
- _clientSubfocus :: !Subfocus
- _clientExtraFocus :: ![Focus]
- _clientConnections :: !(IntMap NetworkState)
- _clientEvents :: !(TQueue NetworkEvent)
- _clientNetworkMap :: !(HashMap Text NetworkId)
- _clientConfig :: !Configuration
- _clientConfigPath :: !(Maybe FilePath)
- _clientTextBox :: !EditBox
- _clientTextBoxOffset :: !Int
- _clientWidth :: !Int
- _clientHeight :: !Int
- _clientScroll :: !Int
- _clientDetailView :: !Bool
- _clientActivityBar :: !Bool
- _clientShowPing :: !Bool
- _clientRegex :: Maybe Regex
- _clientLayout :: !LayoutMode
- _clientBell :: !Bool
- _clientIgnores :: !(HashSet Identifier)
- _clientIgnoreMask :: Mask
- _clientExtensions :: !ExtensionState
- _clientLogQueue :: ![LogLine]
- _clientErrorMsg :: Maybe Text
- _clientRtsStats :: Maybe Stats
- clientWindows :: Lens' ClientState (Map Focus Window)
- clientTextBox :: Lens' ClientState EditBox
- clientTextBoxOffset :: Lens' ClientState Int
- clientConnections :: Lens' ClientState (IntMap NetworkState)
- clientWidth :: Lens' ClientState Int
- clientHeight :: Lens' ClientState Int
- clientEvents :: Lens' ClientState (TQueue NetworkEvent)
- clientFocus :: Lens' ClientState Focus
- clientPrevFocus :: Lens' ClientState Focus
- clientExtraFocus :: Lens' ClientState [Focus]
- clientConfig :: Lens' ClientState Configuration
- clientScroll :: Lens' ClientState Int
- clientDetailView :: Lens' ClientState Bool
- clientActivityBar :: Lens' ClientState Bool
- clientShowPing :: Lens' ClientState Bool
- clientSubfocus :: Lens' ClientState Subfocus
- clientNetworkMap :: Lens' ClientState (HashMap Text NetworkId)
- clientIgnores :: Lens' ClientState (HashSet Identifier)
- clientIgnoreMask :: Lens' ClientState Mask
- clientConnection :: Applicative f => Text -> LensLike' f ClientState NetworkState
- clientBell :: Lens' ClientState Bool
- clientExtensions :: Lens' ClientState ExtensionState
- clientRegex :: Lens' ClientState (Maybe Regex)
- clientLogQueue :: Lens' ClientState [LogLine]
- clientActivityReturn :: Lens' ClientState (Maybe Focus)
- clientErrorMsg :: Lens' ClientState (Maybe Text)
- clientLayout :: Lens' ClientState LayoutMode
- clientRtsStats :: Lens' ClientState (Maybe Stats)
- clientConfigPath :: Lens' ClientState (Maybe FilePath)
- withClientState :: Maybe FilePath -> Configuration -> (ClientState -> IO a) -> IO a
- clientStartExtensions :: ClientState -> IO ClientState
- clientShutdown :: ClientState -> IO ()
- clientPark :: ClientState -> (Ptr () -> IO a) -> IO (ClientState, a)
- clientMatcher :: ClientState -> Maybe (Text -> Bool)
- clientMatcher' :: ClientState -> Maybe (Text -> Bool)
- clientActiveRegex :: ClientState -> Maybe Regex
- clientToggleHideMeta :: ClientState -> ClientState
- clientHighlightsNetwork :: Text -> ClientState -> HashSet Identifier
- channelUserList :: Text -> Identifier -> ClientState -> [Identifier]
- consumeInput :: ClientState -> ClientState
- currentCompletionList :: ClientState -> [Identifier]
- identIgnored :: UserInfo -> ClientState -> Bool
- clientFirstLine :: ClientState -> String
- clientLine :: ClientState -> (Int, String)
- abortNetwork :: Text -> ClientState -> IO ClientState
- addConnection :: Int -> Maybe UTCTime -> Text -> ClientState -> IO ClientState
- removeNetwork :: NetworkId -> ClientState -> (NetworkState, ClientState)
- clientTick :: ClientState -> ClientState
- applyMessageToClientState :: ZonedTime -> IrcMsg -> NetworkId -> NetworkState -> ClientState -> ([RawIrcMsg], ClientState)
- clientHighlights :: NetworkState -> ClientState -> HashSet Identifier
- clientWindowNames :: ClientState -> [Char]
- clientPalette :: ClientState -> Palette
- clientAutoconnects :: ClientState -> [Text]
- clientActiveCommand :: ClientState -> Maybe (String, String)
- clientExtraFocuses :: ClientState -> [Focus]
- currentNickCompletionMode :: ClientState -> WordCompletionMode
- recordChannelMessage :: Text -> Identifier -> ClientMessage -> ClientState -> ClientState
- recordNetworkMessage :: ClientMessage -> ClientState -> ClientState
- recordIrcMessage :: Text -> MessageTarget -> ClientMessage -> ClientState -> ClientState
- changeFocus :: Focus -> ClientState -> ClientState
- changeSubfocus :: Subfocus -> ClientState -> ClientState
- returnFocus :: ClientState -> ClientState
- advanceFocus :: ClientState -> ClientState
- advanceNetworkFocus :: ClientState -> ClientState
- retreatFocus :: ClientState -> ClientState
- jumpToActivity :: ClientState -> ClientState
- jumpFocus :: Int -> ClientState -> ClientState
- setExtraFocus :: [Focus] -> ClientState -> ClientState
- scrollClient :: Int -> ClientState -> ClientState
- data ExtensionState
- esActive :: Lens' ExtensionState [ActiveExtension]
- urlPattern :: Regex
- urlMatches :: Text -> [Text]
Client state type
data ClientState Source #
All state information for the IRC client
ClientState | |
|
Lenses
:: Applicative f | |
=> Text | network |
-> LensLike' f ClientState NetworkState |
Traversal
for finding the NetworkState
associated with a given network
if that connection is currently active.
clientRegex :: Lens' ClientState (Maybe Regex) Source #
clientRtsStats :: Lens' ClientState (Maybe Stats) Source #
Client operations
withClientState :: Maybe FilePath -> 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
clientShutdown :: ClientState -> IO () Source #
Actions to be run when exiting the client.
:: ClientState | client state |
-> (Ptr () -> IO a) | continuation using the stable pointer to the client |
-> IO (ClientState, a) |
Prepare the client to support reentry from the extension API.
:: ClientState | client state |
-> Maybe (Text -> Bool) | optional predicate |
Returns the current filtering predicate if one is active.
:: ClientState | client state |
-> Maybe (Text -> Bool) | optional predicate |
Strict version of clientMatcher
clientActiveRegex :: ClientState -> Maybe Regex Source #
Construct a text matching predicate used to filter the message window.
clientToggleHideMeta :: ClientState -> ClientState Source #
Toggle the hide metadata setting for the focused window.
clientHighlightsNetwork Source #
:: Text | network |
-> ClientState | client state |
-> HashSet Identifier | extra highlight identifiers |
Compute the set of extra identifiers that should be highlighted given a particular network.
:: 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.
:: 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
:: ClientState | |
-> (Int, String) | line number, line content |
The line under the cursor in the edit box.
:: Text | network |
-> ClientState | |
-> IO ClientState |
Forcefully terminate the connection currently associated with a given network name.
:: Int | attempts |
-> 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 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 #
:: ZonedTime | timestamp |
-> IrcMsg | message received |
-> NetworkId | message network |
-> NetworkState | network connection state |
-> ClientState | client state |
-> ([RawIrcMsg], ClientState) | response , updated state |
:: 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.
clientAutoconnects :: ClientState -> [Text] Source #
Returns the list of network names that requested autoconnection.
:: ClientState | client state |
-> Maybe (String, String) | command name and argument string |
Compute the command and arguments currently in the textbox.
clientExtraFocuses :: ClientState -> [Focus] 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
:: 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
:: Text | network |
-> MessageTarget | |
-> ClientMessage | |
-> ClientState | |
-> ClientState |
Record a message in the windows corresponding to the given target
Focus manipulation
:: 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.
:: 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.
:: Int | zero-based window index |
-> ClientState | |
-> ClientState |
Jump the focus directly to a window based on its zero-based index.
setExtraFocus :: [Focus] -> 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.
URL view
urlPattern :: Regex Source #
Regular expression for matching HTTP/HTTPS URLs in chat text.
urlMatches :: Text -> [Text] Source #
Find all the URL matches using urlPattern
in a given Text
suitable
for being opened. Surrounding <
and >
are removed.