-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update the codebase (unclean)
- Loading branch information
Showing
53 changed files
with
1,751 additions
and
1,567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
__version__ = '0.5.1' | ||
__version__ = '0.7.0' | ||
__version_info__ = tuple([ int(num) for num in __version__.split('.')]) | ||
|
||
# For tests to run successfully | ||
import sys | ||
from os.path import abspath, dirname, join | ||
sys.path.append(abspath(join(dirname(__file__), '.'))) | ||
|
||
|
||
from .editor import Editor |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,78 @@ | ||
import tkinter as tk | ||
|
||
from ..config import Config | ||
from .events import Events | ||
from .linenumbers import LineNumbers | ||
from ...utils import Scrollbar | ||
from ..editor import BaseEditor | ||
|
||
from .minimap import Minimap | ||
from .scrollbar import Scrollbar | ||
from .language import SyntaxLoader | ||
from .linenumbers import LineNumbers | ||
from .text import Text | ||
from .find_replace import FinderReplacer | ||
|
||
|
||
class Editor(tk.Frame): | ||
def __init__(self, master, *args, **kwargs): | ||
super().__init__(master, *args, **kwargs) | ||
self.master = master | ||
|
||
self.config = Config(self) | ||
self.font = self.config.font | ||
|
||
self.syntax = SyntaxLoader() | ||
|
||
self.grid_rowconfigure(0, weight=1) | ||
self.grid_columnconfigure(1, weight=1) | ||
|
||
self.text = Text(self) | ||
self.linenumebers = LineNumbers(self, self.text) | ||
self.minimap = Minimap(self, self.text) | ||
self.scrollbar = Scrollbar(self, self.text) | ||
|
||
# actual find-replace widget | ||
# self.find_replace = FindReplace(self, self.text) | ||
# self.find_replace_active = False | ||
self.find_replace = FinderReplacer(self) | ||
self.find_replace.on_close() | ||
#self.text.bind("<Control-s>", self.find_replace.revive) | ||
class TextEditor(BaseEditor): | ||
def __init__(self, master, path=None, exists=True, minimalist=False, *args, **kwargs): | ||
super().__init__(master, path, exists, *args, **kwargs) | ||
self.font = self.base.settings.font | ||
self.minimalist = minimalist | ||
|
||
self.rowconfigure(0, weight=1) | ||
self.columnconfigure(1, weight=1) | ||
|
||
self.linenumebers.grid(row=0, column=0, sticky=tk.NS) | ||
self.text = Text(self, path=self.path, exists=self.exists, minimalist=minimalist) | ||
self.linenumbers = LineNumbers(self, text=self.text) | ||
self.scrollbar = Scrollbar(self, orient=tk.VERTICAL, command=self.text.yview) | ||
|
||
self.text.config(font=self.font) | ||
self.text.configure(yscrollcommand=self.scrollbar.set) | ||
|
||
if not self.minimalist: | ||
self.minimap = Minimap(self, self.text) | ||
self.minimap.grid(row=0, column=2, sticky=tk.NS) | ||
|
||
self.linenumbers.grid(row=0, column=0, sticky=tk.NS) | ||
self.text.grid(row=0, column=1, sticky=tk.NSEW) | ||
self.minimap.grid(row=0, column=2, sticky=tk.NS) | ||
self.scrollbar.grid(row=0, column=3, sticky=tk.NS) | ||
|
||
self.events = Events(self) | ||
self.text.config(yscrollcommand=self.text_scrolled) | ||
self.focus() | ||
self.text.bind("<<Change>>", self.on_change) | ||
self.text.bind("<<Scroll>>", self.on_scroll) | ||
|
||
def on_change(self, *_): | ||
self.text.refresh() | ||
self.linenumbers.redraw() | ||
self.base.update_statusbar() | ||
|
||
def text_scrolled(self, *args): | ||
pass | ||
def on_scroll(self, *_): | ||
self.linenumbers.redraw() | ||
if not self.minimalist: | ||
self.minimap.redraw() | ||
|
||
def show_find_replace(self, event): | ||
# positioning of the actual find_replace widget | ||
# if not self.find_replace_active: | ||
# pos_x, pos_y, width = self.text.winfo_rootx(), self.text.winfo_rooty(), self.text.winfo_width() | ||
# self.find_replace.show(((pos_x + width) - (self.find_replace.winfo_width() + 10), pos_y)) | ||
# else: | ||
# self.find_replace.reset() | ||
self.find_replace.revive(event) | ||
def unsupported_file(self): | ||
self.text.highlighter.lexer = None | ||
self.text.show_unsupported_dialog() | ||
self.linenumbers.grid_remove() | ||
self.scrollbar.grid_remove() | ||
self.editable = False | ||
|
||
def focus(self): | ||
self.text.focus() | ||
self.refresh_editor() | ||
self.on_change() | ||
|
||
def set_fontsize(self, size): | ||
self.font.configure(size=size) | ||
self.linenumebers.set_bar_width(size * 4) | ||
|
||
def refresh_editor(self, *_): | ||
self.text.on_change() | ||
self.text.highlighter.highlight_all() | ||
self.redraw_ln() | ||
self.minimap.redraw() | ||
self.scrollbar.redraw() | ||
|
||
def redraw_ln(self, *_): | ||
self.linenumebers.redraw() | ||
|
||
def insert(self, text): | ||
self.text.clear_insert(text) | ||
self.linenumbers.set_bar_width(size * 3) | ||
self.on_change() | ||
|
||
def save(self, path=None): | ||
if self.editable: | ||
self.text.save_file(path) | ||
|
||
def load_file(self, filepath): | ||
self.text.load_file(filepath) | ||
def cut(self, *_): | ||
if self.editable: | ||
self.text.cut() | ||
|
||
def copy(self, *_): | ||
if self.editable: | ||
self.text.copy() | ||
|
||
def paste(self, *_): | ||
if self.editable: | ||
self.text.paste() |
Oops, something went wrong.