Update comment of headers.

This commit is contained in:
Dave Davenport
2014-11-25 08:27:08 +01:00
parent be9bc59c34
commit 471c0c5df7
3 changed files with 153 additions and 39 deletions

View File

@@ -29,58 +29,79 @@
#include "rofi.h" #include "rofi.h"
Settings config = { Settings config = {
// List of enabled switchers. /** List of enabled switchers. */
// -switchers /** -switchers */
.switchers = "window,run,ssh", .switchers = "window,run,ssh",
// Set the default window opacity. /** Set the default window opacity. */
// This option only works when running a composite manager. /** This option only works when running a composite manager. */
// -o /** -o */
.window_opacity = 100, .window_opacity = 100,
// Border width around the window. /** Border width around the window. */
.menu_bw = 1, .menu_bw = 1,
// The width of the switcher. (0100 in % > 100 in pixels) /** The width of the switcher. (0100 in % > 100 in pixels) */
.menu_width = 50, .menu_width = 50,
// Maximum number of options to show. /** Maximum number of options to show. */
.menu_lines = 15, .menu_lines = 15,
// Number of columns /** Number of columns */
.menu_columns = 1, .menu_columns = 1,
// Font /** Font */
.menu_font = "mono 12", .menu_font = "mono 12",
// Foreground color /** Foreground color */
.menu_fg = "#222222", .menu_fg = "#222222",
// Background color /** Background color */
.menu_bg = "#f2f1f0", .menu_bg = "#f2f1f0",
// Foreground color (selected) /** Foreground color (selected) */
.menu_hlfg = "#ffffff", .menu_hlfg = "#ffffff",
// Background color (selected) /** Background color (selected) */
.menu_hlbg = "#005577", .menu_hlbg = "#005577",
// Border color. /** Border color. */
.menu_bc = "black", .menu_bc = "black",
// Terminal to use. (for ssh and open in terminal) /** Terminal to use. (for ssh and open in terminal) */
.terminal_emulator = "x-terminal-emulator", .terminal_emulator = "x-terminal-emulator",
.ssh_client = "ssh", .ssh_client = "ssh",
// Command when executing ssh. /** Command when executing ssh. */
.ssh_command = "{terminal} -e {ssh-client} {host}", .ssh_command = "{terminal} -e {ssh-client} {host}",
// Command when running /** Command when running */
.run_command = "{cmd}", .run_command = "{cmd}",
/** Command executed when running application in terminal */
.run_shell_command = "{terminal} -e {cmd}", .run_shell_command = "{terminal} -e {cmd}",
// Key binding /** Key binding */
.window_key = "F12", .window_key = "F12",
/** Key to open run dialog */
.run_key = "mod1+F2", .run_key = "mod1+F2",
/** Key to open ssh dialog */
.ssh_key = "mod1+F3", .ssh_key = "mod1+F3",
// Location of the window. WL_CENTER, WL_NORTH_WEST, WL_NORTH,WL_NORTH_EAST, etc. /**
* Location of the window.
* Enumeration indicating location or gravity of window.
*
* WL_NORTH_WEST WL_NORTH WL_NORTH_EAST
*
* WL_EAST WL_CENTER WL_EAST
*
* WL_SOUTH_WEST WL_SOUTH WL_SOUTH_EAST
*
*/
.location = WL_CENTER, .location = WL_CENTER,
// Mode of window, list (Vertical) or dmenu like (Horizontal) /** Mode of window, list (Vertical) or dmenu like (Horizontal) */
.hmode = FALSE, .hmode = FALSE,
// Padding of the window. /** Padding between elements */
.padding = 5, .padding = 5,
/** Y offset */
.y_offset = 0, .y_offset = 0,
/** X offset */
.x_offset = 0, .x_offset = 0,
/** Always should config.menu_lines lines, even if less lines are available */
.fixed_num_lines = FALSE, .fixed_num_lines = FALSE,
/** Do not use history */
.disable_history = FALSE, .disable_history = FALSE,
/** Use levenshtein sorting when matching */
.levenshtein_sort = FALSE, .levenshtein_sort = FALSE,
/** Separator to use for dmenu mode */
.separator = '\n', .separator = '\n',
/** Height of an element in #chars */
.element_height = 1, .element_height = 1,
/** Sidebar mode, show the switchers */
.sidebar_mode = FALSE .sidebar_mode = FALSE
}; };

View File

