15 #include "label_input.h"
31 if (!editable_)
return false;
35 if (my_font_ == NULL)
return false;
43 if (c == SDLK_BACKSPACE || c == SDLK_DELETE)
45 if (my_text_.empty () || my_cursor_.idx == 0)
return true;
48 if (my_cursor_.idx > 2 && (
u_int8) my_text_[my_cursor_.idx-3] == 0xEF) count = 3;
49 else if (my_cursor_.idx > 1 && (
u_int8) my_text_[my_cursor_.idx-2] == 0xC3) count = 2;
52 my_cursor_.idx -= count;
55 my_text_.erase (my_cursor_.idx, count);
58 my_old_cursor_ = my_cursor_;
61 fillrect (my_cursor_.pos_x, my_cursor_.pos_y,
62 (*my_font_) [glyph].length (),
68 else if (c == SDLK_RETURN)
add_text (
"\n");
69 else if (my_font_->in_table (c))
74 if (c < 0x80) count = 1;
75 else if (c < 0x800) count = 2;
76 else if (c < 0x10000) count = 3;
79 case 3: r[2] = 0x80 | (c & 0x3f); c = c >> 6; c |= 0x800;
80 case 2: r[1] = 0x80 | (c & 0x3f); c = c >> 6; c |= 0xc0;
#define s_int32
32 bits long signed integer
void set_cursor_visible(const bool b)
Set visible cursor.
#define u_int16
16 bits long unsigned integer
void build(const bool erase_all)
Build label.
void fillrect(s_int16 x, s_int16 y, u_int16 l, u_int16 h, u_int32 col, drawing_area *da_opt=NULL)
Fills an area of the surface with a given color.
#define u_int8
8 bits long unsigned integer
void unlock() const
Unlock the surface after you've worked on it's pixels with the get_pix () and put_pix () methods...
bool input_update()
Update input label, you can move the cursor if the cursor is moveable.
void set_cursor_moveable(const bool b)
Set if the cursor can be moved with arrow key.
void add_text(const string &text)
Add text.
static u_int32 trans_col()
Returns the translucent color in screen's depth format.
void lock() const
Locks the surface.