diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-12-13 02:28:37 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-12-13 02:28:37 -0500 |
commit | db08747aa9c2123a45a948dba4e9b3704b8538b7 (patch) | |
tree | 1f416340227ed7e74e5625fc76906ba713c74880 /util.hpp | |
parent | 93c67bc8684c3daaf7c0e8bf6eb7219f26cbcbdb (diff) | |
download | abaddon-portaudio-db08747aa9c2123a45a948dba4e9b3704b8538b7.tar.gz abaddon-portaudio-db08747aa9c2123a45a948dba4e9b3704b8538b7.zip |
remove unused stuff
Diffstat (limited to 'util.hpp')
-rw-r--r-- | util.hpp | 54 |
1 files changed, 0 insertions, 54 deletions
@@ -180,60 +180,6 @@ inline std::string IntToCSSColor(int color) { return ss.str(); } -// https://www.compuphase.com/cmetric.htm -inline double ColorDistance(int c1, int c2) { - int r1 = (c1 & 0xFF0000) >> 16; - int g1 = (c1 & 0x00FF00) >> 8; - int b1 = (c1 & 0x0000FF) >> 0; - int r2 = (c2 & 0xFF0000) >> 16; - int g2 = (c2 & 0x00FF00) >> 8; - int b2 = (c2 & 0x0000FF) >> 0; - - int rmean = (r1 - r2) / 2; - int r = r1 - r2; - int g = g1 - g2; - int b = b1 - b2; - return sqrt((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8)); -} - -// somehow this works -template<typename F> -std::string RegexReplaceMany(std::string str, std::string regexstr, F func) { - std::regex reg(regexstr, std::regex_constants::ECMAScript); - std::smatch match; - - std::vector<std::tuple<int, int, std::string, int>> matches; - - std::string::const_iterator sstart(str.cbegin()); - while (std::regex_search(sstart, str.cend(), match, reg)) { - const auto start = std::distance(str.cbegin(), sstart) + match.position(); - const auto end = start + match.length(); - matches.push_back(std::make_tuple(static_cast<int>(start), static_cast<int>(end), match[1].str(), static_cast<int>(match.str().size()))); - sstart = match.suffix().first; - } - - int offset = 0; - for (auto it = matches.begin(); it != matches.end(); it++) { - const auto start = std::get<0>(*it); - const auto end = std::get<1>(*it); - const auto match = std::get<2>(*it); - const auto full_match_size = std::get<3>(*it); - const auto replacement = func(match); - const auto diff = full_match_size - replacement.size(); - - str = str.substr(0, start) + replacement + str.substr(end); - - offset += diff; - - if (it + 1 != matches.end()) { - std::get<0>(*(it + 1)) -= offset; - std::get<1>(*(it + 1)) -= offset; - } - } - - return str; -} - inline void AddWidgetMenuHandler(Gtk::Widget *widget, Gtk::Menu &menu) { widget->signal_button_press_event().connect([&menu](GdkEventButton *ev) -> bool { if (ev->type == GDK_BUTTON_PRESS && ev->button == GDK_BUTTON_SECONDARY) { |