diff options
author | Florent Le Coz <louiz@louiz.org> | 2013-11-09 23:20:12 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2013-11-09 23:20:12 +0100 |
commit | 8acd7a02aeda01c0ac828b05c36f10bbacaea70e (patch) | |
tree | 138a6bea399f540cae828d329ac9c082548746f0 /src/bridge | |
parent | 7c671499350e22f8bfba2f72b9827aa5b200f7b0 (diff) | |
download | biboumi-8acd7a02aeda01c0ac828b05c36f10bbacaea70e.tar.gz biboumi-8acd7a02aeda01c0ac828b05c36f10bbacaea70e.tar.bz2 biboumi-8acd7a02aeda01c0ac828b05c36f10bbacaea70e.tar.xz biboumi-8acd7a02aeda01c0ac828b05c36f10bbacaea70e.zip |
Aaaand, I forgot to add files
Diffstat (limited to 'src/bridge')
-rw-r--r-- | src/bridge/colors.cpp | 20 | ||||
-rw-r--r-- | src/bridge/colors.hpp | 21 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/bridge/colors.cpp b/src/bridge/colors.cpp new file mode 100644 index 0000000..f49f31f --- /dev/null +++ b/src/bridge/colors.cpp @@ -0,0 +1,20 @@ +#include <bridge/colors.hpp> +#include <algorithm> + +#include <iostream> + +void remove_irc_colors(std::string& str) +{ + auto it = std::remove_if(str.begin(), str.end(), + [](const char c) + { + if (c == IRC_COLOR_BOLD_CHAR || c == IRC_COLOR_COLOR_CHAR || + c == IRC_COLOR_FIXED_CHAR || c == IRC_COLOR_RESET_CHAR || + c == IRC_COLOR_REVERSE_CHAR || c == IRC_COLOR_REVERSE2_CHAR || + c == IRC_COLOR_UNDERLINE_CHAR || c == IRC_COLOR_ITALIC_CHAR) + return true; + return false; + } + ); + str.erase(it, str.end()); +} diff --git a/src/bridge/colors.hpp b/src/bridge/colors.hpp new file mode 100644 index 0000000..a4775e1 --- /dev/null +++ b/src/bridge/colors.hpp @@ -0,0 +1,21 @@ +#ifndef COLORS_INCLUDED +# define COLORS_INCLUDED + +#include <string> + +/** + * A module handling the conversion between IRC colors and XHTML-IM, and vice versa. + */ + +#define IRC_COLOR_BOLD_CHAR '\x02' +#define IRC_COLOR_COLOR_CHAR '\x03' +#define IRC_COLOR_RESET_CHAR '\x0F' +#define IRC_COLOR_FIXED_CHAR '\x11' +#define IRC_COLOR_REVERSE_CHAR '\x12' +#define IRC_COLOR_REVERSE2_CHAR '\x16' +#define IRC_COLOR_ITALIC_CHAR '\x1D' +#define IRC_COLOR_UNDERLINE_CHAR '\x1F' + +void remove_irc_colors(std::string& str); + +#endif // COLORS_INCLUDED |