rofi  1.5.4
Textbox
Collaboration diagram for Textbox:

Data Structures

struct  textbox
 

Enumerations

enum  TextboxFlags {
  TB_AUTOHEIGHT = 1 << 0, TB_AUTOWIDTH = 1 << 1, TB_EDITABLE = 1 << 19, TB_MARKUP = 1 << 20,
  TB_WRAP = 1 << 21, TB_PASSWORD = 1 << 22, TB_INDICATOR = 1 << 23, TB_ICON = 1 << 24
}
 
enum  TextBoxFontType {
  NORMAL = 0, URGENT = 1, ACTIVE = 2, SELECTED = 4,
  MARKUP = 8, ALT = 16, HIGHLIGHT = 32, FMOD_MASK = ( ALT | HIGHLIGHT ),
  STATE_MASK = ~( SELECTED | MARKUP | ALT | HIGHLIGHT )
}
 

Functions

textboxtextbox_create (widget *parent, WidgetType type, const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text, double xalign, double yalign)
 
void textbox_font (textbox *tb, TextBoxFontType tbft)
 
void textbox_text (textbox *tb, const char *text)
 
void textbox_icon (textbox *tb, cairo_surface_t *icon)
 
int textbox_keybinding (textbox *tb, KeyBindingAction action)
 
gboolean textbox_append_text (textbox *tb, const char *pad, const int pad_len)
 
void textbox_cursor (textbox *tb, int pos)
 
void textbox_insert (textbox *tb, const int char_pos, const char *str, const int slen)
 
void textbox_setup (void)
 
void textbox_cleanup (void)
 
int textbox_get_height (const textbox *tb)
 
int textbox_get_font_height (const textbox *tb)
 
int textbox_get_font_width (const textbox *tb)
 
double textbox_get_estimated_char_width (void)
 
double textbox_get_estimated_ch (void)
 
double textbox_get_estimated_char_height (void)
 
void textbox_delete (textbox *tb, int pos, int dlen)
 
void textbox_moveresize (textbox *tb, int x, int y, int w, int h)
 
int textbox_get_estimated_height (const textbox *tb, int eh)
 
void textbox_set_pango_context (const char *font, PangoContext *p)
 
void textbox_set_pango_attributes (textbox *tb, PangoAttrList *list)
 
void textbox_set_icon_index (textbox *tb, int index)
 
PangoAttrList * textbox_get_pango_attributes (textbox *tb)
 
const char * textbox_get_visible_text (const textbox *tb)
 
int textbox_get_desired_width (widget *wid)
 
void textbox_cursor_end (textbox *tb)
 
void textbox_set_ellipsize (textbox *tb, PangoEllipsizeMode mode)
 

Variables

widget textbox::widget
 
unsigned long textbox::flags
 
short textbox::cursor
 
char * textbox::text
 
PangoLayout * textbox::layout
 
int textbox::tbft
 
int textbox::markup
 
int textbox::changed
 
cairo_surface_t * textbox::icon
 
int textbox::icon_index
 
int textbox::blink
 
guint textbox::blink_timeout
 
double textbox::yalign
 
double textbox::xalign
 
PangoFontMetrics * textbox::metrics
 
PangoEllipsizeMode textbox::emode
 
int textbox::left_offset
 
const char * textbox::theme_name
 

Detailed Description

Enumeration Type Documentation

◆ TextboxFlags

Flags for configuring textbox behaviour and looks during creation.

Enumerator
TB_AUTOHEIGHT 
TB_AUTOWIDTH 
TB_EDITABLE 
TB_MARKUP 
TB_WRAP 
TB_PASSWORD 
TB_INDICATOR 
TB_ICON 

Definition at line 80 of file textbox.h.

◆ TextBoxFontType

Flags indicating current state of the textbox.

Enumerator
NORMAL 

Normal

URGENT 

Text in box is urgent.

ACTIVE 

Text in box is active.

SELECTED 

Text in box is selected.

MARKUP 

Text in box has pango markup.

ALT 

Text is on an alternate row

HIGHLIGHT 

Render font highlighted (inverted colors.)

FMOD_MASK 

Mask for alternate and highlighted

STATE_MASK 

Mask of bits indicating state

Definition at line 94 of file textbox.h.

Function Documentation

◆ textbox_append_text()

