mirror of
				https://github.com/ArthurSonzogni/FTXUI.git
				synced 2025-11-04 05:28:15 +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:
		@@ -33,8 +33,11 @@ Dimensions Terminal::Size() {
 | 
			
		||||
  return Dimensions{80, 80};
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
  winsize w;
 | 
			
		||||
  winsize 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};
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user