From: Adam Borowski <kilobyte@angband.pl>
To: linux-kernel@vger.kernel.org
Cc: Adam Borowski <kilobyte@angband.pl>
Subject: [PATCH 2/4] n_tty: use runes rather than uppercase in IUTF8 OLCUC mode
Date: Sat, 1 Apr 2017 11:43:35 +0200 [thread overview]
Message-ID: <20170401094337.4367-2-kilobyte@angband.pl> (raw)
In-Reply-To: <20170401094337.4367-1-kilobyte@angband.pl>
It is puzzling why OLCUC support has been added to Linux, despite it being
obsolete for a long long time before Linux was born. The only explanation
I see, as on all-caps displays those were often called "Great Runes" (see
the Jargon File), is that the intention was to support runes but that
wasn't possible before Unicode.
As the kernel's tty discipline knows about UTF-8, that's now possible.
Standards compliance:
Elder Futhark (2nd to 8th centuries), other than:
'y' 'c' are from Anglo-Saxon runes (5th to 11th centuries), 'c' should use
kauna rather than cen but as the former is shared with 'k', I sacrificed
period accuracy for usability.
'q' 'v' 'x' are from Medieval runes (12th to 15th centuries). 'x' could
use Anglo-Saxon eolhx but that's same glyph (and Unicode codepoint) as
Elder Futhark algiz 'z'.
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
---
drivers/tty/n_tty.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index bbc9f07c19fa..c36b9114f76b 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -401,8 +401,10 @@ static inline int is_continuation(unsigned char c, struct tty_struct *tty)
* only some commands require lowercase.
*/
-static int do_olcuc_char(unsigned char c, struct tty_struct *tty)
+static int do_olcuc_char(unsigned char c, struct tty_struct *tty, int space)
{
+ /* 3 bytes per character */
+ static const char *runes = "ᚨᛒᚳᛞᛖᚠᚷᚺᛁᛃᚲᛚᛗᚾᛟᛈᛩᚱᛊᛏᚢᚡᚹᛪᚣᛉ";
struct n_tty_data *ldata = tty->disc_data;
switch (ldata->vt_state) {
@@ -418,10 +420,24 @@ static int do_olcuc_char(unsigned char c, struct tty_struct *tty)
ldata->vt_state = ESnormal;
break;
default:
- if (c == '\e')
+ if (c == '\e') {
ldata->vt_state = ESesc;
- else if (c >= 'a' && c <= 'z')
+ break;
+ }
+ if (c >= 'a' && c <= 'z')
c -= 32;
+ if (I_IUTF8(tty)) {
+ if (c >= 'A' && c <= 'Z') {
+ if (space < 3)
+ return -1;
+ ldata->column++;
+ c -= 'A';
+ tty_put_char(tty, runes[3 * c + 0]);
+ tty_put_char(tty, runes[3 * c + 1]);
+ tty_put_char(tty, runes[3 * c + 2]);
+ return 1;
+ }
+ }
}
if (!iscntrl(c) && !is_continuation(c, tty))
ldata->column++;
@@ -500,7 +516,7 @@ static int do_output_char(unsigned char c, struct tty_struct *tty, int space)
break;
default:
if (O_OLCUC(tty))
- return do_olcuc_char(c, tty);
+ return do_olcuc_char(c, tty, space);
if (!iscntrl(c) && !is_continuation(c, tty))
ldata->column++;
break;
--
2.11.0
next prev parent reply other threads:[~2017-04-01 9:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-01 9:42 [GIT PULL] runes Adam Borowski
2017-04-01 9:43 ` [PATCH 1/4] n_tty: don't mangle tty codes in OLCUC mode Adam Borowski
2017-04-01 9:43 ` Adam Borowski [this message]
2017-04-01 9:43 ` [PATCH 3/4] n_tty: support th, ae and ng runes Adam Borowski
2017-04-01 9:43 ` [PATCH 4/4] n_tty: wrap all OLCUC code in a config option Adam Borowski
2017-04-01 18:09 ` [GIT PULL] runes Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170401094337.4367-2-kilobyte@angband.pl \
--to=kilobyte@angband.pl \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®