42 lines
1.1 KiB
C++
42 lines
1.1 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(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;
|
|
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;
|
|
|
|
private:
|
|
void _on_ret_press(void);
|
|
|
|
bool _should_close;
|
|
std::vector<std::string> _history;
|
|
int _scroll_offset;
|
|
std::string _prompt;
|
|
GameState* _game_state;
|
|
TextBuffer _input_buffer;
|
|
WindowAction _pending_action;
|
|
std::unique_ptr<TextView> _input_view;
|
|
};
|