mirror of
https://github.com/rkd77/elinks.git
synced 2024-06-28 01:35:32 +00: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:
parent
ed1afeb648
commit
aae82861cf
|
@ -475,6 +475,7 @@ dialog_func(struct window *win, struct term_event *ev)
|
||||||
case EVENT_RESIZE:
|
case EVENT_RESIZE:
|
||||||
case EVENT_REDRAW:
|
case EVENT_REDRAW:
|
||||||
redraw_dialog(dlg_data, 1);
|
redraw_dialog(dlg_data, 1);
|
||||||
|
win->term->sixel = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_MOUSE:
|
case EVENT_MOUSE:
|
||||||
|
@ -489,6 +490,7 @@ dialog_func(struct window *win, struct term_event *ev)
|
||||||
|
|
||||||
case EVENT_ABORT:
|
case EVENT_ABORT:
|
||||||
dialog_ev_abort(dlg_data);
|
dialog_ev_abort(dlg_data);
|
||||||
|
win->term->sixel = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1014,6 +1014,7 @@ menu_handler(struct window *win, struct term_event *ev)
|
||||||
* menu->selected here. */
|
* menu->selected here. */
|
||||||
scroll_menu(menu, 0, 1);
|
scroll_menu(menu, 0, 1);
|
||||||
display_menu(win->term, menu);
|
display_menu(win->term, menu);
|
||||||
|
win->term->sixel = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_MOUSE:
|
case EVENT_MOUSE:
|
||||||
|
@ -1027,6 +1028,7 @@ menu_handler(struct window *win, struct term_event *ev)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_ABORT:
|
case EVENT_ABORT:
|
||||||
|
win->term->sixel = 1;
|
||||||
free_menu_items(menu->items);
|
free_menu_items(menu->items);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1367,6 +1369,7 @@ mainmenu_handler(struct window *win, struct term_event *ev)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EVENT_ABORT:
|
case EVENT_ABORT:
|
||||||
|
win->term->sixel = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1126,7 +1126,11 @@ static union option_info config_options_info[] = {
|
||||||
"underline", OPT_ZERO, 0,
|
"underline", OPT_ZERO, 0,
|
||||||
N_("If we should use underline or enhance the color "
|
N_("If we should use underline or enhance the color "
|
||||||
"instead.")),
|
"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"),
|
INIT_OPT_CODEPAGE("terminal._template_", N_("Codepage"),
|
||||||
"charset", OPT_ZERO, "System",
|
"charset", OPT_ZERO, "System",
|
||||||
N_("Codepage of charset used for displaying content on "
|
N_("Codepage of charset used for displaying content on "
|
||||||
|
|
|
@ -99,7 +99,9 @@ enum termopt {
|
||||||
#ifdef CONFIG_COMBINE
|
#ifdef CONFIG_COMBINE
|
||||||
TERM_OPT_COMBINE,
|
TERM_OPT_COMBINE,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
TERM_OPT_SIXEL,
|
||||||
|
#endif
|
||||||
TERM_OPTIONS,
|
TERM_OPTIONS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -116,6 +118,9 @@ static struct option_resolver resolvers[] = {
|
||||||
#ifdef CONFIG_COMBINE
|
#ifdef CONFIG_COMBINE
|
||||||
{ TERM_OPT_COMBINE, "combine" },
|
{ TERM_OPT_COMBINE, "combine" },
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
{ TERM_OPT_SIXEL, "sixel" },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static widget_handler_status_T
|
static widget_handler_status_T
|
||||||
|
@ -241,7 +246,9 @@ terminal_options(struct terminal *term, void *xxx, struct session *ses)
|
||||||
#ifdef CONFIG_COMBINE
|
#ifdef CONFIG_COMBINE
|
||||||
add_dlg_checkbox(dlg, _("Combining characters", term), &values[TERM_OPT_COMBINE].number);
|
add_dlg_checkbox(dlg, _("Combining characters", term), &values[TERM_OPT_COMBINE].number);
|
||||||
#endif
|
#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);
|
add_dlg_button(dlg, _("~OK", term), B_ENTER, push_ok_button, NULL);
|
||||||
if (!anonymous)
|
if (!anonymous)
|
||||||
add_dlg_button(dlg, _("Sa~ve", term), B_ENTER, push_save_button, NULL);
|
add_dlg_button(dlg, _("Sa~ve", term), B_ENTER, push_save_button, NULL);
|
||||||
|
|
|
@ -270,6 +270,10 @@ struct screen_driver_opt {
|
||||||
/* Whether use terminfo. */
|
/* Whether use terminfo. */
|
||||||
unsigned int terminfo:1;
|
unsigned int terminfo:1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
unsigned int sixel:1;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Used in @c add_char*() and @c redraw_screen() to reduce the logic.
|
/** 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
|
#ifdef CONFIG_TERMINFO
|
||||||
/* terminfo */ 0,
|
/* terminfo */ 0,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
/* sixel */ 0,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default options for ::TERM_VT100. */
|
/** Default options for ::TERM_VT100. */
|
||||||
|
@ -335,6 +342,9 @@ static const struct screen_driver_opt vt100_screen_driver_opt = {
|
||||||
#ifdef CONFIG_TERMINFO
|
#ifdef CONFIG_TERMINFO
|
||||||
/* terminfo */ 0,
|
/* terminfo */ 0,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
/* sixel */ 0,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default options for ::TERM_LINUX. */
|
/** Default options for ::TERM_LINUX. */
|
||||||
|
@ -358,6 +368,9 @@ static const struct screen_driver_opt linux_screen_driver_opt = {
|
||||||
#ifdef CONFIG_TERMINFO
|
#ifdef CONFIG_TERMINFO
|
||||||
/* terminfo */ 0,
|
/* terminfo */ 0,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
/* sixel */ 0,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default options for ::TERM_KOI8. */
|
/** Default options for ::TERM_KOI8. */
|
||||||
|
@ -381,6 +394,9 @@ static const struct screen_driver_opt koi8_screen_driver_opt = {
|
||||||
#ifdef CONFIG_TERMINFO
|
#ifdef CONFIG_TERMINFO
|
||||||
/* terminfo */ 0,
|
/* terminfo */ 0,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
/* sixel */ 0,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default options for ::TERM_FREEBSD. */
|
/** Default options for ::TERM_FREEBSD. */
|
||||||
|
@ -404,6 +420,9 @@ static const struct screen_driver_opt freebsd_screen_driver_opt = {
|
||||||
#ifdef CONFIG_TERMINFO
|
#ifdef CONFIG_TERMINFO
|
||||||
/* terminfo */ 0,
|
/* terminfo */ 0,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
/* sixel */ 0,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default options for ::TERM_FBTERM. */
|
/** Default options for ::TERM_FBTERM. */
|
||||||
|
@ -427,6 +446,9 @@ static const struct screen_driver_opt fbterm_screen_driver_opt = {
|
||||||
#ifdef CONFIG_TERMINFO
|
#ifdef CONFIG_TERMINFO
|
||||||
/* terminfo */ 0,
|
/* terminfo */ 0,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
/* sixel */ 0,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Default options for all the different types of terminals.
|
/** 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
|
#ifdef CONFIG_COMBINE
|
||||||
driver->opt.combine = get_opt_bool_tree(term_spec, "combine", NULL);
|
driver->opt.combine = get_opt_bool_tree(term_spec, "combine", NULL);
|
||||||
#endif /* CONFIG_COMBINE */
|
#endif /* CONFIG_COMBINE */
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
driver->opt.sixel = get_opt_bool_tree(term_spec, "sixel", NULL);
|
||||||
|
#endif /* CONFIG_LIBSIXEL */
|
||||||
|
|
||||||
#ifdef CONFIG_UTF8
|
#ifdef CONFIG_UTF8
|
||||||
/* Force UTF-8 I/O if the UTF-8 charset is selected. Various
|
/* Force UTF-8 I/O if the UTF-8 charset is selected. Various
|
||||||
* places assume that the terminal's charset is unibyte if
|
* places assume that the terminal's charset is unibyte if
|
||||||
|
@ -1394,7 +1421,9 @@ redraw_screen(struct terminal *term)
|
||||||
if (!init_string(&image)) return;
|
if (!init_string(&image)) return;
|
||||||
|
|
||||||
#ifdef CONFIG_LIBSIXEL
|
#ifdef CONFIG_LIBSIXEL
|
||||||
try_to_draw_images(term);
|
if (driver->opt.sixel) {
|
||||||
|
try_to_draw_images(term);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
switch (driver->opt.color_mode) {
|
switch (driver->opt.color_mode) {
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -759,6 +759,10 @@ try_to_draw_images(struct terminal *term)
|
||||||
{
|
{
|
||||||
struct image *im;
|
struct image *im;
|
||||||
|
|
||||||
|
if (!term->sixel) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (im, term->images) {
|
foreach (im, term->images) {
|
||||||
struct string text;
|
struct string text;
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,7 @@ init_term(int fdin, int fdout)
|
||||||
|
|
||||||
#ifdef CONFIG_LIBSIXEL
|
#ifdef CONFIG_LIBSIXEL
|
||||||
init_list(term->images);
|
init_list(term->images);
|
||||||
|
term->sixel = 1;
|
||||||
#endif
|
#endif
|
||||||
term->fdin = fdin;
|
term->fdin = fdin;
|
||||||
term->fdout = fdout;
|
term->fdout = fdout;
|
||||||
|
|
|
@ -151,6 +151,9 @@ struct terminal {
|
||||||
unsigned int utf8_io:1;
|
unsigned int utf8_io:1;
|
||||||
#endif /* CONFIG_UTF8 */
|
#endif /* CONFIG_UTF8 */
|
||||||
|
|
||||||
|
#ifdef CONFIG_LIBSIXEL
|
||||||
|
unsigned int sixel:1;
|
||||||
|
#endif
|
||||||
/** The current tab number. */
|
/** The current tab number. */
|
||||||
int current_tab;
|
int current_tab;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user