godot/scene/gui/rich_text_label.cpp

/**************************************************************************/
/*  rich_text_label.cpp                                                   */
/**************************************************************************/
/*                         This file is part of:                          */
/*                             GODOT ENGINE                               */
/*                        https://godotengine.org                         */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */
/*                                                                        */
/* Permission is hereby granted, free of charge, to any person obtaining  */
/* a copy of this software and associated documentation files (the        */
/* "Software"), to deal in the Software without restriction, including    */
/* without limitation the rights to use, copy, modify, merge, publish,    */
/* distribute, sublicense, and/or sell copies of the Software, and to     */
/* permit persons to whom the Software is furnished to do so, subject to  */
/* the following conditions:                                              */
/*                                                                        */
/* The above copyright notice and this permission notice shall be         */
/* included in all copies or substantial portions of the Software.        */
/*                                                                        */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
/**************************************************************************/

#include "rich_text_label.h"
#include "rich_text_label.compat.inc"

#include "core/input/input_map.h"
#include "core/math/math_defs.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/string/translation.h"
#include "scene/gui/label.h"
#include "scene/gui/rich_text_effect.h"
#include "scene/resources/atlas_texture.h"
#include "scene/theme/theme_db.h"
#include "servers/display_server.h"

#include "modules/modules_enabled.gen.h" // For regex.
#ifdef MODULE_REGEX_ENABLED
#include "modules/regex/regex.h"
#endif

RichTextLabel::ItemCustomFX::ItemCustomFX() {}

RichTextLabel::ItemCustomFX::~ItemCustomFX() {}

RichTextLabel::Item *RichTextLabel::_get_next_item(Item *p_item, bool p_free) const {}

RichTextLabel::Item *RichTextLabel::_get_prev_item(Item *p_item, bool p_free) const {}

Rect2 RichTextLabel::_get_text_rect() {}

RichTextLabel::Item *RichTextLabel::_get_item_at_pos(RichTextLabel::Item *p_item_from, RichTextLabel::Item *p_item_to, int p_position) {}

String RichTextLabel::_roman(int p_num, bool p_capitalize) const {}

String RichTextLabel::_letters(int p_num, bool p_capitalize) const {}

String RichTextLabel::_get_prefix(Item *p_item, const Vector<int> &p_list_index, const Vector<ItemList *> &p_list_items) {}

void RichTextLabel::_update_line_font(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size) {}

float RichTextLabel::_resize_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width, float p_h) {}

float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width, float p_h, int *r_char_offset) {}

void RichTextLabel::_set_table_size(ItemTable *p_table, int p_available_width) {}

int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, float p_vsep, const Color &p_base_color, int p_outline_size, const Color &p_outline_color, const Color &p_font_shadow_color, int p_shadow_outline_size, const Point2 &p_shadow_ofs, int &r_processed_glyphs) {}

void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, ItemFrame **r_click_frame, int *r_click_line, Item **r_click_item, int *r_click_char, bool *r_outside, bool p_meta) {}

float RichTextLabel::_find_click_in_line(ItemFrame *p_frame, int p_line, const Vector2 &p_ofs, int p_width, float p_vsep, const Point2i &p_click, ItemFrame **r_click_frame, int *r_click_line, Item **r_click_item, int *r_click_char, bool p_table, bool p_meta) {}

void RichTextLabel::_scroll_changed(double) {}

void RichTextLabel::_update_fx(RichTextLabel::ItemFrame *p_frame, double p_delta_time) {}

int RichTextLabel::_find_first_line(int p_from, int p_to, int p_vofs) const {}

_FORCE_INLINE_ float RichTextLabel::_calculate_line_vertical_offset(const RichTextLabel::Line &line) const {}

void RichTextLabel::_update_theme_item_cache() {}

void RichTextLabel::_notification(int p_what) {}

Control::CursorShape RichTextLabel::get_cursor_shape(const Point2 &p_pos) const {}

