Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
202 lines (169 loc) · 4.79 KB
/
Copy pathmain.py
File metadata and controls
202 lines (169 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import customtkinter as ctk
from CTkMenuBarPlus import *
import subprocess
import tkinter.messagebox as messagebox
import os, sys
from ui.editor import Editor
from ui.terminal import Terminal
from ui.action import Action
from core.file import save_as, open_file
root = ctk.CTk()
root.title("Fluide")
root.geometry('1200x750')
menu_bar = CTkMenuBar(root)
file_button = menu_bar.add_cascade("File")
edit_button = menu_bar.add_cascade("Edit")
view_button = menu_bar.add_cascade("View")
go_button = menu_bar.add_cascade("Go")
#Menu bar idk lol
is_full = False
root.attributes("-fullscreen", is_full)
action = Action(root)
action.pack(fill="x", padx=8, pady=8)
check = subprocess.run(
["where","flu"],
capture_output=True,
text=True
)
if check.returncode == 0:
content = ctk.CTkFrame(root)
content.pack(expand=True, fill="both")
content.grid_columnconfigure(0, weight=1)
content.grid_columnconfigure(1, weight=1)
content.grid_rowconfigure(0, weight=1)
editor = Editor(content)
editor.grid(row=0, column=0, sticky="nsew")
terminal = Terminal(content)
terminal.grid(row=0, column=1, sticky="nsew")
compilerpath = check.stdout.strip()
else:
messagebox.showwarning("Flu Compiler Not found", "Please install it on official Fluentix page.\nFluide will run on Editor-only mode.")
editor = Editor(root)
editor.pack(expand=True, fill="both")
compilerpath = False
def get_content():
return editor.codebox.get("1.0", "end")
def change_file(content="", namefile="Untitled"):
global filepath
filepath = namefile if namefile != "Untitled" else ""
action.name_file.configure(text=os.path.basename(namefile) if namefile != "Untitled" else namefile)
editor.codebox.clear_all_text()
editor.codebox.insert("1.0", content)
editor.codebox.update_code()
editor.codebox.clear_history()
def full_screen():
global is_full
root.attributes("-fullscreen", not is_full)
is_full = not is_full
if len(sys.argv) > 1:
filepath = sys.argv[1]
with open(filepath, "r", encoding="utf-8") as f:
change_file(f.read(), filepath)
else:
filepath = ""
def save():
if filepath:
#* "" -> False. According to Truthy/Falsy
with open(filepath, "w", encoding="utf-8") as file:
file.write(editor.codebox.get("1.0", "end"))
else:
save_as(get_content, change_file)
def open():
if editor.codebox.is_edited():
requests = messagebox.askyesnocancel("The file has not been saved", "Do you want to save this file?")
if requests:
save()
elif requests is None:
return 0
open_file(change_file)
editor.codebox.reset_edited()
def new():
if editor.codebox.is_edited():
requests = messagebox.askyesnocancel("The file has not been saved", "Do you want to save this file?")
if requests:
save()
elif requests is None:
return 0
change_file()
editor.codebox.reset_edited()
file_dropdown = CustomDropdownMenu(file_button)
file_dropdown.add_option(
option="New",
command=new
)
file_dropdown.add_option(
option="Open",
command=open
)
file_dropdown.add_separator()
file_dropdown.add_option(
option="Save",
command=save
)
file_dropdown.add_option(
option="Save as",
command=lambda: save_as(get_content, change_file)
)
file_dropdown.add_separator()
settings_dropdown = file_dropdown.add_submenu("Setting")
settings_dropdown.add_option("Theme")
settings_dropdown.add_option("Editor")
# settings_dropdown.add_option("Compiler")
# settings_dropdown.add_option("AI")
settings_dropdown.add_option("Help")
file_dropdown.add_option(
option="Exit",
command=root.destroy
)
edit_dropdown = CustomDropdownMenu(edit_button)
edit_dropdown.add_option(
option="Undo",
command=editor.codebox.undo
)
edit_dropdown.add_option(
option="Redo",
command=editor.codebox.redo
)
edit_dropdown.add_separator()
edit_dropdown.add_option(
option="Cut",
command=editor.codebox.cut_text
)
edit_dropdown.add_option(
option="Copy",
command=editor.codebox.copy_text
)
edit_dropdown.add_option(
option="Paste",
command=editor.codebox.paste_text
)
edit_dropdown.add_separator()
edit_dropdown.add_option(
option="Select All",
command=editor.codebox.select_all_text
)
edit_dropdown.add_separator()
edit_dropdown.add_option(
option="Search & Replace",
command=editor.codebox.open_search_window
)
view_dropdown = CustomDropdownMenu(view_button)
view_dropdown.add_option(
option="Zen mode"
)
view_dropdown.add_option(
option="Full Screen",
command=full_screen
)
go_dropdown = CustomDropdownMenu(go_button)
go_dropdown.add_option(
option="Go to Line"
)
go_dropdown.add_separator()
go_dropdown.add_option(
option="Back"
)
go_dropdown.add_option(
option="Forward"
)
root.mainloop()