Giter Site home page Giter Site logo

Comments (13)

boutil avatar boutil commented on July 18, 2024

I should mention that in these environments, stty prints the following warning:
stty: standard input: Inappropriate ioctl for device

from highline.

JEG2 avatar JEG2 commented on July 18, 2024

Is there another way for us to get the terminal size on such systems?

from highline.

boutil avatar boutil commented on July 18, 2024

I am not sure it is possible on purpose, as a minimalist environment is created. The warning says that the flow passes directly through stdin, and not via a terminal. I will ask. At least, what that shows is that there are cases where terminal_size, as it is written now, does not return a Fixnum, and thus the test is not reliable.

from highline.

JEG2 avatar JEG2 commented on July 18, 2024

Right. We just need to decide what it should do in those cases. Should it raise an exception on such platforms?

from highline.

abinoam avatar abinoam commented on July 18, 2024

Hi @boutil and @JEG2 ,

What about just falling back to the old and gold 80x24 terminal size when stty doesn't get the size correctly?

It fixes temporarily until interested people implement support for getting the terminal size for specific system with other methods (not stty size).

What do you think?

from highline.

abinoam avatar abinoam commented on July 18, 2024

I could "reproduce" the issue with a stdin redirection at command line:

rake test < anyfile.txt

It gives me

[ 48/108] TestHighLine#test_terminal_sizestty: stdin isn't a terminal
 = 0.00 s
  1) Failure:
TestHighLine#test_terminal_size [/Users/abinoam/src/highline/test/tc_highline.rb:1098]:
Expected nil to be an instance of Fixnum, not NilClass.

from highline.

JEG2 avatar JEG2 commented on July 18, 2024

Could we use Ruby's standard io/console to get the size when stty returns nothing? Just a thought. I'm fine with the default too.

Could we use the tty?() method to detect $stdin redirects? Not sure if that's helpful.

from highline.

abinoam avatar abinoam commented on July 18, 2024

Testing here.
IO.console.console_size is consistently getting terminal size even with redirections.
Doing some more testing.

from highline.

JEG2 avatar JEG2 commented on July 18, 2024

My fear though is that it could fail if run as a Cron job or in a similar minimized environment. In which case we probably still need a default. I can't decide if this is better or worse.

from highline.

abinoam avatar abinoam commented on July 18, 2024

We could sequentially try more than one method of getting terminal size and
fall back into a default if fail. I'll do some experimentation later and
give a report. Meanwhile, don't merge the PR.
Em 02/02/2015 12:45, "James Edward Gray II" [email protected]
escreveu:

My fear though is that it could fail if run as a Cron job or in a similar
minimized environment. In which case we probably still need a default. I
can't decide if this is better or worse.


Reply to this email directly or view it on GitHub
#85 (comment).

from highline.

abinoam avatar abinoam commented on July 18, 2024

I don't understand clearly.
IO.console.winsize is working well (I misspelled to console_size at my last comment).
IO.console_size not.
I'll try some code now.

from highline.

abinoam avatar abinoam commented on July 18, 2024

Hi @JEG2

Using IO.console.winsize is really great. I also think we could refactor (later) most of the code to rely on it. (trimming all that tests for solaris, etc...)

What do you think of how the PR is now with this new commit?

from highline.

JEG2 avatar JEG2 commented on July 18, 2024

Looks awesome. You went above an beyond the call. Thank you.

from highline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.