void RichTextLabel::gui_input(const Ref<InputEvent> &p_event) {}

String RichTextLabel::get_tooltip(const Point2 &p_pos) const {}

void RichTextLabel::_find_frame(Item *p_item, ItemFrame **r_frame, int *r_line) {}

RichTextLabel::Item *RichTextLabel::_find_indentable(Item *p_item) {}

RichTextLabel::ItemFont *RichTextLabel::_find_font(Item *p_item) {}

RichTextLabel::ItemFontSize *RichTextLabel::_find_font_size(Item *p_item) {}

int RichTextLabel::_find_outline_size(Item *p_item, int p_default) {}

RichTextLabel::ItemDropcap *RichTextLabel::_find_dc_item(Item *p_item) {}

RichTextLabel::ItemList *RichTextLabel::_find_list_item(Item *p_item) {}

int RichTextLabel::_find_list(Item *p_item, Vector<int> &r_index, Vector<int> &r_count, Vector<ItemList *> &r_list) {}

int RichTextLabel::_find_margin(Item *p_item, const Ref<Font> &p_base_font, int p_base_font_size) {}

BitField<TextServer::JustificationFlag> RichTextLabel::_find_jst_flags(Item *p_item) {}

PackedFloat32Array RichTextLabel::_find_tab_stops(Item *p_item) {}

HorizontalAlignment RichTextLabel::_find_alignment(Item *p_item) {}

TextServer::Direction RichTextLabel::_find_direction(Item *p_item) {}

TextServer::StructuredTextParser RichTextLabel::_find_stt(Item *p_item) {}

String RichTextLabel::_find_language(Item *p_item) {}

Color RichTextLabel::_find_color(Item *p_item, const Color &p_default_color) {}

Color RichTextLabel::_find_outline_color(Item *p_item, const Color &p_default_color) {}

bool RichTextLabel::_find_underline(Item *p_item) {}

bool RichTextLabel::_find_strikethrough(Item *p_item) {}

void RichTextLabel::_fetch_item_fx_stack(Item *p_item, Vector<ItemFX *> &r_stack) {}

void RichTextLabel::_normalize_subtags(Vector<String> &subtags) {}

bool RichTextLabel::_find_meta(Item *p_item, Variant *r_meta, ItemMeta **r_item) {}

bool RichTextLabel::_find_hint(Item *p_item, String *r_description) {}

Color RichTextLabel::_find_bgcolor(Item *p_item) {}

Color RichTextLabel::_find_fgcolor(Item *p_item) {}

bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) {}

void RichTextLabel::_thread_function(void *p_userdata) {}

void RichTextLabel::_thread_end() {}

void RichTextLabel::_stop_thread() {}

int RichTextLabel::get_pending_paragraphs() const {}

bool RichTextLabel::is_finished() const {}

bool RichTextLabel::is_updating() const {}

void RichTextLabel::set_threaded(bool p_threaded) {}

bool RichTextLabel::is_threaded() const {}

void RichTextLabel::set_progress_bar_delay(int p_delay_ms) {}

int RichTextLabel::get_progress_bar_delay() const {}

_FORCE_INLINE_ float RichTextLabel::_update_scroll_exceeds(float p_total_height, float p_ctrl_height, float p_width, int p_idx, float p_old_scroll, float p_text_rect_height) {}

bool RichTextLabel::_validate_line_caches() {}

void RichTextLabel::_process_line_caches() {}

void RichTextLabel::_invalidate_current_line(ItemFrame *p_frame) {}

void RichTextLabel::_texture_changed(RID p_item) {}

void RichTextLabel::add_text(const String &p_text) {}

void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline) {}

Size2 RichTextLabel::_get_image_size(const Ref<Texture2D> &p_image, int p_width, int p_height, const Rect2 &p_region) {}

void RichTextLabel::add_image(const Ref<Texture2D> &p_image, int p_width, int p_height, const Color &p_color, InlineAlignment p_alignment, const Rect2 &p_region, const Variant &p_key, bool p_pad, const String &p_tooltip, bool p_size_in_percent) {}

