From 40d2ebc64eb114ec6aa4bb1c621a4ce8930b2c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Tue, 23 Jul 2024 17:20:08 +0700 Subject: [PATCH] cmatrix: fix Japanese --- ...1-Fix-unicode-character-printing-112.patch | 88 +++++++++++++++++++ srcpkgs/cmatrix/template | 4 + 2 files changed, 92 insertions(+) create mode 100644 srcpkgs/cmatrix/patches/0001-Fix-unicode-character-printing-112.patch diff --git a/srcpkgs/cmatrix/patches/0001-Fix-unicode-character-printing-112.patch b/srcpkgs/cmatrix/patches/0001-Fix-unicode-character-printing-112.patch new file mode 100644 index 00000000000..db58a843599 --- /dev/null +++ b/srcpkgs/cmatrix/patches/0001-Fix-unicode-character-printing-112.patch @@ -0,0 +1,88 @@ +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. + +(cherry picked from commit 7647b4774c72a0803b36d89ece4edd95f5dbb97f) +--- + CMakeLists.txt | 1 + + cmatrix.c | 24 +++++++++++++++++++----- + 2 files changed, 20 insertions(+), 5 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c5548b3..056ccec 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -35,6 +35,7 @@ if (HAVE_TERMIO_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 90284cb..d4f8ab1 100644 +--- a/cmatrix.c ++++ b/cmatrix.c +@@ -21,6 +21,9 @@ + + */ + ++#define NCURSES_WIDECHAR 1 ++ ++#include + #include + #include + #include +@@ -435,10 +438,13 @@ 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; ++ if (classic) { ++ /* 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; +@@ -739,7 +745,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 facfa4c3b2f..2682869f62f 100644 --- a/srcpkgs/cmatrix/template +++ b/srcpkgs/cmatrix/template @@ -11,3 +11,7 @@ license="GPL-2.0-or-later" homepage="https://github.com/abishekvashok/cmatrix" distfiles="https://github.com/abishekvashok/cmatrix/archive/v${version}.tar.gz" checksum=ad93ba39acd383696ab6a9ebbed1259ecf2d3cf9f49d6b97038c66f80749e99a + +post_install() { + vman cmatrix.1 +}