1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[sixel] Added sixel to terminal options.

To see sixel images you must:
- build elinks with -Dlibsixel=true
- set document.plain.sixel=1
- enable sixel in terminal options
- add to mailcap:
image/*; img2sixel %s; copiousoutput
or
image/*; convert %s sixel:- ; copiousoutput

and click some images on terminal which supports sixel.

While opening dialogs or menu, sixel images are not shown.
This commit is contained in:
Witold Filipczyk 2023-05-27 21:35:31 +02:00
parent ed1afeb648
commit aae82861cf
8 changed files with 57 additions and 4 deletions

View File

@ -475,6 +475,7 @@ dialog_func(struct window *win, struct term_event *ev)
case EVENT_RESIZE:
case EVENT_REDRAW:
redraw_dialog(dlg_data, 1);
win->term->sixel = 0;
break;
case EVENT_MOUSE:
@ -489,6 +490,7 @@ dialog_func(struct window *win, struct term_event *ev)
case EVENT_ABORT:
dialog_ev_abort(dlg_data);
win->term->sixel = 1;
break;
}
}

View File

@ -1014,6 +1014,7 @@ menu_handler(struct window *win, struct term_event *ev)
* menu->selected here. */
scroll_menu(menu, 0, 1);
display_menu(win->term, menu);
win->term->sixel = 0;
break;
case EVENT_MOUSE:
@ -1027,6 +1028,7 @@ menu_handler(struct window *win, struct term_event *ev)
break;
case EVENT_ABORT:
win->term->sixel = 1;
free_menu_items(menu->items);
break;
}
@ -1367,6 +1369,7 @@ mainmenu_handler(struct window *win, struct term_event *ev)
break;
case EVENT_ABORT:
win->term->sixel = 1;
break;
}
}

View File

@ -1126,7 +1126,11 @@ static union option_info config_options_info[] = {
"underline", OPT_ZERO, 0,
N_("If we should use underline or enhance the color "
"instead.")),
#ifdef CONFIG_LIBSIXEL
INIT_OPT_BOOL("terminal._template_", N_("Sixel"),
"sixel", OPT_ZERO, 0,
N_("Whether terminal supports sixel graphics.")),
#endif
INIT_OPT_CODEPAGE("terminal._template_", N_("Codepage"),
"charset", OPT_ZERO, "System",
N_("Codepage of charset used for displaying content on "

View File

@ -99,7 +99,9 @@ enum termopt {
#ifdef CONFIG_COMBINE
TERM_OPT_COMBINE,
#endif
#ifdef CONFIG_LIBSIXEL
TERM_OPT_SIXEL,
#endif
TERM_OPTIONS,
};
@ -116,6 +118,9 @@ static struct option_resolver resolvers[] = {
#ifdef CONFIG_COMBINE
{ TERM_OPT_COMBINE, "combine" },
#endif
#ifdef CONFIG_LIBSIXEL
{ TERM_OPT_SIXEL, "sixel" },
#endif
};
static widget_handler_status_T
@ -241,7 +246,9 @@ terminal_options(struct terminal *term, void *xxx, struct session *ses)
#ifdef CONFIG_COMBINE
add_dlg_checkbox(dlg, _("Combining characters", term), &values[TERM_OPT_COMBINE].number);
#endif
#ifdef CONFIG_LIBSIXEL
add_dlg_checkbox(dlg, _("Sixel", term), &values[TERM_OPT_SIXEL].number);
#endif
add_dlg_button(dlg, _("~OK", term), B_ENTER, push_ok_button, NULL);
if (!anonymous)
add_dlg_button(dlg, _("Sa~ve", term), B_ENTER, push_save_button, NULL);

View File

@ -270,6 +270,10 @@ struct screen_driver_opt {
/* Whether use terminfo. */
unsigned int terminfo:1;
#endif
#ifdef CONFIG_LIBSIXEL
unsigned int sixel:1;
#endif
};
/** Used in @c add_char*() and @c redraw_screen() to reduce the logic.
@ -312,6 +316,9 @@ static const struct screen_driver_opt dumb_screen_driver_opt = {
#ifdef CONFIG_TERMINFO
/* terminfo */ 0,
#endif
#ifdef CONFIG_LIBSIXEL
/* sixel */ 0,
#endif
};
/** Default options for ::TERM_VT100. */
@ -335,6 +342,9 @@ static const struct screen_driver_opt vt100_screen_driver_opt = {
#ifdef CONFIG_TERMINFO
/* terminfo */ 0,
#endif
#ifdef CONFIG_LIBSIXEL
/* sixel */ 0,
#endif
};
/** Default options for ::TERM_LINUX. */
@ -358,6 +368,9 @@ static const struct screen_driver_opt linux_screen_driver_opt = {
#ifdef CONFIG_TERMINFO
/* terminfo */ 0,
#endif
#ifdef CONFIG_LIBSIXEL
/* sixel */ 0,
#endif
};
/** Default options for ::TERM_KOI8. */
@ -381,6 +394,9 @@ static const struct screen_driver_opt koi8_screen_driver_opt = {
#ifdef CONFIG_TERMINFO
/* terminfo */ 0,
#endif
#ifdef CONFIG_LIBSIXEL
/* sixel */ 0,
#endif
};
/** Default options for ::TERM_FREEBSD. */
@ -404,6 +420,9 @@ static const struct screen_driver_opt freebsd_screen_driver_opt = {
#ifdef CONFIG_TERMINFO
/* terminfo */ 0,
#endif
#ifdef CONFIG_LIBSIXEL
/* sixel */ 0,
#endif
};
/** Default options for ::TERM_FBTERM. */
@ -427,6 +446,9 @@ static const struct screen_driver_opt fbterm_screen_driver_opt = {
#ifdef CONFIG_TERMINFO
/* terminfo */ 0,
#endif
#ifdef CONFIG_LIBSIXEL
/* sixel */ 0,
#endif
};
/** Default options for all the different types of terminals.
@ -473,6 +495,11 @@ set_screen_driver_opt(struct screen_driver *driver, struct option *term_spec)
#ifdef CONFIG_COMBINE
driver->opt.combine = get_opt_bool_tree(term_spec, "combine", NULL);
#endif /* CONFIG_COMBINE */
#ifdef CONFIG_LIBSIXEL
driver->opt.sixel = get_opt_bool_tree(term_spec, "sixel", NULL);
#endif /* CONFIG_LIBSIXEL */
#ifdef CONFIG_UTF8
/* Force UTF-8 I/O if the UTF-8 charset is selected. Various
* places assume that the terminal's charset is unibyte if
@ -1394,7 +1421,9 @@ redraw_screen(struct terminal *term)
if (!init_string(&image)) return;
#ifdef CONFIG_LIBSIXEL
try_to_draw_images(term);
if (driver->opt.sixel) {
try_to_draw_images(term);
}
#endif
switch (driver->opt.color_mode) {
default:

View File

@ -759,6 +759,10 @@ try_to_draw_images(struct terminal *term)
{
struct image *im;
if (!term->sixel) {
return;
}
foreach (im, term->images) {
struct string text;

View File

@ -120,6 +120,7 @@ init_term(int fdin, int fdout)
#ifdef CONFIG_LIBSIXEL
init_list(term->images);
term->sixel = 1;
#endif
term->fdin = fdin;
term->fdout = fdout;

View File

@ -151,6 +151,9 @@ struct terminal {
unsigned int utf8_io:1;
#endif /* CONFIG_UTF8 */
#ifdef CONFIG_LIBSIXEL
unsigned int sixel:1;
#endif
/** The current tab number. */
int current_tab;