diff --git a/lib/aux_vis.cpp b/lib/aux_vis.cpp index 12c15b4f..a0c6206d 100644 --- a/lib/aux_vis.cpp +++ b/lib/aux_vis.cpp @@ -1785,24 +1785,26 @@ void SetFont(const std::string& fn) #endif } -function NumberFormatter(int precision, char format, bool showsign) +function NumberFormatter(int precision, char format, + bool showsign) { return [precision, format, showsign](double x) -> string { ostringstream oss; - switch (format) { + switch (format) + { case 'f': - oss << fixed; - break; + oss << fixed; + break; case 's': - oss << scientific; - break; + oss << scientific; + break; case 'd': - oss << defaultfloat; - break; + oss << defaultfloat; + break; default: MFEM_WARNING("Unknown formatting type. Using default. " - << "Valid options include: ['f', 's', 'd']" << endl); + << "Valid options include: ['f', 's', 'd']" << endl); oss << defaultfloat; break; }; diff --git a/lib/aux_vis.hpp b/lib/aux_vis.hpp index e1b8c259..27ce2cab 100644 --- a/lib/aux_vis.hpp +++ b/lib/aux_vis.hpp @@ -136,7 +136,8 @@ bool SetFont(const vector& patterns, int height); void SetFont(const std::string& fn); void SetUseHiDPI(bool status); -function NumberFormatter(int precision=4, char format='d', bool showsign=false); +function NumberFormatter(int precision=4, char format='d', + bool showsign=false); function NumberFormatter(string formatting); bool isValidNumberFormatting(const string& formatting); @@ -148,40 +149,40 @@ bool isValidNumberFormatting(const string& formatting); template T prompt(const string question, const T* default_value = nullptr, - function validator = [](T) { return true; }) +function validator = [](T) { return true; }) { - T input; - string strInput; - - while (true) - { - cout << question << " "; - getline(cin, strInput); - stringstream buf(strInput); - - if (strInput.empty() && default_value != nullptr) - { - cout << "Input empty. Using default value: " << *default_value << endl; - return *default_value; - } - - if (buf >> input) - { - if (validator(input)) - { - return input; - } - else - { - cout << "Input is not valid. Please try again." << endl; - } - } - else - { - cout << "Input can not be casted to expected type. Please try again." << endl; - } - } - return input; + T input; + string strInput; + + while (true) + { + cout << question << " "; + getline(cin, strInput); + stringstream buf(strInput); + + if (strInput.empty() && default_value != nullptr) + { + cout << "Input empty. Using default value: " << *default_value << endl; + return *default_value; + } + + if (buf >> input) + { + if (validator(input)) + { + return input; + } + else + { + cout << "Input is not valid. Please try again." << endl; + } + } + else + { + cout << "Input can not be casted to expected type. Please try again." << endl; + } + } + return input; } #endif diff --git a/lib/sdl.cpp b/lib/sdl.cpp index 958389e6..1149a79d 100644 --- a/lib/sdl.cpp +++ b/lib/sdl.cpp @@ -382,8 +382,8 @@ void SdlWindow::mainIter() keep_going = true; break; case SDL_KEYDOWN: -// For debugging: uncomment the next line to track key events. -// #define TRACK_KEY_EVENTS + // For debugging: uncomment the next line to track key events. + // #define TRACK_KEY_EVENTS #ifdef TRACK_KEY_EVENTS cout << "Event: SDL_KEYDOWN sym=" << e.key.keysym.sym << " mod=" << e.key.keysym.mod << endl; diff --git a/lib/threads.cpp b/lib/threads.cpp index 4e964ee9..e961c5f7 100644 --- a/lib/threads.cpp +++ b/lib/threads.cpp @@ -1256,7 +1256,8 @@ void communication_thread::execute() string formatting; *is[0] >> ws >> c; // read the opening char - getline(*is[0], formatting, c); // read formatting string & use c for termination + getline(*is[0], formatting, + c); // read formatting string & use c for termination // all processors sent the command for (size_t i = 1; i < is.size(); i++) @@ -1277,7 +1278,8 @@ void communication_thread::execute() string formatting; *is[0] >> ws >> c; // read the opening char - getline(*is[0], formatting, c); // read formatting string & use c for termination + getline(*is[0], formatting, + c); // read formatting string & use c for termination // all processors sent the command for (size_t i = 1; i < is.size(); i++) diff --git a/lib/vsdata.cpp b/lib/vsdata.cpp index adca19b6..b0351f18 100644 --- a/lib/vsdata.cpp +++ b/lib/vsdata.cpp @@ -571,10 +571,11 @@ void KeycPressed(GLenum state) int precision = prompt("Enter precision (4): ", &default_precision, - [](int p){ return p>=0; }); - char format = prompt("Enter format [(d)efault, (f)ixed, (s)cientific] (d): ", - &default_format, - [](char c){ return c=='d' || c=='f' || c=='s'; }); + [](int p) { return p>=0; }); + char format = + prompt("Enter format [(d)efault, (f)ixed, (s)cientific] (d): ", + &default_format, + [](char c) { return c=='d' || c=='f' || c=='s'; }); bool showsign = prompt("Show sign? [(1)true, (0)false] (0): ", &default_showsign); vsdata->SetColorbarNumberFormat(precision, format, showsign); @@ -628,10 +629,11 @@ void Key_Mod_a_Pressed(GLenum state) int precision = prompt("Enter precision (4): ", &default_precision, - [](int p){ return p>=0; }); - char format = prompt("Enter format [(d)efault, (f)ixed, (s)cientific] (d): ", - &default_format, - [](char c){ return c=='d' || c=='f' || c=='s'; }); + [](int p) { return p>=0; }); + char format = + prompt("Enter format [(d)efault, (f)ixed, (s)cientific] (d): ", + &default_format, + [](char c) { return c=='d' || c=='f' || c=='s'; }); bool showsign = prompt("Show sign? [(1)true, (0)false] (0): ", &default_showsign); vsdata->SetAxisNumberFormat(precision, format, showsign);