diff options
author | Benji Dial <benji6283@gmail.com> | 2021-06-21 17:47:13 -0400 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-06-21 17:47:13 -0400 |
commit | f57e2eabe0a10c9732c83532e01654a499fb8dcf (patch) | |
tree | cbf91a23fcdd65e0ea7ed55b0940ca7042d59bef /src/user/include/cxx/raleigh/w/entry.h | |
parent | 83835306d57461205a7bcfef9f4c3e06bc504006 (diff) | |
download | portland-os-f57e2eabe0a10c9732c83532e01654a499fb8dcf.tar.gz |
many, many changes; settings is broken
Diffstat (limited to 'src/user/include/cxx/raleigh/w/entry.h')
-rw-r--r-- | src/user/include/cxx/raleigh/w/entry.h | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/src/user/include/cxx/raleigh/w/entry.h b/src/user/include/cxx/raleigh/w/entry.h index c86b281..cc797b0 100644 --- a/src/user/include/cxx/raleigh/w/entry.h +++ b/src/user/include/cxx/raleigh/w/entry.h @@ -1,72 +1,61 @@ #ifndef RALEIGH_W_ENTRY_H #define RALEIGH_W_ENTRY_H +#include <raleigh/s/text_flower.h> #include <raleigh/widget.h> #include <libfont/fonts.h> namespace raleigh { class entry : public widget { public: - //default_text's data is copied, so it's okay if it changes or if the memory is freed entry(uint32_t rows=25, uint32_t cols=25, const char *default_text="", - const char *font="fixed-10", _pixel_t bg=RGB(ff, ff, ff), + const struct font_info *fi=get_font("fixed-10"), _pixel_t bg=RGB(ff, ff, ff), _pixel_t fg=RGB(00, 00, 00), _pixel_t border_color=RGB(00, 00, 00)); //not a copy - const char *get_contents(); - //s's data is copied + const char *get_contents() __attribute__ ((pure)); + //s is copied void set_contents(const char *s); - void notify_window_change() override; void paint(_pixel_t *pixbuf, uint32_t pitch) override; - void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override; void notify_has_opaque_parent(widget *parent) override; + void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override; void handle_key(struct key_packet kp) override; void on_focus() override; void on_unfocus() override; + private: + const struct font_info *fi; + _pixel_t border_color; + _pixel_t fg; + _pixel_t bg; uint32_t rows; uint32_t cols; - _pixel_t bg; - _pixel_t fg; - _pixel_t border_color; - struct font_info *fi; - char *data; - //line_indices[end_y + 1] == end_d - uint32_t *line_indices; + void left(); + void right(); + void up(); + void down(); - uint32_t cur_y; - uint32_t cur_x; - uint32_t cur_d; + void check_y(); + void check_x(); - //the row of the last character - uint32_t end_y; - //the column after the last character - uint32_t end_x; - //the index of the null terminator - uint32_t end_d; + void on_text_change(); + void on_cursor_change(); - bool has_focus; - bool had_focus_last_paint; - bool text_changed_since_last_paint; - uint32_t cur_y_last_paint; - uint32_t cur_x_last_paint; - uint32_t cur_d_last_paint; + alist<char> text_back; + text_flower flower; - //uses cur_x, not cur_d; sets both - //will not modify cur_y - void ensure_cursor_in_line(); + bool text_change; + bool cursor_change; - void paint_text(_pixel_t *pixbuf, uint32_t pitch); - //sets line_indices[from_y + 1 .. end_y + 1], end_y, end_x and end_d - void get_indices(uint32_t from_y, uint32_t from_x, uint32_t from_d); + bool was_cur_before; + uint32_t old_cur_x; + uint32_t old_cur_y; - //these four return true on success, and do not send a paint request to the window - bool cursor_left(); - bool cursor_right(); - bool cursor_up(); - bool cursor_down(); + bool is_cur; + uint32_t cur_x; + uint32_t cur_y; }; } |