FTXUI  0.8.1
C++ functional terminal UI.
paragraph.cpp
Go to the documentation of this file.
1 #include <sstream> // for basic_istream, wstringstream
2 #include <string> // for allocator, char_traits, getline, operator+, wstring, basic_string
3 
4 #include "ftxui/dom/deprecated.hpp" // for text, paragraph
5 #include "ftxui/dom/elements.hpp" // for Elements
6 
7 namespace ftxui {
8 
9 /// @brief Return a vector of ftxui::text for every word of the string. This is
10 /// useful combined with ftxui::hflow.
11 /// @param the_text The string to be splitted.
12 /// @ingroup dom
13 /// @see hflow.
14 Elements paragraph(std::wstring the_text) {
15  Elements output;
16  std::wstringstream ss(the_text);
17  std::wstring word;
18  while (std::getline(ss, word, L' '))
19  output.push_back(text(word + L' '));
20  return output;
21 }
22 
23 /// @brief Return a vector of ftxui::text for every word of the string. This is
24 /// useful combined with ftxui::hflow.
25 /// @param the_text The string to be splitted.
26 /// @ingroup dom
27 /// @see hflow.
28 Elements paragraph(std::string the_text) {
29  Elements output;
30  std::stringstream ss(the_text);
31  std::string word;
32  while (std::getline(ss, word, ' '))
33  output.push_back(text(word + ' '));
34  return output;
35 }
36 
37 } // namespace ftxui
38 
39 // Copyright 2020 Arthur Sonzogni. All rights reserved.
40 // Use of this source code is governed by the MIT license that can be found in
41 // the LICENSE file.
ftxui::paragraph
Elements paragraph(std::wstring text)
Return a vector of ftxui::text for every word of the string. This is useful combined with ftxui::hflo...
Definition: paragraph.cpp:14
deprecated.hpp
ftxui
Definition: captured_mouse.hpp:6
ftxui::Elements
std::vector< Element > Elements
Definition: elements.hpp:16
elements.hpp
ftxui::text
Element text(std::wstring text)
Display a piece of unicode text.
Definition: text.cpp:106