mcde: readable computer names in the network view; Remote Login's title
The names the computers announce are UTF-8; CDE's ISO 8859-1 interface fonts showed a typographic quote as three wrong characters. The usual punctuation becomes ASCII before it is shown. dtremotelogin names its window "Remote Login", then after the computer, with an xterm title sequence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d95f0fc8af
commit
ee91a9ffbc
2 files changed
+44
-2
No files matched your search
@@ -66,6 +66,40 @@ static struct {
|
||||
char pendingUrl[600], pendingMount[1100];
|
||||
} nv;
|
||||
|
||||
/*
|
||||
* A name as the computers announce it is UTF-8 ("Konrad\u2019s computer");
|
||||
* CDE's interface fonts are ISO 8859-1 and show the typographic quote as
|
||||
* three wrong characters (measured with a real announcement). The usual
|
||||
* punctuation becomes its ASCII form; the rest is left as it is.
|
||||
*/
|
||||
static void
|
||||
Plain(const char *in, char *out, size_t len)
|
||||
{
|
||||
static const struct { const char *utf8, *ascii; } map[] = {
|
||||
{ "\xe2\x80\x98", "'" }, { "\xe2\x80\x99", "'" },
|
||||
{ "\xe2\x80\x9c", "\"" }, { "\xe2\x80\x9d", "\"" },
|
||||
{ "\xe2\x80\x93", "-" }, { "\xe2\x80\x94", "-" },
|
||||
{ "\xe2\x80\xa6", "..." }, { "\xc2\xa0", " " },
|
||||
};
|
||||
size_t o = 0, i, n;
|
||||
|
||||
while (*in != '\0' && o + 4 < len) {
|
||||
for (i = 0; i < sizeof map / sizeof map[0]; i++) {
|
||||
n = strlen(map[i].utf8);
|
||||
if (strncmp(in, map[i].utf8, n) == 0)
|
||||
break;
|
||||
}
|
||||
if (i < sizeof map / sizeof map[0]) {
|
||||
n = strlen(map[i].utf8);
|
||||
o += (size_t) snprintf(out + o, len - o, "%s",
|
||||
map[i].ascii);
|
||||
in += n;
|
||||
} else
|
||||
out[o++] = *in++;
|
||||
}
|
||||
out[o] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
Note(const char *text)
|
||||
{
|
||||
@@ -86,7 +120,12 @@ AddItem(ItemKind k, const char *text, const char *label)
|
||||
nv.kind[nv.nitems] = k;
|
||||
snprintf(nv.item[nv.nitems], sizeof nv.item[0], "%s", text);
|
||||
nv.nitems++;
|
||||
s = XmStringCreateLocalized((char *) label);
|
||||
{
|
||||
char plain[512];
|
||||
|
||||
Plain(label, plain, sizeof plain);
|
||||
s = XmStringCreateLocalized(plain);
|
||||
}
|
||||
XmListAddItemUnselected(nv.itemList, s, 0);
|
||||
XmStringFree(s);
|
||||
}
|
||||
@@ -371,7 +410,7 @@ Browse(XtPointer client, XtIntervalId *id)
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < nv.nhosts; i++) {
|
||||
snprintf(label, sizeof label, "%s", nv.hosts[i].name);
|
||||
Plain(nv.hosts[i].name, label, sizeof label);
|
||||
s = XmStringCreateLocalized(label);
|
||||
XmListAddItemUnselected(nv.hostList, s, 0);
|
||||
XmStringFree(s);
|
||||
|
||||
@@ -6,9 +6,12 @@
|
||||
# panel's Network drawer). Asks for user@computer, runs ssh(1); when ssh
|
||||
# fails the window stays until Return, so its message can be read.
|
||||
#
|
||||
# the title of the tab and the window (an xterm title sequence, TermParse.c)
|
||||
printf '\033]0;Remote Login\007'
|
||||
printf 'Connect to (user@computer): '
|
||||
read -r host || exit 0
|
||||
[ -n "$host" ] || exit 0
|
||||
printf '\033]0;%s\007' "$host"
|
||||
ssh "$host" && exit 0
|
||||
printf '\nPress Return to close. '
|
||||
read -r _
|
||||
Reference in new issue
Block a user