about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-04-20 12:35:47 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-04-20 12:36:05 -0700
commit54d48b25a08b5b238371b2d1bd0f594dad8dbeb9 (patch)
tree150507eb0c81dfbb26e7d79b16d71ff672b5369c /cpp
parent07efdfd7072d84209b419e66e5a2b48a0c78b2ac (diff)
downloadmu-54d48b25a08b5b238371b2d1bd0f594dad8dbeb9.tar.gz
1111 - start adding ncurses primitives
Diffstat (limited to 'cpp')
-rw-r--r--cpp/070console34
-rw-r--r--cpp/console.mu5
-rw-r--r--cpp/makefile2
3 files changed, 40 insertions, 1 deletions
diff --git a/cpp/070console b/cpp/070console
new file mode 100644
index 00000000..18faffb6
--- /dev/null
+++ b/cpp/070console
@@ -0,0 +1,34 @@
+//: Text-mode cursor primitives. Currently thin wrappers around ncurses calls.
+
+:(before "End Includes")
+#include<ncurses.h>
+
+:(before "End Primitive Recipe Declarations")
+CONSOLE_MODE,
+:(before "End Primitive Recipe Numbers")
+Recipe_number["console-mode"] = CONSOLE_MODE;
+:(before "End Primitive Recipe Implementations")
+case CONSOLE_MODE: {
+  initscr();
+  break;
+}
+
+:(before "End Primitive Recipe Declarations")
+RETRO_MODE,
+:(before "End Primitive Recipe Numbers")
+Recipe_number["retro-mode"] = RETRO_MODE;
+:(before "End Primitive Recipe Implementations")
+case RETRO_MODE: {
+  endwin();
+  break;
+}
+
+:(before "End Primitive Recipe Declarations")
+WAIT_FOR_KEY,
+:(before "End Primitive Recipe Numbers")
+Recipe_number["wait-for-key"] = WAIT_FOR_KEY;
+:(before "End Primitive Recipe Implementations")
+case WAIT_FOR_KEY: {
+  getch();
+  break;
+}
diff --git a/cpp/console.mu b/cpp/console.mu
new file mode 100644
index 00000000..04eee3a2
--- /dev/null
+++ b/cpp/console.mu
@@ -0,0 +1,5 @@
+recipe main [
+  console-mode 0:literal/screen
+  wait-for-key
+  retro-mode 0:literal/screen
+]
diff --git a/cpp/makefile b/cpp/makefile
index 69b7318e..1d4cf9a7 100644
--- a/cpp/makefile
+++ b/cpp/makefile
@@ -1,5 +1,5 @@
 mu: makefile enumerate/enumerate tangle/tangle mu.cc
-	g++ -g -Wall -Wextra -fno-strict-aliasing mu.cc -o mu
+	g++ -g -Wall -Wextra -fno-strict-aliasing mu.cc -lncurses -o mu
 
 # To see what the program looks like after all layers have been applied, read
 # mu.cc