From 1bf43eacb929e0651f854f038fba83feced2a9e9 Mon Sep 17 00:00:00 2001 From: cancel Date: Sat, 24 Nov 2018 08:13:49 +0900 Subject: [PATCH] Init with basic test --- .clang-format | 2 ++ .gitignore | 46 ++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 20 ++++++++++++++++++++ README.md | 1 + main.c | 23 +++++++++++++++++++++++ 5 files changed, 92 insertions(+) create mode 100644 .clang-format create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 main.c diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..c183cb7 --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: LLVM +PointerAlignment: Left diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0fc719f --- /dev/null +++ b/.gitignore @@ -0,0 +1,46 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Default build dir +build/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f726897 --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +basic_flags := -std=c99 -Wall -Wpedantic -Wextra +debug_flags := -DDEBUG -O0 -ggdb -feliminate-unused-debug-symbols +library_flags := -lncurses +source_files := main.c + +all: debug + +build: + mkdir $@ + +build/debug build/release: | build + mkdir $@ + +.PHONY: debug +debug: | build/debug + cc $(basic_flags) $(debug_flags) $(source_files) -o build/debug/acro $(library_flags) + +.PHONY: clean +clean: + rm -rf build diff --git a/README.md b/README.md new file mode 100644 index 0000000..4b30baa --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +A basic starting point for an ncurses C99 program. diff --git a/main.c b/main.c new file mode 100644 index 0000000..5f01970 --- /dev/null +++ b/main.c @@ -0,0 +1,23 @@ +#include + +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 + + printw("Type any character to see it in bold\n"); + refresh(); + int ch = getch(); + printw("Your character:\n"); + attron(A_BOLD); + printw(" %c\n", ch); + attroff(A_BOLD); + printw("Press any key to exit"); + attroff(A_BOLD); + refresh(); + getch(); + endwin(); + return 0; +}