diff --git a/src/class_todo.py b/src/class_todo.py index 290eb3d..11e9c05 100644 --- a/src/class_todo.py +++ b/src/class_todo.py @@ -56,10 +56,12 @@ def _init_box_char(self, pointer: int) -> tuple[BoxChar, int]: def _init_color(self, pointer: int) -> tuple[Color, int]: if ( len(self.text) > pointer + 1 - and self.text[pointer].isdigit() and self.text[pointer + 1] == " " ): - return Color(int(self.text[pointer])), pointer + 2 + if self.text[pointer].isdigit(): + return Color(int(self.text[pointer])), pointer + 2 + if self.text[pointer] in "rgybmcw": + return Color.from_first_char(self.text[pointer]), pointer + 2 return Color.WHITE, pointer def _init_attrs(self) -> tuple[BoxChar, Color, str]: @@ -167,7 +169,7 @@ def __repr__(self) -> str: self.box_char != BoxChar.NONE and not self.is_empty(), str(self.box_char), ), - Chunk(self.color != Color.WHITE, str(self.color.as_int())), + Chunk(self.color != Color.WHITE, str(self.color.as_char())), Chunk( (self.box_char != BoxChar.NONE and not self.is_empty()) or self.color != Color.WHITE, diff --git a/src/utils.py b/src/utils.py index e84b1c3..529380f 100644 --- a/src/utils.py +++ b/src/utils.py @@ -41,6 +41,23 @@ def as_int(self) -> int: """ return self.value + def as_char(self) -> str: + """Get lowercase first letter of color""" + return self.name[0].lower() + + @staticmethod + def from_first_char(char: str) -> "Color": + """Return the color corresponding to its first character""" + return { + "r": Color.RED, + "g": Color.GREEN, + "y": Color.YELLOW, + "b": Color.BLUE, + "m": Color.MAGENTA, + "c": Color.CYAN, + "w": Color.WHITE, + }[char] + @staticmethod def as_dict() -> dict[str, int]: """ diff --git a/todo.txt b/todo.txt index 3410a93..16994bc 100644 --- a/todo.txt +++ b/todo.txt @@ -1,17 +1,16 @@ --1 fix strikethrough - -1 fix long lines (longer than width // 2 - 1) - -1 fix moving down onto a toggled line --4 implement multiline todos - -4 allow multiline paste - -4 allow multiline print --5 make startup faster --1 fix silence if dependencies are not installed --2 add unit tests? --2 use color names first letter rather than number (rgybmcw) --3 add docstrings to `public` functions - -3 clipboard - -3 get_todo - -3 todo.py --3 migrate from sometimes using `int` as cursor, to always using `Cursor`s --3 migrate from `win: Any` to `win: curses.window` +-r fix strikethrough + -r fix long lines (longer than width // 2 - 1) + -r fix moving down onto a toggled line +-b implement multiline todos + -b allow multiline paste + -b allow multiline print +-m make startup faster +-r fix silence if dependencies are not installed +-g add unit tests? +-y add docstrings to `public` functions + -y clipboard + -y get_todo + -y todo.py +-y migrate from sometimes using `int` as cursor, to always using `Cursor`s +-y migrate from `win: Any` to `win: curses.window` - fix gui support \ No newline at end of file