Added os_get_text_style() to ease restoring after interruptions.
authorDavid Griffith <dave@661.org>
Sat, 29 Apr 2023 04:11:42 +0000 (21:11 -0700)
committerDavid Griffith <dave@661.org>
Sat, 29 Apr 2023 05:50:45 +0000 (22:50 -0700)
int os_get_text_style(void) returns the current style.
I'll probably want os_get_font_style() soon.

src/common/frotz.h
src/curses/ux_init.c
src/curses/ux_text.c

index 82a688a9adbe2a73cacad48f7db0148969d40e56..591377691e992ffb95670fda9b74ae2d47383fb9 100644 (file)
@@ -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);
index 5dcefa0d5ee374eec02c001fe056ca83a1cbb397..cad454904ef16ea6c143fd6b6ee428bbcb419777 100644 (file)
@@ -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();
index 91026c65a1ddb11b071a47a3566c64547d63e389..bbf9204a2dca5b7503c2e568aa79a3a0fbd17f80 100644 (file)
@@ -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
  *