Merge pull request #1557 from ailin-nemui/solarisvm

test solaris build with github/vmactions
This commit is contained in:
ailin-nemui 2025-04-14 13:07:23 +00:00 committed by GitHub
commit 5a9a9ababa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 283 additions and 158 deletions

104
.github/workflows/solarisvm.yml vendored Normal file
View File

@ -0,0 +1,104 @@
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
name: Check Irssi on Solaris
env:
get_pip_build_deps_meson: pip3 install setuptools${setuptools_ver}; pip3 install wheel
prefix: ~/irssi-build
jobs:
dist:
runs-on: ubuntu-latest
env:
setuptools_ver: <66
steps:
- name: prepare required software
run: |
sudo apt update && sudo apt install $apt_build_deps
eval "$get_pip_build_deps_meson"
patch ~/.local/lib/python3.12/site-packages/pkg_resources/__init__.py <<- PATCH
--- __init__.py 2024-12-16 20:37:46.733230351 +0100
+++ __init__.py 2024-12-16 20:38:42.479554540 +0100
@@ -2188,7 +2188,8 @@ def resolve_egg_link(path):
return next(dist_groups, ())
-register_finder(pkgutil.ImpImporter, find_on_path)
+if hasattr(pkgutil, 'ImpImporter'):
+ register_finder(pkgutil.ImpImporter, find_on_path)
if hasattr(importlib_machinery, 'FileFinder'):
register_finder(importlib_machinery.FileFinder, find_on_path)
@@ -2345,7 +2346,8 @@ def file_ns_handler(importer, path_item,
return subpath
-register_namespace_handler(pkgutil.ImpImporter, file_ns_handler)
+if hasattr(pkgutil, 'ImpImporter'):
+ register_namespace_handler(pkgutil.ImpImporter, file_ns_handler)
register_namespace_handler(zipimport.zipimporter, file_ns_handler)
if hasattr(importlib_machinery, 'FileFinder'):
PATCH
- uses: actions/checkout@main
- name: make dist
run: |
./utils/make-dist.sh
- uses: actions/upload-artifact@v4
with:
path: irssi-*.tar.gz
retention-days: 1
install:
runs-on: ubuntu-latest
needs: dist
steps:
- name: fetch dist
uses: actions/download-artifact@v4
- name: Test in Solaris
uses: vmactions/solaris-vm@v1
with:
usesh: true
sync: rsync
release: "11.4-gcc"
prepare: |
pkg update --accept
pkg install meson
pkgutil -y -i curl
pkgutil -y -i gtar
pkgutil -y -i findutils
run: |
set -ex
export PKG_CONFIG_PATH=/usr/lib/64/pkgconfig
curl -SLf https://github.com/irssi-import/actions-irssi/raw/master/check-irssi/render.pl -o ~/render.pl && chmod +x ~/render.pl
gtar xzf artifact/irssi-*.tar.gz
# ninja install
cd irssi-*/
meson Build -Dwith-proxy=yes -Dwith-bot=yes -Dwith-perl=yes --prefix=$HOME/irssi-build
ninja -C Build
ninja -C Build install
# ninja test
ninja -C Build test
gfind -name testlog.txt -exec gsed -i -e '/Inherited environment:.* GITHUB/d' {} + -exec cat {} +
export TERM=xterm
# automated irssi launch test
cd
mkdir irssi-test
echo 'echo automated irssi launch test
^set settings_autosave off
^set -clear log_close_string
^set -clear log_day_changed
^set -clear log_open_string
^set log_timestamp *
^window log on
load irc
load dcc
load flood
load notifylist
load perl
load otr
load proxy
^quit' > irssi-test/startup
irssi-build/bin/irssi --home irssi-test | perl -Mutf8 -C ~/render.pl
cat irc.log.*

View File

@ -569,6 +569,28 @@ foreach h : headers
endif endif
endforeach endforeach
if want_textui and conf.get('HAVE_TERM_H', 0) == 1
if not cc.links('''
#include <stdio.h>
#include <term.h>
int main () {
return tputs("x", 1, putchar);
}
''', dependencies : textui_dep)
if cc.has_header('curses.h') and cc.links('''
#include <curses.h>
#include <term.h>
int main () {
return tputs("x", 1, putchar);
}
''', dependencies : textui_dep, name : 'working Curses')
conf.set('NEED_CURSES_H', 1, description : 'tputs needs curses.h')
else
error('could not link terminfo')
endif
endif
endif
conf.set('HAVE_LIBUTF8PROC', have_libutf8proc) conf.set('HAVE_LIBUTF8PROC', have_libutf8proc)
conf.set_quoted('PACKAGE_VERSION', package_version) conf.set_quoted('PACKAGE_VERSION', package_version)
conf.set_quoted('PACKAGE_TARNAME', meson.project_name()) conf.set_quoted('PACKAGE_TARNAME', meson.project_name())

View File

@ -31,6 +31,9 @@
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_TERM_H #ifdef HAVE_TERM_H
#ifdef NEED_CURSES_H
#include <curses.h>
#endif
#include <term.h> #include <term.h>
#else #else
/* TODO: This needs arguments, starting with C2X. */ /* TODO: This needs arguments, starting with C2X. */
@ -40,14 +43,13 @@ int tputs();
/* returns number of characters in the beginning of the buffer being a /* returns number of characters in the beginning of the buffer being a
a single character, or -1 if more input is needed. The character will be a single character, or -1 if more input is needed. The character will be
saved in result */ saved in result */
typedef int (*TERM_INPUT_FUNC)(const unsigned char *buffer, int size, typedef int (*TERM_INPUT_FUNC)(const unsigned char *buffer, int size, unichar *result);
unichar *result);
struct _TERM_WINDOW { struct _TERM_WINDOW {
/* Terminal to use for window */ /* Terminal to use for window */
TERM_REC *term; TERM_REC *term;
/* Area for window in terminal */ /* Area for window in terminal */
int x, y; int x, y;
int width, height; int width, height;
}; };
@ -367,8 +369,8 @@ void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigne
if (!term_use_colors && bg > 0) if (!term_use_colors && bg > 0)
col |= ATTR_REVERSE; col |= ATTR_REVERSE;
set_normal = ((col & ATTR_RESETFG) && last_fg != COLOR_RESET) || set_normal = ((col & ATTR_RESETFG) && last_fg != COLOR_RESET) ||
((col & ATTR_RESETBG) && last_bg != COLOR_RESET); ((col & ATTR_RESETBG) && last_bg != COLOR_RESET);
if (((last_attrs & ATTR_BOLD) && (col & ATTR_BOLD) == 0) || if (((last_attrs & ATTR_BOLD) && (col & ATTR_BOLD) == 0) ||
((last_attrs & ATTR_REVERSE) && (col & ATTR_REVERSE) == 0) || ((last_attrs & ATTR_REVERSE) && (col & ATTR_REVERSE) == 0) ||
((last_attrs & ATTR_BLINK) && (col & ATTR_BLINK) == 0)) { ((last_attrs & ATTR_BLINK) && (col & ATTR_BLINK) == 0)) {
@ -379,19 +381,17 @@ void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigne
if (set_normal) { if (set_normal) {
last_fg = last_bg = COLOR_RESET; last_fg = last_bg = COLOR_RESET;
last_attrs = 0; last_attrs = 0;
terminfo_set_normal(); terminfo_set_normal();
} }
/* set foreground color */ /* set foreground color */
if (fg != last_fg && if (fg != last_fg && (fg != 0 || (col & ATTR_RESETFG) == 0)) {
(fg != 0 || (col & ATTR_RESETFG) == 0)) { if (term_use_colors) {
if (term_use_colors) {
last_fg = fg; last_fg = fg;
if (fg >> 8) if (fg >> 8)
termctl_set_color_24bit(0, termctl_set_color_24bit(0, last_fg == COLOR_BLACK24 ? 0 :
last_fg == COLOR_BLACK24 ? 0 last_fg >> 8);
: last_fg >> 8);
else else
terminfo_set_fg(last_fg); terminfo_set_fg(last_fg);
} }
@ -399,19 +399,17 @@ void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigne
/* set background color */ /* set background color */
if (window && window->term->TI_colors && if (window && window->term->TI_colors &&
(term_color256map[bg&0xff]&8) == window->term->TI_colors) (term_color256map[bg & 0xff] & 8) == window->term->TI_colors)
col |= ATTR_BLINK; col |= ATTR_BLINK;
if (col & ATTR_BLINK) if (col & ATTR_BLINK)
current_term->set_blink(current_term); current_term->tr_set_blink(current_term);
if (bg != last_bg && if (bg != last_bg && (bg != 0 || (col & ATTR_RESETBG) == 0)) {
(bg != 0 || (col & ATTR_RESETBG) == 0)) { if (term_use_colors) {
if (term_use_colors) {
last_bg = bg; last_bg = bg;
if (bg >> 8) if (bg >> 8)
termctl_set_color_24bit(1, termctl_set_color_24bit(1, last_bg == COLOR_BLACK24 ? 0 :
last_bg == COLOR_BLACK24 ? 0 last_bg >> 8);
: last_bg >> 8);
else else
terminfo_set_bg(last_bg); terminfo_set_bg(last_bg);
} }
@ -423,7 +421,7 @@ void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigne
/* bold */ /* bold */
if (window && window->term->TI_colors && if (window && window->term->TI_colors &&
(term_color256map[fg&0xff]&8) == window->term->TI_colors) (term_color256map[fg & 0xff] & 8) == window->term->TI_colors)
col |= ATTR_BOLD; col |= ATTR_BOLD;
if (col & ATTR_BOLD) if (col & ATTR_BOLD)
terminfo_set_bold(); terminfo_set_bold();
@ -443,7 +441,7 @@ void term_set_color2(TERM_WINDOW *window, int col, unsigned int fgcol24, unsigne
terminfo_set_italic(FALSE); terminfo_set_italic(FALSE);
/* update the new attribute settings whilst ignoring color values. */ /* update the new attribute settings whilst ignoring color values. */
last_attrs = col & ~( BG_MASK | FG_MASK ); last_attrs = col & ~(BG_MASK | FG_MASK);
} }
void term_move(TERM_WINDOW *window, int x, int y) void term_move(TERM_WINDOW *window, int x, int y)

View File

@ -13,6 +13,9 @@ inline static int term_putchar(int c)
} }
#ifdef HAVE_TERM_H #ifdef HAVE_TERM_H
#ifdef NEED_CURSES_H
#include <curses.h>
#endif
#include <term.h> #include <term.h>
#else #else
/* Don't bother including curses.h because of these - /* Don't bother including curses.h because of these -
@ -169,20 +172,20 @@ static void _set_cursor_visible(TERM_REC *term, int set)
/* Scroll (change_scroll_region+parm_rindex+parm_index / csr+rin+indn) */ /* Scroll (change_scroll_region+parm_rindex+parm_index / csr+rin+indn) */
static void _scroll_region(TERM_REC *term, int y1, int y2, int count) static void _scroll_region(TERM_REC *term, int y1, int y2, int count)
{ {
/* setup the scrolling region to wanted area */ /* setup the scrolling region to wanted area */
scroll_region_setup(term, y1, y2); scroll_region_setup(term, y1, y2);
term->move(term, 0, y1); term->tr_move(term, 0, y1);
if (count > 0) { if (count > 0) {
term->move(term, 0, y2); term->tr_move(term, 0, y2);
tput(tparm(term->TI_indn, count, count, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_indn, count, count, 0, 0, 0, 0, 0, 0, 0));
} else if (count < 0) { } else if (count < 0) {
term->move(term, 0, y1); term->tr_move(term, 0, y1);
tput(tparm(term->TI_rin, -count, -count, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_rin, -count, -count, 0, 0, 0, 0, 0, 0, 0));
} }
/* reset the scrolling region to full screen */ /* reset the scrolling region to full screen */
scroll_region_setup(term, 0, term->height-1); scroll_region_setup(term, 0, term->height - 1);
} }
/* Scroll (change_scroll_region+scroll_reverse+scroll_forward / csr+ri+ind) */ /* Scroll (change_scroll_region+scroll_reverse+scroll_forward / csr+ri+ind) */
@ -190,21 +193,21 @@ static void _scroll_region_1(TERM_REC *term, int y1, int y2, int count)
{ {
int i; int i;
/* setup the scrolling region to wanted area */ /* setup the scrolling region to wanted area */
scroll_region_setup(term, y1, y2); scroll_region_setup(term, y1, y2);
if (count > 0) { if (count > 0) {
term->move(term, 0, y2); term->tr_move(term, 0, y2);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
tput(tparm(term->TI_ind, 0, 0, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_ind, 0, 0, 0, 0, 0, 0, 0, 0, 0));
} else if (count < 0) { } else if (count < 0) {
term->move(term, 0, y1); term->tr_move(term, 0, y1);
for (i = count; i < 0; i++) for (i = count; i < 0; i++)
tput(tparm(term->TI_ri, 0, 0, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_ri, 0, 0, 0, 0, 0, 0, 0, 0, 0));
} }
/* reset the scrolling region to full screen */ /* reset the scrolling region to full screen */
scroll_region_setup(term, 0, term->height-1); scroll_region_setup(term, 0, term->height - 1);
} }
/* Scroll (parm_insert_line+parm_delete_line / il+dl) */ /* Scroll (parm_insert_line+parm_delete_line / il+dl) */
@ -213,22 +216,22 @@ static void _scroll_line(TERM_REC *term, int y1, int y2, int count)
/* setup the scrolling region to wanted area - /* setup the scrolling region to wanted area -
this might not necessarily work with il/dl, but at least it this might not necessarily work with il/dl, but at least it
looks better if it does */ looks better if it does */
scroll_region_setup(term, y1, y2); scroll_region_setup(term, y1, y2);
if (count > 0) { if (count > 0) {
term->move(term, 0, y1); term->tr_move(term, 0, y1);
tput(tparm(term->TI_dl, count, count, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_dl, count, count, 0, 0, 0, 0, 0, 0, 0));
term->move(term, 0, y2-count+1); term->tr_move(term, 0, y2 - count + 1);
tput(tparm(term->TI_il, count, count, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_il, count, count, 0, 0, 0, 0, 0, 0, 0));
} else if (count < 0) { } else if (count < 0) {
term->move(term, 0, y2+count+1); term->tr_move(term, 0, y2 + count + 1);
tput(tparm(term->TI_dl, -count, -count, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_dl, -count, -count, 0, 0, 0, 0, 0, 0, 0));
term->move(term, 0, y1); term->tr_move(term, 0, y1);
tput(tparm(term->TI_il, -count, -count, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_il, -count, -count, 0, 0, 0, 0, 0, 0, 0));
} }
/* reset the scrolling region to full screen */ /* reset the scrolling region to full screen */
scroll_region_setup(term, 0, term->height-1); scroll_region_setup(term, 0, term->height - 1);
} }
/* Scroll (insert_line+delete_line / il1+dl1) */ /* Scroll (insert_line+delete_line / il1+dl1) */
@ -237,17 +240,17 @@ static void _scroll_line_1(TERM_REC *term, int y1, int y2, int count)
int i; int i;
if (count > 0) { if (count > 0) {
term->move(term, 0, y1); term->tr_move(term, 0, y1);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
tput(tparm(term->TI_dl1, 0, 0, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_dl1, 0, 0, 0, 0, 0, 0, 0, 0, 0));
term->move(term, 0, y2-count+1); term->tr_move(term, 0, y2 - count + 1);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
tput(tparm(term->TI_il1, 0, 0, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_il1, 0, 0, 0, 0, 0, 0, 0, 0, 0));
} else if (count < 0) { } else if (count < 0) {
term->move(term, 0, y2+count+1); term->tr_move(term, 0, y2 + count + 1);
for (i = count; i < 0; i++) for (i = count; i < 0; i++)
tput(tparm(term->TI_dl1, 0, 0, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_dl1, 0, 0, 0, 0, 0, 0, 0, 0, 0));
term->move(term, 0, y1); term->tr_move(term, 0, y1);
for (i = count; i < 0; i++) for (i = count; i < 0; i++)
tput(tparm(term->TI_il1, 0, 0, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_il1, 0, 0, 0, 0, 0, 0, 0, 0, 0));
} }
@ -262,14 +265,14 @@ static void _clear_screen(TERM_REC *term)
/* Clear screen (clr_eos / ed) */ /* Clear screen (clr_eos / ed) */
static void _clear_eos(TERM_REC *term) static void _clear_eos(TERM_REC *term)
{ {
term->move(term, 0, 0); term->tr_move(term, 0, 0);
tput(tparm(term->TI_ed, 0, 0, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_ed, 0, 0, 0, 0, 0, 0, 0, 0, 0));
} }
/* Clear screen (parm_delete_line / dl) */ /* Clear screen (parm_delete_line / dl) */
static void _clear_del(TERM_REC *term) static void _clear_del(TERM_REC *term)
{ {
term->move(term, 0, 0); term->tr_move(term, 0, 0);
tput(tparm(term->TI_dl, term->height, term->height, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_dl, term->height, term->height, 0, 0, 0, 0, 0, 0, 0));
} }
@ -278,8 +281,8 @@ static void _clear_del_1(TERM_REC *term)
{ {
int i; int i;
term->move(term, 0, 0); term->tr_move(term, 0, 0);
for (i = 0; i < term->height; i++) for (i = 0; i < term->height; i++)
tput(tparm(term->TI_dl1, 0, 0, 0, 0, 0, 0, 0, 0, 0)); tput(tparm(term->TI_dl1, 0, 0, 0, 0, 0, 0, 0, 0, 0));
} }
@ -452,10 +455,7 @@ static void terminfo_colors_deinit(TERM_REC *term)
terminal capabilities don't contain color codes */ terminal capabilities don't contain color codes */
void terminfo_setup_colors(TERM_REC *term, int force) void terminfo_setup_colors(TERM_REC *term, int force)
{ {
static const char ansitab[16] = { static const char ansitab[16] = { 0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15 };
0, 4, 2, 6, 1, 5, 3, 7,
8, 12, 10, 14, 9, 13, 11, 15
};
unsigned int i, color; unsigned int i, color;
terminfo_colors_deinit(term); terminfo_colors_deinit(term);
@ -463,16 +463,15 @@ void terminfo_setup_colors(TERM_REC *term, int force)
if (force && term->TI_setf == NULL && term->TI_setaf == NULL) if (force && term->TI_setf == NULL && term->TI_setaf == NULL)
term->TI_colors = 8; term->TI_colors = 8;
if ((term->TI_setf || term->TI_setaf || force) && if ((term->TI_setf || term->TI_setaf || force) && term->TI_colors > 0) {
term->TI_colors > 0) {
term->TI_fg = g_new0(char *, term->TI_colors); term->TI_fg = g_new0(char *, term->TI_colors);
term->TI_bg = g_new0(char *, term->TI_colors); term->TI_bg = g_new0(char *, term->TI_colors);
term->set_fg = _set_fg; term->tr_set_fg = _set_fg;
term->set_bg = _set_bg; term->tr_set_bg = _set_bg;
} else { } else {
/* no colors */ /* no colors */
term->TI_colors = 0; term->TI_colors = 0;
term->set_fg = term->set_bg = _ignore_parm; term->tr_set_fg = term->tr_set_bg = _ignore_parm;
} }
if (term->TI_setaf) { if (term->TI_setaf) {
@ -486,7 +485,7 @@ void terminfo_setup_colors(TERM_REC *term, int force)
term->TI_fg[i] = g_strdup(tparm(term->TI_setf, i, 0, 0, 0, 0, 0, 0, 0, 0)); term->TI_fg[i] = g_strdup(tparm(term->TI_setf, i, 0, 0, 0, 0, 0, 0, 0, 0));
} else if (force) { } else if (force) {
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
term->TI_fg[i] = g_strdup_printf("\033[%dm", 30+ansitab[i]); term->TI_fg[i] = g_strdup_printf("\033[%dm", 30 + ansitab[i]);
} }
if (term->TI_setab) { if (term->TI_setab) {
@ -500,7 +499,7 @@ void terminfo_setup_colors(TERM_REC *term, int force)
term->TI_bg[i] = g_strdup(tparm(term->TI_setb, i, 0, 0, 0, 0, 0, 0, 0, 0)); term->TI_bg[i] = g_strdup(tparm(term->TI_setb, i, 0, 0, 0, 0, 0, 0, 0, 0));
} else if (force) { } else if (force) {
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
term->TI_bg[i] = g_strdup_printf("\033[%dm", 40+ansitab[i]); term->TI_bg[i] = g_strdup_printf("\033[%dm", 40 + ansitab[i]);
} }
} }
@ -578,12 +577,12 @@ static int term_setup(TERM_REC *term)
{ {
GString *str; GString *str;
int err; int err;
char *term_env; char *term_env;
term_env = getenv("TERM"); term_env = getenv("TERM");
if (term_env == NULL) { if (term_env == NULL) {
fprintf(stderr, "TERM environment not set\n"); fprintf(stderr, "TERM environment not set\n");
return 0; return 0;
} }
if (setupterm(term_env, 1, &err) != 0) { if (setupterm(term_env, 1, &err) != 0) {
@ -591,98 +590,99 @@ static int term_setup(TERM_REC *term)
return 0; return 0;
} }
term_fill_capabilities(term); term_fill_capabilities(term);
/* Cursor movement */ /* Cursor movement */
if (term->TI_cup) if (term->TI_cup)
term->move = _move_cup; term->tr_move = _move_cup;
else if (term->TI_hpa && term->TI_vpa) else if (term->TI_hpa && term->TI_vpa)
term->move = _move_pa; term->tr_move = _move_pa;
else { else {
fprintf(stderr, "Terminal doesn't support cursor movement\n"); fprintf(stderr, "Terminal doesn't support cursor movement\n");
return 0; return 0;
} }
term->move_relative = _move_relative; term->tr_move_relative = _move_relative;
term->set_cursor_visible = term->TI_civis && term->TI_cnorm ? term->tr_set_cursor_visible =
_set_cursor_visible : _ignore_parm; term->TI_civis && term->TI_cnorm ? _set_cursor_visible : _ignore_parm;
/* Scrolling */ /* Scrolling */
if ((term->TI_csr || term->TI_wind) && term->TI_rin && term->TI_indn) if ((term->TI_csr || term->TI_wind) && term->TI_rin && term->TI_indn)
term->scroll = _scroll_region; term->tr_scroll = _scroll_region;
else if (term->TI_il && term->TI_dl) else if (term->TI_il && term->TI_dl)
term->scroll = _scroll_line; term->tr_scroll = _scroll_line;
else if ((term->TI_csr || term->TI_wind) && term->TI_ri && term->TI_ind) else if ((term->TI_csr || term->TI_wind) && term->TI_ri && term->TI_ind)
term->scroll = _scroll_region_1; term->tr_scroll = _scroll_region_1;
else if (term->scroll == NULL && (term->TI_il1 && term->TI_dl1)) else if (term->tr_scroll == NULL && (term->TI_il1 && term->TI_dl1))
term->scroll = _scroll_line_1; term->tr_scroll = _scroll_line_1;
else if (term->scroll == NULL) { else if (term->tr_scroll == NULL) {
fprintf(stderr, "Terminal doesn't support scrolling\n"); fprintf(stderr, "Terminal doesn't support scrolling\n");
return 0; return 0;
} }
/* Clearing screen */ /* Clearing screen */
if (term->TI_clear) if (term->TI_clear)
term->clear = _clear_screen; term->tr_clear = _clear_screen;
else if (term->TI_ed) else if (term->TI_ed)
term->clear = _clear_eos; term->tr_clear = _clear_eos;
else if (term->TI_dl) else if (term->TI_dl)
term->clear = _clear_del; term->tr_clear = _clear_del;
else if (term->TI_dl1) else if (term->TI_dl1)
term->clear = _clear_del_1; term->tr_clear = _clear_del_1;
else { else {
/* we could do this by line inserts as well, but don't /* we could do this by line inserts as well, but don't
bother - if some terminal has insert line it most probably bother - if some terminal has insert line it most probably
has delete line as well, if not a regular clear screen */ has delete line as well, if not a regular clear screen */
fprintf(stderr, "Terminal doesn't support clearing screen\n"); fprintf(stderr, "Terminal doesn't support clearing screen\n");
return 0; return 0;
} }
/* Clearing to end of line */ /* Clearing to end of line */
if (term->TI_el) if (term->TI_el)
term->clrtoeol = _clrtoeol; term->tr_clrtoeol = _clrtoeol;
else { else {
fprintf(stderr, "Terminal doesn't support clearing to end of line\n"); fprintf(stderr, "Terminal doesn't support clearing to end of line\n");
return 0; return 0;
} }
/* Repeating character */ /* Repeating character */
if (term->TI_rep) if (term->TI_rep)
term->repeat = _repeat; term->tr_repeat = _repeat;
else else
term->repeat = _repeat_manual; term->tr_repeat = _repeat_manual;
/* Bold, underline, standout, reverse, italics */ /* Bold, underline, standout, reverse, italics */
term->set_blink = term->TI_blink ? _set_blink : _ignore; term->tr_set_blink = term->TI_blink ? _set_blink : _ignore;
term->set_bold = term->TI_bold ? _set_bold : _ignore; term->tr_set_bold = term->TI_bold ? _set_bold : _ignore;
term->set_reverse = term->TI_rev ? _set_reverse : term->tr_set_reverse = term->TI_rev ? _set_reverse :
term->TI_smso ? _set_standout_on : _ignore; term->TI_smso ? _set_standout_on :
term->set_uline = term->TI_smul && term->TI_rmul ? _ignore;
_set_uline : _ignore_parm; term->tr_set_uline = term->TI_smul && term->TI_rmul ? _set_uline : _ignore_parm;
term->set_standout = term->TI_smso && term->TI_rmso ? term->tr_set_standout = term->TI_smso && term->TI_rmso ? _set_standout : _ignore_parm;
_set_standout : _ignore_parm; term->tr_set_italic = term->TI_sitm && term->TI_ritm ? _set_italic : _ignore_parm;
term->set_italic = term->TI_sitm && term->TI_ritm ?
_set_italic : _ignore_parm;
/* Create a string to set all attributes off */ /* Create a string to set all attributes off */
str = g_string_new(NULL); str = g_string_new(NULL);
if (term->TI_sgr0) if (term->TI_sgr0)
g_string_append(str, term->TI_sgr0); g_string_append(str, term->TI_sgr0);
if (term->TI_rmul && (term->TI_sgr0 == NULL || g_strcmp0(term->TI_rmul, term->TI_sgr0) != 0)) if (term->TI_rmul &&
(term->TI_sgr0 == NULL || g_strcmp0(term->TI_rmul, term->TI_sgr0) != 0))
g_string_append(str, term->TI_rmul); g_string_append(str, term->TI_rmul);
if (term->TI_rmso && (term->TI_sgr0 == NULL || g_strcmp0(term->TI_rmso, term->TI_sgr0) != 0)) if (term->TI_rmso &&
(term->TI_sgr0 == NULL || g_strcmp0(term->TI_rmso, term->TI_sgr0) != 0))
g_string_append(str, term->TI_rmso); g_string_append(str, term->TI_rmso);
if (term->TI_ritm && (term->TI_sgr0 == NULL || g_strcmp0(term->TI_ritm, term->TI_sgr0) != 0)) if (term->TI_ritm &&
(term->TI_sgr0 == NULL || g_strcmp0(term->TI_ritm, term->TI_sgr0) != 0))
g_string_append(str, term->TI_ritm); g_string_append(str, term->TI_ritm);
term->TI_normal = str->str; term->TI_normal = str->str;
g_string_free(str, FALSE); g_string_free(str, FALSE);
term->set_normal = _set_normal; term->tr_set_normal = _set_normal;
term->beep = term->TI_bel ? _beep : _ignore; term->tr_beep = term->TI_bel ? _beep : _ignore;
terminfo_setup_colors(term, FALSE); terminfo_setup_colors(term, FALSE);
terminfo_input_init0(term); terminfo_input_init0(term);
terminfo_cont(term); terminfo_cont(term);
return 1; return 1;
} }
void term_set_appkey_mode(int enable) void term_set_appkey_mode(int enable)
@ -727,14 +727,14 @@ void terminfo_core_deinit(TERM_REC *term)
TERM_REC *old_term; TERM_REC *old_term;
old_term = current_term; old_term = current_term;
current_term = term; current_term = term;
term->set_normal(term); term->tr_set_normal(term);
current_term = old_term; current_term = old_term;
terminfo_stop(term); terminfo_stop(term);
g_free(term->TI_normal); g_free(term->TI_normal);
terminfo_colors_deinit(term); terminfo_colors_deinit(term);
g_free(term); g_free(term);
} }

