No tabs should be shown when /SET TAB is OFF

This also counts beeps, tabs and non-destructive spaces in the same way.

To maintain historical behaviour, BEEP_MAX of zero indicates no beeps allowed (the same
as /SET BEEP OFF), but TAB_MAX and ND_SPACE_MAX of zero indicates no limit.
This commit is contained in:
Kevin Easton
2018-05-25 11:19:02 +10:00
parent 255c25158c
commit d4c6123002
2 changed files with 45 additions and 28 deletions

View File

@@ -1,5 +1,7 @@
[Changes 1.2.2] [Changes 1.2.2]
* Fix /SET TAB OFF. (caf)
* Count columns used by ND_SPACE character when splitting lines. (caf) * Count columns used by ND_SPACE character when splitting lines. (caf)
* Use target window width rather than terminal width to wrap /list -wide * Use target window width rather than terminal width to wrap /list -wide

View File

@@ -368,11 +368,8 @@ char **BX_prepare_display(const char *orig_str,
word_break = 0, /* Last end of word */ word_break = 0, /* Last end of word */
indent = 0, /* Start of second word */ indent = 0, /* Start of second word */
firstwb = 0, firstwb = 0,
beep_cnt = 0, /* Number of beeps */ beep_max = 0, /* Maximum number of beeps */
beep_max, /* Maximum number of beeps */ tab_max = 0, /* Maximum number of tabs */
tab_cnt = 0, /* TAB counter */
tab_max, /* Maximum number of tabs */
nds_count = 0,
nds_max, nds_max,
line = 0, /* Current pos in "output" */ line = 0, /* Current pos in "output" */
len, i, /* Used for counting tabs */ len, i, /* Used for counting tabs */
@@ -392,9 +389,22 @@ char **BX_prepare_display(const char *orig_str,
ircpanic("prepare_display() called recursively"); ircpanic("prepare_display() called recursively");
recursion++; recursion++;
beep_max = get_int_var(BEEP_VAR)? get_int_var(BEEP_MAX_VAR) : -1; if (get_int_var(BEEP_VAR))
tab_max = get_int_var(TAB_VAR) ? get_int_var(TAB_MAX_VAR) : -1; beep_max = get_int_var(BEEP_MAX_VAR);
if (get_int_var(TAB_VAR))
{
tab_max = get_int_var(TAB_MAX_VAR);
/* TAB_MAX = 0 means "unlimited" */
if (tab_max == 0)
tab_max = -1;
}
nds_max = get_int_var(ND_SPACE_MAX_VAR); nds_max = get_int_var(ND_SPACE_MAX_VAR);
/* NS_SPACE_MAX = 0 means "unlimited" */
if (nds_max == 0)
nds_max = -1;
do_indent = get_int_var(INDENT_VAR); do_indent = get_int_var(INDENT_VAR);
words = get_string_var(WORD_BREAK_VAR); words = get_string_var(WORD_BREAK_VAR);
@@ -450,8 +460,14 @@ char **BX_prepare_display(const char *orig_str,
{ {
case BELL_CHAR: /* bell */ case BELL_CHAR: /* bell */
{ {
beep_cnt++; if (beep_max)
if ((beep_max == -1) || (beep_cnt > beep_max)) {
if (beep_max > 0)
beep_max--;
buffer[pos++] = *ptr;
}
else
{ {
if (!in_rev) if (!in_rev)
buffer[pos++] = REV_TOG; buffer[pos++] = REV_TOG;
@@ -460,25 +476,15 @@ char **BX_prepare_display(const char *orig_str,
buffer[pos++] = REV_TOG; buffer[pos++] = REV_TOG;
col++; col++;
} }
else
buffer[pos++] = *ptr;
break; /* case '\a' */ break; /* case '\a' */
} }
case '\t': /* TAB */ case '\t': /* TAB */
{ {
tab_cnt++; if (tab_max)
if ((tab_max > 0) && (tab_cnt > tab_max))
{
if (!in_rev)
buffer[pos++] = REV_TOG;
buffer[pos++] = (*ptr & 0x7f) | 64;
if (!in_rev)
buffer[pos++] = REV_TOG;
col++;
}
else
{ {
if (tab_max > 0)
tab_max--;
if (indent == 0) if (indent == 0)
{ {
indent = -1; indent = -1;
@@ -495,19 +501,28 @@ char **BX_prepare_display(const char *orig_str,
break; break;
} }
} }
else
{
if (!in_rev)
buffer[pos++] = REV_TOG;
buffer[pos++] = (*ptr & 0x7f) | 64;
if (!in_rev)
buffer[pos++] = REV_TOG;
col++;
}
break; /* case '\t' */ break; /* case '\t' */
} }
case ND_SPACE: case ND_SPACE:
{ {
nds_count++; if (nds_max)
/*
* Just swallop up any ND's over the max
*/
if ((nds_count <= nds_max) || (nds_max <= 0))
{ {
if (nds_max > 0)
nds_max--;
buffer[pos++] = ND_SPACE; buffer[pos++] = ND_SPACE;
col++; col++;
} }
/* Just swallop up any ND's over the max */
break; break;
} }
case '\n': /* Forced newline */ case '\n': /* Forced newline */