ELinks 0.18.0
draw.c File Reference

Public terminal drawing API. More...

#include "elinks.h"
#include "bfu/dialog.h"
#include "config/options.h"
#include "intl/charsets.h"
#include "terminal/color.h"
#include "terminal/draw.h"
#include "terminal/screen.h"
#include "terminal/terminal.h"
#include "util/color.h"
#include "util/box.h"
Include dependency graph for draw.c:

Macros

#define check_range(term, x, y)
 Makes sure that x and y are within the dimensions of the terminal.
 
#define clear_screen_char_color(schar)    do { (schar)->c.color[0] = 0; } while (0)
 

Functions

NONSTATIC_INLINE struct screen_charget_char (struct terminal *term, int x, int y)
 Extracts a char from the screen.
 
void draw_border_cross (struct terminal *term, int x, int y, enum border_cross_direction dir, struct color_pair *color)
 Sets the cross position of two borders.
 
void draw_border_char (struct terminal *term, int x, int y, border_char_T border, struct color_pair *color)
 Sets the data to border and of a screen position.
 
void draw_char_color (struct terminal *term, int x, int y, struct color_pair *color)
 Sets the color of a screen position.
 
void draw_char_data (struct terminal *term, int x, int y, unicode_val_T data)
 Sets the data of a screen position.
 
void draw_space (struct terminal *term, int x, int y, struct screen_char *color)
 
void draw_line (struct terminal *term, int x, int y, int l, struct screen_char *line)
 Draws length chars from line on the screen.
 
void draw_border (struct terminal *term, struct el_box *box, struct color_pair *color, int width)
 Draw borders.
 
void fix_dwchar_around_box (struct terminal *term, struct el_box *box, int border, int shadow_width, int shadow_height)
 Checks cells left and right to the box for broken double-width chars.
 
void draw_char (struct terminal *term, int x, int y, unicode_val_T data, int attr, struct color_pair *color)
 Draws a char.
 
void draw_box (struct terminal *term, struct el_box *box, unicode_val_T data, int attr, struct color_pair *color)
 Draws area defined by box using the same colors and attributes.
 
void draw_shadow (struct terminal *term, struct el_box *box, struct color_pair *color, int width, int height)
 Draws a shadow of width and height with color color around box.
 
static void draw_text_utf8 (struct terminal *term, int x, int y, const char *text2, int length, int attr, struct color_pair *color)
 
void draw_text (struct terminal *term, int x, int y, const char *text, int length, int attr, struct color_pair *color)
 Draws length chars from text.
 
void draw_dlg_text (struct dialog_data *dlg_data, int x, int y, const char *text, int length, int attr, struct color_pair *color)
 Draws text for dialogs.
 
void set_cursor (struct terminal *term, int x, int y, int blockable)
 Updates the terminals cursor position.
 
void set_dlg_cursor (struct terminal *term, struct dialog_data *dlg_data, int x, int y, int blockable)
 
void clear_terminal (struct terminal *term)
 Blanks the screen.
 

Detailed Description

Public terminal drawing API.

Frontend for the screen image in memory.

Macro Definition Documentation

◆ check_range

#define check_range ( term,
x,
y )
Value:
do { \
int_bounds(&(x), 0, (term)->width - 1); \
int_bounds(&(y), 0, (term)->height - 1); \
} while (0)

Makes sure that x and y are within the dimensions of the terminal.

◆ clear_screen_char_color

#define clear_screen_char_color ( schar)     do { (schar)->c.color[0] = 0; } while (0)

Function Documentation

◆ clear_terminal()

void clear_terminal ( struct terminal * term)

Blanks the screen.

◆ draw_border()

void draw_border ( struct terminal * term,
struct el_box * box,
struct color_pair * color,
int width )

Draw borders.

◆ draw_border_char()

void draw_border_char ( struct terminal * term,
int x,
int y,
border_char_T border,
struct color_pair * color )

Sets the data to border and of a screen position.

◆ draw_border_cross()

void draw_border_cross ( struct terminal * term,
int x,
int y,
enum border_cross_direction dir,
struct color_pair * color )

Sets the cross position of two borders.

◆ draw_box()

void draw_box ( struct terminal * term,
struct el_box * box,
unicode_val_T data,
int attr,
struct color_pair * color )

Draws area defined by box using the same colors and attributes.

◆ draw_char()

void draw_char ( struct terminal * term,
int x,
int y,
unicode_val_T data,
int attr,
struct color_pair * color )

Draws a char.

◆ draw_char_color()

void draw_char_color ( struct terminal * term,
int x,
int y,
struct color_pair * color )

Sets the color of a screen position.

◆ draw_char_data()

void draw_char_data ( struct terminal * term,
int x,
int y,
unicode_val_T data )

Sets the data of a screen position.

The data parameter here is like screen_char.data: UCS-4 if the charset of the terminal is UTF-8 (possible only if CONFIG_UTF8 is defined), and a byte otherwise.

◆ draw_dlg_text()

void draw_dlg_text ( struct dialog_data * dlg_data,
int x,
int y,
const char * text,
int length,
int attr,
struct color_pair * color )

Draws text for dialogs.

◆ draw_line()

void draw_line ( struct terminal * term,
int x,
int y,
int l,
struct screen_char * line )

Draws length chars from line on the screen.

Used by viewer to copy over a document. When doing frame drawing x can be different than 0.

◆ draw_shadow()

void draw_shadow ( struct terminal * term,
struct el_box * box,
struct color_pair * color,
int width,
int height )

Draws a shadow of width and height with color color around box.

◆ draw_space()

void draw_space ( struct terminal * term,
int x,
int y,
struct screen_char * color )

◆ draw_text()

void draw_text ( struct terminal * term,
int x,
int y,
const char * text,
int length,
int attr,
struct color_pair * color )

Draws length chars from text.

◆ draw_text_utf8()

static void draw_text_utf8 ( struct terminal * term,
int x,
int y,
const char * text2,
int length,
int attr,
struct color_pair * color )
static

◆ fix_dwchar_around_box()

void fix_dwchar_around_box ( struct terminal * term,
struct el_box * box,
int border,
int shadow_width,
int shadow_height )

Checks cells left and right to the box for broken double-width chars.

Replace it with UCS_ORPHAN_CELL.

* 1+---+3
* 1|box|##4
* 1|   |##4
* 1|   |##4
* 1+---+##4
*   2#####4
* 1,2,3,4 - needs to be checked, # - shadow , +,-,| - border
* 

◆ get_char()

NONSTATIC_INLINE struct screen_char * get_char ( struct terminal * term,
int x,
int y )

Extracts a char from the screen.

◆ set_cursor()

void set_cursor ( struct terminal * term,
int x,
int y,
int blockable )

Updates the terminals cursor position.

When blockable is set the block_cursor terminal option decides whether the cursor should be put at the bottom right corner of the screen.

◆ set_dlg_cursor()

void set_dlg_cursor ( struct terminal * term,
struct dialog_data * dlg_data,
int x,
int y,
int blockable )