diff --git a/diff_edit/__init__.py b/diff_edit/__init__.py index 2b70a14..0222b9e 100755 --- a/diff_edit/__init__.py +++ b/diff_edit/__init__.py @@ -128,7 +128,7 @@ def draw_connector(columns, color, left_y, right_y): class DiffEditor: def __init__(self, left_path, right_path): - self.left_editor = editor.Editor(is_right_aligned=True) + self.left_editor = editor.Editor(is_left_aligned=False) self.left_editor.load(left_path) self.left_editor.view_widget.is_left_scrollbar = True self.right_editor = editor.Editor() diff --git a/diff_edit/editor.py b/diff_edit/editor.py index ae45e41..657a5db 100755 --- a/diff_edit/editor.py +++ b/diff_edit/editor.py @@ -184,8 +184,9 @@ class Editor: THEMES = [pygments.styles.get_style_by_name(style) for style in ["monokai", "fruity", "native"]] + [None] - def __init__(self, text="", path="Untitled", is_right_aligned=False): + def __init__(self, text="", path="Untitled", is_left_aligned=True): self.path = os.path.normpath(path) + self.is_left_aligned = is_left_aligned self.set_text(text) self.mark = None self.clipboard = None @@ -195,7 +196,6 @@ class Editor: self.theme_index = 0 self.previous_term_code = None self.history = [] - self.is_right_aligned = is_right_aligned @property def cursor_x(self): @@ -252,6 +252,9 @@ class Editor: self.decor_widget = Decor(self.text_widget, lambda appearance: add_highlights(self, appearance)) self.view_widget = fill3.View.from_widget(self.decor_widget) + if not self.is_left_aligned: + self.view_widget.portal.is_scroll_limited = True + self.view_widget.portal.is_left_aligned = False self.cursor_x, self.cursor_y = 0, 0 self.original_text = self.text_widget.actual_text.copy() @@ -628,12 +631,6 @@ class Editor: def appearance_for(self, dimensions): width, height = dimensions text_width = self.text_widget.max_line_length - if self.is_right_aligned and text_width < width: - x, y = self.view_widget.position - new_x = text_width - width - if self.cursor_x == text_width: - new_x += 1 - self.view_widget.position = new_x, y is_changed = self.text_widget.actual_text != self.original_text header = self.get_header(self.path, width, self.cursor_x, self.cursor_y, is_changed) self.last_width = width diff --git a/setup.py b/setup.py index 17dbd8b..764ff7e 100755 --- a/setup.py +++ b/setup.py @@ -18,4 +18,4 @@ setup(name="diff-edit", entry_points={"console_scripts": ["diff-edit=diff_edit:main"]}, install_requires=[ "pygments==2.10.0", "docopt==0.6.2", - "fill3 @ git+https://github.com/ahamilton/eris@v2022.01.21#subdirectory=fill3"]) + "fill3 @ git+https://github.com/ahamilton/eris@v2022.01.24#subdirectory=fill3"])