Added cursor position options

modified:   src/nms.c
	modified:   src/nms.h
	modified:   src/sneakers.c
This commit is contained in:
Brian Barto 2016-04-20 17:51:36 -04:00
parent 227b5a7344
commit 9f1ec97e3f
3 changed files with 9 additions and 1 deletions

View File

@ -228,6 +228,10 @@ char nmsexec(NmsArgs *args) {
// Flush any input up to this point
flushinp();
// Position cursor
if (args->input_cursor_y >= 0 && args->input_cursor_x >= 0)
move(args->input_cursor_y, args->input_cursor_x);
// If stdin is set to the keyboard, user must press a key to continue
if (isatty(STDIN_FILENO)) {
ret = getch();

View File

@ -1,11 +1,13 @@
#ifndef NMS_H
#define NMS_H 1
#define INIT_NMSARGS { .src = NULL, .return_opts = NULL }
#define INIT_NMSARGS { .src = NULL, .return_opts = NULL, .input_cursor_x = -1, .input_cursor_y = -1 }
typedef struct {
char *src;
char *return_opts;
int input_cursor_x;
int input_cursor_y;
} NmsArgs;
// Function prototypes

View File

@ -157,6 +157,8 @@ int main(void) {
// Set needed args
args.src = display;
args.return_opts = "123456";
args.input_cursor_y = 18;
args.input_cursor_x = ((termCols - strlen(foot2Center)) / 2) + 1;
// Display characters
input = nmsexec(&args);