From 072cd29e3c865dc3e385f9a69619c6094a3697a7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 13 Jan 2020 09:56:39 +0530 Subject: [PATCH] Make add_marker easier to use with combine --- kitty/config.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/kitty/config.py b/kitty/config.py index f49535b87..7bf2759c5 100644 --- a/kitty/config.py +++ b/kitty/config.py @@ -243,22 +243,18 @@ def disable_ligatures_in(func, rest): @func_with_args('add_marker') def add_marker(func, rest): - parts = rest.split(maxsplit=1) - if len(parts) != 2: + parts = rest.split(maxsplit=2) + if len(parts) != 3: raise ValueError('{} if not a valid marker specification'.format(rest)) - name = parts[0] - parts = parts[1].split(':', maxsplit=1) - if len(parts) != 2: - raise ValueError('{} if not a valid marker specification'.format(rest)) - ftype, spec = parts + name, ftype, spec = parts color = None if ftype in ('text', 'itext', 'regex'): flags = re.UNICODE - parts = spec.split(':', maxsplit=1) + parts = spec.split(maxsplit=1) if len(parts) != 2: raise ValueError('No color specified in marker: {}'.format(spec)) try: - color = int(parts[0]) + color = max(1, min(int(parts[0]), 3)) except Exception: raise ValueError('color {} in marker specification is not an integer'.format(parts[0])) spec = parts[1]