From f81e9089d39bc0fc6117770b99320b9dca1d2d3e Mon Sep 17 00:00:00 2001 From: mcplayer3 <219271061+mcplayer3@users.noreply.github.com> Date: Sun, 7 Jun 2026 00:12:25 +1000 Subject: [PATCH] Started making a better version of `edit` --- halyde/apps/bedit.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 halyde/apps/bedit.lua diff --git a/halyde/apps/bedit.lua b/halyde/apps/bedit.lua new file mode 100644 index 0000000..08eace7 --- /dev/null +++ b/halyde/apps/bedit.lua @@ -0,0 +1,36 @@ +local fs = require("filesystem") +local shell = require("shell") + +local args = {...} +local file = args[1] +if not file then + print("\x1b[91mEnter a file name.") + return +end +if fs.isDirectory(file) then + print("\x1b[91mThe specified file is a directory.") + return +end + +if file:sub(1, 1) ~= "/" then + file = fs.concat(shell.getWorkingDirectory(), file) +end + +local data = "" +if fs.exists(file) then + local handle = fs.open(file) + local tmpdata + repeat + tmpdata = handle:read(math.huge or math.maxinteger) + data = data .. (tmpdata or "") + until not tmpdata +end + +local lines = {} +for line in data:gmatch("[^\r\n]+") do + table.insert(lines, line) +end + +for _, line in ipairs(lines) do + print(line) +end \ No newline at end of file