2021-08-09 05:25:20 +08:00
|
|
|
#include <sstream> // for basic_istream, wstringstream
|
|
|
|
#include <string> // for allocator, char_traits, getline, operator+, wstring, basic_string
|
2020-03-23 05:32:44 +08:00
|
|
|
|
2021-08-09 05:25:20 +08:00
|
|
|
#include "ftxui/dom/deprecated.hpp" // for text, paragraph
|
|
|
|
#include "ftxui/dom/elements.hpp" // for Elements
|
2019-01-23 07:26:36 +08:00
|
|
|
|
|
|
|
namespace ftxui {
|
|
|
|
|
2020-08-16 08:24:50 +08:00
|
|
|
/// @brief Return a vector of ftxui::text for every word of the string. This is
|
|
|
|
/// useful combined with ftxui::hflow.
|
|
|
|
/// @param the_text The string to be splitted.
|
|
|
|
/// @ingroup dom
|
|
|
|
/// @see hflow.
|
2019-01-23 07:26:36 +08:00
|
|
|
Elements paragraph(std::wstring the_text) {
|
|
|
|
Elements output;
|
|
|
|
std::wstringstream ss(the_text);
|
|
|
|
std::wstring word;
|
2021-08-09 05:25:20 +08:00
|
|
|
while (std::getline(ss, word, L' '))
|
2019-01-23 09:16:00 +08:00
|
|
|
output.push_back(text(word + L' '));
|
2021-08-09 05:25:20 +08:00
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Return a vector of ftxui::text for every word of the string. This is
|
|
|
|
/// useful combined with ftxui::hflow.
|
|
|
|
/// @param the_text The string to be splitted.
|
|
|
|
/// @ingroup dom
|
|
|
|
/// @see hflow.
|
|
|
|
Elements paragraph(std::string the_text) {
|
|
|
|
Elements output;
|
|
|
|
std::stringstream ss(the_text);
|
|
|
|
std::string word;
|
|
|
|
while (std::getline(ss, word, ' '))
|
|
|
|
output.push_back(text(word + ' '));
|
2019-01-23 07:26:36 +08:00
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ftxui
|
2020-08-16 06:24:18 +08:00
|
|
|
|
|
|
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
|
|
// the LICENSE file.
|