mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Beginnings of terminfo support.
--with-terminfo must be added for configure and --terminfo to command line. terminfo is only used for output and not all sequences are changed.
This commit is contained in:
parent
9175f8ed39
commit
c4cb7ed8e5
@ -170,6 +170,7 @@ CONFIG_SMB = @CONFIG_SMB@
|
||||
CONFIG_SPIDERMONKEY = @CONFIG_SPIDERMONKEY@
|
||||
CONFIG_SSL = @CONFIG_SSL@
|
||||
CONFIG_SYSMOUSE = @CONFIG_SYSMOUSE@
|
||||
CONFIG_TERMINFO = @CONFIG_TERMINFO@
|
||||
CONFIG_TRUE_COLOR = @CONFIG_TRUE_COLOR@
|
||||
CONFIG_URI_REWRITE = @CONFIG_URI_REWRITE@
|
||||
CONFIG_UTF8 = @CONFIG_UTF8@
|
||||
|
@ -477,6 +477,10 @@ AC_DEFUN([EL_CONFIG_OPTIONAL_LIBRARY],
|
||||
EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_GPM, gpm, gpm.h, gpm, Gpm_Open,
|
||||
[ --without-gpm disable gpm (mouse) support])
|
||||
|
||||
|
||||
EL_CONFIG_OPTIONAL_LIBRARY(CONFIG_TERMINFO, terminfo, term.h, ncurses, setupterm,
|
||||
[ --with-terminfo enable terminfo support])
|
||||
|
||||
# ELinks calls deflateInit2 with windowBits = MAX_WBITS | 32, to
|
||||
# enable automatic decoding of both zlib and gzip headers. This
|
||||
# feature was added in zlib 1.2.0.2; earlier versions return an error.
|
||||
|
@ -932,6 +932,11 @@ union option_info cmdline_options_info[] = {
|
||||
|
||||
INIT_OPT_COMMAND("", NULL, "stdin", OPT_HIDDEN, redir_cmd, NULL),
|
||||
|
||||
INIT_OPT_BOOL("", N_("Whether to use terminfo"),
|
||||
"terminfo", 0, 0,
|
||||
N_("When enabled, terminfo ncurses functions will be used "
|
||||
"instead of hardcoded sequences.")),
|
||||
|
||||
INIT_OPT_BOOL("", N_("Touch files in ~/.elinks when running with -no-connect/-session-ring"),
|
||||
"touch-files", 0, 0,
|
||||
N_("When enabled, runtime state files (bookmarks, history, "
|
||||
|
@ -157,6 +157,9 @@ get_dyn_full_version(struct terminal *term, int more)
|
||||
#endif
|
||||
#ifdef CONFIG_LIBEVENT
|
||||
comma, (event_enabled ? _("libevent", term) : _("libevent (disabled)", term)),
|
||||
#endif
|
||||
#ifdef CONFIG_TERMINFO
|
||||
comma, (get_cmd_opt_bool("terminfo") ? _("terminfo", term) : _("terminfo (disabled)", term)),
|
||||
#endif
|
||||
comma,
|
||||
(unsigned char *) NULL
|
||||
|
@ -2,6 +2,7 @@ top_builddir=../..
|
||||
include $(top_builddir)/Makefile.config
|
||||
|
||||
OBJS-$(CONFIG_MOUSE) += mouse.o
|
||||
OBJS-$(CONFIG_TERMINFO) += terminfo.o
|
||||
|
||||
OBJS = \
|
||||
color.o \
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include "terminal/kbd.h"
|
||||
#include "terminal/screen.h"
|
||||
#include "terminal/terminal.h"
|
||||
#ifdef CONFIG_TERMINFO
|
||||
#include "terminal/terminfo.h"
|
||||
#endif
|
||||
#include "util/conv.h"
|
||||
#include "util/error.h"
|
||||
#include "util/memory.h"
|
||||
@ -246,6 +249,11 @@ struct screen_driver_opt {
|
||||
/* Whether the terminal supports combining characters. */
|
||||
unsigned int combine:1;
|
||||
#endif /* CONFIG_COMBINE */
|
||||
|
||||
#ifdef CONFIG_TERMINFO
|
||||
/* Whether use terminfo. */
|
||||
unsigned int terminfo:1;
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Used in @c add_char*() and @c redraw_screen() to reduce the logic.
|
||||
@ -285,6 +293,9 @@ static const struct screen_driver_opt dumb_screen_driver_opt = {
|
||||
#ifdef CONFIG_COMBINE
|
||||
/* combine */ 0,
|
||||
#endif /* CONFIG_COMBINE */
|
||||
#ifdef CONFIG_TERMINFO
|
||||
/* terminfo */ 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Default options for ::TERM_VT100. */
|
||||
@ -305,6 +316,9 @@ static const struct screen_driver_opt vt100_screen_driver_opt = {
|
||||
#ifdef CONFIG_COMBINE
|
||||
/* combine */ 0,
|
||||
#endif /* CONFIG_COMBINE */
|
||||
#ifdef CONFIG_TERMINFO
|
||||
/* terminfo */ 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Default options for ::TERM_LINUX. */
|
||||
@ -325,6 +339,9 @@ static const struct screen_driver_opt linux_screen_driver_opt = {
|
||||
#ifdef CONFIG_COMBINE
|
||||
/* combine */ 0,
|
||||
#endif /* CONFIG_COMBINE */
|
||||
#ifdef CONFIG_TERMINFO
|
||||
/* terminfo */ 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Default options for ::TERM_KOI8. */
|
||||
@ -345,6 +362,9 @@ static const struct screen_driver_opt koi8_screen_driver_opt = {
|
||||
#ifdef CONFIG_COMBINE
|
||||
/* combine */ 0,
|
||||
#endif /* CONFIG_COMBINE */
|
||||
#ifdef CONFIG_TERMINFO
|
||||
/* terminfo */ 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Default options for ::TERM_FREEBSD. */
|
||||
@ -365,6 +385,9 @@ static const struct screen_driver_opt freebsd_screen_driver_opt = {
|
||||
#ifdef CONFIG_COMBINE
|
||||
/* combine */ 0,
|
||||
#endif /* CONFIG_COMBINE */
|
||||
#ifdef CONFIG_TERMINFO
|
||||
/* terminfo */ 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Default options for ::TERM_FBTERM. */
|
||||
@ -385,6 +408,9 @@ static const struct screen_driver_opt fbterm_screen_driver_opt = {
|
||||
#ifdef CONFIG_COMBINE
|
||||
/* combine */ 0,
|
||||
#endif /* CONFIG_COMBINE */
|
||||
#ifdef CONFIG_TERMINFO
|
||||
/* terminfo */ 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
/** Default options for all the different types of terminals.
|
||||
@ -502,6 +528,9 @@ set_screen_driver_opt(struct screen_driver *driver, struct option *term_spec)
|
||||
driver->opt.frame = frame_vt100;
|
||||
}
|
||||
} /* !utf8_io */
|
||||
#ifdef CONFIG_TERMINFO
|
||||
driver->opt.terminfo = get_cmd_opt_bool("terminfo");
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
@ -806,8 +835,15 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
||||
italic != state->italic && driver->opt.italic
|
||||
) {
|
||||
state->italic = italic;
|
||||
#ifdef CONFIG_TERMINFO
|
||||
if (driver->opt.terminfo) {
|
||||
add_to_string(screen, terminfo_set_italics(italic));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_term_string(screen, driver->opt.italic[!!italic]);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
#ifdef CONFIG_UTF8
|
||||
@ -816,8 +852,15 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
||||
underline != state->underline && driver->opt.underline
|
||||
) {
|
||||
state->underline = underline;
|
||||
#ifdef CONFIG_TERMINFO
|
||||
if (driver->opt.terminfo) {
|
||||
add_to_string(screen, terminfo_set_underline(underline));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_term_string(screen, driver->opt.underline[!!underline]);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
#ifdef CONFIG_UTF8
|
||||
@ -827,7 +870,14 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
||||
) {
|
||||
state->bold = bold;
|
||||
if (bold) {
|
||||
#ifdef CONFIG_TERMINFO
|
||||
if (driver->opt.terminfo) {
|
||||
add_to_string(screen, terminfo_set_bold(bold));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_bytes_to_string(screen, "\033[1m", 4);
|
||||
}
|
||||
} else {
|
||||
/* Force repainting of the other attributes. */
|
||||
state->color[0] = ch->c.color[0] + 1;
|
||||
@ -842,6 +892,21 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
||||
) {
|
||||
copy_color_16(state->color, ch->c.color);
|
||||
|
||||
#ifdef CONFIG_TERMINFO
|
||||
if (driver->opt.terminfo) {
|
||||
add_to_string(screen, terminfo_set_bold(bold));
|
||||
add_to_string(screen, terminfo_set_foreground(TERM_COLOR_FOREGROUND_16(ch->c.color)));
|
||||
add_to_string(screen, terminfo_set_background(TERM_COLOR_BACKGROUND_16(ch->c.color)));
|
||||
|
||||
if (italic)
|
||||
add_to_string(screen, terminfo_set_italics(italic));
|
||||
|
||||
if (underline)
|
||||
add_to_string(screen, terminfo_set_underline(underline));
|
||||
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_bytes_to_string(screen, "\033[0", 3);
|
||||
|
||||
/* @set_screen_driver_opt has set @driver->opt.color_mode
|
||||
@ -886,6 +951,7 @@ add_char16(struct string *screen, struct screen_driver *driver,
|
||||
|
||||
add_bytes_to_string(screen, "m", 1);
|
||||
}
|
||||
}
|
||||
|
||||
add_char_data(screen, driver, ch->data, border);
|
||||
}
|
||||
@ -961,17 +1027,38 @@ add_char256(struct string *screen, struct screen_driver *driver,
|
||||
|
||||
if ((attr_delta & SCREEN_ATTR_ITALIC) && driver->opt.italic) {
|
||||
state->italic = !!(ch->attr & SCREEN_ATTR_ITALIC);
|
||||
#ifdef CONFIG_TERMINFO
|
||||
if (driver->opt.terminfo) {
|
||||
add_to_string(screen, terminfo_set_italics(state->italic));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_term_string(screen, driver->opt.italic[state->italic]);
|
||||
}
|
||||
}
|
||||
|
||||
if ((attr_delta & SCREEN_ATTR_UNDERLINE) && driver->opt.underline) {
|
||||
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||
#ifdef CONFIG_TERMINFO
|
||||
if (driver->opt.terminfo) {
|
||||
add_to_string(screen, terminfo_set_underline(state->underline));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_term_string(screen, driver->opt.underline[state->underline]);
|
||||
}
|
||||
}
|
||||
|
||||
if (attr_delta & SCREEN_ATTR_BOLD) {
|
||||
if (ch->attr & SCREEN_ATTR_BOLD) {
|
||||
#ifdef CONFIG_TERMINFO
|
||||
if (driver->opt.terminfo) {
|
||||
add_to_string(screen, terminfo_set_bold(1));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_bytes_to_string(screen, "\033[1m", 4);
|
||||
}
|
||||
} else {
|
||||
/* Force repainting of the other attributes. */
|
||||
state->color[0] = ch->c.color[0] + 1;
|
||||
@ -988,7 +1075,24 @@ add_char256(struct string *screen, struct screen_driver *driver,
|
||||
!compare_color_256(ch->c.color, state->color)
|
||||
) {
|
||||
copy_color_256(state->color, ch->c.color);
|
||||
#ifdef CONFIG_TERMINFO
|
||||
if (driver->opt.terminfo) {
|
||||
add_to_string(screen, terminfo_set_bold(ch->attr & SCREEN_ATTR_BOLD));
|
||||
add_to_string(screen, terminfo_set_foreground(ch->c.color[0]));
|
||||
add_to_string(screen, terminfo_set_background(ch->c.color[1]));
|
||||
|
||||
if (ch->attr & SCREEN_ATTR_ITALIC && driver->opt.italic) {
|
||||
state->italic = !!(ch->attr & SCREEN_ATTR_ITALIC);
|
||||
add_to_string(screen, terminfo_set_italics(state->italic));
|
||||
}
|
||||
|
||||
if (ch->attr & SCREEN_ATTR_UNDERLINE && driver->opt.underline) {
|
||||
state->underline = !!(ch->attr & SCREEN_ATTR_UNDERLINE);
|
||||
add_to_string(screen, terminfo_set_underline(state->underline));
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
add_foreground_color(screen, driver->opt.color256_seqs, ch);
|
||||
if (!driver->opt.transparent || ch->c.color[1] != 0) {
|
||||
add_background_color(screen, driver->opt.color256_seqs, ch);
|
||||
@ -1007,6 +1111,7 @@ add_char256(struct string *screen, struct screen_driver *driver,
|
||||
add_term_string(screen, driver->opt.underline[state->underline]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_char_data(screen, driver, ch->data, ch->attr & SCREEN_ATTR_FRAME);
|
||||
}
|
||||
|
@ -33,6 +33,9 @@
|
||||
#include "terminal/kbd.h"
|
||||
#include "terminal/screen.h"
|
||||
#include "terminal/terminal.h"
|
||||
#ifdef CONFIG_TERMINFO
|
||||
#include "terminal/terminfo.h"
|
||||
#endif
|
||||
#include "terminal/window.h"
|
||||
#include "util/error.h"
|
||||
#include "util/memory.h"
|
||||
@ -101,6 +104,9 @@ init_term(int fdin, int fdout)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TERMINFO
|
||||
terminfo_setupterm(NULL, fdout);
|
||||
#endif
|
||||
init_list(term->windows);
|
||||
|
||||
term->fdin = fdin;
|
||||
|
Loading…
Reference in New Issue
Block a user