48 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#pragma once
 | 
						|
 | 
						|
#include <SDL3/SDL_events.h>
 | 
						|
#include <string>
 | 
						|
#include <vector>
 | 
						|
#include <unordered_set>
 | 
						|
 | 
						|
#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<Token> _tokenize_line(const std::string& line);
 | 
						|
 | 
						|
  TextBuffer* _buffer;
 | 
						|
  int _scroll_offset;
 | 
						|
  bool _handle_ret;
 | 
						|
  bool _show_line_numbers;
 | 
						|
  std::unordered_set<std::string> _lua_keywords;
 | 
						|
};
 |