From e6dc670c1d8c9fa686c75c840609ed718899f92f Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Fri, 25 Oct 2019 15:34:56 -0400 Subject: [PATCH] Complete step 176 --- src/Editor.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Editor.php b/src/Editor.php index 04890c4..eb9cae0 100644 --- a/src/Editor.php +++ b/src/Editor.php @@ -528,7 +528,21 @@ class Editor { for ($i = 0; $i < $len; $i++) { - if ($hl[$i] === Highlight::NORMAL) + // Handle 'non-printable' characters + if (is_cntrl($c[$i])) + { + $sym = (ord($c[$i]) <= 26) + ? chr(ord('@') + ord($c[$i])) + : '?'; + $this->ab .= "\x1b[7m"; + $this->ab .= $sym; + $this->ab .= "\x1b[m"; + if ($currentColor !== -1) + { + $this->ab .= sprintf("\x1b%dm", $currentColor); + } + } + else if ($hl[$i] === Highlight::NORMAL) { if ($currentColor !== -1) {