mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Add support for ECMA-48 SGR italic
Add 'Italic' checkbox to Terminal options dialog box. Enable italic text by default for rxvt-unicode (and also enable frames, 88-colour mode, and underline).
This commit is contained in:
parent
d6116ca83a
commit
3334efb32c
@ -761,6 +761,14 @@ register_autocreated_options(void)
|
|||||||
get_opt_int("terminal.xterm-88color.colors", NULL) = COLOR_MODE_88;
|
get_opt_int("terminal.xterm-88color.colors", NULL) = COLOR_MODE_88;
|
||||||
get_opt_bool("terminal.xterm-88color.underline", NULL) = 1;
|
get_opt_bool("terminal.xterm-88color.underline", NULL) = 1;
|
||||||
#endif
|
#endif
|
||||||
|
get_opt_int("terminal.rxvt-unicode.type", NULL) = 1;
|
||||||
|
#ifdef CONFIG_88_COLORS
|
||||||
|
get_opt_int("terminal.rxvt-unicode.colors", NULL) = COLOR_MODE_88;
|
||||||
|
#else
|
||||||
|
get_opt_int("terminal.rxvt-unicode.colors", NULL) = COLOR_MODE_16;
|
||||||
|
#endif
|
||||||
|
get_opt_bool("terminal.rxvt-unicode.italic", NULL) = 1;
|
||||||
|
get_opt_bool("terminal.rxvt-unicode.underline", NULL) = 1;
|
||||||
#ifdef CONFIG_256_COLORS
|
#ifdef CONFIG_256_COLORS
|
||||||
get_opt_int("terminal.xterm-256color.type", NULL) = TERM_VT100;
|
get_opt_int("terminal.xterm-256color.type", NULL) = TERM_VT100;
|
||||||
get_opt_int("terminal.xterm-256color.colors", NULL) = COLOR_MODE_256;
|
get_opt_int("terminal.xterm-256color.colors", NULL) = COLOR_MODE_256;
|
||||||
|
@ -981,6 +981,10 @@ static struct option_info config_options_info[] = {
|
|||||||
"Note that this option makes sense only when colors are "
|
"Note that this option makes sense only when colors are "
|
||||||
"enabled.")),
|
"enabled.")),
|
||||||
|
|
||||||
|
INIT_OPT_BOOL("terminal._template_", N_("Italic"),
|
||||||
|
"italic", 0, 0,
|
||||||
|
N_("If we should use italics.")),
|
||||||
|
|
||||||
INIT_OPT_BOOL("terminal._template_", N_("Underline"),
|
INIT_OPT_BOOL("terminal._template_", N_("Underline"),
|
||||||
"underline", 0, 0,
|
"underline", 0, 0,
|
||||||
N_("If we should use underline or enhance the color "
|
N_("If we should use underline or enhance the color "
|
||||||
|
@ -91,6 +91,7 @@ enum termopt {
|
|||||||
TERM_OPT_UTF_8_IO,
|
TERM_OPT_UTF_8_IO,
|
||||||
TERM_OPT_TRANSPARENCY,
|
TERM_OPT_TRANSPARENCY,
|
||||||
TERM_OPT_UNDERLINE,
|
TERM_OPT_UNDERLINE,
|
||||||
|
TERM_OPT_ITALIC,
|
||||||
#ifdef CONFIG_COMBINE
|
#ifdef CONFIG_COMBINE
|
||||||
TERM_OPT_COMBINE,
|
TERM_OPT_COMBINE,
|
||||||
#endif
|
#endif
|
||||||
@ -107,6 +108,7 @@ static struct option_resolver resolvers[] = {
|
|||||||
{ TERM_OPT_TRANSPARENCY, "transparency" },
|
{ TERM_OPT_TRANSPARENCY, "transparency" },
|
||||||
{ TERM_OPT_UTF_8_IO, "utf_8_io" },
|
{ TERM_OPT_UTF_8_IO, "utf_8_io" },
|
||||||
{ TERM_OPT_UNDERLINE, "underline" },
|
{ TERM_OPT_UNDERLINE, "underline" },
|
||||||
|
{ TERM_OPT_ITALIC, "italic" },
|
||||||
#ifdef CONFIG_COMBINE
|
#ifdef CONFIG_COMBINE
|
||||||
{ TERM_OPT_COMBINE, "combine" },
|
{ TERM_OPT_COMBINE, "combine" },
|
||||||
#endif
|
#endif
|
||||||
@ -228,6 +230,7 @@ terminal_options(struct terminal *term, void *xxx, struct session *ses)
|
|||||||
add_dlg_checkbox(dlg, _("Switch fonts for line drawing", term), &values[TERM_OPT_M11_HACK].number);
|
add_dlg_checkbox(dlg, _("Switch fonts for line drawing", term), &values[TERM_OPT_M11_HACK].number);
|
||||||
add_dlg_checkbox(dlg, _("Restrict frames in cp850/852", term), &values[TERM_OPT_RESTRICT_852].number);
|
add_dlg_checkbox(dlg, _("Restrict frames in cp850/852", term), &values[TERM_OPT_RESTRICT_852].number);
|
||||||
add_dlg_checkbox(dlg, _("Block cursor", term), &values[TERM_OPT_BLOCK_CURSOR].number);
|
add_dlg_checkbox(dlg, _("Block cursor", term), &values[TERM_OPT_BLOCK_CURSOR].number);
|
||||||
|
add_dlg_checkbox(dlg, _("Italic", term), &values[TERM_OPT_ITALIC].number);
|
||||||
add_dlg_checkbox(dlg, _("Transparency", term), &values[TERM_OPT_TRANSPARENCY].number);
|
add_dlg_checkbox(dlg, _("Transparency", term), &values[TERM_OPT_TRANSPARENCY].number);
|
||||||
add_dlg_checkbox(dlg, _("Underline", term), &values[TERM_OPT_UNDERLINE].number);
|
add_dlg_checkbox(dlg, _("Underline", term), &values[TERM_OPT_UNDERLINE].number);
|
||||||
add_dlg_checkbox(dlg, _("UTF-8 I/O", term), &values[TERM_OPT_UTF_8_IO].number);
|
add_dlg_checkbox(dlg, _("UTF-8 I/O", term), &values[TERM_OPT_UTF_8_IO].number);
|
||||||
|
@ -174,6 +174,16 @@ static const struct string vt100_frame_seqs[] = {
|
|||||||
/* begin border: */ TERM_STRING("\x0e"),
|
/* begin border: */ TERM_STRING("\x0e"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Italic begin/end sequences using ECMA-48 SGR.
|
||||||
|
* ECMA-48: CSI Ps... 06/13 = SGR - SELECT GRAPHIC RENDITION
|
||||||
|
* - Ps = 3 = italicized
|
||||||
|
* - Ps = 20 = Fraktur (Gothic)
|
||||||
|
* - Ps = 23 = not italicized, not fraktur */
|
||||||
|
static const struct string italic_seqs[] = {
|
||||||
|
/* end italics: */ TERM_STRING("\033[23m"),
|
||||||
|
/* begin italics: */ TERM_STRING("\033[3m"),
|
||||||
|
};
|
||||||
|
|
||||||
/** Underline begin/end sequences using ECMA-48 SGR.
|
/** Underline begin/end sequences using ECMA-48 SGR.
|
||||||
* ECMA-48: CSI Ps... 06/13 = SGR - SELECT GRAPHIC RENDITION
|
* ECMA-48: CSI Ps... 06/13 = SGR - SELECT GRAPHIC RENDITION
|
||||||
* - Ps = 4 = singly underlined
|
* - Ps = 4 = singly underlined
|
||||||
@ -223,6 +233,9 @@ struct screen_driver {
|
|||||||
/** The frame mode setup and teardown sequences. May be NULL. */
|
/** The frame mode setup and teardown sequences. May be NULL. */
|
||||||
const struct string *frame_seqs;
|
const struct string *frame_seqs;
|
||||||
|
|
||||||
|
/** The italic mode setup and teardown sequences. May be NULL. */
|
||||||
|
const struct string *italic;
|
||||||
|
|
||||||
/** The underline mode setup and teardown sequences. May be NULL. */
|
/** The underline mode setup and teardown sequences. May be NULL. */
|
||||||
const struct string *underline;
|
const struct string *underline;
|
||||||
|
|
||||||
@ -257,6 +270,7 @@ static const struct screen_driver_opt dumb_screen_driver_opt = {
|
|||||||
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
||||||
/* frame: */ frame_dumb,
|
/* frame: */ frame_dumb,
|
||||||
/* frame_seqs: */ NULL,
|
/* frame_seqs: */ NULL,
|
||||||
|
/* italic: */ italic_seqs,
|
||||||
/* underline: */ underline_seqs,
|
/* underline: */ underline_seqs,
|
||||||
/* color_mode: */ COLOR_MODE_16,
|
/* color_mode: */ COLOR_MODE_16,
|
||||||
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
@ -276,6 +290,7 @@ static const struct screen_driver_opt vt100_screen_driver_opt = {
|
|||||||
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
||||||
/* frame: */ frame_vt100,
|
/* frame: */ frame_vt100,
|
||||||
/* frame_seqs: */ vt100_frame_seqs,
|
/* frame_seqs: */ vt100_frame_seqs,
|
||||||
|
/* italic: */ italic_seqs,
|
||||||
/* underline: */ underline_seqs,
|
/* underline: */ underline_seqs,
|
||||||
/* color_mode: */ COLOR_MODE_16,
|
/* color_mode: */ COLOR_MODE_16,
|
||||||
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
@ -295,6 +310,7 @@ static const struct screen_driver_opt linux_screen_driver_opt = {
|
|||||||
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
||||||
/* frame: */ NULL, /* No restrict_852 */
|
/* frame: */ NULL, /* No restrict_852 */
|
||||||
/* frame_seqs: */ NULL, /* No m11_hack */
|
/* frame_seqs: */ NULL, /* No m11_hack */
|
||||||
|
/* italic: */ italic_seqs,
|
||||||
/* underline: */ underline_seqs,
|
/* underline: */ underline_seqs,
|
||||||
/* color_mode: */ COLOR_MODE_16,
|
/* color_mode: */ COLOR_MODE_16,
|
||||||
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
@ -314,6 +330,7 @@ static const struct screen_driver_opt koi8_screen_driver_opt = {
|
|||||||
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
||||||
/* frame: */ frame_koi,
|
/* frame: */ frame_koi,
|
||||||
/* frame_seqs: */ NULL,
|
/* frame_seqs: */ NULL,
|
||||||
|
/* italic: */ italic_seqs,
|
||||||
/* underline: */ underline_seqs,
|
/* underline: */ underline_seqs,
|
||||||
/* color_mode: */ COLOR_MODE_16,
|
/* color_mode: */ COLOR_MODE_16,
|
||||||
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
@ -333,6 +350,7 @@ static const struct screen_driver_opt freebsd_screen_driver_opt = {
|
|||||||
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
/* charsets: */ { -1, -1 }, /* No UTF8 I/O */
|
||||||
/* frame: */ frame_freebsd,
|
/* frame: */ frame_freebsd,
|
||||||
/* frame_seqs: */ NULL, /* No m11_hack */
|
/* frame_seqs: */ NULL, /* No m11_hack */
|
||||||
|
/* italic: */ italic_seqs,
|
||||||
/* underline: */ underline_seqs,
|
/* underline: */ underline_seqs,
|
||||||
/* color_mode: */ COLOR_MODE_16,
|
/* color_mode: */ COLOR_MODE_16,
|
||||||
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
#if defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
@ -415,6 +433,12 @@ set_screen_driver_opt(struct screen_driver *driver, struct option *term_spec)
|
|||||||
driver->opt.transparent = get_opt_bool_tree(term_spec, "transparency",
|
driver->opt.transparent = get_opt_bool_tree(term_spec, "transparency",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
if (get_opt_bool_tree(term_spec, "italic", NULL)) {
|
||||||
|
driver->opt.italic = italic_seqs;
|
||||||
|
} else {
|
||||||
|
driver->opt.italic = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (get_opt_bool_tree(term_spec, "underline", NULL)) {
|
if (get_opt_bool_tree(term_spec, "underline", NULL)) {
|
||||||
driver->opt.underline = underline_seqs;
|
driver->opt.underline = underline_seqs;
|
||||||
} else {
|
} else {
|
||||||
@ -580,6 +604,7 @@ add_cursor_move_to_string(struct string *screen, int y, int x)
|
|||||||
|
|
||||||
struct screen_state {
|
struct screen_state {
|
||||||
unsigned char border;
|
unsigned char border;
|
||||||
|
unsigned char italic;
|
||||||
unsigned char underline;
|
unsigned char underline;
|
||||||
unsigned char bold;
|
unsigned char bold;
|
||||||
unsigned char attr;
|
unsigned char attr;
|
||||||
@ -588,11 +613,11 @@ struct screen_state {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if defined(CONFIG_TRUE_COLOR)
|
#if defined(CONFIG_TRUE_COLOR)
|
||||||
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} }
|
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} }
|
||||||
#elif defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
#elif defined(CONFIG_88_COLORS) || defined(CONFIG_256_COLORS)
|
||||||
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF } }
|
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0xFF, 0, { 0xFF, 0xFF } }
|
||||||
#else
|
#else
|
||||||
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0, { 0xFF } }
|
#define INIT_SCREEN_STATE { 0xFF, 0xFF, 0xFF, 0xFF, 0, { 0xFF } }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_TRUE_COLOR
|
#ifdef CONFIG_TRUE_COLOR
|
||||||
@ -757,6 +782,7 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
|||||||
struct screen_char *ch, struct screen_state *state)
|
struct screen_char *ch, struct screen_state *state)
|
||||||
{
|
{
|
||||||
unsigned char border = (ch->attr & SCREEN_ATTR_FRAME);
|
unsigned char border = (ch->attr & SCREEN_ATTR_FRAME);
|
||||||
|
unsigned char italic = (ch->attr & SCREEN_ATTR_ITALIC);
|
||||||
unsigned char underline = (ch->attr & SCREEN_ATTR_UNDERLINE);
|
unsigned char underline = (ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||||
unsigned char bold = (ch->attr & SCREEN_ATTR_BOLD);
|
unsigned char bold = (ch->attr & SCREEN_ATTR_BOLD);
|
||||||
|
|
||||||
@ -770,6 +796,16 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
|||||||
add_term_string(screen, driver->opt.frame_seqs[!!border]);
|
add_term_string(screen, driver->opt.frame_seqs[!!border]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
#ifdef CONFIG_UTF8
|
||||||
|
!(driver->opt.utf8_cp && ch->data == UCS_NO_CHAR) &&
|
||||||
|
#endif /* CONFIG_UTF8 */
|
||||||
|
italic != state->italic && driver->opt.italic
|
||||||
|
) {
|
||||||
|
state->italic = italic;
|
||||||
|
add_term_string(screen, driver->opt.italic[!!italic]);
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
#ifdef CONFIG_UTF8
|
#ifdef CONFIG_UTF8
|
||||||
!(driver->opt.utf8_cp && ch->data == UCS_NO_CHAR) &&
|
!(driver->opt.utf8_cp && ch->data == UCS_NO_CHAR) &&
|
||||||
@ -832,6 +868,10 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
|||||||
add_bytes_to_string(screen, ";7", 2);
|
add_bytes_to_string(screen, ";7", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (italic && driver->opt.italic) {
|
||||||
|
add_bytes_to_string(screen, ";3", 2);
|
||||||
|
}
|
||||||
|
|
||||||
if (underline && driver->opt.underline) {
|
if (underline && driver->opt.underline) {
|
||||||
add_bytes_to_string(screen, ";4", 2);
|
add_bytes_to_string(screen, ";4", 2);
|
||||||
}
|
}
|
||||||
@ -916,6 +956,11 @@ add_char256(struct string *screen, struct screen_driver *driver,
|
|||||||
add_term_string(screen, driver->opt.frame_seqs[state->border]);
|
add_term_string(screen, driver->opt.frame_seqs[state->border]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((attr_delta & SCREEN_ATTR_ITALIC) && driver->opt.italic) {
|
||||||
|
state->italic = !!(ch->attr & SCREEN_ATTR_ITALIC);
|
||||||
|
add_term_string(screen, driver->opt.italic[state->italic]);
|
||||||
|
}
|
||||||
|
|
||||||
if ((attr_delta & SCREEN_ATTR_UNDERLINE) && driver->opt.underline) {
|
if ((attr_delta & SCREEN_ATTR_UNDERLINE) && driver->opt.underline) {
|
||||||
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||||
add_term_string(screen, driver->opt.underline[state->underline]);
|
add_term_string(screen, driver->opt.underline[state->underline]);
|
||||||
@ -949,6 +994,11 @@ add_char256(struct string *screen, struct screen_driver *driver,
|
|||||||
if (ch->attr & SCREEN_ATTR_BOLD)
|
if (ch->attr & SCREEN_ATTR_BOLD)
|
||||||
add_bytes_to_string(screen, "\033[1m", 4);
|
add_bytes_to_string(screen, "\033[1m", 4);
|
||||||
|
|
||||||
|
if (ch->attr & SCREEN_ATTR_ITALIC && driver->opt.italic) {
|
||||||
|
state->italic = !!(ch->attr & SCREEN_ATTR_ITALIC);
|
||||||
|
add_term_string(screen, driver->opt.italic[state->italic]);
|
||||||
|
}
|
||||||
|
|
||||||
if (ch->attr & SCREEN_ATTR_UNDERLINE && driver->opt.underline) {
|
if (ch->attr & SCREEN_ATTR_UNDERLINE && driver->opt.underline) {
|
||||||
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||||
add_term_string(screen, driver->opt.underline[state->underline]);
|
add_term_string(screen, driver->opt.underline[state->underline]);
|
||||||
@ -1031,6 +1081,11 @@ add_char_true(struct string *screen, struct screen_driver *driver,
|
|||||||
add_term_string(screen, driver->opt.frame_seqs[state->border]);
|
add_term_string(screen, driver->opt.frame_seqs[state->border]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((attr_delta & SCREEN_ATTR_ITALIC) && driver->opt.italic) {
|
||||||
|
state->italic = !!(ch->attr & SCREEN_ATTR_ITALIC);
|
||||||
|
add_term_string(screen, driver->opt.italic[state->italic]);
|
||||||
|
}
|
||||||
|
|
||||||
if ((attr_delta & SCREEN_ATTR_UNDERLINE) && driver->opt.underline) {
|
if ((attr_delta & SCREEN_ATTR_UNDERLINE) && driver->opt.underline) {
|
||||||
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||||
add_term_string(screen, driver->opt.underline[state->underline]);
|
add_term_string(screen, driver->opt.underline[state->underline]);
|
||||||
@ -1064,6 +1119,11 @@ add_char_true(struct string *screen, struct screen_driver *driver,
|
|||||||
if (ch->attr & SCREEN_ATTR_BOLD)
|
if (ch->attr & SCREEN_ATTR_BOLD)
|
||||||
add_bytes_to_string(screen, "\033[1m", 4);
|
add_bytes_to_string(screen, "\033[1m", 4);
|
||||||
|
|
||||||
|
if (ch->attr & SCREEN_ATTR_ITALIC && driver->opt.italic) {
|
||||||
|
state->italic = !!(ch->attr & SCREEN_ATTR_ITALIC);
|
||||||
|
add_term_string(screen, driver->opt.italic[state->italic]);
|
||||||
|
}
|
||||||
|
|
||||||
if (ch->attr & SCREEN_ATTR_UNDERLINE && driver->opt.underline) {
|
if (ch->attr & SCREEN_ATTR_UNDERLINE && driver->opt.underline) {
|
||||||
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||||
add_term_string(screen, driver->opt.underline[state->underline]);
|
add_term_string(screen, driver->opt.underline[state->underline]);
|
||||||
|
Loading…
Reference in New Issue
Block a user