mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-22 03:54:20 -05:00
Compare commits
5 Commits
8865768576
...
c5f304380e
Author | SHA1 | Date | |
---|---|---|---|
|
c5f304380e | ||
|
0aaf4acd52 | ||
|
d15a841316 | ||
|
d12ec38016 | ||
|
0db31a2e27 |
@ -17,7 +17,7 @@ end
|
||||
function ed.bfunc:save(fpath)
|
||||
local path = fpath or self.path
|
||||
if not path then return false, "no path" end
|
||||
self.path = path
|
||||
self.path = path
|
||||
local f = io.open(path,"wb")
|
||||
if not f then return false, "unable to open file" end
|
||||
for k,v in ipairs(self) do
|
||||
@ -112,6 +112,7 @@ function ed.newBuffer()
|
||||
end
|
||||
|
||||
function ed.open(buffer)
|
||||
local bpath = buffer
|
||||
if ed.buffers[buffer] then
|
||||
buffer = ed.buffers[buffer]
|
||||
end
|
||||
@ -120,7 +121,9 @@ function ed.open(buffer)
|
||||
nb:load(buffer)
|
||||
buffer = nb
|
||||
end
|
||||
if type(buffer) ~= "table" then buffer = ed.newBuffer() buffer[1] = "" end
|
||||
if type(buffer) ~= "table" then buffer = ed.newBuffer() end
|
||||
buffer[1] = buffer[1] or ""
|
||||
buffer.path = buffer.path or "/"..((bpath:sub(1,1) == "/" and table.concat(fs.segments(path),"/")) or table.concat(fs.segments(os.getenv("PWD").."/"..bpath),"/"))
|
||||
return buffer
|
||||
end
|
||||
|
||||
|
@ -303,11 +303,21 @@ function buffer:read(...)
|
||||
end
|
||||
hIndex = math.max(math.min(hIndex,#self.history),0)
|
||||
end
|
||||
elseif char == "\8" then
|
||||
elseif char == "\8" then -- backspace
|
||||
if #buffer > 0 and pos <= #buffer then
|
||||
buffer = buffer:sub(1, (#buffer - pos)) .. buffer:sub((#buffer - pos) + 2)
|
||||
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")
|
||||
self.history[#self.history+1] = buffer
|
||||
if #self.history > (self.maxhistory or 16) then table.remove(self.history,1) end
|
||||
|
Loading…
Reference in New Issue
Block a user