calc: Migration to libshared

This commit is contained in:
Paul Beckingham 2016-12-06 07:23:25 -05:00
parent 355620c640
commit 0ed7fa8b2a
4 changed files with 5 additions and 67 deletions

View file

@ -32,7 +32,8 @@
#include <Eval.h> #include <Eval.h>
#include <Dates.h> #include <Dates.h>
#include <Context.h> #include <Context.h>
#include <text.h> #include <Task.h>
#include <format.h>
#include <util.h> #include <util.h>
#include <i18n.h> #include <i18n.h>

View file

@ -37,8 +37,8 @@
#include <ISO8601.h> #include <ISO8601.h>
#include <main.h> #include <main.h>
#include <i18n.h> #include <i18n.h>
#include <text.h> #include <shared.h>
#include <util.h> #include <format.h>
extern Context context; extern Context context;
@ -212,8 +212,7 @@ Chart::Chart (char type)
// Set the title. // Set the title.
std::vector <std::string> words = context.cli2.getWords (); std::vector <std::string> words = context.cli2.getWords ();
std::string filter; auto filter = join (" ", words);
join (filter, " ", words);
_title = '(' + filter + ')'; _title = '(' + filter + ')';
} }

View file

@ -377,59 +377,3 @@ void replace_positional (
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
std::string leftJustify (const int input, const int width)
{
std::stringstream s;
s << input;
std::string output = s.str ();
return output + std::string (width - output.length (), ' ');
}
////////////////////////////////////////////////////////////////////////////////
std::string leftJustify (const std::string& input, const int width)
{
auto len = static_cast <int> (utf8_text_width (input));
if (len == width)
return input;
if (len > width)
return input.substr (0, width);
return input + std::string (width - utf8_text_width (input), ' ');
}
////////////////////////////////////////////////////////////////////////////////
std::string rightJustifyZero (const int input, const int width)
{
std::stringstream s;
s << std::setw (width) << std::setfill ('0') << input;
return s.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string rightJustify (const int input, const int width)
{
std::stringstream s;
s << std::setw (width) << std::setfill (' ') << input;
return s.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string rightJustify (const std::string& input, const int width)
{
auto len = static_cast <int> (utf8_text_width (input));
if (len == width)
return input;
if (len > width)
return input.substr (0, width);
return ((width > len)
? std::string (width - len, ' ')
: "")
+ input;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -48,11 +48,5 @@ int strippedLength (const std::string&);
const std::string obfuscateText (const std::string&); const std::string obfuscateText (const std::string&);
void replace_positional (std::string&, const std::string&, const std::string&); void replace_positional (std::string&, const std::string&, const std::string&);
std::string leftJustify (const int, const int);
std::string leftJustify (const std::string&, const int);
std::string rightJustifyZero (const int, const int);
std::string rightJustify (const int, const int);
std::string rightJustify (const std::string&, const int);
#endif #endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////