ELinks 0.18.0
renderer.c File Reference
#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#include "elinks.h"
#include "cache/cache.h"
#include "config/options.h"
#include "document/docdata.h"
#include "document/document.h"
#include "document/html/frames.h"
#include "document/html/iframes.h"
#include "document/html/parser.h"
#include "document/html/parser/parse.h"
#include "document/html/renderer.h"
#include "document/html/tables.h"
#include "document/options.h"
#include "document/refresh.h"
#include "document/renderer.h"
#include "intl/charsets.h"
#include "osdep/types.h"
#include "protocol/uri.h"
#include "session/session.h"
#include "terminal/color.h"
#include "terminal/draw.h"
#include "util/color.h"
#include "util/conv.h"
#include "util/error.h"
#include "util/hash.h"
#include "util/lists.h"
#include "util/memory.h"
#include "util/string.h"
#include "util/time.h"
#include "viewer/text/form.h"
#include "viewer/text/view.h"
#include "viewer/text/vs.h"
#include "document/html/internal.h"
Include dependency graph for renderer.c:

Data Structures

struct  table_cache_entry_key
struct  table_cache_entry

Macros

#define MAX_TABLE_CACHE_ENTRIES   16384
#define X(x_)
#define Y(y_)
#define SPACES_GRANULARITY   0x7F
#define ALIGN_SPACES(x, o, n)
#define LINE(y_)
#define POS(x_, y_)
#define LEN(y_)
#define overlap_width(x)
#define overlap(x)
#define add_evhook(list_, type_, src_)
#define assert_link_variable(old, new)

Typedefs

typedef unsigned char link_state_T

Enumerations

enum  link_state { LINK_STATE_NONE , LINK_STATE_NEW , LINK_STATE_SAME }

Functions

static void put_chars (struct html_context *, const char *, int)
static void set_screen_char_color (struct screen_char *schar, color_T bgcolor, color_T fgcolor, color_flags_T color_flags, color_mode_T color_mode)
static int realloc_line (struct html_context *html_context, struct document *document, int y, int length)
static int realloc_spaces (struct part *part, int length)
static void clear_hchars (struct html_context *html_context, int x, int y, int width, struct screen_char *a)
static struct screen_charget_frame_char (struct html_context *html_context, struct part *part, int x, int y, unsigned char data, color_T bgcolor, color_T fgcolor)
static struct screen_charget_format_screen_char (struct html_context *html_context, link_state_T link_state)
void draw_frame_hchars (struct part *part, int x, int y, int width, unsigned char data, color_T bgcolor, color_T fgcolor, struct html_context *html_context)
void draw_blockquote_chars (struct part *part, int y, struct html_context *html_context)
void draw_frame_vchars (struct part *part, int x, int y, int height, unsigned char data, color_T bgcolor, color_T fgcolor, struct html_context *html_context)
void expand_lines (struct html_context *html_context, struct part *part, int x, int y, int lines, color_T bgcolor)
static int set_hline (struct html_context *html_context, const char *chars, int charslen, link_state_T link_state)
static void move_links (struct html_context *html_context, int xf, int yf, int xt, int yt)
static void copy_chars (struct html_context *html_context, int x, int y, int width, struct screen_char *d)
static void move_chars (struct html_context *html_context, int x, int y, int nx, int ny)
static void shift_chars (struct html_context *html_context, int y, int shift)
 Shift the line y to the right by shift character cells, and update document.comb_x and document.comb_y.
static void del_chars (struct html_context *html_context, int x, int y)
static int split_line_at (struct html_context *html_context, int width)
static int split_line (struct html_context *html_context)
static void insert_spaces_in_link (struct part *part, int x, int y, int new_spaces)
static void justify_line (struct html_context *html_context, int y)
static void align_line (struct html_context *html_context, int y, int last)
static void init_link_event_hooks (struct html_context *html_context, struct link *link)
static struct linknew_link (struct html_context *html_context, const char *name, int namelen)
static void html_special_tag (struct document *document, char *t, int x, int y)
void put_chars_conv (struct html_context *html_context, const char *chars, int charslen)
int dec2qwerty (int num, char *link_sym, const char *key, int base)
int qwerty2dec (const char *link_sym, const char *key, int base)
static void put_link_number (struct html_context *html_context)
static void init_link_state_info (char *link, char *target, char *image, struct el_form_control *form)
static void done_link_state_info (void)
static void process_link (struct html_context *html_context, link_state_T link_state, const char *chars, int charslen, int cells)
static link_state_T get_link_state (struct html_context *html_context)
static int html_has_non_space_chars (const char *chars, int charslen)
void line_break (struct html_context *html_context)
static void html_special_form (struct part *part, struct form *form)
static void html_special_form_control (struct part *part, struct el_form_control *fc)
static void assert_forms_list_ok (struct form list *forms)
 Assert that each form in the list has a different form.form_num ... form.form_end range and that the ranges are contiguous and together cover all numbers from 0 to INT_MAX.
