FTXUI 7.0.3
C++ functional terminal UI.
Loading...
Searching...
No Matches
terminal.hpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// Use of this source code is governed by the MIT license that can be found in
3// the LICENSE file.
4#ifndef FTXUI_SCREEN_TERMINAL_HPP
5#define FTXUI_SCREEN_TERMINAL_HPP
6
7#include <cstdint>
8
9#include <memory>
10#include <string_view>
11#include <vector>
12
13#include "ftxui/util/export.hpp"
14
15namespace ftxui {
16
17/// @brief Dimensions est une structure qui représente la taille du terminal
18/// @ingroup screen
19struct FTXUI_EXPORT(SCREEN) Dimensions {
20 int dimx;
21 int dimy;
22};
23
24namespace Terminal {
25FTXUI_EXPORT(SCREEN) Dimensions Size();
26FTXUI_EXPORT(SCREEN) void SetFallbackSize(const Dimensions& fallbackSize);
27
28/// @brief Color est une énumération qui représente le support des couleurs
29/// du terminal.
30/// @ingroup screen
37FTXUI_EXPORT(SCREEN) Color ColorSupport();
38FTXUI_EXPORT(SCREEN) void SetColorSupport(Color color);
39
40/// @brief Quirks est une structure qui représente divers comportements spécifiques
41/// au terminal pouvant nécessiter des solutions de repli.
42/// @ingroup screen
43class FTXUI_EXPORT(SCREEN) Quirks {
44 public:
45 Quirks();
46 ~Quirks();
47 Quirks(const Quirks&);
48 Quirks& operator=(const Quirks&);
49 Quirks(Quirks&&) noexcept;
50 Quirks& operator=(Quirks&&) noexcept;
51
52 /// @brief Indique si la police du terminal prend en charge les 8 caractères de bloc Unicode.
53 bool BlockCharacters() const;
54 void SetBlockCharacters(bool v);
55
56 /// @brief Indique si le terminal gère correctement le masquage du curseur.
57 bool CursorHiding() const;
58 void SetCursorHiding(bool v);
59
60 /// @brief Indique si le terminal doit utiliser des caractères ASCII pour les composants.
61 bool ComponentAscii() const;
62 void SetComponentAscii(bool v);
63
64 /// @brief Le niveau de prise en charge des couleurs du terminal.
65 Color ColorSupport() const;
66 void SetColorSupport(Color v);
67
68 private:
69 struct Impl;
70 std::unique_ptr<Impl> impl_;
71};
72FTXUI_EXPORT(SCREEN) Quirks GetQuirks();
73FTXUI_EXPORT(SCREEN) void SetQuirks(const Quirks& quirks);
74
75/// @brief TerminalInfo est une structure qui contient des informations sur le
76/// terminal.
77/// @ingroup screen
78class FTXUI_EXPORT(SCREEN) TerminalInfo {
79 public:
80 TerminalInfo();
81 ~TerminalInfo();
82 TerminalInfo(const TerminalInfo&) = delete;
83 TerminalInfo& operator=(const TerminalInfo&) = delete;
84 TerminalInfo(TerminalInfo&&) noexcept;
85 TerminalInfo& operator=(TerminalInfo&&) noexcept;
86
87 void SetTerm(std::string_view term);
88 void SetColorterm(std::string_view colorterm);
89 void SetTermProgram(std::string_view term_program);
90 void SetTerminalName(std::string_view terminal_name);
91 void SetTerminalEmulatorName(std::string_view terminal_emulator_name);
92 void SetCapabilities(std::vector<int> capabilities);
93
94 Color ComputeColorSupport() const;
95
96 private:
97 struct Impl;
98 std::unique_ptr<Impl> impl_;
99};
100
101/// @brief Calcule la prise en charge des couleurs en fonction des variables d'environnement et de
102/// l'identification du terminal.
103/// @param term La variable d'environnement TERM.
104/// @param colorterm La variable d'environnement COLORTERM.
105/// @param term_program La variable d'environnement TERM_PROGRAM.
106/// @param terminal_name Le nom du terminal (depuis DA2).
107/// @param terminal_emulator_name Le nom de l'émulateur de terminal (depuis XTVERSION).
108/// @param capabilities Les capacités du terminal (depuis DA1).
109FTXUI_EXPORT(SCREEN)
110Color ComputeColorSupport(std::string_view term,
111 std::string_view colorterm,
112 std::string_view term_program,
113 std::string_view terminal_name,
114 std::string_view terminal_emulator_name,
115 const std::vector<int>& capabilities);
116
117} // namespace Terminal
118
119} // namespace ftxui
120
121#endif // FTXUI_SCREEN_TERMINAL_HPP
#define FTXUI_EXPORT(component)
Definition export.hpp:24
Color
Color est une énumération qui représente le support des couleurs du terminal.
Definition terminal.hpp:31
L'espace de noms ftxui::Terminal:: de FTXUI.
L'espace de noms FTXUI ftxui::
Definition animation.hpp:11