• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision312809f8838911dabff84d7ad3ccf341307d2b19 (tree)
l'heure2015-01-31 17:47:14
AuteurEli Zaretskii <eliz@gnu....>
CommiterEli Zaretskii

Message de Log

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.

Change Summary

Modification

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
1+2015-01-31 Eli Zaretskii <eliz@gnu.org>
2+
3+ * tui/tui-io.c (tui_expand_tabs): New function.
4+ (tui_puts, tui_redisplay_readline): Expand TABs into the
5+ appropriate number of spaces.
6+ * tui/tui-regs.c: Include tui-io.h.
7+ (tui_register_format): Call tui_expand_tabs to expand TABs into
8+ the appropriate number of spaces.
9+ * tui/tui-io.h: Add prototype for tui_expand_tabs.
10+
111 2015-01-30 Doug Evans <dje@google.com>
212
313 * NEWS: "info source" command now display producer string if present.
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -178,7 +178,20 @@ tui_puts (const char *string)
178178 else if (tui_skip_line != 1)
179179 {
180180 tui_skip_line = -1;
181- waddch (w, c);
181+ /* Expand TABs, since ncurses on MS-Windows doesn't. */
182+ if (c == '\t')
183+ {
184+ int line, col;
185+
186+ getyx (w, line, col);
187+ do
188+ {
189+ waddch (w, ' ');
190+ col++;
191+ } while ((col % 8) != 0);
192+ }
193+ else
194+ waddch (w, c);
182195 }
183196 else if (c == '\n')
184197 tui_skip_line = -1;
@@ -256,6 +269,16 @@ tui_redisplay_readline (void)
256269 waddch (w, '^');
257270 waddch (w, CTRL_CHAR (c) ? UNCTRL (c) : '?');
258271 }
272+ else if (c == '\t')
273+ {
274+ /* Expand TABs, since ncurses on MS-Windows doesn't. */
275+ getyx (w, line, col);
276+ do
277+ {
278+ waddch (w, ' ');
279+ col++;
280+ } while ((col % 8) != 0);
281+ }
259282 else
260283 {
261284 waddch (w, c);
@@ -724,6 +747,59 @@ tui_getc (FILE *fp)
724747 return ch;
725748 }
726749
750+/* Utility function to expand TABs in a STRING into spaces. STRING
751+ will be displayed starting at column COL, and is assumed to include
752+ no newlines. The returned expanded string is malloc'ed. */
753+
754+char *
755+tui_expand_tabs (const char *string, int col)
756+{
757+ int n_adjust;
758+ const char *s;
759+ char *ret, *q;
760+
761+ /* 1. How many additional characters do we need? */
762+ for (n_adjust = 0, s = string; s; )
763+ {
764+ s = strpbrk (s, "\t");
765+ if (s)
766+ {
767+ col += (s - string) + n_adjust;
768+ /* Adjustment for the next tab stop, minus one for the TAB
769+ we replace with spaces. */
770+ n_adjust += 8 - (col % 8) - 1;
771+ s++;
772+ }
773+ }
774+
775+ /* Allocate the copy. */
776+ ret = q = xmalloc (strlen (string) + n_adjust + 1);
777+
778+ /* 2. Copy the original string while replacing TABs with spaces. */
779+ for (s = string; s; )
780+ {
781+ char *s1 = strpbrk (s, "\t");
782+ if (s1)
783+ {
784+ if (s1 > s)
785+ {
786+ strncpy (q, s, s1 - s);
787+ q += s1 - s;
788+ col += s1 - s;
789+ }
790+ do {
791+ *q++ = ' ';
792+ col++;
793+ } while ((col % 8) != 0);
794+ s1++;
795+ }
796+ else
797+ strcpy (q, s);
798+ s = s1;
799+ }
800+
801+ return ret;
802+}
727803
728804 /* Cleanup when a resize has occured.
729805 Returns the character that must be processed. */
--- a/gdb/tui/tui-io.h
+++ b/gdb/tui/tui-io.h
@@ -41,6 +41,9 @@ extern int tui_getc (FILE *);
4141 changed the edited text. */
4242 extern void tui_redisplay_readline (void);
4343
44+/* Expand TABs into spaces. */
45+extern char *tui_expand_tabs (const char *, int);
46+
4447 extern struct ui_out *tui_out;
4548 extern struct ui_out *tui_old_uiout;
4649
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -36,6 +36,7 @@
3636 #include "tui/tui-wingeneral.h"
3737 #include "tui/tui-file.h"
3838 #include "tui/tui-regs.h"
39+#include "tui/tui-io.h"
3940 #include "reggroups.h"
4041 #include "valprint.h"
4142
@@ -693,7 +694,9 @@ tui_register_format (struct frame_info *frame, int regnum)
693694 if (s && s[1] == 0)
694695 *s = 0;
695696
696- ret = xstrdup (p);
697+ /* Expand tabs into spaces, since ncurses on MS-Windows doesn't. */
698+ ret = tui_expand_tabs (p, 0);
699+
697700 do_cleanups (cleanups);
698701
699702 return ret;