void check_html_form_hierarchy (struct part *part)
static void color_link_lines (struct html_context *html_context)
void * html_special (struct html_context *html_context, html_special_type_T c,...)
void free_table_cache (void)
struct partformat_html_part (struct html_context *html_context, char *start, char *end, int align, int margin, int width, struct document *document, int x, int y, char *head, int link_num)
static void subst_frame_chars (struct document *document)
void render_html_document (struct cache_entry *cached, struct document *document, struct string *buffer)

Variables

static int table_cache_entries
static struct hashtable_cache
struct renderer_context renderer_context

Macro Definition Documentation

◆ add_evhook

#define add_evhook ( list_,
type_,
src_ )
Value:
do { \
struct script_event_hook *evhook; \
\
if (!src_) break; \
\
evhook = (struct script_event_hook *)mem_calloc(1, sizeof(*evhook)); \
if (!evhook) break; \
\
evhook->type = type_; \
evhook->src = stracpy(src_); \
add_to_list(*(list_), evhook); \
} while (0)
void * mem_calloc(size_t, size_t)
Definition document.h:111
enum script_event_hook_type type
Definition document.h:114
char * src
Definition document.h:115
char * stracpy(const char *src)
Allocated NUL terminated string with the content of src.

◆ ALIGN_SPACES

#define ALIGN_SPACES ( x,
o,
n )
Value:
int n
Definition general.c:868
#define SPACES_GRANULARITY
Definition renderer.c:97
#define mem_align_alloc(ptr, old, new_, mask)
Definition memory.h:148

◆ assert_link_variable

#define assert_link_variable ( old,
new )
Value:
assertm(!(old), "Old link value [%s]. New value [%s]", old, new);
#define assertm(x, m...)
This is extended assert() version, it can print additional user-specified message.
Definition error.h:129

◆ LEN

#define LEN ( y_)
Value:
int_max(LINE(y_).length - part->box.x, 0)
#define LINE(y_)
Definition renderer.c:170
static int int_max(int x, int y)
Definition math.h:37
int x
Definition box.h:10
Definition renderer.h:49
struct el_box box
Definition renderer.h:59

◆ LINE

#define LINE ( y_)
Value:
#define Y(renderer)
Definition util.h:45
struct line * data
Definition document.h:271
struct document * document
Definition renderer.h:50

◆ MAX_TABLE_CACHE_ENTRIES

#define MAX_TABLE_CACHE_ENTRIES   16384

◆ overlap

#define overlap ( x)
Value:
int_max(overlap_width(x) - (x).rightmargin, 0)
#define overlap_width(x)
Definition renderer.c:880

◆ overlap_width

#define overlap_width ( x)
Value:
int_min((x).width, \
static int int_min(int x, int y)
Definition math.h:30
#define TABLE_LINE_PADDING
Definition setup.h:123
int document_width
Definition options.h:64
Definition internal.h:69
struct document_options * options
Definition internal.h:86

◆ POS

#define POS ( x_,
y_ )
Value:
LINE(y_).ch.chars[X(x_)]
#define X(renderer)
Definition util.h:44

◆ SPACES_GRANULARITY

#define SPACES_GRANULARITY   0x7F

◆ X

#define X ( x_)
Value:
(part->box.x + (x_))

◆ Y

#define Y ( y_)
Value:
(part->box.y + (y_))
int y
Definition box.h:11

Typedef Documentation

◆ link_state_T

typedef unsigned char link_state_T

Enumeration Type Documentation

◆ link_state

enum link_state
Enumerator
LINK_STATE_NONE 
LINK_STATE_NEW 
LINK_STATE_SAME 

Function Documentation

◆ align_line()

void align_line ( struct html_context * html_context,
int y,
int last )
static

◆ assert_forms_list_ok()

void assert_forms_list_ok ( struct form list * forms)
static

Assert that each form in the list has a different form.form_num ... form.form_end range and that the ranges are contiguous and together cover all numbers from 0 to INT_MAX.

Alternatively, the whole list may be empty. This function can be called from a debugger, or automatically from some places.

This function may leave assert_failed = 1; the caller must use if_assert_failed.

◆ check_html_form_hierarchy()

void check_html_form_hierarchy ( struct part * part)

◆ clear_hchars()

void clear_hchars ( struct html_context * html_context,
int x,
int y,
int width,
struct screen_char * a )
inlinestatic

◆ color_link_lines()

void color_link_lines ( struct html_context * html_context)
inlinestatic

◆ copy_chars()

void copy_chars ( struct html_context * html_context,
int x,
int y,
int width,
struct screen_char * d )
inlinestatic

◆ dec2qwerty()

int dec2qwerty ( int num,
char * link_sym,
const char * key,
int base )

◆ del_chars()

