mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-26 04:31:34 +08:00
Use sensible defaults in case TIOCGWINSZ fails (#224)
This can happen for example in embedded linux, in case the application is started via serial terminal. Signed-off-by: Jarosław Pelczar <jarek@jpelczar.com> Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
parent
31c26c6956
commit
75482d82d4
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## Current
|
## Current
|
||||||
|
|
||||||
|
## Bug
|
||||||
|
- On Unix system, fallback to {80,25} screen dimension on failure.
|
||||||
|
|
||||||
## 0.10 (2021-09-30)
|
## 0.10 (2021-09-30)
|
||||||
|
|
||||||
## Bug
|
## Bug
|
||||||
|
@ -33,8 +33,11 @@ Dimensions Terminal::Size() {
|
|||||||
return Dimensions{80, 80};
|
return Dimensions{80, 80};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
winsize w;
|
winsize w{};
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||||
|
if (w.ws_col == 0 || w.ws_row == 0) {
|
||||||
|
return Dimensions{80, 25};
|
||||||
|
}
|
||||||
return Dimensions{w.ws_col, w.ws_row};
|
return Dimensions{w.ws_col, w.ws_row};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user