diff options
| author | Agando <roduccomm@gmail.com> | 2026-05-25 18:02:02 +0200 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-05-25 18:02:02 +0200 |
| commit | 4baa484b84c5184286cac2743575251454a5ee2b (patch) | |
| tree | cb9002f93644f363d0f35831dc97e6492bbb0ed6 /modules/core/module-simplegui.js | |
auto: 2026-05-25_18:02 changes
Diffstat (limited to 'modules/core/module-simplegui.js')
| -rw-r--r-- | modules/core/module-simplegui.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/modules/core/module-simplegui.js b/modules/core/module-simplegui.js new file mode 100644 index 0000000..78fa9b5 --- /dev/null +++ b/modules/core/module-simplegui.js @@ -0,0 +1,67 @@ +// Extracted from newOS4 index.html — SimpleGUIModule + class SimpleGUIModule { + constructor() { this.commands = {}; this.terminal = null; this.guiElements = {}; } + getHelpInfo() { + return { + 'gui': 'gui — Show the GUI builder overview', + 'gui-button': 'gui-button <label> <command> — Add a clickable button', + 'gui-input': 'gui-input <placeholder> <varName> — Add a text input field', + 'gui-text': 'gui-text <content> — Add a text element', + 'gui-clear': 'gui-clear — Clear all GUI elements', + 'gui-run': 'gui-run <command> — Run a terminal command from the GUI' + }; + } + registerCommands() { + this.commands['gui'] = () => this.showGUI(); + this.commands['gui-button'] = (args) => this.createButton(args); + this.commands['gui-input'] = (args) => this.createInput(args); + this.commands['gui-text'] = (args) => this.createText(args); + this.commands['gui-clear'] = () => this.clearGUI(); + this.commands['gui-run'] = (args) => this.runCommand(args); + } + showGUI() { + this.terminal.print("=== Simple GUI Builder ===", "info"); + this.terminal.print("Commands: gui-button, gui-input, gui-text, gui-clear", "info"); + } + createButton(args) { + if (args.length < 2) { + this.terminal.print("Usage: gui-button <label> <command>", "warning"); return; + } + const label = args[0], command = args.slice(1).join(' '); + const id = 'gui-btn-' + Date.now(); + this.terminal.printHTML(`<div style="margin: 5px 0;"> + <button class="qa-btn" onclick="${command}" id="${id}">${label}</button> + </div>`); + this.guiElements[id] = { type: 'button', label, command }; + this.terminal.print(`Button '${label}' created`, "success"); + } + createInput(args) { + if (args.length < 2) { + this.terminal.print("Usage: gui-input <placeholder> <varName>", "warning"); return; + } + const placeholder = args[0], varName = args[1], id = 'gui-input-' + Date.now(); + this.terminal.printHTML(`<div style="margin: 5px 0;"> + <input type="text" id="${id}" placeholder="${placeholder}" + style="background: #0a0a0a; border: 1px solid #005500; + color: #00ff00; padding: 8px; width: 100%;" /> + </div>`); + this.guiElements[id] = { type: 'input', placeholder, varName }; + this.terminal.print(`Input '${placeholder}' created (var: ${varName})`, "success"); + } + createText(args) { + if (!args[0]) { + this.terminal.print("Usage: gui-text <content>", "warning"); return; + } + const content = args.join(' '); + this.terminal.printHTML(`<div style="margin: 5px 0; padding: 8px; + background: #111111; border-left: 3px solid #00aaff;">${content}</div>`); + this.terminal.print("Text element created", "success"); + } + clearGUI() { this.guiElements = {}; this.terminal.print("GUI elements cleared", "success"); } + runCommand(args) { + if (!args[0]) { + this.terminal.print("Usage: gui-run <command>", "warning"); return; + } + this.terminal.executeCommand(args.join(' ')); + } + } |