Added save-restore prompt option to SDL interface with restriction to .aux.
authorDavid Griffith <dave@661.org>
Sun, 30 Apr 2023 22:33:01 +0000 (15:33 -0700)
committerDavid Griffith <dave@661.org>
Thu, 4 May 2023 06:10:55 +0000 (23:10 -0700)
src/sdl/generic.c
src/sdl/sf_fonts.c
src/sdl/sf_images.c
src/sdl/sf_util.c

index cd833a1c3e350d4e842689d5c1b917f5595389a6..e2e1f185d104f94efa46b6a2926f8003074def08 100644 (file)
@@ -267,6 +267,7 @@ void os_warn(const char *s, ...)
        va_list va;
        char buf[1024];
        int len;
+       int style;
 
        /* XXX Too lazy to do this right
         * (try again with a bigger buf if necessary). */
@@ -276,9 +277,10 @@ void os_warn(const char *s, ...)
        /* Solaris 2.6's cc complains if the below cast is missing */
        print_c_string("\n\n");
        os_beep(BEEP_HIGH);
+       style = os_get_text_style();
        os_set_text_style(BOLDFACE_STYLE);
        print_c_string("Warning: ");
-       os_set_text_style(0);
+       os_set_text_style(NORMAL_STYLE);
        print_c_string((len < 0 ? s : buf));
        print_c_string("\n");
        if (len < 0)
@@ -286,6 +288,7 @@ void os_warn(const char *s, ...)
        else if (len >= sizeof(buf))
                print_c_string("(truncated)\n");
        new_line();
+       os_set_text_style(style);
 }
 
 
index a1368aba178b4bdb869cba95c920b0cf39b6cce3..1d08e4ca89952e6321e0f7302e80bae7768b3d17 100644 (file)
@@ -635,6 +635,23 @@ void os_set_font(int new_font)
 }
 
 
+/*
+ * 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 current.style;
+} /* os_get_text_style */
+
+
 /*
  * os_set_text_style
  *
index 1c7ee8991f3f555f4d9aafd5564efc27c194a095..0a5deeac4697206ef86f76b02807276d82081d01 100644 (file)
@@ -227,7 +227,7 @@ static int loadpng(zbyte * data, int length, sf_picture * graphic)
                free(rowPointers);
 
        return 1;
-}
+} /* loadpng */
 
 /****************************************************************************
  * Loader for JPEG images
@@ -410,7 +410,7 @@ static int sf_loadpic(int picture, sf_picture * graphic)
        if (st)
                graphic->number = picture;
        return st;
-}
+} /* sf_loadpic */
 
 /*******************
  * CACHE
index ff1d920645f4b477e8a893ce7af84fc3f9b9ba20..431fc9c8d17a27b18cf130d2d8fc5915e08414d2 100644 (file)
@@ -663,7 +663,14 @@ char *os_read_file_name(const char *default_name, int flag)
         * and our filename is already provided with the -L flag,
         * just go ahead silently.
         */
-       if (f_setup.restore_mode) {
+       if (flag == FILE_NO_PROMPT) {
+               const char *ext = strrchr(default_name, '.');
+               if (strncmp(ext, EXT_AUX, 4)) {
+                       os_warn("Blocked unprompted access of %s. Should only be %s files.", default_name, EXT_AUX);
+                       return NULL;
+               } else 
+                       strncpy(file_name, default_name, FILENAME_MAX);
+       } else if (f_setup.restore_mode) {
                strncpy(file_name, f_setup.save_name, FILENAME_MAX);
        } else {
                st = dialog_read_file_name(file_name, initname, flag);