console window caption on windows

This commit is contained in:
Vadim Lopatin 2016-09-13 16:08:06 +03:00
parent 380bc94f19
commit 62a1a156b9
2 changed files with 16 additions and 1 deletions

View File

@ -143,13 +143,14 @@ class ConsolePlatform : Platform {
_drawBuf.fillRect(Rect(0, 0, w.width, w.height), w.backgroundColor);
w.onDraw(_drawBuf);
auto caretRect = w.caretRect;
if ((w is activeWindow) && !caretRect.empty) {
if ((w is activeWindow)) {
if (!caretRect.empty) {
_drawBuf.console.setCursor(caretRect.left, caretRect.top);
_drawBuf.console.setCursorType(w.caretReplace ? ConsoleCursorType.Replace : ConsoleCursorType.Insert);
} else {
_drawBuf.console.setCursorType(ConsoleCursorType.Invisible);
}
_drawBuf.console.setWindowCaption(w.windowCaption);
}
}
}

View File

@ -485,6 +485,20 @@ class Console {
}
}
private dstring _windowCaption;
void setWindowCaption(dstring str) {
if (_windowCaption == str)
return;
_windowCaption = str;
version(Windows) {
import std.utf;
SetConsoleTitle(toUTF16z(str));
} else {
// TODO: ANSI terminal caption
}
}
private ConsoleCursorType _rawCursorType = ConsoleCursorType.Insert;
protected void rawSetCursorType(ConsoleCursorType type) {
if (_rawCursorType == type)