void del_chars ( struct html_context * html_context,
int x,
int y )
inlinestatic

◆ done_link_state_info()

void done_link_state_info ( void )
inlinestatic

◆ draw_blockquote_chars()

void draw_blockquote_chars ( struct part * part,
int y,
struct html_context * html_context )

◆ draw_frame_hchars()

void draw_frame_hchars ( struct part * part,
int x,
int y,
int width,
unsigned char data,
color_T bgcolor,
color_T fgcolor,
struct html_context * html_context )

◆ draw_frame_vchars()

void draw_frame_vchars ( struct part * part,
int x,
int y,
int height,
unsigned char data,
color_T bgcolor,
color_T fgcolor,
struct html_context * html_context )

◆ expand_lines()

void expand_lines ( struct html_context * html_context,
struct part * part,
int x,
int y,
int lines,
color_T bgcolor )

◆ format_html_part()

struct part * format_html_part ( struct html_context * html_context,
char * start,
char * end,
int align,
int margin,
int width,
struct document * document,
int x,
int y,
char * head,
int link_num )

◆ free_table_cache()

void free_table_cache ( void )

◆ get_format_screen_char()

struct screen_char * get_format_screen_char ( struct html_context * html_context,
link_state_T link_state )
inlinestatic

◆ get_frame_char()

struct screen_char * get_frame_char ( struct html_context * html_context,
struct part * part,
int x,
int y,
unsigned char data,
color_T bgcolor,
color_T fgcolor )
inlinestatic

◆ get_link_state()

link_state_T get_link_state ( struct html_context * html_context)
inlinestatic

◆ html_has_non_space_chars()

int html_has_non_space_chars ( const char * chars,
int charslen )
inlinestatic

◆ html_special()

void * html_special ( struct html_context * html_context,
html_special_type_T c,
... )

◆ html_special_form()

void html_special_form ( struct part * part,
struct form * form )
static

◆ html_special_form_control()

void html_special_form_control ( struct part * part,
struct el_form_control * fc )
static

◆ html_special_tag()

void html_special_tag ( struct document * document,
char * t,
int x,
int y )
static

◆ init_link_event_hooks()

void init_link_event_hooks ( struct html_context * html_context,
struct link * link )
inlinestatic

◆ init_link_state_info()

void init_link_state_info ( char * link,
char * target,
char * image,
struct el_form_control * form )
inlinestatic

◆ insert_spaces_in_link()

void insert_spaces_in_link ( struct part * part,
int x,
int y,
int new_spaces )
static

◆ justify_line()

void justify_line ( struct html_context * html_context,
int y )
static

◆ line_break()

void line_break ( struct html_context * html_context)

◆ move_chars()

void move_chars ( struct html_context * html_context,
int x,
int y,
int nx,
int ny )
inlinestatic

◆ move_links()

void move_links ( struct html_context * html_context,
int xf,
int yf,
int xt,
int yt )
static

◆ new_link()

struct link * new_link ( struct html_context * html_context,
const char * name,
int namelen )
static

◆ process_link()

void process_link ( struct html_context * html_context,
link_state_T link_state,
const char * chars,
int charslen,
int cells )
inlinestatic

◆ put_chars()

void put_chars ( struct html_context * html_context,
const char * chars,
int charslen )
static

◆ put_chars_conv()

void put_chars_conv ( struct html_context * html_context,
const char * chars,
int charslen )

◆ put_link_number()

void put_link_number ( struct html_context * html_context)
inlinestatic

◆ qwerty2dec()

int qwerty2dec ( const char * link_sym,
const char * key,
int base )

◆ realloc_line()

int realloc_line ( struct html_context * html_context,
struct document * document,
int y,
int length )
static

◆ realloc_spaces()

int realloc_spaces ( struct part * part,
int length )
inlinestatic

◆ render_html_document()

void render_html_document ( struct cache_entry * cached,
struct document * document,
struct string * buffer )

◆ set_hline()

int set_hline ( struct html_context * html_context,
const char * chars,
int charslen,
link_state_T link_state )
inlinestatic

◆ set_screen_char_color()

void set_screen_char_color ( struct screen_char * schar,
color_T bgcolor,
color_T fgcolor,
color_flags_T color_flags,
color_mode_T color_mode )
inlinestatic

◆ shift_chars()

void shift_chars ( struct html_context * html_context,
int y,
int shift )
inlinestatic

Shift the line y to the right by shift character cells, and update document.comb_x and document.comb_y.

◆ split_line()

int split_line ( struct html_context * html_context)
static

◆ split_line_at()

int split_line_at ( struct html_context * html_context,
int width )
inlinestatic

◆ subst_frame_chars()

void subst_frame_chars ( struct document * document)
static

Variable Documentation

◆ renderer_context

struct renderer_context renderer_context

◆ table_cache

struct hash* table_cache
static

◆ table_cache_entries

int table_cache_entries
static