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
Jens Nolte
qbar
Commits
e2969310
Verified
Commit
e2969310
authored
1 year ago
by
Legy (Beini)
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug in rainbow theme generation with `&` escape sequences
parent
4d2f6a07
No related branches found
No related tags found
1 merge request
!9
Ags ready
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
qbar/src/QBar/Theme.hs
+13
-3
13 additions, 3 deletions
qbar/src/QBar/Theme.hs
with
13 additions
and
3 deletions
qbar/src/QBar/Theme.hs
+
13
−
3
View file @
e2969310
...
...
@@ -155,7 +155,7 @@ rainbowTheme = AnimatedTheme rainbowThemePipe
rainbowBlock
::
BlockOutput
->
State
Integer
ThemedBlockOutput
rainbowBlock
block
@
BlockOutput
{
_blockName
}
=
do
let
text
=
rawText
$
block
^.
fullText
let
chars
=
T
.
unpack
.
T
.
reverse
$
text
let
chars
=
reverse
.
splitToChars
$
text
coloredChars
<-
mapM
rainbowChar
chars
let
rainbowText
=
reverse
coloredChars
return
$
ThemedBlockOutput
{
...
...
@@ -163,10 +163,10 @@ rainbowTheme = AnimatedTheme rainbowThemePipe
_fullText
=
ThemedBlockText
rainbowText
,
_shortText
=
Nothing
}
rainbowChar
::
Char
->
State
Integer
ThemedBlockTextSegment
rainbowChar
::
T
.
Text
->
State
Integer
ThemedBlockTextSegment
rainbowChar
char
=
do
color
<-
nextRainbowColor
return
$
mkThemedSegment
(
color
,
Nothing
)
$
T
.
singleton
char
return
$
mkThemedSegment
(
color
,
Nothing
)
$
char
nextRainbowColor
::
State
Integer
Color
-- nextRainbowColor = state $ \index -> (rainbowColor (fromInteger index), index + 1)
nextRainbowColor
=
do
...
...
@@ -178,3 +178,13 @@ rainbowTheme = AnimatedTheme rainbowThemePipe
let
hue'
=
position
*
3
color
=
hsv
hue'
0.8
1.0
in
ColorRGB
color
splitToChars
::
T
.
Text
->
[
T
.
Text
]
splitToChars
=
splitStringToChars
.
T
.
unpack
splitStringToChars
::
String
->
[
T
.
Text
]
splitStringToChars
[]
=
[]
splitStringToChars
(
'&'
:
xs
)
=
splitStringToCharsAmp
"&"
xs
splitStringToChars
(
x
:
xs
)
=
T
.
singleton
x
:
splitStringToChars
xs
splitStringToCharsAmp
::
String
->
String
->
[
T
.
Text
]
splitStringToCharsAmp
_
[]
=
[]
splitStringToCharsAmp
acc
(
';'
:
xs
)
=
T
.
pack
(
acc
<>
";"
)
:
splitStringToChars
xs
splitStringToCharsAmp
acc
(
x
:
xs
)
=
splitStringToCharsAmp
(
acc
<>
[
x
])
xs
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