#ifndef WINDOW_H #define WINDOW_H #include #include #include #include "Font.h" #include "Buffer.h" #include "GL.h" #include "EncodedString.h" #include "CommandParser.h" class BufferPane; class Window { public: class Keymod { public: enum : uint32_t { CTRL = 0x10000, ALT = 0x20000, SHIFT = 0x40000, GUI = 0x80000, }; }; enum class CursorMovement : uint8_t { LEFT, RIGHT, UP, DOWN, SOL, EOL, FIRST_LINE, LAST_LINE, SCREEN_ROW_UP, SCREEN_ROW_DOWN, }; enum class ScrollMode : uint8_t { ONE_LINE, WHEEL, HALF_SCREEN, WHOLE_SCREEN, }; enum class EnterInsertModeMode : uint8_t { START_OF_CHAR, END_OF_CHAR, START_OF_LINE, END_OF_LINE, NEW_LINE_BEFORE, NEW_LINE_AFTER, }; bool create(std::shared_ptr buffer); void run_event_loop(); void request_redraw() { m_redraw_requested = true; } std::shared_ptr font() const { return m_font; } std::shared_ptr gl() const { return m_gl; } protected: void resize(); void redraw(); void handle_event(SDL_Event & event); void handle_keysym(uint32_t keysym); void handle_keyval(uint32_t keyval); uint32_t get_keyval(SDL_Keycode keysym); uint32_t get_shifted(uint32_t keysym); void change_focus(std::shared_ptr buffer_pane); void set_window_icon(); void handle_command(const EncodedString & command); void command_write_file(const CommandParser & cp); void command_quit(const CommandParser & cp); SDL_Window * m_window; bool m_exit_requested; bool m_redraw_requested; int m_width; int m_height; int m_command_buffer_screen_rows; std::shared_ptr m_font; uint32_t m_target_column; std::shared_ptr m_gl; std::shared_ptr m_buffer_pane; std::shared_ptr m_focused_buffer_pane; std::shared_ptr m_command_buffer; std::shared_ptr m_command_buffer_pane; Uint16 m_keymod; }; #endif