Commit Graph

375 Commits

Author SHA1 Message Date
Ryan Prichard
a364522006 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-24 03:03:25 -08:00
Ryan Prichard
b2f15c8f27 Fix terminal output bugs in the TestNet client.
* If the client was unable to write any data, write would return -1 with
   errno==EAGAIN, and the client would assert fail.

 * Apparently I thought that continue would jump to the start of the
   do-while(0) loop.  Replace the continue/do-while(0) with a
   did_something flag.

While I'm at it, replace a few hard-coded constants with constants.
2011-11-24 03:03:25 -08:00
Ryan Prichard
7e4b19dc79 Check in two test programs. 2011-11-24 03:03:25 -08:00
Ryan Prichard
9712f74b76 First cut at incremental console output scraping.
- On each polling, identify a range of lines to scan.  This range will
   include lines in the history if output has scrolled.

 - Line in scrapeOutput and the terminal output routines (e.g.
   sendLineToTerminal) are numbered as if writing to an infinitely-sized
   terminal.

 - Once history is large enough, write a string to column 1 ~200 lines
   up.  This synchronizing marker lets us know how much the console output
   has scrolled.

 - Freeze the console output by putting the console into select/mark mode.
   Unfreeze it by sending an ESC keypress.
2011-11-24 03:03:25 -08:00
Ryan Prichard
f77557aa95 Add a Win32Console class that provides a simpler, Qt/C++ interface to the
Win32 Console API.
2011-11-24 03:03:25 -08:00
Ryan Prichard
c74f82abdb Pass an initial window size to the agent on startup.
* The TestNet protocol starts with a terminal resize escape sequence, so
   the server discards all input until it sees the sequence, and it delays
   starting the agent.  Eventually, the goal is to implement an SSH server,
   and the SSH message that creates a PTY also provides the terminal size.
2011-11-24 03:03:25 -08:00
Ryan Prichard
662b140c62 Add a test program that uses the ioctl-like console interface to scroll
and write.
2011-11-24 03:03:25 -08:00
Ryan Prichard
8647405a6d Add comments regarding capturing console output. 2011-11-24 03:03:25 -08:00
Ryan Prichard
0bb71ee53c In the Unix client, send a resize escape sequence on startup and when the
terminal window is resized.
2011-11-24 03:03:25 -08:00
Ryan Prichard
166c553f15 Add initial server support for resizing terminal windows. 2011-11-24 03:03:25 -08:00
Ryan Prichard
3ae1f5f9a7 Add a TODO describing an EDIT/NTVDM-related bug. 2011-11-24 03:03:25 -08:00
Ryan Prichard
b491fd6378 Add a UnixSignalHandler class. It emits a Qt signal when a Unix signal is
handled.

Use the UnixSignalHandler to detect terminal resizing.  The client doesn't
do anything with the terminal size yet.  It should send the size to the
server.
2011-11-24 03:03:25 -08:00
Ryan Prichard
af5a742e57 Two Unix client changes:
* Use disconnected instead of readChannelFinished.

 * Fix a serious bug in doServerToClient.
2011-11-24 03:03:25 -08:00
Ryan Prichard
e3ce5c0ff0 Checkpoint work on the Windows server.
* Use disconnected() instead of readChannelFinished().

 * Cleanup.  There are three bidirectional pipes conceptually:
      console <-> agent
      agent <-> server
      server <-> client
   If one end of a pipe dies, start closing the other end, then clean up.
   If the console dies (e.g. because cmd.exe exits), we still want to
   collect the final console output and send it to the client.

   To help with this, in the Agent, I call GetConsoleProcessList, then
   scrapeOutput, then (potentially) disconnectFromServer.
2011-11-24 03:03:25 -08:00
Ryan Prichard
f9b713dc57 In the Unix client, stop the program when the read channel finishes. 2011-11-24 03:03:25 -08:00
Ryan Prichard
c0c261b2b5 Add simplistic console output polling in the server and feed the output
to the client.
2011-11-24 03:03:25 -08:00
Ryan Prichard
73bd43d051 Implement the Unix TestNet client. 2011-11-24 03:03:25 -08:00
Ryan Prichard
f70b2bd772 Add a mostly empty TestNetClient project. 2011-11-24 03:03:25 -08:00
Ryan Prichard
a7ae78b9b1 Add test programs that echo their input to stdout. 2011-11-24 03:03:25 -08:00
Ryan Prichard
d473320350 Rename TelnetServer to TestNetServer to accurately reflect its actual
functionality.
2011-11-24 03:03:25 -08:00
Ryan Prichard
7898332d9e Remove the older pre-Qt code. 2011-11-24 03:03:24 -08:00
Ryan Prichard
6021840a1f Checkpoint Console work.
- Add a very incomplete "telnet" server.  It doesn't recognize any telnet
   commands, so it's "telnet" only in the sense that I can connect to the
   server and type commands.  The commands are fed to a Win32 Console, but
   I don't get to see the output over the network.

 - Move AgentClient to the Shared directory and move QtEvent-specific code
   out of it.

 - Move the startShell routine into the AgentClient so I can share it
   between the different console-consuming prototypes.
2011-11-24 03:03:05 -08:00
Ryan Prichard
22b4de90b8 Checkpoint a reimplementation that uses Qt extensively.
- Use QMake instead of CMake.

 - Use QLocalSocket/QLocalServer to access Win32 named pipes.
2011-10-31 02:19:18 -07:00
Ryan Prichard
6009fcaf7b Checkpoint of console work.
The agent process uses shared memory and events now instead of pipes.
2011-10-30 17:59:27 -07:00
Ryan Prichard
6e8f04139a Initial commit of console work. 2011-10-30 15:07:02 -07:00