terminal: Escape sequence handling fixes
terminal: Escape sequence handling fixes

Upgrade and refactor terminal_data to properly handle non-csi escape
codes, control characters in escape codes, and invalid escape sequences.
Also fix a buffer overflow in the escape sequence buffer.

Signed-off-by: Callum Lowcay <30277750103c2cd3d9ca2faae7875553e95d86f7@callumscode.com>

giucam/weston,udoprog/weston,tulcod/wayland,mchalupa/wayland,eyolfson/wayland,jonnylamb/weston,Gnurou/weston,Fantu/compositor-spice,sir-murray/wayland,Fantu/compositor-spice,krezovic/weston,abooij/wayland,jonnylamb/weston,eyolfson/weston,abooij/wayland,bitfactor/wayland,kwm81/weston,sir-murray/weston,mchalupa/wayland,krezovic/weston,sir-murray/weston,eyolfson/wayland,udoprog/weston,Tarnyko/weston-xdg_surface_present,kwm81/weston,eyolfson/weston,mchalupa/weston,mchalupa/weston,tulcod/wayland,sir-murray/wayland,Fantu/compositor-spice,bitfactor/wayland,abooij/wayland,eyolfson/wayland,mchalupa/wayland,sir-murray/wayland,bitfactor/wayland,xorgy/weston,xorgy/weston,tulcod/wayland,Gnurou/weston,giucam/weston,Tarnyko/weston-xdg_surface_present