Make sure TABs are expanded in TUI windows on MS-Windows.
gdb/ 2015-01-31 Eli Zaretskii <eliz@gnu.org> * tui/tui-io.c (tui_expand_tabs): New function. (tui_puts, tui_redisplay_readline): Expand TABs into the appropriate number of spaces. * tui/tui-regs.c: Include tui-io.h. (tui_register_format): Call tui_expand_tabs to expand TABs into the appropriate number of spaces. * tui/tui-io.h: Add prototype for tui_expand_tabs.
This commit is contained in:
parent
b6577aab8a
commit
312809f883
|
@ -1,3 +1,13 @@
|
||||||
|
2015-01-31 Eli Zaretskii <eliz@gnu.org>
|
||||||
|
|
||||||
|
* tui/tui-io.c (tui_expand_tabs): New function.
|
||||||
|
(tui_puts, tui_redisplay_readline): Expand TABs into the
|
||||||
|
appropriate number of spaces.
|
||||||
|
* tui/tui-regs.c: Include tui-io.h.
|
||||||
|
(tui_register_format): Call tui_expand_tabs to expand TABs into
|
||||||
|
the appropriate number of spaces.
|
||||||
|
* tui/tui-io.h: Add prototype for tui_expand_tabs.
|
||||||
|
|
||||||
2015-01-30 Doug Evans <dje@google.com>
|
2015-01-30 Doug Evans <dje@google.com>
|
||||||
|
|
||||||
* NEWS: "info source" command now display producer string if present.
|
* NEWS: "info source" command now display producer string if present.
|
||||||
|
|
|
@ -178,6 +178,19 @@ tui_puts (const char *string)
|
||||||
else if (tui_skip_line != 1)
|
else if (tui_skip_line != 1)
|
||||||
{
|
{
|
||||||
tui_skip_line = -1;
|
tui_skip_line = -1;
|
||||||
|
/* Expand TABs, since ncurses on MS-Windows doesn't. */
|
||||||
|
if (c == '\t')
|
||||||
|
{
|
||||||
|
int line, col;
|
||||||
|
|
||||||
|
getyx (w, line, col);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
waddch (w, ' ');
|
||||||
|
col++;
|
||||||
|
} while ((col % 8) != 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
waddch (w, c);
|
waddch (w, c);
|
||||||
}
|
}
|
||||||
else if (c == '\n')
|
else if (c == '\n')
|
||||||
|
@ -256,6 +269,16 @@ tui_redisplay_readline (void)
|
||||||
waddch (w, '^');
|
waddch (w, '^');
|
||||||
waddch (w, CTRL_CHAR (c) ? UNCTRL (c) : '?');
|
waddch (w, CTRL_CHAR (c) ? UNCTRL (c) : '?');
|
||||||
}
|
}
|
||||||
|
else if (c == '\t')
|
||||||
|
{
|
||||||
|
/* Expand TABs, since ncurses on MS-Windows doesn't. */
|
||||||
|
getyx (w, line, col);
|
||||||
|
do
|
||||||
|
{
|
||||||
|
waddch (w, ' ');
|
||||||
|
col++;
|
||||||
|
} while ((col % 8) != 0);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
waddch (w, c);
|
waddch (w, c);
|
||||||
|
@ -724,6 +747,59 @@ tui_getc (FILE *fp)
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Utility function to expand TABs in a STRING into spaces. STRING
|
||||||
|
will be displayed starting at column COL, and is assumed to include
|
||||||
|
no newlines. The returned expanded string is malloc'ed. */
|
||||||
|
|
||||||
|
char *
|
||||||
|
tui_expand_tabs (const char *string, int col)
|
||||||
|
{
|
||||||
|
int n_adjust;
|
||||||
|
const char *s;
|
||||||
|
char *ret, *q;
|
||||||
|
|
||||||
|
/* 1. How many additional characters do we need? */
|
||||||
|
for (n_adjust = 0, s = string; s; )
|
||||||
|
{
|
||||||
|
s = strpbrk (s, "\t");
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
col += (s - string) + n_adjust;
|
||||||
|
/* Adjustment for the next tab stop, minus one for the TAB
|
||||||
|
we replace with spaces. */
|
||||||
|
n_adjust += 8 - (col % 8) - 1;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allocate the copy. */
|
||||||
|
ret = q = xmalloc (strlen (string) + n_adjust + 1);
|
||||||
|
|
||||||
|
/* 2. Copy the original string while replacing TABs with spaces. */
|
||||||
|
for (s = string; s; )
|
||||||
|
{
|
||||||
|
char *s1 = strpbrk (s, "\t");
|
||||||
|
if (s1)
|
||||||
|
{
|
||||||
|
if (s1 > s)
|
||||||
|
{
|
||||||
|
strncpy (q, s, s1 - s);
|
||||||
|
q += s1 - s;
|
||||||
|
col += s1 - s;
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
*q++ = ' ';
|
||||||
|
col++;
|
||||||
|
} while ((col % 8) != 0);
|
||||||
|
s1++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcpy (q, s);
|
||||||
|
s = s1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Cleanup when a resize has occured.
|
/* Cleanup when a resize has occured.
|
||||||
Returns the character that must be processed. */
|
Returns the character that must be processed. */
|
||||||
|
|
|
@ -41,6 +41,9 @@ extern int tui_getc (FILE *);
|
||||||
changed the edited text. */
|
changed the edited text. */
|
||||||
extern void tui_redisplay_readline (void);
|
extern void tui_redisplay_readline (void);
|
||||||
|
|
||||||
|
/* Expand TABs into spaces. */
|
||||||
|
extern char *tui_expand_tabs (const char *, int);
|
||||||
|
|
||||||
extern struct ui_out *tui_out;
|
extern struct ui_out *tui_out;
|
||||||
extern struct ui_out *tui_old_uiout;
|
extern struct ui_out *tui_old_uiout;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "tui/tui-wingeneral.h"
|
#include "tui/tui-wingeneral.h"
|
||||||
#include "tui/tui-file.h"
|
#include "tui/tui-file.h"
|
||||||
#include "tui/tui-regs.h"
|
#include "tui/tui-regs.h"
|
||||||
|
#include "tui/tui-io.h"
|
||||||
#include "reggroups.h"
|
#include "reggroups.h"
|
||||||
#include "valprint.h"
|
#include "valprint.h"
|
||||||
|
|
||||||
|
@ -693,7 +694,9 @@ tui_register_format (struct frame_info *frame, int regnum)
|
||||||
if (s && s[1] == 0)
|
if (s && s[1] == 0)
|
||||||
*s = 0;
|
*s = 0;
|
||||||
|
|
||||||
ret = xstrdup (p);
|
/* Expand tabs into spaces, since ncurses on MS-Windows doesn't. */
|
||||||
|
ret = tui_expand_tabs (p, 0);
|
||||||
|
|
||||||
do_cleanups (cleanups);
|
do_cleanups (cleanups);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue