mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Embedded version of Clara with TextFlow fix for embedded newlines
This commit is contained in:
		
							
								
								
									
										21
									
								
								third_party/clara.hpp
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								third_party/clara.hpp
									
									
									
									
										vendored
									
									
								
							| @@ -33,8 +33,7 @@ | ||||
| #endif | ||||
|  | ||||
|  | ||||
| namespace clara { namespace TextFlow | ||||
| { | ||||
| namespace clara { namespace TextFlow { | ||||
|  | ||||
|     inline auto isWhitespace( char c ) -> bool { | ||||
|         static std::string chars = " \t\n\r"; | ||||
| @@ -66,6 +65,7 @@ namespace clara { namespace TextFlow | ||||
|             size_t m_pos = 0; | ||||
|  | ||||
|             size_t m_len = 0; | ||||
|             size_t m_end = 0; | ||||
|             bool m_suffix = false; | ||||
|  | ||||
|             iterator( Column const& column, size_t stringIndex ) | ||||
| @@ -90,8 +90,12 @@ namespace clara { namespace TextFlow | ||||
|  | ||||
|                 m_suffix = false; | ||||
|                 auto width = m_column.m_width-indent(); | ||||
|                 if( line().size() < m_pos + width ) { | ||||
|                     m_len = line().size() - m_pos; | ||||
|                 m_end = m_pos; | ||||
|                 while( m_end < line().size() && line()[m_end] != '\n' ) | ||||
|                     ++m_end; | ||||
|  | ||||
|                 if( m_end < m_pos + width ) { | ||||
|                     m_len = m_end - m_pos; | ||||
|                 } | ||||
|                 else { | ||||
|                     size_t len = width; | ||||
| @@ -129,15 +133,18 @@ namespace clara { namespace TextFlow | ||||
|  | ||||
|             auto operator *() const -> std::string { | ||||
|                 assert( m_stringIndex < m_column.m_strings.size() ); | ||||
|                 assert( m_pos < line().size() ); | ||||
|                 if( m_pos + m_column.m_width < line().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)); | ||||
|                     return addIndentAndSuffix(line().substr(m_pos, m_end - m_pos)); | ||||
|             } | ||||
|  | ||||
|             auto operator ++() -> iterator& { | ||||
|                 m_pos += m_len; | ||||
|                 if( m_pos < line().size() && line()[m_pos] == '\n' ) | ||||
|                     m_pos += 1; | ||||
|  | ||||
|                 while( m_pos < line().size() && isWhitespace( line()[m_pos] ) ) | ||||
|                     ++m_pos; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash