summaryrefslogtreecommitdiff
path: root/src/user/raleigh/w/entry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/raleigh/w/entry.cpp')
-rw-r--r--src/user/raleigh/w/entry.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/user/raleigh/w/entry.cpp b/src/user/raleigh/w/entry.cpp
index 991d75a..3053413 100644
--- a/src/user/raleigh/w/entry.cpp
+++ b/src/user/raleigh/w/entry.cpp
@@ -5,18 +5,10 @@
#include <knob/key.h>
namespace raleigh {
- entry::entry(uint32_t rows, uint32_t cols, const char *default_text,
- const char *font, _pixel_t bg, _pixel_t fg, _pixel_t border_color)
- : rows(rows), cols(cols), bg(bg), fg(fg), border_color(border_color),
- fi(get_font(font)), data(new char[rows * cols]),
- line_indices(new uint32_t[rows + 1]), has_focus(false) {
- size = coord(fi->space_width * (cols - 1) + fi->char_width + 6,
- fi->space_height * (rows - 1) + fi->char_height + 6);
- closest_opaque = this;
-
- const uint32_t l = strlen(default_text);
+ void entry::set_contents(const char *s) {
+ const uint32_t l = strlen(s);
const uint32_t cl = l > rows * cols - 1 ? rows * cols - 1 : l;
- blockcpy(data, default_text, cl);
+ blockcpy(data, s, cl);
data[cl] = '\0';
line_indices[0] = 0;
@@ -24,6 +16,21 @@ namespace raleigh {
cur_x = end_x;
cur_y = end_y;
cur_d = end_d;
+
+ next_paint_full = true;
+ if (w)
+ w->notify_needs_paint(*this);
+ }
+
+ entry::entry(uint32_t rows, uint32_t cols, const char *default_text,
+ const char *font, _pixel_t bg, _pixel_t fg, _pixel_t border_color)
+ : rows(rows), cols(cols), bg(bg), fg(fg), border_color(border_color),
+ fi(get_font(font)), data(new char[rows * cols]),
+ line_indices(new uint32_t[rows + 1]), has_focus(false) {
+ size = coord(fi->space_width * (cols - 1) + fi->char_width + 6,
+ fi->space_height * (rows - 1) + fi->char_height + 6);
+ closest_opaque = this;
+ set_contents(default_text);
}
void entry::get_indices(uint32_t from_y, uint32_t from_x, uint32_t from_d) {
@@ -260,4 +267,8 @@ namespace raleigh {
has_focus = false;
w->notify_needs_paint(*this);
}
+
+ const char *entry::get_contents() {
+ return data;
+ }
} \ No newline at end of file