Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select adaptive width for process bar #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Unsigned-Long
Copy link

  • Add .gitignore and CMakeLists.txt files.
  • Select adaptive width for the process bar. when the width of the output message is larger than the width of the terminal, the message line can not be flushed. This can be solved by selecting a suitable width of the the process bar at the beginning (the origin width is 40).
  • The adaptive width module works well on both ubuntu and windows.
        int width = []() {
#ifdef __linux__
          struct winsize win {};
          ioctl(0, TIOCGWINSZ, &win);
          unsigned short width = win.ws_col;
#else
          CONSOLE_SCREEN_BUFFER_INFO csbi;
          GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
          unsigned short width = csbi.srWindow.Right - csbi.srWindow.Left;
#endif
          // return the space left for process bar 
          // '60' is an experience value to exclude other output info, such as percent, time elapsed, etc.
          return std::max((int)width - 60, 1);
        }();

fig1

petebunting added a commit to remotesensinginfo/rsgislib that referenced this pull request Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant