aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Byron <[email protected]>2016-08-22 09:28:14 +1000
committerDaniel Byron <[email protected]>2016-08-22 09:28:14 +1000
commit1889a4623b8146b34631bfc701f3d57fac1687e5 (patch)
treeda2e2ccde231364662842a51172967233fabfd56
parentGnome terminal (dconf) support added (diff)
downloadschemer2-1889a4623b8146b34631bfc701f3d57fac1687e5.tar.xz
schemer2-1889a4623b8146b34631bfc701f3d57fac1687e5.zip
Removed abort on less than 16 colors generated
Now when the number of colors generated is less than 16, the sequence of generated colors will be repeated to fill 16 colors.
-rw-r--r--main.go15
-rw-r--r--tests/Terminals/xterm/test-10colors11
-rw-r--r--tests/Terminals/xterm/test-4colors5
-rw-r--r--tests/Terminals/xterm/test-8colors9
4 files changed, 35 insertions, 5 deletions
diff --git a/main.go b/main.go
index 8ae1e34..afdbfdf 100644
--- a/main.go
+++ b/main.go
@@ -204,12 +204,17 @@ func main() {
return
}
- // Ensure there are 16 colors
- if len(colors) > 16 {
+ // Keep track of the original number of colors
+ // In case we need to add more to meet 16
+ num_colors := len(colors)
+ if num_colors > 16 {
+ // Truncate the list down to 16
colors = colors[:16]
- } else if len(colors) < 16 {
- // TODO: Should this just be a warning (for cases where only 8 colors are defined?)
- log.Fatal("Less than 16 colors. Aborting.")
+ } else if num_colors < 16 {
+ // In the case that less than 16 colors are generated, repeat the sequence.
+ for i := 0; i < 16-num_colors; i++ {
+ colors = append(colors, colors[i%num_colors])
+ }
}
// Output the configuration for terminal, or image
diff --git a/tests/Terminals/xterm/test-10colors b/tests/Terminals/xterm/test-10colors
new file mode 100644
index 0000000..b88eb8b
--- /dev/null
+++ b/tests/Terminals/xterm/test-10colors
@@ -0,0 +1,11 @@
+! Terminal colors
+*color0: #000211
+*color1: #bb0454
+*color2: #32b792
+*color3: #db9b64
+*color4: #15547b
+*color5: #910957
+*color6: #81148e
+*color7: #cacaca
+*color8: #282a3b
+*color9: #cd236d
diff --git a/tests/Terminals/xterm/test-4colors b/tests/Terminals/xterm/test-4colors
new file mode 100644
index 0000000..b737af9
--- /dev/null
+++ b/tests/Terminals/xterm/test-4colors
@@ -0,0 +1,5 @@
+! Terminal colors
+*color0: #000211
+*color1: #bb0454
+*color2: #32b792
+*color3: #db9b64
diff --git a/tests/Terminals/xterm/test-8colors b/tests/Terminals/xterm/test-8colors
new file mode 100644
index 0000000..6764357
--- /dev/null
+++ b/tests/Terminals/xterm/test-8colors
@@ -0,0 +1,9 @@
+! Terminal colors
+*color0: #000211
+*color1: #bb0454
+*color2: #32b792
+*color3: #db9b64
+*color4: #15547b
+*color5: #910957
+*color6: #81148e
+*color7: #cacaca