mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
calc: Migration to libshared
This commit is contained in:
parent
355620c640
commit
0ed7fa8b2a
4 changed files with 5 additions and 67 deletions
|
@ -32,7 +32,8 @@
|
|||
#include <Eval.h>
|
||||
#include <Dates.h>
|
||||
#include <Context.h>
|
||||
#include <text.h>
|
||||
#include <Task.h>
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
#include <ISO8601.h>
|
||||
#include <main.h>
|
||||
#include <i18n.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
|
@ -212,8 +212,7 @@ Chart::Chart (char type)
|
|||
|
||||
// Set the title.
|
||||
std::vector <std::string> words = context.cli2.getWords ();
|
||||
std::string filter;
|
||||
join (filter, " ", words);
|
||||
auto filter = join (" ", words);
|
||||
_title = '(' + filter + ')';
|
||||
}
|
||||
|
||||
|
|
56
src/text.cpp
56
src/text.cpp
|
@ -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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -48,11 +48,5 @@ int strippedLength (const std::string&);
|
|||
const std::string obfuscateText (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
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue