Initial commit: HTab spreadsheet engine and GemUI X11 frontend
This commit is contained in:
commit
395f458fee
55 files changed
+12682
No files matched your search
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include "engine/workbook.hpp"
|
||||
|
||||
#include <gemui.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace htab::ui {
|
||||
|
||||
class X11Clipboard {
|
||||
public:
|
||||
X11Clipboard() = default;
|
||||
~X11Clipboard();
|
||||
|
||||
X11Clipboard(const X11Clipboard&) = delete;
|
||||
X11Clipboard& operator=(const X11Clipboard&) = delete;
|
||||
|
||||
void init(gemui_app_t* app);
|
||||
void shutdown(gemui_app_t* app);
|
||||
|
||||
void copy_grid(const ClipboardGrid& grid);
|
||||
void set_text(const std::string& text);
|
||||
|
||||
bool owns_clipboard() const { return owns_clipboard_; }
|
||||
bool has_internal() const { return owns_clipboard_ && !internal_.cells.empty(); }
|
||||
const ClipboardGrid& internal_grid() const { return internal_; }
|
||||
void clear_cut_flag() { internal_.is_cut = false; }
|
||||
|
||||
std::string get_external_text(gemui_app_t* app) const;
|
||||
|
||||
static std::string grid_to_tsv(const ClipboardGrid& grid);
|
||||
static std::vector<CellEdit> parse_tsv_to_edits(const std::string& text,
|
||||
int dest_row,
|
||||
int dest_col);
|
||||
|
||||
private:
|
||||
static void on_fd_ready(gemui_app_t* app, int fd, void* ud);
|
||||
void process_events();
|
||||
void handle_selection_request(const XSelectionRequestEvent& req);
|
||||
|
||||
Display* dpy_ = nullptr;
|
||||
Window win_ = None;
|
||||
int xfd_ = -1;
|
||||
Atom atom_clipboard_ = None;
|
||||
Atom atom_targets_ = None;
|
||||
Atom atom_utf8_ = None;
|
||||
Atom atom_text_ = None;
|
||||
bool owns_clipboard_ = false;
|
||||
std::string text_;
|
||||
ClipboardGrid internal_;
|
||||
};
|
||||
|
||||
} // namespace htab::ui
|
||||
Reference in new issue
Block a user