-
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.
revert: Clean unclean commit from main branch
- Loading branch information
Showing
53 changed files
with
1,567 additions
and
1,751 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,10 +1,3 @@ | ||
__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__), '.'))) | ||
|
||
__version__ = '0.5.1' | ||
|
||
from .editor import Editor |
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 |
---|---|---|
@@ -0,0 +1,188 @@ | ||
from .language import Language | ||
|
||
|
||
class CPP(Language): | ||
keywords = [ | ||
"abstract", | ||
"amp", | ||
"array", | ||
"auto", | ||
"bool", | ||
"break", | ||
"case", | ||
"catch", | ||
"char", | ||
"class", | ||
"const", | ||
"constexpr", | ||
"const_cast", | ||
"continue", | ||
"cpu", | ||
"decltype", | ||
"default", | ||
"delegate", | ||
"delete", | ||
"do", | ||
"double", | ||
"dynamic_cast", | ||
"each", | ||
"else", | ||
"enum", | ||
"event", | ||
"explicit", | ||
"export", | ||
"extern", | ||
"false", | ||
"final", | ||
"finally", | ||
"float", | ||
"for", | ||
"friend", | ||
"gcnew", | ||
"generic", | ||
"goto", | ||
"if", | ||
"in", | ||
"initonly", | ||
"inline", | ||
"int", | ||
"interface", | ||
"interior_ptr", | ||
"internal", | ||
"literal", | ||
"long", | ||
"mutable", | ||
"namespace", | ||
"new", | ||
"noexcept", | ||
"nullptr", | ||
"__nullptr", | ||
"operator", | ||
"override", | ||
"partial", | ||
"pascal", | ||
"pin_ptr", | ||
"private", | ||
"property", | ||
"protected", | ||
"public", | ||
"ref", | ||
"register", | ||
"reinterpret_cast", | ||
"restrict", | ||
"return", | ||
"safe_cast", | ||
"sealed", | ||
"short", | ||
"signed", | ||
"sizeof", | ||
"static", | ||
"static_assert", | ||
"static_cast", | ||
"struct", | ||
"switch", | ||
"template", | ||
"this", | ||
"thread_local", | ||
"throw", | ||
"tile_static", | ||
"true", | ||
"try", | ||
"typedef", | ||
"typeid", | ||
"typename", | ||
"union", | ||
"unsigned", | ||
"using", | ||
"virtual", | ||
"void", | ||
"volatile", | ||
"wchar_t", | ||
"where", | ||
"while", | ||
|
||
"_asm", | ||
"_based", | ||
"_cdecl", | ||
"_declspec", | ||
"_fastcall", | ||
"_if_exists", | ||
"_if_not_exists", | ||
"_inline", | ||
"_multiple_inheritance", | ||
"_pascal", | ||
"_single_inheritance", | ||
"_stdcall", | ||
"_virtual_inheritance", | ||
"_w64", | ||
|
||
"__abstract", | ||
"__alignof", | ||
"__asm", | ||
"__assume", | ||
"__based", | ||
"__box", | ||
"__builtin_alignof", | ||
"__cdecl", | ||
"__clrcall", | ||
"__declspec", | ||
"__delegate", | ||
"__event", | ||
"__except", | ||
"__fastcall", | ||
"__finally", | ||
"__forceinline", | ||
"__gc", | ||
"__hook", | ||
"__identifier", | ||
"__if_exists", | ||
"__if_not_exists", | ||
"__inline", | ||
"__int128", | ||
"__int16", | ||
"__int32", | ||
"__int64", | ||
"__int8", | ||
"__interface", | ||
"__leave", | ||
"__m128", | ||
"__m128d", | ||
"__m128i", | ||
"__m256", | ||
"__m256d", | ||
"__m256i", | ||
"__m64", | ||
"__multiple_inheritance", | ||
"__newslot", | ||
"__nogc", | ||
"__noop", | ||
"__nounwind", | ||
"__novtordisp", | ||
"__pascal", | ||
"__pin", | ||
"__pragma", | ||
"__property", | ||
"__ptr32", | ||
"__ptr64", | ||
"__raise", | ||
"__restrict", | ||
"__resume", | ||
"__sealed", | ||
"__single_inheritance", | ||
"__stdcall", | ||
"__super", | ||
"__thiscall", | ||
"__try", | ||
"__try_cast", | ||
"__typeof", | ||
"__unaligned", | ||
"__unhook", | ||
"__uuidof", | ||
"__value", | ||
"__virtual_inheritance", | ||
"__w64", | ||
"__wchar_t"] | ||
|
||
strings = ["(\\'(.)\\')", "(\"(.)*\")"] | ||
numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] | ||
comments = ["(//(.)*)", "(\/\\*(.*?)\\*\/)"] |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Language: | ||
keywords: list | ||
strings: list | ||
numbers: list | ||
comments: list |
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,78 +1,81 @@ | ||
import tkinter as tk | ||
|
||
from ...utils import Scrollbar | ||
from ..editor import BaseEditor | ||
|
||
from .minimap import Minimap | ||
from ..config import Config | ||
from .events import Events | ||
from .linenumbers import LineNumbers | ||
from .minimap import Minimap | ||
from .scrollbar import Scrollbar | ||
from .language import SyntaxLoader | ||
from .text import Text | ||
from .find_replace import FinderReplacer | ||
|
||
|
||
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) | ||
class Editor(tk.Frame): | ||
def __init__(self, master, *args, **kwargs): | ||
super().__init__(master, *args, **kwargs) | ||
self.master = master | ||
|
||
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.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) | ||
|
||
self.linenumebers.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.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() | ||
self.events = Events(self) | ||
self.text.config(yscrollcommand=self.text_scrolled) | ||
self.focus() | ||
|
||
def on_scroll(self, *_): | ||
self.linenumbers.redraw() | ||
if not self.minimalist: | ||
self.minimap.redraw() | ||
def text_scrolled(self, *args): | ||
pass | ||
|
||
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 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 focus(self): | ||
self.text.focus() | ||
self.on_change() | ||
self.refresh_editor() | ||
|
||
def set_fontsize(self, size): | ||
self.font.configure(size=size) | ||
self.linenumbers.set_bar_width(size * 3) | ||
self.on_change() | ||
|
||
def save(self, path=None): | ||
if self.editable: | ||
self.text.save_file(path) | ||
|
||
def cut(self, *_): | ||
if self.editable: | ||
self.text.cut() | ||
|
||
def copy(self, *_): | ||
if self.editable: | ||
self.text.copy() | ||
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 paste(self, *_): | ||
if self.editable: | ||
self.text.paste() | ||
def insert(self, text): | ||
self.text.clear_insert(text) | ||
|
||
def load_file(self, filepath): | ||
self.text.load_file(filepath) |
Oops, something went wrong.