File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 4343// ! Maximum number of registers per type
4444static constexpr size_t MODBUS_MAX_REGS = 0x10000 ;
4545
46- // ! Help output line width
47- static constexpr std::size_t HELP_WIDTH = 120 ;
48-
4946// ! Default permissions for the created shared memory
5047static constexpr mode_t DEFAULT_SHM_PERMISSIONS = 0660 ;
5148
@@ -200,7 +197,15 @@ int main(int argc, char **argv) {
200197
201198 // print usage
202199 if (args.count (" help" )) {
203- options.set_width (HELP_WIDTH);
200+ static constexpr std::size_t MIN_HELP_SIZE = 80 ;
201+ if (isatty (STDIN_FILENO)) {
202+ struct winsize w {};
203+ if (ioctl (STDOUT_FILENO, TIOCGWINSZ, &w) != -1 ) { // NOLINT
204+ options.set_width (std::max (static_cast <decltype (w.ws_col )>(MIN_HELP_SIZE), w.ws_col ));
205+ }
206+ } else {
207+ options.set_width (MIN_HELP_SIZE);
208+ }
204209#ifdef OS_LINUX
205210 if (isatty (STDIN_FILENO)) {
206211 struct winsize w {};
You can’t perform that action at this time.
0 commit comments