1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Add button_url[] and hypertext element to allow mods to open web pages (#13825)

Fixes #12500
This commit is contained in:
rubenwardy 2024-03-24 17:19:23 +00:00 committed by GitHub
parent 6c4a110679
commit 24cc33e704
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 530 additions and 37 deletions

View file

@ -512,7 +512,7 @@ inline bool string_allowed_blacklist(std::string_view str,
* Create a string based on \p from where a newline is forcefully inserted
* every \p row_len characters.
*
* @note This function does not honour word wraps and blindy inserts a newline
* @note This function does not honour word wraps and blindly inserts a newline
* every \p row_len characters whether it breaks a word or not. It is
* intended to be used for, for example, showing paths in the GUI.
*
@ -521,26 +521,10 @@ inline bool string_allowed_blacklist(std::string_view str,
*
* @param from The (utf-8) string to be wrapped into rows.
* @param row_len The row length (in characters).
* @param has_color_codes Whether the source string has colorize codes.
* @return A new string with the wrapping applied.
*/
inline std::string wrap_rows(std::string_view from, unsigned row_len)
{
std::string to;
to.reserve(from.size());
unsigned character_idx = 0;
for (size_t i = 0; i < from.size(); i++) {
if (!IS_UTF8_MULTB_INNER(from[i])) {
// Wrap string after last inner byte of char
if (character_idx > 0 && character_idx % row_len == 0)
to += '\n';
character_idx++;
}
to += from[i];
}
return to;
}
std::string wrap_rows(std::string_view from, unsigned row_len, bool has_color_codes = false);
/**