Skip to content

Commit

Permalink
Explicit narrow cast to short
Browse files Browse the repository at this point in the history
Eliminate Warning C4838: conversion from [X] to 'SHORT' requires a narrowing conversion
  • Loading branch information
refack committed Dec 3, 2018
1 parent 823d841 commit 43825d0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions clink/terminal/src/win_screen_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ void win_screen_buffer::set_cursor(int column, int row)
int width = (window.Right - window.Left) + 1;
int height = (window.Bottom - window.Top) + 1;

column = clamp(column, 0, width);
row = clamp(row, 0, height);
SHORT s_column = clamp(column, 0, width);
SHORT s_row = clamp(row, 0, height);

COORD xy = { window.Left + column, window.Top + row };
COORD xy = { window.Left + s_column, window.Top + s_row };
SetConsoleCursorPosition(m_handle, xy);
}

Expand All @@ -172,6 +172,9 @@ void win_screen_buffer::move_cursor(int dx, int dy)
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(m_handle, &csbi);

SHORT s_dx = dx;
SHORT s_dy = dy;

COORD xy = {
clamp(csbi.dwCursorPosition.X + dx, 0, csbi.dwSize.X - 1),
clamp(csbi.dwCursorPosition.Y + dy, 0, csbi.dwSize.Y - 1),
Expand Down

0 comments on commit 43825d0

Please sign in to comment.