~ubuntu-branches/ubuntu/feisty/elinks/feisty-updates

« back to all changes in this revision

Viewing changes to src/document/plain/renderer.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-06-30 08:57:43 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060630085743-l81fgbw9dehvl1ds
Tags: 0.11.1-1ubuntu1
* Merge to Debian unstable.
* Removed gnutls12 porting, this is upstream now.
* Only Ubuntu changes left:
  - Killed type-handling.
  - Add X-Ubuntu-Gettext-Domain to .desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Plain text document renderer */
2
 
/* $Id: renderer.c,v 1.171.2.4 2005/09/14 13:29:01 jonas Exp $ */
3
2
 
4
3
#ifdef HAVE_CONFIG_H
5
4
#include "config.h"
9
8
#include <string.h>
10
9
 
11
10
#include "elinks.h"
12
 
#include "main.h"
13
11
 
14
12
#include "bookmarks/bookmarks.h"
15
13
#include "cache/cache.h"
96
94
        link->where = uri;
97
95
        link->color.background = document->options.default_bg;
98
96
        link->color.foreground = document->options.default_link;
 
97
        link->number = document->nlinks;
99
98
 
100
99
        for (point = link->points; length > 0; length--, point++, x++) {
101
100
                point->x = x;
136
135
 
137
136
        if (!where) return NULL;
138
137
 
 
138
        /* We need to reparse the URI and normalize it so that the protocol and
 
139
         * host part are converted to lowercase. */
 
140
        normalize_uri(NULL, where);
 
141
 
139
142
        new_link = add_document_link(document, where, length, x, y);
140
143
 
141
144
        if (!new_link) mem_free(where);
236
239
        int width = line_width;
237
240
        int line_pos;
238
241
 
239
 
        line = convert_string(renderer->convert_table, line, width, CSM_NONE, &width, NULL, NULL);
 
242
        line = convert_string(renderer->convert_table, line, width,
 
243
                              document->options.cp, CSM_NONE, &width,
 
244
                              NULL, NULL);
240
245
        if (!line) return 0;
241
246
 
242
247
        /* Now expand tabs */
303
308
                } else if (line_char == ASCII_BS) {
304
309
                        if (!(expanded + line_pos)) {
305
310
                                /* We've backspaced to the start of the line */
306
 
                                if (expanded > 0)
307
 
                                        expanded--; /* Don't count it */
308
311
                                continue;
309
312
                        }
310
313
 
326
329
                                continue;
327
330
                        }
328
331
 
329
 
                        if (expanded - 2 >= 0) {
 
332
                        if ((expanded + line_pos) - 2 >= 0) {
330
333
                                /* Don't count the backspace character or the
331
334
                                 * deleted character when returning the line's
332
335
                                 * width or when expanding tabs. */
407
410
}
408
411
 
409
412
static void
410
 
init_template(struct screen_char *template, color_t background, color_t foreground)
 
413
init_template(struct screen_char *template, struct document_options *options)
411
414
{
 
415
        color_T background = options->default_bg;
 
416
        color_T foreground = options->default_fg;
412
417
        struct color_pair colors = INIT_COLOR_PAIR(background, foreground);
413
418
 
414
419
        template->attr = 0;
415
420
        template->data = ' ';
416
 
        set_term_color(template, &colors, global_doc_opts->color_flags, global_doc_opts->color_mode);
 
421
        set_term_color(template, &colors,
 
422
                       options->color_flags, options->color_mode);
417
423
}
418
424
 
419
425
static struct node *
536
542
                                          &document->cp_status,
537
543
                                          document->options.hard_assume);
538
544
 
539
 
        document->bgcolor = global_doc_opts->default_bg;
540
 
        document->width = 0;
541
 
 
542
545
        renderer.source = buffer->source;
543
546
        renderer.length = buffer->length;
544
547
 
549
552
        renderer.max_width = document->options.wrap ? document->options.box.width
550
553
                                                    : INT_MAX;
551
554
 
 
555
        document->bgcolor = document->options.default_bg;
 
556
        document->width = 0;
 
557
 
552
558
        /* Setup the style */
553
 
        init_template(&renderer.template, global_doc_opts->default_bg,
554
 
                                          global_doc_opts->default_fg);
 
559
        init_template(&renderer.template, &document->options);
555
560
 
556
561
        add_document_lines(&renderer);
557
562
}