Compare commits

...

2 Commits

Author SHA1 Message Date
Juhani Krekelä 50f5e88722 Add irssi port. 2023-12-26 19:28:49 +02:00
Juhani Krekelä fc20a4f6a3 Support CSI n L and CSI n M in console and terminal(1).
With these escapes supported, include definitions for line deletion
(dl1, dl) and insertion (il1, il) in terminfo for "sortix".
2023-12-26 19:24:00 +02:00
7 changed files with 307 additions and 9 deletions

View File

@ -1,3 +1,3 @@
set_minimal="cut dash e2fsprogs grep grub mdocml sed xargs"
set_basic="$set_minimal binutils bison bzip2 diffutils ed flex gawk gcc git gzip libcurl libcurses libssl libstdc++ m4 make nano ntpd patch perl pkg-config python ssh tar texinfo vim wget xz xorriso"
set_basic="$set_minimal binutils bison bzip2 diffutils ed flex gawk gcc git gzip irssi libcurl libcurses libssl libstdc++ m4 make nano ntpd patch perl pkg-config python ssh tar texinfo vim wget xz xorriso"
sets="basic minimal"

View File

@ -1,5 +1,6 @@
/*
* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016 Jonas 'Sortie' Termansen.
* Copyright (c) 2023 Juhani 'nortti' Krekelä.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -659,8 +660,45 @@ void TextTerminal::RunAnsiCommand(TextBuffer* textbuf, char c)
uint32_t fillbg = attr & ATTR_INVERSE ? fgcolor : bgcolor;
textbuf->Fill(from, to, TextChar(' ', vgacolor, 0, fillfg, fillbg));
} break;
// TODO: CSI Ps M Delete Ps Line(s) (default = 1) (DL).
// (delete those lines and move the rest of the lines upwards).
case 'L': // Append lines before current line.
{
column = 0;
unsigned count = 0 < ansiusedparams ? ansiparams[0] : 1;
if ( height - line < count )
count = height - line;
TextPos from(0, line);
TextPos move_to(0, line + count);
unsigned move_lines = height - (line + count);
textbuf->Move(move_to, from, move_lines * width);
if ( 0 < count )
{
TextPos fill_to(width - 1, line + count - 1);
uint32_t fill_fg = attr & ATTR_INVERSE ? bgcolor : fgcolor;
uint32_t fill_bg = attr & ATTR_INVERSE ? fgcolor : bgcolor;
TextChar fill_char(' ', vgacolor, 0, fill_fg, fill_bg);
textbuf->Fill(from, fill_to, fill_char);
}
} break;
case 'M': // Delete lines starting from beginning of current line.
{
column = 0;
unsigned count = 0 < ansiusedparams ? ansiparams[0] : 1;
if ( height - line < count )
count = height - line;
TextPos move_from(0, line + count);
TextPos move_to(0, line);
unsigned move_lines = height - (line + count);
textbuf->Move(move_to, move_from, move_lines * width);
if ( 0 < count )
{
TextPos fill_from(0, height - count);
TextPos fill_to(width - 1, height - 1);
uint32_t fill_fg = attr & ATTR_INVERSE ? bgcolor : fgcolor;
uint32_t fill_bg = attr & ATTR_INVERSE ? fgcolor : bgcolor;
TextChar fill_char(' ', vgacolor, 0, fill_fg, fill_bg);
textbuf->Fill(fill_from, fill_to, fill_char);
}
} break;
// TODO: CSI Ps P Delete Ps Character(s) (default = 1) (DCH).
// (delete those characters and move the rest of the line leftward).
case 'S': // Scroll a line up and place a new line at the buttom.

197
ports/irssi/irssi.patch Normal file
View File

@ -0,0 +1,197 @@
diff -Paur --no-dereference -- irssi.upstream/Makefile.in irssi/Makefile.in
--- irssi.upstream/Makefile.in
+++ irssi/Makefile.in
@@ -426,7 +426,7 @@
BUILT_SOURCES = default-config.h default-theme.h irssi-version.h
CLEANFILES = default-config.h default-theme.h
SUBDIRS = src tests docs scripts themes utils
-confdir = $(sysconfdir)
+confdir = $(sysconfdir)/examples
conf_DATA = irssi.conf
pkgconfig_DATA = irssi-1.pc
pkginclude_HEADERS = irssi-config.h irssi-version.h
diff -Paur --no-dereference -- irssi.upstream/configure irssi/configure
--- irssi.upstream/configure
+++ irssi/configure
@@ -18236,4 +18236,3 @@
echo
echo "If there are any problems, read the INSTALL file."
-
diff -Paur --no-dereference -- irssi.upstream/irssi.conf irssi/irssi.conf
--- irssi.upstream/irssi.conf
+++ irssi/irssi.conf
@@ -12,6 +12,7 @@
{ address = "irc.quakenet.org"; chatnet = "QuakeNet"; port = "6667"; },
{ address = "irc.rizon.net"; chatnet = "Rizon"; port = "6697"; use_tls = "yes"; tls_verify = "yes"; },
{ address = "silc.silcnet.org"; chatnet = "SILC"; port = "706"; },
+ { address = "irc.sortix.org"; chatnet = "sortix"; port = "6697"; use_tls = "yes"; tls_verify = "yes"; },
{ address = "irc.undernet.org"; chatnet = "Undernet"; port = "6667"; }
);
@@ -85,6 +86,9 @@
SILC = {
type = "SILC";
};
+ sortix = {
+ type = "IRC";
+ };
Undernet = {
type = "IRC";
max_kicks = "1";
@@ -103,6 +107,7 @@
{ name = "#netfuze"; chatnet = "NetFuze"; autojoin = "No"; },
{ name = "#oftc"; chatnet = "OFTC"; autojoin = "No"; },
{ name = "silc"; chatnet = "SILC"; autojoin = "No"; }
+ { name = "#sortix"; chatnet = "sortix"; autojoin = "No"; },
);
aliases = {
diff -Paur --no-dereference -- irssi.upstream/src/core/log.c irssi/src/core/log.c
--- irssi.upstream/src/core/log.c
+++ irssi/src/core/log.c
@@ -101,7 +101,10 @@
int log_start_logging(LOG_REC *log)
{
char *dir;
+/* PATCH: Sortix doesn't implement flock */
+#ifdef F_SETLK
struct flock lock;
+#endif
g_return_val_if_fail(log != NULL, FALSE);
@@ -139,6 +142,8 @@
log->failed = TRUE;
return FALSE;
}
+/* PATCH: Sortix doesn't implement flock */
+#ifdef F_SETLK
memset(&lock, 0, sizeof(lock));
lock.l_type = F_WRLCK;
if (fcntl(log->handle, F_SETLK, &lock) == -1 && errno == EACCES) {
@@ -148,6 +153,7 @@
log->failed = TRUE;
return FALSE;
}
+#endif
lseek(log->handle, 0, SEEK_END);
log->opened = log->last = time(NULL);
@@ -162,7 +168,10 @@
void log_stop_logging(LOG_REC *log)
{
+/* PATCH: Sortix doesn't implement flock */
+#ifdef F_SETLK
struct flock lock;
+#endif
g_return_if_fail(log != NULL);
@@ -175,9 +184,12 @@
settings_get_str("log_close_string"),
"\n", time(NULL));
+/* PATCH: Sortix doesn't implement flock */
+#ifdef F_SETLK
memset(&lock, 0, sizeof(lock));
lock.l_type = F_UNLCK;
fcntl(log->handle, F_SETLK, &lock);
+#endif
write_buffer_flush();
close(log->handle);
diff -Paur --no-dereference -- irssi.upstream/src/core/net-disconnect.c irssi/src/core/net-disconnect.c
--- irssi.upstream/src/core/net-disconnect.c
+++ irssi/src/core/net-disconnect.c
@@ -18,6 +18,8 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <sys/select.h>
+
#include "module.h"
#include <irssi/src/core/network.h>
diff -Paur --no-dereference -- irssi.upstream/src/core/network.c irssi/src/core/network.c
--- irssi.upstream/src/core/network.c
+++ irssi/src/core/network.c
@@ -491,8 +491,6 @@
int net_host2ip(const char *host, IPADDR *ip)
{
- unsigned long addr;
-
if (strchr(host, ':') != NULL) {
/* IPv6 */
ip->family = AF_INET6;
@@ -501,16 +499,8 @@
} else {
/* IPv4 */
ip->family = AF_INET;
-#ifdef HAVE_INET_ATON
- if (inet_aton(host, &ip->ip.s_addr) == 0)
- return -1;
-#else
- addr = inet_addr(host);
- if (addr == INADDR_NONE)
+ if (inet_pton(AF_INET, host, &ip->ip) == 0)
return -1;
-
- memcpy(&ip->ip, &addr, 4);
-#endif
}
return 0;
diff -Paur --no-dereference -- irssi.upstream/src/core/network.h irssi/src/core/network.h
--- irssi.upstream/src/core/network.h
+++ irssi/src/core/network.h
@@ -11,6 +11,11 @@
# include <netdb.h>
# include <arpa/inet.h>
+/* PATCH: Sortix netdb.h does not define HOST_NOT_FOUND */
+#ifndef HOST_NOT_FOUND
+#define HOST_NOT_FOUND 1
+#endif
+
#ifndef AF_INET6
# ifdef PF_INET6
# define AF_INET6 PF_INET6
diff -Paur --no-dereference -- irssi.upstream/src/core/refstrings.c irssi/src/core/refstrings.c
--- irssi.upstream/src/core/refstrings.c
+++ irssi/src/core/refstrings.c
@@ -122,7 +122,7 @@
mem += sizeof(char) * (strlen(key) + 1) + 2 * sizeof(void *);
}
- return g_strdup_printf("Shared strings: %ld, %dkB of data", count,
+ return g_strdup_printf("Shared strings: %zu, %dkB of data", count,
(int) (mem / 1024));
}
diff -Paur --no-dereference -- irssi.upstream/src/fe-common/core/fe-exec.c irssi/src/fe-common/core/fe-exec.c
--- irssi.upstream/src/fe-common/core/fe-exec.c
+++ irssi/src/fe-common/core/fe-exec.c
@@ -327,7 +327,7 @@
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_DFL);
- putenv("TERM=tty");
+ setenv("TERM", "tty", 1);
/* set stdin, stdout and stderr */
dup2(in[0], STDIN_FILENO);
diff -Paur --no-dereference -- irssi.upstream/src/irc/core/irc.c irssi/src/irc/core/irc.c
--- irssi.upstream/src/irc/core/irc.c
+++ irssi/src/irc/core/irc.c
@@ -90,7 +90,7 @@
end = tmp;
if (tmp - cmd > MAX_IRC_USER_TAGS_LEN) {
- g_warning("irc_send_cmd_full(); tags too long(%ld)", tmp - cmd);
+ g_warning("irc_send_cmd_full(); tags too long(%td)", tmp - cmd);
while (tmp - cmd > MAX_IRC_USER_TAGS_LEN && cmd != tmp - 1) tmp--;
while (*tmp != ',' && cmd != tmp - 1) tmp--;
}

