ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/dclient/src/backend/ndk/edit.cpp
(Generate patch)

Comparing deliantra/dclient/src/backend/ndk/edit.cpp (file contents):
Revision 1.1 by sf-pippijn, Sun Oct 17 08:15:08 2010 UTC vs.
Revision 1.3 by sf-pippijn, Mon Oct 18 15:34:23 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines