File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,16 +99,15 @@ void Input::Update()
9999 || (e.key .keysym .sym == SDLK_SPACE )) {
100100 char ch = (char )e.key .keysym .sym ;
101101 ch = shift ? toupper (ch) : ch;
102- text. write (&ch, 1 ) ;
102+ text += ch ;
103103 }
104104 else if (e.key .keysym .sym == SDLK_LSHIFT
105105 || e.key .keysym .sym == SDLK_RSHIFT ) {
106106 shift = true ;
107107 }
108- else if (e.key .keysym .sym == SDLK_BACKSPACE && text.tellp () > 0 ) {
109- long pos = text.tellp ();
110- if (pos > 0 )
111- text.seekp (pos - 1 );
108+ else if (e.key .keysym .sym == SDLK_BACKSPACE ) {
109+ if (!text.empty ())
110+ text.erase (text.end () - 1 );
112111 }
113112 }
114113 break ;
@@ -248,7 +247,7 @@ void Input::OpenCharBuffer(int max)
248247
249248 shift = false ;
250249 maxchar = max;
251- text. str ( " " ) ;
250+ text = " " ;
252251 textinput = true ;
253252}
254253
@@ -268,5 +267,5 @@ void Input::CloseCharBuffer()
268267//
269268string Input::GetInput () const
270269{
271- return text. str () ;
270+ return text;
272271}
Original file line number Diff line number Diff line change 2222
2323#include " Platform.hpp"
2424
25- #include < sstream>
26-
2725//
2826// A singleton class to manage SDL input.
2927//
@@ -60,7 +58,7 @@ class Input {
6058
6159 bool shift;
6260 bool textinput; // Is a character buffer open?
63- ostringstream text; // Text read so far
61+ string text; // Text read so far
6462 int maxchar; // Maximum number of characters to read
6563
6664 // Record joystick state
Original file line number Diff line number Diff line change 2424#include " InterfaceSounds.hpp"
2525
2626#include < cassert>
27+ #include < sstream>
2728
2829const double Options::FADE_SPEED = 0.1 ;
2930
You can’t perform that action at this time.
0 commit comments