rofi 2.0.0
textbox.h
Go to the documentation of this file.
1/*
2 * rofi
3 *
4 * MIT/X11 License
5 * Copyright © 2013-2017 Qball Cow <qball@gmpclient.org>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 */
27
28#ifndef ROFI_TEXTBOX_H
29#define ROFI_TEXTBOX_H
30
31#include "keyb.h"
33#include "widgets/widget.h"
34#include <cairo.h>
35#include <pango/pango-fontmap.h>
36#include <pango/pango.h>
37#include <pango/pangocairo.h>
38
45
48typedef struct TBFontConfig {
50 PangoFontDescription *pfd;
52 PangoFontMetrics *metrics;
54 double height;
60typedef struct {
62 unsigned long flags;
63 short cursor;
64 char *text;
67 PangoLayout *layout;
68 int tbft;
69 int markup;
71
72 int blink;
74
75 double yalign;
76 double xalign;
77
79
81
82 PangoEllipsizeMode emode;
83
84 const char *password_mask_char;
85
86 const char *theme_name;
87} textbox;
88
92typedef enum {
93 TB_AUTOHEIGHT = 1 << 0,
94 TB_AUTOWIDTH = 1 << 1,
95 TB_EDITABLE = 1 << 19,
96 TB_MARKUP = 1 << 20,
97 TB_WRAP = 1 << 21,
98 TB_PASSWORD = 1 << 22,
100
124
140textbox *textbox_create(widget *parent, WidgetType type, const char *name,
142 const char *text, double xalign, double yalign);
149void textbox_font(textbox *tb, TextBoxFontType tbft);
150
157void textbox_text(textbox *tb, const char *text);
158
176gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len);
177
184void textbox_cursor(textbox *tb, int pos);
185
194void textbox_insert(textbox *tb, const int char_pos, const char *str,
195 const int slen);
196
202void textbox_setup(void);
203
207void textbox_cleanup(void);
208
216int textbox_get_height(const textbox *tb);
217
225int textbox_get_font_height(const textbox *tb);
226
234int textbox_get_font_width(const textbox *tb);
235
242
248double textbox_get_estimated_ch(void);
255
263void textbox_delete(textbox *tb, int pos, int dlen);
264
275void textbox_moveresize(textbox *tb, int x, int y, int w, int h);
276
286int textbox_get_estimated_height(const textbox *tb, int eh);
293void textbox_set_pango_context(const char *font, PangoContext *p);
300void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list);
301
309PangoAttrList *textbox_get_pango_attributes(textbox *tb);
310
316const char *textbox_get_visible_text(const textbox *tb);
317
326int textbox_get_desired_width(widget *wid, G_GNUC_UNUSED const int height);
327
334
341void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode);
342
348int textbox_get_cursor_x_pos(const textbox *tb);
349
355char *textbox_get_text(const textbox *tb);
356
362int textbox_get_cursor(const textbox *tb);
364#endif // ROFI_TEXTBOX_H
KeyBindingAction
Definition keyb.h:58
int textbox_get_height(const textbox *tb)
Definition textbox.c:1022
void textbox_insert(textbox *tb, const int char_pos, const char *str, const int slen)
Definition textbox.c:751
void textbox_font(textbox *tb, TextBoxFontType tbft)
Definition textbox.c:307
TextboxFlags
Definition textbox.h:92
void textbox_delete(textbox *tb, int pos, int dlen)
Definition textbox.c:775
int textbox_keybinding(textbox *tb, KeyBindingAction action)
Definition textbox.c:864
TextBoxFontType
Definition textbox.h:103
void textbox_cleanup(void)
Definition textbox.c:998
double textbox_get_estimated_char_width(void)
Definition textbox.c:1044
int textbox_get_font_height(const textbox *tb)
Definition textbox.c:1027
void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list)
Definition textbox.c:383
void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode)
Definition textbox.c:1089
int textbox_get_desired_width(widget *wid, G_GNUC_UNUSED const int height)
Definition textbox.c:1066
void textbox_setup(void)
Definition textbox.c:966
double textbox_get_estimated_char_height(void)
Definition textbox.c:1040
const char * textbox_get_visible_text(const textbox *tb)
Definition textbox.c:371
int textbox_get_cursor(const textbox *tb)
Definition textbox.c:396
int textbox_get_estimated_height(const textbox *tb, int eh)
Definition textbox.c:1062
void textbox_cursor(textbox *tb, int pos)
Definition textbox.c:636
void textbox_set_pango_context(const char *font, PangoContext *p)
Definition textbox.c:973
textbox * textbox_create(widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign)
Definition textbox.c:203
int textbox_get_font_width(const textbox *tb)
Definition textbox.c:1033
void textbox_cursor_end(textbox *tb)
Definition textbox.c:738
gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len)
Definition textbox.c:926
void textbox_moveresize(textbox *tb, int x, int y, int w, int h)
Definition textbox.c:438
PangoAttrList * textbox_get_pango_attributes(textbox *tb)
Definition textbox.c:377
void textbox_text(textbox *tb, const char *text)
Definition textbox.c:403
double textbox_get_estimated_ch(void)
Definition textbox.c:1054
int textbox_get_cursor_x_pos(const textbox *tb)
Definition textbox.c:1099
char * textbox_get_text(const textbox *tb)
Definition textbox.c:390
@ TB_AUTOHEIGHT
Definition textbox.h:93
@ TB_PASSWORD
Definition textbox.h:98
@ TB_MARKUP
Definition textbox.h:96
@ TB_WRAP
Definition textbox.h:97
@ TB_EDITABLE
Definition textbox.h:95
@ TB_AUTOWIDTH
Definition textbox.h:94
@ SELECTED
Definition textbox.h:111
@ URGENT
Definition textbox.h:107
@ ACTIVE
Definition textbox.h:109
@ HIGHLIGHT
Definition textbox.h:118
@ NORMAL
Definition textbox.h:105
@ STATE_MASK
Definition textbox.h:122
@ ALT
Definition textbox.h:116
@ FMOD_MASK
Definition textbox.h:120
@ MARKUP
Definition textbox.h:113
struct _widget widget
Definition widget.h:49
WidgetType
Definition widget.h:54
double height
Definition textbox.h:54
PangoFontMetrics * metrics
Definition textbox.h:52
PangoFontDescription * pfd
Definition textbox.h:50
int blink
Definition textbox.h:72
int cursor_x_pos
Definition textbox.h:78
int markup
Definition textbox.h:69
char * text
Definition textbox.h:64
short cursor
Definition textbox.h:63
PangoEllipsizeMode emode
Definition textbox.h:82
double yalign
Definition textbox.h:75
const char * theme_name
Definition textbox.h:86
widget widget
Definition textbox.h:61
const char * password_mask_char
Definition textbox.h:84
int tbft
Definition textbox.h:68
double xalign
Definition textbox.h:76
guint blink_timeout
Definition textbox.h:73
int show_placeholder
Definition textbox.h:66
PangoLayout * layout
Definition textbox.h:67
TBFontConfig * tbfc
Definition textbox.h:80
unsigned long flags
Definition textbox.h:62
char * placeholder
Definition textbox.h:65
int changed
Definition textbox.h:70
MenuFlags flags
Definition view.c:72