48 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#pragma once
 | 
						|
#include <string>
 | 
						|
#include <vector>
 | 
						|
#include <memory>
 | 
						|
#include <SDL3/SDL.h>
 | 
						|
 | 
						|
#include "gfx/types.h"
 | 
						|
#include "ui/text_buffer.h"
 | 
						|
#include "ui/text_view.h"
 | 
						|
#include "ui/i_window_content.h"
 | 
						|
#include "ui/window_action.h"
 | 
						|
 | 
						|
class GameState;
 | 
						|
 | 
						|
class Terminal : public IWindowContent {
 | 
						|
public:
 | 
						|
  Terminal(GameState* game_state);
 | 
						|
  ~Terminal(void);
 | 
						|
 | 
						|
  void update(int content_width, int content_height) override;
 | 
						|
  void handle_input(SDL_Event* event, int window_x, int window_y, int window_gl_y,
 | 
						|
                    int content_width, int content_height) 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;
 | 
						|
  void add_history(const std::string& line);
 | 
						|
  void set_prompt(const std::string& prompt);
 | 
						|
  bool should_close(void) override;
 | 
						|
  WindowAction get_pending_action(void) override;
 | 
						|
  void set_session_id(uint32_t id);
 | 
						|
  uint32_t get_session_id(void) const;
 | 
						|
 | 
						|
private:
 | 
						|
  void _on_ret_press(void);
 | 
						|
 | 
						|
  bool _should_close;
 | 
						|
  std::vector<std::string> _command_history;
 | 
						|
  int _command_history_index;
 | 
						|
  std::vector<std::string> _history;
 | 
						|
  int _scroll_offset;
 | 
						|
  std::string _prompt;
 | 
						|
  GameState* _game_state;
 | 
						|
  TextBuffer _input_buffer;
 | 
						|
  WindowAction _pending_action;
 | 
						|
  uint32_t _session_id;
 | 
						|
  std::unique_ptr<TextView> _input_view;
 | 
						|
};
 |