FTXUI 7.0.3
C++ functional terminal UI.
Loading...
Searching...
No Matches
screen.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_SCREEN_HPP
5#define FTXUI_SCREEN_SCREEN_HPP
6
7#include <cstdint> // for uint8_t
8#include <functional> // for function
9#include <string> // for string, basic_string, allocator
10#include <vector> // for vector
11
12#include "ftxui/screen/surface.hpp" // for Surface
13#include "ftxui/screen/terminal.hpp" // for Dimensions
14#include "ftxui/util/export.hpp" // for FTXUI_EXPORT
15
16namespace ftxui {
17
18/// @brief スクリーンがどのように見えるべきかを定義します。
19/// @ingroup screen
20namespace Dimension {
21FTXUI_EXPORT(SCREEN) Dimensions Fixed(int);
22FTXUI_EXPORT(SCREEN) Dimensions Full();
23} // namespace Dimension
24
25/// @brief Cellの長方形グリッド。
26/// @ingroup screen
27class FTXUI_EXPORT(SCREEN) Screen : public Surface {
28 public:
29 // コンストラクタ:
30 Screen(int dimx, int dimy);
31 static Screen Create(Dimensions dimension);
32 static Screen Create(Dimensions width, Dimensions height);
33
34 // デストラクタ:
35 ~Screen() override = default;
36
37 // コピー:
38 Screen(const Screen&) = default;
39 Screen& operator=(const Screen&) = default;
40
41 std::string ToString() const;
42 void ToString(std::string& ss) const;
43
44 // Screenをターミナルに出力します。
45 void Print() const;
46
47 // 画面をスペースで埋め、ハイパーリンクやカーソルなどの画面状態を
48 // リセットします。
49 void Clear();
50
51 // ターミナルカーソルをn行上に移動します。n = dimy()です。
52 std::string ResetPosition(bool clear = false) const;
53 void ResetPosition(std::string& ss, bool clear = false) const;
54
55 void ApplyShader();
56
57 struct Cursor {
58 int x = 0;
59 int y = 0;
60
61 enum Shape : uint8_t {
62 Hidden = 0,
63 BlockBlinking = 1,
64 Block = 2,
65 UnderlineBlinking = 3,
66 Underline = 4,
67 BarBlinking = 5,
68 Bar = 6,
69 };
70 Shape shape = Hidden;
71 };
72
73 Cursor cursor() const { return cursor_; }
74 void SetCursor(Cursor cursor) { cursor_ = cursor; }
75
76 // ABI予約:
77 void Reserved1() override;
78 void Reserved2() override;
79 void Reserved3() override;
80 void Reserved4() override;
81 void Reserved5() override;
82 void Reserved6() override;
83 void Reserved7() override;
84 void Reserved8() override;
85
86 // スクリーンにハイパーリンクを保存します。ハイパーリンクのIDを返します。このIDは、ユーザーがクリックしたときにハイパーリンクを識別するために使用されます。
87 uint8_t RegisterHyperlink(std::string_view link);
88 const std::string& Hyperlink(uint8_t id) const;
89
90 using SelectionStyle = std::function<void(Cell&)>;
91 const SelectionStyle& GetSelectionStyle() const;
92 void SetSelectionStyle(SelectionStyle decorator);
93
94 protected:
95 Cursor cursor_;
96 std::vector<std::string> hyperlinks_ = {""};
97
98 // 現在の選択スタイル。これは様々なDOM要素によって上書きされます。
99 SelectionStyle selection_style_ = [](Cell& cell) { cell.inverted ^= true; };
100};
101
102} // namespace ftxui
103
104#endif // FTXUI_SCREEN_SCREEN_HPP
#define FTXUI_EXPORT(component)
Definition export.hpp:25
FTXUI ftxui::Dimension::名前空間
FTXUI ftxui::名前空間
Definition animation.hpp:11
int y
Definition elements.hpp:131