35#ifndef TCOD_CONSOLE_PRINTING_HPP_
36#define TCOD_CONSOLE_PRINTING_HPP_
50#ifndef TCOD_NO_UNICODE
74 TCOD_Console& console,
75 const std::array<int, 2>& xy,
77 std::optional<TCOD_ColorRGB> fg,
78 std::optional<TCOD_ColorRGB> bg,
81 const TCOD_ColorRGB* fg_ptr = fg ? &fg.value() :
nullptr;
82 const TCOD_ColorRGB* bg_ptr = bg ? &bg.value() :
nullptr;
84 TCOD_console_printn(&console, xy.at(0), xy.at(1), str.size(), str.data(), fg_ptr, bg_ptr, flag, alignment));
110inline int print_rect(
111 TCOD_Console& console,
112 const std::array<int, 4>& rect,
113 std::string_view str,
114 std::optional<TCOD_ColorRGB> fg,
115 std::optional<TCOD_ColorRGB> bg,
126 fg ? &fg.value() :
nullptr,
127 bg ? &bg.value() :
nullptr,
148inline int get_height_rect(
int width, std::string_view str) {
151TCODLIB_BEGIN_IGNORE_DEPRECATIONS
152[[deprecated(
"It is recommended that you print your own banners for frames.")]]
inline void print_frame(
153 struct TCOD_Console& console,
154 const std::array<int, 4>& rect,
155 std::string_view title,
156 const TCOD_ColorRGB* fg,
157 const TCOD_ColorRGB* bg,
161 &console, rect.at(0), rect.at(1), rect.at(2), rect.at(3), title.size(), title.data(), fg, bg, flag, clear));
163TCODLIB_END_IGNORE_DEPRECATIONS
189template <
typename... T>
190inline std::string stringf(
const char* format, T... args) {
191 const int str_length = snprintf(
nullptr, 0, format, args...);
192 if (str_length < 0)
throw std::runtime_error(
"Failed to format string.");
193 std::string out(str_length,
'\0');
194 snprintf(&out[0], str_length + 1, format, args...);
Console string printing module.
TCOD_alignment_t
Print justification options.
Definition console.h:81
TCOD_bkgnd_flag_t
Background color blend modes.
Definition console.h:60
TCOD_Error TCOD_console_printn(TCOD_Console *console, int x, int y, size_t n, const char *str, const TCOD_ColorRGB *fg, const TCOD_ColorRGB *bg, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment)
Print a string of a specified length to a console.
int TCOD_console_printn_rect(TCOD_Console *console, int x, int y, int width, int height, size_t n, const char *str, const TCOD_ColorRGB *fg, const TCOD_ColorRGB *bg, TCOD_bkgnd_flag_t flag, TCOD_alignment_t alignment)
Print a string of a specified length in a bounding box to a console.
int TCOD_console_get_height_rect_wn(int width, size_t n, const char *str)
Return the height of the word-wrapped text with the given width.
The libtcod namespace.
Definition color.hpp:45
int check_throw_error(int error)
Check and throw error messages.
Definition error.hpp:57