void RichTextLabel::update_image(const Variant &p_key, BitField<ImageUpdateMask> p_mask, const Ref<Texture2D> &p_image, int p_width, int p_height, const Color &p_color, InlineAlignment p_alignment, const Rect2 &p_region, bool p_pad, const String &p_tooltip, bool p_size_in_percent) {}

void RichTextLabel::add_newline() {}

void RichTextLabel::_remove_frame(HashSet<Item *> &r_erase_list, ItemFrame *p_frame, int p_line, bool p_erase, int p_char_offset, int p_line_offset) {}

bool RichTextLabel::remove_paragraph(int p_paragraph, bool p_no_invalidate) {}

bool RichTextLabel::invalidate_paragraph(int p_paragraph) {}

void RichTextLabel::push_dropcap(const String &p_string, const Ref<Font> &p_font, int p_size, const Rect2 &p_dropcap_margins, const Color &p_color, int p_ol_size, const Color &p_ol_color) {}

void RichTextLabel::_push_def_font_var(DefaultFont p_def_font, const Ref<Font> &p_font, int p_size) {}

void RichTextLabel::_push_def_font(DefaultFont p_def_font) {}

void RichTextLabel::push_font(const Ref<Font> &p_font, int p_size) {}

void RichTextLabel::push_normal() {}

void RichTextLabel::push_bold() {}

void RichTextLabel::push_bold_italics() {}

void RichTextLabel::push_italics() {}

void RichTextLabel::push_mono() {}

void RichTextLabel::push_font_size(int p_font_size) {}

void RichTextLabel::push_outline_size(int p_ol_size) {}

void RichTextLabel::push_color(const Color &p_color) {}

void RichTextLabel::push_outline_color(const Color &p_color) {}

void RichTextLabel::push_underline() {}

void RichTextLabel::push_strikethrough() {}

void RichTextLabel::push_paragraph(HorizontalAlignment p_alignment, Control::TextDirection p_direction, const String &p_language, TextServer::StructuredTextParser p_st_parser, BitField<TextServer::JustificationFlag> p_jst_flags, const PackedFloat32Array &p_tab_stops) {}

void RichTextLabel::push_indent(int p_level) {}

void RichTextLabel::push_list(int p_level, ListType p_list, bool p_capitalize, const String &p_bullet) {}

void RichTextLabel::push_meta(const Variant &p_meta, MetaUnderline p_underline_mode, const String &p_tooltip) {}

void RichTextLabel::push_language(const String &p_language) {}

void RichTextLabel::push_hint(const String &p_string) {}

void RichTextLabel::push_table(int p_columns, InlineAlignment p_alignment, int p_align_to_row) {}

void RichTextLabel::push_fade(int p_start_index, int p_length) {}

void RichTextLabel::push_shake(int p_strength = 10, float p_rate = 24.0f, bool p_connected = true) {}

void RichTextLabel::push_wave(float p_frequency = 1.0f, float p_amplitude = 10.0f, bool p_connected = true) {}

void RichTextLabel::push_tornado(float p_frequency = 1.0f, float p_radius = 10.0f, bool p_connected = true) {}

void RichTextLabel::push_rainbow(float p_saturation, float p_value, float p_frequency) {}

void RichTextLabel::push_pulse(const Color &p_color, float p_frequency, float p_ease) {}

void RichTextLabel::push_bgcolor(const Color &p_color) {}

void RichTextLabel::push_fgcolor(const Color &p_color) {}

void RichTextLabel::push_customfx(Ref<RichTextEffect> p_custom_effect, Dictionary p_environment) {}

void RichTextLabel::push_context() {}

void RichTextLabel::set_table_column_expand(int p_column, bool p_expand, int p_ratio) {}

void RichTextLabel::set_cell_row_background_color(const Color &p_odd_row_bg, const Color &p_even_row_bg) {}

