cmatrix: fix Japanese
This commit is contained in:
parent
1bc9dff40b
commit
40d2ebc64e
|
@ -0,0 +1,88 @@
|
|||
From: patatahooligan <filwn.oikonomou@gmail.com>
|
||||
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 <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
@@ -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)) {
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue