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
e9bbf9b3
Commit
e9bbf9b3
authored
5 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Re-implement invalidation of pango-formatted text
parent
7b03f030
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/QBar/BlockOutput.hs
+16
-9
16 additions, 9 deletions
src/QBar/BlockOutput.hs
src/QBar/Core.hs
+1
-1
1 addition, 1 deletion
src/QBar/Core.hs
src/QBar/Theme.hs
+1
-1
1 addition, 1 deletion
src/QBar/Theme.hs
with
18 additions
and
11 deletions
src/QBar/BlockOutput.hs
+
16
−
9
View file @
e9bbf9b3
...
...
@@ -133,23 +133,30 @@ toImportance' (tMax, tCritical, tError, tWarning, tNormal, tMinimal) val
valueOtherwise
tNormal'
Nothing
v
=
1
-
logarithmicMatch
v
tNormal'
invalidateBlock
::
BlockOutput
->
BlockOutput
invalidateBlock
block
@
BlockOutput
{
_fullText
,
_shortText
}
=
block
{
_fullText
=
normalText
.
rawText
$
_fullText
,
_shortText
=
normalText
.
rawText
<$>
_shortText
,
_invalid
=
True
}
removePango
::
BlockText
->
T
.
Text
removePango
(
BlockText
b
)
=
foldr
((
<>
)
.
removePangoFromSegment
)
""
b
rawText
::
BlockText
->
T
.
Text
rawText
(
BlockText
b
)
=
foldMap
rawTextFromSegment
b
where
r
emovePango
FromSegment
::
BlockTextSegment
->
T
.
Text
r
emovePango
FromSegment
BlockTextSegment
{
active
=
_active
,
importance
=
_importance
,
text
}
=
text
r
emovePango
FromSegment
(
PangoTextSegment
text
)
=
r
awText
FromSegment
::
BlockTextSegment
->
T
.
Text
r
awText
FromSegment
BlockTextSegment
{
text
}
=
text
r
awText
FromSegment
(
PangoTextSegment
text
)
=
case
parsePango
text
of
Left
_
->
text
Right
parsed
->
removeFormatting
parsed
printedLength
::
BlockText
->
Int64
printedLength
(
BlockText
b
)
=
foldr
((
+
)
.
printed
Length
'
)
0
b
printedLength
(
BlockText
b
)
=
sum
.
map
segment
Length
$
b
where
printed
Length
'
::
BlockTextSegment
->
Int64
printed
Length
'
BlockTextSegment
{
text
,
active
=
_
,
importance
=
_
}
=
T
.
length
text
printed
Length
'
(
PangoTextSegment
_
)
=
0
segment
Length
::
BlockTextSegment
->
Int64
segment
Length
BlockTextSegment
{
text
}
=
T
.
length
text
segment
Length
(
PangoTextSegment
pango
)
=
either
(
const
$
T
.
length
pango
)
(
T
.
length
.
removeFormatting
)
$
parsePango
pango
mkText
::
Bool
->
Importance
->
T
.
Text
->
BlockText
mkText
active
importance
text
=
BlockText
[
BlockTextSegment
{
text
=
pangoFriendly
text
,
active
,
importance
}]
...
...
This diff is collapsed.
Click to expand it.
src/QBar/Core.hs
+
1
−
1
View file @
e9bbf9b3
...
...
@@ -187,7 +187,7 @@ sharedInterval seconds = do
updateClickHandler
Nothing
_
=
return
()
updateClickHandler
(
Just
(
block
,
_
))
_
=
do
-- Give user feedback that the block is updating
let
outdatedBlock
=
block
&
invalid
.~
True
let
outdatedBlock
=
invalidateBlock
block
-- The invalidated block output has no event handler
liftIO
$
void
$
atomically
$
send
output
.
Just
$
(
outdatedBlock
,
Nothing
)
-- Notify bar about changed block state to display the feedback
...
...
This diff is collapsed.
Click to expand it.
src/QBar/Theme.hs
+
1
−
1
View file @
e9bbf9b3
...
...
@@ -71,7 +71,7 @@ rainbowTheme time blocks = reverse $ evalState (mapM rainbowBlock $ reverse bloc
where
rainbowBlock
::
BlockOutput
->
State
Integer
BlockOutput
rainbowBlock
block
=
do
let
text
=
r
emovePango
$
block
^.
fullText
let
text
=
r
awText
$
block
^.
fullText
let
chars
=
T
.
unpack
.
T
.
reverse
$
text
coloredChars
<-
mapM
rainbowChar
chars
let
rainbowText
=
T
.
concat
.
reverse
$
coloredChars
...
...
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