From fe7b1ccca6321f215af76061758616aee60c18bf Mon Sep 17 00:00:00 2001 From: Ponali Date: Tue, 8 Jul 2025 12:07:53 +0200 Subject: [PATCH] v2.1.0 - Added seeking through words using Ctrl+Left and Ctrl+Right --- argentum.cfg | 2 +- halyde/core/boot.lua | 2 +- halyde/core/termlib.lua | 25 ++++++++++++++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/argentum.cfg b/argentum.cfg index a8dd6a9..81e828a 100644 --- a/argentum.cfg +++ b/argentum.cfg @@ -1,7 +1,7 @@ local agcfg = { ["halyde"] = { ["maindir"] = "", - ["version"] = "2.0.1", + ["version"] = "2.1.0", ["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.", ["directories"] = { "halyde/apps", diff --git a/halyde/core/boot.lua b/halyde/core/boot.lua index 16aa2de..b27e83d 100644 --- a/halyde/core/boot.lua +++ b/halyde/core/boot.lua @@ -1,7 +1,7 @@ local loadfile = ... local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile) -_G._OSVERSION = "Halyde 2.0.1" +_G._OSVERSION = "Halyde 2.1.0" _G._OSLOGO = "" local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil repeat diff --git a/halyde/core/termlib.lua b/halyde/core/termlib.lua index 238242c..575a736 100644 --- a/halyde/core/termlib.lua +++ b/halyde/core/termlib.lua @@ -246,7 +246,6 @@ function _G.read(readHistoryType, prefix, defaultText, maxChars) return a end local function curPos(cur) - -- component.ocelot.log(table.concat({cur,unicode.wlen(unicode.sub(text,1,cur)),unicode.len(text)}," ")) return unicode.wlen(unicode.sub(text,1,cur-1))+1 end local function add(chr) @@ -268,6 +267,26 @@ function _G.read(readHistoryType, prefix, defaultText, maxChars) set(curPos(cur),strDef(unicode.sub(text,cur,cur)," "),true) cursorBlink = true end + local function isLetter(chr) + return not string.find("\x09 :@-./_~?&=%+#",chr,1,true) + end + local function nextCur(dir,chr) + local next = math.max(math.min(cur+dir,unicode.len(text)+1),1) + if chr then return unicode.sub(text,next,next) end + return next + end + local function moveWord(dir) + if nextCur(dir)==cur then return end + set(curPos(cur),strDef(unicode.sub(text,cur,cur)," "),false) + while nextCur(dir)~=cur and isLetter(nextCur(dir,true))==(dir==1) do + cur=nextCur(dir) + end + while nextCur(dir)~=cur and isLetter(nextCur(dir,true))==(dir==-1) do + cur=nextCur(dir) + end + set(curPos(cur),strDef(unicode.sub(text,cur,cur)," "),true) + cursorBlink = true + end local function isLine(chr) return chr=="\n" or chr=="\r" end @@ -299,6 +318,10 @@ function _G.read(readHistoryType, prefix, defaultText, maxChars) elseif key=="down" and readHistoryType then historyIdx=math.min(historyIdx+1,#termlib.readHistory[readHistoryType]) reprint(termlib.readHistory[readHistoryType][historyIdx]) + elseif key=="left" and keyboard.ctrlDown then + moveWord(-1) + elseif key=="right" and keyboard.ctrlDown then + moveWord(1) elseif key=="left" then moveCur(-1) elseif key=="right" then