- struct ascii_driver_ext *ext = this->ext;
- int line_num;
-
- struct fixed_string *newline = &ext->ops[OPS_NEWLINE];
-
- int n_chars;
- int n_passes;
-
- if (NULL == ext->file.file)
- return;
-
- /* Iterate over all the lines to be output. */
- for (line_num = first; line_num < first + count; line_num++)
- {
- struct line *line = &ext->lines[line_num];
- unsigned short *p = line->chars;
- unsigned short *end_p = p + line->char_cnt;
- unsigned short *bp, *ep;
- unsigned short attr = 0;
-
- assert (end_p >= p);
-
- /* Squeeze multiple blank lines into a single blank line if
- requested. */
- if (ext->squeeze_blank_lines
- && line_num > first
- && ext->lines[line_num].char_cnt == 0
- && ext->lines[line_num - 1].char_cnt == 0)
- continue;
-
- /* Output every character in the line in the appropriate
- manner. */
- n_passes = 1;
- bp = ep = p;
- n_chars = 0;
- advance_to_left_margin (this);
- for (;;)
- {
- while (ep < end_p && attr == (*ep & 0x0300))
- ep++;
- if (output_shorts (this, bp, ep))
- n_passes = 2;
- n_chars += ep - bp;
- bp = ep;
-
- if (bp >= end_p)
- break;
-
- /* Turn off old font. */
- if (attr != (OUTP_F_R << 8))
- {
- struct fixed_string *off;
-
- switch (attr)
- {
- case OUTP_F_I << 8:
- off = &ext->fonts[FSTY_OFF | FSTY_ITALIC];
- break;
- case OUTP_F_B << 8:
- off = &ext->fonts[FSTY_OFF | FSTY_BOLD];
- break;
- case OUTP_F_BI << 8:
- off = &ext->fonts[FSTY_OFF | FSTY_BOLD_ITALIC];
- break;
- default:
- assert (0);
- abort ();
- }
- if (off)
- output_string (this, ls_c_str (off), ls_end (off));
- }
-
- /* Turn on new font. */
- attr = (*bp & 0x0300);
- if (attr != (OUTP_F_R << 8))
- {
- struct fixed_string *on;
-
- switch (attr)
- {
- case OUTP_F_I << 8:
- on = &ext->fonts[FSTY_ON | FSTY_ITALIC];
- break;
- case OUTP_F_B << 8:
- on = &ext->fonts[FSTY_ON | FSTY_BOLD];
- break;
- case OUTP_F_BI << 8:
- on = &ext->fonts[FSTY_ON | FSTY_BOLD_ITALIC];
- break;
- default:
- assert (0);
- abort ();
- }
- if (on)
- output_string (this, ls_c_str (on), ls_end (on));
- }
-
- ep = bp + 1;
- }
- if (n_passes > 1)
- {
- char ch;
-
- return_carriage (this, n_chars);
- n_chars = 0;
- bp = ep = p;
- for (;;)
- {
- while (ep < end_p && (*ep & 0x0300) == (OUTP_F_R << 8))
- ep++;
- if (ep >= end_p)
- break;
- output_char (this, ep - bp, ' ');
-
- switch (*ep & 0x0300)
- {
- case OUTP_F_I << 8:
- ch = '_';
- break;
- case OUTP_F_B << 8:
- ch = *ep;
- break;
- case OUTP_F_BI << 8:
- ch = *ep;
- n_passes = 3;
- break;
- default:
- assert (0);
- abort ();
- }
- output_char (this, 1, ch);
- n_chars += ep - bp + 1;
- bp = ep + 1;
- ep = bp;
- }
- }
- if (n_passes > 2)
- {
- return_carriage (this, n_chars);
- bp = ep = p;
- for (;;)
- {
- while (ep < end_p && (*ep & 0x0300) != (OUTP_F_BI << 8))
- ep++;
- if (ep >= end_p)
- break;
- output_char (this, ep - bp, ' ');
- output_char (this, 1, '_');
- bp = ep + 1;
- ep = bp;
- }
- }
-
- output_string (this, ls_c_str (newline), ls_end (newline));
- }