From cc0d7d4dd1f6819156c45a6a5fc221fad1cbd121 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Fri, 28 Apr 2023 21:11:42 -0700 Subject: [PATCH] Added os_get_text_style() to ease restoring after interruptions. int os_get_text_style(void) returns the current style. I'll probably want os_get_font_style() soon. --- src/common/frotz.h | 1 + src/curses/ux_init.c | 7 ++++--- src/curses/ux_text.c | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/common/frotz.h b/src/common/frotz.h index 82a688a..5913776 100644 --- a/src/common/frotz.h +++ b/src/common/frotz.h @@ -902,6 +902,7 @@ int os_from_true_colour(zword); void os_set_cursor(int, int); void os_set_font(int); void os_set_text_style(int); +int os_get_text_style(void); void os_start_sample(int, int, int, zword); void os_stop_sample(int); int os_storyfile_seek(FILE *, long, int); diff --git a/src/curses/ux_init.c b/src/curses/ux_init.c index 5dcefa0..cad4549 100644 --- a/src/curses/ux_init.c +++ b/src/curses/ux_init.c @@ -134,11 +134,11 @@ void os_warn (const char *s, ...) if (u_setup.curses_active) { os_beep(BEEP_HIGH); - style = u_setup.current_text_style; + style = os_get_text_style(); os_set_text_style(BOLDFACE_STYLE); print_c_string("Warning: "); - print_c_string(errorstring); os_set_text_style(NORMAL_STYLE); + print_c_string(errorstring); new_line(); os_set_text_style(style); } else @@ -171,10 +171,11 @@ void os_fatal (const char *s, ...) style = u_setup.current_text_style; os_set_text_style(BOLDFACE_STYLE); print_c_string("Fatal error: "); - os_set_text_style(style); + os_set_text_style(NORMAL_STYLE); print_c_string(errorstring); print_c_string("\n"); new_line(); + os_set_text_style(style); if (f_setup.ignore_errors) { print_c_string("Continuing anyway..."); new_line(); diff --git a/src/curses/ux_text.c b/src/curses/ux_text.c index 91026c6..bbf9204 100644 --- a/src/curses/ux_text.c +++ b/src/curses/ux_text.c @@ -158,6 +158,22 @@ void os_set_colour (int new_foreground, int new_background) } /* os_set_colour */ +/* + * os_get_text_style + * + * Return the current text style. Following flags can be set: + * + * REVERSE_STYLE + * BOLDFACE_STYLE + * EMPHASIS_STYLE (aka underline aka italics) + * FIXED_WIDTH_STYLE + * + */ +int os_get_text_style (void) +{ + return u_setup.current_text_style; +} /* os_get_text_style */ + /* * os_set_text_style * -- 2.34.1