Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructured documentation -- now we have a tutorial! not a very help…
…ful one though
- Loading branch information
1 parent
758da06
commit 4294eb1
Showing
5 changed files
with
85 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
.. _api: | ||
|
||
|
||
API | ||
=== | ||
API reference | ||
============= | ||
|
||
.. automodule:: pyte | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. include:: ../CHANGES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
.. _tutorial: | ||
|
||
Tutorial | ||
-------- | ||
|
||
There are two important classes in ``pyte``: :class:`~pyte.screens.Screen` | ||
and :class:`~pyte.streams.Stream`. The `Screen` is the terminal screen | ||
emulator. It maintains an in-memory buffer of text and text-attributes | ||
to display on screen. The `Stream` is the stream processor. It manages | ||
the state of the input and dispatches events to anything that's listening | ||
about things that are going on. Events are things like ``LINEFEED``, | ||
``DRAW "a"``, or ``CURSOR_POSITION 10 10``. See the :ref:`API reference <api>` | ||
for more details. | ||
|
||
In general, if you just want to know what's being displayed on screen you | ||
can do something like the following: | ||
|
||
>>> import pyte | ||
>>> screen = pyte.Screen(80, 24) | ||
>>> stream = pyte.Stream() | ||
>>> stream.attach(screen) | ||
>>> stream.feed("Hello World!") | ||
>>> screen.display | ||
['Hello World! ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' '] | ||
|
||
|
||
**Note**: ``Screen`` has no idea what is the source of bytes, fed into ``Stream``, | ||
so, obviously, it **can't read** or **change** environment variables, which implies | ||
that: | ||
|
||
* it doesn't adjust `LINES` and `COLUMNS` on ``"resize"`` event; | ||
* it doesn't use locale settings (`LC_*` and `LANG`); | ||
* it doesn't use `TERM` value and expects it to be `"linux"` and only `"linux"`. |