new option for line height

This implements github issue #51
This commit is contained in:
Sascha Kruse 2012-08-16 23:15:42 +02:00
parent 31d4c1e5a4
commit 788ed745ac
4 changed files with 27 additions and 7 deletions

View File

@ -86,6 +86,10 @@ a negative from the right side of the screen.
Y is measured from the top and down respectevly. Y is measured from the top and down respectevly.
see also EXAMPLES show the notification on monitor n. see also EXAMPLES show the notification on monitor n.
=item B<-lh/-line_height> height
The height of a single line in pixel. If the height is smaller than the font height, it will get raised to the font height.
=item B<-v/--version> =item B<-v/--version>
print version information. print version information.

View File

@ -20,6 +20,7 @@ enum alignment align = left; /* text alignment [left/center/right] */
int sticky_history = True; int sticky_history = True;
int verbosity = 0; int verbosity = 0;
int word_wrap = False; int word_wrap = False;
int line_height = 0; /* a line height < font height will be raised to font height */
/* monitor to display notifications on */ /* monitor to display notifications on */

25
dunst.c
View File

@ -478,6 +478,8 @@ void draw_win(void)
{ {
int width, x, y, height; int width, x, y, height;
line_height = MAX(line_height, font_h);
update_screen_info(); update_screen_info();
/* calculate width */ /* calculate width */
@ -517,9 +519,9 @@ void draw_win(void)
/* calculate height */ /* calculate height */
if (geometry.h == 0) { if (geometry.h == 0) {
height = line_cnt * font_h; height = line_cnt * line_height;
} else { } else {
height = MIN(geometry.h, line_cnt) * font_h; height = MIN(geometry.h, line_cnt) * line_height;
} }
/* add "(x more)" */ /* add "(x more)" */
@ -535,7 +537,7 @@ void draw_win(void)
if (geometry.h != 1) { if (geometry.h != 1) {
/* add additional line */ /* add additional line */
x_more.txt = calloc(x_more_len, sizeof(char)); x_more.txt = calloc(x_more_len, sizeof(char));
height += font_h; height += line_height;
line_cnt++; line_cnt++;
print_to = x_more.txt; print_to = x_more.txt;
@ -553,6 +555,7 @@ void draw_win(void)
snprintf(print_to, x_more_len, "(%d more)", more); snprintf(print_to, x_more_len, "(%d more)", more);
} }
assert(line_height > 0);
assert(font_h > 0); assert(font_h > 0);
assert(width > 0); assert(width > 0);
assert(height > 0); assert(height > 0);
@ -574,18 +577,19 @@ void draw_win(void)
char *line = draw_txt_get_line(&n->draw_txt_buf, i + 1); char *line = draw_txt_get_line(&n->draw_txt_buf, i + 1);
dc->x = 0; dc->x = 0;
drawrect(dc, 0, 0, width, font_h, True, n->colors->BG); drawrect(dc, 0, 0, width, line_height, True, n->colors->BG);
dc->x = calculate_x_offset(width, textw(dc, line)); dc->x = calculate_x_offset(width, textw(dc, line));
dc->y += (line_height - font_h) / 2;
drawtext(dc, line, n->colors); drawtext(dc, line, n->colors);
dc->y += font_h; dc->y += line_height - ((line_height - font_h) / 2);
} }
} }
/* draw x_more */ /* draw x_more */
if (x_more.txt) { if (x_more.txt) {
dc->x = 0; dc->x = 0;
drawrect(dc, 0, 0, width, font_h, True, last_color->BG); drawrect(dc, 0, 0, width, line_height, True, last_color->BG);
dc->x = calculate_x_offset(width, textw(dc, x_more.txt)); dc->x = calculate_x_offset(width, textw(dc, x_more.txt));
drawtext(dc, x_more.txt, last_color); drawtext(dc, x_more.txt, last_color);
} }
@ -1235,6 +1239,8 @@ void parse_cmdline(int argc, char *argv[])
{"mon", required_argument, NULL, 'm'}, {"mon", required_argument, NULL, 'm'},
{"ns", no_argument, NULL, 'x'}, {"ns", no_argument, NULL, 'x'},
{"follow", required_argument, NULL, 'o'}, {"follow", required_argument, NULL, 'o'},
{"line_height", required_argument, NULL, 'H'},
{"lh", required_argument, NULL, 'H'},
{"version", no_argument, NULL, 'v'}, {"version", no_argument, NULL, 'v'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@ -1327,6 +1333,9 @@ void parse_cmdline(int argc, char *argv[])
case 'o': case 'o':
parse_follow_mode(optarg); parse_follow_mode(optarg);
break; break;
case 'H':
line_height = atoi(optarg);
break;
case 'v': case 'v':
print_version(); print_version();
break; break;
@ -1422,6 +1431,8 @@ dunst_ini_handle(void *user_data, const char *section,
free(c); free(c);
} else if (strcmp(name, "geometry") == 0) } else if (strcmp(name, "geometry") == 0)
geom = dunst_ini_get_string(value); geom = dunst_ini_get_string(value);
else if (strcmp(name, "line_height") == 0)
line_height = atoi(value);
else if (strcmp(name, "modifier") == 0) { else if (strcmp(name, "modifier") == 0) {
depricated_dunstrc_shortcuts = True; depricated_dunstrc_shortcuts = True;
char *c = dunst_ini_get_string(value); char *c = dunst_ini_get_string(value);
@ -1622,7 +1633,7 @@ int main(int argc, char *argv[])
void usage(int exit_status) void usage(int exit_status)
{ {
fputs fputs
("usage: dunst [-h/--help] [-v] [-geometry geom] [-fn font] [-format fmt]\n[-nb color] [-nf color] [-lb color] [-lf color] [-cb color] [ -cf color]\n[-to secs] [-lto secs] [-cto secs] [-nto secs] [-key key] [-history_key key] [-all_key key] [-mon n] [-follow none/mouse/keyboard] [-config dunstrc]\n", ("usage: dunst [-h/--help] [-v] [-geometry geom] [-lh height] [-fn font] [-format fmt]\n[-nb color] [-nf color] [-lb color] [-lf color] [-cb color] [ -cf color]\n[-to secs] [-lto secs] [-cto secs] [-nto secs] [-key key] [-history_key key] [-all_key key] [-mon n] [-follow none/mouse/keyboard] [-config dunstrc]\n",
stderr); stderr);
exit(exit_status); exit(exit_status);
} }

View File

@ -62,6 +62,10 @@
# timeout as if it would normally down # timeout as if it would normally down
sticky_history = yes sticky_history = yes
# The height of a single line. If the height is smaller than the font height,
# it will get raised to the font height.
line_height = 0
[shortcuts] [shortcuts]
# shortcuts are specified as [modifier+][modifier+]...key # shortcuts are specified as [modifier+][modifier+]...key
# available modifiers are 'ctrl', 'mod1' (the alt-key), 'mod2', 'mod3' # available modifiers are 'ctrl', 'mod1' (the alt-key), 'mod2', 'mod3'