1. wordwrap during console input
- Posted by katsmeow Feb 11, 2015
- 1685 views
I open a dos console, then i tried gets(), getc(), and prompt_string(), but cannot enter text past the right edge of the screen. Text:wrap() applies only to puts()ing, graphics:wrap(1) has no effect. How can i gets() a line of text longer than the console has columns? Wrapping is the normal default in a regular dos cmd window.
I switched to using get_key(), and re-puts()ing the buffer to the screen with each keystroke.
Kat
2. Re: wordwrap during console input
- Posted by ghaberek (admin) Feb 11, 2015
- 1618 views
I open a dos console, then i tried gets(), getc(), and prompt_string(), but cannot enter text past the right edge of the screen. Text:wrap() applies only to puts()ing, graphics:wrap(1) has no effect. How can i gets() a line of text longer than the console has columns? Wrapping is the normal default in a regular dos cmd window.
I switched to using get_key(), and re-puts()ing the buffer to the screen with each keystroke.
Kat
I've noticed this happens with euiw.exe but not eui.exe. Text wraps fine for me with gets() on eui.exe up to 255 characters. Tested on both 4.0.5 and 4.1.0 dev, 32-bit on Windows 7. If you're running from a command prompt, are you using eui.exe? Is that where you're seeing this behavior? Which version of OE and Windows are you running on? (I am wondering if changes to the way Windows handles console apps has changed this behavior.)
-Greg
3. Re: wordwrap during console input
- Posted by katsmeow Feb 11, 2015
- 1618 views
- Last edited Feb 12, 2015
Greg, using
inputline = gets(0) return inputlinethe input line stops at the end of the first screen row at the right side. If column count is 80, i can enter the 80th character, but the cursor stays at the 80th column as well. This is using eui or euiw , version Euphoria-10-Feb-2013 (the last stable release i am aware of).
However, using
-- get user text typed or pasted to input region at bottom of console window
-- test is echoed to screen as it's typed
-- 4 lines max, and only [backspace] is working
function get_text()
sequence inputline = ""
integer colflag = 0
while 1 do
--trace(1)
integer n = get_key()
if n != -1 then
if find(n,{10,13}) -- [enter]
then return inputline
else if equal(n,8) -- 8 = [backspace]
then
junk = get_position()
if not equal(junk[2],1) then
position(junk[1],junk[2]-1)
puts(1,' ')
position(junk[1],junk[2]-1)
inputline = inputline[1..$-1]
end if
if equal(junk[2],1) then
position(junk[1]-1,col_count)
puts(1,' ')
position(junk[1]-1,col_count)
inputline = inputline[1..$-1]
end if
else
inputline &= n
if (length(inputline) > (4*col_count)-2) then return inputline end if
junk = get_position()
if equal(junk[2],col_count) then colflag = 1 end if
position(row_count-3,1)
puts(1,inputline)
if colflag then
position(junk[1]+1,1)
colflag = 0
end if
end if
end if
end if
sleep(0)
end while
return ""
end function --get_text()
-- cursor go left = 1016384
-- cursor go right = 1016416
i can enter 4 screenlines 80 chars wide, and most likely as many screen lines as i want. But i also don't have mouse or cursor controls. I also coded a backspace function (ASerpa's Bug Ticket #915), as you can see, and i should recode the if-stack as a case-stack. I'm not really looking for much as a gui (it's only an irc bot interface, not a real client), but i did expect as much as i find in a dos console window, like when doing a netstat or wget or dir or mogrify operation. Kat

