1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-22 03:54:20 -05:00

added some more keyboard shortcuts to io.read linemode

This commit is contained in:
XeonSquared 2020-08-21 10:18:43 +10:00
parent 8865768576
commit 0db31a2e27

View File

@ -303,11 +303,21 @@ function buffer:read(...)
end end
hIndex = math.max(math.min(hIndex,#self.history),0) hIndex = math.max(math.min(hIndex,#self.history),0)
end end
elseif char == "\8" then elseif char == "\8" then -- backspace
if #buffer > 0 and pos <= #buffer then if #buffer > 0 and pos <= #buffer then
buffer = buffer:sub(1, (#buffer - pos)) .. buffer:sub((#buffer - pos) + 2) buffer = buffer:sub(1, (#buffer - pos)) .. buffer:sub((#buffer - pos) + 2)
end end
elseif char == "\13" or char == "\10" or char == "\n" then elseif char == "\1" then -- ^A, go to start of line
pos = buffer:len()+1
elseif char == "\5" then -- ^E, go to end of line
pos = 1
elseif char == "\2" then -- ^B, back one word
local nc = buffer:reverse():find(" ",pos+1)
pos = nc or #buffer+1
elseif char == "\6" then -- ^F, forward one word
local nc = buffer:find(" ",math.max(#buffer-pos+3,0))
pos = (nc and #buffer-nc+2) or 1
elseif char == "\13" or char == "\10" or char == "\n" then -- return / newline
io.write("\n") io.write("\n")
self.history[#self.history+1] = buffer self.history[#self.history+1] = buffer
if #self.history > (self.maxhistory or 16) then table.remove(self.history,1) end if #self.history > (self.maxhistory or 16) then table.remove(self.history,1) end