OpenTTD Source 20241224-master-gf74b0cf984
|
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 "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 { 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. | |
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, const std::string &filename) |
Search a textfile file next to the given content. | |
Variables | |
static constexpr NWidgetPart | _nested_textfile_widgets [] |
Widgets for the textfile window. | |
static WindowDesc | _textfile_desc (WDP_CENTER, "textfile", 630, 460, WC_TEXTFILE, WC_NONE, 0, _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 170 of file textfile_gui.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 184 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, | ||
const std::string & | 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 833 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 665 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 204 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 705 of file textfile_gui.cpp.
Referenced by TextfileWindow::LoadTextfile().
|
static |
Regular expression that searches for Markdown links.
Definition at line 167 of file textfile_gui.cpp.
Referenced by TextfileWindow::FindHyperlinksInMarkdown().
|
staticconstexpr |
Widgets for the textfile window.
Definition at line 42 of file textfile_gui.cpp.