From 15955422635775e684c23a3f45c8a4709e12ee36 Mon Sep 17 00:00:00 2001 From: Kaleb Efflandt Date: Mon, 20 Jan 2025 20:35:57 -0600 Subject: [PATCH] Fixes to YML editor --- source/menu.py | 59 +++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/source/menu.py b/source/menu.py index bfb8e1db..c5f34287 100644 --- a/source/menu.py +++ b/source/menu.py @@ -23410,13 +23410,10 @@ def get_y(lb, ref_y): # Check if search matches in key label if text in self.key_label.text: - self.key_label.text = f'[color=#000000][ref=0]{text}[/ref][/color]'.join( - [x for x in self.key_label.original_text.split(text)]) + self.key_label.text = f'[color=#000000][ref=0]{text}[/ref][/color]'.join([x for x in self.key_label.original_text.split(text)]) self.line_matched = True - elif key_text and self.key_label.text.endswith(key_text) and self.value_label.original_text.startswith( - value_text): - self.key_label.text = f'[color=#000000][ref=0]{key_text}[/ref][/color]'.join( - [x for x in self.key_label.original_text.rsplit(key_text, 1)]) + elif key_text and self.key_label.text.endswith(key_text) and self.value_label.original_text.startswith(value_text): + self.key_label.text = f'[color=#000000][ref=0]{key_text}[/ref][/color]'.join([x for x in self.key_label.original_text.rsplit(key_text, 1)]) self.line_matched = True else: self.key_label.text = self.key_label.original_text @@ -23424,13 +23421,10 @@ def get_y(lb, ref_y): # Check if search matches in value input/ghost label if text in self.value_label.text: - self.value_label.search.text = f'[color=#000000][ref=0]{text}[/ref][/color]'.join( - [x for x in self.value_label.text.split(text)]) + self.value_label.search.text = f'[color=#000000][ref=0]{text}[/ref][/color]'.join([x for x in self.value_label.text.split(text)]) self.line_matched = True - elif value_text and self.value_label.text.startswith( - value_text) and self.key_label.original_text.endswith(key_text): - self.value_label.search.text = f'[color=#000000][ref=0]{value_text}[/ref][/color]'.join( - [x for x in self.value_label.text.split(value_text, 1)]) + elif value_text and self.value_label.text.startswith(value_text) and self.key_label.original_text.endswith(key_text): + self.value_label.search.text = f'[color=#000000][ref=0]{value_text}[/ref][/color]'.join([x for x in self.value_label.text.split(value_text, 1)]) self.line_matched = True else: self.value_label.search.text = self.value_label.text @@ -24532,6 +24526,7 @@ def on_index_update(self): def on_resize(self, *args): Clock.schedule_once(self.key_label.texture_update, -1) Clock.schedule_once(self.eq_label.texture_update, -1) + Clock.schedule_once(self.value_label.search.texture_update, -1) def after_texture_update(*a): self.key_label.size_hint_max = self.key_label.texture_size self.eq_label.size_hint_max = self.eq_label.texture_size @@ -24541,6 +24536,18 @@ def after_texture_update(*a): self.value_label.x = self.eq_label.x + self.eq_label.size_hint_max[0] + (self.spacing * 0.75) self.value_label.y = -6 + # Properly position comments + if self.is_comment: + if not self._comment_padding: + self._comment_padding = self.key_label.size_hint_max_y * 0.75 + self.key_label.size_hint_max_y = self._comment_padding + self.key_label.size_hint_max_x = Window.width + + # Properly position search text + vl = self.value_label + vl.search.x = vl.x + 6 + vl.search.y = vl.y + (5 if 'italic' in vl.font_name.lower() else 7) + 10 + # Additional cover elements for ghosting or blocking touches try: self.ghost_cover_left.x = -10 @@ -24609,6 +24616,7 @@ def get_y(lb, ref_y): self.value_label.foreground_color = (0, 0, 0, 0) self.value_label.search.opacity = 1 + else: # Reset visuals self.line_number.text = str(self.line) @@ -24671,6 +24679,7 @@ def __init__(self, line, key, value, indent_level, is_header, is_list_header, ma self.is_blank_line = is_blank_line self.inactive = is_header or is_list_header or is_comment or is_blank_line self._finished_rendering = False + self._comment_padding = None def finish_rendering(*a): self._finished_rendering = True Clock.schedule_once(finish_rendering, 1) @@ -24751,10 +24760,6 @@ def on_text(me, *args): me.search.font_name = me.font_name me.search.text_size = me.search.size - if me.scroll_x == 0: - me.search.x = me.x + 5.3 - me.search.y = me.y + (5 if 'italic' in me.font_name.lower() else 7) - if me.search.opacity == 1: me.foreground_color = (0, 0, 0, 0) @@ -24973,7 +24978,10 @@ def on_touch_down(me, touch): self.line_number.pos_hint = {'center_y': 0.7} # Key label - self.key_label = Label() + if self.is_comment: + self.key_label = AlignLabel(halign='left') + else: + self.key_label = Label() self.key_label.__translate__ = False self.key_label.text = key self.key_label.original_text = key @@ -24981,7 +24989,7 @@ def on_touch_down(me, touch): self.key_label.font_size = self.font_size self.key_label.max_lines = 1 self.key_label.shorten = True - self.key_label.shorten_from = 'left' + self.key_label.shorten_from = 'right' self.key_label.markup = True self.key_label.default_color = "#636363" if is_comment else (0.5, 0.5, 1, 1) if is_header else "#5E6BFF" self.key_label.color = self.key_label.default_color @@ -25009,20 +25017,21 @@ def on_touch_down(me, touch): undo_func=undo_func ) - # Add all widgets - self.add_widget(self.line_number) - self.add_widget(self.key_label) - if not (is_blank_line or is_comment): - self.add_widget(self.eq_label) if not is_header and not is_list_header: self.add_widget(self.value_label) # Ghost covers for left / right self.ghost_cover_left = Image(color=background_color) self.ghost_cover_right = Image(color=background_color) - # self.add_widget(self.ghost_cover_left) - # self.add_widget(self.ghost_cover_right) + self.add_widget(self.ghost_cover_left) + self.add_widget(self.ghost_cover_right) + + # Add remaining widgets + if not (is_blank_line or is_comment): + self.add_widget(self.eq_label) + self.add_widget(self.line_number) + self.add_widget(self.key_label) Clock.schedule_once(self.key_label.texture_update, -1) Clock.schedule_once(self.eq_label.texture_update, -1)