View File

@ -3,48 +3,49 @@
#include <termios.h> #include <termios.h>
#define terminfo_move(x, y) current_term->move(current_term, x, y) #define terminfo_move(x, y) current_term->tr_move(current_term, x, y)
#define terminfo_move_relative(oldx, oldy, x, y) current_term->move_relative(current_term, oldx, oldy, x, y) #define terminfo_move_relative(oldx, oldy, x, y) \
#define terminfo_set_cursor_visible(set) current_term->set_cursor_visible(current_term, set) current_term->tr_move_relative(current_term, oldx, oldy, x, y)
#define terminfo_scroll(y1, y2, count) current_term->scroll(current_term, y1, y2, count) #define terminfo_set_cursor_visible(set) current_term->tr_set_cursor_visible(current_term, set)
#define terminfo_clear() current_term->clear(current_term) #define terminfo_scroll(y1, y2, count) current_term->tr_scroll(current_term, y1, y2, count)
#define terminfo_clrtoeol() current_term->clrtoeol(current_term) #define terminfo_clear() current_term->tr_clear(current_term)
#define terminfo_repeat(chr, count) current_term->repeat(current_term, chr, count) #define terminfo_clrtoeol() current_term->tr_clrtoeol(current_term)
#define terminfo_set_fg(color) current_term->set_fg(current_term, color) #define terminfo_repeat(chr, count) current_term->tr_repeat(current_term, chr, count)
#define terminfo_set_bg(color) current_term->set_bg(current_term, color) #define terminfo_set_fg(color) current_term->tr_set_fg(current_term, color)
#define terminfo_set_normal() current_term->set_normal(current_term) #define terminfo_set_bg(color) current_term->tr_set_bg(current_term, color)
#define terminfo_set_bold() current_term->set_bold(current_term) #define terminfo_set_normal() current_term->tr_set_normal(current_term)
#define terminfo_set_uline(set) current_term->set_uline(current_term, set) #define terminfo_set_bold() current_term->tr_set_bold(current_term)
#define terminfo_set_standout(set) current_term->set_standout(current_term, set) #define terminfo_set_uline(set) current_term->tr_set_uline(current_term, set)
#define terminfo_set_reverse() current_term->set_reverse(current_term) #define terminfo_set_standout(set) current_term->tr_set_standout(current_term, set)
#define terminfo_set_italic(set) current_term->set_italic(current_term, set) #define terminfo_set_reverse() current_term->tr_set_reverse(current_term)
#define terminfo_set_italic(set) current_term->tr_set_italic(current_term, set)
#define terminfo_is_colors_set(term) (term->TI_fg != NULL) #define terminfo_is_colors_set(term) (term->TI_fg != NULL)
#define terminfo_beep(term) current_term->beep(current_term) #define terminfo_beep(term) current_term->tr_beep(current_term)
typedef struct _TERM_REC TERM_REC; typedef struct _TERM_REC TERM_REC;
struct _TERM_REC { struct _TERM_REC {
/* Functions */ /* Functions */
void (*move)(TERM_REC *term, int x, int y); void (*tr_move)(TERM_REC *term, int x, int y);
void (*move_relative)(TERM_REC *term, int oldx, int oldy, int x, int y); void (*tr_move_relative)(TERM_REC *term, int oldx, int oldy, int x, int y);
void (*set_cursor_visible)(TERM_REC *term, int set); void (*tr_set_cursor_visible)(TERM_REC *term, int set);
void (*scroll)(TERM_REC *term, int y1, int y2, int count); void (*tr_scroll)(TERM_REC *term, int y1, int y2, int count);
void (*clear)(TERM_REC *term); void (*tr_clear)(TERM_REC *term);
void (*clrtoeol)(TERM_REC *term); void (*tr_clrtoeol)(TERM_REC *term);
void (*repeat)(TERM_REC *term, char chr, int count); void (*tr_repeat)(TERM_REC *term, char chr, int count);
void (*set_fg)(TERM_REC *term, int color); void (*tr_set_fg)(TERM_REC *term, int color);
void (*set_bg)(TERM_REC *term, int color); void (*tr_set_bg)(TERM_REC *term, int color);
void (*set_normal)(TERM_REC *term); void (*tr_set_normal)(TERM_REC *term);
void (*set_blink)(TERM_REC *term); void (*tr_set_blink)(TERM_REC *term);
void (*set_bold)(TERM_REC *term); void (*tr_set_bold)(TERM_REC *term);
void (*set_reverse)(TERM_REC *term); void (*tr_set_reverse)(TERM_REC *term);
void (*set_uline)(TERM_REC *term, int set); void (*tr_set_uline)(TERM_REC *term, int set);
void (*set_standout)(TERM_REC *term, int set); void (*tr_set_standout)(TERM_REC *term, int set);
void (*set_italic)(TERM_REC *term, int set); void (*tr_set_italic)(TERM_REC *term, int set);
void (*beep)(TERM_REC *term); void (*tr_beep)(TERM_REC *term);
#ifndef HAVE_TERMINFO #ifndef HAVE_TERMINFO
char buffer1[1024], buffer2[1024]; char buffer1[1024], buffer2[1024];
@ -52,13 +53,13 @@ struct _TERM_REC {
FILE *in, *out; FILE *in, *out;
struct termios tio, old_tio; struct termios tio, old_tio;
/* Terminal size */ /* Terminal size */
int width, height; int width, height;
/* Cursor movement */ /* Cursor movement */
const char *TI_smcup, *TI_rmcup, *TI_cup; const char *TI_smcup, *TI_rmcup, *TI_cup;
const char *TI_hpa, *TI_vpa, *TI_cub1, *TI_cuf1; const char *TI_hpa, *TI_vpa, *TI_cub1, *TI_cuf1;
const char *TI_civis, *TI_cnorm; const char *TI_civis, *TI_cnorm;
/* Scrolling */ /* Scrolling */
const char *TI_csr, *TI_wind; const char *TI_csr, *TI_wind;
@ -68,26 +69,26 @@ struct _TERM_REC {
/* Clearing screen */ /* Clearing screen */
const char *TI_clear, *TI_ed; /* + *TI_dl, *TI_dl1; */ const char *TI_clear, *TI_ed; /* + *TI_dl, *TI_dl1; */
/* Clearing to end of line */ /* Clearing to end of line */
const char *TI_el; const char *TI_el;
/* Repeating character */ /* Repeating character */
const char *TI_rep; const char *TI_rep;
/* Colors */ /* Colors */
int TI_colors; /* numbers of colors in TI_fg[] and TI_bg[] */ int TI_colors; /* numbers of colors in TI_fg[] and TI_bg[] */
const char *TI_sgr0; /* turn off all attributes */ const char *TI_sgr0; /* turn off all attributes */
const char *TI_smul, *TI_rmul; /* underline on/off */ const char *TI_smul, *TI_rmul; /* underline on/off */
const char *TI_smso, *TI_rmso; /* standout on/off */ const char *TI_smso, *TI_rmso; /* standout on/off */
const char *TI_sitm, *TI_ritm; /* italic on/off */ const char *TI_sitm, *TI_ritm; /* italic on/off */
const char *TI_bold, *TI_blink, *TI_rev; const char *TI_bold, *TI_blink, *TI_rev;
const char *TI_setaf, *TI_setab, *TI_setf, *TI_setb; const char *TI_setaf, *TI_setab, *TI_setf, *TI_setb;
/* Colors - generated and dynamically allocated */ /* Colors - generated and dynamically allocated */
char **TI_fg, **TI_bg, *TI_normal; char **TI_fg, **TI_bg, *TI_normal;
/* Beep */ /* Beep */
char *TI_bel; char *TI_bel;
/* Keyboard-transmit mode */ /* Keyboard-transmit mode */
const char *TI_smkx; const char *TI_smkx;