MCPcopy Create free account
hub / github.com/git/git / write_console

Function write_console

compat/winansi.c:106–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104#define MAX_PARAMS 16
105
106static void write_console(unsigned char *str, size_t len)
107{
108 /* only called from console_thread, so a static buffer will do */
109 static wchar_t wbuf[2 * BUFFER_SIZE + 1];
110 DWORD dummy;
111
112 /* convert utf-8 to utf-16 */
113 int wlen = xutftowcsn(wbuf, (char*) str, ARRAY_SIZE(wbuf), len);
114 if (wlen < 0) {
115 const wchar_t *err = L"[invalid]";
116 WriteConsoleW(console, err, wcslen(err), &dummy, NULL);
117 return;
118 }
119
120 /* write directly to console */
121 WriteConsoleW(console, wbuf, wlen, &dummy, NULL);
122
123 /* remember if non-ascii characters are printed */
124 if (wlen != len)
125 non_ascii_used = 1;
126}
127
128#define FOREGROUND_ALL (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE)
129#define BACKGROUND_ALL (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)

Callers 1

console_threadFunction · 0.85

Calls 1

xutftowcsnFunction · 0.85

Tested by

no test coverage detected