34 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT) 35 #error "Only <final/final.h> can be included directly." 43 #include <unordered_map> 47 #include "final/ftypes.h" 48 #include "final/util/frect.h" 49 #include "final/util/fstring.h" 67 auto getMappedChar (
wchar_t)
const -> wchar_t;
68 void setCharMapping (
const Map&);
69 auto isEmpty()
const -> bool;
73 std::vector<Map> sub_map{};
78 inline auto FCharSubstitution::getMappedChar (
wchar_t c)
const ->
wchar_t 80 const auto& cend = sub_map.cend();
81 auto iter = std::find_if ( sub_map.cbegin(), cend,
82 [&c] (
const auto& map)
94 inline void FCharSubstitution::setCharMapping (
const Map& m)
96 const auto& end = sub_map.end();
97 auto iter = std::find_if ( sub_map.begin(), end,
98 [&m] (
const auto& map)
100 return map.from == m.from;
104 sub_map.push_back(m);
110 inline auto FCharSubstitution::isEmpty()
const ->
bool 112 return sub_map.empty();
116 inline void FCharSubstitution::sort()
118 std::sort ( sub_map.begin(), sub_map.end()
119 , [] (
const auto& lhs,
const auto& rhs)
121 return lhs.from < rhs.from;
141 using EncodingMap = std::unordered_map<std::string, Encoding>;
147 auto getClassName()
const ->
FString;
149 auto getEncodingList() & -> EncodingMap&;
151 auto getTerminalEncoding()
const -> Encoding;
152 auto getTerminalGeometry() & ->
FRect&;
153 auto getTerminalGeometry()
const & ->
const FRect&;
154 auto getTTYFileDescriptor()
const noexcept -> int;
155 auto getBaudrate()
const noexcept -> uInt;
156 auto getTermType()
const & ->
const std::string&;
157 auto getTermFileName()
const & ->
const std::string&;
158 auto getGnomeTerminalID()
const noexcept -> int;
160 auto getXtermFont()
const & ->
const FString&;
161 auto getXtermTitle()
const & ->
const FString&;
163 auto getFramebufferBpp()
const noexcept -> int;
167 auto hasShadowCharacter()
const noexcept -> bool;
168 auto hasHalfBlockCharacter()
const noexcept -> bool;
169 auto hasCursorOptimisation()
const noexcept -> bool;
170 auto isCursorHidden()
const noexcept -> bool;
171 auto hasAlternateScreen()
const noexcept -> bool;
172 auto isInAlternateScreen()
const noexcept -> bool;
173 auto hasASCIIConsole()
const noexcept -> bool;
174 auto hasVT100Console()
const noexcept -> bool;
175 auto hasUTF8Console()
const noexcept -> bool;
176 auto isUTF8()
const noexcept -> bool;
177 auto isNewFont()
const noexcept -> bool;
178 auto isVGAFont()
const noexcept -> bool;
179 auto isMonochron()
const noexcept -> bool;
180 auto hasTermResized() -> bool;
181 auto isTermType (FTermType)
const -> bool;
182 auto isTermType (FTermTypeT)
const -> bool;
185 void setTermEncoding (Encoding) noexcept;
186 void setTTYFileDescriptor (
int) noexcept;
187 void setBaudrate (uInt) noexcept;
188 void supportShadowCharacter (
bool =
true) noexcept;
189 void supportHalfBlockCharacter (
bool =
true) noexcept;
190 void supportCursorOptimisation (
bool =
true) noexcept;
191 void setCursorHidden (
bool =
true) noexcept;
192 void useAlternateScreen (
bool =
true) noexcept;
193 void setAlternateScreenInUse (
bool =
true) noexcept;
194 void setASCIIConsole (
bool =
true) noexcept;
195 void setVT100Console (
bool =
true) noexcept;
196 void setUTF8Console (
bool =
true) noexcept;
197 void setUTF8 (
bool =
true) noexcept;
198 void setNewFont (
bool =
true) noexcept;
199 void setVGAFont (
bool =
true) noexcept;
200 void setMonochron (
bool =
true) noexcept;
201 void setTermResized (
bool =
true);
202 void setTermType (
const std::string&);
203 void setTermType (FTermType);
204 void unsetTermType (FTermType);
205 void setTermFileName (
const std::string&);
206 void setGnomeTerminalID (
int) noexcept;
208 void setXtermFont (
const FString&);
209 void setXtermTitle (
const FString&);
211 void setFramebufferBpp (
int) noexcept;
218 EncodingMap encoding_list{};
220 Encoding term_encoding{Encoding::Unknown};
224 struct TerminalProperties
226 FRect terminal_geometry{};
229 FTermTypeT terminal_type{};
235 struct TerminalSettings
240 int gnome_terminal_id{0};
243 int framebuffer_bpp{-1};
246 std::string termtype{};
247 std::string termfilename{};
251 struct SynchronizationState
253 std::mutex resize_mutex{};
254 std::atomic<int> resize_count{0};
259 bool shadow_character{
true};
260 bool half_block_character{
true};
261 bool cursor_optimisation{
true};
262 bool hidden_cursor{
false};
263 bool use_alternate_screen{
true};
264 bool alternate_screen{
false};
265 bool ascii_console{
false};
266 bool vt100_console{
false};
267 bool utf8_console{
false};
268 bool utf8_state{
false};
269 bool new_font{
false};
270 bool vga_font{
false};
271 bool monochron{
false};
275 EncodingInfo encoding_info{};
276 TerminalProperties terminal_properties{};
277 TerminalSettings terminal_settings{};
278 SynchronizationState synchronization_state{};
284 inline auto FTermData::getClassName()
const ->
FString 285 {
return "FTermData"; }
288 inline auto FTermData::getInstance() ->
FTermData&
290 static const auto& data = std::make_unique<FTermData>();
295 inline auto FTermData::getEncodingList() & -> EncodingMap&
296 {
return encoding_info.encoding_list; }
300 {
return encoding_info.char_substitution_map; }
303 inline auto FTermData::getTerminalEncoding()
const -> Encoding
304 {
return encoding_info.term_encoding; }
307 inline auto FTermData::getTerminalGeometry() & ->
FRect&
308 {
return terminal_properties.terminal_geometry; }
311 inline auto FTermData::getTerminalGeometry()
const & ->
const FRect&
312 {
return terminal_properties.terminal_geometry; }
315 inline auto FTermData::getTTYFileDescriptor()
const noexcept ->
int 316 {
return terminal_properties.fd_tty; }
319 inline auto FTermData::getBaudrate()
const noexcept -> uInt
320 {
return terminal_settings.baudrate; }
323 inline auto FTermData::getTermType()
const & ->
const std::string&
324 {
return terminal_settings.termtype; }
327 inline auto FTermData::getTermFileName()
const & ->
const std::string&
328 {
return terminal_settings.termfilename; }
331 inline auto FTermData::getGnomeTerminalID()
const noexcept ->
int 332 {
return terminal_settings.gnome_terminal_id; }
335 inline auto FTermData::getKittyVersion()
const noexcept ->
kittyVersion 336 {
return terminal_settings.kitty_version; }
339 inline auto FTermData::getXtermFont()
const & ->
const FString&
340 {
return terminal_properties.xterm_font; }
343 inline auto FTermData::getXtermTitle()
const & ->
const FString&
344 {
return terminal_properties.xterm_title; }
348 inline auto FTermData::getFramebufferBpp()
const noexcept ->
int 349 {
return terminal_settings.framebuffer_bpp; }
353 inline auto FTermData::hasShadowCharacter()
const noexcept ->
bool 354 {
return flags.shadow_character; }
357 inline auto FTermData::hasHalfBlockCharacter()
const noexcept ->
bool 358 {
return flags.half_block_character; }
361 inline auto FTermData::hasCursorOptimisation()
const noexcept ->
bool 362 {
return flags.cursor_optimisation; }
365 inline auto FTermData::isCursorHidden()
const noexcept ->
bool 366 {
return flags.hidden_cursor; }
369 inline auto FTermData::hasAlternateScreen()
const noexcept ->
bool 370 {
return flags.use_alternate_screen; }
373 inline auto FTermData::isInAlternateScreen()
const noexcept ->
bool 374 {
return flags.alternate_screen; }
377 inline auto FTermData::hasASCIIConsole()
const noexcept ->
bool 378 {
return flags.ascii_console; }
381 inline auto FTermData::hasVT100Console()
const noexcept ->
bool 382 {
return flags.vt100_console; }
385 inline auto FTermData::hasUTF8Console()
const noexcept ->
bool 386 {
return flags.utf8_console; }
389 inline auto FTermData::isUTF8()
const noexcept ->
bool 390 {
return flags.utf8_state; }
393 inline auto FTermData::isNewFont()
const noexcept ->
bool 394 {
return flags.new_font; }
397 inline auto FTermData::isVGAFont()
const noexcept ->
bool 398 {
return flags.vga_font; }
401 inline auto FTermData::isMonochron()
const noexcept ->
bool 402 {
return flags.monochron; }
405 inline auto FTermData::hasTermResized() ->
bool 407 std::lock_guard<std::mutex> resize_lock_guard(synchronization_state.resize_mutex);
408 return synchronization_state.resize_count.load() > 0;
412 inline auto FTermData::isTermType (FTermType type)
const ->
bool 413 {
return terminal_properties.terminal_type &
static_cast<FTermTypeT
>(type); }
416 inline auto FTermData::isTermType (FTermTypeT mask)
const ->
bool 417 {
return terminal_properties.terminal_type & mask; }
420 inline void FTermData::setTermEncoding (Encoding enc) noexcept
421 { encoding_info.term_encoding = enc; }
424 inline void FTermData::setTTYFileDescriptor (
int fd) noexcept
425 { terminal_properties.fd_tty = fd; }
428 inline void FTermData::setBaudrate (uInt baud) noexcept
429 { terminal_settings.baudrate = baud; }
432 inline void FTermData::supportShadowCharacter (
bool available) noexcept
433 { flags.shadow_character = available; }
436 inline void FTermData::supportHalfBlockCharacter (
bool available) noexcept
437 { flags.half_block_character = available; }
440 inline void FTermData::supportCursorOptimisation (
bool available) noexcept
441 { flags.cursor_optimisation = available; }
444 inline void FTermData::setCursorHidden (
bool hidden_state) noexcept
445 { flags.hidden_cursor = hidden_state; }
448 inline void FTermData::useAlternateScreen (
bool use) noexcept
449 { flags.use_alternate_screen = use; }
452 inline void FTermData::setAlternateScreenInUse (
bool in_use) noexcept
453 { flags.alternate_screen = in_use; }
456 inline void FTermData::setASCIIConsole (
bool ascii) noexcept
457 { flags.ascii_console = ascii; }
460 inline void FTermData::setVT100Console (
bool vt100) noexcept
461 { flags.vt100_console = vt100; }
464 inline void FTermData::setUTF8Console (
bool utf8) noexcept
465 { flags.utf8_console = utf8; }
468 inline void FTermData::setUTF8 (
bool utf8) noexcept
469 { flags.utf8_state = utf8; }
472 inline void FTermData::setNewFont (
bool nfont) noexcept
473 { flags.new_font = nfont; }
476 inline void FTermData::setVGAFont (
bool vga) noexcept
477 { flags.vga_font = vga; }
480 inline void FTermData::setMonochron (
bool mono) noexcept
481 { flags.monochron = mono; }
484 inline void FTermData::setTermResized (
bool resize)
486 std::lock_guard<std::mutex> resize_lock_guard(synchronization_state.resize_mutex);
489 ++synchronization_state.resize_count;
490 else if ( synchronization_state.resize_count.load() > 0 )
491 --synchronization_state.resize_count;
495 inline void FTermData::setTermType (
const std::string& name)
497 if ( ! name.empty() )
498 terminal_settings.termtype = name;
502 inline void FTermData::setTermType (FTermType type)
503 { terminal_properties.terminal_type |=
static_cast<FTermTypeT
>(type); }
506 inline void FTermData::unsetTermType (FTermType type)
507 { terminal_properties.terminal_type &= ~(
static_cast<FTermTypeT
>(type)); }
510 inline void FTermData::setTermFileName (
const std::string& file_name)
512 if ( ! file_name.empty() )
513 terminal_settings.termfilename = file_name;
517 inline void FTermData::setGnomeTerminalID (
int id) noexcept
518 { terminal_settings.gnome_terminal_id = id; }
521 inline void FTermData::setKittyVersion(
const kittyVersion& version)
523 terminal_settings.kitty_version.primary = version.primary;
524 terminal_settings.kitty_version.secondary = version.secondary;
528 inline void FTermData::setXtermFont (
const FString& font)
529 { terminal_properties.xterm_font = font; }
532 inline void FTermData::setXtermTitle (
const FString& title)
533 { terminal_properties.xterm_title = title; }
536 #if DEBUG && defined(__linux__) 537 inline void FTermData::setFramebufferBpp (
int bpp) noexcept
538 { terminal_settings.framebuffer_bpp = bpp; }
543 #endif // FTERMDATA_H Definition: ftermdata.h:61
Definition: ftermdata.h:58
Definition: class_template.cpp:25
Definition: ftermdata.h:134
Definition: ftermdata.h:131