Giter Club home page Giter Club logo

Comments (9)

derekdreery avatar derekdreery commented on June 15, 2024

I've had a look at implementing this - the main problem as I see it is that currently the unix implementation does everything with terminfo, therefore not needing to make any system calls directly. The best way to get the console dimensions is to issue an ioctl to populate the winsize struct, but that may not be possible with serial consoles for example.

According to https://unix.stackexchange.com/questions/93173/how-does-less-know-the-terminal-resolution the program less takes the approach of using ioctl if available, and then using some tricks to try and figure out the width/height (e.g. environment variables).

So questions:

  1. Do you want/mind linking to libc on linux?
  2. Do you therefore think that the size function should return an Option, with none if it wasn't possible to calculate the size?

from term.

derekdreery avatar derekdreery commented on June 15, 2024

You can see my messings about at https://github.com/derekdreery/term :master

from term.

Stebalien avatar Stebalien commented on June 15, 2024
  1. I'm fine with that.
  2. When #49 gets merged, we can use a NotSupported error variant.

As for getting this working on unix, given that #49 will be a breaking change anyways I plan on reworking the internals quite a bit (after it lands) so this will probably get much easier.

from term.

derekdreery avatar derekdreery commented on June 15, 2024

http://docs.freebsd.org/44doc/usd/13.viref/paper.html#section5f seems like a good strategy?

from term.

Stebalien avatar Stebalien commented on June 15, 2024

@derekdreery Yes, that looks good. However, I'm probably going to reorder those a bit (use ioctl first, then the environment, then the terminfo database.

from term.

xSke avatar xSke commented on June 15, 2024

Would this be possible in Windows too?

from term.

Stebalien avatar Stebalien commented on June 15, 2024

Yes but I won't be able to do that myself (I don't use windows).

from term.

derekdreery avatar derekdreery commented on June 15, 2024

I put the windows function on the top of this thread - I can implement it - waiting on some constants in libc at the moment

from term.

derekdreery avatar derekdreery commented on June 15, 2024

... a long time later

I've submitted PR #77 to implement this.

from term.

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.