#pragma once #include #include "gfx/types.h" #include "i_window_content.h" #include "ui/text_buffer.h" #include "ui/window_action.h" #include "ui/menu_bar.h" class TextView; struct SyntaxTheme { Color normal = { 1.0f, 1.0f, 1.0f }; Color keyword = { 0.8f, 0.6f, 1.0f }; Color string = { 1.0f, 0.8f, 0.6f }; Color number = { 0.6f, 1.0f, 0.8f }; Color comment = { 0.6f, 0.6f, 0.6f }; Color line_num = { 0.5f, 0.6f, 0.7f }; }; class Editor : public IWindowContent { public: Editor(void); Editor(const std::string& filename); ~Editor(void) override; void update(void) override; void handle_input(SDL_Event* event, int window_x, int window_y, int window_gl_y) override; void render(const RenderContext& context, int x, int y_screen, int y_gl, int width, int height) override; void scroll(int amount, int content_height) override; bool should_close(void) override; void set_buffer_content(const std::string& content); WindowAction get_pending_action(void) override; const std::string& get_filename(void) const; private: TextBuffer _buffer; std::unique_ptr _view; std::unique_ptr _menu_bar; bool _should_close; WindowAction _pending_action; SyntaxTheme _theme; std::string _filename; };