ncmd 0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ncmd-0.8/LISCENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
ncmd-0.8/PKG-INFO ADDED
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.5
2
+ Name: ncmd
3
+ Version: 0.8
4
+ Summary: this is a python package that lets you easily use tkinter and more with a unique command prompt system.
5
+ Author-email: CSWAST <cswastacc@gmail.com>
6
+ Requires-Python: >=3.8
7
+ Requires-Dist: tkinter>=8.6
8
+ Description-Content-Type: text/markdown
9
+
10
+ **Note: arguments behind "::" is optional.**
11
+
12
+
13
+
14
+ **These commands are only the commands for starters. For more commands, run n\_? or n\_help.**
15
+
16
+
17
+
18
+ \--Commands--
19
+
20
+ **n\_p <text1>** - prints text1
21
+
22
+ **n\_v <text1/variable> <text2>** - stores text2 into new/old variable text1.
23
+
24
+ **n\_r <variable>** - requests player for text/number to set variable to.
25
+
26
+ **n\_i <cond> : <cmd>** - single line if statement. if cond is true runs cmd.
27
+
28
+ **n\_l <count> : <cmd>** - single line loop. reapeats cmd count times.
29
+
30
+ **n\_if <cond> run { ... }** - same as n\_i but multi-line is allowed
31
+
32
+ **n\_unless <cond> run { ... }** - opposite of n\_if
33
+
34
+ **n\_while :: <cond> { ... }** - repeats multi-line allowed code while cond is true.
35
+
36
+ **n.until <cond> run { ... }** - repeats multi-line allowed code until cond is true.
37
+
38
+
39
+
40
+ \--GUI \& Events--
41
+
42
+
43
+
44
+ **n\_button \[area, text, size] *:: name\["text1"]*** - makes a clickable button in a GUI window called text1 (default: \[button]. Note: use with n\_p)
45
+
46
+ **n\_event \[\[button]] run { ... }** - runs multi-line code when the matching button is clicked.
47
+
48
+
49
+
50
+ \--Loop Only--
51
+
52
+
53
+
54
+ **sub.break** - exits only innermost loop
55
+
56
+ **all.break** - exits all active loops
57
+
58
+
59
+
60
+ \--Editor \& File--
61
+
62
+
63
+
64
+ **n\_run *:: viewfile \\\\ filename*** - executes the code.
65
+
66
+ **n\_paste** - supports pasting code. '>' changes line.
67
+
68
+ **n\_save *\\\\ filename*** - saves previous code into a file.
69
+
70
+ **n\_load \\\\ filename** - loads file code from the file.
71
+
72
+ **n\_edit :: viewfile *\\\\ filename*** - edits a file. (w and s to move between lines, n\_save to save)
73
+
74
+ **n\_clear** - wipes all code and variables from memory.
75
+
76
+ **n\_exit** - exits n.
77
+
78
+ **n\_quit** - exits n.
79
+
80
+ **n\_end** - exits n.
81
+
82
+ **n\_x** - exits n.
83
+
84
+
85
+
ncmd-0.8/README.md ADDED
@@ -0,0 +1,76 @@
1
+ **Note: arguments behind "::" is optional.**
2
+
3
+
4
+
5
+ **These commands are only the commands for starters. For more commands, run n\_? or n\_help.**
6
+
7
+
8
+
9
+ \--Commands--
10
+
11
+ **n\_p <text1>** - prints text1
12
+
13
+ **n\_v <text1/variable> <text2>** - stores text2 into new/old variable text1.
14
+
15
+ **n\_r <variable>** - requests player for text/number to set variable to.
16
+
17
+ **n\_i <cond> : <cmd>** - single line if statement. if cond is true runs cmd.
18
+
19
+ **n\_l <count> : <cmd>** - single line loop. reapeats cmd count times.
20
+
21
+ **n\_if <cond> run { ... }** - same as n\_i but multi-line is allowed
22
+
23
+ **n\_unless <cond> run { ... }** - opposite of n\_if
24
+
25
+ **n\_while :: <cond> { ... }** - repeats multi-line allowed code while cond is true.
26
+
27
+ **n.until <cond> run { ... }** - repeats multi-line allowed code until cond is true.
28
+
29
+
30
+
31
+ \--GUI \& Events--
32
+
33
+
34
+
35
+ **n\_button \[area, text, size] *:: name\["text1"]*** - makes a clickable button in a GUI window called text1 (default: \[button]. Note: use with n\_p)
36
+
37
+ **n\_event \[\[button]] run { ... }** - runs multi-line code when the matching button is clicked.
38
+
39
+
40
+
41
+ \--Loop Only--
42
+
43
+
44
+
45
+ **sub.break** - exits only innermost loop
46
+
47
+ **all.break** - exits all active loops
48
+
49
+
50
+
51
+ \--Editor \& File--
52
+
53
+
54
+
55
+ **n\_run *:: viewfile \\\\ filename*** - executes the code.
56
+
57
+ **n\_paste** - supports pasting code. '>' changes line.
58
+
59
+ **n\_save *\\\\ filename*** - saves previous code into a file.
60
+
61
+ **n\_load \\\\ filename** - loads file code from the file.
62
+
63
+ **n\_edit :: viewfile *\\\\ filename*** - edits a file. (w and s to move between lines, n\_save to save)
64
+
65
+ **n\_clear** - wipes all code and variables from memory.
66
+
67
+ **n\_exit** - exits n.
68
+
69
+ **n\_quit** - exits n.
70
+
71
+ **n\_end** - exits n.
72
+
73
+ **n\_x** - exits n.
74
+
75
+
76
+
@@ -0,0 +1,16 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ncmd"
7
+ version = "0.8"
8
+ authors = [
9
+ { name="CSWAST", email="cswastacc@gmail.com" },
10
+ ]
11
+ description = "this is a python package that lets you easily use tkinter and more with a unique command prompt system."
12
+ readme = "readme.md"
13
+ requires-python = ">=3.8"
14
+ dependencies = [
15
+ "tkinter>=8.6",
16
+ ]
ncmd-0.8/readme.md ADDED
@@ -0,0 +1,76 @@
1
+ **Note: arguments behind "::" is optional.**
2
+
3
+
4
+
5
+ **These commands are only the commands for starters. For more commands, run n\_? or n\_help.**
6
+
7
+
8
+
9
+ \--Commands--
10
+
11
+ **n\_p <text1>** - prints text1
12
+
13
+ **n\_v <text1/variable> <text2>** - stores text2 into new/old variable text1.
14
+
15
+ **n\_r <variable>** - requests player for text/number to set variable to.
16
+
17
+ **n\_i <cond> : <cmd>** - single line if statement. if cond is true runs cmd.
18
+
19
+ **n\_l <count> : <cmd>** - single line loop. reapeats cmd count times.
20
+
21
+ **n\_if <cond> run { ... }** - same as n\_i but multi-line is allowed
22
+
23
+ **n\_unless <cond> run { ... }** - opposite of n\_if
24
+
25
+ **n\_while :: <cond> { ... }** - repeats multi-line allowed code while cond is true.
26
+
27
+ **n.until <cond> run { ... }** - repeats multi-line allowed code until cond is true.
28
+
29
+
30
+
31
+ \--GUI \& Events--
32
+
33
+
34
+
35
+ **n\_button \[area, text, size] *:: name\["text1"]*** - makes a clickable button in a GUI window called text1 (default: \[button]. Note: use with n\_p)
36
+
37
+ **n\_event \[\[button]] run { ... }** - runs multi-line code when the matching button is clicked.
38
+
39
+
40
+
41
+ \--Loop Only--
42
+
43
+
44
+
45
+ **sub.break** - exits only innermost loop
46
+
47
+ **all.break** - exits all active loops
48
+
49
+
50
+
51
+ \--Editor \& File--
52
+
53
+
54
+
55
+ **n\_run *:: viewfile \\\\ filename*** - executes the code.
56
+
57
+ **n\_paste** - supports pasting code. '>' changes line.
58
+
59
+ **n\_save *\\\\ filename*** - saves previous code into a file.
60
+
61
+ **n\_load \\\\ filename** - loads file code from the file.
62
+
63
+ **n\_edit :: viewfile *\\\\ filename*** - edits a file. (w and s to move between lines, n\_save to save)
64
+
65
+ **n\_clear** - wipes all code and variables from memory.
66
+
67
+ **n\_exit** - exits n.
68
+
69
+ **n\_quit** - exits n.
70
+
71
+ **n\_end** - exits n.
72
+
73
+ **n\_x** - exits n.
74
+
75
+
76
+
File without changes
@@ -0,0 +1,387 @@
1
+ import os
2
+ import re
3
+ import tkinter as tk
4
+
5
+
6
+ class BreakAllLoops(Exception):
7
+ pass
8
+
9
+
10
+ class BreakSubLoop(Exception):
11
+ pass
12
+
13
+
14
+ HELP_TEXT = """
15
+ --Commands--
16
+ n_p <text1> - prints text1
17
+ n_v <var> <val> - stores val into variable
18
+ n_v <var> n_gui :: askfor :: input - asks for input via GUI box
19
+ n_r <variable> - requests terminal input for variable
20
+ n_i <cond> : <cmd> - single line if statement
21
+ n_l <count> : <cmd> - single line loop
22
+ n_if <cond> run { ... } - multi-line if block
23
+ n_unless <cond> run { ... } - opposite of n_if
24
+ n_while :: <cond> { ... } - multi-line while loop (:: optional)
25
+ n_until <cond> run { ... } - repeats until cond is true
26
+
27
+ --GUI & Events--
28
+ n_button [area, text, size] :: name["text1"] - creates GUI button
29
+ n_event [[button]] run { ... } - runs code when matching button is clicked
30
+ n_gui - views all components in current GUI settings
31
+ n_gui :: reset - resets all current GUI components
32
+ n_savegui \\\\ filename - saves GUI components to file
33
+ n_loadgui \\\\ filename - loads GUI components from file
34
+ n_editgui \\\\ filename - edits GUI components (w/s to move, n_save to save)
35
+ n_run :: gui :: <guiname> - runs code with custom GUI window title
36
+
37
+ --Loop Only--
38
+ sub.break - exits innermost loop
39
+ all.break - exits all active loops
40
+
41
+ --Editor & File--
42
+ n_run :: viewfile \\\\ filename - executes code (:: viewfile and \\\\ optional)
43
+ n_paste - pastes single-line code and formats into lines
44
+ n_save \\\\ filename - saves code to file
45
+ n_load \\\\ filename - loads code from file
46
+ n_edit :: viewfile \\\\ filename - edits code (w/s to move, n_save to save)
47
+ n_clear - wipes code, GUI, and variables from memory
48
+ n_help / n_? - shows this command list
49
+ n_exit / n_quit / n_end / n_x - exits n
50
+ """
51
+
52
+
53
+ class nInterpreter:
54
+
55
+ def __init__(self):
56
+ self.vars = {"button": "button"}
57
+ self.events = {}
58
+ self.gui_components = []
59
+ self.gui_title = "n Window"
60
+ self.root = None
61
+ self.columns = {}
62
+
63
+ def eval_expr(self, expr):
64
+ expr = expr.strip()
65
+
66
+ def eval_bracket(match):
67
+ val = self.eval_expr(match.group(1))
68
+ return f'"{val}"' if isinstance(val, str) else str(val)
69
+
70
+ while "[" in expr and "]" in expr:
71
+ expr = re.sub(r"\[([^\[\]]+)\]", eval_bracket, expr)
72
+
73
+ if (expr.startswith('"') and expr.endswith('"')) or (
74
+ expr.startswith("'") and expr.endswith("'")
75
+ ):
76
+ return expr[1:-1]
77
+
78
+ tokens = re.findall(r"[a-zA-Z_]\w*|\d+|[^\s\w]", expr)
79
+ parsed_tokens = []
80
+ for t in tokens:
81
+ if t.lower() == "true":
82
+ parsed_tokens.append("True")
83
+ elif t.lower() == "false":
84
+ parsed_tokens.append("False")
85
+ elif t in self.vars:
86
+ val = self.vars[t]
87
+ parsed_tokens.append(f'"{val}"' if isinstance(val, str) else str(val))
88
+ else:
89
+ parsed_tokens.append(t)
90
+
91
+ try:
92
+ return eval("".join(parsed_tokens), {"__builtins__": None}, {})
93
+ except Exception as e:
94
+ raise SyntaxError(f"Invalid expression '{expr}': {e}")
95
+ def ensure_window(self):
96
+ if self.root is None:
97
+ self.root = tk.Tk()
98
+ self.root.title(self.gui_title)
99
+ self.root.geometry("620x420")
100
+ for idx, col in enumerate(("left", "middle", "right")):
101
+ self.root.columnconfigure(idx, weight=1)
102
+ frame = tk.Frame(self.root)
103
+ frame.grid(row=0, column=idx, sticky="n", padx=10, pady=15)
104
+ self.columns[col] = frame
105
+
106
+ def build_button(self, rest, record=True):
107
+ if record and f"n_button {rest}" not in self.gui_components:
108
+ self.gui_components.append(f"n_button {rest}")
109
+
110
+ btn_name = "button"
111
+ main_part = rest
112
+
113
+ if "::" in rest:
114
+ main_part, attr = rest.split("::", 1)
115
+ name_match = re.search(r'name\[["\']?([^"\'\]]+)["\']?\]', attr.strip())
116
+ if name_match:
117
+ btn_name = name_match.group(1).strip()
118
+
119
+ bracket_match = re.match(r"^\[([^\]]+)\]$", main_part.strip())
120
+ if not bracket_match:
121
+ raise SyntaxError("Expected: n_button [area, text, size]")
122
+
123
+ parts = [p.strip() for p in bracket_match.group(1).split(",")]
124
+ area = parts.pop(0).lower()
125
+ if area not in ("left", "middle", "right"):
126
+ raise SyntaxError(f"Invalid area '{area}'. Use left, middle, or right.")
127
+
128
+ text_arg = parts.pop(0) if parts else ""
129
+ size_arg = parts.pop(0) if parts else ""
130
+
131
+ text = str(self.eval_expr(text_arg)) if text_arg else btn_name
132
+ size = int(self.eval_expr(size_arg)) if size_arg else 12
133
+
134
+ self.vars["button"] = btn_name
135
+ self.ensure_window()
136
+
137
+ def on_click(name=btn_name):
138
+ self.vars["button"] = name
139
+ if name in self.events:
140
+ try:
141
+ self.execute_block(self.events[name])
142
+ except (BreakAllLoops, BreakSubLoop):
143
+ pass
144
+ except Exception as e:
145
+ print(f"[n Event Error ({name})]: {e}")
146
+
147
+ btn = tk.Button(
148
+ self.columns[area],
149
+ text=text,
150
+ font=("Arial", size),
151
+ padx=max(8, size // 2),
152
+ pady=max(4, size // 3),
153
+ command=on_click,
154
+ )
155
+ btn.pack(pady=6)
156
+
157
+ def build_gui_input(self, var_name, spec, record=True):
158
+ full_cmd = f"n_v {var_name} {spec}"
159
+ if record and full_cmd not in self.gui_components:
160
+ self.gui_components.append(full_cmd)
161
+
162
+ area = "middle"
163
+ label_text = f"{var_name}:"
164
+ size = 12
165
+
166
+ bracket_match = re.search(r"\[([^\]]+)\]", spec)
167
+ if bracket_match:
168
+ parts = [p.strip() for p in bracket_match.group(1).split(",")]
169
+ if parts and parts.lower() in ("left", "middle", "right"):
170
+ area = parts.pop(0).lower()
171
+ if parts:
172
+ label_text = str(self.eval_expr(parts.pop(0)))
173
+ if parts:
174
+ size = int(self.eval_expr(parts.pop(0)))
175
+
176
+ self.vars.setdefault(var_name, "")
177
+ self.ensure_window()
178
+
179
+ box = tk.Frame(self.columns[area])
180
+ box.pack(pady=6)
181
+ tk.Label(box, text=label_text, font=("Arial", size)).pack()
182
+ entry = tk.Entry(box, font=("Arial", size), width=18)
183
+ entry.pack(pady=2)
184
+
185
+ def sync_value(*_):
186
+ raw_val = entry.get()
187
+ try:
188
+ val = int(raw_val)
189
+ except ValueError:
190
+ try:
191
+ val = float(raw_val)
192
+ except ValueError:
193
+ val = raw_val
194
+ self.vars[var_name] = val
195
+
196
+ entry.bind("<KeyRelease>", sync_value)
197
+ entry.bind("<Return>", sync_value)
198
+
199
+ def extract_block(self, lines, start_idx):
200
+ block = []
201
+ depth = 0
202
+ i = start_idx
203
+ while i < len(lines):
204
+ line = lines[i]
205
+ depth += line.count("{") - line.count("}")
206
+ if i > start_idx:
207
+ if depth == 0 and line.strip() == "}":
208
+ return block, i
209
+ block.append(line)
210
+ i += 1
211
+ raise SyntaxError("Unclosed '{' block")
212
+ def parse_paste(pasted_text):
213
+ tokens, current, in_quote = [], [], None
214
+ for ch in pasted_text:
215
+ if ch in ('"', "'"):
216
+ in_quote = None if in_quote == ch else (ch if in_quote is None else in_quote)
217
+ current.append(ch)
218
+ elif in_quote is None and ch == "{":
219
+ current.append("{")
220
+ tokens.append("".join(current).strip())
221
+ current = []
222
+ elif in_quote is None and ch in ("}", ";"):
223
+ part = "".join(current).strip()
224
+ if part:
225
+ tokens.append(part)
226
+ if ch == "}":
227
+ tokens.append("}")
228
+ current = []
229
+ else:
230
+ current.append(ch)
231
+ if "".join(current).strip():
232
+ tokens.append("".join(current).strip())
233
+
234
+ raw_lines = []
235
+ cmd_splitter = re.compile(
236
+ r"(?<!:\s)(?<!:)\b(?=n_(?:if|unless|while|until|event|v|r|p|i|l|button|gui|run)\b|all\.break\b|sub\.break\b)"
237
+ )
238
+ for tok in tokens:
239
+ cleaned = tok.lstrip(">").strip()
240
+ if not cleaned or cleaned == "n_run":
241
+ continue
242
+ if cleaned in ("{", "}"):
243
+ raw_lines.append(cleaned)
244
+ else:
245
+ for sub in cmd_splitter.split(cleaned):
246
+ sub = sub.lstrip(">").strip()
247
+ if sub and sub != "n_run":
248
+ raw_lines.append(sub)
249
+
250
+ formatted, indent = [], 0
251
+ for line in raw_lines:
252
+ if line == "}":
253
+ indent = max(0, indent - 1)
254
+ formatted.append(" " * indent + "}")
255
+ elif line.endswith("{"):
256
+ formatted.append(" " * indent + line)
257
+ indent += 1
258
+ else:
259
+ formatted.append(" " * indent + line)
260
+ return formatted
261
+
262
+
263
+ def load_file(filename, current_lines):
264
+ filename = filename.strip().strip("\"'")
265
+ if os.path.exists(filename):
266
+ with open(filename, "r") as f:
267
+ loaded = f.read().splitlines()
268
+ print(f"[Loaded {len(loaded)} lines from '{filename}']")
269
+ return loaded, True
270
+ print(f"[Error: File '{filename}' not found]")
271
+ return current_lines, False
272
+
273
+
274
+ def print_code(lines, title="Loaded Code"):
275
+ print(f"\n--- {title} ---")
276
+ if not lines:
277
+ print("(empty)")
278
+ for idx, l in enumerate(lines, 1):
279
+ print(f"{idx}: {l}")
280
+ print("-" * (len(title) + 8))
281
+
282
+
283
+ def edit_code(lines, title="Loaded Code"):
284
+ if not lines:
285
+ lines = [""]
286
+ idx = 0
287
+ print("\n[Editor Mode: 'w' = up, 's' = down, 'n_save' = finish editing]")
288
+ while True:
289
+ print_code(lines, title=title)
290
+ print(f"Editing Line {idx + 1}: {lines[idx]}")
291
+ action = input("edit> ").strip()
292
+ if action == "n_save":
293
+ print("[Changes saved to memory]")
294
+ return lines
295
+ elif action == "w":
296
+ idx = max(0, idx - 1)
297
+ elif action == "s":
298
+ if idx + 1 >= len(lines):
299
+ lines.append("")
300
+ idx += 1
301
+ else:
302
+ lines[idx] = action
303
+
304
+
305
+ if __name__ == "__main__":
306
+ interpreter = nInterpreter()
307
+ print("Welcome to n! Type 'n_help' or 'n_?' for all commands.")
308
+
309
+ lines = []
310
+ while True:
311
+ user_input = input("> ")
312
+ stripped = user_input.strip()
313
+
314
+ if stripped in ("n_exit", "n_quit", "n_end", "n_x"):
315
+ break
316
+ elif stripped in ("n_help", "n_?"):
317
+ print(HELP_TEXT)
318
+ elif stripped == "n_clear":
319
+ lines = []
320
+ interpreter.vars = {"button": "button"}
321
+ interpreter.gui_components = []
322
+ interpreter.gui_title = "n Window"
323
+ print("[Memory, GUI, and variables cleared]")
324
+ elif stripped.startswith("n_gui"):
325
+ if "::" in stripped and stripped.split("::", 1).pop().strip() == "reset":
326
+ interpreter.gui_components = []
327
+ print("[GUI settings reset]")
328
+ else:
329
+ print_code(interpreter.gui_components, title="Current GUI Settings")
330
+ elif stripped.startswith("n_savegui") and r"\\" in stripped:
331
+ _, filename = stripped.split(r"\\", 1)
332
+ filename = filename.strip().strip("\"'")
333
+ with open(filename, "w") as f:
334
+ f.write("\n".join(interpreter.gui_components))
335
+ print(f"[Saved {len(interpreter.gui_components)} GUI components to '{filename}']")
336
+ elif stripped.startswith("n_loadgui") and r"\\" in stripped:
337
+ _, filename = stripped.split(r"\\", 1)
338
+ interpreter.gui_components, _ = load_file(filename, interpreter.gui_components)
339
+ elif stripped.startswith("n_editgui"):
340
+ if r"\\" in stripped:
341
+ _, filename = stripped.split(r"\\", 1)
342
+ interpreter.gui_components, ok = load_file(filename, interpreter.gui_components)
343
+ if not ok:
344
+ continue
345
+ interpreter.gui_components = edit_code(interpreter.gui_components, title="GUI Settings")
346
+ elif stripped == "n_paste":
347
+ pasted = input("paste> ")
348
+ broken_down = parse_paste(pasted)
349
+ lines.extend(broken_down)
350
+ print("\n--- Broken Down Code ---")
351
+ for b_line in broken_down:
352
+ print(f">{b_line}")
353
+ print("------------------------")
354
+ elif stripped.startswith("n_run"):
355
+ header = stripped
356
+ if r"\\" in header:
357
+ header, filename = header.split(r"\\", 1)
358
+ lines, ok = load_file(filename, lines)
359
+ if not ok:
360
+ continue
361
+ gui_name = None
362
+ gui_match = re.search(r"::\s*gui\s*::\s*([^\s:]+)", header)
363
+ if gui_match:
364
+ gui_name = gui_match.group(1).strip().strip("\"'")
365
+ if ":: viewfile" in header:
366
+ print_code(lines)
367
+ print("\n--- Output ---")
368
+ interpreter.run("\n".join(lines), gui_name=gui_name)
369
+ print("--------------")
370
+ elif stripped.startswith("n_edit"):
371
+ if r"\\" in stripped:
372
+ _, filename = stripped.split(r"\\", 1)
373
+ lines, ok = load_file(filename, lines)
374
+ if not ok:
375
+ continue
376
+ lines = edit_code(lines)
377
+ elif stripped.startswith("n_save") and r"\\" in stripped:
378
+ _, filename = stripped.split(r"\\", 1)
379
+ filename = filename.strip().strip("\"'")
380
+ with open(filename, "w") as f:
381
+ f.write("\n".join(lines))
382
+ print(f"[Saved {len(lines)} lines to '{filename}']")
383
+ elif stripped.startswith("n_load") and r"\\" in stripped:
384
+ _, filename = stripped.split(r"\\", 1)
385
+ lines, _ = load_file(filename, lines)
386
+ else:
387
+ lines.append(user_input)