Re: Unicode console patch

Stanislav V. Voronyi (stas@cnti.uanet.kharkov.ua)
Tue, 2 Feb 1999 00:10:02 +0200


In message <199901312029.MAA19298@cesium.transmeta.com> H. Peter Anvin
writes:

>> >Please don't extend TIOCLINUX. It was a bad mistake to begin with,
>> >and furthermore, we're trying to move away from ioctl()s (ioctl()s
>> >were used because most changes affected *all* consoles. Per-console
>> >changes should be done with escape codes.)
>>
>> It is very useful to have posibilities to get the state of
>> translation related variables. Imo we don't have yet the wide UTF support
>> (in bash, vi, etc) just because there is not such posibility.

>That is definitely true.

I don't found anything about possible format of such requests/responces.
So I try to made this in my own way. If its not true please correct me.
At the end of this letter I attach patch which make possible to get
all translation information using ESC sequences. This patch add such
new ESC sequences:
\033(? - ask about G0_charset
\033)? - ask about G1_charset
\033%? - ask about utf state
\033C - ask about charset (^N/^O)
\033? - ask about all together
The response string is the escape sequnce to set appropriate mode, i.e.
\033(? -> \033(K or
\033? -> \033(K\033)0\033%@^O
So now possible send to console \033?, save the response string, and than
just send saved string to console to restore its state.
Is this sequnces good ? Any comments wellcome.

SY, Stanislav Voronyi.

-------------------- PATCH HERE ------------------------
--- linux/drivers/char/console.c.orig Mon Feb 1 23:25:19 1999
+++ linux/drivers/char/console.c Mon Feb 1 23:29:40 1999
@@ -66,6 +66,9 @@
*
* Resurrected character buffers in videoram plus lots of other trickery
* by Martin Mares <mj@atrey.karlin.mff.cuni.cz>, July 1998
+ *
+ * Reporting of translation related variables state with escape sequnces
+ * by Stanislav Voronyi <stas@esc.kharkov.com>
*/

#include <linux/module.h>
@@ -1120,6 +1123,42 @@
respond_string(VT102ID, tty);
}

+static char charsets[]={'B','0','U','K'};
+static void respond_G0(int currcons,struct tty_struct * tty)
+{
+ char buf[4];
+ sprintf(buf, "\033(%c", charsets[G0_charset]);
+ respond_string(buf, tty);
+}
+static void respond_G1(int currcons,struct tty_struct * tty)
+{
+ char buf[4];
+ sprintf(buf, "\033)%c", charsets[G1_charset]);
+ respond_string(buf, tty);
+}
+static void respond_charset(int currcons,struct tty_struct * tty)
+{
+ if (charset == 1)
+ respond_string("\016", tty);
+ else
+ respond_string("\017", tty);
+}
+static void respond_utf(int currcons,struct tty_struct * tty)
+{
+ if (utf == 1)
+ respond_string("\033%G", tty);
+ else
+ respond_string("\033%@", tty);
+}
+static void respond_all_translation(int currcons,struct tty_struct * tty)
+{
+ char buf[11];
+ sprintf(buf, "\033(%c\033)%c\033%%%c%c",
+ charsets[G0_charset], charsets[G1_charset],
+ utf?'G':'@', charset?'\016':'\017');
+ respond_string(buf, tty);
+}
+
void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry)
{
char buf[8];
@@ -1453,6 +1492,9 @@
case ESesc:
vc_state = ESnormal;
switch (c) {
+ case '?':
+ respond_all_translation(currcons,tty);
+ return;
case '[':
vc_state = ESsquare;
return;
@@ -1478,6 +1520,9 @@
case 'Z':
respond_ID(tty);
return;
+ case 'C':
+ respond_charset(currcons,tty);
+ return;
case '7':
save_cur(currcons);
return;
@@ -1706,6 +1751,9 @@
case ESpercent:
vc_state = ESnormal;
switch (c) {
+ case '?':
+ respond_utf(currcons,tty);
+ return;
case '@': /* defined in ISO 2022 */
utf = 0;
return;
@@ -1731,7 +1779,11 @@
}
return;
case ESsetG0:
- if (c == '0')
+ if (c == '?') {
+ respond_G0(currcons,tty);
+ return;
+ }
+ else if (c == '0')
G0_charset = GRAF_MAP;
else if (c == 'B')
G0_charset = LAT1_MAP;
@@ -1744,7 +1796,11 @@
vc_state = ESnormal;
return;
case ESsetG1:
- if (c == '0')
+ if (c == '?') {
+ respond_G1(currcons,tty);
+ return;
+ }
+ else if (c == '0')
G1_charset = GRAF_MAP;
else if (c == 'B')
G1_charset = LAT1_MAP;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/