simon-git: putty (main): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Sat Oct 16 14:07:50 BST 2021
TL;DR:
e744071a Remove some unused variables.
4f41bc04 Charset-aware handling of C1 ST in OSC sequences.
c35d8b83 win_set_[icon_]title: send a codepage along with the string.
Repository: https://git.tartarus.org/simon/putty.git
On the web: https://git.tartarus.org/?p=simon/putty.git
Branch updated: main
Committer: Simon Tatham <anakin at pobox.com>
Date: 2021-10-16 14:07:50
commit e744071a033e223ebdc8bb8e3bbab53ee649e3a3
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=e744071a033e223ebdc8bb8e3bbab53ee649e3a3;hp=54930cf784163294ce1211b9d7c3c91b372e13ef
Author: Simon Tatham <anakin at pobox.com>
Date: Sat Oct 16 11:54:43 2021 +0100
Remove some unused variables.
clang warned about these in the recent bidi work.
terminal/bidi.c | 4 ++--
terminal/bidi_test.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
commit 4f41bc04ab27953cce112070b796b52a8d0de52d
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=4f41bc04ab27953cce112070b796b52a8d0de52d;hp=e744071a033e223ebdc8bb8e3bbab53ee649e3a3
Author: Simon Tatham <anakin at pobox.com>
Date: Sat Oct 16 11:47:06 2021 +0100
Charset-aware handling of C1 ST in OSC sequences.
When the terminal is in UTF-8 mode, we accumulate UTF-8 text normally
in the OSC string buffer - but the byte 0x9C is interpreted as the C1
control character String Terminator, which terminates the OSC
sequence. That's not really what you want in UTF-8 mode, because 0x9C
is also a perfectly normal UTF-8 continuation character. For example,
you'd expect this to set the window title to "FÃNF":
echo -ne '\033]0;FÃNF\007'
but in fact, by the sheer chance that à is encoded with an 0x9C byte,
you get a window title consisting of "F" followed by an illegal-
encoding marker, and the OSC sequence is terminated abruptly so that
the trailing 'NF' is printed normally to the terminal and then the BEL
generates a beep.
Now, in UTF-8 mode, we only support the C1 control for ST if it
appears in the form of the proper UTF-8 encoding of U+009C. So that
example now 'works', at least in the sense that the terminal considers
the OSC sequence to terminate where the sender expected it to
terminate.
Another case where we interpret 0x9C inappropriately as ST is if the
terminal is in a single-byte character set in which that character is
a printing one. In CP437, for example, you can't set a window title
containing a pound sign, because its encoding is 0x9C.
This commit by itself doesn't make those window titles _work_, in the
sense of coming out looking right. They just mean that the OSC
sequence is not terminated at the wrong place. The actual title
rendering will be fixed in the next commit.
terminal/terminal.c | 96 +++++++++++++++++++++++++++++++++++++++++++----------
terminal/terminal.h | 2 +-
2 files changed, 79 insertions(+), 19 deletions(-)
commit c35d8b832801d926a16ad29c416b969654051ef0
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=c35d8b832801d926a16ad29c416b969654051ef0;hp=4f41bc04ab27953cce112070b796b52a8d0de52d
Author: Simon Tatham <anakin at pobox.com>
Date: Sat Oct 16 13:20:44 2021 +0100
win_set_[icon_]title: send a codepage along with the string.
While fixing the previous commit I noticed that window titles don't
actually _work_ properly if you change the terminal character set,
because the text accumulated in the OSC string buffer is sent to the
TermWin as raw bytes, with no indication of what character set it
should interpret them as. You might get lucky if you happened to
choose the right charset (in particular, UTF-8 is a common default),
but if you change the charset half way through a run, then there's
certainly no way the frontend will know to interpret two window titles
sent before and after the change in two different charsets.
So, now win_set_title() and win_set_icon_title() both include a
codepage parameter along with the byte string, and it's up to them to
translate the provided window title from that encoding to whatever the
local window system expects to receive.
On Windows, that's wide-string Unicode, so we can just use the
existing dup_mb_to_wc utility function. But in GTK, it's UTF-8, so I
had to write an extra utility function to encode a wide string as
UTF-8.
fuzzterm.c | 4 ++--
misc.h | 5 +++++
putty.h | 14 ++++++++------
terminal/terminal.c | 11 +++++++++--
terminal/terminal.h | 1 +
unix/window.c | 20 ++++++++++++++++----
utils/CMakeLists.txt | 1 +
utils/dup_mb_to_wc.c | 28 ++++++++++++++++++++++++++++
utils/encode_wide_string_as_utf8.c | 25 +++++++++++++++++++++++++
windows/window.c | 31 ++++++++++++++++---------------
10 files changed, 111 insertions(+), 29 deletions(-)
More information about the tartarus-commits
mailing list