From baab068dc5404fbd374fad326f19d2e0c77e4d15 Mon Sep 17 00:00:00 2001 From: Moosems <95927277+Moosems@users.noreply.github.com> Date: Sat, 11 May 2024 10:11:33 -0400 Subject: [PATCH] Fix justify and format (#52) --- chlorophyll/codeview.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/chlorophyll/codeview.py b/chlorophyll/codeview.py index 6336c5c..1c54c4c 100644 --- a/chlorophyll/codeview.py +++ b/chlorophyll/codeview.py @@ -58,18 +58,22 @@ def __init__( kwargs.setdefault("wrap", "none") kwargs.setdefault("font", ("monospace", 11)) + linenum_justify = kwargs.pop("justify", "left") + super().__init__(self._frame, **kwargs) super().grid(row=0, column=1, sticky="nswe") self._line_numbers = TkLineNumbers( self._frame, self, - justify=kwargs.get("justify", "left"), + justify=linenum_justify, colors=linenums_theme, - borderwidth=kwargs.get("borderwidth", linenums_border) + borderwidth=kwargs.get("borderwidth", linenums_border), ) self._vs = Scrollbar(self._frame, autohide=autohide_scrollbar, orient="vertical", command=self.yview) - self._hs = Scrollbar(self._frame, autohide=autohide_scrollbar, orient="horizontal", command=self.xview) + self._hs = Scrollbar( + self._frame, autohide=autohide_scrollbar, orient="horizontal", command=self.xview + ) self._line_numbers.grid(row=0, column=0, sticky="ns") self._vs.grid(row=0, column=2, sticky="ns") @@ -124,13 +128,21 @@ def _create_context_menu(self) -> Menu: if self._default_context_menu: contmand = "⌘" if self._windowingsystem == "aqua" else "Ctrl" - context_menu.add_command(label="Undo", accelerator=f"{contmand}+Z", command=lambda: self.event_generate("<>")) - context_menu.add_command(label="Redo", accelerator=f"{contmand}+Y", command=lambda: self.event_generate("<>")) + context_menu.add_command( + label="Undo", accelerator=f"{contmand}+Z", command=lambda: self.event_generate("<>") + ) + context_menu.add_command( + label="Redo", accelerator=f"{contmand}+Y", command=lambda: self.event_generate("<>") + ) context_menu.add_separator() - context_menu.add_command(label="Cut", accelerator=f"{contmand}+X", command=lambda: self.event_generate("<>")) + context_menu.add_command( + label="Cut", accelerator=f"{contmand}+X", command=lambda: self.event_generate("<>") + ) context_menu.add_command(label="Copy", accelerator=f"{contmand}+C", command=self._copy) context_menu.add_command(label="Paste", accelerator=f"{contmand}+V", command=self._paste) - context_menu.add_command(label="Select all", accelerator=f"{contmand}+A", command=self._select_all) + context_menu.add_command( + label="Select all", accelerator=f"{contmand}+A", command=self._select_all + ) return context_menu