GlistEngine
Loading...
Searching...
No Matches
tinyfiledialogs.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: Zlib
2Copyright (c) 2014 - 2025 Guillaume Vareille http://ysengrin.com
3 ____________________________________________________________________
4 | |
5 | 100% compatible C C++ -> You can rename tinfiledialogs.c as .cpp |
6 |____________________________________________________________________|
7
8********* TINY FILE DIALOGS OFFICIAL WEBSITE IS ON SOURCEFORGE *********
9 _________
10 / \ tinyfiledialogs.h v3.20.1 [Sep 25, 2025]
11 |tiny file| Unique header file created [November 9, 2014]
12 | dialogs |
13 \____ ___/ http://tinyfiledialogs.sourceforge.net
14 \| git clone http://git.code.sf.net/p/tinyfiledialogs/code tinyfd
15 ____________________________________________
16| |
17| email: tinyfiledialogs at ysengrin.com |
18|____________________________________________|
19 ________________________________________________________________________________
20| ____________________________________________________________________________ |
21| | | |
22| | - in tinyfiledialogs, char is UTF-8 by default (since v3.6) | |
23| | | |
24| | on windows: | |
25| | - for UTF-16, use the wchar_t functions at the bottom of the header file | |
26| | | |
27| | - _wfopen() requires wchar_t | |
28| | - fopen() uses char but expects ASCII or MBCS (not UTF-8) | |
29| | - if you want char to be MBCS: set tinyfd_winUtf8 to 0 | |
30| | | |
31| | - alternatively, tinyfiledialogs provides | |
32| | functions to convert between UTF-8, UTF-16 and MBCS | |
33| |____________________________________________________________________________| |
34|________________________________________________________________________________|
35
36If you like tinyfiledialogs, please upvote my stackoverflow answer
37https://stackoverflow.com/a/47651444
38
39- License -
40This software is provided 'as-is', without any express or implied
41warranty. In no event will the authors be held liable for any damages
42arising from the use of this software.
43Permission is granted to anyone to use this software for any purpose,
44including commercial applications, and to alter it and redistribute it
45freely, subject to the following restrictions:
461. The origin of this software must not be misrepresented; you must not
47claim that you wrote the original software. If you use this software
48in a product, an acknowledgment in the product documentation would be
49appreciated but is not required.
502. Altered source versions must be plainly marked as such, and must not be
51misrepresented as being the original software.
523. This notice may not be removed or altered from any source distribution.
53
54 __________________________________________
55 | ______________________________________ |
56 | | | |
57 | | DO NOT USE USER INPUT IN THE DIALOGS | |
58 | |______________________________________| |
59 |__________________________________________|
60*/
61
62#ifndef TINYFILEDIALOGS_H
63#define TINYFILEDIALOGS_H
64
65#ifdef __cplusplus
66extern "C" {
67#endif
68
69/******************************************************************************************************/
70/**************************************** UTF-8 on Windows ********************************************/
71/******************************************************************************************************/
72#ifdef _WIN32
73/* On windows, if you want to use UTF-8 ( instead of the UTF-16/wchar_t functions at the end of this file )
74Make sure your code is really prepared for UTF-8 (on windows, functions like fopen() expect MBCS and not UTF-8) */
75extern int tinyfd_winUtf8; /* on windows char strings can be 1:UTF-8(default) or 0:MBCS */
76/* for MBCS change this to 0, in tinyfiledialogs.c or in your code */
77
78/* Here are some functions to help you convert between UTF-16 UTF-8 MBSC */
79char * tinyfd_utf8toMbcs(char const * aUtf8string);
80char * tinyfd_utf16toMbcs(wchar_t const * aUtf16string);
81wchar_t * tinyfd_mbcsTo16(char const * aMbcsString);
82char * tinyfd_mbcsTo8(char const * aMbcsString);
83wchar_t * tinyfd_utf8to16(char const * aUtf8string);
84char * tinyfd_utf16to8(wchar_t const * aUtf16string);
85#endif
86/******************************************************************************************************/
87/******************************************************************************************************/
88/******************************************************************************************************/
89
90/************* 3 funtions for C# (you don't need this in C or C++) : */
91char const * tinyfd_getGlobalChar(char const * aCharVariableName); /* returns NULL on error */
92int tinyfd_getGlobalInt(char const * aIntVariableName); /* returns -1 on error */
93int tinyfd_setGlobalInt(char const * aIntVariableName, int aValue); /* returns -1 on error */
94/* aCharVariableName: "tinyfd_version" "tinyfd_needs" "tinyfd_response"
95 aIntVariableName : "tinyfd_verbose" "tinyfd_silent" "tinyfd_allowCursesDialogs"
96 "tinyfd_forceConsole" "tinyfd_assumeGraphicDisplay" "tinyfd_winUtf8"
97**************/
98
99extern char tinyfd_version[8]; /* contains tinyfd current version number */
100extern char tinyfd_needs[]; /* info about requirements */
101extern int tinyfd_verbose; /* 0 (default) or 1 : on unix, prints the command line calls */
102extern int tinyfd_silent; /* 1 (default) or 0 : on unix, hide errors and warnings from called dialogs */
103
106extern int tinyfd_allowCursesDialogs; /* 0 (default) or 1 */
107
108extern int tinyfd_forceConsole; /* 0 (default) or 1 */
109/* for unix & windows: 0 (graphic mode) or 1 (console mode).
1100: try to use a graphic solution, if it fails then it uses console mode.
1111: forces all dialogs into console mode even when an X server is present.
112 if enabled, it can use the package Dialog or dialog.exe.
113 on windows it only make sense for console applications */
114
115/* extern int tinyfd_assumeGraphicDisplay; */ /* 0 (default) or 1 */
116/* some systems don't set the environment variable DISPLAY even when a graphic display is present.
117set this to 1 to tell tinyfiledialogs to assume the existence of a graphic display */
118
119extern char tinyfd_response[1024];
120/* if you pass "tinyfd_query" as aTitle,
121the functions will not display the dialogs
122but will return 0 for console mode, 1 for graphic mode.
123tinyfd_response is then filled with the retain solution.
124possible values for tinyfd_response are (all lowercase)
125for graphic mode:
126 windows_wchar windows applescript kdialog zenity zenity3 yad matedialog
127 shellementary qarma python2-tkinter python3-tkinter python-dbus
128 perl-dbus gxmessage gmessage xmessage xdialog gdialog dunst
129for console mode:
130 dialog whiptail basicinput no_solution */
131
132void tinyfd_beep(void);
133
135 char const * aTitle, /* NULL or "" */
136 char const * aMessage, /* NULL or "" may contain \n \t */
137 char const * aIconType); /* "info" "warning" "error" */
138 /* return has only meaning for tinyfd_query */
139
141 char const * aTitle , /* NULL or "" */
142 char const * aMessage , /* NULL or "" may contain \n \t */
143 char const * aDialogType , /* "ok" "okcancel" "yesno" "yesnocancel" */
144 char const * aIconType , /* "info" "warning" "error" "question" */
145 int aDefaultButton ) ;
146 /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
147
148char * tinyfd_inputBox(
149 char const * aTitle , /* NULL or "" */
150 char const * aMessage , /* NULL or "" (\n and \t have no effect) */
151 char const * aDefaultInput ) ; /* NULL = passwordBox, "" = inputbox */
152 /* returns NULL on cancel */
153
155 char const * aTitle , /* NULL or "" */
156 char const * aDefaultPathAndOrFile , /* NULL or "" , ends with / to set only a directory */
157 int aNumOfFilterPatterns , /* 0 (1 in the following example) */
158 char const * const * aFilterPatterns , /* NULL or char const * lFilterPatterns[1]={"*.txt"} */
159 char const * aSingleFilterDescription ) ; /* NULL or "text files" */
160 /* returns NULL on cancel */
161
163 char const * aTitle, /* NULL or "" */
164 char const * aDefaultPathAndOrFile, /* NULL or "" , ends with / to set only a directory */
165 int aNumOfFilterPatterns , /* 0 (2 in the following example) */
166 char const * const * aFilterPatterns, /* NULL or char const * lFilterPatterns[2]={"*.png","*.jpg"}; */
167 char const * aSingleFilterDescription, /* NULL or "image files" */
168 int aAllowMultipleSelects ) ; /* 0 or 1 */
169 /* in case of multiple files, the separator is | */
170 /* returns NULL on cancel */
171
173 char const * aTitle, /* NULL or "" */
174 char const * aDefaultPath); /* NULL or "" */
175 /* returns NULL on cancel */
176
178 char const * aTitle, /* NULL or "" */
179 char const * aDefaultHexRGB, /* NULL or "" or "#FF0000" */
180 unsigned char const aDefaultRGB[3] , /* unsigned char lDefaultRGB[3] = { 0 , 128 , 255 }; */
181 unsigned char aoResultRGB[3] ) ; /* unsigned char lResultRGB[3]; */
182 /* aDefaultRGB is used only if aDefaultHexRGB is absent */
183 /* aDefaultRGB and aoResultRGB can be the same array */
184 /* returns NULL on cancel */
185 /* returns the hexcolor as a string "#FF0000" */
186 /* aoResultRGB also contains the result */
187
188
189/************ WINDOWS ONLY SECTION ************************/
190#ifdef _WIN32
191
192/* windows only - utf-16 version */
193int tinyfd_notifyPopupW(
194 wchar_t const * aTitle, /* NULL or L"" */
195 wchar_t const * aMessage, /* NULL or L"" may contain \n \t */
196 wchar_t const * aIconType); /* L"info" L"warning" L"error" */
197
198/* windows only - utf-16 version */
199int tinyfd_messageBoxW(
200 wchar_t const * aTitle, /* NULL or L"" */
201 wchar_t const * aMessage, /* NULL or L"" may contain \n \t */
202 wchar_t const * aDialogType, /* L"ok" L"okcancel" L"yesno" */
203 wchar_t const * aIconType, /* L"info" L"warning" L"error" L"question" */
204 int aDefaultButton ); /* 0 for cancel/no , 1 for ok/yes */
205 /* returns 0 for cancel/no , 1 for ok/yes */
206
207/* windows only - utf-16 version */
208wchar_t * tinyfd_inputBoxW(
209 wchar_t const * aTitle, /* NULL or L"" */
210 wchar_t const * aMessage, /* NULL or L"" (\n nor \t not respected) */
211 wchar_t const * aDefaultInput); /* NULL passwordBox, L"" inputbox */
212
213/* windows only - utf-16 version */
214wchar_t * tinyfd_saveFileDialogW(
215 wchar_t const * aTitle, /* NULL or L"" */
216 wchar_t const * aDefaultPathAndOrFile, /* NULL or L"" , ends with / to set only a directory */
217 int aNumOfFilterPatterns, /* 0 (1 in the following example) */
218 wchar_t const * const * aFilterPatterns, /* NULL or wchar_t const * lFilterPatterns[1]={L"*.txt"} */
219 wchar_t const * aSingleFilterDescription); /* NULL or L"text files" */
220 /* returns NULL on cancel */
221
222/* windows only - utf-16 version */
223wchar_t * tinyfd_openFileDialogW(
224 wchar_t const * aTitle, /* NULL or L"" */
225 wchar_t const * aDefaultPathAndOrFile, /* NULL or L"" , ends with / to set only a directory */
226 int aNumOfFilterPatterns , /* 0 (2 in the following example) */
227 wchar_t const * const * aFilterPatterns, /* NULL or wchar_t const * lFilterPatterns[2]={L"*.png","*.jpg"} */
228 wchar_t const * aSingleFilterDescription, /* NULL or L"image files" */
229 int aAllowMultipleSelects ) ; /* 0 or 1 */
230 /* in case of multiple files, the separator is | */
231 /* returns NULL on cancel */
232
233/* windows only - utf-16 version */
234wchar_t * tinyfd_selectFolderDialogW(
235 wchar_t const * aTitle, /* NULL or L"" */
236 wchar_t const * aDefaultPath); /* NULL or L"" */
237 /* returns NULL on cancel */
238
239/* windows only - utf-16 version */
240wchar_t * tinyfd_colorChooserW(
241 wchar_t const * aTitle, /* NULL or L"" */
242 wchar_t const * aDefaultHexRGB, /* NULL or L"#FF0000" */
243 unsigned char const aDefaultRGB[3], /* unsigned char lDefaultRGB[3] = { 0 , 128 , 255 }; */
244 unsigned char aoResultRGB[3]); /* unsigned char lResultRGB[3]; */
245 /* returns the hexcolor as a string L"#FF0000" */
246 /* aoResultRGB also contains the result */
247 /* aDefaultRGB is used only if aDefaultHexRGB is NULL */
248 /* aDefaultRGB and aoResultRGB can be the same array */
249 /* returns NULL on cancel */
250
251#endif /*_WIN32 */
252
253#ifdef __cplusplus
254} /*extern "C"*/
255#endif
256
257#endif /* TINYFILEDIALOGS_H */
258
259/*
260 ________________________________________________________________________________
261| ____________________________________________________________________________ |
262| | | |
263| | on windows: | |
264| | - for UTF-16, use the wchar_t functions at the bottom of the header file | |
265| | - _wfopen() requires wchar_t | |
266| | | |
267| | - in tinyfiledialogs, char is UTF-8 by default (since v3.6) | |
268| | - but fopen() expects MBCS (not UTF-8) | |
269| | - if you want char to be MBCS: set tinyfd_winUtf8 to 0 | |
270| | | |
271| | - alternatively, tinyfiledialogs provides | |
272| | functions to convert between UTF-8, UTF-16 and MBCS | |
273| |____________________________________________________________________________| |
274|________________________________________________________________________________|
275
276- This is not for ios nor android (it works in termux though).
277- The files can be renamed with extension ".cpp" as the code is 100% compatible C C++
278 (just comment out << extern "C" >> in the header file)
279- Windows is fully supported from XP to 10 (maybe even older versions)
280- C# & LUA via dll, see files in the folder EXTRAS
281- OSX supported from 10.4 to latest (maybe even older versions)
282- Do not use " and ' as the dialogs will be displayed with a warning
283 instead of the title, message, etc...
284- There's one file filter only, it may contain several patterns.
285- If no filter description is provided,
286 the list of patterns will become the description.
287- On windows link against Comdlg32.lib and Ole32.lib
288 (on windows the no linking claim is a lie)
289- On unix: it tries command line calls, so no such need (NO LINKING).
290- On unix you need one of the following:
291 applescript, kdialog, zenity, matedialog, shellementary, qarma, yad,
292 python (2 or 3)/tkinter/python-dbus (optional), Xdialog
293 or curses dialogs (opens terminal if running without console).
294- One of those is already included on most (if not all) desktops.
295- In the absence of those it will use gdialog, gxmessage or whiptail
296 with a textinputbox. If nothing is found, it switches to basic console input,
297 it opens a console if needed (requires xterm + bash).
298- for curses dialogs you must set tinyfd_allowCursesDialogs=1
299- You can query the type of dialog that will be used (pass "tinyfd_query" as aTitle)
300- String memory is preallocated statically for all the returned values.
301- File and path names are tested before return, they should be valid.
302- tinyfd_forceConsole=1; at run time, forces dialogs into console mode.
303- On windows, console mode only make sense for console applications.
304- On windows, console mode is not implemented for wchar_T UTF-16.
305- Mutiple selects are not possible in console mode.
306- The package dialog must be installed to run in curses dialogs in console mode.
307 It is already installed on most unix systems.
308- On osx, the package dialog can be installed via
309 http://macappstore.org/dialog or http://macports.org
310- On windows, for curses dialogs console mode,
311 dialog.exe should be copied somewhere on your executable path.
312 It can be found at the bottom of the following page:
313 http://andrear.altervista.org/home/cdialog.php
314*/
int tinyfd_allowCursesDialogs
Definition tinyfiledialogs.c:133
void tinyfd_beep(void)
Definition tinyfiledialogs.c:4406
int tinyfd_setGlobalInt(char const *aIntVariableName, int aValue)
Definition tinyfiledialogs.c:489
int tinyfd_getGlobalInt(char const *aIntVariableName)
Definition tinyfiledialogs.c:474
char * tinyfd_selectFolderDialog(char const *aTitle, char const *aDefaultPath)
Definition tinyfiledialogs.c:7318
char tinyfd_needs[]
Definition tinyfiledialogs.c:175
int tinyfd_forceConsole
Definition tinyfiledialogs.c:134
char tinyfd_response[1024]
Definition tinyfiledialogs.c:146
char * tinyfd_inputBox(char const *aTitle, char const *aMessage, char const *aDefaultInput)
Definition tinyfiledialogs.c:5695
int tinyfd_silent
Definition tinyfiledialogs.c:130
char * tinyfd_colorChooser(char const *aTitle, char const *aDefaultHexRGB, unsigned char const aDefaultRGB[3], unsigned char aoResultRGB[3])
Definition tinyfiledialogs.c:7632
char tinyfd_version[8]
Definition tinyfiledialogs.c:114
char const * tinyfd_getGlobalChar(char const *aCharVariableName)
Definition tinyfiledialogs.c:464
int tinyfd_messageBox(char const *aTitle, char const *aMessage, char const *aDialogType, char const *aIconType, int aDefaultButton)
Definition tinyfiledialogs.c:4477
int tinyfd_notifyPopup(char const *aTitle, char const *aMessage, char const *aIconType)
Definition tinyfiledialogs.c:5468
char * tinyfd_openFileDialog(char const *aTitle, char const *aDefaultPathAndOrFile, int aNumOfFilterPatterns, char const *const *aFilterPatterns, char const *aSingleFilterDescription, int aAllowMultipleSelects)
Definition tinyfiledialogs.c:6741
int tinyfd_verbose
Definition tinyfiledialogs.c:129
char * tinyfd_saveFileDialog(char const *aTitle, char const *aDefaultPathAndOrFile, int aNumOfFilterPatterns, char const *const *aFilterPatterns, char const *aSingleFilterDescription)
Definition tinyfiledialogs.c:6280