rofi  1.7.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 #include <xkbcommon/xkbcommon.h>
39 
49 typedef struct TBFontConfig {
51  PangoFontDescription *pfd;
53  PangoFontMetrics *metrics;
55  double height;
61 typedef struct {
63  unsigned long flags;
64  short cursor;
65  char *text;
66  const char *placeholder;
68  PangoLayout *layout;
69  int tbft;
70  int markup;
71  int changed;
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 
89 typedef 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,
96  TB_INDICATOR = 1 << 23,
97 } TextboxFlags;
101 typedef enum {
103  NORMAL = 0,
105  URGENT = 1,
107  ACTIVE = 2,
109  SELECTED = 4,
111  MARKUP = 8,
112 
114  ALT = 16,
116  HIGHLIGHT = 32,
122 
138 textbox *textbox_create(widget *parent, WidgetType type, const char *name,
140  const char *text, double xalign, double yalign);
147 void textbox_font(textbox *tb, TextBoxFontType tbft);
148 
155 void textbox_text(textbox *tb, const char *text);
156 
174 gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len);
175 
182 void textbox_cursor(textbox *tb, int pos);
183 
192 void textbox_insert(textbox *tb, const int char_pos, const char *str,
193  const int slen);
194 
200 void textbox_setup(void);
201 
205 void textbox_cleanup(void);
206 
214 int textbox_get_height(const textbox *tb);
215 
223 int textbox_get_font_height(const textbox *tb);
224 
232 int textbox_get_font_width(const textbox *tb);
233 
240 
246 double textbox_get_estimated_ch(void);
253 
261 void textbox_delete(textbox *tb, int pos, int dlen);
262 
273 void textbox_moveresize(textbox *tb, int x, int y, int w, int h);
274 
284 int textbox_get_estimated_height(const textbox *tb, int eh);
291 void textbox_set_pango_context(const char *font, PangoContext *p);
298 void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list);
299 
307 PangoAttrList *textbox_get_pango_attributes(textbox *tb);
308 
314 const char *textbox_get_visible_text(const textbox *tb);
323 
329 void textbox_cursor_end(textbox *tb);
330 
337 void 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:858
void textbox_insert(textbox *tb, const int char_pos, const char *str, const int slen)
Definition: textbox.c:598
void textbox_font(textbox *tb, TextBoxFontType tbft)
Definition: textbox.c:239
TextboxFlags
Definition: textbox.h:89
void textbox_delete(textbox *tb, int pos, int dlen)
Definition: textbox.c:622
int textbox_keybinding(textbox *tb, KeyBindingAction action)
Definition: textbox.c:713
TextBoxFontType
Definition: textbox.h:101
void textbox_cleanup(void)
Definition: textbox.c:832
double textbox_get_estimated_char_width(void)
Definition: textbox.c:880
int textbox_get_font_height(const textbox *tb)
Definition: textbox.c:863
void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list)
Definition: textbox.c:303
void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode)
Definition: textbox.c:927
void textbox_setup(void)
Definition: textbox.c:806
const char * textbox_get_visible_text(const textbox *tb)
Definition: textbox.c:291
double textbox_get_estimated_char_height(void)
Definition: textbox.c:876
int textbox_get_desired_width(widget *wid)
Definition: textbox.c:902
struct TBFontConfig TBFontConfig
PangoAttrList * textbox_get_pango_attributes(textbox *tb)
Definition: textbox.c:297
textbox * textbox_create(widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign)
Definition: textbox.c:158
int textbox_get_estimated_height(const textbox *tb, int eh)
Definition: textbox.c:898
void textbox_cursor(textbox *tb, int pos)
Definition: textbox.c:483
void textbox_set_pango_context(const char *font, PangoContext *p)
Definition: textbox.c:813
int textbox_get_font_width(const textbox *tb)
Definition: textbox.c:869
void textbox_cursor_end(textbox *tb)
Definition: textbox.c:585
gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len)
Definition: textbox.c:775
void textbox_moveresize(textbox *tb, int x, int y, int w, int h)
Definition: textbox.c:342
void textbox_text(textbox *tb, const char *text)
Definition: textbox.c:311
double textbox_get_estimated_ch(void)
Definition: textbox.c:890
@ TB_INDICATOR
Definition: textbox.h:96
@ 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:109
@ URGENT
Definition: textbox.h:105
@ ACTIVE
Definition: textbox.h:107
@ HIGHLIGHT
Definition: textbox.h:116
@ NORMAL
Definition: textbox.h:103
@ STATE_MASK
Definition: textbox.h:120
@ ALT
Definition: textbox.h:114
@ FMOD_MASK
Definition: textbox.h:118
@ MARKUP
Definition: textbox.h:111
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