diff --git a/srcpkgs/cmatrix/patches/unicode.patch b/srcpkgs/cmatrix/patches/unicode.patch new file mode 100644 index 00000000000..52b7a07a5e4 --- /dev/null +++ b/srcpkgs/cmatrix/patches/unicode.patch @@ -0,0 +1,84 @@ +From 7647b4774c72a0803b36d89ece4edd95f5dbb97f Mon Sep 17 00:00:00 2001 +From: patatahooligan +Date: Thu, 20 Oct 2022 07:23:15 +0300 +Subject: [PATCH] Fix unicode character printing (#112) + +* Fix unicode character printing + +Fix several issues that prevented it from working + + * link to the wide-character version of ncurses + * define NCURSES_WIDECHAR + * use a function that can print wide characters + * fix the character range. I don't know what the original was supposed + to be, but half-width kana (which is what the movie reportedly used) + was not at that range. + +* Fix half-width kana character range + +I'm not very familiar with katakana, but I think the extra characters I +was using are punctuation or other marks. So let's remove them. Note +that this is the same range space-pagan is using. +--- + CMakeLists.txt | 1 + + cmatrix.c | 21 +++++++++++++++++---- + 2 files changed, 18 insertions(+), 4 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 6c50d7b..68ee176 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -50,6 +50,7 @@ if (HAVE_GETOPT_H) + endif () + + Set(CURSES_NEED_NCURSES TRUE) ++Set(CURSES_NEED_WIDE TRUE) + find_package(Curses) + include_directories(${CURSES_INCLUDE_DIR}) + add_definitions(-DHAVE_NCURSES_H) +diff --git a/cmatrix.c b/cmatrix.c +index 7e3fbb9..7d8ca39 100644 +--- a/cmatrix.c ++++ b/cmatrix.c +@@ -21,6 +21,8 @@ + + */ + ++#define NCURSES_WIDECHAR 1 ++ + #include + #include + #include +@@ -521,9 +523,12 @@ if (console) { + + /* Set up values for random number generation */ + if(classic) { +- /* Japanese character unicode range [they are seen in the original cmatrix] */ +- randmin = 12288; +- highnum = 12351; ++ /* Half-width kana characters. In the movie they are y-axis flipped, and ++ * they appear alongside latin characters and numerals, but this is the ++ * closest we can do with a standard unicode set and a single number ++ * range */ ++ randmin = 0xff66; ++ highnum = 0xff9d; + } else if (console || xwindow) { + randmin = 166; + highnum = 217; +@@ -834,7 +839,15 @@ if (console) { + } else if (lambda && matrix[i][j].val != ' ') { + addstr("λ"); + } else { +- addch(matrix[i][j].val); ++ /* addch doesn't seem to work with unicode ++ * characters and there was no direct equivalent. ++ * So, construct a c-style string with the character ++ * and print that. ++ */ ++ wchar_t char_array[2]; ++ char_array[0] = matrix[i][j].val; ++ char_array[1] = 0; ++ addwstr(char_array); + } + if (bold == 2 || + (bold == 1 && matrix[i][j].val % 2 == 0)) { diff --git a/srcpkgs/cmatrix/template b/srcpkgs/cmatrix/template index 5c49e0c6644..facfa4c3b2f 100644 --- a/srcpkgs/cmatrix/template +++ b/srcpkgs/cmatrix/template @@ -1,7 +1,7 @@ # Template file for 'cmatrix' pkgname=cmatrix version=2.0 -revision=1 +revision=2 build_style=cmake hostmakedepends="kbd" makedepends="ncurses-devel"