Jump to content




Editable Print.


  • You cannot reply to this topic
15 replies to this topic

#1 Left

  • Members
  • 88 posts

Posted 11 March 2013 - 08:14 PM

Like the edit program how can I print something that can then be edited?

#2 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 11 March 2013 - 08:41 PM

By print do you mean on screen print or paper print?

#3 Left

  • Members
  • 88 posts

Posted 11 March 2013 - 08:43 PM

Print on screen then be able to edit it.... Like the program edit.

#4 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 11 March 2013 - 08:50 PM

You can do it by copying the edit program into your program

#5 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

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?

#6 Kryptanyte

  • Members
  • 95 posts
  • LocationNew Zealand

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.

#7 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 11 March 2013 - 09:43 PM

So basically you want to make something simliar to the adress bar on your browser?

#8 Kryptanyte

  • Members
  • 95 posts
  • LocationNew Zealand

Posted 11 March 2013 - 10:22 PM

Yeah

#9 ikke009

  • Members
  • 224 posts
  • LocationSliding between sunbeams

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

#10 Left

  • Members
  • 88 posts

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

#11 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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


#12 Kryptanyte

  • Members
  • 95 posts
  • LocationNew Zealand

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.

#13 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 11 March 2013 - 11:20 PM

View PostKryptanyte, on 11 March 2013 - 11:16 PM, said:

@TOB What exactly is the mask? Like I see where is it used, but don't fully understand what it is.
Its like when you do read( '*' ) for password input. it "masks" the input.

#14 Kryptanyte

  • Members
  • 95 posts
  • LocationNew Zealand

Posted 11 March 2013 - 11:33 PM

Oh, I see thank you

#15 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 11 March 2013 - 11:35 PM

no problems.

#16 GopherAtl

  • Members
  • 888 posts

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" })






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users