mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 07:57:20 +02:00
Text Handling
- Implemented longestWord, a UTF8-aware helper for word-wrapping.
This commit is contained in:
parent
28b0960015
commit
1d0ad3838b
3 changed files with 32 additions and 1 deletions
24
src/text.cpp
24
src/text.cpp
|
@ -215,6 +215,30 @@ std::string unquoteText (const std::string& input)
|
|||
return output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int longestWord (const std::string& input)
|
||||
{
|
||||
int longest = 0;
|
||||
int length = 0;
|
||||
std::string::size_type i;
|
||||
int character;
|
||||
|
||||
while (character = utf8_next_char (input, i))
|
||||
{
|
||||
if (character == ' ')
|
||||
{
|
||||
if (length > longest)
|
||||
longest = length;
|
||||
|
||||
length = 0;
|
||||
}
|
||||
else
|
||||
++length;
|
||||
}
|
||||
|
||||
return longest;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void extractLine (std::string& text, std::string& line, int length)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue