ELinks 0.18.0
|
Terminal screen drawing routines. More...
#include <stdlib.h>
#include <string.h>
#include "elinks.h"
#include "config/options.h"
#include "intl/charsets.h"
#include "main/module.h"
#include "osdep/ascii.h"
#include "osdep/osdep.h"
#include "terminal/color.h"
#include "terminal/draw.h"
#include "terminal/hardio.h"
#include "terminal/kbd.h"
#include "terminal/screen.h"
#include "terminal/terminal.h"
#include "util/bitfield.h"
#include "util/conv.h"
#include "util/error.h"
#include "util/memory.h"
#include "util/string.h"
#include <stdio.h>
Data Structures | |
struct | screen_driver_opt |
struct | screen_driver |
Used in add_char* () and redraw_screen() to reduce the logic. More... | |
struct | screen_state |
Macros | |
#define | TERM_STRING(str) |
#define | add_term_string(str, tstr) |
Like add_string_to_string() but has fewer checks to slow it down. | |
#define | use_utf8_io(driver) |
#define | CURSOR_NUM_LEN 10 /* 10 chars for @y and @x numbers should be more than enough. */ |
#define | INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0xFF, 0, 0xFF, { 0xFF } } |
#define | add_chars(image_, term_, driver_, state_, ADD_CHAR, compare_bg_color, compare_fg_color) |
Functions | |
void | set_screen_dirty (struct terminal_screen *screen, int from, int to) |
Mark the screen ready for redrawing. | |
static void | set_screen_driver_opt (struct screen_driver *driver, struct option *term_spec) |
Set screen_driver.opt according to screen_driver.type and term_spec. | |
static int | screen_driver_change_hook (struct session *ses, struct option *term_spec, struct option *changed) |
static struct screen_driver * | add_screen_driver (term_mode_type_T type, struct terminal *term, int env_len) |
static struct screen_driver * | get_screen_driver (struct terminal *term) |
void | done_screen_drivers (struct module *xxx) |
Release private screen drawing utilities. | |
struct string * | add_cursor_move_to_string (struct string *screen, int y, int x) |
Adds the term code for positioning the cursor at x and y to string. | |
static int | compare_color_16 (unsigned char *a, unsigned char *b) |
static int | compare_bg_color_16 (unsigned char *a, unsigned char *b) |
static int | compare_fg_color_16 (unsigned char *a, unsigned char *b) |
static void | copy_color_16 (unsigned char *a, unsigned char *b) |
static void | add_char_data (struct string *screen, struct screen_driver *driver, unicode_val_T data, unsigned char border) |
static void | add_char16 (struct string *screen, struct screen_driver *driver, struct screen_char *ch, struct screen_state *state) |
Time critical section. | |
void | redraw_screen (struct terminal *term) |
Updates the terminal screen. | |
void | erase_screen (struct terminal *term) |
Erases the entire screen and moves the cursor to the upper left corner. | |
void | beep_terminal (struct terminal *term) |
Meeep! | |
struct terminal_screen * | init_screen (void) |
Initializes a screen. | |
void | resize_screen (struct terminal *term, int width, int height) |
Update the size of the previous and the current screen image to hold x time y chars. | |
void | done_screen (struct terminal_screen *screen) |
Cleans up after the screen. |
Variables | |
const unsigned char | frame_dumb [48] |
Mapping from (enum border_char - 0xB0) to ASCII characters. | |
static const unsigned char | frame_vt100 [48] |
Mapping from (enum border_char - 0xB0) to VT100 line-drawing characters. | |
static const unsigned char | frame_vt100_u [48] |
Mapping from (enum border_char - 0xB0) to VT100 line-drawing characters encoded in CP437. | |
static const unsigned char | frame_freebsd [48] |
Mapping from (enum border_char - 0xB0) to obsolete FreeBSD ACS graphics. | |
static const unsigned char | frame_freebsd_u [48] |
Mapping from (enum border_char - 0xB0) to obsolete FreeBSD ACS graphics encoded in CP437. | |
static const unsigned char | frame_koi [48] |
Mapping from (enum border_char - 0xB0) to KOI8-R. | |
static const unsigned char | frame_restrict [48] |
Mapping from (enum border_char - 0xB0) to CP850 or CP852. | |
static const struct string | m11_hack_frame_seqs [] |
Frame begin/end sequences that switch fonts with ECMA-48 SGR. | |
static const struct string | vt100_frame_seqs [] |
Frame begin/end sequences for VT100. | |
static const struct string | italic_seqs [] |
Italic begin/end sequences using ECMA-48 SGR. | |
static const struct string | underline_seqs [] |
Underline begin/end sequences using ECMA-48 SGR. | |
static const struct string | strike_seqs [] |
static const struct screen_driver_opt | dumb_screen_driver_opt |
Default options for TERM_DUMB. | |
static const struct screen_driver_opt | vt100_screen_driver_opt |
Default options for TERM_VT100. | |
static const struct screen_driver_opt | linux_screen_driver_opt |
Default options for TERM_LINUX. | |
static const struct screen_driver_opt | koi8_screen_driver_opt |
Default options for TERM_KOI8. | |
static const struct screen_driver_opt | freebsd_screen_driver_opt |
Default options for TERM_FREEBSD. | |
static const struct screen_driver_opt | fbterm_screen_driver_opt |
Default options for TERM_FBTERM. | |
static const struct screen_driver_opt *const | screen_driver_opts [] |
Default options for all the different types of terminals. | |
static struct screen_driver list | active_screen_drivers = { D_LIST_HEAD_EL(active_screen_drivers) } |
struct module | terminal_screen_module |
Terminal screen drawing routines.
#define add_chars | ( | image_, | |
term_, | |||
driver_, | |||
state_, | |||
ADD_CHAR, | |||
compare_bg_color, | |||
compare_fg_color ) |
#define add_term_string | ( | str, | |
tstr ) |
Like add_string_to_string() but has fewer checks to slow it down.
#define CURSOR_NUM_LEN 10 /* 10 chars for @y and @x numbers should be more than enough. */ |
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0xFF, 0, 0xFF, { 0xFF } } |
#define TERM_STRING | ( | str | ) |
#define use_utf8_io | ( | driver | ) |
|
inlinestatic |
Time critical section.
|
inlinestatic |
Adds the term code for positioning the cursor at x and y to string.
The template term code is: "\033[<y>;<x>H"
|
inlinestatic |
void beep_terminal | ( | struct terminal * | term | ) |
Meeep!
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
void done_screen | ( | struct terminal_screen * | screen | ) |
Cleans up after the screen.
void done_screen_drivers | ( | struct module * | xxx | ) |
Release private screen drawing utilities.
void erase_screen | ( | struct terminal * | term | ) |
Erases the entire screen and moves the cursor to the upper left corner.
|
inlinestatic |
struct terminal_screen * init_screen | ( | void | ) |
Initializes a screen.
Returns NULL upon allocation failure.
void redraw_screen | ( | struct terminal * | term | ) |
Updates the terminal screen.
Updating of the terminal screen is done by checking what needs to be updated using the last screen.
void resize_screen | ( | struct terminal * | term, |
int | width, | ||
int | height ) |
Update the size of the previous and the current screen image to hold x time y chars.
The two images are allocated in one chunk.
|
static |
void set_screen_dirty | ( | struct terminal_screen * | screen, |
int | from, | ||
int | to ) |
Mark the screen ready for redrawing.
|
static |
Set screen_driver.opt according to screen_driver.type and term_spec.
Other members of *driver need not have been initialized.
If you modify anything here, check whether option descriptions should be updated.
|
static |
|
static |
Default options for TERM_DUMB.
|
static |
Default options for TERM_FBTERM.
const unsigned char frame_dumb[48] |
Mapping from (enum border_char - 0xB0) to ASCII characters.
|
static |
Mapping from (enum border_char - 0xB0) to obsolete FreeBSD ACS graphics.
This is for FreeBSD fonts that place graphics characters in the 0x80...0x9F range, which ISO 8859 does not use. The characters are supposed to be sorted according to the codes used in VT100 or in the terminfo "acsc" capability:
* 0x80 U+2588 '0' ACS_BLOCK * 0x81 U+25C6 '`' ACS_DIAMOND * 0x82 U+2592 'a' ACS_CKBOARD * 0x83 U+2409 'b' - * 0x84 U+240C 'c' - * 0x85 U+240D 'd' - * 0x86 U+240A 'e' - * 0x87 U+00B0 'f' ACS_DEGREE * 0x88 U+00B1 'g' ACS_PLMINUS * 0x89 U+2424 'h' - * 0x8A U+240B 'i' - * 0x8B U+2518 'j' ACS_LRCORNER * 0x8C U+2510 'k' ACS_URCORNER * 0x8D U+250C 'l' ACS_ULCORNER * 0x8E U+2514 'm' ACS_LLCORNER * 0x8F U+253C 'n' ACS_PLUS * 0x90 U+23BA 'o' ACS_S1 * 0x91 U+23BB 'p' ACS_S3 * 0x92 U+2500 'q' ACS_HLINE * 0x93 U+23BC 'r' ACS_S7 * 0x94 U+23BD 's' ACS_S9 * 0x95 U+251C 't' ACS_LTEE * 0x96 U+2524 'u' ACS_RTEE * 0x97 U+2534 'v' ACS_BTEE * 0x98 U+252C 'w' ACS_TTEE * 0x99 U+2502 'x' ACS_VLINE * 0x9A U+2264 'y' ACS_LEQUAL * 0x9B U+2265 'z' ACS_GEQUAL * 0x9C U+03C0 '{' ACS_PI * 0x9D U+2260 '|' ACS_NEQUAL * 0x9E U+00A3 '}' ACS_STERLING * 0x9F U+00B7 '~' ACS_BULLET *
(Ncurses 5.5 defines ACS_BOARD using 'h' and ACS_LANTERN using 'i', but those are not the characters meant above.)
In FreeBSD CVS, src/share/syscons/fonts/iso-8x16.fnt revision 1.1 includes these characters, except it has a space at 0x80. In revision 1.2 however, all the characters not defined by ISO 8859-1 have been blanked out. This change was made on 2001-11-22 and included in FreeBSD 4.6.0, which was then released in June 2002. Yet, support for these characters was added to Links on 2003-11-18 and to ELinks on 2003-12-07, so perhaps we should keep it for now.
|
static |
Mapping from (enum border_char - 0xB0) to obsolete FreeBSD ACS graphics encoded in CP437.
When UTF-8 I/O is enabled, ELinks uses this array instead of frame_freebsd[], and converts the characters from CP437 to UTF-8.
Derived from frame_freebsd[] by converting the characters to Unicode and back to CP437. frame_freebsd[1] = 138 = 0x8a = U+240B SYMBOL FOR VERTICAL TABULATION does not exist in CP437, so we substitute U+2592 MEDIUM SHADE.
|
static |
Mapping from (enum border_char - 0xB0) to KOI8-R.
|
static |
Mapping from (enum border_char - 0xB0) to CP850 or CP852.
Most of this table is just 0xB0 + <index in table>, because these codepages are quite similar to CP437. However, they lack some line-drawing characters, so we must use others instead.
|
static |
Mapping from (enum border_char - 0xB0) to VT100 line-drawing characters.
|
static |
Mapping from (enum border_char - 0xB0) to VT100 line-drawing characters encoded in CP437.
When UTF-8 I/O is enabled, ELinks uses this array instead of frame_vt100[], and converts the characters from CP437 to UTF-8.
|
static |
Default options for TERM_FREEBSD.
|
static |
Italic begin/end sequences using ECMA-48 SGR.
ECMA-48: CSI Ps... 06/13 = SGR - SELECT GRAPHIC RENDITION
|
static |
|
static |
Default options for TERM_LINUX.
|
static |
Frame begin/end sequences that switch fonts with ECMA-48 SGR.
ECMA-48: CSI Ps... 06/13 = SGR - SELECT GRAPHIC RENDITION
|
static |
Default options for all the different types of terminals.
XXX: Keep in sync with term_mode_type_T.
|
static |
struct module terminal_screen_module |
|
static |
Underline begin/end sequences using ECMA-48 SGR.
ECMA-48: CSI Ps... 06/13 = SGR - SELECT GRAPHIC RENDITION
|
static |
Frame begin/end sequences for VT100.
|
static |
Default options for TERM_VT100.