diff --git a/CHANGELOG.md b/CHANGELOG.md index bf24134..ed44ad3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.0.0beta3 (April 7, 2017) + +* In `editorPrompt()`, change `!iscntrl(c)` to `!iscntrl(c) && c < 128`, so + that we don't try to append special keys like the arrow keys to the prompt + input. (Thanks @fmdkdd) + ## 1.0.0beta2 (April 6, 2017) * Replace all instances of `isprint()` with `!iscntrl()`, so that extended @@ -9,7 +15,7 @@ ## 1.0.0beta1 (April 6, 2017) * Add changelog. -* Fix landing page typo. +* Fix landing page typo. (Thanks @mtr) ## 1.0.0beta0 (April 4, 2017) diff --git a/doc/05.aTextEditor.md b/doc/05.aTextEditor.md index c28262d..f049fb5 100644 --- a/doc/05.aTextEditor.md +++ b/doc/05.aTextEditor.md @@ -413,6 +413,11 @@ and allocate that amount of memory before appending to `buf`. We also make sure that `buf` ends with a `\0` character, because both `editorSetStatusMessage()` and the caller of `editorPrompt()` will use it to know where the string ends. +Notice that we have to make sure the input key isn't one of the special keys in +the `editorKey` enum, which have high integer values. To do that, we test +whether the input key is in the range of a `char` by making sure it is less +than `128`. + Now let's prompt the user for a filename in `editorSave()`, when `E.filename` is `NULL`. diff --git a/leg.yml b/leg.yml index 9f6a6e9..cdc2503 100644 --- a/leg.yml +++ b/leg.yml @@ -1,6 +1,6 @@ --- :name: kilo -:version: "1.0.0beta2" +:version: "1.0.0beta3" :title: Build Your Own Text Editor :rouge_theme: github :bold_weight: 500 diff --git a/steps.diff b/steps.diff index 22acac4..81af52c 100644 --- a/steps.diff +++ b/steps.diff @@ -3106,7 +3106,7 @@ diff --git a/kilo.c b/kilo.c + editorSetStatusMessage(""); + return buf; + } -+ } else if (!iscntrl(c)) { ++ } else if (!iscntrl(c) && c < 128) { + if (buflen == bufsize - 1) { + bufsize *= 2; + buf = realloc(buf, bufsize); @@ -3330,7 +3330,7 @@ diff --git a/kilo.c b/kilo.c + if (callback) callback(buf, c); return buf; } - } else if (!iscntrl(c)) { + } else if (!iscntrl(c) && c < 128) { @@ -594,6 +596,8 @@ char *editorPrompt(char *prompt) { buf[buflen++] = c; buf[buflen] = '\0';