mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Add format option to disable padding with space the "window-format" entries (#1715)
This commit is contained in:
parent
95fe682939
commit
b3c46d2d5a
3 changed files with 8 additions and 9 deletions
|
@ -948,7 +948,7 @@ Format what is being displayed for windows.
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
\fIlen\fP: maximum field length (0 for auto-size). If length and window \fIwidth\fP are negative, field length is \fIwidth - len\fP\&.
|
\fIlen\fP: maximum field length (0 for auto-size). If length is negative, the entry will be unchanged.
|
||||||
.br
|
.br
|
||||||
If length is positive, the entry will be truncated or padded to fill that length.
|
If length is positive, the entry will be truncated or padded to fill that length.
|
||||||
|
|
||||||
|
|
|
@ -572,7 +572,7 @@ Format what is being displayed for windows.
|
||||||
* **r**: role
|
* **r**: role
|
||||||
* **c**: class
|
* **c**: class
|
||||||
|
|
||||||
*len*: maximum field length (0 for auto-size). If length and window *width* are negative, field length is *width - len*.
|
*len*: maximum field length (0 for auto-size). If length is negative, the entry will be unchanged.
|
||||||
If length is positive, the entry will be truncated or padded to fill that length.
|
If length is positive, the entry will be truncated or padded to fill that length.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -860,10 +860,7 @@ static void helper_eval_add_str(GString *str, const char *input, int l,
|
||||||
const char *input_nn = input ? input : "";
|
const char *input_nn = input ? input : "";
|
||||||
// Both l and max_len are in characters, not bytes.
|
// Both l and max_len are in characters, not bytes.
|
||||||
int spaces = 0;
|
int spaces = 0;
|
||||||
if (l == 0) {
|
if (l > 0) {
|
||||||
spaces = MAX(0, max_len - nc);
|
|
||||||
g_string_append(str, input_nn);
|
|
||||||
} else {
|
|
||||||
if (nc > l) {
|
if (nc > l) {
|
||||||
int bl = g_utf8_offset_to_pointer(input_nn, l) - input_nn;
|
int bl = g_utf8_offset_to_pointer(input_nn, l) - input_nn;
|
||||||
char *tmp = g_markup_escape_text(input_nn, bl);
|
char *tmp = g_markup_escape_text(input_nn, bl);
|
||||||
|
@ -875,6 +872,11 @@ static void helper_eval_add_str(GString *str, const char *input, int l,
|
||||||
g_string_append(str, tmp);
|
g_string_append(str, tmp);
|
||||||
g_free(tmp);
|
g_free(tmp);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
g_string_append(str, input_nn);
|
||||||
|
if (l == 0) {
|
||||||
|
spaces = MAX(0, max_len - nc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (spaces--) {
|
while (spaces--) {
|
||||||
g_string_append_c(str, ' ');
|
g_string_append_c(str, ' ');
|
||||||
|
@ -890,9 +892,6 @@ static gboolean helper_eval_cb(const GMatchInfo *info, GString *str,
|
||||||
int l = 0;
|
int l = 0;
|
||||||
if (match[2] == ':') {
|
if (match[2] == ':') {
|
||||||
l = (int)g_ascii_strtoll(&match[3], NULL, 10);
|
l = (int)g_ascii_strtoll(&match[3], NULL, 10);
|
||||||
if (l < 0) {
|
|
||||||
l = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (match[1] == 'w') {
|
if (match[1] == 'w') {
|
||||||
helper_eval_add_str(str, d->c->wmdesktopstr, l, d->pd->wmdn_len,
|
helper_eval_add_str(str, d->c->wmdesktopstr, l, d->pd->wmdn_len,
|
||||||
|
|
Loading…
Reference in a new issue