@@ -6,6 +6,9 @@
#define OVERLAP( a, b, c, d ) ( ( ( a ) == ( c ) && ( b ) == ( d ) ) || MIN ( ( a ) + ( b ), ( c ) + ( d ) ) - MAX ( ( a ), ( c ) ) > 0 ) #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 ) ) ) #define INTERSECT( x, y, w, h, x1, y1, w1, h1 ) ( OVERLAP ( ( x ), ( w ), ( x1 ), ( w1 ) ) && OVERLAP ( ( y ), ( h ), ( y1 ), ( h1 ) ) )
/**
* Pointer to xdg cache directory.
*/
extern const char *cache_dir; extern const char *cache_dir;
@@ -24,7 +27,14 @@ typedef enum
PREVIOUS_DIALOG = 1003 PREVIOUS_DIALOG = 1003
} SwitcherMode; } SwitcherMode;
// switcher callback /**
* @param input Pointer to the user input.
* @param data Usr data.
*
* Callback typedef for a switcher
*
* @returns SwitcherMode
*/
typedef SwitcherMode ( *switcher_callback )( char **input, void *data ); typedef SwitcherMode ( *switcher_callback )( char **input, void *data );
/** /**
@@ -42,13 +52,22 @@ typedef enum
MENU_CUSTOM_INPUT = -3, MENU_CUSTOM_INPUT = -3,
/** User wanted to delete entry from history. */ /** User wanted to delete entry from history. */
MENU_ENTRY_DELETE = -4, MENU_ENTRY_DELETE = -4,
/** User wants to jump to another switcher. */
MENU_QUICK_SWITCH = -5, MENU_QUICK_SWITCH = -5,
/** Go to the previous menu. */
MENU_PREVIOUS = -6 MENU_PREVIOUS = -6
} MenuReturn; } MenuReturn;
/** /**
* @param tokens List of (input) tokens to match.
* @param input The entry to match against.
* @param index The current selected index.
* @param data User data.
*
* Function prototype for the matching algorithm. * Function prototype for the matching algorithm.
*
* @returns 1 when it matches, 0 if not.
*/ */
typedef int ( *menu_match_cb )( char **tokens, const char *input, int index, void *data ); typedef int ( *menu_match_cb )( char **tokens, const char *input, int index, void *data );
@@ -71,19 +90,42 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
Time *time, int *shift, Time *time, int *shift,
menu_match_cb mmc, void *mmc_data, menu_match_cb mmc, void *mmc_data,
int *selected_line, int sorting ) __attribute__ ( ( nonnull ( 1, 3, 4, 9 ) ) ); int *selected_line, int sorting ) __attribute__ ( ( nonnull ( 1, 3, 4, 9 ) ) );
/**
* @param sig The caught signal
*
* Catch the exit signal generated by X.
*/
void catch_exit ( __attribute__( ( unused ) ) int sig ); void catch_exit ( __attribute__( ( unused ) ) int sig );
/**
* Enumeration indicating location or gravity of window.
*
* WL_NORTH_WEST WL_NORTH WL_NORTH_EAST
*
* WL_EAST WL_CENTER WL_EAST
*
* WL_SOUTH_WEST WL_SOUTH WL_SOUTH_EAST
*
*/
typedef enum _WindowLocation typedef enum _WindowLocation
{ {
/** Center */
WL_CENTER = 0, WL_CENTER = 0,
/** Left top corner. */
WL_NORTH_WEST = 1, WL_NORTH_WEST = 1,
/** Top middle */
WL_NORTH = 2, WL_NORTH = 2,
/** Top right */
WL_NORTH_EAST = 3, WL_NORTH_EAST = 3,
/** Middle right */
WL_EAST = 4, WL_EAST = 4,
/** Bottom right */
WL_EAST_SOUTH = 5, WL_EAST_SOUTH = 5,
/** Bottom middle */
WL_SOUTH = 6, WL_SOUTH = 6,
/** Bottom left */
WL_SOUTH_WEST = 7, WL_SOUTH_WEST = 7,
/** Middle left */
WL_WEST = 8 WL_WEST = 8
} WindowLocation; } WindowLocation;
@@ -93,57 +135,94 @@ typedef enum _WindowLocation
typedef struct _Settings typedef struct _Settings
{ {
/** List of enabled switchers */
char *switchers; char *switchers;
// Window settings /** Window settings */
unsigned int window_opacity; unsigned int window_opacity;
// Menu settings /** Border width */
unsigned int menu_bw; unsigned int menu_bw;
/** Width (0-100 in %, > 100 in pixels, < 0 in char width.) */
int menu_width; int menu_width;
/** # lines */
unsigned int menu_lines; unsigned int menu_lines;
/** # Columns */
unsigned int menu_columns; unsigned int menu_columns;
/** Font string (pango format) */
char * menu_font; char * menu_font;
/** Foreground color */
char * menu_fg; char * menu_fg;
/** Background color */
char * menu_bg; char * menu_bg;
/** Highlight foreground color */
char * menu_hlfg; char * menu_hlfg;
/** Highlight background color */
char * menu_hlbg; char * menu_hlbg;
/** Border color */
char * menu_bc; char * menu_bc;
// Behavior /** Terminal to use */
char * terminal_emulator; char * terminal_emulator;
/** SSH client to use */
char * ssh_client; char * ssh_client;
/** Command to execute when ssh session is selected */
// Command to execute when ssh session is selected.
char * ssh_command; char * ssh_command;
// Command for executing an application. /** Command for executing an application */
char * run_command; char * run_command;
/** Command for executing an application in a terminal */
char * run_shell_command; char * run_shell_command;
// Key bindings /** Key to open window switcher */
char * window_key; char * window_key;
/** Key to open run dialog */
char * run_key; char * run_key;
/** Key to open ssh dialog */
char * ssh_key; char * ssh_key;
/** Windows location/gravity */
WindowLocation location; WindowLocation location;
/** Horizontal mode. */
unsigned int hmode; unsigned int hmode;
/** Padding between elements */
unsigned int padding; unsigned int padding;
/** Y offset */
int y_offset; int y_offset;
/** X offset */
int x_offset; int x_offset;
/** Always should config.menu_lines lines, even if less lines are available */
unsigned int fixed_num_lines; unsigned int fixed_num_lines;
/** Do not use history */
unsigned int disable_history; unsigned int disable_history;
/** Use levenshtein sorting when matching */
unsigned int levenshtein_sort; unsigned int levenshtein_sort;
/** Separator to use for dmenu mode */
char separator; char separator;
/** Height of an element in #chars */
int element_height; int element_height;
/** Sidebar mode, show the switchers */
int sidebar_mode; int sidebar_mode;
} Settings; } Settings;
/** Global Settings structure. */
extern Settings config; extern Settings config;
/**
* @params tokens
* @param tokens List of (input) tokens to match.
* @param input The entry to match against.
* @param index The current selected index.
* @param data User data.
*
* Tokenized match, match tokens to line input.
*
* @returns 1 when matches, 0 otherwise
*/
int token_match ( char **tokens, const char *input, int token_match ( char **tokens, const char *input,
__attribute__( ( unused ) ) int index, __attribute__( ( unused ) ) int index,
__attribute__( ( unused ) ) void *data ); __attribute__( ( unused ) ) void *data );
/**
* @param msg The error message to show.
*
* The error message to show.
*/
void error_dialog ( char *msg ); void error_dialog ( char *msg );
#endif #endif

