9#ifndef GP_WIDGET_TBOX_H
10#define GP_WIDGET_TBOX_H
15enum gp_widget_tbox_type {
19 GP_WIDGET_TBOX_HIDDEN,
25 GP_WIDGET_TBOX_FILENAME,
30struct gp_widget_tbox {
58 uint16_t clear_on_input:1;
72 gp_widget_tattr tattr;
77 uint32_t click_cursor_x;
85enum gp_widget_tbox_event_type {
87 GP_WIDGET_TBOX_TRIGGER,
89 GP_WIDGET_TBOX_PRE_FILTER,
91 GP_WIDGET_TBOX_POST_FILTER,
105 GP_WIDGET_TBOX_PASTE,
108#define GP_TBOX_FILTER_INT "0123456789"
109#define GP_TBOX_FILTER_HEX "0123456789abcdefABCDEF"
124gp_widget *gp_widget_tbox_new(
const char *text, gp_widget_tattr tattr,
125 unsigned int len,
unsigned int max_len,
126 const char *filter,
enum gp_widget_tbox_type type);
137int gp_widget_tbox_printf(gp_widget *self,
const char *fmt, ...)
138 __attribute__((format (printf, 2, 3)));
147void gp_widget_tbox_set(gp_widget *self, const
char *str);
154void gp_widget_tbox_clear(gp_widget *self);
162const
char *gp_widget_tbox_text(gp_widget *self);
171static inline
int gp_widget_tbox_is_empty(gp_widget *self)
173 const char *text = gp_widget_tbox_text(self);
175 if (!text || !text[0])
187gp_utf8_pos gp_widget_tbox_cursor_get(gp_widget *self);
200void gp_widget_tbox_cursor_set(gp_widget *self, ssize_t off,
216void gp_widget_tbox_ins(gp_widget *self, ssize_t off,
225static inline void gp_widget_tbox_append(gp_widget *self,
const char *str)
227 gp_widget_tbox_ins(self, 0, GP_SEEK_CUR, str);
243void gp_widget_tbox_del(gp_widget *self, ssize_t off,
256void gp_widget_tbox_sel_set(gp_widget *self, ssize_t off,
266void gp_widget_tbox_sel_all(gp_widget *self);
273void gp_widget_tbox_sel_clr(gp_widget *self);
280void gp_widget_tbox_sel_del(gp_widget *self);
290gp_utf8_pos gp_widget_tbox_sel_len(gp_widget *self);
300gp_utf8_pos gp_widget_tbox_sel_off(gp_widget *self);
307static inline int gp_widget_tbox_sel(gp_widget *self)
309 return !!gp_widget_tbox_sel_len(self).
bytes;
323void gp_widget_tbox_sel_delim_set(gp_widget *self,
const char *delim);
336void gp_widget_tbox_type_set(gp_widget *self,
enum gp_widget_tbox_type type);
346void gp_widget_tbox_help_set(gp_widget *self,
const char *help);
353void gp_widget_tbox_clear_on_input(gp_widget *self);
Seek contants and transformations.
gp_seek_whence
Seek constants.
An iterator for an UTF-8 string.
Position in an UTF-8 string.