2014-01-20 22:36:20 +00:00
|
|
|
#ifndef __SIMPLESWITCHER_H__
|
|
|
|
#define __SIMPLESWITCHER_H__
|
2014-03-18 09:55:25 +00:00
|
|
|
#include <config.h>
|
2014-01-26 12:29:38 +00:00
|
|
|
#include <X11/X.h>
|
2014-01-25 22:37:37 +00:00
|
|
|
|
2014-03-22 20:04:19 +00:00
|
|
|
#define MAX( a, b ) ( ( a ) > ( b ) ? ( a ) : ( b ) )
|
|
|
|
#define MIN( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) )
|
|
|
|
#define NEAR( a, o, b ) ( ( b ) > ( a ) - ( o ) && ( b ) < ( a ) + ( o ) )
|
|
|
|
#define OVERLAP( a, b, c, d ) ( ( ( a ) == ( c ) && ( b ) == ( d ) ) || MIN ( ( a ) + ( b ), ( c ) + ( d ) ) - MAX ( ( a ), ( c ) ) > 0 )
|
|
|
|
#define INTERSECT( x, y, w, h, x1, y1, w1, h1 ) ( OVERLAP ( ( x ), ( w ), ( x1 ), ( w1 ) ) && OVERLAP ( ( y ), ( h ), ( y1 ), ( h1 ) ) )
|
2014-01-20 22:36:20 +00:00
|
|
|
|
2014-05-21 22:38:14 +00:00
|
|
|
#ifndef TRUE
|
2014-05-22 08:03:36 +00:00
|
|
|
#define TRUE 1
|
2014-05-21 22:38:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FALSE
|
2014-05-22 08:03:36 +00:00
|
|
|
#define FALSE 0
|
2014-05-21 22:38:14 +00:00
|
|
|
#endif
|
|
|
|
|
2014-01-25 22:37:37 +00:00
|
|
|
extern const char *cache_dir;
|
2014-01-20 22:36:20 +00:00
|
|
|
|
2014-06-02 10:54:35 +00:00
|
|
|
/**
|
|
|
|
* Enum used to sum the possible states of ROFI.
|
|
|
|
*/
|
2014-03-22 20:04:19 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2014-06-02 10:54:35 +00:00
|
|
|
/** Show the window switcher */
|
2014-01-20 22:36:20 +00:00
|
|
|
WINDOW_SWITCHER,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** Show the run dialog */
|
2014-01-20 22:36:20 +00:00
|
|
|
RUN_DIALOG,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** Show the ssh dialog */
|
2014-01-21 09:01:55 +00:00
|
|
|
SSH_DIALOG,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** Number of cycle-able dialogs */
|
2014-01-22 08:24:31 +00:00
|
|
|
NUM_DIALOGS,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** Dmenu mode */
|
2014-01-29 23:47:23 +00:00
|
|
|
DMENU_DIALOG,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** Exit. */
|
2014-01-22 08:24:31 +00:00
|
|
|
MODE_EXIT,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** Skip to the next cycle-able dialog. */
|
2014-01-22 08:24:31 +00:00
|
|
|
NEXT_DIALOG
|
2014-01-20 22:36:20 +00:00
|
|
|
} SwitcherMode;
|
|
|
|
|
2014-06-02 10:54:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* State returned by the rofi window.
|
|
|
|
*/
|
2014-03-22 20:04:19 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
2014-06-02 10:54:35 +00:00
|
|
|
/** Entry is selected. */
|
2014-03-22 20:04:19 +00:00
|
|
|
MENU_OK = 0,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** User canceled the operation. (e.g. pressed escape) */
|
2014-02-01 13:03:23 +00:00
|
|
|
MENU_CANCEL = -1,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** User requested a mode switch */
|
2014-02-01 13:03:23 +00:00
|
|
|
MENU_NEXT = -2,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** Custom (non-matched) input was entered. */
|
2014-02-01 13:03:23 +00:00
|
|
|
MENU_CUSTOM_INPUT = -3,
|
2014-06-02 10:54:35 +00:00
|
|
|
/** User wanted to delete entry from history. */
|
2014-02-01 13:03:23 +00:00
|
|
|
MENU_ENTRY_DELETE = -4
|
|
|
|
} MenuReturn;
|
2014-01-20 22:36:20 +00:00
|
|
|
|
2014-01-26 11:59:10 +00:00
|
|
|
|
2014-06-02 10:54:35 +00:00
|
|
|
/**
|
|
|
|
* Function prototype for the matching algorithm.
|
|
|
|
*/
|
2014-01-21 09:13:42 +00:00
|
|
|
typedef int ( *menu_match_cb )( char **tokens, const char *input, int index, void *data );
|
2014-06-02 10:54:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param lines An array of strings to display.
|
2014-07-20 10:29:27 +00:00
|
|
|
* @param num_lines Length of the array with strings to display.
|
2014-06-02 10:54:35 +00:00
|
|
|
* @param input A pointer to a string where the inputted data is placed.
|
|
|
|
* @param prompt The prompt to show.
|
|
|
|
* @param time The current time (used for window interaction.)
|
|
|
|
* @param shift pointer to integer that is set to the state of the shift key.
|
|
|
|
* @param mmc Menu menu match callback, used for matching user input.
|
|
|
|
* @param mmc_data data to pass to mmc.
|
|
|
|
* @param selected_line pointer to integer holding the selected line.
|
|
|
|
*
|
|
|
|
* Main menu callback.
|
|
|
|
*
|
|
|
|
* @returns The command issued (see MenuReturn)
|
|
|
|
*/
|
2014-07-20 10:29:27 +00:00
|
|
|
MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prompt,
|
2014-03-22 20:04:19 +00:00
|
|
|
Time *time, int *shift,
|
|
|
|
menu_match_cb mmc, void *mmc_data,
|
2014-07-20 10:29:27 +00:00
|
|
|
int *selected_line ) __attribute__ ( ( nonnull ( 1, 3, 4, 9 ) ) );
|
2014-01-20 22:36:20 +00:00
|
|
|
|
2014-03-22 20:04:19 +00:00
|
|
|
void catch_exit ( __attribute__( ( unused ) ) int sig );
|
|
|
|
|
|
|
|
typedef enum _WindowLocation
|
|
|
|
{
|
|
|
|
WL_CENTER = 0,
|
|
|
|
WL_NORTH_WEST = 1,
|
|
|
|
WL_NORTH = 2,
|
|
|
|
WL_NORTH_EAST = 3,
|
|
|
|
WL_EAST = 4,
|
|
|
|
WL_EAST_SOUTH = 5,
|
|
|
|
WL_SOUTH = 6,
|
|
|
|
WL_SOUTH_WEST = 7,
|
|
|
|
WL_WEST = 8
|
2014-01-25 23:27:57 +00:00
|
|
|
} WindowLocation;
|
|
|
|
|
2014-01-23 10:39:12 +00:00
|
|
|
/**
|
|
|
|
* Settings
|
|
|
|
*/
|
|
|
|
|
2014-03-22 20:04:19 +00:00
|
|
|
typedef struct _Settings
|
|
|
|
{
|
2014-01-23 10:39:12 +00:00
|
|
|
// Window settings
|
2014-03-22 20:04:19 +00:00
|
|
|
unsigned int window_opacity;
|
2014-01-23 10:39:12 +00:00
|
|
|
// Menu settings
|
2014-03-22 20:04:19 +00:00
|
|
|
unsigned int menu_bw;
|
|
|
|
unsigned int menu_width;
|
|
|
|
unsigned int menu_lines;
|
2014-05-19 07:50:09 +00:00
|
|
|
unsigned int menu_columns;
|
2014-03-22 20:04:19 +00:00
|
|
|
char * menu_font;
|
|
|
|
char * menu_fg;
|
|
|
|
char * menu_bg;
|
|
|
|
char * menu_hlfg;
|
|
|
|
char * menu_hlbg;
|
|
|
|
char * menu_bc;
|
2014-01-23 10:39:12 +00:00
|
|
|
// Behavior
|
2014-03-22 20:04:19 +00:00
|
|
|
unsigned int zeltak_mode;
|
|
|
|
char * terminal_emulator;
|
2014-05-20 09:22:03 +00:00
|
|
|
|
2014-01-23 10:39:12 +00:00
|
|
|
// Key bindings
|
2014-03-22 20:04:19 +00:00
|
|
|
char * window_key;
|
|
|
|
char * run_key;
|
|
|
|
char * ssh_key;
|
|
|
|
WindowLocation location;
|
2014-05-21 22:38:14 +00:00
|
|
|
unsigned int hmode;
|
2014-03-22 20:04:19 +00:00
|
|
|
unsigned int padding;
|
2014-05-15 14:54:35 +00:00
|
|
|
int y_offset;
|
2014-05-15 19:55:23 +00:00
|
|
|
int x_offset;
|
2014-04-22 09:11:46 +00:00
|
|
|
|
2014-05-22 08:03:36 +00:00
|
|
|
unsigned int ssh_set_title;
|
2014-05-17 20:17:07 +00:00
|
|
|
unsigned int fixed_num_lines;
|
2014-06-05 19:55:47 +00:00
|
|
|
|
|
|
|
unsigned int disable_history;
|
2014-07-16 06:42:42 +00:00
|
|
|
|
|
|
|
unsigned int levenshtein_sort;
|
2014-01-23 10:39:12 +00:00
|
|
|
} Settings;
|
|
|
|
|
|
|
|
extern Settings config;
|
2014-02-03 21:49:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
int token_match ( char **tokens, const char *input,
|
2014-03-22 20:04:19 +00:00
|
|
|
__attribute__( ( unused ) ) int index,
|
|
|
|
__attribute__( ( unused ) ) void *data );
|
2014-05-19 19:02:05 +00:00
|
|
|
|
2014-01-20 22:36:20 +00:00
|
|
|
#endif
|