gboolean textbox_append_text ( textbox tb,
const char *  pad,
const int  pad_len 
)
Parameters
tbHandle to the textbox
padThe text to insert
pad_lenthe length of the text

The text should be one insert from a keypress.. the first gunichar is validated to be (or not) control return TRUE if inserted

Definition at line 801 of file textbox.c.

References textbox::cursor, textbox::flags, TB_EDITABLE, textbox_cursor(), and textbox_insert().

Referenced by rofi_view_handle_text().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_cleanup()

void textbox_cleanup ( void  )

Cleanup the allocated colors and fonts by textbox_setup().

Definition at line 851 of file textbox.c.

References p_context, and tbfc_cache.

Referenced by teardown().

Here is the caller graph for this function:

◆ textbox_create()

textbox* textbox_create ( widget parent,
WidgetType  type,
const char *  name,
TextboxFlags  flags,
TextBoxFontType  tbft,
const char *  text,
double  xalign,
double  yalign 
)

◆ textbox_cursor()

void textbox_cursor ( textbox tb,
int  pos 
)
Parameters
tbHandle to the textbox
posNew cursor position

Set the cursor position (string index)

Definition at line 497 of file textbox.c.

References textbox::blink, textbox::cursor, textbox::text, WIDGET, and widget_queue_redraw().

Referenced by textbox_append_text(), textbox_cursor_dec(), textbox_cursor_dec_word(), textbox_cursor_inc(), textbox_cursor_inc_word(), textbox_editable_trigger_action(), and textbox_keybinding().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_cursor_end()

void textbox_cursor_end ( textbox tb)
Parameters
tbHandle to the textbox

Move the cursor to the end of the string.

Definition at line 600 of file textbox.c.

References textbox::blink, textbox::cursor, textbox::text, WIDGET, and widget_queue_redraw().

Referenced by rofi_view_create(), textbox_create(), textbox_editable_trigger_action(), and textbox_keybinding().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_delete()

void textbox_delete ( textbox tb,
int  pos,
int  dlen 
)
Parameters
tbHandle to the textbox
posThe start position
dlenThe length

Remove dlen bytes from position pos.

Definition at line 638 of file textbox.c.

References textbox::blink, textbox::changed, textbox::cursor, and textbox::text.

Referenced by textbox_cursor_bkspc_word(), textbox_cursor_del(), textbox_cursor_del_eol(), textbox_cursor_del_sol(), and textbox_cursor_del_word().

Here is the caller graph for this function:

◆ textbox_font()

void textbox_font ( textbox tb,
TextBoxFontType  tbft 
)
Parameters
tbHandle to the textbox
tbftThe style of font to render.

Set the font render style.

Definition at line 231 of file textbox.c.

References ACTIVE, ALT, FMOD_MASK, HIGHLIGHT, _widget::state, STATE_MASK, textbox::tbft, theme_prop_names, URGENT, textbox::widget, WIDGET, widget_queue_redraw(), and widget_set_state().

Referenced by rofi_view_switch_mode(), textbox_create(), and update_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_get_desired_width()

int textbox_get_desired_width ( widget wid)
Parameters
widThe handle to the textbox.

TODO: is this deprecated by widget::get_desired_width

Returns
the desired width of the textbox.

Definition at line 935 of file textbox.c.

References distance_get_pixel(), DOT_OFFSET, _widget::expand, textbox::flags, textbox::layout, textbox::left_offset, ROFI_ORIENTATION_HORIZONTAL, rofi_theme_get_distance(), TB_AUTOWIDTH, TB_INDICATOR, textbox_get_font_width(), WIDGET, widget_padding_get_left(), widget_padding_get_padding_width(), and widget_padding_get_right().

Referenced by barview_draw(), and textbox_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_get_estimated_ch()

double textbox_get_estimated_ch ( void  )

Estimate the width of a 0.

Returns
the width of a 0 in pixels.

Definition at line 921 of file textbox.c.

References ch_width, and p_metrics.

Referenced by distance_get_pixel().

Here is the caller graph for this function:

◆ textbox_get_estimated_char_height()

double textbox_get_estimated_char_height ( void  )

Estimate the height of a character.

Returns
the height of a character in pixels.

Definition at line 899 of file textbox.c.

References char_height, and p_metrics.

Referenced by distance_get_pixel(), and textbox_initialize_font().

