rofi  1.6.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 <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 
50 typedef struct
51 {
53  unsigned long flags;
54  short cursor;
55  char *text;
56  const char *placeholder;
58  PangoLayout *layout;
59  int tbft;
60  int markup;
61  int changed;
62 
63  int blink;
65 
66  double yalign;
67  double xalign;
68 
69  PangoFontMetrics *metrics;
70  PangoEllipsizeMode emode;
71  //
72  const char *theme_name;
73 } textbox;
74 
78 typedef enum
79 {
80  TB_AUTOHEIGHT = 1 << 0,
81  TB_AUTOWIDTH = 1 << 1,
82  TB_EDITABLE = 1 << 19,
83  TB_MARKUP = 1 << 20,
84  TB_WRAP = 1 << 21,
85  TB_PASSWORD = 1 << 22,
86  TB_INDICATOR = 1 << 23,
87 } TextboxFlags;
91 typedef enum
92 {
94  NORMAL = 0,
96  URGENT = 1,
98  ACTIVE = 2,
100  SELECTED = 4,
102  MARKUP = 8,
103 
105  ALT = 16,
107  HIGHLIGHT = 32,
113 
129 textbox* textbox_create ( widget *parent, WidgetType type, const char *name, TextboxFlags flags,
130  TextBoxFontType tbft, const char *text, double xalign, double yalign );
137 void textbox_font ( textbox *tb, TextBoxFontType tbft );
138 
145 void textbox_text ( textbox *tb, const char *text );
146 
155 int textbox_keybinding ( textbox *tb, KeyBindingAction action );
164 gboolean textbox_append_text ( textbox *tb, const char *pad, const int pad_len );
165 
172 void textbox_cursor ( textbox *tb, int pos );
173 
182 void textbox_insert ( textbox *tb, const int char_pos, const char *str, const int slen );
183 
189 void textbox_setup ( void );
190 
194 void textbox_cleanup ( void );
195 
203 int textbox_get_height ( const textbox *tb );
204 
212 int textbox_get_font_height ( const textbox *tb );
213 
221 int textbox_get_font_width ( const textbox *tb );
222 
228 double textbox_get_estimated_char_width ( void );
229 
235 double textbox_get_estimated_ch ( void );
241 double textbox_get_estimated_char_height ( void );
242 
250 void textbox_delete ( textbox *tb, int pos, int dlen );
251 
262 void textbox_moveresize ( textbox *tb, int x, int y, int w, int h );
263 
273 int textbox_get_estimated_height ( const textbox *tb, int eh );
280 void textbox_set_pango_context ( const char *font, PangoContext *p );
287 void textbox_set_pango_attributes ( textbox *tb, PangoAttrList *list );
288 
296 PangoAttrList *textbox_get_pango_attributes ( textbox *tb );
297 
303 const char *textbox_get_visible_text ( const textbox *tb );
311 int textbox_get_desired_width ( widget *wid );
312 
318 void textbox_cursor_end ( textbox *tb );
319 
326 void textbox_set_ellipsize ( textbox *tb, PangoEllipsizeMode mode );
328 #endif //ROFI_TEXTBOX_H
void textbox_cursor_end(textbox *tb)
Definition: textbox.c:584
Definition: textbox.h:98
int blink
Definition: textbox.h:63
WidgetType
Definition: widget.h:56
void textbox_cleanup(void)
Definition: textbox.c:835
guint blink_timeout
Definition: textbox.h:64
void textbox_setup(void)
Definition: textbox.c:817
unsigned long flags
Definition: textbox.h:53
void textbox_text(textbox *tb, const char *text)
Definition: textbox.c:314
double textbox_get_estimated_char_width(void)
Definition: textbox.c:894
int markup
Definition: textbox.h:60
double yalign
Definition: textbox.h:66
widget widget
Definition: textbox.h:52
void textbox_font(textbox *tb, TextBoxFontType tbft)
Definition: textbox.c:234
char * text
Definition: textbox.h:55
textbox * textbox_create(widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign)
Definition: textbox.c:164
void textbox_cursor(textbox *tb, int pos)
Definition: textbox.c:481
Definition: textbox.h:105
int textbox_get_font_width(const textbox *tb)
Definition: textbox.c:874
int changed
Definition: textbox.h:61
PangoFontMetrics * metrics
Definition: textbox.h:69
short cursor
Definition: textbox.h:54
TextboxFlags
Definition: textbox.h:78
double textbox_get_estimated_ch(void)
Definition: textbox.c:905
int textbox_keybinding(textbox *tb, KeyBindingAction action)
Definition: textbox.c:721
const char * textbox_get_visible_text(const textbox *tb)
Definition: textbox.c:291
TextBoxFontType
Definition: textbox.h:91
Definition: textbox.h:94
const char * theme_name
Definition: textbox.h:72
Definition: textbox.h:96
void textbox_moveresize(textbox *tb, int x, int y, int w, int h)
Definition: textbox.c:347
int tbft
Definition: textbox.h:59
KeyBindingAction
Definition: keyb.h:58
void textbox_insert(textbox *tb, const int char_pos, const char *str, const int slen)
Definition: textbox.c:598
int textbox_get_height(const textbox *tb)
Definition: textbox.c:862
void textbox_set_ellipsize(textbox *tb, PangoEllipsizeMode mode)
Definition: textbox.c:944
MenuFlags flags
Definition: view.c:108
double xalign
Definition: textbox.h:67
const char * placeholder
Definition: textbox.h:56
PangoAttrList * textbox_get_pango_attributes(textbox *tb)
Definition: textbox.c:298
int textbox_get_estimated_height(const textbox *tb, int eh)
Definition: textbox.c:914
int textbox_get_font_height(const textbox *tb)
Definition: textbox.c:867
int show_placeholder
Definition: textbox.h:57
int textbox_get_desired_width(widget *wid)
Definition: textbox.c:919
double textbox_get_estimated_char_height(void)
Definition: textbox.c:883
PangoLayout * layout
Definition: textbox.h:58
void textbox_set_pango_attributes(textbox *tb, PangoAttrList *list)
Definition: textbox.c:305
void textbox_delete(textbox *tb, int pos, int dlen)
Definition: textbox.c:622
gboolean textbox_append_text(textbox *tb, const char *pad, const int pad_len)
Definition: textbox.c:785
PangoEllipsizeMode emode
Definition: textbox.h:70
void textbox_set_pango_context(const char *font, PangoContext *p)
Definition: textbox.c:824