1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00
Conflicts:
	doc/rofi-manpage.markdown
	doc/rofi.1
This commit is contained in:
Edwin Pujols 2015-01-12 15:48:04 -04:00
commit 32b8281cfb
9 changed files with 119 additions and 67 deletions

View file

@ -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) */

View file

@ -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`

View file

@ -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

View file

@ -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 */

View file

@ -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
);

View file

@ -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 );

View file

@ -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 );

View file

@ -75,6 +75,8 @@ static XrmOption xrmOptions[] = {
{ 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 },

View file

@ -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 );