Move rich text escape methods to helper .h .cpp files
This commit is contained in:
@ -81,6 +81,7 @@ set(sources
|
||||
src/screenmanager.cpp
|
||||
src/splitgraphdisplay.cpp
|
||||
src/popupdisplay.cpp
|
||||
src/richtexthelper.cpp
|
||||
src/richtextrenderer.cpp
|
||||
src/icons/back.cpp
|
||||
src/icons/checked.cpp
|
||||
|
18
src/richtexthelper.cpp
Normal file
18
src/richtexthelper.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "richtexthelper.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <strutils.h>
|
||||
|
||||
namespace espgui {
|
||||
|
||||
void richTextEscape(std::string &subject)
|
||||
{
|
||||
cpputils::stringReplaceAll('&', "&&", subject);
|
||||
}
|
||||
|
||||
std::string richTextEscape(std::string_view subject)
|
||||
{
|
||||
return cpputils::stringReplaceAll('&', "&&", subject);
|
||||
}
|
||||
|
||||
} // namespace espgui
|
@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
// system includes
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace espgui {
|
||||
namespace colors {
|
||||
constexpr char RED[] = "&1"; // #ff0000 (TFT_RED)
|
||||
@ -17,4 +21,8 @@ constexpr char SMALL[] = "&s"; // tft.setTextFont(2)
|
||||
constexpr char MEDIUM[] = "&m"; // tft.setTextFont(4)
|
||||
constexpr char RESTORE[] = "&f"; // restore original font
|
||||
} // namespace fonts
|
||||
|
||||
void richTextEscape(std::string &subject);
|
||||
std::string richTextEscape(std::string_view subject);
|
||||
|
||||
} // namespace espgui
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <string_view>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <strutils.h>
|
||||
#include <fontrenderer.h>
|
||||
|
||||
// local includes
|
||||
@ -13,16 +12,6 @@
|
||||
|
||||
namespace espgui {
|
||||
|
||||
void richTextEscape(std::string &subject)
|
||||
{
|
||||
cpputils::stringReplaceAll('&', "&&", subject);
|
||||
}
|
||||
|
||||
std::string richTextEscape(std::string_view subject)
|
||||
{
|
||||
return cpputils::stringReplaceAll('&', "&&", subject);
|
||||
}
|
||||
|
||||
int16_t renderRichText(TftInterface &tft, std::string_view str, int32_t poX, int32_t poY, uint16_t color, uint16_t bgcolor, uint8_t font)
|
||||
{
|
||||
FontRenderer fontRenderer{tft};
|
||||
|
@ -9,9 +9,6 @@ namespace espgui { class TftInterface; class FontRenderer; }
|
||||
|
||||
namespace espgui {
|
||||
|
||||
void richTextEscape(std::string &subject);
|
||||
std::string richTextEscape(std::string_view subject);
|
||||
|
||||
int16_t renderRichText(TftInterface &tft, std::string_view str, int32_t poX, int32_t poY, uint16_t color, uint16_t bgcolor, uint8_t font);
|
||||
int16_t renderRichText(TftInterface &tft, FontRenderer &fontRenderer, std::string_view str, int32_t poX, int32_t poY, uint16_t color, uint16_t bgcolor, uint8_t font);
|
||||
|
||||
|
Reference in New Issue
Block a user