2011-10-31 09:19:18 +00:00
|
|
|
#ifndef AGENT_H
|
|
|
|
#define AGENT_H
|
|
|
|
|
|
|
|
#include <QObject>
|
Record a high-water-mark of "dirty" lines in the console screen buffer
and avoid sending lines in the window that aren't dirty yet.
The idea is that the bottom of the console screen commonly has blank lines
that do not need to be sent to the client, because nothing has been written
there yet. For example, when the console first appears, there is typically
a command-line prompt at the top of the window. When a console is expanded
vertically, blank lines commonly appear at the bottom.
Other misc changes to the output:
- When we send one later, also send all following lines.
- When we save a line into m_bufferData, fill in the rest of the line with
spaces. This way, it's possible to expand the console horizontally
without the agent resending all the lines.
- If nothing on the console has changed, then leave the cursor alone.
Don't hide, show, or move it.
2011-11-21 08:25:14 +00:00
|
|
|
#include <QPoint>
|
2011-10-31 09:19:18 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2011-11-17 11:00:02 +00:00
|
|
|
class Win32Console;
|
2011-10-31 09:19:18 +00:00
|
|
|
class QLocalSocket;
|
2011-11-22 10:31:47 +00:00
|
|
|
class Terminal;
|
2011-10-31 09:19:18 +00:00
|
|
|
class QTimer;
|
2012-02-20 09:23:46 +00:00
|
|
|
class ReadBuffer;
|
2011-10-31 09:19:18 +00:00
|
|
|
|
2011-11-19 10:26:37 +00:00
|
|
|
const int BUFFER_LINE_COUNT = 3000; // TODO: Use something like 9000.
|
|
|
|
const int MAX_CONSOLE_WIDTH = 500;
|
|
|
|
|
2011-10-31 09:19:18 +00:00
|
|
|
class Agent : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-02-20 09:23:46 +00:00
|
|
|
explicit Agent(const QString &controlPipeName,
|
|
|
|
const QString &dataPipeName,
|
2011-11-16 11:25:03 +00:00
|
|
|
int initialCols, int initialRows,
|
|
|
|
QObject *parent = 0);
|
2011-11-12 09:42:33 +00:00
|
|
|
virtual ~Agent();
|
2011-10-31 09:19:18 +00:00
|
|
|
|
2011-11-21 10:03:40 +00:00
|
|
|
private:
|
2012-02-20 09:23:46 +00:00
|
|
|
QLocalSocket *makeSocket(const QString &pipeName);
|
2011-11-22 10:31:47 +00:00
|
|
|
void resetConsoleTracking(bool sendClear = true);
|
2011-11-21 10:03:40 +00:00
|
|
|
|
2011-10-31 09:19:18 +00:00
|
|
|
signals:
|
|
|
|
|
|
|
|
private slots:
|
2012-02-20 09:23:46 +00:00
|
|
|
void controlSocketReadyRead();
|
|
|
|
void handlePacket(ReadBuffer &packet);
|
|
|
|
void handleStartProcessPacket(ReadBuffer &packet);
|
|
|
|
void handleSetSizePacket(ReadBuffer &packet);
|
|
|
|
void dataSocketReadyRead();
|
2011-11-12 09:42:33 +00:00
|
|
|
void socketDisconnected();
|
2011-10-31 09:19:18 +00:00
|
|
|
void pollTimeout();
|
2011-11-16 11:25:03 +00:00
|
|
|
|
|
|
|
private:
|
Record a high-water-mark of "dirty" lines in the console screen buffer
and avoid sending lines in the window that aren't dirty yet.
The idea is that the bottom of the console screen commonly has blank lines
that do not need to be sent to the client, because nothing has been written
there yet. For example, when the console first appears, there is typically
a command-line prompt at the top of the window. When a console is expanded
vertically, blank lines commonly appear at the bottom.
Other misc changes to the output:
- When we send one later, also send all following lines.
- When we save a line into m_bufferData, fill in the rest of the line with
spaces. This way, it's possible to expand the console horizontally
without the agent resending all the lines.
- If nothing on the console has changed, then leave the cursor alone.
Don't hide, show, or move it.
2011-11-21 08:25:14 +00:00
|
|
|
void markEntireWindowDirty();
|
|
|
|
void scanForDirtyLines();
|
2011-11-17 11:00:02 +00:00
|
|
|
void resizeWindow(int cols, int rows);
|
2011-11-12 09:42:33 +00:00
|
|
|
void scrapeOutput();
|
2011-11-19 10:26:37 +00:00
|
|
|
void freezeConsole();
|
|
|
|
void unfreezeConsole();
|
|
|
|
void syncMarkerText(CHAR_INFO *output);
|
|
|
|
int findSyncMarker();
|
|
|
|
void createSyncMarker(int row);
|
|
|
|
|
2011-10-31 09:19:18 +00:00
|
|
|
private:
|
2011-11-17 11:00:02 +00:00
|
|
|
Win32Console *m_console;
|
2012-02-20 09:23:46 +00:00
|
|
|
QLocalSocket *m_controlSocket;
|
|
|
|
QLocalSocket *m_dataSocket;
|
2011-11-22 10:31:47 +00:00
|
|
|
Terminal *m_terminal;
|
2011-10-31 09:19:18 +00:00
|
|
|
QTimer *m_timer;
|
2011-11-19 10:26:37 +00:00
|
|
|
|
2011-11-26 02:34:33 +00:00
|
|
|
bool m_autoShutDown;
|
|
|
|
|
2011-11-19 10:26:37 +00:00
|
|
|
int m_syncRow;
|
|
|
|
int m_syncCounter;
|
|
|
|
|
|
|
|
int m_scrapedLineCount;
|
|
|
|
int m_scrolledCount;
|
|
|
|
int m_maxBufferedLine;
|
|
|
|
CHAR_INFO (*m_bufferData)[MAX_CONSOLE_WIDTH];
|
Record a high-water-mark of "dirty" lines in the console screen buffer
and avoid sending lines in the window that aren't dirty yet.
The idea is that the bottom of the console screen commonly has blank lines
that do not need to be sent to the client, because nothing has been written
there yet. For example, when the console first appears, there is typically
a command-line prompt at the top of the window. When a console is expanded
vertically, blank lines commonly appear at the bottom.
Other misc changes to the output:
- When we send one later, also send all following lines.
- When we save a line into m_bufferData, fill in the rest of the line with
spaces. This way, it's possible to expand the console horizontally
without the agent resending all the lines.
- If nothing on the console has changed, then leave the cursor alone.
Don't hide, show, or move it.
2011-11-21 08:25:14 +00:00
|
|
|
int m_dirtyWindowTop;
|
|
|
|
int m_dirtyLineCount;
|
2011-10-31 09:19:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AGENT_H
|