Skip to content

Commit

Permalink
fix arrow keys when searching
Browse files Browse the repository at this point in the history
  • Loading branch information
paigeruten committed Apr 7, 2017
1 parent dbc9995 commit 42c9672
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions doc/05.aTextEditor.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
2 changes: 1 addition & 1 deletion leg.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions steps.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 42c9672

Please sign in to comment.