1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Big rename from Switcher to Mode internal, to match with user terminology

This commit is contained in:
Dave Davenport 2015-11-25 09:26:38 +01:00
parent b7ec4fa6fb
commit 3c411433b4
17 changed files with 242 additions and 242 deletions

View file

@ -29,9 +29,9 @@
#include "rofi.h"
Settings config = {
/** List of enabled switchers. */
/** -switchers */
.switchers = "window,run,ssh",
/** List of enabled modi. */
/** -modi */
.modi = "window,run,ssh",
/** Set the default window opacity. */
/** This option only works when running a composite manager. */
/** -o */
@ -118,7 +118,7 @@ Settings config = {
.separator = '\n',
/** Height of an element in #chars */
.element_height = 1,
/** Sidebar mode, show the switchers */
/** Sidebar mode, show the modi */
.sidebar_mode = FALSE,
/** Lazy mode setting */
.lazy_filter_limit = 15000,

View file

@ -1,5 +1,5 @@
#ifndef __COMBI_DIALOG_H__
#define __COMBI_DIALOG_H__
extern Switcher combi_mode;
extern Mode combi_mode;
#endif

View file

@ -1,5 +1,5 @@
#ifndef __DRUN_DIALOG_H__
#define __DRUN_DIALOG_H__
extern Switcher drun_mode;
extern Mode drun_mode;
#endif

View file

@ -1,5 +1,5 @@
#ifndef __RUN_DIALOG_H__
#define __RUN_DIALOG_H__
extern Switcher run_mode;
extern Mode run_mode;
#endif

View file

@ -9,5 +9,5 @@
*
* @returns NULL when it fails, a newly allocated ScriptOptions when successful.
*/
Switcher *script_switcher_parse_setup ( const char *str );
Mode *script_switcher_parse_setup ( const char *str );
#endif

View file

@ -1,5 +1,5 @@
#ifndef __SSH_DIALOG_H__
#define __SSH_DIALOG_H__
extern Switcher ssh_mode;
extern Mode ssh_mode;
#endif

View file

@ -4,7 +4,7 @@
#include <config.h>
#ifdef WINDOW_MODE
extern Switcher window_mode;
extern Switcher window_mode_cd;
extern Mode window_mode;
extern Mode window_mode_cd;
#endif // WINDOW_MODE
#endif // __WINDOW_DIALOG_H__

View file

@ -15,7 +15,7 @@
*/
extern const char *cache_dir;
typedef struct _Switcher Switcher;
typedef struct _Mode Mode;
/**
* Enum used to sum the possible states of ROFI.
*/
@ -29,7 +29,7 @@ typedef enum
RELOAD_DIALOG = 1002,
/** Previous dialog */
PREVIOUS_DIALOG = 1003
} SwitcherMode;
} ModeMode;
/**
* State returned by the rofi window.
@ -96,7 +96,7 @@ typedef enum _WindowLocation
} WindowLocation;
/**
* @param sw the Switcher to show.
* @param sw the Mode to show.
* @param lines An array of strings to display.
* @param num_lines Length of the array with strings to display.
* @param input A pointer to a string where the inputted data is placed.
@ -111,7 +111,7 @@ typedef enum _WindowLocation
*
* @returns The command issued (see MenuReturn)
*/
MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
MenuReturn menu ( Mode *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
__attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) );
/**
* Settings
@ -119,8 +119,8 @@ __attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) );
typedef struct _Settings
{
/** List of enabled switchers */
char *switchers;
/** List of enabled modi */
char *modi;
/** Window settings */
unsigned int window_opacity;
/** Border width */
@ -193,7 +193,7 @@ typedef struct _Settings
char separator;
/** Height of an element in #chars */
int element_height;
/** Sidebar mode, show the switchers */
/** Sidebar mode, show the modi */
unsigned int sidebar_mode;
/** Lazy filter limit. */
unsigned int lazy_filter_limit;
@ -203,7 +203,7 @@ typedef struct _Settings
unsigned int parse_hosts;
/** Knonw_hosts file parsing */
unsigned int parse_known_hosts;
/** Combi Switchers */
/** Combi Modes */
char *combi_modi;
/** Fuzzy match */
unsigned int fuzzy;
@ -243,11 +243,11 @@ extern Settings config;
*/
void error_dialog ( const char *msg, int markup );
typedef void ( *switcher_free )( Switcher *data );
typedef void ( *switcher_free )( Mode *data );
typedef char * ( *switcher_get_display_value )( const Switcher *sw, unsigned int selected_line, int *state, int get_entry );
typedef char * ( *switcher_get_display_value )( const Mode *sw, unsigned int selected_line, int *state, int get_entry );
typedef char * ( *switcher_get_completion )( const Switcher *sw, unsigned int selected_line );
typedef char * ( *switcher_get_completion )( const Mode *sw, unsigned int selected_line );
/**
* @param tokens List of (input) tokens to match.
* @param input The entry to match against.
@ -259,24 +259,24 @@ typedef char * ( *switcher_get_completion )( const Switcher *sw, unsigned int se
*
* @returns 1 when it matches, 0 if not.
*/
typedef int ( *switcher_token_match )( const Switcher *data, char **tokens, int not_ascii, int case_sensitive, unsigned int index );
typedef int ( *switcher_token_match )( const Mode *data, char **tokens, int not_ascii, int case_sensitive, unsigned int index );
typedef void ( *switcher_init )( Switcher *sw );
typedef void ( *switcher_init )( Mode *sw );
typedef unsigned int ( *switcher_get_num_entries )( const Switcher *sw );
typedef unsigned int ( *switcher_get_num_entries )( const Mode *sw );
typedef void ( *switcher_destroy )( Switcher *sw );
typedef void ( *switcher_destroy )( Mode *sw );
typedef SwitcherMode ( *switcher_result )( Switcher *sw, int menu_retv, char **input, unsigned int selected_line );
typedef ModeMode ( *switcher_result )( Mode *sw, int menu_retv, char **input, unsigned int selected_line );
typedef int ( *switcher_is_not_ascii )( const Switcher *sw, unsigned int index );
typedef int ( *switcher_is_not_ascii )( const Mode *sw, unsigned int index );
/**
* Structure defining a switcher.
* It consists of a name, callback and if enabled
* a textbox for the sidebar-mode.
*/
struct _Switcher
struct _Mode
{
// Name (max 31 char long)
char name[32];
@ -289,32 +289,32 @@ struct _Switcher
/**
* A switcher normally consists of the following parts:
*/
// Initialize the Switcher
switcher_init init;
// Initialize the Mode
switcher_init init;
// Destroy the switcher, e.g. free all its memory.
switcher_destroy destroy;
switcher_destroy destroy;
// Get number of entries to display. (unfiltered).
switcher_get_num_entries get_num_entries;
switcher_get_num_entries get_num_entries;
// Check if the element is ascii.
switcher_is_not_ascii is_not_ascii;
switcher_is_not_ascii is_not_ascii;
// Process the result of the user selection.
switcher_result result;
switcher_result result;
// Token match.
switcher_token_match token_match;
switcher_token_match token_match;
// Get the string to display for the entry.
switcher_get_display_value mgrv;
// Get the 'completed' entry.
switcher_get_completion get_completion;
switcher_get_completion get_completion;
// Pointer to private data.
void *private_data;
void *private_data;
// Free SWitcher
// Only to be used when the switcher object itself is dynamic.
// And has data in `ed`
switcher_free free;
switcher_free free;
// Extra fields for script
void *ed;
void *ed;
};
#define color_reset "\033[0m"

