Added option to show cursor during "type" and "jumble" loops.

modified:   src/main.c
	modified:   src/nms.c
	modified:   src/nms.h
This commit is contained in:
Brian Barto 2016-04-20 18:16:19 -04:00
parent 36cf124a0d
commit 53f3835195
3 changed files with 10 additions and 2 deletions

View File

@ -17,6 +17,7 @@ int main(void) {
// Set needed args
args.src = input;
args.show_cursor = true;
// Display characters
nms_exec(&args);

View File

@ -63,6 +63,8 @@ char nms_exec(NmsArgs *args) {
cbreak();
noecho();
scrollok(stdscr, true);
if (args->show_cursor == false)
curs_set(0);
// Setting up and starting colors if terminal supports them
if (has_colors()) {
@ -222,8 +224,10 @@ char nms_exec(NmsArgs *args) {
flushinp();
// Position cursor
if (args->input_cursor_y >= 0 && args->input_cursor_x >= 0)
if (args->input_cursor_y >= 0 && args->input_cursor_x >= 0) {
move(args->input_cursor_y, args->input_cursor_x);
curs_set(1);
}
// If stdin is set to the keyboard, user must press a key to continue
if (isatty(STDIN_FILENO)) {

View File

@ -1,13 +1,16 @@
#ifndef NMS_H
#define NMS_H 1
#define INIT_NMSARGS { .src = NULL, .return_opts = NULL, .input_cursor_x = -1, .input_cursor_y = -1 }
#include <stdbool.h>
#define INIT_NMSARGS { NULL, NULL, -1, -1, false }
typedef struct {
char *src;
char *return_opts;
int input_cursor_x;
int input_cursor_y;
bool show_cursor;
} NmsArgs;
// Function prototypes