From e7ae2325a89260b5be2b60bff87a3da3ff328cd0 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 12 May 2015 10:22:26 +0200 Subject: [PATCH] Fixed Visual Studio warning C4204 (nonstandard extension used : non-constant aggregate initializer) --- linenoise.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/linenoise.c b/linenoise.c index 17303b1..fb2b680 100644 --- a/linenoise.c +++ b/linenoise.c @@ -642,9 +642,12 @@ static void clearScreen(struct current *current) static void cursorToLeft(struct current *current) { - COORD pos = { 0, (SHORT)current->y }; + COORD pos; DWORD n; + pos.X = 0; + pos.Y = (SHORT)current->y; + FillConsoleOutputAttribute(current->outh, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN, current->cols, pos, &n); current->x = 0; @@ -652,9 +655,12 @@ static void cursorToLeft(struct current *current) static int outputChars(struct current *current, const char *buf, int len) { - COORD pos = { (SHORT)current->x, (SHORT)current->y }; + COORD pos; DWORD n; + pos.X = (SHORT)current->x; + pos.Y = (SHORT)current->y; + WriteConsoleOutputCharacter(current->outh, buf, len, pos, &n); current->x += len; return 0; @@ -662,9 +668,12 @@ static int outputChars(struct current *current, const char *buf, int len) static void outputControlChar(struct current *current, char ch) { - COORD pos = { (SHORT)current->x, (SHORT)current->y }; + COORD pos; DWORD n; + pos.X = (SHORT) current->x; + pos.Y = (SHORT) current->y; + FillConsoleOutputAttribute(current->outh, BACKGROUND_INTENSITY, 2, pos, &n); outputChars(current, "^", 1); outputChars(current, &ch, 1); @@ -672,15 +681,21 @@ static void outputControlChar(struct current *current, char ch) static void eraseEol(struct current *current) { - COORD pos = { (SHORT)current->x, (SHORT)current->y }; + COORD pos; DWORD n; + pos.X = (SHORT) current->x; + pos.Y = (SHORT) current->y; + FillConsoleOutputCharacter(current->outh, ' ', current->cols - current->x, pos, &n); } static void setCursorPos(struct current *current, int x) { - COORD pos = { (SHORT)x, (SHORT)current->y }; + COORD pos; + + pos.X = (SHORT)x; + pos.Y = (SHORT) current->y; SetConsoleCursorPosition(current->outh, pos); current->x = x; -- 2.44.0