Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qbar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jktr
qbar
Commits
dd496bf5
Commit
dd496bf5
authored
5 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Pass click event data to event handler
parent
7d95a511
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/QBar/Core.hs
+5
-4
5 additions, 4 deletions
src/QBar/Core.hs
src/QBar/Server.hs
+13
-13
13 additions, 13 deletions
src/QBar/Server.hs
with
18 additions
and
17 deletions
src/QBar/Core.hs
+
5
−
4
View file @
dd496bf5
...
...
@@ -31,13 +31,14 @@ import Data.Colour.RGBSpace
data
Block
=
Block
{
values
::
HM
.
HashMap
T
.
Text
T
.
Text
,
clickAction
::
Maybe
(
IO
()
)
clickAction
::
Maybe
(
Click
->
IO
()
)
}
instance
Show
Block
where
show
Block
{
values
}
=
show
values
data
Click
=
Click
{
name
::
T
.
Text
name
::
T
.
Text
,
button
::
Int
}
deriving
Show
$
(
deriveJSON
defaultOptions
''Click
)
...
...
@@ -170,8 +171,8 @@ sharedInterval barUpdateChannel seconds = do
clickAction
=
Just
(
updateClickHandler
result
)
}
where
updateClickHandler
::
Block
->
IO
()
updateClickHandler
block
=
do
updateClickHandler
::
Block
->
Click
->
IO
()
updateClickHandler
block
_
=
do
-- Give user feedback that the block is updating
let
outdatedBlock
=
setColor
updatingColor
$
removePango
block
void
$
atomically
$
send
output
$
outdatedBlock
...
...
This diff is collapsed.
Click to expand it.
src/QBar/Server.hs
+
13
−
13
View file @
dd496bf5
...
...
@@ -28,7 +28,7 @@ import System.IO (stdin, stdout, stderr, hFlush, hPutStrLn)
import
System.Posix.Signals
data
Handle
=
Handle
{
handleActionList
::
IORef
[(
T
.
Text
,
IO
()
)],
handleActionList
::
IORef
[(
T
.
Text
,
Click
->
IO
()
)],
handleActiveFilter
::
IORef
Filter
}
...
...
@@ -91,9 +91,9 @@ renderLine MainOptions{verbose} Handle{handleActionList} blockFilter blocks prev
return
encodedOutput
where
clickActionList
::
[(
T
.
Text
,
IO
()
)]
clickActionList
::
[(
T
.
Text
,
Click
->
IO
()
)]
clickActionList
=
mapMaybe
getClickAction
blocks
getClickAction
::
Block
->
Maybe
(
T
.
Text
,
IO
()
)
getClickAction
::
Block
->
Maybe
(
T
.
Text
,
Click
->
IO
()
)
getClickAction
block
=
if
hasBlockName
&&
hasClickAction
then
Just
(
fromJust
maybeBlockName
,
fromJust
maybeClickAction
)
else
Nothing
where
maybeBlockName
=
getBlockName
block
...
...
@@ -106,7 +106,7 @@ createBarUpdateChannel = do
event
<-
Event
.
newSet
return
(
BarUpdateChannel
$
Event
.
set
event
,
event
)
handleStdin
::
MainOptions
->
IORef
[(
T
.
Text
,
IO
()
)]
->
IO
()
handleStdin
::
MainOptions
->
IORef
[(
T
.
Text
,
Click
->
IO
()
)]
->
IO
()
handleStdin
options
actionListIORef
=
forever
$
do
line
<-
BSSC8
.
hGetLine
stdin
...
...
@@ -116,17 +116,17 @@ handleStdin options actionListIORef = forever $ do
BSSC8
.
hPutStrLn
stderr
line
hFlush
stderr
clickActionList
<-
readIORef
actionListIORef
let
maybeParsedClick
=
decode
$
removeComma
$
BS
.
fromStrict
line
let
clickAction'
=
getClickAction
clickActionList
maybeParsedClick
async
(
fromMaybe
(
return
()
)
clickAction'
)
>>=
link
let
maybeClick
=
decode
$
removeComma
$
BS
.
fromStrict
line
case
maybeClick
of
Just
click
->
do
clickActionList
<-
readIORef
actionListIORef
let
clickAction'
=
getClickAction
clickActionList
click
async
((
fromMaybe
discard
clickAction'
)
click
)
>>=
link
Nothing
->
return
()
where
getClickAction
::
[(
T
.
Text
,
IO
()
)]
->
Maybe
Click
->
Maybe
(
IO
()
)
getClickAction
clickActionList
maybeParsedClick
=
do
parsedClick
<-
maybeParsedClick
let
blockName
=
name
parsedClick
lookup
blockName
clickActionList
getClickAction
::
[(
T
.
Text
,
Click
->
IO
()
)]
->
Click
->
Maybe
(
Click
->
IO
()
)
getClickAction
clickActionList
click
=
lookup
(
name
click
)
clickActionList
removeComma
::
C8
.
ByteString
->
C8
.
ByteString
removeComma
line
|
C8
.
head
line
==
','
=
C8
.
tail
line
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment