aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/line_accumulator.cc10
-rw-r--r--src/line_accumulator.h3
2 files changed, 11 insertions, 2 deletions
diff --git a/src/line_accumulator.cc b/src/line_accumulator.cc
index d12ef54..31b8ddc 100644
--- a/src/line_accumulator.cc
+++ b/src/line_accumulator.cc
@@ -54,8 +54,12 @@ std::size_t getCharacterLength(const std::string& token) {
namespace justify {
-LineAccumulator::LineAccumulator(const std::uint8_t max_length):
+LineAccumulator::LineAccumulator(
+ const std::uint8_t max_length,
+ const std::uint8_t offset
+):
max_length_{max_length},
+ offset_{offset},
length_{0},
tokens_{} { }
@@ -160,6 +164,10 @@ void LineAccumulator::discharge(const bool full) {
this->justify();
}
+ if ( this->offset_ > 0 ) {
+ std::cout << std::string(this->offset_, ' ');
+ }
+
for ( const auto& token : this->tokens_ ) {
std::cout << token.first
<< std::string(token.second, ' ');
diff --git a/src/line_accumulator.h b/src/line_accumulator.h
index 2ca271c..69b4c74 100644
--- a/src/line_accumulator.h
+++ b/src/line_accumulator.h
@@ -9,7 +9,7 @@ namespace justify {
class LineAccumulator {
public:
- LineAccumulator(const std::uint8_t max_length);
+ LineAccumulator(const std::uint8_t max_length, const std::uint8_t offset);
~LineAccumulator();
std::uint8_t getMissing() const;
@@ -18,6 +18,7 @@ class LineAccumulator {
private:
const std::uint8_t max_length_;
+ const std::uint8_t offset_;
std::uint8_t length_;