summaryrefslogtreecommitdiffstats
path: root/include/rofi.h
blob: e18398795c3ba59e2bf323a881f4c6de82fe97fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef __SIMPLESWITCHER_H__
#define __SIMPLESWITCHER_H__

#include <X11/X.h>

#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)))

extern const char *cache_dir;
#ifdef I3
extern char *i3_socket_path;
#endif

typedef enum {
    WINDOW_SWITCHER,
    RUN_DIALOG,
    SSH_DIALOG,
    NUM_DIALOGS,
    DMENU_DIALOG,
    MODE_EXIT,
    NEXT_DIALOG
} SwitcherMode;

typedef enum {
    MENU_OK           =  0,
    MENU_CANCEL       = -1,
    MENU_NEXT         = -2,
    MENU_CUSTOM_INPUT = -3,
    MENU_ENTRY_DELETE = -4

} MenuReturn;


typedef int ( *menu_match_cb )( char **tokens, const char *input, int index, void *data );
MenuReturn menu( char **lines, char **input, char *prompt,
                 Time *time, int *shift,
                 menu_match_cb mmc, void *mmc_data,
                 int *selected_line );


/**
 * Allocator wrappers
 */
void* allocate( unsigned long bytes ) __attribute__((malloc));
void* allocate_clear( unsigned long bytes );
void* reallocate( void *ptr, unsigned long bytes );


void catch_exit( __attribute__( ( unused ) ) int sig );

typedef enum _WindowLocation {
    CENTER      = 0,
    NORTH_WEST  = 1,
    NORTH       = 2,
    NORTH_EAST  = 3,
    EAST        = 4,
    EAST_SOUTH  = 5,
    SOUTH       = 6,
    SOUTH_WEST  = 7,
    WEST        = 8
} WindowLocation;

typedef enum {
    VERTICAL   = 0,
    HORIZONTAL = 1
} WindowMode;
/**
 * Settings
 */

typedef struct _Settings {
    // Window settings
    unsigned int    window_opacity;
    // Menu settings
    unsigned int    menu_bw;
    unsigned int    menu_width;
    unsigned int    menu_lines;
    char *          menu_font;
    char *          menu_fg;
    char *          menu_bg;
    char *          menu_hlfg;
    char *          menu_hlbg;
    char *          menu_bc;
    // Behavior
    unsigned int    zeltak_mode;
    char *          terminal_emulator;
#ifdef I3
    unsigned int    i3_mode;
#endif
    // Key bindings
    char *          window_key;
    char *          run_key;
    char *          ssh_key;
    WindowLocation  location;
    WindowMode      wmode;
    unsigned int    padding;
} Settings;

extern Settings config;


int token_match ( char **tokens, const char *input,
                  __attribute__( ( unused ) )int index,
                  __attribute__( ( unused ) )void *data );
#endif