diff --git a/include/indicators/block_progress_bar.hpp b/include/indicators/block_progress_bar.hpp index f348be6..11ae0a8 100644 --- a/include/indicators/block_progress_bar.hpp +++ b/include/indicators/block_progress_bar.hpp @@ -1,3 +1,4 @@ + #pragma once #include diff --git a/include/indicators/color.hpp b/include/indicators/color.hpp index 34a7a00..39ad01e 100644 --- a/include/indicators/color.hpp +++ b/include/indicators/color.hpp @@ -1,3 +1,4 @@ + #pragma once #include diff --git a/include/indicators/cursor_control.hpp b/include/indicators/cursor_control.hpp index 5aaa658..6ddedee 100755 --- a/include/indicators/cursor_control.hpp +++ b/include/indicators/cursor_control.hpp @@ -1,3 +1,4 @@ + #pragma once #if defined(_MSC_VER) diff --git a/include/indicators/cursor_movement.hpp b/include/indicators/cursor_movement.hpp index 99a3645..2ae09f0 100755 --- a/include/indicators/cursor_movement.hpp +++ b/include/indicators/cursor_movement.hpp @@ -1,3 +1,4 @@ + #pragma once #if defined(_MSC_VER) diff --git a/include/indicators/details/stream_helper.hpp b/include/indicators/details/stream_helper.hpp index 4259a27..f7e02c9 100644 --- a/include/indicators/details/stream_helper.hpp +++ b/include/indicators/details/stream_helper.hpp @@ -1,3 +1,4 @@ + #pragma once #include diff --git a/include/indicators/display_width.hpp b/include/indicators/display_width.hpp index 6330948..638cec1 100644 --- a/include/indicators/display_width.hpp +++ b/include/indicators/display_width.hpp @@ -1,3 +1,4 @@ + #pragma once #include #include diff --git a/include/indicators/dynamic_progress.hpp b/include/indicators/dynamic_progress.hpp index 7dedb75..2d7370f 100644 --- a/include/indicators/dynamic_progress.hpp +++ b/include/indicators/dynamic_progress.hpp @@ -1,3 +1,4 @@ + #pragma once #include #include diff --git a/include/indicators/font_style.hpp b/include/indicators/font_style.hpp index 6561504..4937470 100644 --- a/include/indicators/font_style.hpp +++ b/include/indicators/font_style.hpp @@ -1,7 +1,5 @@ + #pragma once - namespace indicators { - enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed }; - } diff --git a/include/indicators/indeterminate_progress_bar.hpp b/include/indicators/indeterminate_progress_bar.hpp index 00fec29..b549e06 100644 --- a/include/indicators/indeterminate_progress_bar.hpp +++ b/include/indicators/indeterminate_progress_bar.hpp @@ -1,3 +1,4 @@ + #pragma once #include diff --git a/include/indicators/multi_progress.hpp b/include/indicators/multi_progress.hpp index cdadb00..85c174a 100644 --- a/include/indicators/multi_progress.hpp +++ b/include/indicators/multi_progress.hpp @@ -1,3 +1,4 @@ + #pragma once #include #include diff --git a/include/indicators/progress_bar.hpp b/include/indicators/progress_bar.hpp index 95eb457..dcfae7a 100644 --- a/include/indicators/progress_bar.hpp +++ b/include/indicators/progress_bar.hpp @@ -1,3 +1,4 @@ + #pragma once #include diff --git a/include/indicators/progress_spinner.hpp b/include/indicators/progress_spinner.hpp index ea2f9b0..130b5ff 100644 --- a/include/indicators/progress_spinner.hpp +++ b/include/indicators/progress_spinner.hpp @@ -1,3 +1,4 @@ + #pragma once #include diff --git a/include/indicators/progress_type.hpp b/include/indicators/progress_type.hpp index 314f4f0..2ea1347 100644 --- a/include/indicators/progress_type.hpp +++ b/include/indicators/progress_type.hpp @@ -1,3 +1,4 @@ + #pragma once namespace indicators { diff --git a/include/indicators/setting.hpp b/include/indicators/setting.hpp index 9345882..9bd569c 100644 --- a/include/indicators/setting.hpp +++ b/include/indicators/setting.hpp @@ -1,3 +1,4 @@ + /* Activity Indicators for Modern C++ https://github.com/p-ranav/indicators diff --git a/include/indicators/termcolor.hpp b/include/indicators/termcolor.hpp index a0238a4..b663d61 100644 --- a/include/indicators/termcolor.hpp +++ b/include/indicators/termcolor.hpp @@ -1,3 +1,4 @@ + //! //! termcolor //! ~~~~~~~~~ diff --git a/include/indicators/terminal_size.hpp b/include/indicators/terminal_size.hpp index 923085c..29b21e7 100644 --- a/include/indicators/terminal_size.hpp +++ b/include/indicators/terminal_size.hpp @@ -1,3 +1,4 @@ + #pragma once #include diff --git a/single_include/indicators/indicators.hpp b/single_include/indicators/indicators.hpp index 6344352..f6f20c2 100644 --- a/single_include/indicators/indicators.hpp +++ b/single_include/indicators/indicators.hpp @@ -1,5 +1,7 @@ + #pragma once -// #include //! +// #include +//! //! termcolor //! ~~~~~~~~~ //! @@ -450,21 +452,22 @@ inline void win_change_attributes(std::ostream &stream, int foreground, int back #endif // TERMCOLOR_HPP_ + namespace indicators { enum class Color { grey, red, green, yellow, blue, magenta, cyan, white, unspecified }; } + #pragma once - namespace indicators { - enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed }; - } + #pragma once namespace indicators { enum class ProgressType { incremental, decremental }; } + //! //! termcolor //! ~~~~~~~~~ @@ -915,6 +918,7 @@ inline void win_change_attributes(std::ostream &stream, int foreground, int back #undef TERMCOLOR_OS_LINUX #endif // TERMCOLOR_HPP_ + #pragma once #include @@ -948,6 +952,32 @@ size_t terminal_width() { return terminal_size().second; } #endif } // namespace indicators +/* +Activity Indicators for Modern C++ +https://github.com/p-ranav/indicators + +Licensed under the MIT License . +SPDX-License-Identifier: MIT +Copyright (c) 2019 Dawid Pilarski . + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ #pragma once #include @@ -1140,6 +1170,7 @@ using ProgressType = details::Setting; } // namespace option } // namespace indicators + #pragma once #if defined(_MSC_VER) @@ -1175,6 +1206,7 @@ static inline void show_console_cursor(bool const show) { #endif } // namespace indicators +#pragma once #if defined(_MSC_VER) #if !defined(NOMINMAX) @@ -1220,10 +1252,10 @@ static inline void move_left(int cols) { std::cout << "\033[" << cols << "D"; } #endif } // namespace indicators +#pragma once -// #include -// #include // #include + #include #include #include @@ -1521,6 +1553,9 @@ static inline int display_width(const std::wstring &input) { } // namespace unicode +// #include +// #include + #include #include #include @@ -1653,21 +1688,18 @@ public: std::ostream &write(float progress) { auto pos = static_cast(progress * bar_width / 100.0); - for (size_t i = 0; i < bar_width;) { - std::string next{""}; - size_t current_display_width = 0; + for (size_t i = 0, current_display_width = 0; i < bar_width;) { + std::string next; - if (i < pos && !fill.empty()) { + if (i < pos) { next = fill; current_display_width = unicode::display_width(fill); - } else if (i == pos && !lead.empty()) { + } else if (i == pos) { next = lead; current_display_width = unicode::display_width(lead); } else { - if (!remainder.empty()) { - next = remainder; - current_display_width = unicode::display_width(remainder); - } + next = remainder; + current_display_width = unicode::display_width(remainder); } i += current_display_width; @@ -2019,6 +2051,7 @@ public: }; } // namespace indicators + #pragma once // #include @@ -2262,6 +2295,7 @@ public: }; } // namespace indicators + #pragma once // #include @@ -2458,6 +2492,7 @@ public: }; } // namespace indicators + #pragma once #include #include @@ -2465,8 +2500,8 @@ public: #include #include -// #include // #include +// #include namespace indicators { @@ -2535,6 +2570,7 @@ public: }; } // namespace indicators + #pragma once #include #include @@ -2648,6 +2684,7 @@ public: }; } // namespace indicators + #pragma once // #include