This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Editable Print.
Started by Left, 11 March 2013 - 07:14 PMPosted 11 March 2013 - 08:14 PM
Like the edit program how can I print something that can then be edited?
Posted 11 March 2013 - 08:41 PM
By print do you mean on screen print or paper print?
Posted 11 March 2013 - 08:43 PM
Print on screen then be able to edit it…. Like the program edit.
Posted 11 March 2013 - 08:50 PM
You can do it by copying the edit program into your program
Posted 11 March 2013 - 09:13 PM
Print only draws text to the screen. Making it editable is not a trivial task. I recommend you take a look at edit. What do you need this for?
Posted 11 March 2013 - 09:30 PM
I am also interested in this, for like a config file, so you don't have to go into the config file to change options.
Posted 11 March 2013 - 09:43 PM
So basically you want to make something simliar to the adress bar on your browser?
Posted 11 March 2013 - 10:22 PM
Yeah
Posted 11 March 2013 - 10:27 PM
I believe this has been asked before about a week ago.. Im on my tablet right now so i cant look it up easily for you, but i suggest using the search button and see what you can find
Posted 11 March 2013 - 10:45 PM
I looked at the edit program and it seems to just return lines. I dont know how this works
Posted 11 March 2013 - 10:49 PM
This isn't all the code, and its really basic, but here is the start of what you need to do
local function editableInput( initial, mask )
local sx, sy = term.getCursorPos()
while true do
local event, param = os.pullEvent()
if event == 'key' then
if param == key.backspace then
initial = initial:sub( 1, #initial - 1 )
end
elseif event == 'char' then
initial = initial..param
end
end
term.setCursorPos(sx,sy)
if mask then
write( string.rep( mask, #initial )..' ' )
else
write( initial..' ' )
end
end
Posted 11 March 2013 - 11:16 PM
@TOB What exactly is the mask? Like I see where is it used, but don't fully understand what it is.
Posted 11 March 2013 - 11:20 PM
Its like when you do read( '*' ) for password input. it "masks" the input.@TOB What exactly is the mask? Like I see where is it used, but don't fully understand what it is.
Posted 11 March 2013 - 11:33 PM
Oh, I see thank you
Posted 11 March 2013 - 11:35 PM
no problems.
Posted 12 March 2013 - 03:27 AM
if all you want is a single line of editable input, basically read() that can be pre-loaded with a value, you can simply queue an up arrow key event before calling read, and pass the initial value in a table as the 2nd argument to read, as so:
os.queueEvent("key",keys.up)
read(nil, { "initial value" })