From aa509105295147246c16258534ce989994c75bf5 Mon Sep 17 00:00:00 2001 From: "Adam D. Ruppe" Date: Thu, 23 Jan 2020 14:51:06 -0500 Subject: [PATCH] 16 bit console title --- terminal.d | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/terminal.d b/terminal.d index caa3ca7..7f1cffd 100644 --- a/terminal.d +++ b/terminal.d @@ -187,7 +187,6 @@ version(Posix) { version(Windows) { import core.sys.windows.windows; - import std.string : toStringz; private { enum RED_BIT = 4; enum GREEN_BIT = 2; @@ -1179,7 +1178,16 @@ http://msdn.microsoft.com/en-us/library/windows/desktop/ms683193%28v=vs.85%29.as /// Changes the terminal's title void setTitle(string t) { version(Windows) { - SetConsoleTitleA(toStringz(t)); + wchar[256] buffer; + size_t bufferLength; + foreach(wchar ch; t) + if(bufferLength < buffer.length) + buffer[bufferLength++] = ch; + if(bufferLength < buffer.length) + buffer[bufferLength++] = 0; + else + buffer[$-1] = 0; + SetConsoleTitleW(buffer.ptr); } else { import std.string; if(terminalInFamily("xterm", "rxvt", "screen"))