#pragma once #include #include #include #include #include "ui/text_buffer.h" #include "ui/ui_renderer.h" #include "ui/editor.h" /* For SyntaxTheme */ class TextRenderer; enum class TokenType { NORMAL, KEYWORD, STRING, NUMBER, COMMENT }; struct Token { TokenType type; std::string text; }; class TextView { public: TextView(TextBuffer* buffer, bool handle_ret, bool show_line_numbers); ~TextView(void); bool handle_event(SDL_Event* event); void scroll(int amount, int content_height); void render_text_content(UIRenderer* ui_renderer, const SyntaxTheme& theme, int x, int y, int width, int height); void render_cursor(UIRenderer* ui_renderer, const SyntaxTheme& theme, int x, int y, int width, int height); private: std::vector _tokenize_line(const std::string& line); TextBuffer* _buffer; int _scroll_offset; bool _handle_ret; bool _show_line_numbers; std::unordered_set _lua_keywords; };