This project is a fully functional terminal emulator application for Windows.
- Local terminal emulation on Windows.
- Tabbed interface for managing multiple terminal sessions.
- Support for text-based UI applications like
VIM
andhtop
will work when ssh'd to a linux host. - Customizable appearance and behavior.
tkinter
: Standard GUI toolkit for Python used for the application interface.pyte
: A simple VTXXX-compatible terminal emulator library used for interpreting escape sequences and managing the terminal state.uuid
: For generating unique identifiers for terminal sessions.threading
: For managing concurrent operations.winpty
: A Windows software package providing an interface to the Windows pseudo terminal (WinPTY).
App
: The main application class that initializes the GUI, manages terminal tabs, and handles user interactions.Terminal
: A class representing a single terminal instance. It handles the rendering of the terminal screen, input events, and terminal resizing.WinPtyHandler
: This class manages the interaction with the local Windows command line, encapsulating the functionality provided by WinPTY.KeyHandler
: A utility class for interpreting keyboard input and sending it to the terminal.
The core of the terminal emulation is handled by pyte
. Here's how it's integrated into our application:
-
Terminal Output Handling: When output from the command line is available, it is fed into
pyte
'sByteStream
object.pyte
interprets this data, which includes processing escape sequences and maintaining an in-memory representation of the terminal's screen. -
Screen Rendering: The
Terminal
class translatespyte
's in-memory screen into text and colors in thetkinter.Text
widget. This involves converting the screen's character cells into styled text that can be displayed in the GUI. -
Input Handling: User input from the keyboard is captured by the
KeyHandler
and sent to theWinPtyHandler
. For remote connections, input would be sent via an SSH channel. -
Terminal Resizing: When the terminal window is resized, both
pyte
andWinPtyHandler
are informed of the new dimensions.pyte
uses this information to update its screen model, andWinPtyHandler
adjusts the pseudo terminal accordingly. -
Session Management: Each terminal tab has a unique session, identified by a UUID. This allows for multiple independent terminal sessions within the application.
To run the application, ensure you have Python installed and the required packages available. Clone the repository, and run the main script:
python main_winpty.py
Contributions to the project are welcome. Please fork the repository and submit a pull request with your enhancements.
This project is licensed under the GPLv3 License - see the LICENSE file for details.
# Create a wheel
pip install wheel setuptools
python setup.py sdist bdist_wheel