View File

@@ -6,22 +6,36 @@
*/ */
typedef struct typedef struct
{ {
// Prompt to display. /** Prompt to display. */
char *name; char *name;
// The script /** The script */
char *script_path; char *script_path;
} ScriptOptions; } ScriptOptions;
/**
* @param input Pointer to the user-input string.
* @param data Custom data pointer for callback.
*
* Run the script dialog
*
* @returns SwitcherMode selected by user.
*/
SwitcherMode script_switcher_dialog ( char **input, void *data ); SwitcherMode script_switcher_dialog ( char **input, void *data );
/** /**
* @param str The input string to parse
*
* Parse an argument string into the right ScriptOptions data object. * Parse an argument string into the right ScriptOptions data object.
* This is off format: <Name>:<Script> * This is off format: <Name>:<Script>
* Return NULL when it fails. *
* @returns NULL when it fails, a newly allocated ScriptOptions when successful.
*/ */
ScriptOptions *script_switcher_parse_setup ( const char *str ); ScriptOptions *script_switcher_parse_setup ( const char *str );
/** /**
* @param sw Handle to the ScriptOption
*
* Free the ScriptOptions block. * Free the ScriptOptions block.
*/ */
void script_switcher_free_options ( ScriptOptions *sw ); void script_switcher_free_options ( ScriptOptions *sw );