@@ -59,12 +59,15 @@ static int CommandScreen_scanWide(InfoScreen* this, const char* p, size_t total,
5959 assert (line_offset >= 0 && (size_t )line_offset <= total );
6060 unsigned char c = (unsigned char )p [i ];
6161 if (c < 0x80 ) { // skip mbrtowc for ASCII characters
62- if (c == ' ' ) {
63- last_spc_offset = line_offset ;
64- last_spc_cols = line_cols ;
65- }
6662 bytes = width = 1 ;
6763 line [line_offset ] = c ;
64+ if (c == ' ' || c == '\t' ) {
65+ bytes = width = (c == '\t' ? 8 - (line_offset % 8 ) : 1 );
66+ memset (line + line_offset , ' ' , bytes );
67+ last_spc_offset = line_offset + (int ) bytes - 1 ;
68+ last_spc_cols = line_cols + (int ) bytes - 1 ;
69+ i -= bytes - 1 ;
70+ }
6871 } else {
6972 wchar_t wc ;
7073 bytes = mbrtowc (& wc , p + i , total - i , & state );
@@ -99,6 +102,9 @@ static int CommandScreen_scanWide(InfoScreen* this, const char* p, size_t total,
99102 line_offset -= line_size ;
100103 if (line_offset > 0 ) {
101104 memcpy (line , p + i - line_offset , line_offset + 1 );
105+ if (line [0 ] == '\t' ) {
106+ line [0 ] = ' ' ; // ensure we have at least one character
107+ }
102108 }
103109 }
104110
@@ -114,8 +120,8 @@ static void CommandScreen_scan(InfoScreen* this) {
114120
115121 const char * p = Process_getCommand (this -> process );
116122 assert (p != NULL );
117- size_t total = strlen (p );
118- char line [total + 1 ];
123+ size_t total = strlen (p ), max = MAXIMUM ( total , ( size_t ) COLS * 2 ) ;
124+ char line [max + 1 ];
119125
120126 int line_offset =
121127#ifdef HAVE_LIBNCURSESW
0 commit comments