15
ports/irssi/irssi.port Normal file
View File

@ -0,0 +1,15 @@
NAME=irssi
BUILD_LIBRARIES='libcurses libglib libssl'
VERSION=1.4.5
DISTNAME=$NAME-$VERSION
COMPRESSION=tar.xz
ARCHIVE=$DISTNAME.$COMPRESSION
SHA256SUM=72a951cb0ad622785a8962801f005a3a412736c7e7e3ce152f176287c52fe062
UPSTREAM_SITE=https://codeberg.org/irssi/irssi/releases/download/$VERSION
UPSTREAM_ARCHIVE=$ARCHIVE
RELEASE_SEARCH_PAGE=https://codeberg.org/irssi/irssi/releases
BUILD_SYSTEM=configure
# Perl support in irssi is fundamentally broken for cross-compilation.
CONFIGURE_ARGS='--enable-true-color --with-perl=no'
MAKE_VARS=V=1
LICENSE=GPL-2.0-or-later

View File

@ -0,0 +1 @@
rm -rf -- 'irssi-config.h'

View File

@ -293,7 +293,7 @@ diff -Paur --no-dereference -- libcurses.upstream/netbsd_sys/cdefs.h libcurses/n
diff -Paur --no-dereference -- libcurses.upstream/terminfo/sortix.terminfo libcurses/terminfo/sortix.terminfo
--- libcurses.upstream/terminfo/sortix.terminfo
+++ libcurses/terminfo/sortix.terminfo
@@ -0,0 +1,230 @@
@@ -0,0 +1,231 @@
+# TODO: Decode setab and setaf and see if they are what I want.
+# TODO: Implement BEL \a and add bel=^G,
+# TODO: Add blink support and add blink=\E[5m,
@ -302,12 +302,9 @@ diff -Paur --no-dereference -- libcurses.upstream/terminfo/sortix.terminfo libcu
+# TODO: Support dch=\E[%p1%dP,
+# TODO: dch1=\E[P,
+# TODO: Add faint support and add dim=\E[2m,
+# TODO: dl1=\E[M,
+# TODO: ech=\E[%p1%dX,
+# TODO: hts=\EH,
+# TODO: ich=\E[%p1%d@,
+# TODO: il=\E[%p1%dL,
+# TODO: il1=\E[L,
+# TODO: invis=\E[8m,
+# TODO: Some modifiers for the function keys are missing, like control + alt +
+# shift + f12, kfxx should probably go up to 96. On the other hand,
@ -346,12 +343,16 @@ diff -Paur --no-dereference -- libcurses.upstream/terminfo/sortix.terminfo libcu
+ cup=\E[%i%p1%d;%p2%dH,
+ cuu1=\E[A,
+ cuu=\E[%p1%dA,
+ dl1=\E[M,
+ dl=\E[%p1%dM,
+ ed=\E[J,
+ el1=\E[1K,
+ el=\E[K,
+ home=\E[H,
+ hpa=\E[%i%p1%dG,
+ ht=^I,
+ il1=\E[L,
+ il=\E[%p1%dL,
+ ind=^J,
+ indn=\E[%p1%dS,
+ nel=^J,

View File

@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, 2022 Jonas 'Sortie' Termansen.
* Copyright (c) 2023 Juhani 'nortti' Krekelä.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -211,6 +212,21 @@ static void fill(size_t from_x, size_t from_y, size_t to_x, size_t to_y,
scrollback[i] = with;
}
static void move(size_t to_x, size_t to_y, size_t from_x, size_t from_y,
size_t num_chars)
{
// TODO: Assert within bounds?
size_t from = from_y * columns + from_x;
size_t to = to_y * columns + to_x;
if ( to < from )
for ( size_t i = 0; i < num_chars; i++ )
scrollback[to + i] = scrollback[from + i];
else if ( from < to )
for ( size_t i = 0; i < num_chars; i++ )
scrollback[to + num_chars - 1 - i] =
scrollback[from + num_chars - 1 - i];
}
static void scroll(ssize_t offsigned, struct entry with)
{
if ( 0 < offsigned )
@ -396,8 +412,38 @@ static void run_ansi_command(char c)
with.wc = 0;
fill(from_x, from_y, to_x, to_y, with);
} break;
// TODO: CSI Ps M Delete Ps Line(s) (default = 1) (DL).
// (delete those lines and move the rest of the lines upwards).
case 'L': // Append lines before current line.
{
column = 0;
unsigned count = 0 < ansiusedparams ? ansiparams[0] : 1;
if ( rows - row < count )
count = rows - row;
unsigned move_lines = rows - (row + count);
move(0, row + count, 0, row, move_lines * columns);
struct entry with;
with.attr = 0;
with.fgcolor = attr & ATTR_INVERSE ? current_bgcolor : current_fgcolor;
with.bgcolor = attr & ATTR_INVERSE ? current_fgcolor : current_bgcolor;
with.wc = 0;
if ( 0 < count )
fill(0, row, columns - 1, row + count - 1, with);
} break;
case 'M': // Delete lines starting from beginning of current line.
{
column = 0;
unsigned count = 0 < ansiusedparams ? ansiparams[0] : 1;
if ( rows - row < count )
count = rows - row;
unsigned move_lines = rows - (row + count);
move(0, row, 0, row + count, move_lines * columns);
struct entry with;
with.attr = 0;
with.fgcolor = attr & ATTR_INVERSE ? current_bgcolor : current_fgcolor;
with.bgcolor = attr & ATTR_INVERSE ? current_fgcolor : current_bgcolor;
with.wc = 0;
if ( 0 < count )
fill(0, rows - count, columns - 1, rows - 1, with);
} break;
// TODO: CSI Ps P Delete Ps Character(s) (default = 1) (DCH).
// (delete those characters and move the rest of the line leftward).
case 'S': // Scroll a line up and place a new line at the buttom.