Reading text in Python text buffer from VteTerminal in Gtk3 app

178 views Asked by At

So I am making a Matlab-like app, which I am open sourcing. Right now I just have a functional source editor and gnome-terminal, https://github.com/3LP/M.O.B. Its not very flashy but I am adding functionality until I graduate in June. I want to be able to scan the commands executed in the terminal. This snippet of code in the app:

  terminal = Vte.Terminal()
  term = terminal.get_text()
  print(term)

Gives gobbledygook as output:('\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', [, , , , , , , , , , , , , , , , , , , , , , , ])

I want to grab text from users commands, and scan them for instances of certain command executions. Like when a user executes 'Python'. Any suggestions on possible solutions? I spent last night researching methods but I had no success.

1

There are 1 answers

1
goodguyAbaddon On

you can intercept the signal 'commit'; this is the C reference, i think there is a binding for python. https://developer.gnome.org/vte/unstable/VteTerminal.html#VteTerminal-commit