1/* display.c -- How to display Info windows. |
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. */ |
106 int pl_ignore = 0; /* How many chars use zero width on screen. */ 107 int allocated_win_width; |
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. */ |
128 allocated_win_width = win->width + 1; 129 printed_line = (char *)xmalloc (allocated_win_width); |
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 { |
153 replen = win->width - pl_index + pl_ignore; |
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 |
179 /* If this character can be printed without passing the width of 180 the line, then stuff it into the line. */ |
181 if (replen + pl_index < win->width + pl_ignore) |
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. */ |
212 for (i = 0; pl_index < (win->width + pl_ignore - 1);) |
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. */ |
237 if (entry->inverse 238 /* Need to erase the line if it has escape sequences. */ 239 || (raw_escapes_p && strchr (entry->text, '\033') != 0)) |
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. */ |
267 if ((pl_index < win->width + pl_ignore 268 && pl_index < entry->textlen) 269 || (entry->inverse)) |
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); |
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 */ |
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 --- |