rofi  1.6.1
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 <xkbcommon/xkbcommon.h>
32 #include <pango/pango.h>
33 #include <pango/pango-fontmap.h>
34 #include <pango/pangocairo.h>
35 #include <cairo.h>
36 #include "widgets/widget.h"
38 #include "keyb.h"
39 
48 typedef struct TBFontConfig
49 {
51  PangoFontDescription *pfd;
53  PangoFontMetrics *metrics;
55  double height;
61 typedef struct
62 {
64  unsigned long flags;
65  short cursor;
66  char *text;
67  const char *placeholder;
69  PangoLayout *layout;
70  int tbft;
71  int markup;
72  int changed;
73 
74  int blink;
76 
77  double yalign;
78  double xalign;
79 
81 
82  PangoEllipsizeMode emode;
83  //
84  const char *theme_name;
85 } textbox;
86 
90 typedef enum
91 {
92  TB_AUTOHEIGHT = 1 << 0,
93  TB_AUTOWIDTH = 1 << 1,
94  TB_EDITABLE = 1 << 19,
95  TB_MARKUP = 1 << 20,
96  TB_WRAP = 1 << 21,
97  TB_PASSWORD = 1 << 22,
98  TB_INDICATOR = 1 << 23,
99 } TextboxFlags;
103 typedef enum
104 {
106  NORMAL = 0,
108  URGENT = 1,
110  ACTIVE = 2,
112  SELECTED = 4,
114  MARKUP = 8,
115 
117  ALT = 16,
119  HIGHLIGHT = 32,
125 
141 textbox* textbox_create ( widget *parent, WidgetType type, const char *name, TextboxFlags flags,
142  TextBoxFontType tbft, const char *text, double xalign, double yalign );
149 void textbox_font ( textbox *tb, TextBoxFontType tbft );
150 
157 void textbox_text ( textbox *tb, const char *text );
158 
167 int textbox_keybinding ( textbox *tb, KeyBindingAction action );
176 gboolean textbox_append_text ( textbox *tb, const char *pad, const int pad_len );
177 
184 void textbox_cursor ( textbox *tb, int pos );
185 
194 void textbox_insert ( textbox *tb, const int char_pos, const char *str, const int slen );
195 
201 void textbox_setup ( void );
202 
206 void textbox_cleanup ( void );
207 
215 int textbox_get_height ( const textbox *tb );
216 
224 int textbox_get_font_height ( const textbox *tb );
225 
233 int textbox_get_font_width ( const textbox *tb );
234 
240 double textbox_get_estimated_char_width ( void );
241 
247 double textbox_get_estimated_ch ( void );
253 double textbox_get_estimated_char_height ( void );
254 
262 void textbox_delete ( textbox *tb, int pos, int dlen );
263 
274 void textbox_moveresize ( textbox *tb, int x, int y, int w, int h );
275 
285 int textbox_get_estimated_height ( const textbox *tb, int eh );
292 void textbox_set_pango_context ( const char *font, PangoContext *p );
299 void textbox_set_pango_attributes ( textbox *tb, PangoAttrList *list );
300 
308 PangoAttrList *textbox_get_pango_attributes ( textbox *tb );
309 
315 const char *textbox_get_visible_text ( const textbox *tb );
323 int textbox_get_desired_width ( widget *wid );
324 
330 void textbox_cursor_end ( textbox *tb );
331 
338 void textbox_set_ellipsize ( textbox *tb, PangoEllipsizeMode mode );
340 #endif //ROFI_TEXTBOX_H
void textbox_cursor_end(textbox *tb)
Definition: textbox.c:582
PangoFontMetrics * metrics
Definition: textbox.h:53
int blink
Definition: textbox.h:74
WidgetType
Definition: widget.h:56
void textbox_cleanup(void)
Definition: textbox.c:841
guint blink_timeout
Definition: textbox.h:75
void textbox_setup(void)
Definition: textbox.c:815
unsigned long flags
Definition: textbox.h:64
void textbox_text(textbox *tb, const char *text)
Definition: textbox.c:312
double textbox_get_estimated_char_width(void)
Definition: textbox.c:895
int markup
Definition: textbox.h:71
TBFontConfig * tbfc
Definition: textbox.h:80
double yalign
Definition: textbox.h:77
widget widget
Definition: textbox.h:63
void textbox_font(textbox *tb, TextBoxFontType tbft)
Definition: textbox.c:232
char * text
Definition: textbox.h:66
textbox * textbox_create(widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign)
Definition: textbox.c:162
void textbox_cursor(textbox *tb, int pos)
Definition: textbox.c:479
double height
Definition: textbox.h:55
Definition: textbox.h:117
int textbox_get_font_width(const textbox *tb)
Definition: textbox.c:880
int changed
Definition: textbox.h:72
short cursor
Definition: textbox.h:65
TextboxFlags
Definition: textbox.h:90
double textbox_get_estimated_ch(void)
Definition: textbox.c:906
int textbox_keybinding(textbox *tb, KeyBindingAction action)
Definition: textbox.c:719
const char * textbox_get_visible_text(const textbox *tb)
Definition: textbox.c:289
TextBoxFontType
Definition: textbox.h:103
const char * theme_name
Definition: textbox.h:84
void textbox_moveresize(textbox *tb, int x, int y, int w, int h)
Definition: textbox.c:345
int tbft
Definition: textbox.h:70
KeyBindingAction
Definition: keyb.h:58
void textbox_insert(textbox *tb, const int char_pos, const char *str, const int slen)
Definition: textbox.c:596
int textbox_get_height(const textbox *tb)
Definition: textbox.c:868
void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode)
Definition: textbox.c:945
MenuFlags flags
Definition: view.c:108
double xalign
Definition: textbox.h:78
const char * placeholder
Definition: textbox.h:67
PangoFontDescription * pfd
Definition: textbox.h:51
PangoAttrList * textbox_get_pango_attributes(textbox *tb)
Definition: textbox.c:296
int textbox_get_estimated_height(const textbox *tb, int eh)
Definition: textbox.c:915
struct TBFontConfig TBFontConfig
int textbox_get_font_height(const textbox *tb)
Definition: textbox.c:873
int show_placeholder
Definition: textbox.h:68
int textbox_get_desired_width(widget *wid)
Definition: textbox.c:920
double textbox_get_estimated_char_height(void)
Definition: textbox.c:888
PangoLayout * layout
Definition: textbox.h:69
void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list)
Definition: textbox.c:303
void textbox_delete(textbox *tb, int pos, int dlen)
Definition: textbox.c:620
gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len)
Definition: textbox.c:783
PangoEllipsizeMode emode
Definition: textbox.h:82
void textbox_set_pango_context(const char *font, PangoContext *p)
Definition: textbox.c:822