… | |
… | |
15 | #include <cctype> |
15 | #include <cctype> |
16 | |
16 | |
17 | |
17 | |
18 | using ndk::edit; |
18 | using ndk::edit; |
19 | |
19 | |
20 | edit::edit (const std::string &str, panel *parent, bool accept) |
20 | edit::edit (std::string const &str, panel *parent, bool accept) |
21 | : button (str, parent, accept) |
21 | : button (str, parent, accept) |
22 | , current_ (0) |
22 | , current_ (0) |
23 | , begin_ (0) |
23 | , begin_ (0) |
24 | , mode_ (normal) |
24 | , mode_ (normal) |
25 | { |
25 | { |
… | |
… | |
32 | { |
32 | { |
33 | button::resize (size, 1); |
33 | button::resize (size, 1); |
34 | } |
34 | } |
35 | |
35 | |
36 | void |
36 | void |
37 | edit::set_text (const std::string &str) |
37 | edit::set_text (std::string const &str) |
38 | { |
38 | { |
39 | label::set_text (str); |
39 | label::set_text (str); |
40 | current_ = text_.length (); |
40 | current_ = text_.length (); |
41 | draw (); |
41 | draw (); |
42 | } |
42 | } |
… | |
… | |
83 | set_cursor (); /* and finally update cursor position */ |
83 | set_cursor (); /* and finally update cursor position */ |
84 | ncurses::pen (*this).commit (); /* commit changes to the screen */ |
84 | ncurses::pen (*this).commit (); /* commit changes to the screen */ |
85 | } |
85 | } |
86 | |
86 | |
87 | ndk::event::result |
87 | ndk::event::result |
88 | edit::at_system (const event &ev) |
88 | edit::at_system (event const &ev) |
89 | { |
89 | { |
90 | event::result res = event::ignored; |
90 | event::result res = event::ignored; |
91 | |
91 | |
92 | if (!ev.sender_) |
92 | if (!ev.sender_) |
93 | { |
93 | { |
… | |
… | |
105 | } |
105 | } |
106 | return res; |
106 | return res; |
107 | } |
107 | } |
108 | |
108 | |
109 | ndk::event::result |
109 | ndk::event::result |
110 | edit::at_keyboard (const keyboard &ev) |
110 | edit::at_keyboard (keyboard const &ev) |
111 | { |
111 | { |
112 | event::result res = event::ignored; |
112 | event::result res = event::ignored; |
113 | unsigned int pos = current_; |
113 | unsigned int pos = current_; |
114 | |
114 | |
115 | switch (ev.code ()) |
115 | switch (ev.code ()) |
… | |
… | |
214 | |
214 | |
215 | void |
215 | void |
216 | edit::set_cursor () |
216 | edit::set_cursor () |
217 | { |
217 | { |
218 | /* always move to zero position in no_echo mode */ |
218 | /* always move to zero position in no_echo mode */ |
219 | ncurses::pen (*this).move (mode_ != no_echo ? current_ - begin_ : 0, 0); |
219 | return_unless (ncurses::pen (*this).move (mode_ != no_echo ? current_ - begin_ : 0, 0)); |
220 | ncurses::pen (*this).commit (); |
220 | ncurses::pen (*this).commit (); |
221 | } |
221 | } |
222 | |
222 | |
223 | void |
223 | void |
224 | edit::insert (int pos, char sym) |
224 | edit::insert (int pos, char sym) |