strtrim -> strtrim_end
This commit is contained in:
parent
92499b38a0
commit
79dff42fe1
16
dunst.c
16
dunst.c
@ -365,7 +365,7 @@ void update_lists()
|
|||||||
/* TODO get draw_txt_buf as argument */
|
/* TODO get draw_txt_buf as argument */
|
||||||
int do_word_wrap(char *source, int max_width)
|
int do_word_wrap(char *source, int max_width)
|
||||||
{
|
{
|
||||||
strtrim(source);
|
strtrim_end(source);
|
||||||
if (!source || source == '\0' || strcmp(source, "") == 0)
|
if (!source || source == '\0' || strcmp(source, "") == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -406,9 +406,14 @@ int do_word_wrap(char *source, int max_width)
|
|||||||
|
|
||||||
void update_draw_txt_buf(notification * n, int max_width)
|
void update_draw_txt_buf(notification * n, int max_width)
|
||||||
{
|
{
|
||||||
|
strtrim_end(n->msg);
|
||||||
|
char *msg = n->msg;
|
||||||
|
while(isspace(*msg))
|
||||||
|
msg++;
|
||||||
|
|
||||||
if (!n->draw_txt_buf.txt) {
|
if (!n->draw_txt_buf.txt) {
|
||||||
int dup_len = strlen(" () ") + digit_count(INT_MAX);
|
int dup_len = strlen(" () ") + digit_count(INT_MAX);
|
||||||
int msg_len = strlen(n->msg) + 2; /* 2 == surrounding spaces */
|
int msg_len = strlen(msg) + 2; /* 2 == surrounding spaces */
|
||||||
int age_len = strlen(" ( h 60m 60s old ) ")
|
int age_len = strlen(" ( h 60m 60s old ) ")
|
||||||
+ digit_count(INT_MAX); /* could be INT_MAX hours */
|
+ digit_count(INT_MAX); /* could be INT_MAX hours */
|
||||||
int line_length = dup_len + msg_len + age_len;
|
int line_length = dup_len + msg_len + age_len;
|
||||||
@ -432,7 +437,7 @@ void update_draw_txt_buf(notification * n, int max_width)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* print msg */
|
/* print msg */
|
||||||
strncat(buf, n->msg, bufsize - strlen(buf));
|
strncat(buf, msg, bufsize - strlen(buf));
|
||||||
next = buf + strlen(buf);
|
next = buf + strlen(buf);
|
||||||
|
|
||||||
/* print age */
|
/* print age */
|
||||||
@ -825,7 +830,6 @@ int init_notification(notification * n, int id)
|
|||||||
n->msg = string_replace("%b", n->body, n->msg);
|
n->msg = string_replace("%b", n->body, n->msg);
|
||||||
|
|
||||||
n->msg = fix_markup(n->msg);
|
n->msg = fix_markup(n->msg);
|
||||||
n->msg = strtrim(n->msg);
|
|
||||||
|
|
||||||
n->dup_count = 0;
|
n->dup_count = 0;
|
||||||
n->draw_txt_buf.txt = NULL;
|
n->draw_txt_buf.txt = NULL;
|
||||||
@ -980,10 +984,10 @@ void init_shortcut(keyboard_shortcut * ks)
|
|||||||
str++;
|
str++;
|
||||||
*str = '\0';
|
*str = '\0';
|
||||||
str++;
|
str++;
|
||||||
strtrim(mod);
|
strtrim_end(mod);
|
||||||
ks->mask = ks->mask | string_to_mask(mod);
|
ks->mask = ks->mask | string_to_mask(mod);
|
||||||
}
|
}
|
||||||
strtrim(str);
|
strtrim_end(str);
|
||||||
|
|
||||||
ks->sym = XStringToKeysym(str);
|
ks->sym = XStringToKeysym(str);
|
||||||
ks->code = XKeysymToKeycode(dc->dpy, ks->sym);
|
ks->code = XKeysymToKeycode(dc->dpy, ks->sym);
|
||||||
|
8
utils.c
8
utils.c
@ -7,20 +7,14 @@
|
|||||||
#include "dunst.h"
|
#include "dunst.h"
|
||||||
|
|
||||||
|
|
||||||
char *strtrim(char *str)
|
void strtrim_end(char *str)
|
||||||
{
|
{
|
||||||
char *end;
|
char *end;
|
||||||
while (isspace(*str))
|
|
||||||
str++;
|
|
||||||
|
|
||||||
end = str + strlen(str) - 1;
|
end = str + strlen(str) - 1;
|
||||||
while (isspace(*end)) {
|
while (isspace(*end)) {
|
||||||
*end = '\0';
|
*end = '\0';
|
||||||
end--;
|
end--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *string_replace(const char *needle, const char *replacement,
|
char *string_replace(const char *needle, const char *replacement,
|
||||||
|
2
utils.h
2
utils.h
@ -1,7 +1,7 @@
|
|||||||
#ifndef UTIL_H
|
#ifndef UTIL_H
|
||||||
#define UTIL_H
|
#define UTIL_H
|
||||||
/* remove spaces before and after str */
|
/* remove spaces before and after str */
|
||||||
char *strtrim(char *str);
|
void strtrim_end(char *str);
|
||||||
|
|
||||||
/* replace needle with replacement in haystack */
|
/* replace needle with replacement in haystack */
|
||||||
char *string_replace(const char *needle, const char *replacement,
|
char *string_replace(const char *needle, const char *replacement,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user