From a105630199bb4be80b3a8228a2c3e5b0c7347625 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 3 Apr 2021 18:51:13 +0200 Subject: Make url parsing better by using a list of valid tlds. Make urls blue in text --- include/NetUtils.hpp | 9 ++++++++- include/Text.hpp | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/NetUtils.hpp b/include/NetUtils.hpp index 4770fb4..e719c82 100644 --- a/include/NetUtils.hpp +++ b/include/NetUtils.hpp @@ -4,8 +4,15 @@ #include namespace QuickMedia { + struct Range { + size_t start; + size_t length; + }; + void html_escape_sequences(std::string &str); void html_unescape_sequences(std::string &str); std::string url_param_encode(const std::string ¶m); - void extract_urls(const std::string &str, std::vector &urls); + std::vector extract_urls(const std::string &str); + std::vector ranges_get_strings(const std::string &str, const std::vector &ranges); + void convert_utf8_to_utf32_ranges(const std::string &str, std::vector &ranges); } \ No newline at end of file diff --git a/include/Text.hpp b/include/Text.hpp index 3981f13..c74607c 100644 --- a/include/Text.hpp +++ b/include/Text.hpp @@ -1,5 +1,6 @@ #pragma once +#include "NetUtils.hpp" #include #include #include @@ -160,5 +161,7 @@ namespace QuickMedia sf::Vector2u renderTargetSize; std::vector vertices_linear; // TODO: Use textElements instead + + std::vector url_ranges; }; } -- cgit v1.2.3