Fix CSI parameter overflow and some hanging problems

This patch fixes the following problems:

1) CSI parameter causes overflow with a long parameter.
ex. "ESC [ 4 2 9 4 9 6 7 2 9 7 m" is treated as "ESC 1 m"

2) The old parser causes hang problem with many parameters.
ex. ESC [ ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; m

3) Window resize sequences (CSI 4 t / CSI 8 t) causes hang problem with large parameters.
ex. ESC [ 4 ; 2 1 4 7 4 8 3 6 3 0 ; 2 1 4 7 4 8 3 6 3 0 t