1 | /* edit.cc |
1 | /* edit.cc |
2 | * This file is part of NDK++ library |
2 | * This file is part of NDK++ library |
3 | * Copyright (c) 2003,2004 by Stanislav Ievlev |
3 | * Copyright (c) 2003,2004 by Stanislav Ievlev |
4 | * |
4 | * |
5 | * This file is covered by the GNU Library General Public License, |
5 | * This file is covered by the GNU Library General Public License, |
6 | * which should be included with libndk++ as the file COPYING. |
6 | * which should be included with libndk as the file COPYING. |
7 | */ |
7 | */ |
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 <ndk++/pen.hh> |
13 | #include <ndk/pen.hh> |
14 | |
14 | |
15 | #include <cctype> |
15 | #include <cctype> |
16 | |
16 | |
17 | |
17 | |
18 | using ndk::edit; |
18 | using ndk::edit; |
… | |
… | |
76 | break; |
76 | break; |
77 | default: |
77 | default: |
78 | break; |
78 | break; |
79 | } |
79 | } |
80 | |
80 | |
|
|
81 | if (begin_ > out.length ()) |
|
|
82 | begin_ = out.length (); |
|
|
83 | |
81 | label::draw (out, begin_); /* and draw */ |
84 | label::draw (out, begin_); /* and draw */ |
82 | set_cursor (); /* and finally update cursor position */ |
85 | set_cursor (); /* and finally update cursor position */ |
83 | pen (*this).commit (); /* commit changes to the screen */ |
86 | pen (*this).commit (); /* commit changes to the screen */ |
84 | } |
87 | } |
85 | |
88 | |
86 | ndk::event::result |
89 | ndk::event::result |
87 | edit::at_system (event const &ev) |
90 | edit::at_system (event const &ev) |
88 | { |
91 | { |
… | |
… | |
136 | { |
139 | { |
137 | erase (pos); |
140 | erase (pos); |
138 | draw (); /* we always need full redraw */ |
141 | draw (); /* we always need full redraw */ |
139 | res = event::accepted; |
142 | res = event::accepted; |
140 | } |
143 | } |
|
|
144 | break; |
|
|
145 | case key::ctrl_u: |
|
|
146 | if (pos) |
|
|
147 | { |
|
|
148 | /* delete all characters up to the current */ |
|
|
149 | text_ = text_.substr (pos, text_.length () - pos); |
|
|
150 | current_ = 0; |
|
|
151 | recalibrate (); // TODO: ? draw () : set_cursor (); // or always draw? |
|
|
152 | draw (); |
|
|
153 | pos = 0; |
|
|
154 | } |
|
|
155 | res = event::accepted; |
141 | break; |
156 | break; |
142 | case key::home: |
157 | case key::home: |
143 | begin_ = 0; |
158 | begin_ = 0; |
144 | current_ = 0; |
159 | current_ = 0; |
145 | draw (); |
160 | draw (); |