1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

$[.10]var truncates the var to 10 chars, but doesn't pad if var is

shorter than 10 chars


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1105 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-01-12 17:05:05 +00:00 committed by cras
parent 1a3c700838
commit 1698500f80
3 changed files with 16 additions and 9 deletions

View File

@ -7,7 +7,7 @@ referred to as expandos. They are special in that the client is
constantly updating their values automatically. There are also constantly updating their values automatically. There are also
numerous variable modifiers available. numerous variable modifiers available.
Modifier Description Modifier Description
$variable A normal variable, expanding to the first match of: $variable A normal variable, expanding to the first match of:
| 1) an internal SET variable | 1) an internal SET variable
| 2) an environment variable | 2) an environment variable
@ -16,7 +16,9 @@ numerous variable modifiers available.
| The value is padded to meet the width with the | The value is padded to meet the width with the
| character given after number (default is space). | character given after number (default is space).
| The value is truncated to specified width unless | The value is truncated to specified width unless
| '!' character precedes the number. | '!' character precedes the number. If '.' character
| precedes the number the value isn't padded, just
| truncated.
$#variable Expands to the number of words in $variable. If $variable $#variable Expands to the number of words in $variable. If $variable
| is omitted, it assumes $* | is omitted, it assumes $*
$@variable Expands to the number of characters in $variable. if $@variable Expands to the number of characters in $variable. if

View File

@ -27,6 +27,7 @@
#define ALIGN_RIGHT 0x01 #define ALIGN_RIGHT 0x01
#define ALIGN_CUT 0x02 #define ALIGN_CUT 0x02
#define ALIGN_PAD 0x04
#define isvarchar(c) \ #define isvarchar(c) \
(isalnum(c) || (c) == '_') (isalnum(c) || (c) == '_')
@ -273,7 +274,7 @@ static int get_alignment_args(char **data, int *align, int *flags, char *pad)
char *str; char *str;
*align = 0; *align = 0;
*flags = ALIGN_CUT; *flags = ALIGN_CUT|ALIGN_PAD;
*pad = ' '; *pad = ' ';
/* '!' = don't cut, '-' = right padding */ /* '!' = don't cut, '-' = right padding */
@ -283,6 +284,8 @@ static int get_alignment_args(char **data, int *align, int *flags, char *pad)
*flags &= ~ALIGN_CUT; *flags &= ~ALIGN_CUT;
else if (*str == '-') else if (*str == '-')
*flags |= ALIGN_RIGHT; *flags |= ALIGN_RIGHT;
else if (*str == '.')
*flags &= ~ALIGN_PAD;
str++; str++;
} }
if (!isdigit(*str)) if (!isdigit(*str))
@ -321,11 +324,13 @@ static char *get_alignment(const char *text, int align, int flags, char pad)
g_string_truncate(str, align); g_string_truncate(str, align);
/* add pad characters */ /* add pad characters */
while (str->len < align) { if (flags & ALIGN_PAD) {
if (flags & ALIGN_RIGHT) while (str->len < align) {
g_string_prepend_c(str, pad); if (flags & ALIGN_RIGHT)
else g_string_prepend_c(str, pad);
g_string_append_c(str, pad); else
g_string_append_c(str, pad);
}
} }
ret = str->str; ret = str->str;

View File

@ -1119,7 +1119,7 @@ static void read_settings(void)
void gui_windows_init(void) void gui_windows_init(void)
{ {
settings_add_int("lookandfeel", "indent", 10); settings_add_int("lookandfeel", "indent", 10);
settings_add_str("lookandfeel", "prompt", "[$T] "); settings_add_str("lookandfeel", "prompt", "[$[.15]T] ");
settings_add_str("lookandfeel", "prompt_window", "[$winname] "); settings_add_str("lookandfeel", "prompt_window", "[$winname] ");
prompt = NULL; prompt_window = NULL; prompt = NULL; prompt_window = NULL;