Upgrade line counters to 64 bits.
Fixes https://github.com/rprichard/winpty/issues/48
This commit is contained in:
parent
bf7b3c328a
commit
c82849f5b6
@ -437,7 +437,7 @@ void Agent::clearBufferLines(
|
||||
{
|
||||
ASSERT(!m_directMode);
|
||||
for (int row = firstRow; row < firstRow + count; ++row) {
|
||||
const int bufLine = row + m_scrolledCount;
|
||||
const int64_t bufLine = row + m_scrolledCount;
|
||||
m_maxBufferedLine = std::max(m_maxBufferedLine, bufLine);
|
||||
m_bufferData[bufLine % BUFFER_LINE_COUNT].blank(attributes);
|
||||
}
|
||||
@ -641,7 +641,7 @@ void Agent::directScrapeOutput(const ConsoleScreenBufferInfo &info)
|
||||
}
|
||||
|
||||
m_terminal->finishOutput(
|
||||
std::pair<int, int>(
|
||||
std::pair<int, int64_t>(
|
||||
constrained(0, cursor.X - scrapeRect.Left, w - 1),
|
||||
constrained(0, cursor.Y - scrapeRect.Top, h - 1)));
|
||||
}
|
||||
@ -697,8 +697,8 @@ void Agent::scrollingScrapeOutput(const ConsoleScreenBufferInfo &info)
|
||||
ASSERT(m_dirtyLineCount >= 1);
|
||||
|
||||
// The first line to scrape, in virtual line coordinates.
|
||||
const int firstVirtLine = std::min(m_scrapedLineCount,
|
||||
windowRect.top() + m_scrolledCount);
|
||||
const int64_t firstVirtLine = std::min(m_scrapedLineCount,
|
||||
windowRect.top() + m_scrolledCount);
|
||||
|
||||
// Read all the data we will need from the console. Start reading with the
|
||||
// first line to scrape, but adjust the the read area upward to account for
|
||||
@ -706,8 +706,8 @@ void Agent::scrollingScrapeOutput(const ConsoleScreenBufferInfo &info)
|
||||
// bottom of the window. (It's not clear to me whether the
|
||||
// m_dirtyLineCount adjustment here is strictly necessary. It isn't
|
||||
// necessary so long as the cursor is inside the current window.)
|
||||
const int firstReadLine = std::min(firstVirtLine - m_scrolledCount,
|
||||
m_dirtyLineCount - 1);
|
||||
const int firstReadLine = std::min<int>(firstVirtLine - m_scrolledCount,
|
||||
m_dirtyLineCount - 1);
|
||||
const int stopReadLine = std::max(windowRect.top() + windowRect.height(),
|
||||
m_dirtyLineCount);
|
||||
ASSERT(firstReadLine >= 0 && stopReadLine > firstReadLine);
|
||||
@ -724,14 +724,14 @@ void Agent::scrollingScrapeOutput(const ConsoleScreenBufferInfo &info)
|
||||
// be non-dirty.
|
||||
|
||||
// The line to stop scraping at, in virtual line coordinates.
|
||||
const int stopVirtLine = std::min(m_dirtyLineCount,
|
||||
windowRect.top() + windowRect.height()) +
|
||||
const int64_t stopVirtLine =
|
||||
std::min(m_dirtyLineCount, windowRect.top() + windowRect.height()) +
|
||||
m_scrolledCount;
|
||||
|
||||
bool sawModifiedLine = false;
|
||||
|
||||
const int w = m_readBuffer.rect().width();
|
||||
for (int line = firstVirtLine; line < stopVirtLine; ++line) {
|
||||
for (int64_t line = firstVirtLine; line < stopVirtLine; ++line) {
|
||||
const CHAR_INFO *curLine =
|
||||
m_readBuffer.lineData(line - m_scrolledCount);
|
||||
ConsoleLine &bufLine = m_bufferData[line % BUFFER_LINE_COUNT];
|
||||
@ -760,8 +760,9 @@ void Agent::scrollingScrapeOutput(const ConsoleScreenBufferInfo &info)
|
||||
createSyncMarker(newSyncRow);
|
||||
}
|
||||
|
||||
m_terminal->finishOutput(std::pair<int, int>(cursor.X,
|
||||
cursor.Y + m_scrolledCount));
|
||||
m_terminal->finishOutput(
|
||||
std::pair<int, int64_t>(cursor.X,
|
||||
cursor.Y + m_scrolledCount));
|
||||
}
|
||||
|
||||
void Agent::reopenConsole()
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define AGENT_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -106,9 +107,9 @@ private:
|
||||
|
||||
bool m_directMode;
|
||||
Coord m_ptySize;
|
||||
int m_scrapedLineCount;
|
||||
int m_scrolledCount;
|
||||
int m_maxBufferedLine;
|
||||
int64_t m_scrapedLineCount;
|
||||
int64_t m_scrolledCount;
|
||||
int64_t m_maxBufferedLine;
|
||||
LargeConsoleReadBuffer m_readBuffer;
|
||||
std::vector<ConsoleLine> m_bufferData;
|
||||
int m_dirtyWindowTop;
|
||||
|
@ -292,7 +292,7 @@ void Terminal::setConsoleMode(int mode)
|
||||
m_consoleMode = false;
|
||||
}
|
||||
|
||||
void Terminal::reset(SendClearFlag sendClearFirst, int newLine)
|
||||
void Terminal::reset(SendClearFlag sendClearFirst, int64_t newLine)
|
||||
{
|
||||
if (sendClearFirst == SendClear && !m_consoleMode) {
|
||||
// 0m ==> reset SGR parameters
|
||||
@ -302,11 +302,11 @@ void Terminal::reset(SendClearFlag sendClearFirst, int newLine)
|
||||
}
|
||||
m_remoteLine = newLine;
|
||||
m_cursorHidden = false;
|
||||
m_cursorPos = std::pair<int, int>(0, newLine);
|
||||
m_cursorPos = std::pair<int, int64_t>(0, newLine);
|
||||
m_remoteColor = -1;
|
||||
}
|
||||
|
||||
void Terminal::sendLine(int line, const CHAR_INFO *lineData, int width)
|
||||
void Terminal::sendLine(int64_t line, const CHAR_INFO *lineData, int width)
|
||||
{
|
||||
hideTerminalCursor();
|
||||
moveTerminalToLine(line);
|
||||
@ -362,7 +362,7 @@ void Terminal::sendLine(int line, const CHAR_INFO *lineData, int width)
|
||||
}
|
||||
}
|
||||
|
||||
void Terminal::finishOutput(const std::pair<int, int> &newCursorPos)
|
||||
void Terminal::finishOutput(const std::pair<int, int64_t> &newCursorPos)
|
||||
{
|
||||
if (newCursorPos != m_cursorPos)
|
||||
hideTerminalCursor();
|
||||
@ -386,7 +386,7 @@ void Terminal::hideTerminalCursor()
|
||||
m_cursorHidden = true;
|
||||
}
|
||||
|
||||
void Terminal::moveTerminalToLine(int line)
|
||||
void Terminal::moveTerminalToLine(int64_t line)
|
||||
{
|
||||
// Do not use CPL or CNL. Konsole 2.5.4 does not support Cursor Previous
|
||||
// Line (CPL) -- there are "Undecodable sequence" errors. gnome-terminal
|
||||
@ -396,7 +396,7 @@ void Terminal::moveTerminalToLine(int line)
|
||||
if (line < m_remoteLine) {
|
||||
// CUrsor Up (CUU)
|
||||
char buffer[32];
|
||||
sprintf(buffer, "\r" CSI"%dA", m_remoteLine - line);
|
||||
sprintf(buffer, "\r" CSI"%dA", static_cast<int>(m_remoteLine - line));
|
||||
if (!m_consoleMode)
|
||||
m_output->write(buffer);
|
||||
m_remoteLine = line;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define TERMINAL_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@ -35,20 +36,20 @@ class Terminal
|
||||
public:
|
||||
explicit Terminal(NamedPipe *output);
|
||||
enum SendClearFlag { OmitClear, SendClear };
|
||||
void reset(SendClearFlag sendClearFirst, int newLine);
|
||||
void sendLine(int line, const CHAR_INFO *lineData, int width);
|
||||
void finishOutput(const std::pair<int, int> &newCursorPos);
|
||||
void reset(SendClearFlag sendClearFirst, int64_t newLine);
|
||||
void sendLine(int64_t line, const CHAR_INFO *lineData, int width);
|
||||
void finishOutput(const std::pair<int, int64_t> &newCursorPos);
|
||||
void setConsoleMode(int mode);
|
||||
|
||||
private:
|
||||
void hideTerminalCursor();
|
||||
void moveTerminalToLine(int line);
|
||||
void moveTerminalToLine(int64_t line);
|
||||
|
||||
private:
|
||||
NamedPipe *m_output;
|
||||
int m_remoteLine;
|
||||
int64_t m_remoteLine;
|
||||
bool m_cursorHidden;
|
||||
std::pair<int, int> m_cursorPos;
|
||||
std::pair<int, int64_t> m_cursorPos;
|
||||
int m_remoteColor;
|
||||
bool m_consoleMode;
|
||||
std::string m_termLine;
|
||||
|
Loading…
Reference in New Issue
Block a user