1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-21 00:25:37 +00:00

[options] Added bool option document.plain.sixel

This commit is contained in:
Witold Filipczyk 2023-05-26 19:46:07 +02:00
parent c8f55f5df0
commit ed1afeb648
4 changed files with 17 additions and 1 deletions

View File

@ -868,6 +868,12 @@ static union option_info config_options_info[] = {
N_("Change ascii border characters to frame borders. Usage example: "
"mysql --pager=elinks")),
#ifdef CONFIG_LIBSIXEL
INIT_OPT_BOOL("document.plain", N_("Sixel"),
"sixel", OPT_ZERO, 0,
N_("Whether to display sixel images in plain text documents.")),
#endif
INIT_OPT_TREE("document", N_("URI passing"),
"uri_passing", OPT_SORT | OPT_AUTOCREATE,
N_("Rules for passing URIs to external commands. When one "

View File

@ -115,6 +115,7 @@ init_document_options(struct session *ses, struct document_options *doo)
doo->image_link.tagging = get_opt_int("document.browse.images.image_link_tagging", ses);
doo->image_link.show_any_as_links = get_opt_bool("document.browse.images.show_any_as_links", ses);
#ifdef CONFIG_LIBSIXEL
doo->sixel = get_opt_bool("document.plain.sixel", ses);
if (ses && ses->tab->term) {
doo->cell_width = ses->tab->term->cell_width;
doo->cell_height = ses->tab->term->cell_height;

View File

@ -161,6 +161,10 @@ struct document_options {
unsigned int utf8:1;
#endif /* CONFIG_UTF8 */
unsigned int dump:1;
#ifdef CONFIG_LIBSIXEL
unsigned int sixel:1;
#endif
/** Active link coloring.
* This is mostly here to make use of this option cache so
* link drawing is faster. --jonas */

View File

@ -56,6 +56,8 @@ struct plain_renderer {
/* Are we doing line compression */
unsigned int compress:1;
unsigned int sixel:1;
};
#define realloc_document_links(doc, size) \
@ -642,7 +644,7 @@ add_document_line(struct plain_renderer *renderer,
template_->attr |= pos->attr;
} else if (line_char == 27) {
#ifdef CONFIG_LIBSIXEL
if (line_pos + 1 < width && line[line_pos + 1] == 'P') { // && line_pos + 2 < width && line[line_pos + 2] == 'q') {
if (renderer->sixel && line_pos + 1 < width && line[line_pos + 1] == 'P') { // && line_pos + 2 < width && line[line_pos + 2] == 'q') {
while (1) {
char *end = (char *)memchr(line + line_pos + 1, 27, width - line_pos - 1);
@ -1013,6 +1015,9 @@ render_plain_document(struct cache_entry *cached, struct document *document,
renderer.lineno = 0;
renderer.convert_table = convert_table;
renderer.compress = document->options.plain_compress_empty_lines;
#ifdef CONFIG_LIBSIXEL
renderer.sixel = document->options.sixel;
#endif
renderer.max_width = document->options.wrap ? document->options.document_width
: INT_MAX;