Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Update the embedded textflow
Browse files Browse the repository at this point in the history
No version because there are no versions upstream...
  • Loading branch information
horenmar committed Oct 26, 2018
1 parent b3ec2cf commit f0e8fa3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
27 changes: 18 additions & 9 deletions include/clara_textflow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//
// A single-header library for wrapping and laying out basic text, by Phil Nash
//
// This work is licensed under the BSD 2-Clause license.
// See the accompanying LICENSE file, or the one at https://opensource.org/licenses/BSD-2-Clause
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// This project is hosted at https://github.com/philsquared/textflowcpp

Expand All @@ -16,7 +16,7 @@
#include <vector>

#ifndef CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
#define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80
#define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH
#endif


Expand All @@ -39,7 +39,7 @@ namespace clara { namespace TextFlow {

class Column {
std::vector<std::string> m_strings;
size_t m_width = CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH;
size_t m_width = TEXTFLOW_CONFIG_CONSOLE_WIDTH;
size_t m_indent = 0;
size_t m_initialIndent = std::string::npos;

Expand Down Expand Up @@ -110,6 +110,12 @@ namespace clara { namespace TextFlow {
}

public:
using difference_type = std::ptrdiff_t;
using value_type = std::string;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::forward_iterator_tag;

explicit iterator( Column const& column ) : m_column( column ) {
assert( m_column.m_width > m_column.m_indent );
assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent );
Expand All @@ -121,10 +127,7 @@ namespace clara { namespace TextFlow {
auto operator *() const -> std::string {
assert( m_stringIndex < m_column.m_strings.size() );
assert( m_pos <= m_end );
if( m_pos + m_column.m_width < m_end )
return addIndentAndSuffix(line().substr(m_pos, m_len));
else
return addIndentAndSuffix(line().substr(m_pos, m_end - m_pos));
return addIndentAndSuffix(line().substr(m_pos, m_len));
}

auto operator ++() -> iterator& {
Expand Down Expand Up @@ -234,6 +237,12 @@ namespace clara { namespace TextFlow {
}

public:
using difference_type = std::ptrdiff_t;
using value_type = std::string;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::forward_iterator_tag;

explicit iterator( Columns const& columns )
: m_columns( columns.m_columns ),
m_activeIterators( m_columns.size() )
Expand Down Expand Up @@ -323,6 +332,6 @@ namespace clara { namespace TextFlow {
cols += other;
return cols;
}
}} // namespace clara::TextFlow
}

#endif // CLARA_TEXTFLOW_HPP_INCLUDED
23 changes: 16 additions & 7 deletions third_party/TextFlow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//
// A single-header library for wrapping and laying out basic text, by Phil Nash
//
// This work is licensed under the BSD 2-Clause license.
// See the accompanying LICENSE file, or the one at https://opensource.org/licenses/BSD-2-Clause
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// This project is hosted at https://github.com/philsquared/textflowcpp

Expand Down Expand Up @@ -110,6 +110,12 @@ namespace TextFlow {
}

public:
using difference_type = std::ptrdiff_t;
using value_type = std::string;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::forward_iterator_tag;

explicit iterator( Column const& column ) : m_column( column ) {
assert( m_column.m_width > m_column.m_indent );
assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent );
Expand All @@ -120,11 +126,8 @@ namespace TextFlow {

auto operator *() const -> std::string {
assert( m_stringIndex < m_column.m_strings.size() );
assert( m_pos < m_end );
if( m_pos + m_column.m_width < m_end )
return addIndentAndSuffix(line().substr(m_pos, m_len));
else
return addIndentAndSuffix(line().substr(m_pos, m_end - m_pos));
assert( m_pos <= m_end );
return addIndentAndSuffix(line().substr(m_pos, m_len));
}

auto operator ++() -> iterator& {
Expand Down Expand Up @@ -234,6 +237,12 @@ namespace TextFlow {
}

public:
using difference_type = std::ptrdiff_t;
using value_type = std::string;
using pointer = value_type*;
using reference = value_type&;
using iterator_category = std::forward_iterator_tag;

explicit iterator( Columns const& columns )
: m_columns( columns.m_columns ),
m_activeIterators( m_columns.size() )
Expand Down

0 comments on commit f0e8fa3

Please sign in to comment.