rofi 1.7.5
dmenu.c File Reference
#include "modes/dmenu.h"
#include "helper.h"
#include "rofi-icon-fetcher.h"
#include "rofi.h"
#include "settings.h"
#include "view.h"
#include "widgets/textbox.h"
#include "xrmoptions.h"
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <gio/gio.h>
#include <gio/gunixinputstream.h>
#include <glib-unix.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "modes/dmenuscriptshared.h"
#include "mode-private.h"
Include dependency graph for dmenu.c:

Go to the source code of this file.

Data Structures

struct  DmenuModePrivateData
 
struct  Block
 

Macros

#define G_LOG_DOMAIN   "Modes.DMenu"
 
#define BLOCK_LINES_SIZE   2048
 

Functions

static int dmenu_mode_init (Mode *sw)
 
static int dmenu_token_match (const Mode *sw, rofi_int_matcher **tokens, unsigned int index)
 
static cairo_surface_t * dmenu_get_icon (const Mode *sw, unsigned int selected_line, unsigned int height)
 
static char * dmenu_get_message (const Mode *sw)
 
static unsigned int bitget (uint32_t const *const array, unsigned int index)
 
static void bittoggle (uint32_t *const array, unsigned int index)
 
static void read_add_block (DmenuModePrivateData *pd, Block **block, char *data, gsize len)
 
static void read_add (DmenuModePrivateData *pd, char *data, gsize len)
 
static gboolean dmenu_async_read_proc (gint fd, GIOCondition condition, gpointer user_data)
 
static void read_input_sync (DmenuModePrivateData *pd, unsigned int pre_read)
 
static gpointer read_input_thread (gpointer userdata)
 
static unsigned int dmenu_mode_get_num_entries (const Mode *sw)
 
static gchar * dmenu_format_output_string (const DmenuModePrivateData *pd, const char *input, const unsigned int index, gboolean multi_select)
 
static unsigned int get_index (unsigned int length, int index)
 
static char * dmenu_get_completion_data (const Mode *data, unsigned int index)
 
static char * get_display_data (const Mode *data, unsigned int index, int *state, G_GNUC_UNUSED GList **list, int get_entry)
 
static void dmenu_mode_free (Mode *sw)
 
static void dmenu_finish (DmenuModePrivateData *pd, RofiViewState *state, int retv)
 
static void dmenu_print_results (DmenuModePrivateData *pd, const char *input)
 
static void dmenu_finalize (RofiViewState *state)
 
int dmenu_mode_dialog (void)
 
void print_dmenu_options (void)
 

Variables

Mode dmenu_mode
 

Macro Definition Documentation

◆ BLOCK_LINES_SIZE

#define BLOCK_LINES_SIZE   2048

Definition at line 116 of file dmenu.c.

Referenced by read_input_thread().

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "Modes.DMenu"

The log domain of this dialog.

Definition at line 29 of file dmenu.c.

Function Documentation

◆ bitget()

static unsigned int bitget ( uint32_t const *const array,
unsigned int index )
inlinestatic

Definition at line 63 of file dmenu.c.

Referenced by dmenu_finalize(), dmenu_format_output_string(), dmenu_print_results(), and get_display_data().

Here is the caller graph for this function:

◆ bittoggle()

static void bittoggle ( uint32_t *const array,
unsigned int index )
inlinestatic

Definition at line 70 of file dmenu.c.

Referenced by dmenu_finalize().

Here is the caller graph for this function:

◆ dmenu_async_read_proc()

static gboolean dmenu_async_read_proc ( gint fd,
GIOCondition condition,
gpointer user_data )
static

This method is called from a GSource that responds to READ available event on the file descriptor of the IPC pipe with the reading thread. This method runs in the same thread as the UI and updates the dmenu mode internal administratinos with new items.

The data is copied not via the pipe, but via the Async Queue. A maximal BLOCK_LINES_SIZE items are added with one block.

Definition at line 194 of file dmenu.c.

References DmenuModePrivateData::async_queue, DmenuModePrivateData::cmd_list, DmenuModePrivateData::cmd_list_length, DmenuModePrivateData::cmd_list_real_length, Block::length, DmenuModePrivateData::loading, rofi_view_get_active(), rofi_view_reload(), rofi_view_set_overlay(), and Block::values.

Referenced by dmenu_mode_init().

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

◆ dmenu_finalize()

◆ dmenu_finish()

static void dmenu_finish ( DmenuModePrivateData * pd,
RofiViewState * state,
int retv )
static

◆ dmenu_format_output_string()

static gchar * dmenu_format_output_string ( const DmenuModePrivateData * pd,
const char * input,
const unsigned int index,
gboolean multi_select )
static

Definition at line 355 of file dmenu.c.

