about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-10 23:46:59 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-10 23:47:18 +0200
commit5d0561ab1507acd0c6b18976d34db427f7351433 (patch)
tree07a9bcdc58e3e87f405816bb08a31211d4f711f9
parent6dfccdea61d1effba3b15fb19fd2034be188ec16 (diff)
downloadchawan-5d0561ab1507acd0c6b18976d34db427f7351433.tar.gz
config: add display.sixel-colors
-rw-r--r--doc/config.md10
-rw-r--r--res/config.toml1
-rw-r--r--src/config/config.nim1
-rw-r--r--src/local/term.nim3
4 files changed, 15 insertions, 0 deletions
diff --git a/doc/config.md b/doc/config.md
index b3f2df8d..d4253b4e 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -483,6 +483,16 @@ images.
 </tr>
 
 <tr>
+<td>sixel-colors</td>
+<td>"auto" / 3..65535</td>
+<td>Only applies when `display.image-mode="sixel"`. Setting a number
+overrides the number of sixel color registers reported by the terminal,
+while "auto" leaves color detection to Chawan.<br>
+Defaults to "auto".
+</td>
+</tr>
+
+<tr>
 <td>alt-screen</td>
 <td>"auto" / boolean</td>
 <td>Enable/disable the alternative screen.</td>
diff --git a/res/config.toml b/res/config.toml
index a8782216..1a7318a0 100644
--- a/res/config.toml
+++ b/res/config.toml
@@ -292,6 +292,7 @@ color-mode = "auto"
 format-mode = "auto"
 no-format-mode = ["overline"]
 image-mode = "auto"
+sixel-colors = "auto"
 alt-screen = "auto"
 highlight-color = "cyan"
 highlight-marks = true
diff --git a/src/config/config.nim b/src/config/config.nim
index b0064aa2..3763b98d 100644
--- a/src/config/config.nim
+++ b/src/config/config.nim
@@ -127,6 +127,7 @@ type
     format_mode* {.jsgetset.}: Option[set[FormatFlag]]
     no_format_mode* {.jsgetset.}: set[FormatFlag]
     image_mode* {.jsgetset.}: Option[ImageMode]
+    sixel_colors* {.jsgetset.}: Option[int32]
     alt_screen* {.jsgetset.}: Option[bool]
     highlight_color* {.jsgetset.}: ARGBColor
     highlight_marks* {.jsgetset.}: bool
diff --git a/src/local/term.nim b/src/local/term.nim
index e9b404a1..3ab72d80 100644
--- a/src/local/term.nim
+++ b/src/local/term.nim
@@ -618,6 +618,9 @@ proc applyConfig(term: Terminal) =
       term.formatMode.excl(fm)
   if term.config.display.image_mode.isSome:
     term.imageMode = term.config.display.image_mode.get
+  if term.imageMode == imSixel and term.config.display.sixel_colors.isSome:
+    let n = term.config.display.sixel_colors.get
+    term.sixelRegisterNum = clamp(n, 3, 65535)
   if term.isatty():
     if term.config.display.alt_screen.isSome:
       term.smcup = term.config.display.alt_screen.get