word wrapping yum

This commit is contained in:
2026-02-21 23:55:38 -05:00
parent bdd0fbc1c4
commit 3d3c4e80ae

35
gui.py
View File

@@ -1349,11 +1349,25 @@ class App:
def _rebuild_disc_list(self):
if not dpg.does_item_exist("disc_scroll"):
return
def _toggle_read(s, a, idx):
# Save edit box content before switching to read mode
tag = f"disc_content_{idx}"
if dpg.does_item_exist(tag) and not self.disc_entries[idx].get("read_mode", False):
self.disc_entries[idx]["content"] = dpg.get_value(tag)
self.disc_entries[idx]["read_mode"] = not self.disc_entries[idx].get("read_mode", False)
self._rebuild_disc_list()
dpg.delete_item("disc_scroll", children_only=True)
for i, entry in enumerate(self.disc_entries):
collapsed = entry.get("collapsed", False)
read_mode = entry.get("read_mode", False)
ts_str = entry.get("ts", "")
preview = entry["content"].replace("\n", " ")[:60]
if len(entry["content"]) > 60:
preview += "..."
with dpg.group(parent="disc_scroll"):
with dpg.group(horizontal=True):
dpg.add_button(
@@ -1369,6 +1383,12 @@ class App:
width=120,
callback=self._make_disc_role_cb(i),
)
if not collapsed:
dpg.add_button(
label="[Edit]" if read_mode else "[Read]",
user_data=i,
callback=_toggle_read
)
if ts_str:
dpg.add_text(ts_str, color=(120, 120, 100))
if collapsed:
@@ -1379,27 +1399,26 @@ class App:
)
dpg.add_button(
label="[+ Max]",
user_data=f"disc_content_{i}",
callback=lambda s, a, u, idx=i: _show_text_viewer(f"Entry #{idx+1}", dpg.get_value(u) if dpg.does_item_exist(u) else "")
callback=lambda s, a, u, idx=i: _show_text_viewer(f"Entry #{idx+1}", self.disc_entries[idx]["content"])
)
dpg.add_button(
label="Del",
width=36,
callback=self._make_disc_remove_cb(i),
)
if collapsed:
with dpg.group(horizontal=True):
dpg.add_spacer(width=28) # Indent text past the expand/collapse button
dpg.add_text(entry["content"], wrap=0, color=(200, 200, 200))
dpg.add_text(preview, color=(160, 160, 150))
with dpg.group(tag=f"disc_body_{i}", show=not collapsed):
if read_mode:
with dpg.child_window(height=150, border=True):
dpg.add_text(entry["content"], wrap=0, color=(200, 200, 200))
else:
dpg.add_input_text(
tag=f"disc_content_{i}",
default_value=entry["content"],
multiline=True,
width=-1,
height=100,
height=150,
callback=self._make_disc_content_cb(i),
on_enter=False,
)