-
Notifications
You must be signed in to change notification settings - Fork 0
Add files via upload #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ILIAHHne63
wants to merge
19
commits into
main
Choose a base branch
from
dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f46ae9b
Add files via upload
ILIAHHne63 482ee97
Update README.md
ILIAHHne63 3e7613e
Update README.md
ILIAHHne63 3a1b003
Update main.py
ILIAHHne63 a8f9f53
Create editor.py
ILIAHHne63 5179c8d
Create actions.py
ILIAHHne63 876464b
Create size.py
ILIAHHne63 b465f04
Update README.md
ILIAHHne63 1210697
Rename README.md to src/README.md
ILIAHHne63 e705e2c
Rename actions.py to src/actions.py
ILIAHHne63 26b5a2e
Rename editor.py to src/editor.py
ILIAHHne63 eb30330
Rename font.py to src/font.py
ILIAHHne63 0efea2d
Rename size.py to src/size.py
ILIAHHne63 4e5e3f0
Update editor.py
ILIAHHne63 85d73cb
Update actions.py
ILIAHHne63 7fc73bf
Update README.md
ILIAHHne63 9bd1d66
Update main.py
ILIAHHne63 7e84c3d
Create README.md
ILIAHHne63 bbd7f22
Update README.md
ILIAHHne63 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| Text Editor |
This file contains hidden or 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,3 @@ | ||
| from src.editor import Editor | ||
|
|
||
| text_editor = Editor() |
This file contains hidden or 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,21 @@ | ||
| # text_editor | ||
|
|
||
| # Базовый функционал: | ||
|
|
||
| 1)Возможность редактирования файла | ||
|
|
||
| 2)Перемещение по тексту при помощи “стрелок” - по словам (option+<>), в начало/конец строки (command+<>) | ||
|
|
||
| 3)Удаление строк(control+d) и слов (control+w) | ||
|
|
||
| 4)Текстовый поиск и замена(control+f) | ||
|
|
||
| 5)Хоткеи для сохранения(control+s) и выхода(command+q) | ||
|
|
||
| # Дополнительный функционал: | ||
|
|
||
| 1)Графический интерфейс | ||
|
|
||
| 2)Возможность сохранять файл как .cpp, .py, .c | ||
|
|
||
| 3)Возможность выставлять шрифты и размер |
This file contains hidden or 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,65 @@ | ||
| from tkinter import filedialog, simpledialog, messagebox, END, INSERT | ||
| from src import size, font | ||
|
|
||
|
|
||
| class Actions(): | ||
|
|
||
| def __init__(self, text): | ||
| self.text = text | ||
|
|
||
| def SaveFile(self, event=None): | ||
| file_path = filedialog.asksaveasfilename(filetypes=(('Text Documents (*.txt)', '*.txt'), ('All Files', '*.*'))) | ||
| if file_path: | ||
| with open(file_path, 'w', encoding='utf-8') as file: | ||
| file.write(self.text.get('1.0', END)) | ||
|
|
||
| def DeleteLine(self, event=None): | ||
| current_line = self.text.index(INSERT).split('.')[0] | ||
| start = f"{current_line}.0" | ||
| end = f"{current_line}.end" | ||
| self.text.delete(start, end) | ||
|
|
||
| def DeleteWord(self, event=None): | ||
| cursor_index = self.text.index(INSERT) | ||
| end_index = self.text.search(r"\s", cursor_index, regexp=True) | ||
| start_index = self.text.search(r"\s", cursor_index, backwards=True, regexp=True) | ||
| if start_index == end_index: | ||
| self.text.delete("1.0", end_index) | ||
| if start_index == "" or end_index == "": | ||
| return | ||
| self.text.delete(start_index, end_index) | ||
|
|
||
| def OpenFile(self, event=None): | ||
| file_path = filedialog.askopenfilename(title='Выбор файла', filetypes=( | ||
| ('C++ files (*.cpp)', '*.cpp'), ('Python files (*.py)', '*.py'), ('Все файлы (*.*)', '*.*'))) | ||
| if file_path: | ||
| self.text.delete('1.0', END) | ||
| self.text.insert('1.0', open(file_path, encoding='utf-8').read()) | ||
|
|
||
| def FindText(self, event=None): | ||
| search_query = simpledialog.askstring("Find", "Enter text to search:") | ||
| if search_query: | ||
| replace_query = simpledialog.askstring("Replace", "Enter text to replace:") | ||
| start_pos = "1.0" | ||
| while True: | ||
| start_pos = self.text.search(search_query, start_pos, END) | ||
| if not start_pos: | ||
| break | ||
| end_pos = f"{start_pos}+{len(search_query)}c" | ||
| self.text.tag_add("search", start_pos, end_pos) | ||
| if replace_query: | ||
| self.text.delete(start_pos, end_pos) | ||
| self.text.insert(start_pos, replace_query) | ||
| elif self.text.tag_ranges("search"): | ||
| self.text.mark_set("insert", self.text.tag_ranges("search")[0]) | ||
| self.text.see(self.text.tag_ranges("search")[0]) | ||
| self.text.tag_config("search", background="grey") | ||
| else: | ||
| messagebox.showinfo("Find", "Text not found.") | ||
| start_pos = end_pos | ||
|
|
||
| def ChangeFonts(self, font_to_change): | ||
| self.text['font'] = font.fonts[font_to_change]['font'] | ||
|
|
||
| def ChangeSize(self, size_to_change): | ||
| self.text['font'] = size.sizes[size_to_change]['size'] |
This file contains hidden or 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,77 @@ | ||
| from tkinter import WORD, LEFT, Tk, Scrollbar, RIGHT, Y, Frame, Text, BOTH, Menu | ||
| from src.actions import Actions | ||
|
|
||
| class Editor: | ||
|
|
||
| def WindowEditor(self): | ||
| self.editor_window.title('TextEditor') | ||
| self.editor_window.geometry('700x800') | ||
|
|
||
| def FileMenuEditor(self): | ||
| self.file_menu = Menu(self.main_menu) | ||
| self.file_menu.add_command(label='Open', command=self.actions.OpenFile) | ||
| self.file_menu.add_command(label='Find', command=self.actions.FindText) | ||
| self.file_menu.add_command(label='Save', command=self.actions.SaveFile) | ||
| self.file_menu.add_separator() | ||
| self.file_menu.add_command(label='Delete') | ||
| self.editor_window.config(menu=self.file_menu) | ||
|
|
||
| def ViewMenuEditor(self): | ||
| self.view_menu = Menu(self.main_menu) | ||
| self.font_menu = Menu(self.view_menu) | ||
| self.font_menu.add_command(label='Times New Roman', command=lambda: self.actions.ChangeFonts('TNR')) | ||
| self.font_menu.add_command(label='Arial', command=lambda: self.actions.ChangeFonts('Arial')) | ||
| self.font_menu.add_command(label='Courier New', command=lambda: self.actions.ChangeFonts('CN')) | ||
| self.view_menu.add_cascade(label='Font', menu=self.font_menu) | ||
| self.size_menu = Menu(self.view_menu) | ||
| self.size_menu.add_command(label='10', command=lambda: self.actions.ChangeSize('10')) | ||
| self.size_menu.add_command(label='20', command=lambda: self.actions.ChangeSize('20')) | ||
| self.size_menu.add_command(label='30', command=lambda: self.actions.ChangeSize('30')) | ||
| self.view_menu.add_cascade(label='Size', menu=self.size_menu) | ||
| self.editor_window.config(menu=self.view_menu) | ||
|
|
||
| def MenuEditor(self): | ||
| self.main_menu = Menu(self.editor_window) | ||
|
|
||
| self.FileMenuEditor() | ||
| self.ViewMenuEditor() | ||
|
|
||
| self.editor_window.config(menu=self.main_menu) | ||
| self.main_menu.add_cascade(label='File', menu=self.file_menu) | ||
| self.main_menu.add_cascade(label='View', menu=self.view_menu) | ||
|
|
||
| def ScrollEditor(self): | ||
| self.scroll = Scrollbar(self.text, command=self.text.yview) | ||
| self.scroll.pack(side=RIGHT, fill=Y) | ||
| self.text.config(yscrollcommand=self.scroll.set) | ||
|
|
||
| def TextEditor(self): | ||
| self.widget = Frame(self.editor_window) | ||
| self.widget.pack(fill=BOTH, expand=1) | ||
| self.text = Text(self.widget, | ||
| fg='white', | ||
| bg='black', | ||
| padx=10, | ||
| pady=10, | ||
| wrap=WORD, | ||
| insertbackground='white', | ||
| spacing3=10) | ||
| self.text.pack(fill=BOTH, side=LEFT, expand=1) | ||
|
|
||
| def __init__(self): | ||
| self.editor_window = Tk() | ||
| self.TextEditor() | ||
|
|
||
| self.actions = Actions(self.text) | ||
|
|
||
| self.WindowEditor() | ||
| self.MenuEditor() | ||
| self.ScrollEditor() | ||
|
|
||
| self.editor_window.bind('<Control-s>', self.actions.SaveFile) | ||
| self.editor_window.bind('<Control-o>', self.actions.OpenFile) | ||
| self.editor_window.bind('<Control-f>', self.actions.FindText) | ||
| self.editor_window.bind('<Control-d>', self.actions.DeleteLine) | ||
| self.editor_window.bind('<Control-w>', self.actions.DeleteWord) | ||
|
|
||
| self.editor_window.mainloop() |
This file contains hidden or 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,11 @@ | ||
| fonts = { | ||
| 'Arial': { | ||
| 'font': 'Arial 14 bold' | ||
| }, | ||
| 'CN': { | ||
| 'font': ('Courier New', 14, 'bold') | ||
| }, | ||
| 'TNR': { | ||
| 'font': ('Times New Roman', 14, 'bold') | ||
| } | ||
| } |
This file contains hidden or 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,11 @@ | ||
| sizes = { | ||
| '10': { | ||
| 'size': ('Arial', 10, 'bold') | ||
| }, | ||
| '20': { | ||
| 'size': ('Arial', 20, 'bold') | ||
| }, | ||
| '30': { | ||
| 'size': ('Arial', 30, 'bold') | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нельзя писать все в одном файле. Раздели на разные файлы разные логики. Положи все в каталог
src. И в корневом каталоге создай файлmain.py. Все константы вынеси в отдельный файл. У тебя еще не все пункты базовой части выполнены. Чтобы хотя бы 0 получить за проект нужно сделать полностью базовую часть. А чтобы получить больше 0 нужно хотя бы сделать один пункт доп части.