summaryrefslogtreecommitdiff
path: root/src/user/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/include')
-rw-r--r--src/user/include/cxx/raleigh/w/button.h5
-rw-r--r--src/user/include/cxx/raleigh/w/entry.h25
-rw-r--r--src/user/include/cxx/raleigh/w/label.h5
-rw-r--r--src/user/include/cxx/raleigh/w/padding.h5
-rw-r--r--src/user/include/cxx/raleigh/w/vbox.h5
-rw-r--r--src/user/include/cxx/raleigh/widget.h5
-rw-r--r--src/user/include/cxx/raleigh/window.h2
-rw-r--r--src/user/include/knob/block.h3
-rw-r--r--src/user/include/knob/key.h8
9 files changed, 54 insertions, 9 deletions
diff --git a/src/user/include/cxx/raleigh/w/button.h b/src/user/include/cxx/raleigh/w/button.h
index 1847cf1..03e17ab 100644
--- a/src/user/include/cxx/raleigh/w/button.h
+++ b/src/user/include/cxx/raleigh/w/button.h
@@ -11,8 +11,11 @@ namespace raleigh {
void notify_window_change() override;
void paint(_pixel_t *pixbuf, uint32_t pitch) override;
- bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) 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_key(struct key_packet kp) override;
+ void on_focus() override;
+ void on_unfocus() override;
private:
widget &inner;
void (*on_click)(button &);
diff --git a/src/user/include/cxx/raleigh/w/entry.h b/src/user/include/cxx/raleigh/w/entry.h
index 7ea2973..fcae122 100644
--- a/src/user/include/cxx/raleigh/w/entry.h
+++ b/src/user/include/cxx/raleigh/w/entry.h
@@ -12,10 +12,13 @@ namespace raleigh {
const char *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));
- void notify_window_change();
- void paint(_pixel_t *pixbuf, uint32_t pitch);
- bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up);
- void notify_has_opaque_parent(widget *parent);
+ 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_key(struct key_packet kp) override;
+ void on_focus() override;
+ void on_unfocus() override;
private:
uint32_t rows;
uint32_t cols;
@@ -40,12 +43,26 @@ namespace raleigh {
uint32_t end_d;
bool first_paint;
+ 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;
+ //uses cur_x, not cur_d; sets both
+ //will not modify cur_y
+ void ensure_cursor_in_line();
+
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);
+
+ //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();
};
}
diff --git a/src/user/include/cxx/raleigh/w/label.h b/src/user/include/cxx/raleigh/w/label.h
index d133841..4b1dae2 100644
--- a/src/user/include/cxx/raleigh/w/label.h
+++ b/src/user/include/cxx/raleigh/w/label.h
@@ -13,8 +13,11 @@ namespace raleigh {
void notify_window_change() override;
void paint(_pixel_t *pixbuf, uint32_t pitch) override;
- bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) override __attribute__ ((const));
+ 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_key(struct key_packet kp) override;
+ void on_focus() override;
+ void on_unfocus() override;
private:
const char *const value;
const struct font_info *const fi;
diff --git a/src/user/include/cxx/raleigh/w/padding.h b/src/user/include/cxx/raleigh/w/padding.h
index 216b984..792e204 100644
--- a/src/user/include/cxx/raleigh/w/padding.h
+++ b/src/user/include/cxx/raleigh/w/padding.h
@@ -10,8 +10,11 @@ namespace raleigh {
void notify_window_change() override;
void paint(_pixel_t *pixbuf, uint32_t pitch) override;
- bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) 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_key(struct key_packet kp) override;
+ void on_focus() override;
+ void on_unfocus() override;
private:
widget &inner;
uint32_t pad_by;
diff --git a/src/user/include/cxx/raleigh/w/vbox.h b/src/user/include/cxx/raleigh/w/vbox.h
index aead128..02bffd3 100644
--- a/src/user/include/cxx/raleigh/w/vbox.h
+++ b/src/user/include/cxx/raleigh/w/vbox.h
@@ -12,8 +12,11 @@ namespace raleigh {
void notify_window_change() override;
void paint(_pixel_t *pixbuf, uint32_t pitch) override;
- bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) 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_key(struct key_packet kp) override;
+ void on_focus() override;
+ void on_unfocus() override;
private:
dllist<widget &> widgets;
};
diff --git a/src/user/include/cxx/raleigh/widget.h b/src/user/include/cxx/raleigh/widget.h
index de6c5a4..54b9287 100644
--- a/src/user/include/cxx/raleigh/widget.h
+++ b/src/user/include/cxx/raleigh/widget.h
@@ -28,8 +28,11 @@ namespace raleigh {
//called by window class (or parent widget)
virtual void notify_window_change() = 0;
virtual void paint(_pixel_t *pixbuf, uint32_t pitch) = 0;
- virtual bool try_handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) = 0;
+ virtual void handle_click(coord window_coords, enum mouse_packet::mouse_button click_type, bool up) = 0;
virtual void notify_has_opaque_parent(widget *parent) = 0;
+ virtual void handle_key(struct key_packet kp) = 0;
+ virtual void on_focus() = 0;
+ virtual void on_unfocus() = 0;
};
}
diff --git a/src/user/include/cxx/raleigh/window.h b/src/user/include/cxx/raleigh/window.h
index f82f9a9..21ae511 100644
--- a/src/user/include/cxx/raleigh/window.h
+++ b/src/user/include/cxx/raleigh/window.h
@@ -20,11 +20,13 @@ namespace raleigh {
enum try_actions_return_t {NONE, GOOD, DELETE};
try_actions_return_t try_actions();
void show();
+ void focus(widget &w);
private:
_window_handle_t handle;
_pixel_t *pixbuf;
coord size;
widget &root;
+ widget *focussed;
_pixel_t bg_color;
bool needs_repaint;
void paint_full();
diff --git a/src/user/include/knob/block.h b/src/user/include/knob/block.h
index 565c334..27cb83b 100644
--- a/src/user/include/knob/block.h
+++ b/src/user/include/knob/block.h
@@ -28,6 +28,9 @@ bool strequ(const char *a, const char *b) __attribute__ ((pure));
//this replacement happens in place, with no memory allocation
void str_trunc_fill(char *str, uint32_t len);
+//returns first index of any character of delims or the null terminator in str
+uint32_t str_find_any(const char *str, const char *delims) __attribute__ ((pure));
+
#ifdef __cplusplus
}
#endif
diff --git a/src/user/include/knob/key.h b/src/user/include/knob/key.h
index 90509fc..d532afd 100644
--- a/src/user/include/knob/key.h
+++ b/src/user/include/knob/key.h
@@ -1,8 +1,16 @@
#ifndef KNOB_KEY_H
#define KNOB_KEY_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <keypack.h>
char key_to_char(struct key_packet kp) __attribute__ ((pure));
+#ifdef __cplusplus
+}
+#endif
+
#endif \ No newline at end of file