display.c (42660) | display.c (100513) |
---|---|
1/* display.c -- How to display Info windows. | 1/* display.c -- How to display Info windows. |
2 $Id: display.c,v 1.6 1997/07/24 21:13:27 karl Exp $ | 2 $Id: display.c,v 1.7 2002/03/08 21:41:44 karl Exp $ |
3 4 Copyright (C) 1993, 97 Free Software Foundation, Inc. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 --- 87 unchanged lines hidden (view full) --- 98 WINDOW *win; 99{ 100 register char *nodetext; /* Current character to display. */ 101 register char *last_node_char; /* Position of the last character in node. */ 102 register int i; /* General use index. */ 103 char *printed_line; /* Buffer for a printed line. */ 104 int pl_index = 0; /* Index into PRINTED_LINE. */ 105 int line_index = 0; /* Number of lines done so far. */ | 3 4 Copyright (C) 1993, 97 Free Software Foundation, Inc. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 --- 87 unchanged lines hidden (view full) --- 98 WINDOW *win; 99{ 100 register char *nodetext; /* Current character to display. */ 101 register char *last_node_char; /* Position of the last character in node. */ 102 register int i; /* General use index. */ 103 char *printed_line; /* Buffer for a printed line. */ 104 int pl_index = 0; /* Index into PRINTED_LINE. */ 105 int line_index = 0; /* Number of lines done so far. */ |
106 int pl_ignore = 0; /* How many chars use zero width on screen. */ 107 int allocated_win_width; |
|
106 DISPLAY_LINE **display = the_display; 107 108 /* If display is inhibited, that counts as an interrupted display. */ 109 if (display_inhibited) 110 display_was_interrupted_p = 1; 111 112 /* If the window has no height, or display is inhibited, quit now. */ 113 if (!win->height || display_inhibited) --- 4 unchanged lines hidden (view full) --- 118 window to be displayed, and the screen has shrunk to less than one 119 line. */ 120 if ((win->first_row < 0) || (win->first_row > the_screen->height)) 121 return; 122 123 /* Print each line in the window into our local buffer, and then 124 check the contents of that buffer against the display. If they 125 differ, update the display. */ | 108 DISPLAY_LINE **display = the_display; 109 110 /* If display is inhibited, that counts as an interrupted display. */ 111 if (display_inhibited) 112 display_was_interrupted_p = 1; 113 114 /* If the window has no height, or display is inhibited, quit now. */ 115 if (!win->height || display_inhibited) --- 4 unchanged lines hidden (view full) --- 120 window to be displayed, and the screen has shrunk to less than one 121 line. */ 122 if ((win->first_row < 0) || (win->first_row > the_screen->height)) 123 return; 124 125 /* Print each line in the window into our local buffer, and then 126 check the contents of that buffer against the display. If they 127 differ, update the display. */ |
126 printed_line = (char *)xmalloc (1 + win->width); | 128 allocated_win_width = win->width + 1; 129 printed_line = (char *)xmalloc (allocated_win_width); |
127 128 if (!win->node || !win->line_starts) 129 goto done_with_node_display; 130 131 nodetext = win->line_starts[win->pagetop]; 132 last_node_char = win->node->contents + win->node->nodelen; 133 134 for (; nodetext < last_node_char; nodetext++) --- 7 unchanged lines hidden (view full) --- 142 replen = 1; 143 rep_temp[1] = '\0'; 144 rep = rep_temp; 145 } 146 else 147 { 148 if (*nodetext == '\r' || *nodetext == '\n') 149 { | 130 131 if (!win->node || !win->line_starts) 132 goto done_with_node_display; 133 134 nodetext = win->line_starts[win->pagetop]; 135 last_node_char = win->node->contents + win->node->nodelen; 136 137 for (; nodetext < last_node_char; nodetext++) --- 7 unchanged lines hidden (view full) --- 145 replen = 1; 146 rep_temp[1] = '\0'; 147 rep = rep_temp; 148 } 149 else 150 { 151 if (*nodetext == '\r' || *nodetext == '\n') 152 { |
150 replen = win->width - pl_index; | 153 replen = win->width - pl_index + pl_ignore; |
151 } 152 else 153 { 154 rep = printed_representation (*nodetext, pl_index); 155 replen = strlen (rep); 156 } 157 } 158 | 154 } 155 else 156 { 157 rep = printed_representation (*nodetext, pl_index); 158 replen = strlen (rep); 159 } 160 } 161 |
162 /* Support ANSI escape sequences under -R. */ 163 if (raw_escapes_p 164 && *nodetext == '\033' 165 && nodetext[1] == '[' 166 && isdigit (nodetext[2])) 167 { 168 if (nodetext[3] == 'm') 169 pl_ignore += 4; 170 else if (isdigit (nodetext[3]) && nodetext[4] == 'm') 171 pl_ignore += 5; 172 } 173 while (pl_index + 2 >= allocated_win_width - 1) 174 { 175 allocated_win_width *= 2; 176 printed_line = (char *)xrealloc (printed_line, allocated_win_width); 177 } 178 |
|
159 /* If this character can be printed without passing the width of 160 the line, then stuff it into the line. */ | 179 /* If this character can be printed without passing the width of 180 the line, then stuff it into the line. */ |
161 if (replen + pl_index < win->width) | 181 if (replen + pl_index < win->width + pl_ignore) |
162 { 163 /* Optimize if possible. */ 164 if (replen == 1) 165 { 166 printed_line[pl_index++] = *rep; 167 } 168 else 169 { --- 14 unchanged lines hidden (view full) --- 184 rep_carried_over = (char *)NULL; 185 } 186 else 187 { 188 /* The printed representation of this character extends into 189 the next line. Remember the offset of the last character 190 printed out of REP so that we can carry the character over 191 to the next line. */ | 182 { 183 /* Optimize if possible. */ 184 if (replen == 1) 185 { 186 printed_line[pl_index++] = *rep; 187 } 188 else 189 { --- 14 unchanged lines hidden (view full) --- 204 rep_carried_over = (char *)NULL; 205 } 206 else 207 { 208 /* The printed representation of this character extends into 209 the next line. Remember the offset of the last character 210 printed out of REP so that we can carry the character over 211 to the next line. */ |
192 for (i = 0; pl_index < (win->width - 1);) | 212 for (i = 0; pl_index < (win->width + pl_ignore - 1);) |
193 printed_line[pl_index++] = rep[i++]; 194 195 rep_carried_over = rep + i; 196 197 /* If printing the last character in this window couldn't 198 possibly cause the screen to scroll, place a backslash 199 in the rightmost column. */ 200 if (1 + line_index + win->first_row < the_screen->height) --- 8 unchanged lines hidden (view full) --- 209 210 /* We have the exact line as it should appear on the screen. 211 Check to see if this line matches the one already appearing 212 on the screen. */ 213 entry = display[line_index + win->first_row]; 214 215 /* If the screen line is inversed, then we have to clear 216 the line from the screen first. Why, I don't know. */ | 213 printed_line[pl_index++] = rep[i++]; 214 215 rep_carried_over = rep + i; 216 217 /* If printing the last character in this window couldn't 218 possibly cause the screen to scroll, place a backslash 219 in the rightmost column. */ 220 if (1 + line_index + win->first_row < the_screen->height) --- 8 unchanged lines hidden (view full) --- 229 230 /* We have the exact line as it should appear on the screen. 231 Check to see if this line matches the one already appearing 232 on the screen. */ 233 entry = display[line_index + win->first_row]; 234 235 /* If the screen line is inversed, then we have to clear 236 the line from the screen first. Why, I don't know. */ |
217 if (entry->inverse) | 237 if (entry->inverse 238 /* Need to erase the line if it has escape sequences. */ 239 || (raw_escapes_p && strchr (entry->text, '\033') != 0)) |
218 { 219 terminal_goto_xy (0, line_index + win->first_row); 220 terminal_clear_to_eol (); 221 entry->inverse = 0; 222 entry->text[0] = '\0'; 223 entry->textlen = 0; 224 } 225 --- 11 unchanged lines hidden (view full) --- 237 238 /* If there is any text to print, print it. */ 239 if (i != pl_index) 240 terminal_put_text (printed_line + i); 241 242 /* If the printed text didn't extend all the way to the edge 243 of the window, and text was appearing between here and the 244 edge of the window, clear from here to the end of the line. */ | 240 { 241 terminal_goto_xy (0, line_index + win->first_row); 242 terminal_clear_to_eol (); 243 entry->inverse = 0; 244 entry->text[0] = '\0'; 245 entry->textlen = 0; 246 } 247 --- 11 unchanged lines hidden (view full) --- 259 260 /* If there is any text to print, print it. */ 261 if (i != pl_index) 262 terminal_put_text (printed_line + i); 263 264 /* If the printed text didn't extend all the way to the edge 265 of the window, and text was appearing between here and the 266 edge of the window, clear from here to the end of the line. */ |
245 if ((pl_index < win->width && pl_index < entry->textlen) || 246 (entry->inverse)) | 267 if ((pl_index < win->width + pl_ignore 268 && pl_index < entry->textlen) 269 || (entry->inverse)) |
247 terminal_clear_to_eol (); 248 249 fflush (stdout); 250 251 /* Update the display text buffer. */ | 270 terminal_clear_to_eol (); 271 272 fflush (stdout); 273 274 /* Update the display text buffer. */ |
275 if (strlen (printed_line) > screenwidth) 276 /* printed_line[] can include more than screenwidth 277 characters if we are under -R and there are escape 278 sequences in it. However, entry->text was 279 allocated (in display_initialize_display) for 280 screenwidth characters only. */ 281 entry->text = xrealloc (entry->text, strlen (printed_line)+1); |
|
252 strcpy (entry->text + i, printed_line + i); 253 entry->textlen = pl_index; 254 255 /* Lines showing node text are not in inverse. Only modelines 256 have that distinction. */ 257 entry->inverse = 0; 258 } 259 --- 9 unchanged lines hidden (view full) --- 269 { 270 free (printed_line); 271 display_was_interrupted_p = 1; 272 return; 273 } 274 275 /* Reset PL_INDEX to the start of the line. */ 276 pl_index = 0; | 282 strcpy (entry->text + i, printed_line + i); 283 entry->textlen = pl_index; 284 285 /* Lines showing node text are not in inverse. Only modelines 286 have that distinction. */ 287 entry->inverse = 0; 288 } 289 --- 9 unchanged lines hidden (view full) --- 299 { 300 free (printed_line); 301 display_was_interrupted_p = 1; 302 return; 303 } 304 305 /* Reset PL_INDEX to the start of the line. */ 306 pl_index = 0; |
307 pl_ignore = 0; /* this is computed per line */ |
|
277 278 /* If there are characters from REP left to print, stuff them 279 into the buffer now. */ 280 if (rep_carried_over) 281 for (; rep[pl_index]; pl_index++) 282 printed_line[pl_index] = rep[pl_index]; 283 284 /* If this window has chosen not to wrap lines, skip to the end --- 273 unchanged lines hidden --- | 308 309 /* If there are characters from REP left to print, stuff them 310 into the buffer now. */ 311 if (rep_carried_over) 312 for (; rep[pl_index]; pl_index++) 313 printed_line[pl_index] = rep[pl_index]; 314 315 /* If this window has chosen not to wrap lines, skip to the end --- 273 unchanged lines hidden --- |