file_select_ex(3alleg4)

✨ NAME ✨

file_select_ex β€” pops open the Allegro file selector, but make it cute, with a lil caption on top πŸ’– (this is file_select_ex(3alleg4) from the Allegro manual, bestie, buckle up)


🌸 SYNOPSIS 🌸

#include <allegro.h>

int file_select_ex(const char *message, char *path, const char *ext, int
size, int w, int h);

πŸŽ€ DESCRIPTION πŸŽ€

Okay so this one literally shows you the Allegro file selector, and message is the caption sitting right there on it, like a lil name tag 🏷️.

The path parameter holds the initial filename that gets displayed. You can use it to set the starting directory, or to hand over a default filename when it's a save-as moment (very giving, very "here's a head start, bestie").

When the user picks something, that selection comes back to you by altering the path buffer. The max capacity of that buffer, in bytes, is what you put in size. And listen β€” that buffer should have room for at least 80 characters (not bytes, okay, characters), so honestly just reserve 6x that amount, just to be sure. No cap, protect your buffer πŸ’….

The list of files gets filtered by the file extensions in ext:

  • Passing NULL includes all files. everything. the whole menu 🍽️
  • "PCX;BMP" includes only files with .PCX or .BMP extensions. picky, iconic.

Now if you wanna control files by their attributes, one of the fields in the extension list can start with a slash, and then a set of attribute characters follows. Here's the tea β˜•:

  • Any attribute written on its own, or with a + in front of it β†’ include only files that have that attribute set.
  • Any attribute with a - in front of it β†’ leave out any files with that attribute.

The flag characters are:

  • r β€” read-only
  • h β€” hidden
  • s β€” system
  • d β€” directory
  • a β€” archive

For example, an extension string of "PCX;BMP;/+r-h" will display only PCX or BMP files that are read-only and not hidden. slay, so specific ✨

Heads up though: directories are not affected in the same way as the other files by the extension string. The extensions are never taken into account for them, and the other attributes are taken into account only when 'd' is mentioned in the string. In other words β€” all directories are included when 'd' is not mentioned in the string. directories really said "different rules for me" πŸ’€

The file selector gets stretched to the width and height you pass in w and h, and to the size of the standard Allegro font. And if either the width or height argument is set to zero, it stretches to the corresponding screen dimension instead. zero = auto, main character behavior 🫢

And the return value? This function returns zero if it was closed with the Cancel button, or non-zero if it was OK'd. That's it, that's the whole vibe check 🌈


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie πŸ“ this was file_select_ex(3alleg4) from the Allegro manual, brought to you by Allegro version 4.4.3 β€” go forth and file-select, you've got this πŸ‘‘πŸ’œ