Hello world curses app

This commit is contained in:
2018-01-06 18:11:44 -08:00
parent 3db304e893
commit a576e43001
8 changed files with 128 additions and 1 deletions

7
ui/BUILD Normal file
View File

@@ -0,0 +1,7 @@
cc_library(
name="ui",
srcs = ["base.c"],
hdrs = ["base.h"],
deps = ["@system_include//:curses"],
visibility = ["//visibility:public"],
)

17
ui/base.c Normal file
View File

@@ -0,0 +1,17 @@
#include "base.h"
#include <curses.h>
#include <string.h>
void draw_text(int *x, int *y, char *text) {
size_t len = strlen(text);
if (!len) return;
mvaddch(*x, *y, text[0]);
for (size_t i=1; i < strlen(text); i++) {
addch(text[i]);
}
getyx(stdscr, *y, *x);
}

10
ui/base.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef UI_BASE_H_
#define UI_BASE_H_
/**
* Prints the string text starting at position *x, *y. x and y are updated to
* the position after the last character
*/
void draw_text(int *x, int *y, char *text);
#endif // UI_BASE_H_