mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
some fixes learned from btm for term, grep, and devfs
using buffers for term stream string (used in devfs) simulate enter key and split clipboards on multiline paste delay proxy calls to eeprom until actually using /dev/eeprom all reads on /dev/null (returns nil) fix grep using ^
This commit is contained in:
parent
f388340dd0
commit
2a5de6868a
@ -291,7 +291,7 @@ local function test(m,p)
|
||||
write("\n")
|
||||
empty_line = true
|
||||
needs_filename, needs_line_num = include_filename, print_line_num
|
||||
elseif p:find("^^") then break end
|
||||
elseif p:find("^^") and not plain then p="^$" end
|
||||
end
|
||||
if not empty_line then write("\n") end
|
||||
end
|
||||
|
@ -1,8 +1,20 @@
|
||||
require("filesystem").mount(
|
||||
setmetatable({
|
||||
isReadOnly = function()return false end,
|
||||
address = require("uuid").next()
|
||||
address = "f5501a9b-9c23-1e7a-4afe-4b65eed9b88a"
|
||||
},
|
||||
{
|
||||
__index=function(tbl,key)return require("devfs")[key]end
|
||||
__index=function(tbl,key)
|
||||
local pass
|
||||
local passthrough = function() return pass end
|
||||
if key == "getLabel" then
|
||||
pass = "devfs"
|
||||
elseif key == "spaceTotal" or key == "spaceUsed" then
|
||||
pass = 0
|
||||
elseif key == "isReadOnly" then
|
||||
pass = false
|
||||
else
|
||||
return require("devfs")[key]
|
||||
end
|
||||
return passthrough
|
||||
end
|
||||
}), "/dev")
|
||||
|
@ -191,22 +191,10 @@ local devfs = new_devfs_dir()
|
||||
|
||||
local bfd = "bad file descriptor"
|
||||
|
||||
function devfs.getLabel()
|
||||
return "devfs"
|
||||
end
|
||||
|
||||
function devfs.setLabel(value)
|
||||
error("drive does not support labeling")
|
||||
end
|
||||
|
||||
function devfs.spaceTotal()
|
||||
return 0
|
||||
end
|
||||
|
||||
function devfs.spaceUsed()
|
||||
return 0
|
||||
end
|
||||
|
||||
function devfs.makeDirectory(path)
|
||||
return false, "to create dirs in devfs use devfs.create"
|
||||
end
|
||||
@ -284,9 +272,7 @@ end
|
||||
|
||||
devfs.create("null", devfs_load("null"))
|
||||
devfs.create("random", devfs_load("random"))
|
||||
if comp.isAvailable("eeprom") then
|
||||
devfs.create("eeprom", devfs_load("eeprom"))
|
||||
devfs.create("eeprom-data", devfs_load("eeprom-data"))
|
||||
end
|
||||
devfs.create("eeprom", devfs_load("eeprom"))
|
||||
devfs.create("eeprom-data", devfs_load("eeprom-data"))
|
||||
|
||||
return devfs
|
||||
|
@ -261,7 +261,7 @@ function term.readKeyboard(ops)
|
||||
if name == "touch" or name == "drag" then
|
||||
term.internal.onTouch(input,char,code)
|
||||
elseif name == "clipboard" then
|
||||
c = char
|
||||
c = term.internal.clipboard(char)
|
||||
hints.cache = nil
|
||||
elseif name == "key_down" then
|
||||
hints.cache = nil
|
||||
@ -634,4 +634,17 @@ function --[[@delayloaded-start@]] term.getGlobalArea(window)
|
||||
return dx+1,dy+1,w,h
|
||||
end --[[@delayloaded-end@]]
|
||||
|
||||
function --[[@delayloaded-start@]] term.internal.clipboard(char)
|
||||
local first_line, end_index = char:find("\13?\10")
|
||||
if first_line then
|
||||
local after = char:sub(end_index + 1)
|
||||
if after ~= "" then
|
||||
require("computer").pushSignal("key_down", term.keyboard(), 13, 28)
|
||||
require("computer").pushSignal("clipboard", term.keyboard(), after)
|
||||
end
|
||||
char = char:sub(1, first_line - 1)
|
||||
end
|
||||
return char
|
||||
end --[[@delayloaded-end@]]
|
||||
|
||||
return term, local_env
|
||||
|
@ -334,7 +334,7 @@ function --[[@delayloaded-start@]] text.internal.reader(txt)
|
||||
end,
|
||||
}
|
||||
|
||||
return reader
|
||||
return require("buffer").new("r", reader)
|
||||
end --[[@delayloaded-end@]]
|
||||
|
||||
function --[[@delayloaded-start@]] text.internal.writer(ostream, append_txt)
|
||||
@ -374,7 +374,7 @@ function --[[@delayloaded-start@]] text.internal.writer(ostream, append_txt)
|
||||
end,
|
||||
}
|
||||
|
||||
return writer
|
||||
return require("buffer").new("w", writer)
|
||||
end --[[@delayloaded-end@]]
|
||||
|
||||
return text, local_env
|
||||
|
@ -1,10 +1,6 @@
|
||||
local comp = require("component")
|
||||
local text = require("text")
|
||||
|
||||
if not comp.isAvailable("eeprom") then
|
||||
return nil
|
||||
end
|
||||
|
||||
return
|
||||
{
|
||||
open = function(mode)
|
||||
|
@ -1,10 +1,6 @@
|
||||
local comp = require("component")
|
||||
local text = require("text")
|
||||
|
||||
if not comp.isAvailable("eeprom") then
|
||||
return nil
|
||||
end
|
||||
|
||||
return
|
||||
{
|
||||
open = function(mode)
|
||||
|
@ -1,11 +1,9 @@
|
||||
return
|
||||
{
|
||||
open = function(mode)
|
||||
if not mode or not mode:match("[wa]") then
|
||||
return nil, "write only"
|
||||
end
|
||||
return
|
||||
{
|
||||
read = function() end,
|
||||
write = function() end
|
||||
}
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user