#!/usr/bin/python

import pyatspi

def listener(e):
    try:
        if e.source.getRole() == pyatspi.ROLE_TERMINAL:
            return
    except:
        return

    try:
        text = e.source.queryText()
    except NotImplementedError:
        return

    print("Text removed: <%s>. Current text: <%s>" % (e.any_data, text.getText(0, -1)))


pyatspi.Registry.registerEventListener(listener, "object:text-changed:delete")
pyatspi.Registry.start()
