-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.cppm
More file actions
43 lines (35 loc) · 1.46 KB
/
App.cppm
File metadata and controls
43 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// This project is licensed under the GPL-3.0 License. See the LICENSE file for details, or check out <gnu.org>.
// Copyright (C) 2026 mxreal64
// 1. Global Module Fragments for External C Type Definitions
module;
#include <SDL3/SDL.h>
#include <SDL3_ttf/SDL_ttf.h>
// 2. Primary Module Interface Exports Layer
export module delta.app;
// Combine and expose sub-module partitions seamlessly to the outside world
export import :buffer;
export import :events;
import delta.types;
import delta.engine;
import std;
export class DeltaApp {
private:
DocumentBuffer doc_;
EventController controller_;
std::vector<LayoutLine> current_layout_;
selection_span sel_;
bool running_ = true;
public:
DeltaApp() noexcept = default;
[[nodiscard]] std::expected<void, DeltaError> handle_event(const SDL_Event& event, TTF_Font* font) noexcept {
bool changed = controller_.process_input(event, doc_, sel_, font, current_layout_, running_);
if (changed || current_layout_.empty()) {
current_layout_ = compute_text_layout(font, doc_.get_raw());
}
return {};
}
[[nodiscard]] bool is_running() const noexcept { return running_; }
[[nodiscard]] const std::string& get_buffer() const noexcept { return doc_.get_raw(); }
[[nodiscard]] const std::vector<LayoutLine>& get_layout() const noexcept { return current_layout_; }
[[nodiscard]] const selection_span& get_selection() const noexcept { return sel_; }
};