Skip to content

Commit

Permalink
Merge pull request #215 from vancluever/backend-kitty-drop-frac
Browse files Browse the repository at this point in the history
backends/kitty: Drop fractional portions when stringifying numbers
  • Loading branch information
3rd authored Sep 22, 2024
2 parents 4007cdd + 25610ca commit f95cb9c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lua/image/backends/kitty/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,20 @@ local write_graphics = function(config, data)
for k, v in pairs(config) do
if v ~= nil then
local key = codes.control.keys[k]
if key then control_payload = control_payload .. key .. "=" .. v .. "," end
if key then
if type(v) == "number" then
-- There are currently no floating-point values in the Kitty graphics
-- specification. All values are either signed or unsigned 32-bit integers.
-- As such, we just stringify the number values here using "%d" to drop any
-- possible fractional portions.
--
-- (Note that string.format here is used to accommodate older versions of
-- Lua, in addition to the fact that we are just writing the string below
-- anyway).
v = string.format("%d", v)
end
control_payload = control_payload .. key .. "=" .. v .. ","
end
end
end
control_payload = control_payload:sub(0, -2)
Expand Down

0 comments on commit f95cb9c

Please sign in to comment.