From 9f1ec97e3f71f230ac7d5a9e3aaac1d08949980a Mon Sep 17 00:00:00 2001 From: Brian Barto Date: Wed, 20 Apr 2016 17:51:36 -0400 Subject: [PATCH] Added cursor position options modified: src/nms.c modified: src/nms.h modified: src/sneakers.c --- src/nms.c | 4 ++++ src/nms.h | 4 +++- src/sneakers.c | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/nms.c b/src/nms.c index 44973e6..d059351 100644 --- a/src/nms.c +++ b/src/nms.c @@ -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(); diff --git a/src/nms.h b/src/nms.h index ce138bc..1bd70f2 100644 --- a/src/nms.h +++ b/src/nms.h @@ -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 diff --git a/src/sneakers.c b/src/sneakers.c index 28ac46d..c91c267 100644 --- a/src/sneakers.c +++ b/src/sneakers.c @@ -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);