Comments (9)
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:
- Do you want/mind linking to libc on linux?
- 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.
You can see my messings about at https://github.com/derekdreery/term :master
from term.
- I'm fine with that.
- 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.
http://docs.freebsd.org/44doc/usd/13.viref/paper.html#section5f seems like a good strategy?
from term.
@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.
Would this be possible in Windows too?
from term.
Yes but I won't be able to do that myself (I don't use windows).
from term.
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.
... a long time later
I've submitted PR #77 to implement this.
from term.
Related Issues (20)
- Support parsing termcap HOT 11
- Check isatty == false before coloring HOT 11
- tag version v0.4.0? HOT 2
- How to fall back on std::io::stderr() if term::stderr() fails? HOT 8
- Better MSYS2 support HOT 14
- WinConsole's tty check is inaccurate HOT 1
- All Terminal methods leak memory on Windows HOT 7
- better support for multithreaded programs HOT 9
- Use `el` not `dl` to erase a line?
- How to store and pass around `Terminal` of any type. HOT 3
- `Terminal` should probably buffer
- panic with operation not supported by the terminal while libterm works fine HOT 3
- Term crashes on FreeBSD HOT 7
- No output to stdout when no TTY attached in Docker container HOT 2
- term::stdout() returns None unexpectedly HOT 3
- terminfo problem while using rogcat HOT 2
- Write plain text when running under a start/stop daemon like systemd ?
- [LFM] Looking For Maintainer HOT 11
- Last release was in February 2018 HOT 1
- Please relase a new version HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from term.