mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-16 13:08:25 +00:00
Merge branch 'fix-i586-build-pr' of https://github.com/Blarse/kitty
This commit is contained in:
commit
d49e07db22
5 changed files with 14 additions and 8 deletions
|
|
@ -1890,7 +1890,9 @@ init_ColorProfile(PyObject *module) {
|
|||
Py_INCREF(&Color_Type);
|
||||
|
||||
if (PyModule_AddFunctions(module, module_methods) != 0) return false;
|
||||
PyModule_AddIntMacro(module, NULL_COLOR_VALUE);
|
||||
// PyModule_AddIntMacro converts to signed long, which overflows on 32-bit platforms.
|
||||
RAII_PyObject(null_color_value, PyLong_FromUnsignedLong(NULL_COLOR_VALUE));
|
||||
if (!null_color_value || PyModule_AddObjectRef(module, "NULL_COLOR_VALUE", null_color_value) != 0) return 0;
|
||||
PyModule_AddIntMacro(module, COLOR_LAYER_OVERRIDE);
|
||||
PyModule_AddIntMacro(module, COLOR_LAYER_GLOBAL);
|
||||
PyModule_AddIntMacro(module, COLOR_LAYER_WINDOW);
|
||||
|
|
|
|||
|
|
@ -116,7 +116,10 @@ class TestDataTypes(BaseTest):
|
|||
(rgba, 2**32 + 2, 2),
|
||||
(rgba, -2, -2),
|
||||
):
|
||||
with self.assertRaises(ValueError, msg=repr(args[1:])):
|
||||
# Dimensions outside Py_ssize_t fail during argument parsing, before
|
||||
# the buffer length and dimension validation can raise ValueError.
|
||||
error = OverflowError if any(x > sys.maxsize for x in args[1:]) else ValueError
|
||||
with self.assertRaises(error, msg=repr(args[1:])):
|
||||
png_from_32bit_rgba_data(*args)
|
||||
with self.assertRaises(OverflowError):
|
||||
png_from_32bit_rgba_data(rgba, 2, 2**64 + 2)
|
||||
|
|
|
|||
|
|
@ -2581,8 +2581,9 @@ class TestScreen(BaseTest):
|
|||
self.assertNotIn('mark1_background', cp.as_dict())
|
||||
|
||||
def test_color_profile(self):
|
||||
from kitty.fast_data_types import patch_color_profiles
|
||||
from kitty.fast_data_types import NULL_COLOR_VALUE, patch_color_profiles
|
||||
|
||||
self.ae(NULL_COLOR_VALUE, 0xFFFFFFFF)
|
||||
opts = self.set_options({'palette_generate': 'fixed'})
|
||||
c = ColorProfile(opts)
|
||||
for i in range(8):
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ var special_color_values = map[string]map[string]int{
|
|||
// Encode a color that accepts special values the same way as
|
||||
// color_with_special_values() in kitty/options/utils.py: special values are
|
||||
// stored in the lowest byte and actual colors are shifted into the upper bytes.
|
||||
func encode_special_color(key, val string) (int, error) {
|
||||
func encode_special_color(key, val string) (int64, error) {
|
||||
special_values, found := special_color_values[key]
|
||||
if !found {
|
||||
return 0, fmt.Errorf("The special values for the color %s are not known", key)
|
||||
|
|
@ -312,13 +312,13 @@ func encode_special_color(key, val string) (int, error) {
|
|||
}
|
||||
}
|
||||
if ans, found := special_values[val]; found {
|
||||
return ans, nil
|
||||
return int64(ans), nil
|
||||
}
|
||||
col, err := style.ParseColor(val)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("%s is not a valid color", val)
|
||||
}
|
||||
return int(col.AsRGB())<<8 | len(special_values), nil
|
||||
return int64(col.AsRGB())<<8 | int64(len(special_values)), nil
|
||||
}
|
||||
|
||||
func set_color_in_color_map(key, val string, ans map[string]any, check_nullable, skip_nullable bool) error {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func TestSetColorsConfFiles(t *testing.T) {
|
|||
expected := map[string]any{
|
||||
"foreground": uint32(0xff0000), "background": uint32(0xff), "cursor": nil,
|
||||
"selection_background": uint32(0xff00), "color1": uint32(0xaaaaaa),
|
||||
"wayland_titlebar_color": 1,
|
||||
"wayland_titlebar_color": int64(1),
|
||||
}
|
||||
if len(payload.Colors) != len(expected) {
|
||||
t.Fatalf("unexpected colors parsed from conf file: %#v", payload.Colors)
|
||||
|
|
@ -101,7 +101,7 @@ func TestSetColorsSpecialColors(t *testing.T) {
|
|||
// expected values are from kitty.colors.parse_colors()
|
||||
for _, test := range []struct {
|
||||
arg string
|
||||
expected int
|
||||
expected int64
|
||||
}{
|
||||
{"wayland_titlebar_color=#123456", 0x12345602},
|
||||
{"wayland_titlebar_color=system", 0},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue