|
| 1 | +#Devscrip console editor by Sn1pe2win# |
| 2 | + |
| 3 | +currentLine = 0; |
| 4 | +lines = []; |
| 5 | +printHeading = { |
| 6 | + println ""; |
| 7 | + println "OFFICIAL DEVSCRIP CONSOLE EDITOR"; |
| 8 | + println "Type /help for a list of commands"; |
| 9 | + println ""; |
| 10 | +}; |
| 11 | + |
| 12 | +printAll = { |
| 13 | + call $printHeading; |
| 14 | + call $printLinesUntil (length $lines); |
| 15 | +}; |
| 16 | + |
| 17 | +recieveInput = { |
| 18 | + print $0 ">"; |
| 19 | + return (input); |
| 20 | +}; |
| 21 | + |
| 22 | + |
| 23 | +printLinesUntil = { |
| 24 | + for i $0 { |
| 25 | + print $i ">" $lines[$i]; |
| 26 | + println ""; |
| 27 | + }; |
| 28 | +}; |
| 29 | + |
| 30 | + |
| 31 | +exec cls; |
| 32 | +call $printHeading; |
| 33 | + |
| 34 | +loop { |
| 35 | + input = (call $recieveInput $currentLine); |
| 36 | + if ($input != "") { |
| 37 | + if ($input == "/edit") { |
| 38 | + println "EDIT LINE?"; |
| 39 | + line = (input); |
| 40 | + call $printLinesUntil ($line + 1); |
| 41 | + print "NEW: "; |
| 42 | + newLine = (input); |
| 43 | + if ($newLine != "") { |
| 44 | + $newLine === $lines $line; |
| 45 | + exec cls; |
| 46 | + call $printAll; |
| 47 | + } {pop $lines $line;currentLine = ($currentLine - 1)}; |
| 48 | + } { |
| 49 | + if ($input == "/list") { |
| 50 | + exec cls; |
| 51 | + call $printAll; |
| 52 | + } { |
| 53 | + if ($input == "/run") { |
| 54 | + whole = ""; |
| 55 | + for i (length $lines) { |
| 56 | + whole = ($whole + $lines[$i]); |
| 57 | + }; |
| 58 | + println ""; |
| 59 | + exec cls; |
| 60 | + call $printAll; |
| 61 | + println ""; |
| 62 | + println "+++EXECUTING+++"; |
| 63 | + println ""; |
| 64 | + script $whole; |
| 65 | + println ""; |
| 66 | + print "Done. Press Enter..."; |
| 67 | + input; |
| 68 | + exec cls; |
| 69 | + call $printAll; |
| 70 | + |
| 71 | + } { |
| 72 | + if ($input == /help) { |
| 73 | + println "Available commands:"; |
| 74 | + println "/help, /run, /edit, /list, /new, /save, /load"; |
| 75 | + println "Fun fact: This program is written in the devscript language! Take a look into the Editor.txt file!"; |
| 76 | + } { |
| 77 | + if ($input == /new) { |
| 78 | + lines = []; |
| 79 | + currentLine = 0; |
| 80 | + exec cls; |
| 81 | + call $printAll; |
| 82 | + } { |
| 83 | + if ($input == "/save") { |
| 84 | + println "SAFE FILE TO? (Use */ for current path)"; |
| 85 | + file = (getFile (input)); |
| 86 | + for i (length $lines) { |
| 87 | + writeFileLine $file $lines[$i]; |
| 88 | + }; |
| 89 | + println "FILE SAVED TO" $file; |
| 90 | + } { |
| 91 | + if ($input == /load) { |
| 92 | + println "LOAD FILE FROM? (Use */ for current path)"; |
| 93 | + file = (getFile (input)); |
| 94 | + fl = (readFileLines $file); |
| 95 | + lines = $fl; |
| 96 | + currentLine = ((length $fl) + 1); |
| 97 | + println "FILE LOADED"; |
| 98 | + } { |
| 99 | + push $input $lines; |
| 100 | + currentLine = ($currentLine + 1); |
| 101 | + }; |
| 102 | + }; |
| 103 | + }; |
| 104 | + }; |
| 105 | + }; |
| 106 | + }; |
| 107 | + }; |
| 108 | + } {exec cls;call $printAll}; |
| 109 | +}; |
0 commit comments