remove unused stuff

This commit is contained in:
ouwou
2020-12-13 02:28:37 -05:00
parent 93c67bc868
commit db08747aa9

View File

@@ -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) {