snaptoken / kilo-tutorial

build your own text editor
http://viewsourcecode.org/snaptoken/kilo
825 stars 80 forks source link

Text reordering suggestion on step 30 #21

Closed mtn closed 7 years ago

mtn commented 7 years ago

In step 30 (getWindowSize fallback), we have the following:

Because we’re always returning -1 (meaning an error occurred) from getWindowSize() at this point, we make a call to editorReadKey() so we can observe the results of our escape sequences before the program calls die() and clears the screen. When you run the program, you should see the cursor is positioned at the bottom-right corner of the screen, and then when you press a key you’ll see the error message printed by die() after it clears the screen.

Also notice we are sticking a 1 || at the front of our if condition temporarily, so that we can test this fallback branch we are developing.

The opposite (paragraph) ordering reads more logically, in my opinion. We're always returning -1 at this point because we've stuck the 1 || at the front of our conditional. Any thoughts?

If you give the thumbs up, I'm happy to make a pull request. Thanks for putting all of this together! :turtle:

paigeruten commented 7 years ago

You're right, thanks for catching that! You can go ahead and make a pull request. Maybe change 'Also notice' to 'Note that', which I think would flow better with the new ordering.

mtn commented 7 years ago

Sounds great! I'll pull it together by tomorrow.