v2.1.0 - Added seeking through words using Ctrl+Left and Ctrl+Right
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
local agcfg = {
|
local agcfg = {
|
||||||
["halyde"] = {
|
["halyde"] = {
|
||||||
["maindir"] = "",
|
["maindir"] = "",
|
||||||
["version"] = "2.0.1",
|
["version"] = "2.1.0",
|
||||||
["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.",
|
["description"] = "A universal, customizable and feature-packed operating system for OpenComputers.",
|
||||||
["directories"] = {
|
["directories"] = {
|
||||||
"halyde/apps",
|
"halyde/apps",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local loadfile = ...
|
local loadfile = ...
|
||||||
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
||||||
|
|
||||||
_G._OSVERSION = "Halyde 2.0.1"
|
_G._OSVERSION = "Halyde 2.1.0"
|
||||||
_G._OSLOGO = ""
|
_G._OSLOGO = ""
|
||||||
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
|
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
|
||||||
repeat
|
repeat
|
||||||
|
|||||||
+24
-1
@@ -246,7 +246,6 @@ function _G.read(readHistoryType, prefix, defaultText, maxChars)
|
|||||||
return a
|
return a
|
||||||
end
|
end
|
||||||
local function curPos(cur)
|
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
|
return unicode.wlen(unicode.sub(text,1,cur-1))+1
|
||||||
end
|
end
|
||||||
local function add(chr)
|
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)
|
set(curPos(cur),strDef(unicode.sub(text,cur,cur)," "),true)
|
||||||
cursorBlink = true
|
cursorBlink = true
|
||||||
end
|
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)
|
local function isLine(chr)
|
||||||
return chr=="\n" or chr=="\r"
|
return chr=="\n" or chr=="\r"
|
||||||
end
|
end
|
||||||
@@ -299,6 +318,10 @@ function _G.read(readHistoryType, prefix, defaultText, maxChars)
|
|||||||
elseif key=="down" and readHistoryType then
|
elseif key=="down" and readHistoryType then
|
||||||
historyIdx=math.min(historyIdx+1,#termlib.readHistory[readHistoryType])
|
historyIdx=math.min(historyIdx+1,#termlib.readHistory[readHistoryType])
|
||||||
reprint(termlib.readHistory[readHistoryType][historyIdx])
|
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
|
elseif key=="left" then
|
||||||
moveCur(-1)
|
moveCur(-1)
|
||||||
elseif key=="right" then
|
elseif key=="right" then
|
||||||
|
|||||||
Reference in New Issue
Block a user