Better fix for blocking programmatic input

Blocking programmatic input from the time when the user starts editing
the text file to the time when focus is lost.