… | |
… | |
8 | #include <ndk++/application.hh> |
8 | #include <ndk++/application.hh> |
9 | #include <ndk++/edit.hh> |
9 | #include <ndk++/edit.hh> |
10 | #include <ndk++/packer.hh> |
10 | #include <ndk++/packer.hh> |
11 | #include <ndk++/palette.hh> |
11 | #include <ndk++/palette.hh> |
12 | |
12 | |
13 | #include <ncurses/assert.hh> |
|
|
14 | #include <ncurses/pen.hh> |
13 | #include <ncurses/pen.hh> |
15 | |
14 | |
16 | #include <cctype> |
15 | #include <cctype> |
17 | |
16 | |
18 | |
17 | |
19 | using ndk::edit; |
18 | using ndk::edit; |
20 | |
19 | |
21 | edit::edit (const std::string &str, panel *parent, bool accept) |
20 | edit::edit (std::string const &str, panel *parent, bool accept) |
22 | : button (str, parent, accept) |
21 | : button (str, parent, accept) |
23 | , current_ (0) |
22 | , current_ (0) |
24 | , begin_ (0) |
23 | , begin_ (0) |
25 | , mode_ (normal) |
24 | , mode_ (normal) |
26 | { |
25 | { |
… | |
… | |
33 | { |
32 | { |
34 | button::resize (size, 1); |
33 | button::resize (size, 1); |
35 | } |
34 | } |
36 | |
35 | |
37 | void |
36 | void |
38 | edit::set_text (const std::string &str) |
37 | edit::set_text (std::string const &str) |
39 | { |
38 | { |
40 | label::set_text (str); |
39 | label::set_text (str); |
41 | current_ = text_.length (); |
40 | current_ = text_.length (); |
42 | draw (); |
41 | draw (); |
43 | } |
42 | } |
… | |
… | |
84 | set_cursor (); /* and finally update cursor position */ |
83 | set_cursor (); /* and finally update cursor position */ |
85 | ncurses::pen (*this).commit (); /* commit changes to the screen */ |
84 | ncurses::pen (*this).commit (); /* commit changes to the screen */ |
86 | } |
85 | } |
87 | |
86 | |
88 | ndk::event::result |
87 | ndk::event::result |
89 | edit::at_system (const event &ev) |
88 | edit::at_system (event const &ev) |
90 | { |
89 | { |
91 | event::result res = event::ignored; |
90 | event::result res = event::ignored; |
92 | |
91 | |
93 | if (!ev.sender_) |
92 | if (!ev.sender_) |
94 | { |
93 | { |
… | |
… | |
106 | } |
105 | } |
107 | return res; |
106 | return res; |
108 | } |
107 | } |
109 | |
108 | |
110 | ndk::event::result |
109 | ndk::event::result |
111 | edit::at_keyboard (const keyboard &ev) |
110 | edit::at_keyboard (keyboard const &ev) |
112 | { |
111 | { |
113 | event::result res = event::ignored; |
112 | event::result res = event::ignored; |
114 | unsigned int pos = current_; |
113 | unsigned int pos = current_; |
115 | |
114 | |
116 | switch (ev.code ()) |
115 | switch (ev.code ()) |