Here is the caller graph for this function:

◆ textbox_get_estimated_char_width()

double textbox_get_estimated_char_width ( void  )

Estimate the width of a character.

Returns
the width of a character in pixels.

Definition at line 910 of file textbox.c.

References char_width, and p_metrics.

Referenced by rofi_view_calculate_window_width().

Here is the caller graph for this function:

◆ textbox_get_estimated_height()

int textbox_get_estimated_height ( const textbox tb,
int  eh 
)
Parameters
tbHandle to the textbox
ehThe number of rows to display

Get the (estimated) with of a character, can be used to calculate window width. This includes padding.

Returns
the estimated width of a character.

Definition at line 930 of file textbox.c.

References textbox::metrics, WIDGET, and widget_padding_get_padding_height().

Referenced by listview_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_get_font_height()

int textbox_get_font_height ( const textbox tb)
Parameters
tbHandle to the textbox

Get the height of the rendered string.

Returns
the height of the string in pixels.

Definition at line 883 of file textbox.c.

References textbox::layout.

Referenced by textbox_get_height(), and update_callback().

Here is the caller graph for this function:

◆ textbox_get_font_width()

int textbox_get_font_width ( const textbox tb)
Parameters
tbHandle to the textbox

Get the width of the rendered string.

Returns
the width of the string in pixels.

Definition at line 890 of file textbox.c.

References textbox::layout.

Referenced by textbox_editable_trigger_action(), textbox_get_desired_width(), textbox_get_width(), and textbox_moveresize().

Here is the caller graph for this function:

◆ textbox_get_height()

int textbox_get_height ( const textbox tb)
Parameters
tbHandle to the textbox

Get the height of the textbox

Returns
the height of the textbox in pixels.

Definition at line 878 of file textbox.c.

References textbox_get_font_height(), WIDGET, and widget_padding_get_padding_height().

Referenced by _textbox_get_height(), textbox_get_desired_height(), and textbox_moveresize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_get_pango_attributes()

PangoAttrList* textbox_get_pango_attributes ( textbox tb)
Parameters
tbHandle to the textbox

Get the list of currently active pango attributes.

Returns
the pango attributes

Definition at line 289 of file textbox.c.

References textbox::layout.

Referenced by update_callback().

Here is the caller graph for this function:

◆ textbox_get_visible_text()

const char* textbox_get_visible_text ( const textbox tb)
Parameters
tbHandle to the textbox
Returns
the visible text.

Definition at line 282 of file textbox.c.

References textbox::layout.

Referenced by update_callback().

Here is the caller graph for this function:

◆ textbox_icon()

void textbox_icon ( textbox tb,
cairo_surface_t *  icon 
)
Parameters
tbHandle to the textbox
iconThe icon to show on the textbox

Set the text to show. Cursor is moved to end (if visible)

Definition at line 337 of file textbox.c.

References textbox::icon, WIDGET, and widget_queue_redraw().

Referenced by update_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_insert()

void textbox_insert ( textbox tb,
const int  char_pos,
const char *  str,
const int  slen 
)
Parameters
tbHandle to the textbox
char_posThe position to insert the string at
strThe string to insert.
slenThe length of the string.

Insert the string str at position pos.

Definition at line 614 of file textbox.c.

References textbox::blink, textbox::changed, and textbox::text.

Referenced by textbox_append_text().

Here is the caller graph for this function:

◆ textbox_keybinding()

◆ textbox_moveresize()

void textbox_moveresize ( textbox tb,
int  x,
int  y,
int  w,
int  h 
)
Parameters
tbHandle to the textbox
xThe new horizontal position to place with textbox
yThe new vertical position to place with textbox
wThe new width of the textbox
hThe new height of the textbox

Move and resize the textbox. TODO remove for widget_resize and widget_move

Definition at line 353 of file textbox.c.

References DOT_OFFSET, textbox::emode, textbox::flags, _widget::h, textbox::layout, textbox::left_offset, TB_AUTOHEIGHT, TB_AUTOWIDTH, TB_EDITABLE, TB_INDICATOR, TB_WRAP, textbox_get_font_width(), textbox_get_height(), _widget::w, textbox::widget, WIDGET, widget_padding_get_padding_width(), widget_queue_redraw(), _widget::x, and _widget::y.

