shithub: orca

Download patch

ref: 9d431352a71d801b59a75dcf9660a96ba940a413
parent: 0652c46879f990dd88a1a0e93f7e3c75a041eeeb
author: cancel <cancel@cancel.fm>
date: Sat Nov 24 04:27:43 EST 2018

Reformat comments and add more information

--- a/main.c
+++ b/main.c
@@ -1,11 +1,28 @@
+#include <locale.h>
 #include <ncurses.h>
 
 int main() {
-  initscr();            // Initialize ncurses
-  raw();                // Receive keyboard input immediately
-  noecho();             // Don't echo keyboard input
-  keypad(stdscr, TRUE); // Also receive arrow keys, etc.
-  curs_set(0);          // Hide the terminal cursor
+  // Enable UTF-8 by explicitly initializing our locale before initializing
+  // ncurses.
+  setlocale(LC_ALL, "");
+  // Initialize ncurses
+  initscr();
+  // Allow ncurses to control newline translation. Fine to use with any modern
+  // terminal, and will let ncurses run faster.
+  nonl();
+  // Set interrupt keys (interrupt, break, quit...) to not flush. Helps keep
+  // ncurses state consistent, at the cost of less responsive terminal
+  // interrupt. (This will rarely happen.)
+  intrflush(stdscr, FALSE);
+  // Receive keyboard input immediately, and receive shift, control, etc. as
+  // separate events, instead of combined with individual characters.
+  raw();
+  // Don't echo keyboard input
+  noecho();
+  // Also receive arrow keys, etc.
+  keypad(stdscr, TRUE);
+  // Hide the terminal cursor
+  curs_set(0);
 
   printw("Type any character to see it in bold\n");
   refresh();