References DmenuModePrivateData::ballot_selected, DmenuModePrivateData::ballot_unselected, bitget(), DmenuModePrivateData::column_separator, DmenuModePrivateData::columns, and DmenuModePrivateData::selected_list.

Referenced by dmenu_get_completion_data(), and get_display_data().

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

◆ dmenu_get_completion_data()

static char * dmenu_get_completion_data ( const Mode * data,
unsigned int index )
static

Definition at line 414 of file dmenu.c.

References DmenuModePrivateData::cmd_list, dmenu_format_output_string(), and mode_get_private_data().

Here is the call graph for this function:

◆ dmenu_get_icon()

static cairo_surface_t * dmenu_get_icon ( const Mode * sw,
unsigned int selected_line,
unsigned int height )
static

◆ dmenu_get_message()

static char * dmenu_get_message ( const Mode * sw)
static

Definition at line 672 of file dmenu.c.

References DmenuModePrivateData::message, and mode_get_private_data().

Here is the call graph for this function:

◆ dmenu_mode_free()

◆ dmenu_mode_get_num_entries()

static unsigned int dmenu_mode_get_num_entries ( const Mode * sw)
static

Definition at line 348 of file dmenu.c.

References DmenuModePrivateData::cmd_list_length, and mode_get_private_data().

Here is the call graph for this function:

◆ dmenu_mode_init()

◆ dmenu_print_results()

static void dmenu_print_results ( DmenuModePrivateData * pd,
const char * input )
static

◆ dmenu_token_match()

static int dmenu_token_match ( const Mode * sw,
rofi_int_matcher ** tokens,
unsigned int index )
static

Strip out the markup when matching.

Definition at line 635 of file dmenu.c.

References DmenuModePrivateData::cmd_list, DmenuModePrivateData::do_markup, DmenuScriptEntry::entry, helper_token_match(), DmenuScriptEntry::meta, and mode_get_private_data().

Here is the call graph for this function:

◆ get_display_data()

◆ get_index()

static unsigned int get_index ( unsigned int length,
int index )
inlinestatic

Definition at line 403 of file dmenu.c.

Referenced by get_display_data().

Here is the caller graph for this function:

◆ read_add()

◆ read_add_block()

static void read_add_block ( DmenuModePrivateData * pd,
Block ** block,
char * data,
gsize len )
static

Definition at line 123 of file dmenu.c.

References dmenuscript_parse_entry_extras(), and rofi_force_utf8().

Referenced by read_input_thread().

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

◆ read_input_sync()

static void read_input_sync ( DmenuModePrivateData * pd,
unsigned int pre_read )
static

Definition at line 234 of file dmenu.c.

References DmenuModePrivateData::fd_file, read_add(), and DmenuModePrivateData::separator.

Referenced by dmenu_mode_init().

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

◆ read_input_thread()

static gpointer read_input_thread ( gpointer userdata)
static

Definition at line 250 of file dmenu.c.

References DmenuModePrivateData::async_queue, BLOCK_LINES_SIZE, DmenuModePrivateData::fd, Block::length, DmenuModePrivateData::pipefd, DmenuModePrivateData::pipefd2, read_add_block(), and DmenuModePrivateData::separator.

Referenced by dmenu_mode_init().

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

Variable Documentation

◆ dmenu_mode

Mode dmenu_mode
Initial value:
= {.name = "dmenu",
.cfg_name_key = "display-combi",
._init = dmenu_mode_init,
._get_num_entries = dmenu_mode_get_num_entries,
._result = NULL,
._destroy = dmenu_mode_free,
._token_match = dmenu_token_match,
._get_display_value = get_display_data,
._get_icon = dmenu_get_icon,
._get_completion = dmenu_get_completion_data,
._preprocess_input = NULL,
._get_message = dmenu_get_message,
.private_data = NULL,
.free = NULL,
.display_name = "dmenu"}
static cairo_surface_t * dmenu_get_icon(const Mode *sw, unsigned int selected_line, unsigned int height)
Definition dmenu.c:679
static char * get_display_data(const Mode *data, unsigned int index, int *state, G_GNUC_UNUSED GList **list, int get_entry)
Definition dmenu.c:421
static int dmenu_token_match(const Mode *sw, rofi_int_matcher **tokens, unsigned int index)
Definition dmenu.c:635
static void dmenu_mode_free(Mode *sw)
Definition dmenu.c:455
static char * dmenu_get_message(const Mode *sw)
Definition dmenu.c:672
static char * dmenu_get_completion_data(const Mode *data, unsigned int index)
Definition dmenu.c:414
static int dmenu_mode_init(Mode *sw)
Definition dmenu.c:498
static unsigned int dmenu_mode_get_num_entries(const Mode *sw)
Definition dmenu.c:348

dmenu Mode object.

Definition at line 482 of file dmenu.c.

Referenced by dmenu_finish(), dmenu_mode_dialog(), and dmenu_mode_init().