From 37d27d60636a5f84621e82419e4dbb4d20328f72 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 27 Jan 2017 20:44:24 -0500 Subject: [PATCH] get ready to handle commands entered --- src/gui/Window.cc | 22 ++++++++++++++++++++++ src/gui/Window.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/gui/Window.cc b/src/gui/Window.cc index 36449f7..03a8d82 100644 --- a/src/gui/Window.cc +++ b/src/gui/Window.cc @@ -4,6 +4,7 @@ #include "BufferPane.h" #include #include "jes_icon-32x32.h" +#include "CommandParser.h" #define INITIAL_WIDTH 800 #define INITIAL_HEIGHT 800 @@ -323,9 +324,11 @@ void Window::handle_keyval(uint32_t keyval) { if ((keyval == '\n') && (m_focused_buffer_pane == m_command_buffer_pane)) { + EncodedString command = m_command_buffer->get_string(); m_command_buffer_pane->clear(); m_command_buffer_screen_rows = 1; change_focus(m_buffer_pane); + handle_command(command); } else { @@ -565,3 +568,22 @@ void Window::change_focus(std::shared_ptr buffer_pane) m_focused_buffer_pane->set_focused(true); request_redraw(); } + +void Window::handle_command(const EncodedString & command) +{ + CommandParser cp; + if (cp.parse(command)) + { + if (cp.size() >= 1) + { + if (cp[0] == "w") + { + /* TODO */ + } + } + } + else + { + /* TODO: handle command parsing failure */ + } +} diff --git a/src/gui/Window.h b/src/gui/Window.h index e78aa7d..260d02d 100644 --- a/src/gui/Window.h +++ b/src/gui/Window.h @@ -7,6 +7,7 @@ #include "Font.h" #include "Buffer.h" #include "GL.h" +#include "EncodedString.h" class BufferPane; @@ -74,6 +75,7 @@ protected: 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); SDL_Window * m_window; bool m_exit_requested;