22 #include "sdl/texture.hpp"
31 #include <boost/range/adaptor/reversed.hpp>
43 if(SDL_Init(SDL_INIT_VIDEO) != 0) {
44 std::cerr <<
"Unable to initialise SDL with error »"
45 << SDL_GetError() <<
"«.\n";
83 = window.create_texture(SDL_TEXTUREACCESS_STATIC, text.
render());
85 window.draw(texture, x, y);
94 const std::deque<std::string>& history)
97 for(
const std::string & item : boost::adaptors::reverse(history))
106 std::string::const_iterator begin = command_line.begin();
109 if(command ==
"quit") {
113 }
else if(command ==
"window") {
122 std::string::const_iterator& begin,
123 const char separator)
125 const std::string::const_iterator
end
131 if(begin !=
string.
end()) {
146 std::deque<std::string> history;
150 SDL_WINDOWPOS_CENTERED,
151 SDL_WINDOWPOS_CENTERED,
155 SDL_RENDERER_TARGETTEXTURE);
157 SDL_Rect rect = { 25, 575, 750, 25 };
158 SDL_SetTextInputRect(&rect);
164 window.
fill(0, 0, 0, 0);
176 if(SDL_WaitEvent(&event) == 0) {
186 case SDL_TEXTEDITING:
191 if(event.key.keysym.sym == SDLK_BACKSPACE) {
201 if(event.key.keysym.sym == SDLK_RETURN) {
203 history.push_back(line);
204 if(history.size() > 22) {
209 SDL_RaiseWindow(window);
static void draw_text(sdl::twindow &window, const std::string &string, const int x, const int y)
GLenum GLenum GLuint texture
std::string get_token(const std::string &string, std::string::const_iterator &begin, const char separator)
Gets a token from a string.
GLint GLint GLint GLint GLint GLint y
void render()
Renders the contents of the window.
The wrapper class for the SDL_Window class.
static void draw_command_history(sdl::twindow &window, const std::deque< std::string > &history)
std::vector< sdl::twindow * > windows
Contains the windows created by the user.
void fill(Uint8 r, Uint8 g, Uint8 b, Uint8 a=0)
Clears the contents of the window with a given color.
static bool execute_command(std::string &command_line)
size_t size(const utf8::string &str)
Length in characters of a UTF-8 string.
This exception when throw should terminate the application.
surface render() const
Returns the rendered text.
GLint GLint GLint GLint GLint x
bool find(E event, F functor)
Tests whether an event handler is available.
bool set_text(const std::string &text, const bool markedup)
Sets the text to render.
Contains a wrapper class for the SDL_Window class.
utf8::string & insert(utf8::string &str, const size_t pos, const utf8::string &insert)
Insert a UTF-8 string at the specified position.
static void draw_command_line(sdl::twindow &window, const std::string &command)
GLsizei const GLcharARB ** string
utf8::string & erase(utf8::string &str, const size_t start, const size_t len)
Erases a portion of a UTF-8 string.