|
OpenTTD Source 20251117-master-g7398d2e290
|
Implementation of textfile window. More...
#include "stdafx.h"#include "core/backup_type.hpp"#include "fileio_func.h"#include "fontcache.h"#include "gfx_type.h"#include "gfx_func.h"#include "string_func.h"#include "core/string_builder.hpp"#include "textfile_gui.h"#include "dropdown_type.h"#include "dropdown_func.h"#include "gfx_layout.h"#include "debug.h"#include "openttd.h"#include "widgets/misc_widget.h"#include "table/strings.h"#include "table/control_codes.h"#include <zlib.h>#include <lzma.h>#include <regex>#include "safeguards.h"Go to the source code of this file.
Enumerations | |
| enum class | HyperlinkType : uint8_t { Internal , Web , File , Unknown } |
| Types of link we support in markdown files. More... | |
Functions | |
| static HyperlinkType | ClassifyHyperlink (const std::string &destination, bool trusted) |
| Classify the type of hyperlink the destination describes. | |
| static std::string | MakeAnchorSlug (const std::string &line) |
| Create a valid slug for the anchor. | |
| bool | CanContinueRealtimeTick () |
| static std::vector< char > | Gunzip (std::span< char > input) |
| Do an in-memory gunzip operation. | |
| static std::vector< char > | Xunzip (std::span< char > input) |
| Do an in-memory xunzip operation. | |
| std::optional< std::string > | GetTextfile (TextfileType type, Subdirectory dir, std::string_view filename) |
| Search a textfile file next to the given content. | |
Variables | |
| static constexpr std::initializer_list< NWidgetPart > | _nested_textfile_widgets |
| Widgets for the textfile window. | |
| static WindowDesc | _textfile_desc (WDP_CENTER, "textfile", 630, 460, WC_TEXTFILE, WC_NONE, {}, _nested_textfile_widgets) |
| Window definition for the textfile window. | |
| static const std::regex | _markdown_link_regex {"\\[(.+?)\\]\\((.+?)\\)", std::regex_constants::ECMAScript | std::regex_constants::optimize} |
| Regular expression that searches for Markdown links. | |
Implementation of textfile window.
Definition in file textfile_gui.cpp.
|
strong |
Types of link we support in markdown files.
| Enumerator | |
|---|---|
| Internal | Internal link, or "anchor" in HTML language. |
| Web | Link to an external website. |
| File | Link to a local file. |
| Unknown | Unknown link. |
Definition at line 151 of file textfile_gui.cpp.
|
extern |
Definition at line 3076 of file window.cpp.
|
static |
Classify the type of hyperlink the destination describes.
| destination | The hyperlink destination. |
| trusted | Whether we trust the content of this file. |
Definition at line 165 of file textfile_gui.cpp.
References File, Internal, Unknown, and Web.
Referenced by TextfileWindow::FindHyperlinksInMarkdown(), and TextfileWindow::OnHyperlinkClick().
| std::optional< std::string > GetTextfile | ( | TextfileType | type, |
| Subdirectory | dir, | ||
| std::string_view | filename | ||
| ) |
Search a textfile file next to the given content.
| type | The type of the textfile to search for. |
| dir | The subdirectory to search in. |
| filename | The filename of the content to look for. |
nullptr otherwise. Definition at line 939 of file textfile_gui.cpp.
References FioCheckFileExists(), GetCurrentLanguageIsoCode(), and lengthof.
Referenced by GameOptionsWindow::OnInvalidateData().
|
static |
Do an in-memory gunzip operation.
This works on a raw deflate stream, or a file with gzip or zlib header.
| input | Buffer containing the input data. |
When decompressing fails, an empty buffer is returned.
Definition at line 780 of file textfile_gui.cpp.
Referenced by TextfileWindow::LoadTextfile().
|
static |
Create a valid slug for the anchor.
| line | The line to create the slug for. |
Definition at line 185 of file textfile_gui.cpp.
Referenced by TextfileWindow::AfterLoadMarkdown().
|
static |
Do an in-memory xunzip operation.
This works on a .xz or (legacy) .lzma file.
| input | Buffer containing the input data. |
When decompressing fails, an empty buffer is returned.
Definition at line 819 of file textfile_gui.cpp.
Referenced by TextfileWindow::LoadTextfile().
|
static |
Regular expression that searches for Markdown links.
Definition at line 148 of file textfile_gui.cpp.
Referenced by TextfileWindow::FindHyperlinksInMarkdown().
|
staticconstexpr |
Widgets for the textfile window.
Definition at line 43 of file textfile_gui.cpp.