aboutsummaryrefslogtreecommitdiff
path: root/scripts (unfollow)
Commit message (Collapse)AuthorLines
2025-04-30scripts: srgb: use 2.2 gamma TF instead of piece-wise sRGB TFDaniel Eklöf-24/+5
2025-04-28scripts: srgb: use 2.2 gamma TF instead of piece-wise sRGB TFDaniel Eklöf-24/+5
2025-03-05render: gamma-correct blendingDaniel Eklöf-0/+90
This implements gamma-correct blending, which mainly affects font rendering. The implementation requires compile-time availability of the new color-management protocol (available in wayland-protocols >= 1.41), and run-time support for the same in the compositor (specifically, the EXT_LINEAR TF function and sRGB primaries). How it works: all colors are decoded from sRGB to linear (using a lookup table, generated in the exact same way pixman generates it's internal conversion tables) before being used by pixman. The resulting image buffer is thus in decoded/linear format. We use the color-management protocol to inform the compositor of this, by tagging the wayland surfaces with the 'ext_linear' image attribute. Sixes: all colors are sRGB internally, and decoded to linear before being used in any sixels. Thus, the image buffers will contain linear colors. This is important, since otherwise there would be a decode/encode penalty every time a sixel is blended to the grid. Emojis: we require fcft >= 3.2, which adds support for sRGB decoding color glyphs. Meaning, the emoji pixman surfaces can be blended directly to the grid, just like sixels. Gamma-correct blending is enabled by default *when the compositor supports it*. There's a new option to explicitly enable/disable it: gamma-correct-blending=no|yes. If set to 'yes', and the compositor does not implement the required color-management features, warning logs are emitted. There's a loss of precision when storing linear pixels in 8-bit channels. For this reason, this patch also adds supports for 10-bit surfaces. For now, this is disabled by default since such surfaces only have 2 bits for alpha. It can be enabled with tweak.surface-bit-depth=10-bit. Perhaps, in the future, we can enable it by default if: * gamma-correct blending is enabled * the user has not enabled a transparent background
2024-06-26scripts: generate-emoji-variation-sequences: don't assume single codepoint sequencesDaniel Eklöf-4/+11
Right now (Unicode 15.1), all valid variation sequences consist of a single Unicode codepoint (followed by either VS-15 or VS-16). Don't assume this is the case. We don't actually handle longer sequences. But now we at least catch such escapes, and error out.
2024-06-26scripts: generate-emoji-variation-sequences: compact the C structDaniel Eklöf-3/+3
Lookups in this table is not performance critical at all. Thus, let's compact it to bring down the binary size of foot. This brings the size of each entry down from 9 bytes to 6, bringing the size of the whole thing down from 1647 bytes to 1098 bytes, saving us 549 bytes.
2024-06-25scripts: generate-emoji-variation-sequences: don't assume input is sortedDaniel Eklöf-15/+16
2024-06-25vt: only apply VS-15/16 to valid sequencesDaniel Eklöf-0/+95
At compile time, build a lookup table from the Unicode data file 'emoji-variation-sequences.txt'. At run-time, when we detect a VS-15/16 sequence, do a lookup in this table, and enforce the variation selector iff the sequence is valid. Closes #1742
2024-05-01scripts: generate-builtin-terminfo: fix syntax errorArtturin-1/+1
2024-04-30scripts: generate-builtin-terminfo: use \xNN for control charactersDaniel Eklöf-3/+3
Instead of emitting raw control characters (for e.g. bel, cub1 and kbs), use \xNN C string escapes.
2024-04-27dcs: xtgettcap: always reply with tigetstr(3) formatted "strings"Daniel Eklöf-16/+22
That is, instead of sometimes replying with a "source" encoded string (where e.g. '\E' are returned just like that, and not as an actual ESC), always unescape all string values. This also includes \n \r \t \b \f \s, \^ \\ \ \:, as well as ^x-styled escapes. Closes #1701
2024-03-25scripts: generate-alt-random: generate both opaque and transparent sixelsDaniel Eklöf-2/+3
2023-06-29scripts: generate-alt-random: set P2=1 when emitting sixelsDaniel Eklöf-2/+2
P2=1 means "empty sixels remain at their current color". This is usually the case with modern sixel encoders.
2022-10-05scripts: generate-builtin-terminfo: escape fixesDaniel Eklöf-7/+14
* Remove ‘:’ escaping only in raw (non-parameterized) sequences * Double-escape *all* escape characters in parameterized sequences
2022-10-05scripts: generate-builtin-terminfo: double-escape backslash in STDaniel Eklöf-0/+4
Fixes an issue with XTGETTCAP, where escape sequences terminated with ST, and containing parameters were missing a trailing backslash.
2022-09-28scripts: generate-builtin-terminfo: add synthetic ‘name’ capabilityDaniel Eklöf-0/+1
Same as ‘TN’; reports the terminfo name.
2022-01-13xtgettcap: switch from a table based internal structure, to a single char arrayDaniel Eklöf-33/+24
Having the builtin terminfo DB as a table, with one entry per capability/value pair was ineffective memory-wise - we ended up adding ~20K to the final binary size. This patch changes the internal representation from a table, to a single NULL-separated (and NULL-terminated) char array: cap1-name \0 cap1-value \0 cap2-name \0 cap2-value \0 The capabilities are still sorted; to lookup a capability we need to scan from the beginning until we either find a match, or until the capabilities from the DB sort higher (lexicographically) than the searched-for capability. The terminfo char array is 3.3K - more better than before.
2022-01-13dcs: xtgettcap: handle boolean capabilitiesDaniel Eklöf-4/+5
Reply with DCS 1 + r <cap> ST
2022-01-13scripts: generate-builtin-terminfo: add custom capability ‘Co’Daniel Eklöf-1/+2
This is a “special feature”, similar to “TN” and “RGB”: Co for termcap colors (or colors for terminfo colors)
2022-01-13script: add generate-builtin-terminfo.pyDaniel Eklöf-0/+202
This script parses a terminfo source file and generates a C header file with a static struct containing terminfo names and their values. The table is sorted on the capability names
2021-06-24scripts: generate-alt-random: add emoji sequencesDaniel Eklöf-1/+1
2021-04-22generate-alt-random: don’t run TIOCGWINSZ ioctl if --cols and --rows were usedDaniel Eklöf-24/+25
2021-04-22generate-alt-random: do ioctl(TIOCGWINSZ) on /dev/tty, not stdoutDaniel Eklöf-5/+6
2021-04-22generate-alt-random: wait for SIGWINCH if width/height is 0Daniel Eklöf-6/+24
If width/height (that is, the *pixel* values) are 0, that means we are early (or that foot is slow) - we’ve managed to reach this point before the foot window has been mapped. Or rather, before foot has loaded the primary fonts and calculated the cell geometry. But that, and the initial mapping of the window is tightly coupled. To handle this case, detect when width or height is 0, an then wait for SIGWINCH before trying again.
2021-04-22generate-alt-random: assert that lines/cols/width/height are > 0Daniel Eklöf-0/+5
2021-04-22generate-alt-random: use {width,height} + 1 in randrange()Daniel Eklöf-1/+1
When randomizing the sixel width and height, use width/height + 1 in the call to randrange(). This ensures the width/height is never 0, and that the maximum width/height is half the window size, not slightly less than that.
2021-03-14scripts: generate-alt-random: reduce number of emitted sixelsDaniel Eklöf-1/+1
After emitting multiple color bands for each sixel row, the increased amount of sixel data shifted the balance in the profiling data, causing a performance regression in regular ASCII handling.
2021-03-11generate-alt-random: sixel: emit at least 4 color bandsDaniel Eklöf-1/+1
This fixes an issue where there was a relatively high chance of not emitting any color bands at all, causing the final image size to be too small.
2021-03-11generate-alt-random: DECGRI: don’t emit zero-length repeat sequencesDaniel Eklöf-3/+3
2021-03-11generate-alt-random: DECGRI: random repeat lengthsDaniel Eklöf-1/+5
2021-03-11generate-alt-random: don’t skip that last partial rowDaniel Eklöf-2/+3
2021-03-11generate-alt-random: emit “Set Raster Attributes” before color definitionsDaniel Eklöf-4/+4
2021-03-11generate-alt-random: 50% chance of overwriting the last sixelDaniel Eklöf-6/+14
2021-03-11generate-alt-random: emit sixels on the alt screenDaniel Eklöf-2/+5
2021-03-11generate-alt-random: emit multiple sixel bandsDaniel Eklöf-10/+17
This ensures we’re getting the ‘$’ command PGO:d
2021-03-11generate-alt-random: sixel: pan/pad must not be 0Daniel Eklöf-1/+1
2021-03-11scripts: generate-alt-random: sixel: emit DECGRI - Repeat CharacterDaniel Eklöf-5/+6
2020-12-21generate-alt-random: ioctl(TIOCGWINSZ) may fail in run inside a containerDaniel Eklöf-5/+14
This _should_ only happen when we’re doing a partial PGO build, since then the script is run in the parent terminal. In this case, the user is expected to use --rows/--cols anyway.
2020-12-21generate-alt-random: ioctl(TIOCGWINSZ) may fail in run inside a containerDaniel Eklöf-5/+14
This _should_ only happen when we’re doing a partial PGO build, since then the script is run in the parent terminal. In this case, the user is expected to use --rows/--cols anyway.
2020-12-20generate-alt-random: override detected width/height when --cols/--rows have been usedDaniel Eklöf-0/+2
This ensures we have a valid width and height, that matches what the PGO helper binary expects.
2020-12-20generate-alt-random: fix “new style” cube escapeDaniel Eklöf-1/+1
It’s “38:5:<idx>”, not “38:2:5:<idx>”.
2020-12-20generate-alt-random-writes: use python random, allow setting a seedsterni-99/+101
Using Python's own PRNG should make the code cleaner and allow for reproducible stimulus files if that is desired via setting --seed (at least for the same versions of the script, changing the kind and/or order of the random calls will of course impact the output in the future). I did the following substitutions: * rand.read(1)[0] % n and struct.unpack('@H', rand.read(2))[0] % n → random.randrange(n) * rand.read(1)[0] → random.randrange(256) * rand.read(n) → [random.randrange(256) for _ in range(n)] (better alternative would have been random.randbytes(n), but is only available for Python >= 3.9, switching to this in the future will impact output) * list[rand.read(1) % len(list)] → random.choice(list)
2020-12-20generate-alt-random: override detected width/height when --cols/--rows have been usedDaniel Eklöf-0/+2
This ensures we have a valid width and height, that matches what the PGO helper binary expects.
2020-12-20generate-alt-random: fix “new style” cube escapeDaniel Eklöf-1/+1
It’s “38:5:<idx>”, not “38:2:5:<idx>”.
2020-12-20generate-alt-random-writes: use python random, allow setting a seedsterni-99/+101
Using Python's own PRNG should make the code cleaner and allow for reproducible stimulus files if that is desired via setting --seed (at least for the same versions of the script, changing the kind and/or order of the random calls will of course impact the output in the future). I did the following substitutions: * rand.read(1)[0] % n and struct.unpack('@H', rand.read(2))[0] % n → random.randrange(n) * rand.read(1)[0] → random.randrange(256) * rand.read(n) → [random.randrange(256) for _ in range(n)] (better alternative would have been random.randbytes(n), but is only available for Python >= 3.9, switching to this in the future will impact output) * list[rand.read(1) % len(list)] → random.choice(list)
2020-11-24scripts: generate-alt-random-writes: add --sixelDaniel Eklöf-1/+48
When --sixel is specified, we generate random sixel images in the ‘normal’ screen, after exiting the alt screen.
2020-11-22scripts: generate-alt-random-writes: add unicode and multi-column charsDaniel Eklöf-1/+1
2020-11-22scripts: generate-alt-random-writes: add support for bold/italic/underlineDaniel Eklöf-0/+10
2020-11-22scripts: generate-alt-random-writes: don’t always reset all attributesDaniel Eklöf-4/+5
2020-11-22scripts: generate-alt-random-writes: mix \e[S with \nDaniel Eklöf-1/+5
2020-11-22scripts: generate-alt-random-writes: add support for emitting 256-indexed colorsDaniel Eklöf-0/+15
2020-11-22scripts: generate-alt-random-writes: mix new/old-style RGB escapesDaniel Eklöf-1/+8
2020-11-22scripts: generate-alt-random-writes: add command line arguments for cols/rowsDaniel Eklöf-0/+7
2020-11-22scripts: generate-alt-random-writes: don’t re-use ‘count’ variableDaniel Eklöf-2/+2
2020-10-10selection: use appropriate check for PRIMARY pasteSergey Nazaryev-584/+43
Assume it could be a copy-paste typo. We should check PRIMARY, not CLIPBOARD. Without this fix, we can't use PRIMARY until we copy anything to CLIPBOARD.
2020-05-31scripts: benchmarking utility scriptDaniel Eklöf-0/+51
2020-05-09generate-unicode-precompose: /bin/sh is more standard than /usr/bin/shDaniel Eklöf-2/+2
At the same time, fix `cut` command to pass filename last, as this is also more portable. Fixes build issues on e.g. Alpine Linux
2020-05-09unicode-precompose: use fcft's precompose functionalityDaniel Eklöf-33/+0
This allows us more options when determining whether to use a pre-composed character or not: We now only use the pre-composed character if it's from the primary font, or if at least one of the base or combining characters are from a fallback font. I.e. use glyphs from the primary font if possible. But, if one or more of the decomposed glyphs are from a fallback font, use the pre-composed character anyway.
2020-05-02script: generate-unicode-precompose: generate a complete header fileDaniel Eklöf-2/+27
2020-05-02unicode-combine: remove utf8proc dependencyDaniel Eklöf-0/+8
We only used utf8proc to try to pre-compose a glyph from a base and combining character. We can do this ourselves by using a pre-compiled table of valid pre-compositions. This table isn't _that_ big, and binary searching it is fast. That is, for a very small amount of code, and not too much extra RO data, we can get rid of the utf8proc dependency.
2020-03-08scripts/generate-alt-random-writes: use TIOCGWINSZ instead of shutilDaniel Eklöf-4/+8
2019-12-19script: generate-alt-random: reduce output sizeDaniel Eklöf-1/+1
2019-09-20generate-alt-random-writes: reduce output sizeDaniel Eklöf-1/+1
2019-08-30generate-alt-random-writes: generate streaks of charactersDaniel Eklöf-1/+4
2019-08-23generate-alt-random-writes: reset SGR and scroll region at the endDaniel Eklöf-2/+2
2019-08-22generate-alt-random-writes: generate color, scroll and scroll region sequencesDaniel Eklöf-11/+72
2019-08-21generate-alt-random-writes: script to generate payload for profilingDaniel Eklöf-0/+35