Re: Terminal Emulator

2024-05-14 Thread Cameron Simpson via Python-list

On 14May2024 18:44, Gordinator  wrote:
I wish to write a terminal emulator in Python. I am a fairly competent 
Python user, and I wish to try a new project idea. What references can 
I use when writing my terminal emulator? I wish for it to be a true 
terminal emulator as well, not just a Tk text widget or something like 
that.


Start with the `pty` module.
--
https://mail.python.org/mailman/listinfo/python-list


RE: Terminal Emulator

2024-05-14 Thread AVI GROSS via Python-list
The topic was to re-invent the wheel yet again and create a terminal
emulator.

I hesitate to say this but one approach is to consider the curses module as
described by our very own Alan Gauld in a book:

https://www.amazon.com/Programming-curses-Python-Alan-Gauld-ebook/dp/B091B85
B77

The topic is how to make a terminal emulator and as Alan mentions, each kind
of terminal may accept various kinds of escape sequences. There are files
available the are normally used by curses to get a description of sorts of
the capabilities and details of a terminal like a VT100 that curses can use
to decide what stream of bytes to send to update a screen.

You might be able to use something similar, or better, to see what your
terminal emulator should emulate.

And, it may even be possible for you to emulate lots of terminals with the
same basic code.

-Original Message-
From: Python-list  On
Behalf Of Alan Gauld via Python-list
Sent: Tuesday, May 14, 2024 3:07 PM
To: Gordinator ; python-list@python.org
Subject: Re: Terminal Emulator

On 14/05/2024 18:44, Gordinator via Python-list wrote:
> I wish to write a terminal emulator in Python. I am a fairly competent 
> Python user, and I wish to try a new project idea. What references can I 
> use when writing my terminal emulator? I wish for it to be a true 
> terminal emulator as well, not just a Tk text widget or something like
that.

The first thing is to decide which terminal. A VT100 is very different
from a 3270. And even a VT330 is quite different from a VT100 although
sharing a common subset of control codes. And if you start looking at
graphical terminals things get even more interesting!

The other thing to consider is whether it will be a standalone app or
a GUI component. If the latter do you want to expose your own API or
clone the manufacturers? Or both?!
Or you could make it an object that can be used both in GUIs and in
"robotic" or "batch" mode. So many options.

Most of the specs are available online and there must be dozens of
terminal emulators around written in C so you should have plenty
of sample code to study. Good luck!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Terminal Emulator

2024-05-14 Thread Mirko via Python-list

Am 14.05.24 um 19:44 schrieb Gordinator via Python-list:
I wish to write a terminal emulator in Python. I am a fairly 
competent Python user, and I wish to try a new project idea. What 
references can I use when writing my terminal emulator? I wish for 
it to be a true terminal emulator as well, not just a Tk text widget 
or something like that.


If you have any advice, please do let me know!



Not sure, what you mean with:


true terminal emulator as well, not just a Tk text widget or something like that
If you want to write a GUI terminal, than that *is* a terminal 
emulator and *has* a text widget as its visible core. If you want to 
write something like getty which runs on the virtual terminals 
(Ctrl+Alt+F*) than that is a terminal (not a terminal emulator).


In both cases, you write something that gets input from the 
keyboard, processes it and shows the result. How that processing is 
done, depends on the terminal standard, like DEC VT{100, 102, 220, 
320, etc}.


For a start, you might want to look at Terminator, which is a 
terminal emulator written in Python, Gtk and libvte (which does all 
the low level stuff).

--
https://mail.python.org/mailman/listinfo/python-list


Re: Terminal Emulator

2024-05-14 Thread Grant Edwards via Python-list
On 2024-05-14, Alan Gauld via Python-list  wrote:
> On 14/05/2024 18:44, Gordinator via Python-list wrote:
>
>> I wish to write a terminal emulator in Python. I am a fairly
>> competent Python user, and I wish to try a new project idea. What
>> references can I use when writing my terminal emulator? I wish for
>> it to be a true terminal emulator as well, not just a Tk text
>> widget or something like that.
>
> The first thing is to decide which terminal.

If you want to make life easier, make it a superset of a terminal that
already exists in the terminfo database.

Going with some sort of ANSI terminal will probably provide
operability even with dumb apps which ignore $TERM and just spit out
basic ANSI escape sequences.

If you really want to break trail, you could invent your own control
sequences, which means you'll have to write terminfo and/or termcap
entries as well as the terminal emulator.

> A VT100 is very different from a 3270. And even a VT330 is quite
> different from a VT100 although sharing a common subset of control
> codes. And if you start looking at graphical terminals things get
> even more interesting!

"Intersting" is putting it mildly...





-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Terminal Emulator

2024-05-14 Thread Grant Edwards via Python-list
On 2024-05-14, Alan Gauld via Python-list  wrote:
> On 14/05/2024 18:44, Gordinator via Python-list wrote:
>
>> I wish to write a terminal emulator in Python. I am a fairly
>> competent Python user, and I wish to try a new project idea. What
>> references can I use when writing my terminal emulator? I wish for
>> it to be a true terminal emulator as well, not just a Tk text
>> widget or something like that.
>
> The first thing is to decide which terminal.

You also need to decide if you're going to support real serial ports
or just ptys.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Terminal Emulator

2024-05-14 Thread Alan Gauld via Python-list
On 14/05/2024 18:44, Gordinator via Python-list wrote:
> I wish to write a terminal emulator in Python. I am a fairly competent 
> Python user, and I wish to try a new project idea. What references can I 
> use when writing my terminal emulator? I wish for it to be a true 
> terminal emulator as well, not just a Tk text widget or something like that.

The first thing is to decide which terminal. A VT100 is very different
from a 3270. And even a VT330 is quite different from a VT100 although
sharing a common subset of control codes. And if you start looking at
graphical terminals things get even more interesting!

The other thing to consider is whether it will be a standalone app or
a GUI component. If the latter do you want to expose your own API or
clone the manufacturers? Or both?!
Or you could make it an object that can be used both in GUIs and in
"robotic" or "batch" mode. So many options.

Most of the specs are available online and there must be dozens of
terminal emulators around written in C so you should have plenty
of sample code to study. Good luck!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


-- 
https://mail.python.org/mailman/listinfo/python-list


Terminal Emulator

2024-05-14 Thread Gordinator via Python-list
I wish to write a terminal emulator in Python. I am a fairly competent 
Python user, and I wish to try a new project idea. What references can I 
use when writing my terminal emulator? I wish for it to be a true 
terminal emulator as well, not just a Tk text widget or something like that.


If you have any advice, please do let me know!
--
https://mail.python.org/mailman/listinfo/python-list