View file

@ -32,7 +32,7 @@
#include <dialogs/dialogs.h>
/**
* Combi Switcher
* Combi Mode
*/
typedef struct _CombiModePrivateData
{
@ -43,10 +43,10 @@ typedef struct _CombiModePrivateData
unsigned int *lengths;
// List of switchers to combine.
unsigned int num_switchers;
Switcher **switchers;
Mode **switchers;
} CombiModePrivateData;
static void combi_mode_parse_switchers ( Switcher *sw )
static void combi_mode_parse_switchers ( Mode *sw )
{
CombiModePrivateData *pd = sw->private_data;
char *savept = NULL;
@ -56,8 +56,8 @@ static void combi_mode_parse_switchers ( Switcher *sw )
for ( char *token = strtok_r ( switcher_str, ",", &savept ); token != NULL;
token = strtok_r ( NULL, ",", &savept ) ) {
// Resize and add entry.
pd->switchers = (Switcher * *) g_realloc ( pd->switchers,
sizeof ( Switcher* ) * ( pd->num_switchers + 1 ) );
pd->switchers = (Mode * *) g_realloc ( pd->switchers,
sizeof ( Mode* ) * ( pd->num_switchers + 1 ) );
// Window switcher.
#ifdef WINDOW_MODE
@ -82,7 +82,7 @@ static void combi_mode_parse_switchers ( Switcher *sw )
}
else {
// If not build in, use custom switchers.
Switcher *sw = script_switcher_parse_setup ( token );
Mode *sw = script_switcher_parse_setup ( token );
if ( sw != NULL ) {
pd->switchers[pd->num_switchers++] = sw;
}
@ -98,7 +98,7 @@ static void combi_mode_parse_switchers ( Switcher *sw )
g_free ( switcher_str );
}
static void combi_mode_init ( Switcher *sw )
static void combi_mode_init ( Mode *sw )
{
if ( sw->private_data == NULL ) {
CombiModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
@ -120,12 +120,12 @@ static void combi_mode_init ( Switcher *sw )
}
}
}
static unsigned int combi_mode_get_num_entries ( const Switcher *sw )
static unsigned int combi_mode_get_num_entries ( const Mode *sw )
{
const CombiModePrivateData *pd = (const CombiModePrivateData *) sw->private_data;
return pd->cmd_list_length;
}
static void combi_mode_destroy ( Switcher *sw )
static void combi_mode_destroy ( Mode *sw )
{
CombiModePrivateData *pd = (CombiModePrivateData *) sw->private_data;
if ( pd != NULL ) {
@ -140,7 +140,7 @@ static void combi_mode_destroy ( Switcher *sw )
sw->private_data = NULL;
}
}
static SwitcherMode combi_mode_result ( Switcher *sw, int mretv, char **input, unsigned int selected_line )
static ModeMode combi_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
{
CombiModePrivateData *pd = sw->private_data;
if ( *input[0] == '!' ) {
@ -170,7 +170,7 @@ static SwitcherMode combi_mode_result ( Switcher *sw, int mretv, char **input, u
}
return MODE_EXIT;
}
static int combi_mode_match ( const Switcher *sw, char **tokens, int not_ascii,
static int combi_mode_match ( const Mode *sw, char **tokens, int not_ascii,
int case_sensitive, unsigned int index )
{
CombiModePrivateData *pd = sw->private_data;
@ -203,7 +203,7 @@ static int combi_mode_match ( const Switcher *sw, char **tokens, int not_ascii,
abort ();
return 0;
}
static char * combi_mgrv ( const Switcher *sw, unsigned int selected_line, int *state, int get_entry )
static char * combi_mgrv ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
{
CombiModePrivateData *pd = sw->private_data;
if ( !get_entry ) {
@ -226,7 +226,7 @@ static char * combi_mgrv ( const Switcher *sw, unsigned int selected_line, int *
return NULL;
}
static int combi_is_not_ascii ( const Switcher *sw, unsigned int index )
static int combi_is_not_ascii ( const Mode *sw, unsigned int index )
{
CombiModePrivateData *pd = sw->private_data;
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
@ -236,7 +236,7 @@ static int combi_is_not_ascii ( const Switcher *sw, unsigned int index )
}
return FALSE;
}
static char * combi_get_completion ( const Switcher *sw, unsigned int index )
static char * combi_get_completion ( const Mode *sw, unsigned int index )
{
CombiModePrivateData *pd = sw->private_data;
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
@ -257,7 +257,7 @@ static char * combi_get_completion ( const Switcher *sw, unsigned int index )
return NULL;
}
Switcher combi_mode =
Mode combi_mode =
{
.name = "combi",
.keycfg = NULL,

View file

@ -64,7 +64,7 @@ typedef struct _DmenuModePrivateData
static char **get_dmenu ( unsigned int *length )
{
TICK_N ( "Read stdin START" );
char **retv = NULL;
char **retv = NULL;
unsigned int rvlength = 1;
*length = 0;
@ -96,7 +96,7 @@ static char **get_dmenu ( unsigned int *length )
return retv;
}
static unsigned int dmenu_mode_get_num_entries ( const Switcher *sw )
static unsigned int dmenu_mode_get_num_entries ( const Mode *sw )
{
const DmenuModePrivateData *rmpd = (const DmenuModePrivateData *) sw->private_data;
return rmpd->cmd_list_length;
@ -137,9 +137,9 @@ static void parse_ranges ( char *input, struct range_pair **list, unsigned int *
}
}
static char *get_display_data ( const Switcher *data, unsigned int index, int *state, int get_entry )
static char *get_display_data ( const Mode *data, unsigned int index, int *state, int get_entry )
{
Switcher *sw = (Switcher *) data;
Mode *sw = (Mode *) data;
DmenuModePrivateData *pd = (DmenuModePrivateData *) sw->private_data;
char **retv = (char * *) pd->cmd_list;
for ( unsigned int i = 0; i < pd->num_active_list; i++ ) {
@ -206,7 +206,7 @@ static void dmenu_output_formatted_line ( const char *format, const char *string
fputc ( '\n', stdout );
fflush ( stdout );
}
static void dmenu_mode_free ( Switcher *sw )
static void dmenu_mode_free ( Mode *sw )
{
if ( sw->private_data == NULL ) {
return;
@ -227,7 +227,7 @@ static void dmenu_mode_free ( Switcher *sw )
}
}
static void dmenu_mode_init ( Switcher *sw )
static void dmenu_mode_init ( Mode *sw )
{
if ( sw->private_data != NULL ) {
return;
@ -279,19 +279,19 @@ static void dmenu_mode_init ( Switcher *sw )
pd->cmd_list = get_dmenu ( &( pd->cmd_list_length ) );
}
static int dmenu_token_match ( const Switcher *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
static int dmenu_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
{
DmenuModePrivateData *rmpd = (DmenuModePrivateData *) sw->private_data;
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
}
static int dmenu_is_not_ascii ( const Switcher *sw, unsigned int index )
static int dmenu_is_not_ascii ( const Mode *sw, unsigned int index )
{
DmenuModePrivateData *rmpd = (DmenuModePrivateData *) sw->private_data;
return is_not_ascii ( rmpd->cmd_list[index] );
}
Switcher dmenu_mode =
Mode dmenu_mode =
{
.name = "dmenu",
.keycfg = NULL,

View file

@ -226,7 +226,7 @@ static void get_apps ( DRunModePrivateData *pd )
}
}
static void drun_mode_init ( Switcher *sw )
static void drun_mode_init ( Mode *sw )
{
if ( sw->private_data == NULL ) {
DRunModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
@ -235,10 +235,10 @@ static void drun_mode_init ( Switcher *sw )
}
}
static SwitcherMode drun_mode_result ( Switcher *sw, int mretv, char **input, unsigned int selected_line )
static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
{
DRunModePrivateData *rmpd = (DRunModePrivateData *) sw->private_data;
SwitcherMode retv = MODE_EXIT;
ModeMode retv = MODE_EXIT;
int shift = ( ( mretv & MENU_SHIFT ) == MENU_SHIFT );
@ -260,7 +260,7 @@ static SwitcherMode drun_mode_result ( Switcher *sw, int mretv, char **input, un
return retv;
}
static void drun_mode_destroy ( Switcher *sw )
static void drun_mode_destroy ( Mode *sw )
{
DRunModePrivateData *rmpd = (DRunModePrivateData *) sw->private_data;
if ( rmpd != NULL ) {
@ -275,7 +275,7 @@ static void drun_mode_destroy ( Switcher *sw )
}
}
static char *mgrv ( const Switcher *sw, unsigned int selected_line, int *state, int get_entry )
static char *mgrv ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
{
DRunModePrivateData *pd = (DRunModePrivateData *) sw->private_data;
*state |= MARKUP;
@ -296,7 +296,7 @@ static char *mgrv ( const Switcher *sw, unsigned int selected_line, int *state,
dr->generic_name );
}
}
static char *drun_get_completion ( const Switcher *sw, unsigned int index )
static char *drun_get_completion ( const Mode *sw, unsigned int index )
{
DRunModePrivateData *pd = (DRunModePrivateData *) sw->private_data;
/* Free temp storage. */
@ -309,7 +309,7 @@ static char *drun_get_completion ( const Switcher *sw, unsigned int index )
}
}
static int drun_token_match ( const Switcher *data,
static int drun_token_match ( const Mode *data,
char **tokens,
int not_ascii,
int case_sensitive,
@ -329,12 +329,12 @@ static int drun_token_match ( const Switcher *data,
return 0;
}
static unsigned int drun_mode_get_num_entries ( const Switcher *sw )
static unsigned int drun_mode_get_num_entries ( const Mode *sw )
{
const DRunModePrivateData *pd = (const DRunModePrivateData *) sw->private_data;
return pd->cmd_list_length;
}
static int drun_is_not_ascii ( const Switcher *sw, unsigned int index )
static int drun_is_not_ascii ( const Mode *sw, unsigned int index )
{
DRunModePrivateData *pd = (DRunModePrivateData *) sw->private_data;
if ( pd->entry_list[index].generic_name ) {
@ -343,7 +343,7 @@ static int drun_is_not_ascii ( const Switcher *sw, unsigned int index )
return is_not_ascii ( pd->entry_list[index].name );
}
Switcher drun_mode =
Mode drun_mode =
{
.name = "drun",
.keycfg = NULL,

View file

@ -267,7 +267,7 @@ typedef struct _RunModePrivateData
unsigned int cmd_list_length;
} RunModePrivateData;
static void run_mode_init ( Switcher *sw )
static void run_mode_init ( Mode *sw )
{
if ( sw->private_data == NULL ) {
RunModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
@ -276,16 +276,16 @@ static void run_mode_init ( Switcher *sw )
}
}
static unsigned int run_mode_get_num_entries ( const Switcher *sw )
static unsigned int run_mode_get_num_entries ( const Mode *sw )
{
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
return rmpd->cmd_list_length;
}
static SwitcherMode run_mode_result ( Switcher *sw, int mretv, char **input, unsigned int selected_line )
static ModeMode run_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
{
RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
SwitcherMode retv = MODE_EXIT;
ModeMode retv = MODE_EXIT;
int shift = ( ( mretv & MENU_SHIFT ) == MENU_SHIFT );
@ -316,7 +316,7 @@ static SwitcherMode run_mode_result ( Switcher *sw, int mretv, char **input, uns
return retv;
}
static void run_mode_destroy ( Switcher *sw )
static void run_mode_destroy ( Mode *sw )
{
RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
if ( rmpd != NULL ) {
@ -326,23 +326,23 @@ static void run_mode_destroy ( Switcher *sw )
}
}
static char *mgrv ( const Switcher *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, int get_entry )
static char *mgrv ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, int get_entry )
{
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
static int run_token_match ( const Switcher *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
static int run_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
{
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
}
static int run_is_not_ascii ( const Switcher *sw, unsigned int index )
static int run_is_not_ascii ( const Mode *sw, unsigned int index )
{
const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
return is_not_ascii ( rmpd->cmd_list[index] );
}
Switcher run_mode =
Mode run_mode =
{
.name = "run",
.keycfg = NULL,

View file

@ -69,7 +69,7 @@ static char **get_script_output ( const char *command, unsigned int *length )
return retv;
}
static char **execute_executor ( Switcher *sw, const char *result, unsigned int *length )
static char **execute_executor ( Mode *sw, const char *result, unsigned int *length )
{
char **retv = NULL;
@ -81,7 +81,7 @@ static char **execute_executor ( Switcher *sw, const char *result, unsigned int
return retv;
}
static void script_switcher_free ( Switcher *sw )
static void script_switcher_free ( Mode *sw )
{
if ( sw == NULL ) {
return;
@ -97,7 +97,7 @@ typedef struct _ScriptModePrivateData
unsigned int cmd_list_length;
} ScriptModePrivateData;
static void script_mode_init ( Switcher *sw )
static void script_mode_init ( Mode *sw )
{
if ( sw->private_data == NULL ) {
ScriptModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
@ -105,16 +105,16 @@ static void script_mode_init ( Switcher *sw )
pd->cmd_list = get_script_output ( (const char *) sw->ed, &( pd->cmd_list_length ) );
}
}
static unsigned int script_mode_get_num_entries ( const Switcher *sw )
static unsigned int script_mode_get_num_entries ( const Mode *sw )
{
const ScriptModePrivateData *rmpd = (const ScriptModePrivateData *) sw->private_data;
return rmpd->cmd_list_length;
}
static SwitcherMode script_mode_result ( Switcher *sw, int mretv, char **input, unsigned int selected_line )
static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
{
ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data;
SwitcherMode retv = MODE_EXIT;
ModeMode retv = MODE_EXIT;
char **new_list = NULL;
unsigned int new_length = 0;
@ -147,7 +147,7 @@ static SwitcherMode script_mode_result ( Switcher *sw, int mretv, char **input,
return retv;
}
static void script_mode_destroy ( Switcher *sw )
static void script_mode_destroy ( Mode *sw )
{
ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data;
if ( rmpd != NULL ) {
@ -156,27 +156,27 @@ static void script_mode_destroy ( Switcher *sw )
sw->private_data = NULL;
}
}
static char *mgrv ( const Switcher *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, int get_entry )
static char *mgrv ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, int get_entry )
{
ScriptModePrivateData *rmpd = sw->private_data;
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
static int script_token_match ( const Switcher *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
static int script_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
{
ScriptModePrivateData *rmpd = sw->private_data;
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
}
static int script_is_not_ascii ( const Switcher *sw, unsigned int index )
static int script_is_not_ascii ( const Mode *sw, unsigned int index )
{
ScriptModePrivateData *rmpd = sw->private_data;
return is_not_ascii ( rmpd->cmd_list[index] );
}
Switcher *script_switcher_parse_setup ( const char *str )
Mode *script_switcher_parse_setup ( const char *str )
{
Switcher *sw = g_malloc0 ( sizeof ( *sw ) );
Mode *sw = g_malloc0 ( sizeof ( *sw ) );
char *endp = NULL;
char *parse = g_strdup ( str );
unsigned int index = 0;

View file

@ -322,7 +322,7 @@ typedef struct _SSHModePrivateData
unsigned int cmd_list_length;
} SSHModePrivateData;
static void ssh_mode_init ( Switcher *sw )
static void ssh_mode_init ( Mode *sw )
{
if ( sw->private_data == NULL ) {
SSHModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
@ -331,14 +331,14 @@ static void ssh_mode_init ( Switcher *sw )
}
}
static unsigned int ssh_mode_get_num_entries ( const Switcher *sw )
static unsigned int ssh_mode_get_num_entries ( const Mode *sw )
{
const SSHModePrivateData *rmpd = (const SSHModePrivateData *) sw->private_data;
return rmpd->cmd_list_length;
}
static SwitcherMode ssh_mode_result ( Switcher *sw, int mretv, char **input, unsigned int selected_line )
static ModeMode ssh_mode_result ( Mode *sw, int mretv, char **input, unsigned int selected_line )
{
SwitcherMode retv = MODE_EXIT;
ModeMode retv = MODE_EXIT;
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
if ( mretv & MENU_NEXT ) {
retv = NEXT_DIALOG;
@ -366,7 +366,7 @@ static SwitcherMode ssh_mode_result ( Switcher *sw, int mretv, char **input, uns
return retv;
}
static void ssh_mode_destroy ( Switcher *sw )
static void ssh_mode_destroy ( Mode *sw )
{
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
if ( rmpd != NULL ) {
@ -376,24 +376,24 @@ static void ssh_mode_destroy ( Switcher *sw )
}
}
static char *mgrv ( const Switcher *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, int get_entry )
static char *mgrv ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, int get_entry )
{
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
static int ssh_token_match ( const Switcher *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
static int ssh_token_match ( const Mode *sw, char **tokens, int not_ascii, int case_sensitive, unsigned int index )
{
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
}
static int ssh_is_not_ascii ( const Switcher *sw, unsigned int index )
static int ssh_is_not_ascii ( const Mode *sw, unsigned int index )
{
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
return is_not_ascii ( rmpd->cmd_list[index] );
}
Switcher ssh_mode =
Mode ssh_mode =
{
.name = "ssh",
.keycfg = NULL,

View file

@ -308,7 +308,7 @@ static client* window_client ( Display *display, Window win )
return c;
}
typedef struct _SwitcherModePrivateData
typedef struct _ModeModePrivateData
{
unsigned int id;
char **cmd_list;
@ -318,19 +318,19 @@ typedef struct _SwitcherModePrivateData
// Current window.
unsigned int index;
char *cache;
} SwitcherModePrivateData;
} ModeModePrivateData;
static int window_match ( const Switcher *sw, char **tokens,
static int window_match ( const Mode *sw, char **tokens,
__attribute__( ( unused ) ) int not_ascii,
int case_sensitive, unsigned int index )
{
SwitcherModePrivateData *rmpd = (SwitcherModePrivateData *) sw->private_data;
int match = 1;
const winlist *ids = ( winlist * ) rmpd->ids;
ModeModePrivateData *rmpd = (ModeModePrivateData *) sw->private_data;
int match = 1;
const winlist *ids = ( winlist * ) rmpd->ids;
// Want to pull directly out of cache, X calls are not thread safe.
int idx = winlist_find ( cache_client, ids->array[index] );
int idx = winlist_find ( cache_client, ids->array[index] );
g_assert ( idx >= 0 );
client *c = cache_client->data[idx];
client *c = cache_client->data[idx];
if ( tokens ) {
for ( int j = 0; match && tokens != NULL && tokens[j] != NULL; j++ ) {
@ -365,22 +365,22 @@ static int window_match ( const Switcher *sw, char **tokens,
return match;
}
static unsigned int window_mode_get_num_entries ( const Switcher *sw )
static unsigned int window_mode_get_num_entries ( const Mode *sw )
{
const SwitcherModePrivateData *pd = (const SwitcherModePrivateData *) sw->private_data;
const ModeModePrivateData *pd = (const ModeModePrivateData *) sw->private_data;
return pd->cmd_list_length;
}
static void _window_mode_load_data ( Switcher *sw, unsigned int cd )
static void _window_mode_load_data ( Mode *sw, unsigned int cd )
{
SwitcherModePrivateData *pd = (SwitcherModePrivateData *) sw->private_data;
Screen *screen = DefaultScreenOfDisplay ( display );
Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) );
ModeModePrivateData *pd = (ModeModePrivateData *) sw->private_data;
Screen *screen = DefaultScreenOfDisplay ( display );
Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) );
// find window list
Atom type;
int nwins = 0;
Window wins[100];
int count = 0;
Window curr_win_id = 0;
Atom type;
int nwins = 0;
Window wins[100];
int count = 0;
Window curr_win_id = 0;
// Create cache
x11_cache_create ();
@ -494,27 +494,27 @@ static void _window_mode_load_data ( Switcher *sw, unsigned int cd )
}
}
}
static void window_mode_init ( Switcher *sw )
static void window_mode_init ( Mode *sw )
{
if ( sw->private_data == NULL ) {
SwitcherModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
ModeModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
sw->private_data = (void *) pd;
_window_mode_load_data ( sw, FALSE );
}
}
static void window_mode_init_cd ( Switcher *sw )
static void window_mode_init_cd ( Mode *sw )
{
if ( sw->private_data == NULL ) {
SwitcherModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
ModeModePrivateData *pd = g_malloc0 ( sizeof ( *pd ) );
sw->private_data = (void *) pd;
_window_mode_load_data ( sw, TRUE );
}
}
static SwitcherMode window_mode_result ( Switcher *sw, int mretv, G_GNUC_UNUSED char **input,
unsigned int selected_line )
static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **input,
unsigned int selected_line )
{
SwitcherModePrivateData *rmpd = (SwitcherModePrivateData *) sw->private_data;
SwitcherMode retv = MODE_EXIT;
ModeModePrivateData *rmpd = (ModeModePrivateData *) sw->private_data;
ModeMode retv = MODE_EXIT;
if ( mretv & MENU_NEXT ) {
retv = NEXT_DIALOG;
}
@ -545,9 +545,9 @@ static SwitcherMode window_mode_result ( Switcher *sw, int mretv, G_GNUC_UNUSED
return retv;
}
static void window_mode_destroy ( Switcher *sw )
static void window_mode_destroy ( Mode *sw )
{
SwitcherModePrivateData *rmpd = (SwitcherModePrivateData *) sw->private_data;
ModeModePrivateData *rmpd = (ModeModePrivateData *) sw->private_data;
if ( rmpd != NULL ) {
g_strfreev ( rmpd->cmd_list );
winlist_free ( rmpd->ids );
@ -559,9 +559,9 @@ static void window_mode_destroy ( Switcher *sw )
}
}
static char *mgrv ( const Switcher *sw, unsigned int selected_line, int *state, int get_entry )
static char *mgrv ( const Mode *sw, unsigned int selected_line, int *state, int get_entry )
{
SwitcherModePrivateData *rmpd = sw->private_data;
ModeModePrivateData *rmpd = sw->private_data;
if ( window_client ( display, rmpd->ids->array[selected_line] )->demands ) {
*state |= URGENT;
}
@ -571,18 +571,18 @@ static char *mgrv ( const Switcher *sw, unsigned int selected_line, int *state,
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
static int window_is_not_ascii ( const Switcher *sw, unsigned int index )
static int window_is_not_ascii ( const Mode *sw, unsigned int index )
{
const SwitcherModePrivateData *rmpd = sw->private_data;
const winlist *ids = ( winlist * ) rmpd->ids;
const ModeModePrivateData *rmpd = sw->private_data;
const winlist *ids = ( winlist * ) rmpd->ids;
// Want to pull directly out of cache, X calls are not thread safe.
int idx = winlist_find ( cache_client, ids->array[index] );
int idx = winlist_find ( cache_client, ids->array[index] );
g_assert ( idx >= 0 );
client *c = cache_client->data[idx];
client *c = cache_client->data[idx];
return is_not_ascii ( c->role ) || is_not_ascii ( c->class ) || is_not_ascii ( c->title ) || is_not_ascii ( c->name );
}
Switcher window_mode =
Mode window_mode =
{
.name = "window",
.keycfg = NULL,
@ -599,7 +599,7 @@ Switcher window_mode =
.private_data = NULL,
.free = NULL
};
Switcher window_mode_cd =
Mode window_mode_cd =
{
.name = "windowcd",
.keycfg = NULL,

View file

@ -59,18 +59,18 @@
#include "xrmoptions.h"
#include "dialogs/dialogs.h"
SwitcherMode switcher_run ( char **input, Switcher *sw );
ModeMode switcher_run ( char **input, Mode *sw );
typedef enum _MainLoopEvent
{
ML_XEVENT,
ML_TIMEOUT
} MainLoopEvent;
typedef struct _Mode
typedef struct _ModeHolder
{
Switcher *sw;
textbox *tb;
} Mode;
Mode *sw;
textbox *tb;
} ModeHolder;
// Pidfile.
extern Atom netatoms[NUM_NETATOMS];
@ -83,9 +83,9 @@ char *display_str = NULL;
Window main_window = None;
Colormap map = None;
unsigned int normal_window_mode = FALSE;
// Array of switchers.
Mode *switchers = NULL;
unsigned int num_switchers = 0;
// Array of modi.
ModeHolder *modi = NULL;
unsigned int num_modi = 0;
// Current selected switcher.
unsigned int curr_switcher = 0;
XVisualInfo vinfo;
@ -102,12 +102,12 @@ GThreadPool *tpool = NULL;
*
* Find the index of the switcher with name.
*
* @returns index of the switcher in switchers, -1 if not found.
* @returns index of the switcher in modi, -1 if not found.
*/
static int switcher_get ( const char *name )
{
for ( unsigned int i = 0; i < num_switchers; i++ ) {
if ( strcmp ( switchers[i].sw->name, name ) == 0 ) {
for ( unsigned int i = 0; i < num_modi; i++ ) {
if ( strcmp ( modi[i].sw->name, name ) == 0 ) {
return i;
}
}
@ -179,7 +179,7 @@ static int levenshtein ( const char *s1, const char *s2 )
typedef struct MenuState
{
Switcher *sw;
Mode *sw;
unsigned int menu_lines;
unsigned int max_elements;
unsigned int max_rows;
@ -551,7 +551,7 @@ inline static void menu_nav_last ( MenuState * state )
* @param key the Key to match
* @param modstate the modifier state to match
*
* Match key and modifier state against switchers.
* Match key and modifier state against modi.
*
* @return the index of the switcher that matches the key combination
* specified by key and modstate. Returns -1 if none was found
@ -561,10 +561,10 @@ static int locate_switcher ( KeySym key, unsigned int modstate )
{
// ignore annoying modifiers
unsigned int modstate_filtered = modstate & ~( LockMask | NumlockMask );
for ( unsigned int i = 0; i < num_switchers; i++ ) {
if ( switchers[i].sw->keystr != NULL ) {
if ( ( modstate_filtered == switchers[i].sw->modmask ) &&
switchers[i].sw->keysym == key ) {
for ( unsigned int i = 0; i < num_modi; i++ ) {
if ( modi[i].sw->keystr != NULL ) {
if ( ( modstate_filtered == modi[i].sw->modmask ) &&
modi[i].sw->keysym == key ) {
return i;
}
}
@ -712,8 +712,8 @@ static void menu_mouse_navigation ( MenuState *state, XButtonEvent *xbe )
state->update = TRUE;
return;
}
for ( unsigned int i = 0; config.sidebar_mode == TRUE && i < num_switchers; i++ ) {
if ( intersect ( switchers[i].tb, xbe->x, xbe->y ) ) {
for ( unsigned int i = 0; config.sidebar_mode == TRUE && i < num_modi; i++ ) {
if ( intersect ( modi[i].tb, xbe->x, xbe->y ) ) {
*( state->selected_line ) = 0;
state->retv = MENU_QUICK_SWITCH | ( i & MENU_LOWER_MASK );
state->quit = TRUE;
@ -970,7 +970,7 @@ static void menu_update ( MenuState *state )
{
TICK ();
cairo_surface_t * surf = cairo_image_surface_create ( get_format (), state->w, state->h );
cairo_t *d = cairo_create ( surf );
cairo_t *d = cairo_create ( surf );
cairo_set_operator ( d, CAIRO_OPERATOR_SOURCE );
if ( config.fake_transparency ) {
if ( state->bg != NULL ) {
@ -1043,9 +1043,9 @@ static void menu_update ( MenuState *state )
}
}
if ( config.sidebar_mode == TRUE ) {
for ( unsigned int j = 0; j < num_switchers; j++ ) {
if ( switchers[j].tb != NULL ) {
textbox_draw ( switchers[j].tb, d );
for ( unsigned int j = 0; j < num_modi; j++ ) {
if ( modi[j].tb != NULL ) {
textbox_draw ( modi[j].tb, d );
}
}
}
@ -1096,12 +1096,12 @@ static void menu_resize ( MenuState *state )
unsigned int sbw = config.line_margin + 8;
scrollbar_move ( state->scrollbar, state->w - state->border - sbw, state->top_offset );
if ( config.sidebar_mode == TRUE ) {
int width = ( state->w - ( 2 * ( state->border ) + ( num_switchers - 1 ) * config.line_margin ) ) / num_switchers;
for ( unsigned int j = 0; j < num_switchers; j++ ) {
textbox_moveresize ( switchers[j].tb,
int width = ( state->w - ( 2 * ( state->border ) + ( num_modi - 1 ) * config.line_margin ) ) / num_modi;
for ( unsigned int j = 0; j < num_modi; j++ ) {
textbox_moveresize ( modi[j].tb,
state->border + j * ( width + config.line_margin ), state->h - state->line_height - state->border,
width, state->line_height );
textbox_draw ( switchers[j].tb, draw );
textbox_draw ( modi[j].tb, draw );
}
}
int entrybox_width = state->w - ( 2 * ( state->border ) ) - textbox_get_width ( state->prompt_tb )
@ -1172,10 +1172,10 @@ static void menu_setup_fake_transparency ( Display *display, MenuState *state )
TICK_N ( "Fake transparency" );
}
MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
MenuReturn menu ( Mode *sw, char **input, char *prompt, unsigned int *selected_line, unsigned int *next_pos, const char *message )
{
TICK ();
int shift = FALSE;
int shift = FALSE;
MenuState state = {
.sw = sw,
.selected_line = selected_line,
@ -1362,11 +1362,11 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select
calculate_window_position ( &state );
if ( config.sidebar_mode == TRUE ) {
int width = ( state.w - ( 2 * ( state.border ) + ( num_switchers - 1 ) * config.line_margin ) ) / num_switchers;
for ( unsigned int j = 0; j < num_switchers; j++ ) {
switchers[j].tb = textbox_create ( TB_CENTER, state.border + j * ( width + config.line_margin ),
state.h - state.line_height - state.border, width, state.line_height,
( j == curr_switcher ) ? HIGHLIGHT : NORMAL, switchers[j].sw->name );
int width = ( state.w - ( 2 * ( state.border ) + ( num_modi - 1 ) * config.line_margin ) ) / num_modi;
for ( unsigned int j = 0; j < num_modi; j++ ) {
modi[j].tb = textbox_create ( TB_CENTER, state.border + j * ( width + config.line_margin ),
state.h - state.line_height - state.border, width, state.line_height,
( j == curr_switcher ) ? HIGHLIGHT : NORMAL, modi[j].sw->name );
}
}
@ -1630,9 +1630,9 @@ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *select
// Free the switcher boxes.
// When state is free'ed we should no longer need these.
if ( config.sidebar_mode == TRUE ) {
for ( unsigned int j = 0; j < num_switchers; j++ ) {
textbox_free ( switchers[j].tb );
switchers[j].tb = NULL;
for ( unsigned int j = 0; j < num_modi; j++ ) {
textbox_free ( modi[j].tb );
modi[j].tb = NULL;
}
}
@ -1795,7 +1795,7 @@ static int run_dmenu ()
return ret_state;
}
static void run_switcher ( SwitcherMode mode )
static void run_switcher ( ModeMode mode )
{
int pfd = setup ();
if ( pfd < 0 ) {
@ -1803,39 +1803,39 @@ static void run_switcher ( SwitcherMode mode )
}
// Otherwise check if requested mode is enabled.
char *input = g_strdup ( config.filter );
for ( unsigned int i = 0; i < num_switchers; i++ ) {
switchers[i].sw->init ( switchers[i].sw );
for ( unsigned int i = 0; i < num_modi; i++ ) {
modi[i].sw->init ( modi[i].sw );
}
do {
SwitcherMode retv;
ModeMode retv;
curr_switcher = mode;
retv = switcher_run ( &input, switchers[mode].sw );
retv = switcher_run ( &input, modi[mode].sw );
// Find next enabled
if ( retv == NEXT_DIALOG ) {
mode = ( mode + 1 ) % num_switchers;
mode = ( mode + 1 ) % num_modi;
}
else if ( retv == PREVIOUS_DIALOG ) {
if ( mode == 0 ) {
mode = num_switchers - 1;
mode = num_modi - 1;
}
else {
mode = ( mode - 1 ) % num_switchers;
mode = ( mode - 1 ) % num_modi;
}
}
else if ( retv == RELOAD_DIALOG ) {
// do nothing.
}
else if ( retv < MODE_EXIT ) {
mode = ( retv ) % num_switchers;
mode = ( retv ) % num_modi;
}
else {
mode = retv;
}
} while ( mode != MODE_EXIT );
g_free ( input );
for ( unsigned int i = 0; i < num_switchers; i++ ) {
switchers[i].sw->destroy ( switchers[i].sw );
for ( unsigned int i = 0; i < num_modi; i++ ) {
modi[i].sw->destroy ( modi[i].sw );
}
// cleanup
teardown ( pfd );
@ -1941,18 +1941,18 @@ static void cleanup ()
// Cleaning up memory allocated by the Xresources file.
config_xresource_free ();
for ( unsigned int i = 0; i < num_switchers; i++ ) {
// Switcher keystr is free'ed when needed by config system.
if ( switchers[i].sw->keycfg != NULL ) {
g_free ( switchers[i].sw->keycfg );
switchers[i].sw->keycfg = NULL;
for ( unsigned int i = 0; i < num_modi; i++ ) {
// Mode keystr is free'ed when needed by config system.
if ( modi[i].sw->keycfg != NULL ) {
g_free ( modi[i].sw->keycfg );
modi[i].sw->keycfg = NULL;
}
// only used for script dialog.
if ( switchers[i].sw->free != NULL ) {
switchers[i].sw->free ( switchers[i].sw );
if ( modi[i].sw->free != NULL ) {
modi[i].sw->free ( modi[i].sw );
}
}
g_free ( switchers );
g_free ( modi );
// Cleanup the custom keybinding
cleanup_abe ();
@ -1961,60 +1961,60 @@ static void cleanup ()
}
/**
* Parse the switcher string, into internal array of type Switcher.
* Parse the switcher string, into internal array of type Mode.
*
* String is split on separator ','
* First the three build-in modi are checked: window, run, ssh
* if that fails, a script-switcher is created.
*/
static void setup_switchers ( void )
static void setup_modi ( void )
{
char *savept = NULL;
// Make a copy, as strtok will modify it.
char *switcher_str = g_strdup ( config.switchers );
char *switcher_str = g_strdup ( config.modi );
// Split token on ','. This modifies switcher_str.
for ( char *token = strtok_r ( switcher_str, ",", &savept ); token != NULL; token = strtok_r ( NULL, ",", &savept ) ) {
// Resize and add entry.
switchers = (Mode *) g_realloc ( switchers, sizeof ( Mode ) * ( num_switchers + 1 ) );
switchers[num_switchers].tb = NULL;
modi = (ModeHolder *) g_realloc ( modi, sizeof ( ModeHolder ) * ( num_modi + 1 ) );
modi[num_modi].tb = NULL;
// Window switcher.
#ifdef WINDOW_MODE
if ( strcasecmp ( token, "window" ) == 0 ) {
switchers[num_switchers].sw = &window_mode;
num_switchers++;
modi[num_modi].sw = &window_mode;
num_modi++;
}
else if ( strcasecmp ( token, "windowcd" ) == 0 ) {
switchers[num_switchers].sw = &window_mode_cd;
num_switchers++;
modi[num_modi].sw = &window_mode_cd;
num_modi++;
}
else
#endif // WINDOW_MODE
// SSh dialog
if ( strcasecmp ( token, "ssh" ) == 0 ) {
switchers[num_switchers].sw = &ssh_mode;
num_switchers++;
modi[num_modi].sw = &ssh_mode;
num_modi++;
}
// Run dialog
else if ( strcasecmp ( token, "run" ) == 0 ) {
switchers[num_switchers].sw = &run_mode;
num_switchers++;
modi[num_modi].sw = &run_mode;
num_modi++;
}
else if ( strcasecmp ( token, "drun" ) == 0 ) {
switchers[num_switchers].sw = &drun_mode;
num_switchers++;
modi[num_modi].sw = &drun_mode;
num_modi++;
}
// combi dialog
else if ( strcasecmp ( token, "combi" ) == 0 ) {
switchers[num_switchers].sw = &combi_mode;
num_switchers++;
modi[num_modi].sw = &combi_mode;
num_modi++;
}
else {
// If not build in, use custom switchers.
Switcher *sw = script_switcher_parse_setup ( token );
// If not build in, use custom modi.
Mode *sw = script_switcher_parse_setup ( token );
if ( sw != NULL ) {
switchers[num_switchers].sw = sw;
num_switchers++;
modi[num_modi].sw = sw;
num_modi++;
}
else{
// Report error, don't continue.
@ -2028,9 +2028,9 @@ static void setup_switchers ( void )
g_free ( switcher_str );
// We cannot do this in main loop, as we create pointer to string,
// and re-alloc moves that pointer.
for ( unsigned int i = 0; i < num_switchers; i++ ) {
switchers[i].sw->keycfg = g_strdup_printf ( "key-%s", switchers[i].sw->name );
config_parser_add_option ( xrm_String, switchers[i].sw->keycfg, (void * *) &( switchers[i].sw->keystr ), "Keybinding" );
for ( unsigned int i = 0; i < num_modi; i++ ) {
modi[i].sw->keycfg = g_strdup_printf ( "key-%s", modi[i].sw->name );
config_parser_add_option ( xrm_String, modi[i].sw->keycfg, (void * *) &( modi[i].sw->keystr ), "Keybinding" );
}
}
@ -2056,11 +2056,11 @@ static inline void load_configuration_dynamic ( Display *display )
static void release_global_keybindings ()
{
for ( unsigned int i = 0; i < num_switchers; i++ ) {
if ( switchers[i].sw->keystr != NULL ) {
for ( unsigned int i = 0; i < num_modi; i++ ) {
if ( modi[i].sw->keystr != NULL ) {
// No need to parse key, this should be done when grabbing.
if ( switchers[i].sw->keysym != NoSymbol ) {
x11_ungrab_key ( display, switchers[i].sw->modmask, switchers[i].sw->keysym );
if ( modi[i].sw->keysym != NoSymbol ) {
x11_ungrab_key ( display, modi[i].sw->modmask, modi[i].sw->keysym );
}
}
}
@ -2068,11 +2068,11 @@ static void release_global_keybindings ()
static int grab_global_keybindings ()
{
int key_bound = FALSE;
for ( unsigned int i = 0; i < num_switchers; i++ ) {
if ( switchers[i].sw->keystr != NULL ) {
x11_parse_key ( switchers[i].sw->keystr, &( switchers[i].sw->modmask ), &( switchers[i].sw->keysym ) );
if ( switchers[i].sw->keysym != NoSymbol ) {
x11_grab_key ( display, switchers[i].sw->modmask, switchers[i].sw->keysym );
for ( unsigned int i = 0; i < num_modi; i++ ) {
if ( modi[i].sw->keystr != NULL ) {
x11_parse_key ( modi[i].sw->keystr, &( modi[i].sw->modmask ), &( modi[i].sw->keysym ) );
if ( modi[i].sw->keysym != NoSymbol ) {
x11_grab_key ( display, modi[i].sw->modmask, modi[i].sw->keysym );
key_bound = TRUE;
}
}
@ -2082,12 +2082,12 @@ static int grab_global_keybindings ()
static void print_global_keybindings ()
{
fprintf ( stdout, "listening to the following keys:\n" );
for ( unsigned int i = 0; i < num_switchers; i++ ) {
if ( switchers[i].sw->keystr != NULL ) {
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on %s\n", switchers[i].sw->name, switchers[i].sw->keystr );
for ( unsigned int i = 0; i < num_modi; i++ ) {
if ( modi[i].sw->keystr != NULL ) {
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on %s\n", modi[i].sw->name, modi[i].sw->keystr );
}
else {
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on <unspecified>\n", switchers[i].sw->name );
fprintf ( stdout, "\t* "color_bold "%s"color_reset " on <unspecified>\n", modi[i].sw->name );
}
}
}
@ -2233,7 +2233,7 @@ static int main_loop_signal_handler ( char command, int quiet )
return FALSE;
}
SwitcherMode switcher_run ( char **input, Switcher *sw )
ModeMode switcher_run ( char **input, Mode *sw )
{
char *prompt = g_strdup_printf ( "%s:", sw->name );
unsigned int selected_line = UINT32_MAX;
@ -2359,8 +2359,8 @@ int main ( int argc, char *argv[] )
load_configuration ( display );
}
if ( !dmenu_mode ) {
// setup_switchers
setup_switchers ();
// setup_modi
setup_modi ();
}
else {
// Add dmenu options.
@ -2452,8 +2452,8 @@ int main ( int argc, char *argv[] )
fprintf ( stderr, "Rofi was launched in daemon mode, but no key-binding was specified.\n" );
fprintf ( stderr, "Please check the manpage on how to specify a key-binding.\n" );
fprintf ( stderr, "The following modi are enabled and keys can be specified:\n" );
for ( unsigned int i = 0; i < num_switchers; i++ ) {
fprintf ( stderr, "\t* "color_bold "%s"color_reset ": -key-%s <key>\n", switchers[i].sw->name, switchers[i].sw->name );
for ( unsigned int i = 0; i < num_modi; i++ ) {
fprintf ( stderr, "\t* "color_bold "%s"color_reset ": -key-%s <key>\n", modi[i].sw->name, modi[i].sw->name );
}
return EXIT_FAILURE;
}

View file

@ -55,8 +55,8 @@ typedef struct
* Currently supports string, boolean and number (signed and unsigned).
*/
static XrmOption xrmOptions[] = {
{ xrm_String, "switchers", { .str = &config.switchers }, NULL, "" },
{ xrm_String, "modi", { .str = &config.switchers }, NULL, "Enabled modi" },
{ xrm_String, "switchers", { .str = &config.modi }, NULL, "" },
{ xrm_String, "modi", { .str = &config.modi }, NULL, "Enabled modi" },
{ xrm_Number, "opacity", { .num = &config.window_opacity }, NULL, "Window opacity" },
{ xrm_SNumber, "width", { .snum = &config.menu_width }, NULL, "Window width" },
{ xrm_Number, "lines", { .num = &config.menu_lines }, NULL, "Number of lines" },