Set of changes to improve detection of escape sequences for prompt width
computation. Addresses #767