FifeGUI 0.2.0
A C++ GUI library designed for games.
fcn::UTF8StringEditor Class Reference

#include <utf8stringeditor.hpp>

Static Public Member Functions

static int countChars (std::string const &text, int byteOffset)
static int eraseChar (std::string &text, int byteOffset)
static int getOffset (std::string const &text, int charIndex)
static int insertChar (std::string &text, int byteOffset, int ch)
static int nextChar (std::string const &text, int byteOffset)
static int prevChar (std::string const &text, int byteOffset)

Detailed Description

Utility for editing and handling UTF-8 encoded strings.

This is a helper class which allows to use UTF-8 strings in your application.

Definition at line 22 of file utf8stringeditor.hpp.

Member Function Documentation

◆ countChars()

int fcn::UTF8StringEditor::countChars ( std::string const & text,
int byteOffset )
static

Counts characters up to byteOffset.

Parameters
textUTF-8 text to navigate.
byteOffsetByte offset inside the text.
Returns
Number of characters.

Definition at line 71 of file utf8stringeditor.cpp.

Referenced by fcn::TextBox::keyPressed(), and fcn::TextBox::setCaretRowUTF8().

◆ eraseChar()

int fcn::UTF8StringEditor::eraseChar ( std::string & text,
int byteOffset )
static

Erase character at specified byte offset.

Parameters
textUTF-8 text to modify.
byteOffsetByte offset of the character to erase.
Returns
New byte offset (is equal to byteOffset).

Definition at line 37 of file utf8stringeditor.cpp.

Referenced by fcn::PasswordField::keyPressed(), fcn::TextBox::keyPressed(), and fcn::TextField::keyPressed().

◆ getOffset()

int fcn::UTF8StringEditor::getOffset ( std::string const & text,
int charIndex )
static

Gets byte offset for character index.

This method automatically clips charIndex to be inside the string + EOF

Parameters
textUTF-8 text to navigate.
charIndexCharacter index to move to.
Returns
Byte offset of character at charIndex.

Definition at line 76 of file utf8stringeditor.cpp.

Referenced by fcn::TextBox::keyPressed(), fcn::TextBox::setCaretColumnUTF8(), and fcn::TextBox::setCaretRowUTF8().

◆ insertChar()

int fcn::UTF8StringEditor::insertChar ( std::string & text,
int byteOffset,
int ch )
static

Insert a character at specified byte offset.

Parameters
textUTF-8 text to modify.
byteOffsetByte offset where character will be inserted.
chUnicode character to insert.
Returns
New byte offset (after the new character).

Definition at line 49 of file utf8stringeditor.cpp.

Referenced by fcn::PasswordField::keyPressed(), fcn::TextBox::keyPressed(), and fcn::TextField::keyPressed().

◆ nextChar()

int fcn::UTF8StringEditor::nextChar ( std::string const & text,
int byteOffset )
static

Returns byte offset of the next character.

Parameters
textUTF-8 text to navigate.
byteOffsetByte offset of current character.
Returns
Byte offset of the next character.

Definition at line 13 of file utf8stringeditor.cpp.

Referenced by fcn::PasswordField::keyPressed(), fcn::TextBox::keyPressed(), and fcn::TextField::keyPressed().

◆ prevChar()

int fcn::UTF8StringEditor::prevChar ( std::string const & text,
int byteOffset )
static

Returns byte offset of the previous character.

Parameters
textUTF-8 text to navigate.
byteOffsetByte offset of current character.
Returns
Byte offset of the previous character.

Definition at line 25 of file utf8stringeditor.cpp.

Referenced by fcn::PasswordField::keyPressed(), fcn::TextBox::keyPressed(), and fcn::TextField::keyPressed().


The documentation for this class was generated from the following files: