Right align the left editor
This commit is contained in:
parent
f8a3fc0bff
commit
2504dd0cff
4 changed files with 13 additions and 4 deletions
2
TODO
2
TODO
|
|
@ -1,5 +1,4 @@
|
|||
Todo:
|
||||
- Right align the left editor.
|
||||
- Keyboard shortcuts for resolving differences.
|
||||
- How to handle tabs?
|
||||
- Colourise file name.
|
||||
|
|
@ -29,6 +28,7 @@ Done:
|
|||
- Fix coast scrolling.
|
||||
- Put it on github.
|
||||
- tab key should align code.
|
||||
- Right align the left editor.
|
||||
|
||||
|
||||
Shelved:
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
self.left_editor = editor.Editor(is_right_aligned=True)
|
||||
self.left_editor.load(left_path)
|
||||
self.left_editor.view_widget.is_scrollbar_right = False
|
||||
self.right_editor = editor.Editor()
|
||||
|
|
@ -370,6 +370,7 @@ def main():
|
|||
if path_b is None:
|
||||
editor_ = editor.Editor(path_a)
|
||||
editor_.load(path_a)
|
||||
editor_.is_right_aligned = True
|
||||
else:
|
||||
editor_ = DiffEditor(path_a, path_b)
|
||||
asyncio.run(fill3.tui(PROJECT_NAME, editor_))
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ class Editor:
|
|||
THEMES = [pygments.styles.get_style_by_name(style)
|
||||
for style in ["monokai", "fruity", "native"]] + [None]
|
||||
|
||||
def __init__(self, text="", path="Untitled"):
|
||||
def __init__(self, text="", path="Untitled", is_right_aligned=False):
|
||||
self.path = os.path.normpath(path)
|
||||
self.set_text(text)
|
||||
self.mark = None
|
||||
|
|
@ -195,6 +195,7 @@ 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):
|
||||
|
|
@ -626,6 +627,13 @@ 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
|
||||
|
|
|
|||
2
setup.py
2
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.18#subdirectory=fill3"])
|
||||
"fill3 @ git+https://github.com/ahamilton/eris@v2022.01.21#subdirectory=fill3"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue