89 lines
2.2 KiB
C++
89 lines
2.2 KiB
C++
#ifndef WINDOW_H
|
|
#define WINDOW_H
|
|
|
|
#include <utility>
|
|
#include <SDL.h>
|
|
#include "TextShader.h"
|
|
#include "FlatShader.h"
|
|
#include "RectShader.h"
|
|
#include "Font.h"
|
|
#include "Buffer.h"
|
|
#include "glcxx.hpp"
|
|
|
|
class Window
|
|
{
|
|
public:
|
|
bool create(std::shared_ptr<Buffer> buffer);
|
|
void run_event_loop();
|
|
|
|
protected:
|
|
enum
|
|
{
|
|
CURSOR_LEFT,
|
|
CURSOR_RIGHT,
|
|
CURSOR_UP,
|
|
CURSOR_DOWN,
|
|
CURSOR_SOL,
|
|
CURSOR_EOL,
|
|
};
|
|
|
|
enum
|
|
{
|
|
KEYMOD_CTRL = 0x10000,
|
|
KEYMOD_ALT = 0x20000,
|
|
KEYMOD_SHIFT = 0x40000,
|
|
KEYMOD_GUI = 0x80000,
|
|
};
|
|
|
|
void resize();
|
|
void redraw();
|
|
void draw_cursor(int screen_column, int screen_row, bool insert_mode);
|
|
void draw_crosshair(int screen_column, int screen_row);
|
|
void colrow_to_xy(int col, int row, int * x, int * y);
|
|
void handle_event(SDL_Event & event);
|
|
void handle_keysym(uint32_t keysym);
|
|
void handle_keyval(uint32_t keyval);
|
|
void cursor_move(int which);
|
|
std::pair<int, PieceTable::Cursor> calculate_start_position();
|
|
void draw_buffer();
|
|
void draw_buffer_character(int screen_column, int screen_row, uint32_t character);
|
|
void draw_character(int x, int y, uint32_t character);
|
|
void update_cursor_row(int cursor_row);
|
|
void draw_rect(int x, int y, int width, int height, float r, float g, float b, float a);
|
|
void draw_status_bar();
|
|
void insertion_test();
|
|
uint32_t get_keyval(SDL_Keycode keysym);
|
|
uint32_t get_shifted(uint32_t keysym);
|
|
|
|
SDL_Window * m_window;
|
|
bool m_exit_requested;
|
|
int m_width;
|
|
int m_height;
|
|
struct
|
|
{
|
|
std::shared_ptr<TextShader> text;
|
|
std::shared_ptr<FlatShader> flat;
|
|
std::shared_ptr<RectShader> rect;
|
|
} m_shaders;
|
|
|
|
Font m_font;
|
|
int m_columns;
|
|
int m_rows;
|
|
int m_cursor_row;
|
|
int m_scroll_offset;
|
|
uint32_t m_target_column;
|
|
|
|
std::shared_ptr<Buffer> m_buffer;
|
|
|
|
std::shared_ptr<glcxx::Array> m_cursor_array;
|
|
std::shared_ptr<glcxx::Buffer> m_cursor_buffer;
|
|
std::shared_ptr<glcxx::Array> m_rect_array;
|
|
std::shared_ptr<glcxx::Buffer> m_rect_buffer;
|
|
|
|
std::shared_ptr<PieceTable::Cursor> m_cursor;
|
|
|
|
Uint16 m_keymod;
|
|
};
|
|
|
|
#endif
|