From 542743fd978ca83eda460b137f9ed76fe7802c9c Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 29 Oct 2023 11:49:29 -0400 Subject: [PATCH] Added text input thing... --- xurses.c | 31 +++++++++++++++++-------------- xurses.h | 2 ++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/xurses.c b/xurses.c index 659dce4..a593b7c 100644 --- a/xurses.c +++ b/xurses.c @@ -113,6 +113,8 @@ int curses_screen_width = 0; int curses_screen_height = 0; int curses_active = 1; +char curses_character = '\0'; + /* External function definitions. */ void curses_configure (void) { @@ -151,12 +153,14 @@ void curses_configure (void) { void curses_synchronize (void) { int signal; - curses_signal = signal = 0; + curses_signal = curses_character = signal = 0; out (curses_screen, CURSES_REVERT + CURSES_FORMAT * curses_screen_width * curses_screen_height + CURSES_CURSOR); in (& signal, 4); + curses_character = (char) signal; + if ((char) signal == '\033') { curses_signal |= SIGNAL_ESCAPE; } else if (character_is_digit ((char) signal) != 0) { @@ -207,6 +211,10 @@ void curses_render_cursor (int x, int y) { } void curses_render_character (char character, int colour, int effect, int x, int y) { + if ((x >= curses_screen_width) || (y >= curses_screen_height)) { + return; + } + string_copy_limit (curses_screen_offset (x, y), curses_format_character (character, colour, effect), CURSES_FORMAT); } @@ -224,24 +232,19 @@ void curses_render_string_point (char * string, int limit, int colour, int effec int offset; for (offset = 0; offset != limit; ++offset) { - if (* x + offset < curses_screen_width) { - if (string [offset] == '\n') { - * x = curses_realign_x; - * y += 1; - } else if (string [offset] == '\t') { - * x += curses_tab_width; - } else { - curses_render_character (string [offset], colour, effect, * x, * y); - * x += 1; - } + if (string [offset] == '\n') { + * x = curses_realign_x; + * y += 1; + } else if (string [offset] == '\t') { + * x += curses_tab_width; } else { - curses_render_character ('+', COLOUR_GREY, EFFECT_BOLD, * x, * y); - return; + curses_render_character (string [offset], colour, effect, * x, * y); + * x += 1; } } } -void curses_render_number_point (int number, int limit, int colour, int effect, int * x, int * y) { +void curses_render_number_point (int number, int limit, int colour, int effect, int * x, int * y) { (void) number; (void) limit; (void) colour; diff --git a/xurses.h b/xurses.h index a34e937..0502425 100644 --- a/xurses.h +++ b/xurses.h @@ -17,6 +17,8 @@ extern int curses_screen_width; extern int curses_screen_height; extern int curses_active; +extern char curses_character; + extern void curses_configure (void); extern void curses_synchronize (void);