Search code examples
gtkvte

New line in Virtual Terminal


I am trying to send commands in a Virtual Terminal using gtk. My code is

from gi.repository import Gtk, Vte
from gi.repository import GLib
import os

terminal     = Vte.Terminal()
terminal.fork_command_full(
    Vte.PtyFlags.DEFAULT,
    os.environ['HOME'],
    ["/bin/sh"],
    [],
    GLib.SpawnFlags.DO_NOT_REAP_CHILD,
    None,
    None,
    )

terminal.feed("----------------- \n ")
terminal.feed("Virtual Terminal \n")
terminal.feed("----------------- \n")

win = Gtk.Window()
win.connect('delete-event', Gtk.main_quit)
win.add(terminal)
win.show_all()

Gtk.main()

But what I get is:

enter image description here

When I would like something more simmilar like this:

enter image description here


Solution

  • I would suggest sending \r\n to return the cursor to the beginning of each new line.