void RichTextLabel::set_cell_border_color(const Color &p_color) {}

void RichTextLabel::set_cell_size_override(const Size2 &p_min_size, const Size2 &p_max_size) {}

void RichTextLabel::set_cell_padding(const Rect2 &p_padding) {}

void RichTextLabel::push_cell() {}

int RichTextLabel::get_current_table_column() const {}

void RichTextLabel::pop() {}

void RichTextLabel::pop_context() {}

void RichTextLabel::pop_all() {}

void RichTextLabel::clear() {}

void RichTextLabel::set_tab_size(int p_spaces) {}

int RichTextLabel::get_tab_size() const {}

void RichTextLabel::set_fit_content(bool p_enabled) {}

bool RichTextLabel::is_fit_content_enabled() const {}

void RichTextLabel::set_meta_underline(bool p_underline) {}

bool RichTextLabel::is_meta_underlined() const {}

void RichTextLabel::set_hint_underline(bool p_underline) {}

bool RichTextLabel::is_hint_underlined() const {}

void RichTextLabel::set_offset(int p_pixel) {}

void RichTextLabel::set_scroll_active(bool p_active) {}

bool RichTextLabel::is_scroll_active() const {}

void RichTextLabel::set_scroll_follow(bool p_follow) {}

bool RichTextLabel::is_scroll_following() const {}

void RichTextLabel::parse_bbcode(const String &p_bbcode) {}

String RichTextLabel::_get_tag_value(const String &p_tag) {}

int RichTextLabel::_find_unquoted(const String &p_src, char32_t p_chr, int p_from) {}

Vector<String> RichTextLabel::_split_unquoted(const String &p_src, char32_t p_splitter) {}

void RichTextLabel::append_text(const String &p_bbcode) {}

void RichTextLabel::scroll_to_selection() {}

void RichTextLabel::scroll_to_paragraph(int p_paragraph) {}

int RichTextLabel::get_paragraph_count() const {}

int RichTextLabel::get_visible_paragraph_count() const {}

void RichTextLabel::scroll_to_line(int p_line) {}

float RichTextLabel::get_line_offset(int p_line) {}

float RichTextLabel::get_paragraph_offset(int p_paragraph) {}

int RichTextLabel::get_line_count() const {}

int RichTextLabel::get_visible_line_count() const {}

void RichTextLabel::set_selection_enabled(bool p_enabled) {}

void RichTextLabel::set_deselect_on_focus_loss_enabled(const bool p_enabled) {}

Variant RichTextLabel::get_drag_data(const Point2 &p_point) {}

bool RichTextLabel::_is_click_inside_selection() const {}

bool RichTextLabel::_search_table(ItemTable *p_table, List<Item *>::Element *p_from, const String &p_string, bool p_reverse_search) {}

bool RichTextLabel::_search_line(ItemFrame *p_frame, int p_line, const String &p_string, int p_char_idx, bool p_reverse_search) {}

bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p_search_previous) {}

String RichTextLabel::_get_line_text(ItemFrame *p_frame, int p_line, Selection p_selection) const {}

void RichTextLabel::set_context_menu_enabled(bool p_enabled) {}

bool RichTextLabel::is_context_menu_enabled() const {}

void RichTextLabel::set_shortcut_keys_enabled(bool p_enabled) {}

bool RichTextLabel::is_shortcut_keys_enabled() const {}

// Context menu.
PopupMenu *RichTextLabel::get_menu() const {}

bool RichTextLabel::is_menu_visible() const {}

String RichTextLabel::get_selected_text() const {}

void RichTextLabel::deselect() {}

void RichTextLabel::selection_copy() {}

void RichTextLabel::select_all() {}

bool RichTextLabel::is_selection_enabled() const {}

bool RichTextLabel::is_deselect_on_focus_loss_enabled() const {}

void RichTextLabel::set_drag_and_drop_selection_enabled(const bool p_enabled) {}

