rofi 1.7.9
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#include <xkbcommon/xkbcommon.h>
39
46
49typedef struct TBFontConfig {
51 PangoFontDescription *pfd;
53 PangoFontMetrics *metrics;
55 double height;
61typedef struct {
63 unsigned long flags;
64 short cursor;
65 char *text;
68 PangoLayout *layout;
69 int tbft;
70 int markup;
72
73 int blink;
75
76 double yalign;
77 double xalign;
78
80
82
83 PangoEllipsizeMode emode;
84
85 const char *password_mask_char;
86
87 const char *theme_name;
88} textbox;
89
93typedef enum {
94 TB_AUTOHEIGHT = 1 << 0,
95 TB_AUTOWIDTH = 1 << 1,
96 TB_EDITABLE = 1 << 19,
97 TB_MARKUP = 1 << 20,
98 TB_WRAP = 1 << 21,
99 TB_PASSWORD = 1 << 22,
101
125
141textbox *textbox_create(widget *parent, WidgetType type, const char *name,
143 const char *text, double xalign, double yalign);
150void textbox_font(textbox *tb, TextBoxFontType tbft);
151
158void textbox_text(textbox *tb, const char *text);
159
177gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len);
178
185void textbox_cursor(textbox *tb, int pos);
186
195void textbox_insert(textbox *tb, const int char_pos, const char *str,
196 const int slen);
197
203void textbox_setup(void);
204
208void textbox_cleanup(void);
209
217int textbox_get_height(const textbox *tb);
218
226int textbox_get_font_height(const textbox *tb);
227
235int textbox_get_font_width(const textbox *tb);
236
243
249double textbox_get_estimated_ch(void);
256
264void textbox_delete(textbox *tb, int pos, int dlen);
265
276void textbox_moveresize(textbox *tb, int x, int y, int w, int h);
277
287int textbox_get_estimated_height(const textbox *tb, int eh);
294void textbox_set_pango_context(const char *font, PangoContext *p);
301void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list);
302
310PangoAttrList *textbox_get_pango_attributes(textbox *tb);
311
317const char *textbox_get_visible_text(const textbox *tb);
318
327int textbox_get_desired_width(widget *wid, G_GNUC_UNUSED const int height);
328
335
342void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode);
343
349int textbox_get_cursor_x_pos(const textbox *tb);
350
356char *textbox_get_text(const textbox *tb);
357
363int textbox_get_cursor(const textbox *tb);
365#endif // ROFI_TEXTBOX_H
KeyBindingAction
Definition keyb.h:58
int textbox_get_height(const textbox *tb)
Definition textbox.c:1023
void textbox_insert(textbox *tb, const int char_pos, const char *str, const int slen)
Definition textbox.c:752
void textbox_font(textbox *tb, TextBoxFontType tbft)
Definition textbox.c:308
TextboxFlags
Definition textbox.h:93
void textbox_delete(textbox *tb, int pos, int dlen)
Definition textbox.c:776
int textbox_keybinding(textbox *tb, KeyBindingAction action)
Definition textbox.c:865
TextBoxFontType
Definition textbox.h:104
void textbox_cleanup(void)
Definition textbox.c:999
double textbox_get_estimated_char_width(void)
Definition textbox.c:1045
int textbox_get_font_height(const textbox *tb)
Definition textbox.c:1028
void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list)
Definition textbox.c:384
void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode)
Definition textbox.c:1090
int textbox_get_desired_width(widget *wid, G_GNUC_UNUSED const int height)
Definition textbox.c:1067
void textbox_setup(void)
Definition textbox.c:967
double textbox_get_estimated_char_height(void)
Definition textbox.c:1041
const char * textbox_get_visible_text(const textbox *tb)
Definition textbox.c:372
int textbox_get_cursor(const textbox *tb)
Definition textbox.c:397
int textbox_get_estimated_height(const textbox *tb, int eh)
Definition textbox.c:1063
void textbox_cursor(textbox *tb, int pos)
Definition textbox.c:637
void textbox_set_pango_context(const char *font, PangoContext *p)
Definition textbox.c:974
textbox * textbox_create(widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign)
Definition textbox.c:204
int textbox_get_font_width(const textbox *tb)
Definition textbox.c:1034
void textbox_cursor_end(textbox *tb)
Definition textbox.c:739
gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len)
Definition textbox.c:927
void textbox_moveresize(textbox *tb, int x, int y, int w, int h)
Definition textbox.c:439
PangoAttrList * textbox_get_pango_attributes(textbox *tb)
Definition textbox.c:378
void textbox_text(textbox *tb, const char *text)
Definition textbox.c:404
double textbox_get_estimated_ch(void)
Definition textbox.c:1055
int textbox_get_cursor_x_pos(const textbox *tb)
Definition textbox.c:1100
char * textbox_get_text(const textbox *tb)
Definition textbox.c:391
@ TB_AUTOHEIGHT
Definition textbox.h:94
@ TB_PASSWORD
Definition textbox.h:99
@ TB_MARKUP
Definition textbox.h:97
@ TB_WRAP
Definition textbox.h:98
@ TB_EDITABLE
Definition textbox.h:96
@ TB_AUTOWIDTH
Definition textbox.h:95
@ SELECTED
Definition textbox.h:112
@ URGENT
Definition textbox.h:108
@ ACTIVE
Definition textbox.h:110
@ HIGHLIGHT
Definition textbox.h:119
@ NORMAL
Definition textbox.h:106
@ STATE_MASK
Definition textbox.h:123
@ ALT
Definition textbox.h:117
@ FMOD_MASK
Definition textbox.h:121
@ MARKUP
Definition textbox.h:114
struct _widget widget
Definition widget.h:51
WidgetType
Definition widget.h:56
double height
Definition textbox.h:55
PangoFontMetrics * metrics
Definition textbox.h:53
PangoFontDescription * pfd
Definition textbox.h:51
int blink
Definition textbox.h:73
int cursor_x_pos
Definition textbox.h:79
int markup
Definition textbox.h:70
char * text
Definition textbox.h:65
short cursor
Definition textbox.h:64
PangoEllipsizeMode emode
Definition textbox.h:83
double yalign
Definition textbox.h:76
const char * theme_name
Definition textbox.h:87
widget widget
Definition textbox.h:62
const char * password_mask_char
Definition textbox.h:85
int tbft
Definition textbox.h:69
double xalign
Definition textbox.h:77
guint blink_timeout
Definition textbox.h:74
int show_placeholder
Definition textbox.h:67
PangoLayout * layout
Definition textbox.h:68
TBFontConfig * tbfc
Definition textbox.h:81
unsigned long flags
Definition textbox.h:63
char * placeholder
Definition textbox.h:66
int changed
Definition textbox.h:71
MenuFlags flags
Definition view.c:127