diff options
author | Edwin Pujols <edwinpm5@gmail.com> | 2015-01-12 15:48:04 -0400 |
---|---|---|
committer | Edwin Pujols <edwinpm5@gmail.com> | 2015-01-12 15:48:04 -0400 |
commit | 32b8281cfbe9cd2cfbca9bc21aef1265ba8655bf (patch) | |
tree | 73732c69ee95d561c45ed4e076016887e449d329 | |
parent | d1ba4bd8dc1e1d1e0e57015e4d9dd3fe0c03a3b9 (diff) | |
parent | 6dc6269fe70fff24540ecbf05357d0b41960f1a1 (diff) |
Merge branch 'master' of https://github.com/DaveDavenport/rofi
Conflicts:
doc/rofi-manpage.markdown
doc/rofi.1
-rw-r--r-- | config/config.def.c | 2 | ||||
-rw-r--r-- | doc/rofi-manpage.markdown | 23 | ||||
-rw-r--r-- | doc/rofi.1 | 28 | ||||
-rw-r--r-- | include/rofi.h | 2 | ||||
-rw-r--r-- | include/textbox.h | 7 | ||||
-rw-r--r-- | source/rofi.c | 25 | ||||
-rw-r--r-- | source/textbox.c | 23 | ||||
-rw-r--r-- | source/xrmoptions.c | 74 | ||||
-rw-r--r-- | test/textbox-test.c | 2 |
9 files changed, 119 insertions, 67 deletions
diff --git a/config/config.def.c b/config/config.def.c index 5a122def..daa40027 100644 --- a/config/config.def.c +++ b/config/config.def.c @@ -50,6 +50,8 @@ Settings config = { .menu_fg = "#222222", /** Background color */ .menu_bg = "#f2f1f0", + /** Background color alternate row */ + .menu_bg_alt = NULL, /** Foreground color (selected) */ .menu_hlfg = "#ffffff", /** Background color (selected) */ diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 3762b290..ede15c68 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -7,13 +7,14 @@ rofi - A window switcher, run dialog and dmenu replacement ## SYNOPSIS **rofi** [ -width *pct_scr* ] [ -lines *lines* ] [ -columns *columns* ] [ -font *pangofont* ] [ -fg -*color* ] [ -bg *color* ] [ -hlfg *color* ] [ -hlbg *color* ] [ -key *combo* ] [ -dkey *comdo* ] [ --rkey *comdo* ] [ -terminal *terminal* ] [ -location *position* ] [ -hmode ] [ -fixed-num-lines ] [ --padding *padding* ] [ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] -[ -dmenu [ -p *prompt* ] ] [ -ssh-client *client* ] [ -ssh-command *command* ] [ -now ] [ -rnow ] [ --snow ] [ -version ] [ -help] [ -dump-xresources ] [ -disable-history ] [ -levenshtein-sort ] [ --case-sensitive ] [ -show *mode* ] [ -switcher *mode1,mode2* ] [ -e *message*] [ -sep *separator* ] -[ -eh *element height* ] [ -l *selected line* ] [ -run-list-command *cmd* ] +*color* ] [ -bg *color* ] [ -bgalt *color* ] [ -hlfg *color* ] [ -hlbg *color* ] [ -key *combo* ] [ +-dkey *comdo* ] [ -rkey *comdo* ] [ -terminal *terminal* ] [ -location *position* ] [ -hmode ] [ +-fixed-num-lines ] [ -padding *padding* ] [ -opacity *opacity%* ] [ -display *display* ] [ -bc +*color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ] [ -ssh-client *client* ] [ -ssh-command +*command* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump-xresources ] [ +-disable-history ] [ -levenshtein-sort ] [ -case-sensitive ] [ -show *mode* ] [ -switcher *mode1, +mode2* ] [ -e *message*] [ -sep *separator* ] [ -eh *element height* ] [ -l *selected line* ] [ +-run-list-command *cmd* ] ## DESCRIPTION @@ -129,8 +130,14 @@ The default key combinations are: Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222). - rofi -fg "#222222" + rofi -bg "#222222" +`-bg` + + Set the background text color for alternating rows (X11 named color or hex #rrggbb) for the menu + (default: #222222). + + rofi -bgalt "#222222" `-bc` @@ -5,13 +5,14 @@ rofi \- A window switcher, run dialog and dmenu replacement .SH SYNOPSIS .PP \fBrofi\fP [ \-width \fIpct_scr\fP ] [ \-lines \fIlines\fP ] [ \-columns \fIcolumns\fP ] [ \-font \fIpangofont\fP ] [ \-fg -\fIcolor\fP ] [ \-bg \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [ \-dkey \fIcomdo\fP ] [ -\-rkey \fIcomdo\fP ] [ \-terminal \fIterminal\fP ] [ \-location \fIposition\fP ] [ \-hmode ] [ \-fixed\-num\-lines ] [ -\-padding \fIpadding\fP ] [ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc \fIcolor\fP ] [ \-bw \fIwidth\fP ] -[ \-dmenu [ \-p \fIprompt\fP ] ] [ \-ssh\-client \fIclient\fP ] [ \-ssh\-command \fIcommand\fP ] [ \-now ] [ \-rnow ] [ -\-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ -\-case\-sensitive ] [ \-show \fImode\fP ] [ \-switcher \fImode1,mode2\fP ] [ \-e \fImessage\fP] [ \-sep \fIseparator\fP ] -[ \-eh \fIelement height\fP ] [ \-l \fIselected line\fP ] [ \-run\-list\-command \fIcmd\fP ] +\fIcolor\fP ] [ \-bg \fIcolor\fP ] [ \-bgalt \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [ +\-dkey \fIcomdo\fP ] [ \-rkey \fIcomdo\fP ] [ \-terminal \fIterminal\fP ] [ \-location \fIposition\fP ] [ \-hmode ] [ +\-fixed\-num\-lines ] [ \-padding \fIpadding\fP ] [ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc +\fIcolor\fP ] [ \-bw \fIwidth\fP ] [ \-dmenu [ \-p \fIprompt\fP ] ] [ \-ssh\-client \fIclient\fP ] [ \-ssh\-command +\fIcommand\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] [ +\-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-show \fImode\fP ] [ \-switcher \fImode1, +mode2\fP ] [ \-e \fImessage\fP] [ \-sep \fIseparator\fP ] [ \-eh \fIelement height\fP ] [ \-l \fIselected line\fP ] [ +\-run\-list\-command \fIcmd\fP ] .SH DESCRIPTION .PP \fBrofi\fP is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number. @@ -152,7 +153,18 @@ Set the background text color (X11 named color or hex #rrggbb) for the menu (def .PP .RS .nf - rofi \-fg "#222222" + rofi \-bg "#222222" +.fi +.RE +.PP +\fB\fC\-bg\fR +.IP +Set the background text color for alternating rows (X11 named color or hex #rrggbb) for the menu +(default: #222222). +.PP +.RS +.nf + rofi \-bgalt "#222222" .fi .RE .PP diff --git a/include/rofi.h b/include/rofi.h index b1fb17ff..45ced591 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -154,6 +154,8 @@ typedef struct _Settings char * menu_fg; /** Background color */ char * menu_bg; + /** Background color alt */ + char * menu_bg_alt; /** Highlight foreground color */ char * menu_hlfg; /** Highlight background color */ diff --git a/include/textbox.h b/include/textbox.h index e080079b..5f7d1bc5 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -35,6 +35,8 @@ typedef enum { // Render font normally NORMAL, + // Alternating row. + ALT, // Render font highlighted (inverted colors.) HIGHLIGHT, } TextBoxFontType; @@ -132,9 +134,8 @@ void textbox_insert ( textbox *tb, int pos, char *str ); void textbox_hide ( textbox *tb ); /** - * @param font_str The font to use. - * @param font_active_str The font to use for active entries. * @param bg The background color. + * @param bg_alt The background color for alternating row. * @param fg The foreground color. * @param hlbg The background color for a highlighted entry. * @param hlfg The foreground color for a highlighted entry. @@ -144,7 +145,7 @@ void textbox_hide ( textbox *tb ); * Clean with textbox_cleanup() */ void textbox_setup ( - const char *bg, const char *fg, + const char *bg, const char *bg_alt, const char *fg, const char *hlbg, const char *hlfg ); diff --git a/source/rofi.c b/source/rofi.c index 8205ecd0..01faa0cc 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1278,8 +1278,9 @@ static void menu_draw ( MenuState *state ) textbox_text ( state->boxes[i], "" ); } else{ + TextBoxFontType type = ( ( ( i % state->max_rows ) & 1 ) == 0 ) ? NORMAL : ALT; char *text = state->filtered[i + offset]; - TextBoxFontType tbft = ( i + offset ) == state->selected ? HIGHLIGHT : NORMAL; + TextBoxFontType tbft = ( i + offset ) == state->selected ? HIGHLIGHT : type; textbox_font ( state->boxes[i], tbft ); textbox_text ( state->boxes[i], text ); } @@ -1944,7 +1945,7 @@ static int run_dmenu () { int ret_state; textbox_setup ( - config.menu_bg, config.menu_fg, + config.menu_bg, config.menu_bg_alt, config.menu_fg, config.menu_hlbg, config.menu_hlfg ); char *input = NULL; @@ -1977,7 +1978,7 @@ static void run_switcher ( int do_fork, SwitcherMode mode ) // Because of the above fork, we want to do this here. // Make sure this is isolated to its own thread. textbox_setup ( - config.menu_bg, config.menu_fg, + config.menu_bg, config.menu_bg_alt, config.menu_fg, config.menu_hlbg, config.menu_hlfg ); char *input = NULL; @@ -2194,6 +2195,7 @@ static void parse_cmd_options ( int argc, char ** argv ) find_arg_str ( argc, argv, "-font", &( config.menu_font ) ); find_arg_str ( argc, argv, "-fg", &( config.menu_fg ) ); find_arg_str ( argc, argv, "-bg", &( config.menu_bg ) ); + find_arg_str ( argc, argv, "-bgalt", &( config.menu_bg_alt ) ); find_arg_str ( argc, argv, "-hlfg", &( config.menu_hlfg ) ); find_arg_str ( argc, argv, "-hlbg", &( config.menu_hlbg ) ); find_arg_str ( argc, argv, "-bc", &( config.menu_bc ) ); @@ -2245,11 +2247,6 @@ static void parse_cmd_options ( int argc, char ** argv ) if ( find_arg ( argc, argv, "-sidebar-mode" ) >= 0 ) { config.sidebar_mode = TRUE; } - // Dump. - if ( find_arg ( argc, argv, "-dump-xresources" ) >= 0 ) { - xresource_dump (); - exit ( EXIT_SUCCESS ); - } } /** @@ -2322,6 +2319,10 @@ static void config_sanity_check ( void ) fprintf ( stderr, "config.hmode is invalid.\n" ); exit ( 1 ); } + // If alternative row is not set, copy the normal background color. + if ( config.menu_bg_alt == NULL ) { + config.menu_bg_alt = config.menu_bg; + } } /** @@ -2452,6 +2453,12 @@ int main ( int argc, char *argv[] ) load_configuration ( display ); + // Dump. + if ( find_arg ( argc, argv, "-dump-xresources" ) >= 0 ) { + xresource_dump (); + exit ( EXIT_SUCCESS ); + } + // setup_switchers setup_switchers (); @@ -2491,7 +2498,7 @@ int main ( int argc, char *argv[] ) char *msg = NULL; if ( find_arg_str ( argc, argv, "-e", &( msg ) ) ) { textbox_setup ( - config.menu_bg, config.menu_fg, + config.menu_bg, config.menu_bg_alt, config.menu_fg, config.menu_hlbg, config.menu_hlfg ); error_dialog ( msg ); diff --git a/source/textbox.c b/source/textbox.c index 0972fd66..a323a2c7 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -54,6 +54,7 @@ XftColor color_fg; XftColor color_bg; XftColor color_hlfg; XftColor color_hlbg; +XftColor color_bg_alt; PangoContext *p_context = NULL; @@ -83,7 +84,19 @@ textbox* textbox_create ( Window parent, pango_layout_set_font_description ( tb->layout, pfd ); pango_font_description_free ( pfd ); - unsigned int cp = ( tbft == NORMAL ) ? color_bg.pixel : color_hlbg.pixel; + unsigned int cp; + switch ( tbft ) + { + case HIGHLIGHT: + cp = color_hlbg.pixel; + break; + case ALT: + cp = color_bg_alt.pixel; + break; + default: + cp = color_bg.pixel; + break; + } tb->window = XCreateSimpleWindow ( display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, None, cp ); @@ -119,6 +132,10 @@ void textbox_font ( textbox *tb, TextBoxFontType tbft ) tb->color_bg = color_hlbg; tb->color_fg = color_hlfg; break; + case ALT: + tb->color_bg = color_bg_alt; + tb->color_fg = color_fg; + break; case NORMAL: default: tb->color_bg = color_bg; @@ -432,7 +449,7 @@ int textbox_keypress ( textbox *tb, XEvent *ev ) */ void textbox_setup ( - const char *bg, const char *fg, + const char *bg, const char *bg_alt, const char *fg, const char *hlbg, const char *hlfg ) { @@ -441,6 +458,7 @@ void textbox_setup ( XftColorAllocName ( display, visual, colormap, fg, &color_fg ); XftColorAllocName ( display, visual, colormap, bg, &color_bg ); + XftColorAllocName ( display, visual, colormap, bg_alt, &color_bg_alt ); XftColorAllocName ( display, visual, colormap, hlfg, &color_hlfg ); XftColorAllocName ( display, visual, colormap, hlbg, &color_hlbg ); @@ -458,6 +476,7 @@ void textbox_cleanup () XftColorFree ( display, visual, colormap, &color_fg ); XftColorFree ( display, visual, colormap, &color_bg ); + XftColorFree ( display, visual, colormap, &color_bg_alt ); XftColorFree ( display, visual, colormap, &color_hlfg ); XftColorFree ( display, visual, colormap, &color_hlbg ); g_object_unref ( p_context ); diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 560899ed..26bc6daf 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -60,57 +60,59 @@ typedef struct * Currently supports string and number. */ static XrmOption xrmOptions[] = { - { xrm_String, "switchers", { .str = &config.switchers }, NULL }, - { xrm_Number, "opacity", { .num = &config.window_opacity }, NULL }, + { xrm_String, "switchers", { .str = &config.switchers }, NULL }, + { xrm_Number, "opacity", { .num = &config.window_opacity }, NULL }, - { xrm_SNumber, "width", { .snum = &config.menu_width }, NULL }, + { xrm_SNumber, "width", { .snum = &config.menu_width }, NULL }, - { xrm_Number, "lines", { .num = &config.menu_lines }, NULL }, - { xrm_Number, "columns", { .num = &config.menu_columns }, NULL }, + { xrm_Number, "lines", { .num = &config.menu_lines }, NULL }, + { xrm_Number, "columns", { .num = &config.menu_columns }, NULL }, - { xrm_String, "font", { .str = &config.menu_font }, NULL }, + { xrm_String, "font", { .str = &config.menu_font }, NULL }, /* Foreground color */ - { xrm_String, "foreground", { .str = &config.menu_fg }, NULL }, - { xrm_String, "fg", { .str = &config.menu_fg }, NULL }, + { xrm_String, "foreground", { .str = &config.menu_fg }, NULL }, + { xrm_String, "fg", { .str = &config.menu_fg }, NULL }, - { xrm_String, "background", { .str = &config.menu_bg }, NULL }, - { xrm_String, "bg", { .str = &config.menu_bg }, NULL }, + { xrm_String, "background", { .str = &config.menu_bg }, NULL }, + { xrm_String, "bg", { .str = &config.menu_bg }, NULL }, + { xrm_String, "background-alternate", { .str = &config.menu_bg_alt }, NULL }, + { xrm_String, "bgalt", { .str = &config.menu_bg_alt }, NULL }, - { xrm_String, "highlightfg", { .str = &config.menu_hlfg }, NULL }, - { xrm_String, "hlfg", { .str = &config.menu_hlfg }, NULL }, + { xrm_String, "highlightfg", { .str = &config.menu_hlfg }, NULL }, + { xrm_String, "hlfg", { .str = &config.menu_hlfg }, NULL }, - { xrm_String, "highlightbg", { .str = &config.menu_hlbg }, NULL }, - { xrm_String, "hlbg", { .str = &config.menu_hlbg }, NULL }, + { xrm_String, "highlightbg", { .str = &config.menu_hlbg }, NULL }, + { xrm_String, "hlbg", { .str = &config.menu_hlbg }, NULL }, - { xrm_String, "bordercolor", { .str = &config.menu_bc }, NULL }, - { xrm_String, "bc", { .str = &config.menu_bc }, NULL }, + { xrm_String, "bordercolor", { .str = &config.menu_bc }, NULL }, + { xrm_String, "bc", { .str = &config.menu_bc }, NULL }, - { xrm_Number, "borderwidth", { .num = &config.menu_bw }, NULL }, - { xrm_Number, "bw", { .num = &config.menu_bw }, NULL }, + { xrm_Number, "borderwidth", { .num = &config.menu_bw }, NULL }, + { xrm_Number, "bw", { .num = &config.menu_bw }, NULL }, - { xrm_Number, "location", { .num = &config.location }, NULL }, + { xrm_Number, "location", { .num = &config.location }, NULL }, - { xrm_Number, "padding", { .num = &config.padding }, NULL }, - { xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL }, - { xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL }, - { xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL }, - { xrm_Boolean, "hmode", { .num = &config.hmode }, NULL }, + { xrm_Number, "padding", { .num = &config.padding }, NULL }, + { xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL }, + { xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL }, + { xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL }, + { xrm_Boolean, "hmode", { .num = &config.hmode }, NULL }, - { xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL }, - { xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL }, - { xrm_String, "ssh-command", { .str = &config.ssh_command }, NULL }, - { xrm_String, "run-command", { .str = &config.run_command }, NULL }, - { xrm_String, "run-list-command", { .str = &config.run_list_command }, NULL }, - { xrm_String, "run-shell-command", { .str = &config.run_shell_command }, NULL }, + { xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL }, + { xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL }, + { xrm_String, "ssh-command", { .str = &config.ssh_command }, NULL }, + { xrm_String, "run-command", { .str = &config.run_command }, NULL }, + { xrm_String, "run-list-command", { .str = &config.run_list_command }, NULL }, + { xrm_String, "run-shell-command", { .str = &config.run_shell_command }, NULL }, - { xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL }, - { xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort }, NULL }, + { xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL }, + { xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort }, NULL }, /* Key bindings */ - { xrm_String, "key", { .str = &config.window_key }, NULL }, - { xrm_String, "rkey", { .str = &config.run_key }, NULL }, - { xrm_String, "skey", { .str = &config.ssh_key }, NULL }, - { xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL } + { xrm_String, "key", { .str = &config.window_key }, NULL }, + { xrm_String, "rkey", { .str = &config.run_key }, NULL }, + { xrm_String, "skey", { .str = &config.ssh_key }, NULL }, + { xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL } }; diff --git a/test/textbox-test.c b/test/textbox-test.c index 09ba9973..fdeac0c3 100644 --- a/test/textbox-test.c +++ b/test/textbox-test.c @@ -49,7 +49,7 @@ int main ( int argc, char **argv ) color_get ( display, config.menu_bg ) ); TASSERT( mw != None ); - textbox_setup ( config.menu_bg, config.menu_fg, + textbox_setup ( config.menu_bg, config.menu_bg_alt, config.menu_fg, config.menu_hlbg, config.menu_hlfg ); textbox *box = textbox_create(mw , TB_EDITABLE|TB_AUTOWIDTH|TB_AUTOHEIGHT, 0,0, -1, -1, NORMAL, "test"); TASSERT( box != NULL ); |