rofi 1.7.5
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
49typedef struct TBFontConfig {
51 PangoFontDescription *pfd;
53 PangoFontMetrics *metrics;
55 double height;
61typedef struct {
63 unsigned long flags;
64 short cursor;
65 char *text;
66 const char *placeholder;
68 PangoLayout *layout;
69 int tbft;
70 int markup;
72
73 int blink;
75
76 double yalign;
77 double xalign;
78
80
81 PangoEllipsizeMode emode;
82 //
83 const char *theme_name;
84} textbox;
85
89typedef enum {
90 TB_AUTOHEIGHT = 1 << 0,
91 TB_AUTOWIDTH = 1 << 1,
92 TB_EDITABLE = 1 << 19,
93 TB_MARKUP = 1 << 20,
94 TB_WRAP = 1 << 21,
95 TB_PASSWORD = 1 << 22,
121
137textbox *textbox_create(widget *parent, WidgetType type, const char *name,
139 const char *text, double xalign, double yalign);
146void textbox_font(textbox *tb, TextBoxFontType tbft);
147
154void textbox_text(textbox *tb, const char *text);
155
173gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len);
174
181void textbox_cursor(textbox *tb, int pos);
182
191void textbox_insert(textbox *tb, const int char_pos, const char *str,
192 const int slen);
193
199void textbox_setup(void);
200
204void textbox_cleanup(void);
205
213int textbox_get_height(const textbox *tb);
214
222int textbox_get_font_height(const textbox *tb);
223
231int textbox_get_font_width(const textbox *tb);
232
239
245double textbox_get_estimated_ch(void);
252
260void textbox_delete(textbox *tb, int pos, int dlen);
261
272void textbox_moveresize(textbox *tb, int x, int y, int w, int h);
273
283int textbox_get_estimated_height(const textbox *tb, int eh);
290void textbox_set_pango_context(const char *font, PangoContext *p);
297void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list);
298
306PangoAttrList *textbox_get_pango_attributes(textbox *tb);
307
313const char *textbox_get_visible_text(const textbox *tb);
322int textbox_get_desired_width(widget *wid, const int height);
323
330
337void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode);
339#endif // ROFI_TEXTBOX_H
KeyBindingAction
Definition keyb.h:58
int textbox_get_height(const textbox *tb)
Definition textbox.c:914
void textbox_insert(textbox *tb, const int char_pos, const char *str, const int slen)
Definition textbox.c:658
void textbox_font(textbox *tb, TextBoxFontType tbft)
Definition textbox.c:277
TextboxFlags
Definition textbox.h:89
void textbox_delete(textbox *tb, int pos, int dlen)
Definition textbox.c:682
int textbox_keybinding(textbox *tb, KeyBindingAction action)
Definition textbox.c:771
TextBoxFontType
Definition textbox.h:100
void textbox_cleanup(void)
Definition textbox.c:890
double textbox_get_estimated_char_width(void)
Definition textbox.c:936
int textbox_get_font_height(const textbox *tb)
Definition textbox.c:919
void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list)
Definition textbox.c:350
void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode)
Definition textbox.c:981
void textbox_setup(void)
Definition textbox.c:864
double textbox_get_estimated_char_height(void)
Definition textbox.c:932
struct TBFontConfig TBFontConfig
int textbox_get_desired_width(widget *wid, const int height)
const char * textbox_get_visible_text(const textbox *tb)
Definition textbox.c:338
int textbox_get_estimated_height(const textbox *tb, int eh)
Definition textbox.c:954
void textbox_cursor(textbox *tb, int pos)
Definition textbox.c:543
void textbox_set_pango_context(const char *font, PangoContext *p)
Definition textbox.c:871
textbox * textbox_create(widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign)
Definition textbox.c:186
int textbox_get_font_width(const textbox *tb)
Definition textbox.c:925
void textbox_cursor_end(textbox *tb)
Definition textbox.c:645
gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len)
Definition textbox.c:833
void textbox_moveresize(textbox *tb, int x, int y, int w, int h)
Definition textbox.c:393
PangoAttrList * textbox_get_pango_attributes(textbox *tb)
Definition textbox.c:344
void textbox_text(textbox *tb, const char *text)
Definition textbox.c:358
double textbox_get_estimated_ch(void)
Definition textbox.c:946
@ TB_AUTOHEIGHT
Definition textbox.h:90
@ TB_PASSWORD
Definition textbox.h:95
@ TB_MARKUP
Definition textbox.h:93
@ TB_WRAP
Definition textbox.h:94
@ TB_EDITABLE
Definition textbox.h:92
@ TB_AUTOWIDTH
Definition textbox.h:91
@ SELECTED
Definition textbox.h:108
@ URGENT
Definition textbox.h:104
@ ACTIVE
Definition textbox.h:106
@ HIGHLIGHT
Definition textbox.h:115
@ NORMAL
Definition textbox.h:102
@ STATE_MASK
Definition textbox.h:119
@ ALT
Definition textbox.h:113
@ FMOD_MASK
Definition textbox.h:117
@ MARKUP
Definition textbox.h:110
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 markup
Definition textbox.h:70
const char * placeholder
Definition textbox.h:66
char * text
Definition textbox.h:65
short cursor
Definition textbox.h:64
PangoEllipsizeMode emode
Definition textbox.h:81
double yalign
Definition textbox.h:76
const char * theme_name
Definition textbox.h:83
widget widget
Definition textbox.h:62
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:79
unsigned long flags
Definition textbox.h:63
int changed
Definition textbox.h:71
MenuFlags flags
Definition view.c:107