bool RichTextLabel::is_drag_and_drop_selection_enabled() const {}

int RichTextLabel::get_selection_from() const {}

int RichTextLabel::get_selection_to() const {}

void RichTextLabel::set_text(const String &p_bbcode) {}

void RichTextLabel::_apply_translation() {}

String RichTextLabel::get_text() const {}

void RichTextLabel::set_use_bbcode(bool p_enable) {}

bool RichTextLabel::is_using_bbcode() const {}

String RichTextLabel::get_parsed_text() const {}

void RichTextLabel::set_text_direction(Control::TextDirection p_text_direction) {}

Control::TextDirection RichTextLabel::get_text_direction() const {}

void RichTextLabel::set_horizontal_alignment(HorizontalAlignment p_alignment) {}

HorizontalAlignment RichTextLabel::get_horizontal_alignment() const {}

void RichTextLabel::set_vertical_alignment(VerticalAlignment p_alignment) {}

VerticalAlignment RichTextLabel::get_vertical_alignment() const {}

void RichTextLabel::set_justification_flags(BitField<TextServer::JustificationFlag> p_flags) {}

BitField<TextServer::JustificationFlag> RichTextLabel::get_justification_flags() const {}

void RichTextLabel::set_tab_stops(const PackedFloat32Array &p_tab_stops) {}

PackedFloat32Array RichTextLabel::get_tab_stops() const {}

void RichTextLabel::set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser) {}

TextServer::StructuredTextParser RichTextLabel::get_structured_text_bidi_override() const {}

void RichTextLabel::set_structured_text_bidi_override_options(Array p_args) {}

Array RichTextLabel::get_structured_text_bidi_override_options() const {}

void RichTextLabel::set_language(const String &p_language) {}

String RichTextLabel::get_language() const {}

void RichTextLabel::set_autowrap_mode(TextServer::AutowrapMode p_mode) {}

TextServer::AutowrapMode RichTextLabel::get_autowrap_mode() const {}

void RichTextLabel::set_visible_ratio(float p_ratio) {}

float RichTextLabel::get_visible_ratio() const {}

void RichTextLabel::set_effects(Array p_effects) {}

Array RichTextLabel::get_effects() {}

void RichTextLabel::install_effect(const Variant effect) {}

int RichTextLabel::get_content_height() const {}

int RichTextLabel::get_content_width() const {}

#ifndef DISABLE_DEPRECATED
// People will be very angry, if their texts get erased, because of #39148. (3.x -> 4.0)
// Although some people may not used bbcode_text, so we only overwrite, if bbcode_text is not empty.
bool RichTextLabel::_set(const StringName &p_name, const Variant &p_value) {}
#endif

void RichTextLabel::_bind_methods() {}

TextServer::VisibleCharactersBehavior RichTextLabel::get_visible_characters_behavior() const {}

void RichTextLabel::set_visible_characters_behavior(TextServer::VisibleCharactersBehavior p_behavior) {}

void RichTextLabel::set_visible_characters(int p_visible) {}

int RichTextLabel::get_visible_characters() const {}

int RichTextLabel::get_character_line(int p_char) {}

int RichTextLabel::get_character_paragraph(int p_char) {}

int RichTextLabel::get_total_character_count() const {}

int RichTextLabel::get_total_glyph_count() const {}

Size2 RichTextLabel::get_minimum_size() const {}

// Context menu.
void RichTextLabel::_generate_context_menu() {}

void RichTextLabel::_update_context_menu() {}

Key RichTextLabel::_get_menu_action_accelerator(const String &p_action) {}

void RichTextLabel::menu_option(int p_option) {}

Ref<RichTextEffect> RichTextLabel::_get_custom_effect_by_code(String p_bbcode_identifier) {}

Dictionary RichTextLabel::parse_expressions_for_values(Vector<String> p_expressions) {}

RichTextLabel::RichTextLabel(const String &p_text) {}

RichTextLabel::~RichTextLabel() {}