[ANN] HighLine 0.4.0

  • Thread starter James Edward Gray II
  • Start date
J

James Edward Gray II

You might not want to use stty in that exact way. From the stty
manpage (on OSX):

Hey, that's great to know. Thanks.

Is that going to work the same on other Unix flavors as well?

James Edward Gray II
 
A

Andre Nathan

James Edward Gray II said:
Just to give one example, the stty trick works on Mac OS X
out of the box, but I believe you can only install termios if you've
installed Apple's optional Developer Tools.

Hmm. Maybe keep stty as a backup mechanism then... try to require
termios and fall back to stty if it fails. Would that be too ugly?

Best regards,
Andre
 
J

James Edward Gray II

Hmm. Maybe keep stty as a backup mechanism then... try to require
termios and fall back to stty if it fails. Would that be too ugly?

That's an option, possibly.

Can you tell me how to read individual characters with termios? I've
been messing with it and I can't get that right for anything. I
clearly don't know the secret handshake!

On a semi-related angle, is anyone aware of a Unix that isn't going
to support the stty hack? Just curious...

James Edward Gray II
 
M

Mark Hubbart

Hi,

Hey, that's great to know. Thanks.

Is that going to work the same on other Unix flavors as well?

It works on my webhost's Debian system. It seems it's just dumping and
restoring the settings, so it should be safe on all platforms. Setting
"raw" actually sets several other flags, and unsetting "raw" unsets
those same flags. So if someone has turned on or off some of those
flags, those settings would be lost if you do "raw" followed by
"-raw". I think :)

cheers,
Mark
 
J

jm

It works on my webhost's Debian system. It seems it's just dumping and
restoring the settings, so it should be safe on all platforms. Setting
"raw" actually sets several other flags, and unsetting "raw" unsets
those same flags. So if someone has turned on or off some of those
flags, those settings would be lost if you do "raw" followed by
"-raw". I think :)

-a will list the current settings in human readable form, ie, on my
system
$ stty -a
speed 9600 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = M-^?; eol2
= M-^?;
start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon
-ixoff
-iuclc ixany imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0
vt0 ff0
isig icanon iexten echo echoe -echok -echonl -noflsh -xcase -tostop
-echoprt
echoctl echoke


J.
 
M

Mark Hubbart

Hey, that's great to know. Thanks.

Update: setting "raw" seems to be overkill. It might keep the OS from
converting linefeeds and such. Here's the method I'm using in a
project I'm working on now:

def no_echo
state = `stty -g`
system "stty -echo cbreak"
yield
ensure
system "stty #{state}"
end

no_echo{gets} #==>"test\n"

Using raw, it reads the "enter" key as a carriage return, and gets
doesn't work as expected.

cheers,
Mark
 
J

James Edward Gray II

Update: setting "raw" seems to be overkill. It might keep the OS from
converting linefeeds and such. Here's the method I'm using in a
project I'm working on now:

def no_echo
state = `stty -g`
system "stty -echo cbreak"
yield
ensure
system "stty #{state}"
end

no_echo{gets} #==>"test\n"

Using raw, it reads the "enter" key as a carriage return, and gets
doesn't work as expected.

Thanks for the tips, but HighLine actually counts on this. :)

James Edward Gray II
 
Y

YANAGAWA Kazuhisa

In Message-Id: <[email protected]>
James Edward Gray II said:
Can you tell me how to read individual characters with termios? I've
been messing with it and I can't get that right for anything. I
clearly don't know the secret handshake!

Uhm, is the following URL useful?
<http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/48407>

# Well that's an old and brief article so probably you should make
# sure both ruby-termios things and underlying termios function.


In modern Unixen stty are commonly implemented with termios, so you
can almost always do what you want to do with stty by using termios.
 
J

James Edward Gray II

In Message-Id: <D99ECD6A-8AFA-4383-A1EC-
(e-mail address removed)>


Uhm, is the following URL useful?
<http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/48407>

# Well that's an old and brief article so probably you should make
# sure both ruby-termios things and underlying termios function.

Yes, this helped a lot, thank you. (Sorry for my delayed response.)

I have evaluated this and I still prefer using stty here. For now,
HighLine will go that way. However, I promise to revisit the issue
as soon as someone makes a good case against it. :)

James Edward Gray II
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top