From d60f1c05741f16235a915f167191988fdbd78ab8 Mon Sep 17 00:00:00 2001 From: xolatile Date: Wed, 4 Oct 2023 15:12:51 -0400 Subject: [PATCH] I hate this... (for now) --- install.sh | 2 ++ xurses.c | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index 768ecba..6f66a9d 100644 --- a/install.sh +++ b/install.sh @@ -2,6 +2,8 @@ set -xe +mkdir /usr/include/xolatile + cp xurses.h /usr/include/xolatile/xurses.h cp xurses.c /usr/include/xolatile/xurses.c diff --git a/xurses.c b/xurses.c index 3a2baea..97603d1 100644 --- a/xurses.c +++ b/xurses.c @@ -95,23 +95,25 @@ void curses_screen_offset (void) { } char * curses_screen_position (int x, int y) { - fatal_failure (x <= -1, "curses_screen_position: X position is beyond the lower bound."); - fatal_failure (y <= -1, "curses_screen_position: Y position is beyond the lower bound."); - fatal_failure (x >= curses_screen_width, "curses_screen_position: X position is beyond the upper bound."); - fatal_failure (y >= curses_screen_height, "curses_screen_position: Y position is beyond the upper bound."); + fatal_failure (x <= -1, "curses_screen_position: X position is below the lower bound."); + fatal_failure (y <= -1, "curses_screen_position: Y position is below the lower bound."); + fatal_failure (x >= curses_screen_width, "curses_screen_position: X position is above the upper bound."); + fatal_failure (y >= curses_screen_height, "curses_screen_position: Y position is above the upper bound."); return (& curses_screen [CURSES_LENGTH * (y * curses_screen_width + x) + y * CURSES_RETURN + CURSES_OFFSET]); } char * curses_format_character (char character, int colour, int effect) { - fatal_failure (character_is_invisible (character), "curses_format_character: Can not format invisible characters."); - fatal_failure (colour >= COLOUR_COUNT, "curses_format_character: Colour is invalid enumeration value."); - fatal_failure (effect >= EFFECT_COUNT, "curses_format_character: Effect is invalid enumeration value."); + log_in (LOG_WARNING, character_is_invisible (character), "curses_format_character: Can not format invisible characters."); + log_in (LOG_FAILURE, colour >= COLOUR_COUNT, "curses_format_character: Colour is invalid enumeration value."); + log_in (LOG_FAILURE, effect >= EFFECT_COUNT, "curses_format_character: Effect is invalid enumeration value."); - curses_format [2] = (char) effect + '0'; - curses_format [5] = (char) colour + '0'; + curses_format [2] = (char) (effect % EFFECT_COUNT) + '0'; + curses_format [5] = (char) (colour % COLOUR_COUNT) + '0'; curses_format [7] = character; + log_out ("curses.log"); + return (curses_format); } @@ -119,8 +121,8 @@ void curses_output_character (char character, int colour, int effect) { out (curses_format_character (character, colour, effect), CURSES_LENGTH); } -void curses_render_character (char character, int colour, int effect, int x, int y) { - string_copy_limit (curses_screen_position (x, y), curses_format_character (character, colour, effect), CURSES_LENGTH); +void curses_render_character (char character, int x, int y, int colour, int effect) { + string_copy (curses_screen_position (x, y), curses_format_character (character, colour, effect)); curses_screen_size += CURSES_LENGTH; }