Referenced by barview_draw(), listview_draw(), textbox_create(), textbox_resize(), and textbox_text().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_set_ellipsize()

void textbox_set_ellipsize ( textbox tb,
PangoEllipsizeMode  mode 
)
Parameters
tbHandle to the textbox
modeThe PangoEllipsizeMode to use displaying the text in the textbox

Set the ellipsizing mode used on the string.

Definition at line 958 of file textbox.c.

References textbox::emode, textbox::flags, textbox::layout, TB_WRAP, WIDGET, and widget_queue_redraw().

Referenced by listview_toggle_ellipsizing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_set_icon_index()

void textbox_set_icon_index ( textbox tb,
int  index 
)
Parameters
tbHandle to the textbox
indexcharacter index to draw the icon at. -1 for no icon

Sets the character index where the icon should be drawn

◆ textbox_set_pango_attributes()

void textbox_set_pango_attributes ( textbox tb,
PangoAttrList *  list 
)
Parameters
tbHandle to the textbox
listNew pango attributes

Sets list as active pango attributes.

Definition at line 296 of file textbox.c.

References textbox::layout.

Referenced by update_callback().

Here is the caller graph for this function:

◆ textbox_set_pango_context()

void textbox_set_pango_context ( const char *  font,
PangoContext *  p 
)
Parameters
fontThe name of the font used.
pThe new default PangoContext

Set the default pango context (with font description) for all textboxes.

Definition at line 840 of file textbox.c.

References default_font_name, TBFontConfig::height, TBFontConfig::metrics, p_context, p_metrics, and tbfc_cache.

Referenced by __create_window().

Here is the caller graph for this function:

◆ textbox_setup()

void textbox_setup ( void  )

Setup the cached fonts. This is required to do before any of the textbox_ functions is called. Clean with textbox_cleanup()

Definition at line 833 of file textbox.c.

References tbfc_cache, and tbfc_entry_free().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ textbox_text()

void textbox_text ( textbox tb,
const char *  text 
)
Parameters
tbHandle to the textbox
textThe text to show in the textbox

Set the text to show. Cursor is moved to end (if visible)

Definition at line 305 of file textbox.c.

References __textbox_update_pango_text(), textbox::cursor, textbox::flags, _widget::h, TB_AUTOWIDTH, textbox::text, textbox_moveresize(), _widget::w, textbox::widget, WIDGET, widget_queue_redraw(), widget_update(), _widget::x, and _widget::y.

Referenced by rofi_view_add_widget(), rofi_view_clear_input(), rofi_view_create(), rofi_view_nav_row_select(), rofi_view_reload_message_bar(), rofi_view_set_overlay(), rofi_view_trigger_global_action(), rofi_view_update_prompt(), textbox_create(), textbox_keybinding(), and update_callback().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ blink

◆ blink_timeout

guint textbox::blink_timeout

Definition at line 65 of file textbox.h.

Referenced by textbox_create(), and textbox_free().

◆ changed

int textbox::changed

◆ cursor

◆ emode

PangoEllipsizeMode textbox::emode

Definition at line 71 of file textbox.h.

Referenced by textbox_create(), textbox_moveresize(), and textbox_set_ellipsize().

◆ flags

◆ icon

cairo_surface_t* textbox::icon

Definition at line 61 of file textbox.h.

Referenced by textbox_draw(), textbox_free(), and textbox_icon().

◆ icon_index

int textbox::icon_index

Definition at line 62 of file textbox.h.

◆ layout

◆ left_offset

int textbox::left_offset

◆ markup

int textbox::markup

Definition at line 58 of file textbox.h.

◆ metrics

PangoFontMetrics* textbox::metrics

Definition at line 70 of file textbox.h.

Referenced by textbox_draw(), textbox_get_estimated_height(), and textbox_initialize_font().

◆ tbft

int textbox::tbft

Definition at line 57 of file textbox.h.

Referenced by __textbox_update_pango_text(), textbox_draw(), and textbox_font().

◆ text

◆ theme_name

const char* textbox::theme_name

Definition at line 74 of file textbox.h.

◆ widget

◆ xalign

double textbox::xalign

Definition at line 68 of file textbox.h.

Referenced by textbox_create(), and textbox_draw().

◆ yalign

double textbox::yalign

Definition at line 67 of file textbox.h.

Referenced by textbox_create(), and textbox_draw().