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 // Set needed args
args.src = input; args.src = input;
args.show_cursor = true;
// Display characters // Display characters
nms_exec(&args); nms_exec(&args);

View File

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

View File

@ -1,13 +1,16 @@
#ifndef NMS_H #ifndef NMS_H
#define NMS_H 1 #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 { typedef struct {
char *src; char *src;
char *return_opts; char *return_opts;
int input_cursor_x; int input_cursor_x;
int input_cursor_y; int input_cursor_y;
bool show_cursor;
} NmsArgs; } NmsArgs;
// Function prototypes // Function prototypes