View | Details | Raw Unified | Return to bug 278181 | Differences between
and this patch

Collapse All | Expand All

(-)b/games/renpy/Makefile (-17 / +33 lines)
Lines 1-47 Link Here
1
PORTNAME=	renpy
1
PORTNAME=	renpy
2
PORTVERSION=	7.4.11
2
PORTVERSION=	8.2.1
3
DISTVERSIONSUFFIX=-sdk
3
DISTVERSIONSUFFIX=-sdk
4
PORTREVISION=	2
4
PORTREVISION=	3
5
CATEGORIES=	games devel
5
CATEGORIES=	games devel
6
MASTER_SITES=	https://www.renpy.org/dl/${PORTVERSION}/
6
MASTER_SITES=	https://www.renpy.org/dl/${PORTVERSION}/
7
7
8
MAINTAINER=	ports@FreeBSD.org
8
MAINTAINER=	social@brandongrows.me
9
COMMENT=	Framework for developing visual-novel type games
9
COMMENT=	Framework for developing visual-novel type games
10
WWW=		https://www.renpy.org/
10
WWW=		https://www.renpy.org/
11
11
12
LICENSE=	APACHE20 BSD3CLAUSE DejaVu LGPL21+ MIT OFL11 ZLIB
12
LICENSE=	APACHE20 BSD3CLAUSE DejaVu LGPL21+ MIT OFL11 ZLIB
13
LICENSE_COMB=	multi
13
LICENSE_COMB=	multi
14
LICENSE_FILE=	${WRKSRC}/LICENSE.txt
15
LICENSE_NAME_DejaVu=	Bitstream Vera and Arev fonts license
14
LICENSE_NAME_DejaVu=	Bitstream Vera and Arev fonts license
15
LICENSE_FILE=	${WRKSRC}/LICENSE.txt
16
LICENSE_FILE_DejaVu=	${WRKSRC}/renpy/common/DejaVuSans.txt
16
LICENSE_FILE_DejaVu=	${WRKSRC}/renpy/common/DejaVuSans.txt
17
LICENSE_PERMS_DejaVu=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
17
LICENSE_PERMS_DejaVu=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
18
18
19
# https://github.com/renpy/renpy/issues/2003
19
# most taken from the official build system here: https://github.com/renpy/renpy-build/blob/master/tasks/python3.py
20
DEPRECATED=	Uses deprecated version of python
21
22
BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}future>0:devel/py-future@${PY_FLAVOR} \
20
BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}future>0:devel/py-future@${PY_FLAVOR} \
23
		${PYTHON_PKGNAMEPREFIX}game_sdl2>0:devel/py-game_sdl2@${PY_FLAVOR}
21
		${PYTHON_PKGNAMEPREFIX}cython>0:lang/cython@${PY_FLAVOR} \
22
		${PYTHON_PKGNAMEPREFIX}ecdsa>0:security/py-ecdsa@${PY_FLAVOR} \
23
		${PYTHON_PKGNAMEPREFIX}six>0:devel/py-six@${PY_FLAVOR} \
24
		${PYTHON_PKGNAMEPREFIX}rsa>0:security/py-rsa@${PY_FLAVOR} \
25
		${PYTHON_PKGNAMEPREFIX}pyasn1>0:devel/py-pyasn1@${PY_FLAVOR} \
26
		${PYTHON_PKGNAMEPREFIX}urllib3>0:net/py-urllib3@${PY_FLAVOR} \
27
		${PYTHON_PKGNAMEPREFIX}charset-normalizer>0:textproc/py-charset-normalizer@${PY_FLAVOR} \
28
		${PYTHON_PKGNAMEPREFIX}certifi>0:security/py-certifi@${PY_FLAVOR} \
29
		${PYTHON_PKGNAMEPREFIX}idna>0:dns/py-idna@${PY_FLAVOR} \
30
		${PYTHON_PKGNAMEPREFIX}requests>0:www/py-requests@${PY_FLAVOR} \
31
		${PYTHON_PKGNAMEPREFIX}pefile>0:devel/py-pefile@${PY_FLAVOR} \
32
		${PYTHON_PKGNAMEPREFIX}cchardet>0:textproc/py-cchardet@${PY_FLAVOR} \
33
		${PYTHON_PKGNAMEPREFIX}websockets>0:devel/py-websockets@${PY_FLAVOR} \
34
		${PYTHON_PKGNAMEPREFIX}game_sdl2>0:devel/py-game_sdl2@${PY_FLAVOR} \
35
		fribidi>0:converters/fribidi \
36
		zenity>0:x11/zenity
24
LIB_DEPENDS=	libfribidi.so:converters/fribidi \
37
LIB_DEPENDS=	libfribidi.so:converters/fribidi \
25
		libpng.so:graphics/png \
38
		libpng.so:graphics/png \
26
		libavcodec.so:multimedia/ffmpeg \
39
		libavcodec.so:multimedia/ffmpeg \
27
		libfreetype.so:print/freetype2
40
		libfreetype.so:print/freetype2 \
41
		libharfbuzz.so:print/harfbuzz
28
RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}future>0:devel/py-future@${PY_FLAVOR} \
42
RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}future>0:devel/py-future@${PY_FLAVOR} \
43
		${PYTHON_PKGNAMEPREFIX}ecdsa>0:security/py-ecdsa@${PY_FLAVOR} \
29
		${PYTHON_PKGNAMEPREFIX}game_sdl2>0:devel/py-game_sdl2@${PY_FLAVOR}
44
		${PYTHON_PKGNAMEPREFIX}game_sdl2>0:devel/py-game_sdl2@${PY_FLAVOR}
30
45
31
# Upstream tends to reroll distfiles before moving under /release/
46
# Upstream tends to reroll distfiles before moving under /release/
32
PORTSCOUT=	site:http://www.renpy.org/dl/release/
47
PORTSCOUT=	site:http://www.renpy.org/dl/release/
33
48
34
USES=		python:2.7 sdl shebangfix tar:bz2
49
USES=		python:3.9+ sdl shebangfix tar:bz2
35
USE_PYTHON=	autoplist distutils cython
50
USE_PYTHON=	autoplist distutils cython
36
USE_SDL=	sdl2
51
USE_SDL=	sdl2
37
EXCLUDE=	fribidi-src gen 'module/*.py[co]' 'renpy/*.py[co]'
52
EXCLUDE=	fribidi-src gen 'module/*.py[co]' 'renpy/*.py[co]'
38
EXTRACT_AFTER_ARGS=${EXCLUDE:S,^,--exclude ,}
53
EXTRACT_AFTER_ARGS=${EXCLUDE:S,^,--exclude ,}
39
SHEBANG_FILES=	renpy.py launcher/game/tkaskdir.py
54
SHEBANG_FILES=	renpy.py
40
TARGET_ORDER_OVERRIDE=610:fix-shebang
55
TARGET_ORDER_OVERRIDE=610:fix-shebang
41
BUILD_WRKSRC=	${WRKSRC}/module
56
BUILD_WRKSRC=	${WRKSRC}/module
42
INSTALL_WRKSRC=	${BUILD_WRKSRC}
57
INSTALL_WRKSRC=	${BUILD_WRKSRC}
43
MAKE_ENV+=	RENPY_DEPS_INSTALL="${LOCALBASE}" \
58
MAKE_ENV+=	RENPY_DEPS_INSTALL="${LOCALBASE}" \
44
		RENPY_CYTHON=cython-${PYTHON_VER}
59
		RENPY_CYTHON=cython-${PYTHON_VER} \
60
		RENPY_PLATFORM="freebsd-x86_64"
45
PORTDATA=	gui launcher renpy renpy.py
61
PORTDATA=	gui launcher renpy renpy.py
46
PORTDOCS=	*
62
PORTDOCS=	*
47
PLIST_FILES=	bin/${PORTNAME}
63
PLIST_FILES=	bin/${PORTNAME}
Lines 58-71 OPTIONS_DEFINE= DOCS DIST EXAMPLES TKINTER Link Here
58
74
59
DIST_DESC=	Distribution runtimes for Windows, OS X, Linux
75
DIST_DESC=	Distribution runtimes for Windows, OS X, Linux
60
DIST_VARS=	LICENSE+="ART20 PSFL" \
76
DIST_VARS=	LICENSE+="ART20 PSFL" \
61
		PORTDATA+="lib renpy.app renpy.exe renpy-32.exe renpy.sh"
77
		PORTDATA+="lib renpy.app renpy.exe renpy.sh"
62
EXAMPLES_VARS=	PORTDATA+="the_question tutorial"
78
EXAMPLES_VARS=	PORTDATA+="the_question tutorial"
63
TKINTER_DESC=	Install Tkinter to allow choosing Projects Directory
79
TKINTER_DESC=	Install Tkinter to allow choosing Projects Directory
64
TKINTER_RUN_DEPENDS=${PYTHON_PKGNAMEPREFIX}tkinter>0:x11-toolkits/py-tkinter@${PY_FLAVOR}
80
TKINTER_RUN_DEPENDS=${PYTHON_PKGNAMEPREFIX}tkinter>0:x11-toolkits/py-tkinter@${PY_FLAVOR}
65
81
66
post-extract:
67
	@${FIND} ${WRKSRC}/lib ${WRKSRC}/renpy.app -type d -empty -delete
68
69
post-patch:
82
post-patch:
70
	@${REINPLACE_CMD} -e 's,/usr/bin/python[[:>:]],${PYTHON_CMD},' \
83
	@${REINPLACE_CMD} -e 's,/usr/bin/python[[:>:]],${PYTHON_CMD},' \
71
		${WRKSRC}/launcher/game/choose_directory.rpy
84
		${WRKSRC}/launcher/game/choose_directory.rpy
Lines 86-98 add-empty-dirs: Link Here
86
post-install:
99
post-install:
87
	${FIND} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} -name \*.so \
100
	${FIND} ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} -name \*.so \
88
		-exec ${STRIP_CMD} {} +
101
		-exec ${STRIP_CMD} {} +
89
	${LN} -fs ../${DATADIR_REL}/renpy.py \
102
	install files/renpy.sh \
90
		${STAGEDIR}${PREFIX}/bin/${PORTNAME}
103
		${STAGEDIR}${PREFIX}/bin/${PORTNAME}
104
	${REINPLACE_CMD} -e 's%replace%${DATADIR}%' ${STAGEDIR}${PREFIX}/bin/${PORTNAME}
105
91
	(cd ${WRKSRC} && ${COPYTREE_SHARE} \
106
	(cd ${WRKSRC} && ${COPYTREE_SHARE} \
92
		"${PORTDATA}" ${STAGEDIR}${DATADIR} \
107
		"${PORTDATA}" ${STAGEDIR}${DATADIR} \
93
		"! -name *.orig ! -name *.bak \
108
		"! -name *.orig ! -name *.bak \
94
		 ! -name saves ! -name log.txt")
109
		 ! -name saves ! -name log.txt")
95
	${CHMOD} +x ${STAGEDIR}${DATADIR}/renpy.py
110
	${CHMOD} +x ${STAGEDIR}${DATADIR}/renpy.py
111
	${CHMOD} +x ${STAGEDIR}${PREFIX}/bin/renpy
96
112
97
post-install-DOCS-on:
113
post-install-DOCS-on:
98
	(cd ${WRKSRC}/doc && ${COPYTREE_SHARE} \
114
	(cd ${WRKSRC}/doc && ${COPYTREE_SHARE} \
(-)b/games/renpy/distinfo (-3 / +3 lines)
Lines 1-3 Link Here
1
TIMESTAMP = 1638428552
1
TIMESTAMP = 1712368489
2
SHA256 (renpy-7.4.11-sdk.tar.bz2) = a73378f06a5925ea0d163b5825c298ed65dafb3d0cdccd9f34d7eace46adef1f
2
SHA256 (renpy-8.2.1-sdk.tar.bz2) = 415bcd23f3bc69d61e107d2a4008474327e0bda9899398230094e71af07d2d96
3
SIZE (renpy-7.4.11-sdk.tar.bz2) = 111943054
3
SIZE (renpy-8.2.1-sdk.tar.bz2) = 138118266
(-)a/games/renpy/files/patch-issue869 (-11 lines)
Removed Link Here
1
Restore shebang before ecd36ec.
2
3
--- renpy.py.orig	2016-01-27 03:31:10 UTC
4
+++ renpy.py
5
@@ -1,4 +1,5 @@
6
-#!/usr/bin/env python #@PydevCodeAnalysisIgnore
7
+#!/usr/bin/env python
8
+#@PydevCodeAnalysisIgnore
9
 
10
 # This file is part of Ren'Py. The license below applies to Ren'Py only.
11
 # Games and other projects that use Ren'Py may use a different license.
(-)b/games/renpy/files/patch-renpy.sh-freebsd-support (+15 lines)
Added Link Here
1
--- renpy.sh.orig	2024-04-05 22:20:25.282192000 -0500
2
+++ renpy.sh	2024-04-05 22:23:02.119206000 -0500
3
@@ -40,6 +40,12 @@
4
         Linux-*)
5
             RENPY_PLATFORM="linux-$(uname -m)"
6
             ;;
7
+	FreeBSD-amd64)
8
+		RENPY_PLATFORM="freebsd-x86_64"
9
+		;;
10
+	FreeBSD-i*86)
11
+		RENPY_PLATFORM="freebsd-i386"
12
+		;;
13
         *)
14
             ;;
15
     esac
(-)a/games/renpy/files/patch-system-fribidi (-61 lines)
Removed Link Here
1
Partially revert 4a9efc0cab7d as module/fribidi-src/ is missing from source archive.
2
3
gen/_renpybidi.c:564:10: fatal error: 'fribidi.h' file not found
4
#include "fribidi.h"
5
         ^
6
7
--- module/renpybidicore.c.orig	2019-12-14 15:31:48.000000000 +0000
8
+++ module/renpybidicore.c	2021-01-01 15:45:23.115935083 +0000
9
@@ -1,10 +1,6 @@
10
 #include <Python.h>
11
 
12
-#ifdef RENPY_BUILD
13
 #include <fribidi.h>
14
-#else
15
-#include <fribidi-src/lib/fribidi.h>
16
-#endif
17
 
18
 #include <stdlib.h>
19
 
20
--- module/setup.py.orig	2018-07-11 04:29:32 UTC
21
+++ module/setup.py
22
@@ -92,6 +92,7 @@ has_avresample = library("avresample", optional=True)
23
 has_swresample = library("swresample", optional=True)
24
 has_swscale = library("swscale", optional=True)
25
 library("freetype")
26
+has_fribidi = include("fribidi.h", directory="fribidi", optional=True) and library("fribidi", optional=True)
27
 library("z")
28
 has_libglew = library("GLEW", optional=True)
29
 has_libglew32 = library("glew32", optional=True)
30
@@ -105,6 +106,16 @@ else:
31
     sdl = [ 'SDL2' ]
32
     png = 'png'
33
 
34
+
35
+if has_fribidi and (not android) and (not ios):
36
+    try:
37
+        # Some versions of fribidi require glib, and it doesn't hurt to include it in
38
+        # our path.
39
+        glib_flags = subprocess.check_output(["pkg-config", "--cflags", "glib-2.0"])
40
+        setuplib.extra_compile_args.extend(glib_flags.split())
41
+    except:
42
+        pass
43
+
44
 steam_sdk = os.environ.get("RENPY_STEAM_SDK", None)
45
 steam_platform = os.environ.get("RENPY_STEAM_PLATFORM", "")
46
 
47
@@ -134,11 +145,12 @@ renpybidicore.c
48
 """.split()
49
 cython(
50
     "_renpybidi",
51
-    FRIBIDI_SOURCES,
52
-    includes=[
53
+    has_fribidi and [ i for i in FRIBIDI_SOURCES if 'fribidi-src' not in i ] or FRIBIDI_SOURCES,
54
+    includes=has_fribidi and [] or [
55
         BASE + "/fribidi-src/",
56
         BASE + "/fribidi-src/lib/",
57
         ],
58
+    libs=has_fribidi and ['fribidi'] or [],
59
     define_macros=[
60
         ("FRIBIDI_ENTRY", ""),
61
         ("HAVE_CONFIG_H", "1"),
(-)b/games/renpy/files/patch-tinyfd-3.17.5-upgrade.patch (+13882 lines)
Added Link Here
1
--- module/tinyfiledialogs/tinyfiledialogs.c.orig	2024-04-05 20:38:06.709682000 -0500
2
+++ module/tinyfiledialogs/tinyfiledialogs.c	2024-04-05 20:38:24.211102000 -0500
3
@@ -1,17 +1,21 @@
4
-/* this file can be renamed with extension ".cpp" and compiled as C++.
5
-The code is 100% compatible C C++
6
-(just comment out << extern "C" >> in the header file) */
7
+/* SPDX-License-Identifier: Zlib
8
+Copyright (c) 2014 - 2024 Guillaume Vareille http://ysengrin.com
9
+	 ________________________________________________________________
10
+	|                                                                |
11
+	| 100% compatible C C++  ->  You can rename this .c file as .cpp |
12
+	|________________________________________________________________|
13
 
14
-/*_________
15
- /         \ tinyfiledialogs.c v3.8.8 [Apr 22, 2021] zlib licence
16
+********* TINY FILE DIALOGS OFFICIAL WEBSITE IS ON SOURCEFORGE *********
17
+  _________
18
+ /         \ tinyfiledialogs.c v3.17.5 [Mar 28, 2024] zlib licence
19
  |tiny file| Unique code file created [November 9, 2014]
20
- | dialogs | Copyright (c) 2014 - 2021 Guillaume Vareille http://ysengrin.com
21
+ | dialogs |
22
  \____  ___/ http://tinyfiledialogs.sourceforge.net
23
-      \|     git clone http://git.code.sf.net/p/tinyfiledialogs/code tinyfd
24
-              ____________________________________________
25
-             |                                            |
26
-             |   email: tinyfiledialogs at ysengrin.com   |
27
-             |____________________________________________|
28
+	  \|     git clone http://git.code.sf.net/p/tinyfiledialogs/code tinyfd
29
+			  ____________________________________________
30
+			 |                                            |
31
+			 |   email: tinyfiledialogs at ysengrin.com   |
32
+			 |____________________________________________|
33
   _________________________________________________________________________________
34
  |                                                                                 |
35
  | the windows only wchar_t UTF-16 prototypes are at the bottom of the header file |
36
@@ -40,23 +44,28 @@
37
 2. Altered source versions must be plainly marked as such, and must not be
38
 misrepresented as being the original software.
39
 3. This notice may not be removed or altered from any source distribution.
40
------------
41
 
42
-Thanks for contributions, bug corrections & thorough testing to:
43
-- Don Heyse http://ldglite.sf.net for bug corrections & thorough testing!
44
-- Paul Rouget
45
+     __________________________________________
46
+    |  ______________________________________  |
47
+    | |                                      | |
48
+    | | DO NOT USE USER INPUT IN THE DIALOGS | |
49
+    | |______________________________________| |
50
+    |__________________________________________|
51
 */
52
 
53
 
54
-#ifndef __sun
55
-#ifndef _POSIX_C_SOURCE
56
-#define _POSIX_C_SOURCE 2 /* to accept POSIX 2 in old ANSI C standards */
57
-#endif
58
-#endif
59
-
60
-#if !defined(_WIN32) && ( defined(__GNUC__) || defined(__clang__) )
61
-#if !defined(_GNU_SOURCE)
62
+#if defined(__GNUC__) || defined(__clang__)
63
+#ifndef _GNU_SOURCE
64
  #define _GNU_SOURCE /* used only to resolve symbolic links. Can be commented out */
65
+ #ifndef _POSIX_C_SOURCE
66
+  #ifdef __FreeBSD__
67
+    #define _POSIX_C_SOURCE 199506L /* 199506L is enough for freebsd for realpath() */
68
+  #elif defined(__illumos__) || defined(__solaris__)
69
+    #define _POSIX_C_SOURCE 200112L /* illumos/solaris needs 200112L for realpath() */
70
+  #else
71
+    #define _POSIX_C_SOURCE 2 /* to accept POSIX 2 in old ANSI C standards */
72
+  #endif
73
+ #endif
74
 #endif
75
 #endif
76
 
77
@@ -99,7 +108,7 @@
78
 #endif
79
 #define LOW_MULTIPLE_FILES 32
80
 
81
-char tinyfd_version[8] = "3.8.8";
82
+char tinyfd_version[8] = "3.17.5";
83
 
84
 /******************************************************************************************************/
85
 /**************************************** UTF-8 on Windows ********************************************/
86
@@ -134,13 +143,13 @@
87
 char tinyfd_response[1024];
88
 /* if you pass "tinyfd_query" as aTitle,
89
 the functions will not display the dialogs
90
-but and return 0 for console mode, 1 for graphic mode.
91
+but return 0 for console mode, 1 for graphic mode.
92
 tinyfd_response is then filled with the retain solution.
93
 possible values for tinyfd_response are (all lowercase)
94
 for graphic mode:
95
-  windows_wchar windows applescript kdialog zenity zenity3 matedialog
96
-  shellementary qarma yad python2-tkinter python3-tkinter python-dbus
97
-  perl-dbus gxmessage gmessage xmessage xdialog gdialog
98
+  windows_wchar windows applescript kdialog zenity zenity3 yad matedialog
99
+  shellementary qarma python2-tkinter python3-tkinter python-dbus
100
+  perl-dbus gxmessage gmessage xmessage xdialog gdialog dunst
101
 for console mode:
102
   dialog whiptail basicinput no_solution */
103
 
104
@@ -157,7 +166,7 @@
105
       \\|\
106
 \ntiny file dialogs on Windows needs:\
107
 \n   a graphic display\
108
-\nor dialog.exe (curses console mode)\
109
+\nor dialog.exe (curses console mode  ** Disabled by default **)\
110
 \nor a console for basic input";
111
 #else
112
 char tinyfd_needs[] = "\
113
@@ -171,9 +180,10 @@
114
 \n   applescript or kdialog or yad or Xdialog\
115
 \nor zenity (or matedialog or shellementary or qarma)\
116
 \nor python (2 or 3) + tkinter + python-dbus (optional)\
117
-\nor dialog (opens console if needed)\
118
+\nor dialog (opens console if needed) ** Disabled by default **\
119
 \nor xterm + bash (opens console for basic input)\
120
-\nor existing console for basic input";
121
+\nor existing console for basic input.";
122
+
123
 #endif
124
 
125
 #ifdef _MSC_VER
126
@@ -184,198 +194,198 @@
127
 
128
 static int getenvDISPLAY(void)
129
 {
130
-	return tinyfd_assumeGraphicDisplay || getenv("DISPLAY");
131
+		return tinyfd_assumeGraphicDisplay || getenv("DISPLAY");
132
 }
133
 
134
 
135
 static char * getCurDir(void)
136
 {
137
-	static char lCurDir[MAX_PATH_OR_CMD];
138
-	return getcwd(lCurDir, sizeof(lCurDir));
139
+		static char lCurDir[MAX_PATH_OR_CMD];
140
+		return getcwd(lCurDir, sizeof(lCurDir));
141
 }
142
 
143
 
144
 static char * getPathWithoutFinalSlash(
145
-        char * aoDestination, /* make sure it is allocated, use _MAX_PATH */
146
-        char const * aSource) /* aoDestination and aSource can be the same */
147
+		char * aoDestination, /* make sure it is allocated, use _MAX_PATH */
148
+		char const * aSource) /* aoDestination and aSource can be the same */
149
 {
150
-        char const * lTmp ;
151
-        if ( aSource )
152
-        {
153
-                lTmp = strrchr(aSource, '/');
154
-                if (!lTmp)
155
-                {
156
-                        lTmp = strrchr(aSource, '\\');
157
-                }
158
-                if (lTmp)
159
-                {
160
-                        strncpy(aoDestination, aSource, lTmp - aSource );
161
-                        aoDestination[lTmp - aSource] = '\0';
162
-                }
163
-                else
164
-                {
165
-                        * aoDestination = '\0';
166
-                }
167
-        }
168
-        else
169
-        {
170
-                * aoDestination = '\0';
171
-        }
172
-        return aoDestination;
173
+		char const * lTmp ;
174
+		if ( aSource )
175
+		{
176
+				lTmp = strrchr(aSource, '/');
177
+				if (!lTmp)
178
+				{
179
+						lTmp = strrchr(aSource, '\\');
180
+				}
181
+				if (lTmp)
182
+				{
183
+						strncpy(aoDestination, aSource, lTmp - aSource );
184
+						aoDestination[lTmp - aSource] = '\0';
185
+				}
186
+				else
187
+				{
188
+						* aoDestination = '\0';
189
+				}
190
+		}
191
+		else
192
+		{
193
+				* aoDestination = '\0';
194
+		}
195
+		return aoDestination;
196
 }
197
 
198
 
199
 static char * getLastName(
200
-        char * aoDestination, /* make sure it is allocated */
201
-        char const * aSource)
202
+		char * aoDestination, /* make sure it is allocated */
203
+		char const * aSource)
204
 {
205
-        /* copy the last name after '/' or '\' */
206
-        char const * lTmp ;
207
-        if ( aSource )
208
-        {
209
-                lTmp = strrchr(aSource, '/');
210
-                if (!lTmp)
211
-                {
212
-                        lTmp = strrchr(aSource, '\\');
213
-                }
214
-                if (lTmp)
215
-                {
216
-                        strcpy(aoDestination, lTmp + 1);
217
-                }
218
-                else
219
-                {
220
-                        strcpy(aoDestination, aSource);
221
-                }
222
-        }
223
-        else
224
-        {
225
-                * aoDestination = '\0';
226
-        }
227
-        return aoDestination;
228
+		/* copy the last name after '/' or '\' */
229
+		char const * lTmp ;
230
+		if ( aSource )
231
+		{
232
+				lTmp = strrchr(aSource, '/');
233
+				if (!lTmp)
234
+				{
235
+						lTmp = strrchr(aSource, '\\');
236
+				}
237
+				if (lTmp)
238
+				{
239
+						strcpy(aoDestination, lTmp + 1);
240
+				}
241
+				else
242
+				{
243
+						strcpy(aoDestination, aSource);
244
+				}
245
+		}
246
+		else
247
+		{
248
+				* aoDestination = '\0';
249
+		}
250
+		return aoDestination;
251
 }
252
 
253
 
254
 static void ensureFinalSlash( char * aioString )
255
 {
256
-        if ( aioString && strlen( aioString ) )
257
-        {
258
-                char * lastcar = aioString + strlen( aioString ) - 1 ;
259
-                if ( strncmp( lastcar , SLASH , 1 ) )
260
-                {
261
-                        strcat( lastcar , SLASH ) ;
262
-                }
263
-        }
264
+		if ( aioString && strlen( aioString ) )
265
+		{
266
+				char * lastcar = aioString + strlen( aioString ) - 1 ;
267
+				if ( strncmp( lastcar , SLASH , 1 ) )
268
+				{
269
+						strcat( lastcar , SLASH ) ;
270
+				}
271
+		}
272
 }
273
 
274
 
275
 static void Hex2RGB( char const aHexRGB[8] , unsigned char aoResultRGB[3] )
276
 {
277
-        char lColorChannel[8] ;
278
-        if ( aoResultRGB )
279
-        {
280
-                if ( aHexRGB )
281
-                {
282
-                        strcpy(lColorChannel, aHexRGB ) ;
283
-                        aoResultRGB[2] = (unsigned char)strtoul(lColorChannel+5,NULL,16);
284
-                        lColorChannel[5] = '\0';
285
-                        aoResultRGB[1] = (unsigned char)strtoul(lColorChannel+3,NULL,16);
286
-                        lColorChannel[3] = '\0';
287
-                        aoResultRGB[0] = (unsigned char)strtoul(lColorChannel+1,NULL,16);
288
+		char lColorChannel[8] ;
289
+		if ( aoResultRGB )
290
+		{
291
+				if ( aHexRGB )
292
+				{
293
+						strcpy(lColorChannel, aHexRGB ) ;
294
+						aoResultRGB[2] = (unsigned char)strtoul(lColorChannel+5,NULL,16);
295
+						lColorChannel[5] = '\0';
296
+						aoResultRGB[1] = (unsigned char)strtoul(lColorChannel+3,NULL,16);
297
+						lColorChannel[3] = '\0';
298
+						aoResultRGB[0] = (unsigned char)strtoul(lColorChannel+1,NULL,16);
299
 /* printf("%d %d %d\n", aoResultRGB[0], aoResultRGB[1], aoResultRGB[2]); */
300
-                }
301
-                else
302
-                {
303
-                        aoResultRGB[0]=0;
304
-                        aoResultRGB[1]=0;
305
-                        aoResultRGB[2]=0;
306
-                }
307
-        }
308
+				}
309
+				else
310
+				{
311
+						aoResultRGB[0]=0;
312
+						aoResultRGB[1]=0;
313
+						aoResultRGB[2]=0;
314
+				}
315
+		}
316
 }
317
 
318
 static void RGB2Hex( unsigned char const aRGB[3], char aoResultHexRGB[8] )
319
 {
320
-        if ( aoResultHexRGB )
321
-        {
322
-                if ( aRGB )
323
-                {
324
+		if ( aoResultHexRGB )
325
+		{
326
+				if ( aRGB )
327
+				{
328
 #if (defined(__cplusplus ) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__clang__)
329
-    sprintf(aoResultHexRGB, "#%02hhx%02hhx%02hhx", aRGB[0], aRGB[1], aRGB[2]);
330
+	sprintf(aoResultHexRGB, "#%02hhx%02hhx%02hhx", aRGB[0], aRGB[1], aRGB[2]);
331
 #else
332
-    sprintf(aoResultHexRGB, "#%02hx%02hx%02hx", aRGB[0], aRGB[1], aRGB[2]);
333
+	sprintf(aoResultHexRGB, "#%02hx%02hx%02hx", aRGB[0], aRGB[1], aRGB[2]);
334
 #endif
335
-                         /*printf("aoResultHexRGB %s\n", aoResultHexRGB);*/
336
-                }
337
-                else
338
-                {
339
-                        aoResultHexRGB[0]=0;
340
-                        aoResultHexRGB[1]=0;
341
-                        aoResultHexRGB[2]=0;
342
-                }
343
-        }
344
+						 /*printf("aoResultHexRGB %s\n", aoResultHexRGB);*/
345
+				}
346
+				else
347
+				{
348
+						aoResultHexRGB[0]=0;
349
+						aoResultHexRGB[1]=0;
350
+						aoResultHexRGB[2]=0;
351
+				}
352
+		}
353
 }
354
 
355
 
356
 void tfd_replaceSubStr( char const * aSource, char const * aOldSubStr,
357
-                        char const * aNewSubStr, char * aoDestination )
358
+						char const * aNewSubStr, char * aoDestination )
359
 {
360
-        char const * pOccurence ;
361
-        char const * p ;
362
-        char const * lNewSubStr = "" ;
363
-        size_t lOldSubLen = strlen( aOldSubStr ) ;
364
+		char const * pOccurence ;
365
+		char const * p ;
366
+		char const * lNewSubStr = "" ;
367
+		size_t lOldSubLen = strlen( aOldSubStr ) ;
368
 
369
-        if ( ! aSource )
370
-        {
371
-                * aoDestination = '\0' ;
372
-                return ;
373
-        }
374
-        if ( ! aOldSubStr )
375
-        {
376
-                strcpy( aoDestination , aSource ) ;
377
-                return ;
378
-        }
379
-        if ( aNewSubStr )
380
-        {
381
-                lNewSubStr = aNewSubStr ;
382
-        }
383
-        p = aSource ;
384
-        * aoDestination = '\0' ;
385
-        while ( ( pOccurence = strstr( p , aOldSubStr ) ) != NULL )
386
-        {
387
-                strncat( aoDestination , p , pOccurence - p ) ;
388
-                strcat( aoDestination , lNewSubStr ) ;
389
-                p = pOccurence + lOldSubLen ;
390
-        }
391
-        strcat( aoDestination , p ) ;
392
+		if ( ! aSource )
393
+		{
394
+				* aoDestination = '\0' ;
395
+				return ;
396
+		}
397
+		if ( ! aOldSubStr )
398
+		{
399
+				strcpy( aoDestination , aSource ) ;
400
+				return ;
401
+		}
402
+		if ( aNewSubStr )
403
+		{
404
+				lNewSubStr = aNewSubStr ;
405
+		}
406
+		p = aSource ;
407
+		* aoDestination = '\0' ;
408
+		while ( ( pOccurence = strstr( p , aOldSubStr ) ) != NULL )
409
+		{
410
+				strncat( aoDestination , p , pOccurence - p ) ;
411
+				strcat( aoDestination , lNewSubStr ) ;
412
+				p = pOccurence + lOldSubLen ;
413
+		}
414
+		strcat( aoDestination , p ) ;
415
 }
416
 
417
 
418
 static int filenameValid( char const * aFileNameWithoutPath )
419
 {
420
-        if ( ! aFileNameWithoutPath
421
-          || ! strlen(aFileNameWithoutPath)
422
-          || strpbrk(aFileNameWithoutPath , "\\/:*?\"<>|") )
423
-        {
424
-                return 0 ;
425
-        }
426
-        return 1 ;
427
+		if ( ! aFileNameWithoutPath
428
+		  || ! strlen(aFileNameWithoutPath)
429
+		  || strpbrk(aFileNameWithoutPath , "\\/:*?\"<>|") )
430
+		{
431
+				return 0 ;
432
+		}
433
+		return 1 ;
434
 }
435
 
436
 #ifndef _WIN32
437
 
438
 static int fileExists( char const * aFilePathAndName )
439
 {
440
-        FILE * lIn ;
441
-        if ( ! aFilePathAndName || ! strlen(aFilePathAndName) )
442
-        {
443
-                return 0 ;
444
-        }
445
-        lIn = fopen( aFilePathAndName , "r" ) ;
446
-        if ( ! lIn )
447
-        {
448
-                return 0 ;
449
-        }
450
-        fclose( lIn ) ;
451
-        return 1 ;
452
+		FILE * lIn ;
453
+		if ( ! aFilePathAndName || ! strlen(aFilePathAndName) )
454
+		{
455
+				return 0 ;
456
+		}
457
+		lIn = fopen( aFilePathAndName , "r" ) ;
458
+		if ( ! lIn )
459
+		{
460
+				return 0 ;
461
+		}
462
+		fclose( lIn ) ;
463
+		return 1 ;
464
 }
465
 
466
 #endif
467
@@ -383,21 +393,21 @@
468
 
469
 static void wipefile(char const * aFilename)
470
 {
471
-        int i;
472
-        struct stat st;
473
-        FILE * lIn;
474
+		int i;
475
+		struct stat st;
476
+		FILE * lIn;
477
 
478
-        if (stat(aFilename, &st) == 0)
479
-        {
480
-                if ((lIn = fopen(aFilename, "w")))
481
-                {
482
-                        for (i = 0; i < st.st_size; i++)
483
-                        {
484
-                                fputc('A', lIn);
485
-                        }
486
-                        fclose(lIn);
487
-                }
488
-        }
489
+		if (stat(aFilename, &st) == 0)
490
+		{
491
+				if ((lIn = fopen(aFilename, "w")))
492
+				{
493
+						for (i = 0; i < st.st_size; i++)
494
+						{
495
+								fputc('A', lIn);
496
+						}
497
+						fclose(lIn);
498
+				}
499
+		}
500
 }
501
 
502
 
503
@@ -408,137 +418,148 @@
504
 	if (!aString) return 0;
505
 
506
 	p = aString;
507
-	while ((p = strchr(p, '\'')))
508
+	if ( strchr(p, '\''))
509
 	{
510
 		return 1;
511
 	}
512
 
513
-	p = aString;
514
-	while ((p = strchr(p, '\"')))
515
+	if ( strchr(p, '\"'))
516
 	{
517
 		return 1;
518
 	}
519
 
520
+	if ( strchr(p, '`'))
521
+	{
522
+		return 1;
523
+	}
524
+
525
+	p = aString;
526
+	while ((p = strchr(p, '$')))
527
+	{
528
+		p ++ ;
529
+		if ( ( * p == '(' ) || ( * p == '_' ) || isalpha( * p) ) return 1 ;
530
+	}
531
+
532
 	return 0;
533
 }
534
 
535
 
536
 char const * tinyfd_getGlobalChar(char const * aCharVariableName) /* to be called from C# (you don't need this in C or C++) */
537
 {
538
-	if (!aCharVariableName || !strlen(aCharVariableName)) return NULL;
539
-	else if (!strcmp(aCharVariableName, "tinyfd_version")) return tinyfd_version;
540
-	else if (!strcmp(aCharVariableName, "tinyfd_needs")) return tinyfd_needs;
541
-	else if (!strcmp(aCharVariableName, "tinyfd_response")) return tinyfd_response;
542
-	else return NULL ;
543
+		if (!aCharVariableName || !strlen(aCharVariableName)) return NULL;
544
+		else if (!strcmp(aCharVariableName, "tinyfd_version")) return tinyfd_version;
545
+		else if (!strcmp(aCharVariableName, "tinyfd_needs")) return tinyfd_needs;
546
+		else if (!strcmp(aCharVariableName, "tinyfd_response")) return tinyfd_response;
547
+		else return NULL ;
548
 }
549
 
550
 
551
 int tinyfd_getGlobalInt(char const * aIntVariableName) /* to be called from C# (you don't need this in C or C++) */
552
 {
553
-	if ( !aIntVariableName || !strlen(aIntVariableName) ) return -1 ;
554
-	else if ( !strcmp(aIntVariableName, "tinyfd_verbose") ) return tinyfd_verbose ;
555
-	else if ( !strcmp(aIntVariableName, "tinyfd_silent") ) return tinyfd_silent ;
556
-	else if ( !strcmp(aIntVariableName, "tinyfd_allowCursesDialogs") ) return tinyfd_allowCursesDialogs ;
557
-	else if ( !strcmp(aIntVariableName, "tinyfd_forceConsole") ) return tinyfd_forceConsole ;
558
-	else if ( !strcmp(aIntVariableName, "tinyfd_assumeGraphicDisplay") ) return tinyfd_assumeGraphicDisplay ;
559
+		if ( !aIntVariableName || !strlen(aIntVariableName) ) return -1 ;
560
+		else if ( !strcmp(aIntVariableName, "tinyfd_verbose") ) return tinyfd_verbose ;
561
+		else if ( !strcmp(aIntVariableName, "tinyfd_silent") ) return tinyfd_silent ;
562
+		else if ( !strcmp(aIntVariableName, "tinyfd_allowCursesDialogs") ) return tinyfd_allowCursesDialogs ;
563
+		else if ( !strcmp(aIntVariableName, "tinyfd_forceConsole") ) return tinyfd_forceConsole ;
564
+		else if ( !strcmp(aIntVariableName, "tinyfd_assumeGraphicDisplay") ) return tinyfd_assumeGraphicDisplay ;
565
 #ifdef _WIN32
566
-	else if ( !strcmp(aIntVariableName, "tinyfd_winUtf8") ) return tinyfd_winUtf8 ;
567
+		else if ( !strcmp(aIntVariableName, "tinyfd_winUtf8") ) return tinyfd_winUtf8 ;
568
 #endif
569
-	else return -1;
570
+		else return -1;
571
 }
572
 
573
 
574
 int tinyfd_setGlobalInt(char const * aIntVariableName, int aValue) /* to be called from C# (you don't need this in C or C++) */
575
 {
576
-	if (!aIntVariableName || !strlen(aIntVariableName)) return -1 ;
577
-	else if (!strcmp(aIntVariableName, "tinyfd_verbose")) { tinyfd_verbose = aValue; return tinyfd_verbose; }
578
-	else if (!strcmp(aIntVariableName, "tinyfd_silent")) { tinyfd_silent = aValue; return tinyfd_silent; }
579
-	else if (!strcmp(aIntVariableName, "tinyfd_allowCursesDialogs")) { tinyfd_allowCursesDialogs = aValue; return tinyfd_allowCursesDialogs; }
580
-	else if (!strcmp(aIntVariableName, "tinyfd_forceConsole")) { tinyfd_forceConsole = aValue; return tinyfd_forceConsole; }
581
-	else if (!strcmp(aIntVariableName, "tinyfd_assumeGraphicDisplay")) { tinyfd_assumeGraphicDisplay = aValue; return tinyfd_assumeGraphicDisplay; }
582
+		if (!aIntVariableName || !strlen(aIntVariableName)) return -1 ;
583
+		else if (!strcmp(aIntVariableName, "tinyfd_verbose")) { tinyfd_verbose = aValue; return tinyfd_verbose; }
584
+		else if (!strcmp(aIntVariableName, "tinyfd_silent")) { tinyfd_silent = aValue; return tinyfd_silent; }
585
+		else if (!strcmp(aIntVariableName, "tinyfd_allowCursesDialogs")) { tinyfd_allowCursesDialogs = aValue; return tinyfd_allowCursesDialogs; }
586
+		else if (!strcmp(aIntVariableName, "tinyfd_forceConsole")) { tinyfd_forceConsole = aValue; return tinyfd_forceConsole; }
587
+		else if (!strcmp(aIntVariableName, "tinyfd_assumeGraphicDisplay")) { tinyfd_assumeGraphicDisplay = aValue; return tinyfd_assumeGraphicDisplay; }
588
 #ifdef _WIN32
589
-	else if (!strcmp(aIntVariableName, "tinyfd_winUtf8")) { tinyfd_winUtf8 = aValue; return tinyfd_winUtf8; }
590
+		else if (!strcmp(aIntVariableName, "tinyfd_winUtf8")) { tinyfd_winUtf8 = aValue; return tinyfd_winUtf8; }
591
 #endif
592
-	else return -1;
593
+		else return -1;
594
 }
595
 
596
 
597
 #ifdef _WIN32
598
 static int powershellPresent(void)
599
 { /*only on vista and above (or installed on xp)*/
600
-    static int lPowershellPresent = -1;
601
-    char lBuff[MAX_PATH_OR_CMD];
602
-    FILE* lIn;
603
-    char const* lString = "powershell.exe";
604
+	static int lPowershellPresent = -1;
605
+	char lBuff[MAX_PATH_OR_CMD];
606
+	FILE* lIn;
607
+	char const* lString = "powershell.exe";
608
 
609
-    if (lPowershellPresent < 0)
610
-    {
611
-        if (!(lIn = _popen("where powershell.exe", "r")))
612
-        {
613
-            lPowershellPresent = 0;
614
-            return 0;
615
-        }
616
-        while (fgets(lBuff, sizeof(lBuff), lIn) != NULL)
617
-        {
618
-        }
619
-        _pclose(lIn);
620
-        if (lBuff[strlen(lBuff) - 1] == '\n')
621
-        {
622
-            lBuff[strlen(lBuff) - 1] = '\0';
623
-        }
624
-        if (strcmp(lBuff + strlen(lBuff) - strlen(lString), lString))
625
-        {
626
-            lPowershellPresent = 0;
627
-        }
628
-        else
629
-        {
630
-            lPowershellPresent = 1;
631
-        }
632
-    }
633
-    return lPowershellPresent;
634
+	if (lPowershellPresent < 0)
635
+	{
636
+		if (!(lIn = _popen("where powershell.exe", "r")))
637
+		{
638
+			lPowershellPresent = 0;
639
+			return 0;
640
+		}
641
+		while (fgets(lBuff, sizeof(lBuff), lIn) != NULL)
642
+		{
643
+		}
644
+		_pclose(lIn);
645
+		if (lBuff[strlen(lBuff) - 1] == '\n')
646
+		{
647
+			lBuff[strlen(lBuff) - 1] = '\0';
648
+		}
649
+		if (strcmp(lBuff + strlen(lBuff) - strlen(lString), lString))
650
+		{
651
+			lPowershellPresent = 0;
652
+		}
653
+		else
654
+		{
655
+			lPowershellPresent = 1;
656
+		}
657
+	}
658
+	return lPowershellPresent;
659
 }
660
 
661
 static int windowsVersion(void)
662
 {
663
 #if !defined(__MINGW32__) || defined(__MINGW64_VERSION_MAJOR)
664
-    typedef LONG NTSTATUS  ;
665
-    typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
666
-    HMODULE hMod;
667
-    RtlGetVersionPtr lFxPtr;
668
-    RTL_OSVERSIONINFOW lRovi = { 0 };
669
+	typedef LONG NTSTATUS  ;
670
+	typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
671
+	HMODULE hMod;
672
+	RtlGetVersionPtr lFxPtr;
673
+	RTL_OSVERSIONINFOW lRovi = { 0 };
674
 
675
-    hMod = GetModuleHandleW(L"ntdll.dll");
676
-    if (hMod) {
677
-        lFxPtr = (RtlGetVersionPtr)GetProcAddress(hMod, "RtlGetVersion");
678
-        if (lFxPtr)
679
-        {
680
-            lRovi.dwOSVersionInfoSize = sizeof(lRovi);
681
-            if (!lFxPtr(&lRovi))
682
-            {
683
-                return lRovi.dwMajorVersion;
684
-            }
685
-        }
686
-    }
687
+	hMod = GetModuleHandleW(L"ntdll.dll");
688
+	if (hMod) {
689
+		lFxPtr = (RtlGetVersionPtr)GetProcAddress(hMod, "RtlGetVersion");
690
+		if (lFxPtr)
691
+		{
692
+			lRovi.dwOSVersionInfoSize = sizeof(lRovi);
693
+			if (!lFxPtr(&lRovi))
694
+			{
695
+				return lRovi.dwMajorVersion;
696
+			}
697
+		}
698
+	}
699
 #endif
700
-    if (powershellPresent()) return 6; /*minimum is vista or installed on xp*/
701
-    return 0;
702
+	if (powershellPresent()) return 6; /*minimum is vista or installed on xp*/
703
+	return 0;
704
 }
705
 
706
 
707
 static void replaceChr(char * aString, char aOldChr, char aNewChr)
708
 {
709
-	char * p;
710
+		char * p;
711
 
712
-	if (!aString) return;
713
-	if (aOldChr == aNewChr) return;
714
+		if (!aString) return;
715
+		if (aOldChr == aNewChr) return;
716
 
717
-	p = aString;
718
-	while ((p = strchr(p, aOldChr)))
719
-	{
720
-		*p = aNewChr;
721
-		p++;
722
-	}
723
-	return;
724
+		p = aString;
725
+		while ((p = strchr(p, aOldChr)))
726
+		{
727
+				*p = aNewChr;
728
+				p++;
729
+		}
730
+		return;
731
 }
732
 
733
 
734
@@ -549,604 +570,623 @@
735
 
736
 static int sizeUtf16From8(char const * aUtf8string)
737
 {
738
-	return MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
739
-		aUtf8string, -1, NULL, 0);
740
+		return MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
741
+				aUtf8string, -1, NULL, 0);
742
 }
743
 
744
 
745
 static int sizeUtf16FromMbcs(char const * aMbcsString)
746
 {
747
-	return MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
748
-		aMbcsString, -1, NULL, 0);
749
+		return MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
750
+				aMbcsString, -1, NULL, 0);
751
 }
752
 
753
 
754
 static int sizeUtf8(wchar_t const * aUtf16string)
755
 {
756
-	return WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS,
757
-		aUtf16string, -1, NULL, 0, NULL, NULL);
758
+		return WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS,
759
+				aUtf16string, -1, NULL, 0, NULL, NULL);
760
 }
761
 
762
 
763
 static int sizeMbcs(wchar_t const * aMbcsString)
764
 {
765
-	int lRes = WideCharToMultiByte(CP_ACP, 0,
766
-		aMbcsString, -1, NULL, 0, NULL, NULL);
767
-	/* DWORD licic = GetLastError(); */
768
-	return lRes;
769
+		int lRes = WideCharToMultiByte(CP_ACP, 0,
770
+				aMbcsString, -1, NULL, 0, NULL, NULL);
771
+		/* DWORD licic = GetLastError(); */
772
+		return lRes;
773
 }
774
 
775
 
776
 wchar_t* tinyfd_mbcsTo16(char const* aMbcsString)
777
 {
778
-    static wchar_t* lMbcsString = NULL;
779
-    int lSize;
780
+	static wchar_t* lMbcsString = NULL;
781
+	int lSize;
782
 
783
-    free(lMbcsString);
784
-    if (!aMbcsString) { lMbcsString = NULL; return NULL; }
785
-    lSize = sizeUtf16FromMbcs(aMbcsString);
786
-    if (lSize)
787
-    {
788
-        lMbcsString = (wchar_t*)malloc(lSize * sizeof(wchar_t));
789
-        lSize = MultiByteToWideChar(CP_ACP, 0, aMbcsString, -1, lMbcsString, lSize);
790
-    }
791
-    else wcscpy(lMbcsString, L"");
792
-    return lMbcsString;
793
+	free(lMbcsString);
794
+	if (!aMbcsString) { lMbcsString = NULL; return NULL; }
795
+	lSize = sizeUtf16FromMbcs(aMbcsString);
796
+	if (lSize)
797
+	{
798
+		lMbcsString = (wchar_t*) malloc(lSize * sizeof(wchar_t));
799
+		lSize = MultiByteToWideChar(CP_ACP, 0, aMbcsString, -1, lMbcsString, lSize);
800
+	}
801
+	else wcscpy(lMbcsString, L"");
802
+	return lMbcsString;
803
 }
804
 
805
 
806
 wchar_t * tinyfd_utf8to16(char const * aUtf8string)
807
 {
808
-	static wchar_t * lUtf16string = NULL;
809
-	int lSize;
810
+		static wchar_t * lUtf16string = NULL;
811
+		int lSize;
812
 
813
-	free(lUtf16string);
814
-	if (!aUtf8string) {lUtf16string = NULL; return NULL;}
815
-	lSize = sizeUtf16From8(aUtf8string);
816
-    if (lSize)
817
-    {
818
-        lUtf16string = (wchar_t*)malloc(lSize * sizeof(wchar_t));
819
-        lSize = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
820
-            aUtf8string, -1, lUtf16string, lSize);
821
-        return lUtf16string;
822
-    }
823
-    else
824
-    {
825
-        /* let's try mbcs anyway */
826
-        lUtf16string = NULL;
827
-        return tinyfd_mbcsTo16(aUtf8string);
828
-    }
829
+		free(lUtf16string);
830
+		if (!aUtf8string) {lUtf16string = NULL; return NULL;}
831
+		lSize = sizeUtf16From8(aUtf8string);
832
+	if (lSize)
833
+	{
834
+		lUtf16string = (wchar_t*) malloc(lSize * sizeof(wchar_t));
835
+		lSize = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
836
+			aUtf8string, -1, lUtf16string, lSize);
837
+		return lUtf16string;
838
+	}
839
+	else
840
+	{
841
+		/* let's try mbcs anyway */
842
+		lUtf16string = NULL;
843
+		return tinyfd_mbcsTo16(aUtf8string);
844
+	}
845
 }
846
 
847
 
848
 char * tinyfd_utf16toMbcs(wchar_t const * aUtf16string)
849
 {
850
-	static char * lMbcsString = NULL;
851
-	int lSize;
852
+		static char * lMbcsString = NULL;
853
+		int lSize;
854
 
855
-	free(lMbcsString);
856
-	if (!aUtf16string) { lMbcsString = NULL; return NULL; }
857
-	lSize = sizeMbcs(aUtf16string);
858
-    if (lSize)
859
-    {
860
-        lMbcsString = (char*)malloc(lSize);
861
-        lSize = WideCharToMultiByte(CP_ACP, 0, aUtf16string, -1, lMbcsString, lSize, NULL, NULL);
862
-    }
863
-    else strcpy(lMbcsString, "");
864
-	return lMbcsString;
865
+		free(lMbcsString);
866
+		if (!aUtf16string) { lMbcsString = NULL; return NULL; }
867
+		lSize = sizeMbcs(aUtf16string);
868
+	if (lSize)
869
+	{
870
+		lMbcsString = (char*) malloc(lSize);
871
+		lSize = WideCharToMultiByte(CP_ACP, 0, aUtf16string, -1, lMbcsString, lSize, NULL, NULL);
872
+	}
873
+	else strcpy(lMbcsString, "");
874
+		return lMbcsString;
875
 }
876
 
877
 
878
 char * tinyfd_utf8toMbcs(char const * aUtf8string)
879
 {
880
-	wchar_t const * lUtf16string;
881
-	lUtf16string = tinyfd_utf8to16(aUtf8string);
882
-	return tinyfd_utf16toMbcs(lUtf16string);
883
+		wchar_t const * lUtf16string;
884
+		lUtf16string = tinyfd_utf8to16(aUtf8string);
885
+		return tinyfd_utf16toMbcs(lUtf16string);
886
 }
887
 
888
 
889
 char * tinyfd_utf16to8(wchar_t const * aUtf16string)
890
 {
891
-	static char * lUtf8string = NULL;
892
-	int lSize;
893
+		static char * lUtf8string = NULL;
894
+		int lSize;
895
 
896
-	free(lUtf8string);
897
-	if (!aUtf16string) { lUtf8string = NULL; return NULL; }
898
-	lSize = sizeUtf8(aUtf16string);
899
-    if (lSize)
900
-    {
901
-        lUtf8string = (char*)malloc(lSize);
902
-        lSize = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, aUtf16string, -1, lUtf8string, lSize, NULL, NULL);
903
-    }
904
-    else strcpy(lUtf8string, "");
905
-	return lUtf8string;
906
+		free(lUtf8string);
907
+		if (!aUtf16string) { lUtf8string = NULL; return NULL; }
908
+		lSize = sizeUtf8(aUtf16string);
909
+	if (lSize)
910
+	{
911
+		lUtf8string = (char*) malloc(lSize);
912
+		lSize = WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, aUtf16string, -1, lUtf8string, lSize, NULL, NULL);
913
+	}
914
+	else strcpy(lUtf8string, "");
915
+		return lUtf8string;
916
 }
917
 
918
 
919
 char * tinyfd_mbcsTo8(char const * aMbcsString)
920
 {
921
-	wchar_t const * lUtf16string;
922
-	lUtf16string = tinyfd_mbcsTo16(aMbcsString);
923
-	return tinyfd_utf16to8(lUtf16string);
924
+		wchar_t const * lUtf16string;
925
+		lUtf16string = tinyfd_mbcsTo16(aMbcsString);
926
+		return tinyfd_utf16to8(lUtf16string);
927
 }
928
 
929
 
930
 void tinyfd_beep(void)
931
 {
932
-    if (windowsVersion() > 5) Beep(440, 300);
933
-    else MessageBeep(-1);
934
+	if (windowsVersion() > 5) Beep(440, 300);
935
+	else MessageBeep(MB_OK);
936
 }
937
 
938
 
939
 static void wipefileW(wchar_t const * aFilename)
940
 {
941
-        int i;
942
-        FILE * lIn;
943
-#if defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)
944
-        struct _stat st;
945
-        if (_wstat(aFilename, &st) == 0)
946
+		int i;
947
+		FILE * lIn;
948
+#if (defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)) || defined(__BORLANDC__) || defined(__WATCOMC__)
949
+		struct _stat st;
950
+		if (_wstat(aFilename, &st) == 0)
951
 #else
952
-        struct __stat64 st;
953
-        if (_wstat64(aFilename, &st) == 0)
954
+		struct __stat64 st;
955
+		if (_wstat64(aFilename, &st) == 0)
956
 #endif
957
-        {
958
-                if ((lIn = _wfopen(aFilename, L"w")))
959
-                {
960
-                        for (i = 0; i < st.st_size; i++)
961
-                        {
962
-                                fputc('A', lIn);
963
-                        }
964
-                        fclose(lIn);
965
-                }
966
-        }
967
+		{
968
+				if ((lIn = _wfopen(aFilename, L"w")))
969
+				{
970
+						for (i = 0; i < st.st_size; i++)
971
+						{
972
+								fputc('A', lIn);
973
+						}
974
+						fclose(lIn);
975
+				}
976
+		}
977
 }
978
 
979
 
980
 static wchar_t * getPathWithoutFinalSlashW(
981
-        wchar_t * aoDestination, /* make sure it is allocated, use _MAX_PATH */
982
-        wchar_t const * aSource) /* aoDestination and aSource can be the same */
983
+		wchar_t * aoDestination, /* make sure it is allocated, use _MAX_PATH */
984
+		wchar_t const * aSource) /* aoDestination and aSource can be the same */
985
 {
986
-        wchar_t const * lTmp;
987
-        if (aSource)
988
-        {
989
-                lTmp = wcsrchr(aSource, L'/');
990
-                if (!lTmp)
991
-                {
992
-                        lTmp = wcsrchr(aSource, L'\\');
993
-                }
994
-                if (lTmp)
995
-                {
996
-                        wcsncpy(aoDestination, aSource, lTmp - aSource);
997
-                        aoDestination[lTmp - aSource] = L'\0';
998
-                }
999
-                else
1000
-                {
1001
-                        *aoDestination = L'\0';
1002
-                }
1003
-        }
1004
-        else
1005
-        {
1006
-                *aoDestination = L'\0';
1007
-        }
1008
-        return aoDestination;
1009
+		wchar_t const * lTmp;
1010
+		if (aSource)
1011
+		{
1012
+				lTmp = wcsrchr(aSource, L'/');
1013
+				if (!lTmp)
1014
+				{
1015
+						lTmp = wcsrchr(aSource, L'\\');
1016
+				}
1017
+				if (lTmp)
1018
+				{
1019
+						wcsncpy(aoDestination, aSource, lTmp - aSource);
1020
+						aoDestination[lTmp - aSource] = L'\0';
1021
+				}
1022
+				else
1023
+				{
1024
+						*aoDestination = L'\0';
1025
+				}
1026
+		}
1027
+		else
1028
+		{
1029
+				*aoDestination = L'\0';
1030
+		}
1031
+		return aoDestination;
1032
 }
1033
 
1034
 
1035
 static wchar_t * getLastNameW(
1036
-        wchar_t * aoDestination, /* make sure it is allocated */
1037
-        wchar_t const * aSource)
1038
+		wchar_t * aoDestination, /* make sure it is allocated */
1039
+		wchar_t const * aSource)
1040
 {
1041
-        /* copy the last name after '/' or '\' */
1042
-        wchar_t const * lTmp;
1043
-        if (aSource)
1044
-        {
1045
-                lTmp = wcsrchr(aSource, L'/');
1046
-                if (!lTmp)
1047
-                {
1048
-                        lTmp = wcsrchr(aSource, L'\\');
1049
-                }
1050
-                if (lTmp)
1051
-                {
1052
-                        wcscpy(aoDestination, lTmp + 1);
1053
-                }
1054
-                else
1055
-                {
1056
-                        wcscpy(aoDestination, aSource);
1057
-                }
1058
-        }
1059
-        else
1060
-        {
1061
-                *aoDestination = L'\0';
1062
-        }
1063
-        return aoDestination;
1064
+		/* copy the last name after '/' or '\' */
1065
+		wchar_t const * lTmp;
1066
+		if (aSource)
1067
+		{
1068
+				lTmp = wcsrchr(aSource, L'/');
1069
+				if (!lTmp)
1070
+				{
1071
+						lTmp = wcsrchr(aSource, L'\\');
1072
+				}
1073
+				if (lTmp)
1074
+				{
1075
+						wcscpy(aoDestination, lTmp + 1);
1076
+				}
1077
+				else
1078
+				{
1079
+						wcscpy(aoDestination, aSource);
1080
+				}
1081
+		}
1082
+		else
1083
+		{
1084
+				*aoDestination = L'\0';
1085
+		}
1086
+		return aoDestination;
1087
 }
1088
 
1089
 
1090
 static void Hex2RGBW(wchar_t const aHexRGB[8], unsigned char aoResultRGB[3])
1091
 {
1092
-        wchar_t lColorChannel[8];
1093
-        if (aoResultRGB)
1094
-        {
1095
-                if (aHexRGB)
1096
-                {
1097
-                        wcscpy(lColorChannel, aHexRGB);
1098
-                        aoResultRGB[2] = (unsigned char)wcstoul(lColorChannel + 5, NULL, 16);
1099
-                        lColorChannel[5] = '\0';
1100
-                        aoResultRGB[1] = (unsigned char)wcstoul(lColorChannel + 3, NULL, 16);
1101
-                        lColorChannel[3] = '\0';
1102
-                        aoResultRGB[0] = (unsigned char)wcstoul(lColorChannel + 1, NULL, 16);
1103
-                        /* printf("%d %d %d\n", aoResultRGB[0], aoResultRGB[1], aoResultRGB[2]); */
1104
-                }
1105
-                else
1106
-                {
1107
-                        aoResultRGB[0] = 0;
1108
-                        aoResultRGB[1] = 0;
1109
-                        aoResultRGB[2] = 0;
1110
-                }
1111
-        }
1112
+		wchar_t lColorChannel[8];
1113
+		if (aoResultRGB)
1114
+		{
1115
+				if (aHexRGB)
1116
+				{
1117
+						wcscpy(lColorChannel, aHexRGB);
1118
+						aoResultRGB[2] = (unsigned char)wcstoul(lColorChannel + 5, NULL, 16);
1119
+						lColorChannel[5] = '\0';
1120
+						aoResultRGB[1] = (unsigned char)wcstoul(lColorChannel + 3, NULL, 16);
1121
+						lColorChannel[3] = '\0';
1122
+						aoResultRGB[0] = (unsigned char)wcstoul(lColorChannel + 1, NULL, 16);
1123
+						/* printf("%d %d %d\n", aoResultRGB[0], aoResultRGB[1], aoResultRGB[2]); */
1124
+				}
1125
+				else
1126
+				{
1127
+						aoResultRGB[0] = 0;
1128
+						aoResultRGB[1] = 0;
1129
+						aoResultRGB[2] = 0;
1130
+				}
1131
+		}
1132
 }
1133
 
1134
 
1135
 static void RGB2HexW( unsigned char const aRGB[3], wchar_t aoResultHexRGB[8])
1136
 {
1137
 #if (defined(__cplusplus ) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__clang__)
1138
-	wchar_t const * const lPrintFormat = L"#%02hhx%02hhx%02hhx";
1139
+		wchar_t const * const lPrintFormat = L"#%02hhx%02hhx%02hhx";
1140
 #else
1141
-	wchar_t const * const lPrintFormat = L"#%02hx%02hx%02hx";
1142
+		wchar_t const * const lPrintFormat = L"#%02hx%02hx%02hx";
1143
 #endif
1144
 
1145
-        if (aoResultHexRGB)
1146
-        {
1147
-                if (aRGB)
1148
-                {
1149
-                        /* wprintf(L"aoResultHexRGB %s\n", aoResultHexRGB); */
1150
+		if (aoResultHexRGB)
1151
+		{
1152
+				if (aRGB)
1153
+				{
1154
+						/* wprintf(L"aoResultHexRGB %s\n", aoResultHexRGB); */
1155
 #if !defined(__BORLANDC__) && !defined(__TINYC__) && !(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
1156
-					swprintf(aoResultHexRGB, 8, lPrintFormat, aRGB[0], aRGB[1], aRGB[2]);
1157
+										swprintf(aoResultHexRGB, 8, lPrintFormat, aRGB[0], aRGB[1], aRGB[2]);
1158
 #else
1159
-					swprintf(aoResultHexRGB, lPrintFormat, aRGB[0], aRGB[1], aRGB[2]);
1160
+										swprintf(aoResultHexRGB, lPrintFormat, aRGB[0], aRGB[1], aRGB[2]);
1161
 #endif
1162
 
1163
-                }
1164
-                else
1165
-                {
1166
-                        aoResultHexRGB[0] = 0;
1167
-                        aoResultHexRGB[1] = 0;
1168
-                        aoResultHexRGB[2] = 0;
1169
-                }
1170
-        }
1171
+				}
1172
+				else
1173
+				{
1174
+						aoResultHexRGB[0] = 0;
1175
+						aoResultHexRGB[1] = 0;
1176
+						aoResultHexRGB[2] = 0;
1177
+				}
1178
+		}
1179
 }
1180
 
1181
 
1182
 static int dirExists(char const * aDirPath)
1183
 {
1184
-#if defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)
1185
-    struct _stat lInfo;
1186
+#if (defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)) || defined(__BORLANDC__) || defined(__WATCOMC__)
1187
+	struct _stat lInfo;
1188
 #else
1189
-    struct __stat64 lInfo;
1190
+	struct __stat64 lInfo;
1191
 #endif
1192
-        wchar_t * lTmpWChar;
1193
-        int lStatRet;
1194
-		size_t lDirLen;
1195
+		wchar_t * lTmpWChar;
1196
+		int lStatRet;
1197
+				size_t lDirLen;
1198
 
1199
-		if (!aDirPath)
1200
-			return 0;
1201
-		lDirLen = strlen(aDirPath);
1202
-		if (!lDirLen)
1203
-			return 1;
1204
-		if ( (lDirLen == 2) && (aDirPath[1] == ':') )
1205
-			return 1;
1206
+				if (!aDirPath)
1207
+						return 0;
1208
+				lDirLen = strlen(aDirPath);
1209
+				if (!lDirLen)
1210
+						return 1;
1211
+				if ( (lDirLen == 2) && (aDirPath[1] == ':') )
1212
+						return 1;
1213
 
1214
-        if (tinyfd_winUtf8)
1215
-        {
1216
-			lTmpWChar = tinyfd_utf8to16(aDirPath);
1217
-#if defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)
1218
-            lStatRet = _wstat(lTmpWChar, &lInfo);
1219
+		if (tinyfd_winUtf8)
1220
+		{
1221
+						lTmpWChar = tinyfd_utf8to16(aDirPath);
1222
+#if (defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)) || defined(__BORLANDC__) || defined(__WATCOMC__)
1223
+			lStatRet = _wstat(lTmpWChar, &lInfo);
1224
 #else
1225
-            lStatRet = _wstat64(lTmpWChar, &lInfo);
1226
+			lStatRet = _wstat64(lTmpWChar, &lInfo);
1227
 #endif
1228
-            if (lStatRet != 0)
1229
-                    return 0;
1230
-            else if (lInfo.st_mode & S_IFDIR)
1231
-                    return 1;
1232
-            else
1233
-                        return 0;
1234
-        }
1235
-#if defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)
1236
-        else if (_stat(aDirPath, &lInfo) != 0)
1237
+			if (lStatRet != 0)
1238
+					return 0;
1239
+			else if (lInfo.st_mode & S_IFDIR)
1240
+					return 1;
1241
+			else
1242
+						return 0;
1243
+		}
1244
+#if (defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)) || defined(__BORLANDC__) || defined(__WATCOMC__)
1245
+		else if (_stat(aDirPath, &lInfo) != 0)
1246
 #else
1247
-        else if (_stat64(aDirPath, &lInfo) != 0)
1248
+		else if (_stat64(aDirPath, &lInfo) != 0)
1249
 #endif
1250
-                return 0;
1251
-        else if (lInfo.st_mode & S_IFDIR)
1252
-                return 1;
1253
-        else
1254
-                return 0;
1255
+				return 0;
1256
+		else if (lInfo.st_mode & S_IFDIR)
1257
+				return 1;
1258
+		else
1259
+				return 0;
1260
 }
1261
 
1262
 
1263
 static int fileExists(char const * aFilePathAndName)
1264
 {
1265
-#if defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)
1266
-    struct _stat lInfo;
1267
+#if (defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)) || defined(__BORLANDC__) || defined(__WATCOMC__)
1268
+	struct _stat lInfo;
1269
 #else
1270
-    struct __stat64 lInfo;
1271
+	struct __stat64 lInfo;
1272
 #endif
1273
-        wchar_t * lTmpWChar;
1274
-        int lStatRet;
1275
-        FILE * lIn;
1276
+		wchar_t * lTmpWChar;
1277
+		int lStatRet;
1278
+		FILE * lIn;
1279
 
1280
-        if (!aFilePathAndName || !strlen(aFilePathAndName))
1281
-        {
1282
-                return 0;
1283
-        }
1284
+		if (!aFilePathAndName || !strlen(aFilePathAndName))
1285
+		{
1286
+				return 0;
1287
+		}
1288
 
1289
-        if (tinyfd_winUtf8)
1290
-        {
1291
-			lTmpWChar = tinyfd_utf8to16(aFilePathAndName);
1292
-#if defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)
1293
-            lStatRet = _wstat(lTmpWChar, &lInfo);
1294
+		if (tinyfd_winUtf8)
1295
+		{
1296
+						lTmpWChar = tinyfd_utf8to16(aFilePathAndName);
1297
+#if (defined(__MINGW32_MAJOR_VERSION) && !defined(__MINGW64__) && (__MINGW32_MAJOR_VERSION <= 3)) || defined(__BORLANDC__) || defined(__WATCOMC__)
1298
+			lStatRet = _wstat(lTmpWChar, &lInfo);
1299
 #else
1300
-            lStatRet = _wstat64(lTmpWChar, &lInfo);
1301
+			lStatRet = _wstat64(lTmpWChar, &lInfo);
1302
 #endif
1303
 
1304
-            if (lStatRet != 0)
1305
-                    return 0;
1306
-            else if (lInfo.st_mode & _S_IFREG)
1307
-                    return 1;
1308
-            else
1309
-                    return 0;
1310
-        }
1311
-        else
1312
-        {
1313
-                lIn = fopen(aFilePathAndName, "r");
1314
-                if (!lIn)
1315
-                {
1316
-                        return 0;
1317
-                }
1318
-                fclose(lIn);
1319
-                return 1;
1320
-        }
1321
+			if (lStatRet != 0)
1322
+					return 0;
1323
+			else if (lInfo.st_mode & _S_IFREG)
1324
+					return 1;
1325
+			else
1326
+					return 0;
1327
+		}
1328
+		else
1329
+		{
1330
+				lIn = fopen(aFilePathAndName, "r");
1331
+				if (!lIn)
1332
+				{
1333
+						return 0;
1334
+				}
1335
+				fclose(lIn);
1336
+				return 1;
1337
+		}
1338
 }
1339
 
1340
 static void replaceWchar(wchar_t * aString,
1341
-	wchar_t aOldChr,
1342
-	wchar_t aNewChr)
1343
+		wchar_t aOldChr,
1344
+		wchar_t aNewChr)
1345
 {
1346
-	wchar_t * p;
1347
+		wchar_t * p;
1348
 
1349
-	if (!aString)
1350
-	{
1351
-		return ;
1352
-	}
1353
+		if (!aString)
1354
+		{
1355
+				return ;
1356
+		}
1357
 
1358
-	if (aOldChr == aNewChr)
1359
-	{
1360
-		return ;
1361
-	}
1362
+		if (aOldChr == aNewChr)
1363
+		{
1364
+				return ;
1365
+		}
1366
 
1367
-	p = aString;
1368
-	while ((p = wcsrchr(p, aOldChr)))
1369
-	{
1370
-		*p = aNewChr;
1371
+		p = aString;
1372
+		while ((p = wcsrchr(p, aOldChr)))
1373
+		{
1374
+				*p = aNewChr;
1375
 #ifdef TINYFD_NOCCSUNICODE
1376
-		p++;
1377
+				p++;
1378
 #endif
1379
-		p++;
1380
-	}
1381
-	return ;
1382
+				p++;
1383
+		}
1384
+		return ;
1385
 }
1386
 
1387
 
1388
 static int quoteDetectedW(wchar_t const * aString)
1389
 {
1390
-	wchar_t const * p;
1391
+		wchar_t const * p;
1392
 
1393
-	if (!aString) return 0;
1394
+		if (!aString) return 0;
1395
 
1396
-	p = aString;
1397
-	while ((p = wcsrchr(p, L'\'')))
1398
-	{
1399
-		return 1;
1400
-	}
1401
+		p = aString;
1402
+		while ((p = wcsrchr(p, L'\'')))
1403
+		{
1404
+				return 1;
1405
+		}
1406
 
1407
-	p = aString;
1408
-	while ((p = wcsrchr(p, L'\"')))
1409
-	{
1410
-		return 1;
1411
-	}
1412
+		p = aString;
1413
+		while ((p = wcsrchr(p, L'\"')))
1414
+		{
1415
+				return 1;
1416
+		}
1417
 
1418
-	return 0;
1419
+		return 0;
1420
 }
1421
 
1422
 #endif /* _WIN32 */
1423
 
1424
 /* source and destination can be the same or ovelap*/
1425
 static char * ensureFilesExist(char * aDestination,
1426
-        char const * aSourcePathsAndNames)
1427
+		char const * aSourcePathsAndNames)
1428
 {
1429
-        char * lDestination = aDestination;
1430
-        char const * p;
1431
-        char const * p2;
1432
-        size_t lLen;
1433
+		char * lDestination = aDestination;
1434
+		char const * p;
1435
+		char const * p2;
1436
+		size_t lLen;
1437
 
1438
-        if (!aSourcePathsAndNames)
1439
-        {
1440
-                return NULL;
1441
-        }
1442
-        lLen = strlen(aSourcePathsAndNames);
1443
-        if (!lLen)
1444
-        {
1445
-                return NULL;
1446
-        }
1447
+		if (!aSourcePathsAndNames)
1448
+		{
1449
+				return NULL;
1450
+		}
1451
+		lLen = strlen(aSourcePathsAndNames);
1452
+		if (!lLen)
1453
+		{
1454
+				return NULL;
1455
+		}
1456
 
1457
-        p = aSourcePathsAndNames;
1458
-        while ((p2 = strchr(p, '|')) != NULL)
1459
-        {
1460
-                lLen = p2 - p;
1461
-                memmove(lDestination, p, lLen);
1462
-                lDestination[lLen] = '\0';
1463
-                if (fileExists(lDestination))
1464
-                {
1465
-                        lDestination += lLen;
1466
-                        *lDestination = '|';
1467
-                        lDestination++;
1468
-                }
1469
-                p = p2 + 1;
1470
-        }
1471
-        if (fileExists(p))
1472
-        {
1473
-                lLen = strlen(p);
1474
-                memmove(lDestination, p, lLen);
1475
-                lDestination[lLen] = '\0';
1476
-        }
1477
-        else
1478
-        {
1479
-                *(lDestination - 1) = '\0';
1480
-        }
1481
-        return aDestination;
1482
+		p = aSourcePathsAndNames;
1483
+		while ((p2 = strchr(p, '|')) != NULL)
1484
+		{
1485
+				lLen = p2 - p;
1486
+				memmove(lDestination, p, lLen);
1487
+				lDestination[lLen] = '\0';
1488
+				if (fileExists(lDestination))
1489
+				{
1490
+						lDestination += lLen;
1491
+						*lDestination = '|';
1492
+						lDestination++;
1493
+				}
1494
+				p = p2 + 1;
1495
+		}
1496
+		if (fileExists(p))
1497
+		{
1498
+				lLen = strlen(p);
1499
+				memmove(lDestination, p, lLen);
1500
+				lDestination[lLen] = '\0';
1501
+		}
1502
+		else
1503
+		{
1504
+				*(lDestination - 1) = '\0';
1505
+		}
1506
+		return aDestination;
1507
 }
1508
 
1509
 #ifdef _WIN32
1510
 
1511
 static int __stdcall EnumThreadWndProc(HWND hwnd, LPARAM lParam)
1512
 {
1513
-        wchar_t lTitleName[MAX_PATH];
1514
-        GetWindowTextW(hwnd, lTitleName, MAX_PATH);
1515
-        /* wprintf(L"lTitleName %ls \n", lTitleName);  */
1516
-        if (wcscmp(L"tinyfiledialogsTopWindow", lTitleName) == 0)
1517
-        {
1518
-                SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
1519
-                return 0;
1520
-        }
1521
-        return 1;
1522
+		wchar_t lTitleName[MAX_PATH];
1523
+		wchar_t const* lDialogTitle = (wchar_t const *) lParam;
1524
+
1525
+		GetWindowTextW(hwnd, lTitleName, MAX_PATH);
1526
+		/* wprintf(L"lTitleName %ls \n", lTitleName);  */
1527
+
1528
+		if (wcscmp(lDialogTitle, lTitleName) == 0)
1529
+		{
1530
+				SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
1531
+				return 0;
1532
+		}
1533
+		return 1;
1534
 }
1535
 
1536
 
1537
 static void hiddenConsoleW(wchar_t const * aString, wchar_t const * aDialogTitle, int aInFront)
1538
 {
1539
-        STARTUPINFOW StartupInfo;
1540
-        PROCESS_INFORMATION ProcessInfo;
1541
+		STARTUPINFOW StartupInfo;
1542
+		PROCESS_INFORMATION ProcessInfo;
1543
 
1544
-        if (!aString || !wcslen(aString) ) return;
1545
+		if (!aString || !wcslen(aString) ) return;
1546
 
1547
-        memset(&StartupInfo, 0, sizeof(StartupInfo));
1548
-        StartupInfo.cb = sizeof(STARTUPINFOW);
1549
-        StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
1550
-        StartupInfo.wShowWindow = SW_HIDE;
1551
+		memset(&StartupInfo, 0, sizeof(StartupInfo));
1552
+		StartupInfo.cb = sizeof(STARTUPINFOW);
1553
+		StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
1554
+		StartupInfo.wShowWindow = SW_HIDE;
1555
 
1556
-        if (!CreateProcessW(NULL, (LPWSTR)aString, NULL, NULL, FALSE,
1557
-                                CREATE_NEW_CONSOLE, NULL, NULL,
1558
-                                &StartupInfo, &ProcessInfo))
1559
-        {
1560
-                return; /* GetLastError(); */
1561
-        }
1562
+		if (!CreateProcessW(NULL, (LPWSTR)aString, NULL, NULL, FALSE,
1563
+								CREATE_NEW_CONSOLE, NULL, NULL,
1564
+								&StartupInfo, &ProcessInfo))
1565
+		{
1566
+				return; /* GetLastError(); */
1567
+		}
1568
 
1569
-        WaitForInputIdle(ProcessInfo.hProcess, INFINITE);
1570
-        if (aInFront)
1571
-        {
1572
-                while (EnumWindows(EnumThreadWndProc, (LPARAM)NULL)) {}
1573
-                SetWindowTextW(GetForegroundWindow(), aDialogTitle);
1574
-        }
1575
-        WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
1576
-        CloseHandle(ProcessInfo.hThread);
1577
-        CloseHandle(ProcessInfo.hProcess);
1578
+		WaitForInputIdle(ProcessInfo.hProcess, INFINITE);
1579
+		if (aInFront)
1580
+		{
1581
+				while (EnumWindows(EnumThreadWndProc, (LPARAM)aDialogTitle)) {}
1582
+		}
1583
+		WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
1584
+		CloseHandle(ProcessInfo.hThread);
1585
+		CloseHandle(ProcessInfo.hProcess);
1586
 }
1587
 
1588
 
1589
 int tinyfd_messageBoxW(
1590
-        wchar_t const * aTitle, /* NULL or "" */
1591
-        wchar_t const * aMessage, /* NULL or ""  may contain \n and \t */
1592
-        wchar_t const * aDialogType, /* "ok" "okcancel" "yesno" "yesnocancel" */
1593
-        wchar_t const * aIconType, /* "info" "warning" "error" "question" */
1594
-        int aDefaultButton) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
1595
+		wchar_t const * aTitle, /* NULL or "" */
1596
+		wchar_t const * aMessage, /* NULL or ""  may contain \n and \t */
1597
+		wchar_t const * aDialogType, /* "ok" "okcancel" "yesno" "yesnocancel" */
1598
+		wchar_t const * aIconType, /* "info" "warning" "error" "question" */
1599
+		int aDefaultButton) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
1600
 {
1601
-        int lBoxReturnValue;
1602
-        UINT aCode;
1603
+		int lBoxReturnValue;
1604
+		UINT aCode;
1605
 
1606
-        if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return 1; }
1607
+		if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return 1; }
1608
 
1609
-		if (quoteDetectedW(aTitle)) return tinyfd_messageBoxW(L"INVALID TITLE WITH QUOTES", aMessage, aDialogType, aIconType, aDefaultButton);
1610
-		if (quoteDetectedW(aMessage)) return tinyfd_messageBoxW(aTitle, L"INVALID MESSAGE WITH QUOTES", aDialogType, aIconType, aDefaultButton);
1611
+		/*if (quoteDetectedW(aTitle)) return tinyfd_messageBoxW(L"INVALID TITLE WITH QUOTES", aMessage, aDialogType, aIconType, aDefaultButton);
1612
+		if (quoteDetectedW(aMessage)) return tinyfd_messageBoxW(aTitle, L"INVALID MESSAGE WITH QUOTES", aDialogType, aIconType, aDefaultButton);*/
1613
 
1614
-        if (aIconType && !wcscmp(L"warning", aIconType))
1615
-        {
1616
-                aCode = MB_ICONWARNING;
1617
-        }
1618
-        else if (aIconType && !wcscmp(L"error", aIconType))
1619
-        {
1620
-                aCode = MB_ICONERROR;
1621
-        }
1622
-        else if (aIconType && !wcscmp(L"question", aIconType))
1623
-        {
1624
-                aCode = MB_ICONQUESTION;
1625
-        }
1626
-        else
1627
-        {
1628
-                aCode = MB_ICONINFORMATION;
1629
-        }
1630
+		if (aIconType && !wcscmp(L"warning", aIconType))
1631
+		{
1632
+				aCode = MB_ICONWARNING;
1633
+		}
1634
+		else if (aIconType && !wcscmp(L"error", aIconType))
1635
+		{
1636
+				aCode = MB_ICONERROR;
1637
+		}
1638
+		else if (aIconType && !wcscmp(L"question", aIconType))
1639
+		{
1640
+				aCode = MB_ICONQUESTION;
1641
+		}
1642
+		else
1643
+		{
1644
+				aCode = MB_ICONINFORMATION;
1645
+		}
1646
 
1647
-        if (aDialogType && !wcscmp(L"okcancel", aDialogType))
1648
-        {
1649
-                aCode += MB_OKCANCEL;
1650
-                if (!aDefaultButton)
1651
-                {
1652
-                        aCode += MB_DEFBUTTON2;
1653
-                }
1654
-        }
1655
-        else if (aDialogType && !wcscmp(L"yesno", aDialogType))
1656
-        {
1657
-                aCode += MB_YESNO;
1658
-                if (!aDefaultButton)
1659
-                {
1660
-                        aCode += MB_DEFBUTTON2;
1661
-                }
1662
-        }
1663
-        else
1664
-        {
1665
-                aCode += MB_OK;
1666
-        }
1667
+		if (aDialogType && !wcscmp(L"okcancel", aDialogType))
1668
+		{
1669
+				aCode += MB_OKCANCEL;
1670
+				if (!aDefaultButton)
1671
+				{
1672
+						aCode += MB_DEFBUTTON2;
1673
+				}
1674
+		}
1675
+		else if (aDialogType && !wcscmp(L"yesno", aDialogType))
1676
+		{
1677
+				aCode += MB_YESNO;
1678
+				if (!aDefaultButton)
1679
+				{
1680
+						aCode += MB_DEFBUTTON2;
1681
+				}
1682
+		}
1683
+		else if (aDialogType && !wcscmp(L"yesnocancel", aDialogType))
1684
+		{
1685
+			aCode += MB_YESNOCANCEL;
1686
+			if (aDefaultButton == 1)
1687
+			{
1688
+				aCode += MB_DEFBUTTON1;
1689
+			}
1690
+			else if (aDefaultButton == 2)
1691
+			{
1692
+				aCode += MB_DEFBUTTON2;
1693
+			}
1694
+			else
1695
+			{
1696
+				aCode += MB_DEFBUTTON3;
1697
+			}
1698
+		}
1699
+		else
1700
+		{
1701
+				aCode += MB_OK;
1702
+		}
1703
 
1704
-        aCode += MB_TOPMOST;
1705
+		aCode += MB_TOPMOST;
1706
 
1707
-        lBoxReturnValue = MessageBoxW(GetForegroundWindow(), aMessage, aTitle, aCode);
1708
-        if (((aDialogType
1709
-                && wcscmp(L"okcancel", aDialogType)
1710
-                && wcscmp(L"yesno", aDialogType)))
1711
-                || (lBoxReturnValue == IDOK)
1712
-                || (lBoxReturnValue == IDYES))
1713
-        {
1714
-                return 1;
1715
-        }
1716
-        else
1717
-        {
1718
-                return 0;
1719
-        }
1720
+		lBoxReturnValue = MessageBoxW(GetForegroundWindow(), aMessage, aTitle, aCode);
1721
+
1722
+		if ( (lBoxReturnValue == IDNO) && (aDialogType && !wcscmp(L"yesnocancel", aDialogType)) )
1723
+		{
1724
+			return 2;
1725
+		}
1726
+		else if ( (lBoxReturnValue == IDOK) || (lBoxReturnValue == IDYES) )
1727
+		{
1728
+			return 1;
1729
+		}
1730
+		else
1731
+		{
1732
+			return 0;
1733
+		}
1734
 }
1735
 
1736
 
1737
 /* return has only meaning for tinyfd_query */
1738
 int tinyfd_notifyPopupW(
1739
-        wchar_t const * aTitle, /* NULL or L"" */
1740
-        wchar_t const * aMessage, /* NULL or L"" may contain \n \t */
1741
-        wchar_t const * aIconType) /* L"info" L"warning" L"error" */
1742
+		wchar_t const * aTitle, /* NULL or L"" */
1743
+		wchar_t const * aMessage, /* NULL or L"" may contain \n \t */
1744
+		wchar_t const * aIconType) /* L"info" L"warning" L"error" */
1745
 {
1746
-        wchar_t * lDialogString;
1747
-        size_t lTitleLen;
1748
-        size_t lMessageLen;
1749
-        size_t lDialogStringLen;
1750
+		wchar_t * lDialogString;
1751
+		size_t lTitleLen;
1752
+		size_t lMessageLen;
1753
+		size_t lDialogStringLen;
1754
 
1755
-        if (aTitle && !wcscmp(aTitle, L"tinyfd_query")) { strcpy(tinyfd_response, "windows_wchar"); return 1; }
1756
+		if (aTitle && !wcscmp(aTitle, L"tinyfd_query")) { strcpy(tinyfd_response, "windows_wchar"); return 1; }
1757
 
1758
-        if (quoteDetectedW(aTitle)) return tinyfd_notifyPopupW(L"INVALID TITLE WITH QUOTES", aMessage, aIconType);
1759
+		if (quoteDetectedW(aTitle)) return tinyfd_notifyPopupW(L"INVALID TITLE WITH QUOTES", aMessage, aIconType);
1760
 		if (quoteDetectedW(aMessage)) return tinyfd_notifyPopupW(aTitle, L"INVALID MESSAGE WITH QUOTES", aIconType);
1761
 
1762
-        lTitleLen = aTitle ? wcslen(aTitle) : 0;
1763
-        lMessageLen = aMessage ? wcslen(aMessage) : 0;
1764
-        lDialogStringLen = 3 * MAX_PATH_OR_CMD + lTitleLen + lMessageLen;
1765
-        lDialogString = (wchar_t *)malloc(2 * lDialogStringLen);
1766
-        if (!lDialogString) return 0;
1767
+		lTitleLen = aTitle ? wcslen(aTitle) : 0;
1768
+		lMessageLen = aMessage ? wcslen(aMessage) : 0;
1769
+		lDialogStringLen = 3 * MAX_PATH_OR_CMD + lTitleLen + lMessageLen;
1770
+		lDialogString = (wchar_t *) malloc(2 * lDialogStringLen);
1771
+		if (!lDialogString) return 0;
1772
 
1773
-        wcscpy(lDialogString, L"powershell.exe -command \"\
1774
+		wcscpy(lDialogString, L"powershell.exe -command \"\
1775
 function Show-BalloonTip {\
1776
 [cmdletbinding()] \
1777
 param( \
1778
@@ -1159,7 +1199,7 @@
1779
 $path = Get-Process -id $pid | Select-Object -ExpandProperty Path ; \
1780
 $icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) ;");
1781
 
1782
-        wcscat(lDialogString, L"\
1783
+		wcscat(lDialogString, L"\
1784
 $balloon.Icon = $icon ; \
1785
 $balloon.BalloonTipIcon = $IconType ; \
1786
 $balloon.BalloonTipText = $Message ; \
1787
@@ -1169,110 +1209,112 @@
1788
 $balloon.ShowBalloonTip(5000)};\
1789
 Show-BalloonTip");
1790
 
1791
-        if (aTitle && wcslen(aTitle))
1792
-        {
1793
-                wcscat(lDialogString, L" -Title '");
1794
-                wcscat(lDialogString, aTitle);
1795
-                wcscat(lDialogString, L"'");
1796
-        }
1797
-        if (aMessage && wcslen(aMessage))
1798
-        {
1799
-                wcscat(lDialogString, L" -Message '");
1800
-                wcscat(lDialogString, aMessage);
1801
-                wcscat(lDialogString, L"'");
1802
-        }
1803
-        if (aMessage && wcslen(aIconType))
1804
-        {
1805
-                wcscat(lDialogString, L" -IconType '");
1806
-                wcscat(lDialogString, aIconType);
1807
-                wcscat(lDialogString, L"'");
1808
-        }
1809
-        wcscat(lDialogString, L"\"");
1810
+		if (aTitle && wcslen(aTitle))
1811
+		{
1812
+				wcscat(lDialogString, L" -Title '");
1813
+				wcscat(lDialogString, aTitle);
1814
+				wcscat(lDialogString, L"'");
1815
+		}
1816
+		if (aMessage && wcslen(aMessage))
1817
+		{
1818
+				wcscat(lDialogString, L" -Message '");
1819
+				wcscat(lDialogString, aMessage);
1820
+				wcscat(lDialogString, L"'");
1821
+		}
1822
+		if (aMessage && wcslen(aIconType))
1823
+		{
1824
+				wcscat(lDialogString, L" -IconType '");
1825
+				wcscat(lDialogString, aIconType);
1826
+				wcscat(lDialogString, L"'");
1827
+		}
1828
+		wcscat(lDialogString, L"\"");
1829
 
1830
-        /* wprintf ( L"lDialogString: %ls\n" , lDialogString ) ; */
1831
+		/* wprintf ( L"lDialogString: %ls\n" , lDialogString ) ; */
1832
 
1833
-        hiddenConsoleW(lDialogString, aTitle, 0);
1834
-        free(lDialogString);
1835
-        return 1;
1836
+		hiddenConsoleW(lDialogString, aTitle, 0);
1837
+		free(lDialogString);
1838
+		return 1;
1839
 }
1840
 
1841
 
1842
 wchar_t * tinyfd_inputBoxW(
1843
-        wchar_t const * aTitle, /* NULL or L"" */
1844
-        wchar_t const * aMessage, /* NULL or L"" (\n and \t have no effect) */
1845
-        wchar_t const * aDefaultInput) /* L"" , if NULL it's a passwordBox */
1846
+		wchar_t const * aTitle, /* NULL or L"" */
1847
+		wchar_t const * aMessage, /* NULL or L"" (\n and \t have no effect) */
1848
+		wchar_t const * aDefaultInput) /* L"" , if NULL it's a passwordBox */
1849
 {
1850
-        static wchar_t lBuff[MAX_PATH_OR_CMD];
1851
-        wchar_t * lDialogString;
1852
-        FILE * lIn;
1853
-        FILE * lFile;
1854
-        int lResult;
1855
-        size_t lTitleLen;
1856
-        size_t lMessageLen;
1857
-        size_t lDialogStringLen;
1858
+		static wchar_t lBuff[MAX_PATH_OR_CMD];
1859
+		wchar_t * lDialogString;
1860
+		FILE * lIn;
1861
+		FILE * lFile;
1862
+		int lResult;
1863
+		size_t lTitleLen;
1864
+		size_t lMessageLen;
1865
+		size_t lDialogStringLen;
1866
 
1867
-        if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
1868
+		if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
1869
 
1870
 		if (quoteDetectedW(aTitle)) return tinyfd_inputBoxW(L"INVALID TITLE WITH QUOTES", aMessage, aDefaultInput);
1871
 		if (quoteDetectedW(aMessage)) return tinyfd_inputBoxW(aTitle, L"INVALID MESSAGE WITH QUOTES", aDefaultInput);
1872
-		if (quoteDetectedW(aDefaultInput)) return tinyfd_inputBoxW(aTitle, aMessage, L"INVALID DEFAULT_INPUT WITH QUOTES");
1873
+		if (quoteDetectedW(aDefaultInput)) return tinyfd_inputBoxW(aTitle, aMessage, L"INVALID DEFAULT_INPUT WITH QUOTES: use the GRAVE ACCENT \\x60 instead.");
1874
 
1875
-        lTitleLen =  aTitle ? wcslen(aTitle) : 0 ;
1876
-        lMessageLen =  aMessage ? wcslen(aMessage) : 0 ;
1877
-        lDialogStringLen = 3 * MAX_PATH_OR_CMD + lTitleLen + lMessageLen;
1878
-        lDialogString = (wchar_t *)malloc(2 * lDialogStringLen);
1879
+		lTitleLen =  aTitle ? wcslen(aTitle) : 0 ;
1880
+		lMessageLen =  aMessage ? wcslen(aMessage) : 0 ;
1881
+		lDialogStringLen = 3 * MAX_PATH_OR_CMD + lTitleLen + lMessageLen;
1882
+		lDialogString = (wchar_t *) malloc(2 * lDialogStringLen);
1883
 
1884
-        if (aDefaultInput)
1885
-        {
1886
-			swprintf(lDialogString,
1887
+		if (aDefaultInput)
1888
+		{
1889
+						swprintf(lDialogString,
1890
 #if !defined(__BORLANDC__) && !defined(__TINYC__) && !(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
1891
-                lDialogStringLen,
1892
+				lDialogStringLen,
1893
 #endif
1894
-                L"%ls\\tinyfd.vbs", _wgetenv(L"TEMP"));
1895
-        }
1896
-        else
1897
-        {
1898
-                swprintf(lDialogString,
1899
+				L"%ls\\tinyfd.vbs", _wgetenv(L"TEMP"));
1900
+		}
1901
+		else
1902
+		{
1903
+				swprintf(lDialogString,
1904
 #if !defined(__BORLANDC__) && !defined(__TINYC__) && !(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
1905
-                        lDialogStringLen,
1906
+						lDialogStringLen,
1907
 #endif
1908
-                L"%ls\\tinyfd.hta", _wgetenv(L"TEMP"));
1909
-        }
1910
-        lIn = _wfopen(lDialogString, L"w");
1911
-        if (!lIn)
1912
-        {
1913
-                free(lDialogString);
1914
-                return NULL;
1915
-        }
1916
+				L"%ls\\tinyfd.hta", _wgetenv(L"TEMP"));
1917
+		}
1918
+		lIn = _wfopen(lDialogString, L"w");
1919
+		if (!lIn)
1920
+		{
1921
+				free(lDialogString);
1922
+				return NULL;
1923
+		}
1924
 
1925
-        if ( aDefaultInput )
1926
-        {
1927
-                wcscpy(lDialogString, L"Dim result:result=InputBox(\"");
1928
-                if (aMessage && wcslen(aMessage))
1929
-                {
1930
-					wcscpy(lBuff, aMessage);
1931
-					replaceWchar(lBuff, L'\n', L' ');
1932
-					wcscat(lDialogString, lBuff);
1933
-                }
1934
-                wcscat(lDialogString, L"\",\"tinyfiledialogsTopWindow\",\"");
1935
-                if (aDefaultInput && wcslen(aDefaultInput))
1936
-                {
1937
-					wcscpy(lBuff, aDefaultInput);
1938
-					replaceWchar(lBuff, L'\n', L' ');
1939
-					wcscat(lDialogString, lBuff);
1940
-                }
1941
-                wcscat(lDialogString, L"\"):If IsEmpty(result) then:WScript.Echo 0");
1942
-                wcscat(lDialogString, L":Else: WScript.Echo \"1\" & result : End If");
1943
-        }
1944
-        else
1945
-        {
1946
-                wcscpy(lDialogString, L"\n\
1947
+		if ( aDefaultInput )
1948
+		{
1949
+				wcscpy(lDialogString, L"Dim result:result=InputBox(\"");
1950
+				if (aMessage && wcslen(aMessage))
1951
+				{
1952
+										wcscpy(lBuff, aMessage);
1953
+										replaceWchar(lBuff, L'\n', L' ');
1954
+										wcscat(lDialogString, lBuff);
1955
+				}
1956
+				wcscat(lDialogString, L"\",\"");
1957
+				if (aTitle) wcscat(lDialogString, aTitle);
1958
+				wcscat(lDialogString, L"\",\"");
1959
+
1960
+				if (aDefaultInput && wcslen(aDefaultInput))
1961
+				{
1962
+										wcscpy(lBuff, aDefaultInput);
1963
+										replaceWchar(lBuff, L'\n', L' ');
1964
+										wcscat(lDialogString, lBuff);
1965
+				}
1966
+				wcscat(lDialogString, L"\"):If IsEmpty(result) then:WScript.Echo 0");
1967
+				wcscat(lDialogString, L":Else: WScript.Echo \"1\" & result : End If");
1968
+		}
1969
+		else
1970
+		{
1971
+				wcscpy(lDialogString, L"\n\
1972
 <html>\n\
1973
 <head>\n\
1974
 <title>");
1975
-
1976
-                wcscat(lDialogString, L"tinyfiledialogsTopWindow");
1977
-                wcscat(lDialogString, L"</title>\n\
1978
+				if (aTitle) wcscat(lDialogString, aTitle);
1979
+				wcscat(lDialogString, L"</title>\n\
1980
 <HTA:APPLICATION\n\
1981
 ID = 'tinyfdHTA'\n\
1982
 APPLICATIONNAME = 'tinyfd_inputBox'\n\
1983
@@ -1296,7 +1338,7 @@
1984
 End Sub\n\
1985
 \n");
1986
 
1987
-                wcscat(lDialogString, L"\
1988
+				wcscat(lDialogString, L"\
1989
 Sub Window_onUnload\n\
1990
 Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n\
1991
 Set oShell = CreateObject(\"WScript.Shell\")\n\
1992
@@ -1320,7 +1362,7 @@
1993
 End Sub\n\
1994
 \n");
1995
 
1996
-                wcscat(lDialogString, L"Sub Default_Buttons\n\
1997
+				wcscat(lDialogString, L"Sub Default_Buttons\n\
1998
 If Window.Event.KeyCode = 13 Then\n\
1999
 btn_OK.Click\n\
2000
 ElseIf Window.Event.KeyCode = 27 Then\n\
2001
@@ -1335,9 +1377,9 @@
2002
 <tr border = '0'>\n\
2003
 <td align = 'left' valign = 'middle' style='Font-Family:Arial'>\n");
2004
 
2005
-                wcscat(lDialogString, aMessage ? aMessage : L"");
2006
+				wcscat(lDialogString, aMessage ? aMessage : L"");
2007
 
2008
-                wcscat(lDialogString, L"\n\
2009
+				wcscat(lDialogString, L"\n\
2010
 </td>\n\
2011
 <td align = 'right' valign = 'middle' style = 'margin-top: 0em'>\n\
2012
 <table  align = 'right' style = 'margin-right: 0em;'>\n\
2013
@@ -1350,7 +1392,7 @@
2014
 </tr>\n\
2015
 </table>\n");
2016
 
2017
-                wcscat(lDialogString, L"<table width = '100%' height = '100%' align = 'center' border = '0'>\n\
2018
+				wcscat(lDialogString, L"<table width = '100%' height = '100%' align = 'center' border = '0'>\n\
2019
 <tr>\n\
2020
 <td align = 'left' valign = 'top'>\n\
2021
 <input type = 'password' id = 'txt_input'\n\
2022
@@ -1361,238 +1403,238 @@
2023
 </body>\n\
2024
 </html>\n\
2025
 "               ) ;
2026
-        }
2027
-        fputws(lDialogString, lIn);
2028
-        fclose(lIn);
2029
+		}
2030
+		fputws(lDialogString, lIn);
2031
+		fclose(lIn);
2032
 
2033
-        if (aDefaultInput)
2034
-        {
2035
-                swprintf(lDialogString,
2036
+		if (aDefaultInput)
2037
+		{
2038
+				swprintf(lDialogString,
2039
 #if !defined(__BORLANDC__) && !defined(__TINYC__) && !(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
2040
-                        lDialogStringLen,
2041
+						lDialogStringLen,
2042
 #endif
2043
-                        L"%ls\\tinyfd.txt",_wgetenv(L"TEMP"));
2044
+						L"%ls\\tinyfd.txt",_wgetenv(L"TEMP"));
2045
 
2046
 #ifdef TINYFD_NOCCSUNICODE
2047
-				lFile = _wfopen(lDialogString, L"w");
2048
-				fputc(0xFF, lFile);
2049
-				fputc(0xFE, lFile);
2050
+								lFile = _wfopen(lDialogString, L"w");
2051
+								fputc(0xFF, lFile);
2052
+								fputc(0xFE, lFile);
2053
 #else
2054
-				lFile = _wfopen(lDialogString, L"wt, ccs=UNICODE"); /*or ccs=UTF-16LE*/
2055
+								lFile = _wfopen(lDialogString, L"wt, ccs=UNICODE"); /*or ccs=UTF-16LE*/
2056
 #endif
2057
-				fclose(lFile);
2058
+								fclose(lFile);
2059
 
2060
-                wcscpy(lDialogString, L"cmd.exe /c cscript.exe //U //Nologo ");
2061
-                wcscat(lDialogString, L"\"%TEMP%\\tinyfd.vbs\" ");
2062
-                wcscat(lDialogString, L">> \"%TEMP%\\tinyfd.txt\"");
2063
-        }
2064
-        else
2065
-        {
2066
-                wcscpy(lDialogString,
2067
-                        L"cmd.exe /c mshta.exe \"%TEMP%\\tinyfd.hta\"");
2068
-        }
2069
+				wcscpy(lDialogString, L"cmd.exe /c cscript.exe //U //Nologo ");
2070
+				wcscat(lDialogString, L"\"%TEMP%\\tinyfd.vbs\" ");
2071
+				wcscat(lDialogString, L">> \"%TEMP%\\tinyfd.txt\"");
2072
+		}
2073
+		else
2074
+		{
2075
+				wcscpy(lDialogString,
2076
+						L"cmd.exe /c mshta.exe \"%TEMP%\\tinyfd.hta\"");
2077
+		}
2078
 
2079
-        /* wprintf ( "lDialogString: %ls\n" , lDialogString ) ; */
2080
+		/* wprintf ( "lDialogString: %ls\n" , lDialogString ) ; */
2081
 
2082
-        hiddenConsoleW(lDialogString, aTitle, 1);
2083
+		hiddenConsoleW(lDialogString, aTitle, 1);
2084
 
2085
-        swprintf(lDialogString,
2086
+		swprintf(lDialogString,
2087
 #if !defined(__BORLANDC__) && !defined(__TINYC__) && !(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
2088
-                lDialogStringLen,
2089
+				lDialogStringLen,
2090
 #endif
2091
-				L"%ls\\tinyfd.txt", _wgetenv(L"TEMP"));
2092
-		/* wprintf(L"lDialogString: %ls\n", lDialogString); */
2093
+								L"%ls\\tinyfd.txt", _wgetenv(L"TEMP"));
2094
+				/* wprintf(L"lDialogString: %ls\n", lDialogString); */
2095
 #ifdef TINYFD_NOCCSUNICODE
2096
-		if (!(lIn = _wfopen(lDialogString, L"r")))
2097
+				if (!(lIn = _wfopen(lDialogString, L"r")))
2098
 #else
2099
-		if (!(lIn = _wfopen(lDialogString, L"rt, ccs=UNICODE"))) /*or ccs=UTF-16LE*/
2100
+				if (!(lIn = _wfopen(lDialogString, L"rt, ccs=UNICODE"))) /*or ccs=UTF-16LE*/
2101
 #endif
2102
-		{
2103
-                _wremove(lDialogString);
2104
-                free(lDialogString);
2105
-                return NULL;
2106
-        }
2107
+				{
2108
+				_wremove(lDialogString);
2109
+				free(lDialogString);
2110
+				return NULL;
2111
+		}
2112
 
2113
-		memset(lBuff, 0, MAX_PATH_OR_CMD * sizeof(wchar_t) );
2114
+				memset(lBuff, 0, MAX_PATH_OR_CMD * sizeof(wchar_t) );
2115
 
2116
 #ifdef TINYFD_NOCCSUNICODE
2117
-		fgets((char *)lBuff, 2*MAX_PATH_OR_CMD, lIn);
2118
+				fgets((char *)lBuff, 2*MAX_PATH_OR_CMD, lIn);
2119
 #else
2120
-		fgetws(lBuff, MAX_PATH_OR_CMD, lIn);
2121
+				fgetws(lBuff, MAX_PATH_OR_CMD, lIn);
2122
 #endif
2123
-		fclose(lIn);
2124
-		wipefileW(lDialogString);
2125
-		_wremove(lDialogString);
2126
+				fclose(lIn);
2127
+				wipefileW(lDialogString);
2128
+				_wremove(lDialogString);
2129
 
2130
-		if (aDefaultInput)
2131
-		{
2132
-			swprintf(lDialogString,
2133
+				if (aDefaultInput)
2134
+				{
2135
+						swprintf(lDialogString,
2136
 #if !defined(__BORLANDC__) && !defined(__TINYC__) && !(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
2137
-                        lDialogStringLen,
2138
+						lDialogStringLen,
2139
 #endif
2140
-                        L"%ls\\tinyfd.vbs", _wgetenv(L"TEMP"));
2141
-        }
2142
-        else
2143
-        {
2144
-                swprintf(lDialogString,
2145
+						L"%ls\\tinyfd.vbs", _wgetenv(L"TEMP"));
2146
+		}
2147
+		else
2148
+		{
2149
+				swprintf(lDialogString,
2150
 #if !defined(__BORLANDC__) && !defined(__TINYC__) && !(defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR))
2151
-                        lDialogStringLen,
2152
+						lDialogStringLen,
2153
 #endif
2154
-                        L"%ls\\tinyfd.hta", _wgetenv(L"TEMP"));
2155
-        }
2156
-        _wremove(lDialogString);
2157
-        free(lDialogString);
2158
-        /* wprintf( L"lBuff: %ls\n" , lBuff ) ; */
2159
+						L"%ls\\tinyfd.hta", _wgetenv(L"TEMP"));
2160
+		}
2161
+		_wremove(lDialogString);
2162
+		free(lDialogString);
2163
+		/* wprintf( L"lBuff: %ls\n" , lBuff ) ; */
2164
 #ifdef TINYFD_NOCCSUNICODE
2165
-		lResult = !wcsncmp(lBuff+1, L"1", 1);
2166
+				lResult = !wcsncmp(lBuff+1, L"1", 1);
2167
 #else
2168
-		lResult = !wcsncmp(lBuff, L"1", 1);
2169
+				lResult = !wcsncmp(lBuff, L"1", 1);
2170
 #endif
2171
 
2172
-        /* printf( "lResult: %d \n" , lResult ) ; */
2173
-        if (!lResult)
2174
-        {
2175
-            return NULL ;
2176
-        }
2177
+		/* printf( "lResult: %d \n" , lResult ) ; */
2178
+		if (!lResult)
2179
+		{
2180
+			return NULL ;
2181
+		}
2182
 
2183
-        /* wprintf( "lBuff+1: %ls\n" , lBuff+1 ) ; */
2184
+		/* wprintf( "lBuff+1: %ls\n" , lBuff+1 ) ; */
2185
 
2186
 #ifdef TINYFD_NOCCSUNICODE
2187
-		if (aDefaultInput)
2188
-		{
2189
-			lDialogStringLen = wcslen(lBuff) ;
2190
-			lBuff[lDialogStringLen - 1] = L'\0';
2191
-			lBuff[lDialogStringLen - 2] = L'\0';
2192
-		}
2193
-		return lBuff + 2;
2194
+				if (aDefaultInput)
2195
+				{
2196
+						lDialogStringLen = wcslen(lBuff) ;
2197
+						lBuff[lDialogStringLen - 1] = L'\0';
2198
+						lBuff[lDialogStringLen - 2] = L'\0';
2199
+				}
2200
+				return lBuff + 2;
2201
 #else
2202
-		if (aDefaultInput) lBuff[wcslen(lBuff) - 1] = L'\0';
2203
-		return lBuff + 1;
2204
+				if (aDefaultInput) lBuff[wcslen(lBuff) - 1] = L'\0';
2205
+				return lBuff + 1;
2206
 #endif
2207
 }
2208
 
2209
 
2210
 wchar_t * tinyfd_saveFileDialogW(
2211
-        wchar_t const * aTitle, /* NULL or "" */
2212
-        wchar_t const * aDefaultPathAndFile, /* NULL or "" */
2213
-        int aNumOfFilterPatterns, /* 0 */
2214
-        wchar_t const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
2215
-        wchar_t const * aSingleFilterDescription) /* NULL or "image files" */
2216
+		wchar_t const * aTitle, /* NULL or "" */
2217
+		wchar_t const * aDefaultPathAndOrFile, /* NULL or "" */
2218
+		int aNumOfFilterPatterns, /* 0 */
2219
+		wchar_t const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
2220
+		wchar_t const * aSingleFilterDescription) /* NULL or "image files" */
2221
 {
2222
-        static wchar_t lBuff[MAX_PATH_OR_CMD];
2223
-        wchar_t lDirname[MAX_PATH_OR_CMD];
2224
-        wchar_t lDialogString[MAX_PATH_OR_CMD];
2225
-        wchar_t lFilterPatterns[MAX_PATH_OR_CMD] = L"";
2226
-        wchar_t * p;
2227
-        wchar_t * lRetval;
2228
-		wchar_t const * ldefExt = NULL;
2229
-		int i;
2230
-        HRESULT lHResult;
2231
-        OPENFILENAMEW ofn = {0};
2232
+		static wchar_t lBuff[MAX_PATH_OR_CMD];
2233
+		wchar_t lDirname[MAX_PATH_OR_CMD];
2234
+		wchar_t lDialogString[MAX_PATH_OR_CMD];
2235
+		wchar_t lFilterPatterns[MAX_PATH_OR_CMD] = L"";
2236
+		wchar_t * p;
2237
+		wchar_t * lRetval;
2238
+				wchar_t const * ldefExt = NULL;
2239
+				int i;
2240
+		HRESULT lHResult;
2241
+		OPENFILENAMEW ofn = {0};
2242
 
2243
-        if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
2244
+		if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
2245
 
2246
-		if (quoteDetectedW(aTitle)) return tinyfd_saveFileDialogW(L"INVALID TITLE WITH QUOTES", aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
2247
-		if (quoteDetectedW(aDefaultPathAndFile)) return tinyfd_saveFileDialogW(aTitle, L"INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
2248
-		if (quoteDetectedW(aSingleFilterDescription)) return tinyfd_saveFileDialogW(aTitle, aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, L"INVALID FILTER_DESCRIPTION WITH QUOTES");
2249
+		/*if (quoteDetectedW(aTitle)) return tinyfd_saveFileDialogW(L"INVALID TITLE WITH QUOTES", aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
2250
+		if (quoteDetectedW(aDefaultPathAndOrFile)) return tinyfd_saveFileDialogW(aTitle, L"INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
2251
+		if (quoteDetectedW(aSingleFilterDescription)) return tinyfd_saveFileDialogW(aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, L"INVALID FILTER_DESCRIPTION WITH QUOTES");
2252
 		for (i = 0; i < aNumOfFilterPatterns; i++)
2253
 		{
2254
-			if (quoteDetectedW(aFilterPatterns[i])) return tinyfd_saveFileDialogW(L"INVALID FILTER_PATTERN WITH QUOTES", aDefaultPathAndFile, 0, NULL, NULL);
2255
-		}
2256
+				if (quoteDetectedW(aFilterPatterns[i])) return tinyfd_saveFileDialogW(L"INVALID FILTER_PATTERN WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultPathAndOrFile, 0, NULL, NULL);
2257
+		}*/
2258
 
2259
-        lHResult = CoInitializeEx(NULL, 0);
2260
+		lHResult = CoInitializeEx(NULL, 0);
2261
 
2262
-        getPathWithoutFinalSlashW(lDirname, aDefaultPathAndFile);
2263
-        getLastNameW(lBuff, aDefaultPathAndFile);
2264
+		getPathWithoutFinalSlashW(lDirname, aDefaultPathAndOrFile);
2265
+		getLastNameW(lBuff, aDefaultPathAndOrFile);
2266
 
2267
-        if (aNumOfFilterPatterns > 0)
2268
-        {
2269
-			ldefExt = aFilterPatterns[0];
2270
+		if (aNumOfFilterPatterns > 0)
2271
+		{
2272
+						ldefExt = aFilterPatterns[0];
2273
 
2274
-                if (aSingleFilterDescription && wcslen(aSingleFilterDescription))
2275
-                {
2276
-                        wcscpy(lFilterPatterns, aSingleFilterDescription);
2277
-                        wcscat(lFilterPatterns, L"\n");
2278
-                }
2279
-                wcscat(lFilterPatterns, aFilterPatterns[0]);
2280
-                for (i = 1; i < aNumOfFilterPatterns; i++)
2281
-                {
2282
-                        wcscat(lFilterPatterns, L";");
2283
-                        wcscat(lFilterPatterns, aFilterPatterns[i]);
2284
-                }
2285
-                wcscat(lFilterPatterns, L"\n");
2286
-                if (!(aSingleFilterDescription && wcslen(aSingleFilterDescription)))
2287
-                {
2288
-                        wcscpy(lDialogString, lFilterPatterns);
2289
-                        wcscat(lFilterPatterns, lDialogString);
2290
-                }
2291
-                wcscat(lFilterPatterns, L"All Files\n*.*\n");
2292
-                p = lFilterPatterns;
2293
-                while ((p = wcschr(p, L'\n')) != NULL)
2294
-                {
2295
-                        *p = L'\0';
2296
-                        p++;
2297
-                }
2298
-        }
2299
+				if (aSingleFilterDescription && wcslen(aSingleFilterDescription))
2300
+				{
2301
+						wcscpy(lFilterPatterns, aSingleFilterDescription);
2302
+						wcscat(lFilterPatterns, L"\n");
2303
+				}
2304
+				wcscat(lFilterPatterns, aFilterPatterns[0]);
2305
+				for (i = 1; i < aNumOfFilterPatterns; i++)
2306
+				{
2307
+						wcscat(lFilterPatterns, L";");
2308
+						wcscat(lFilterPatterns, aFilterPatterns[i]);
2309
+				}
2310
+				wcscat(lFilterPatterns, L"\n");
2311
+				if (!(aSingleFilterDescription && wcslen(aSingleFilterDescription)))
2312
+				{
2313
+						wcscpy(lDialogString, lFilterPatterns);
2314
+						wcscat(lFilterPatterns, lDialogString);
2315
+				}
2316
+				wcscat(lFilterPatterns, L"All Files\n*.*\n");
2317
+				p = lFilterPatterns;
2318
+				while ((p = wcschr(p, L'\n')) != NULL)
2319
+				{
2320
+						*p = L'\0';
2321
+						p++;
2322
+				}
2323
+		}
2324
 
2325
-        ofn.lStructSize = sizeof(OPENFILENAMEW);
2326
-        ofn.hwndOwner = GetForegroundWindow();
2327
-        ofn.hInstance = 0;
2328
-        ofn.lpstrFilter = wcslen(lFilterPatterns) ? lFilterPatterns : NULL;
2329
-        ofn.lpstrCustomFilter = NULL;
2330
-        ofn.nMaxCustFilter = 0;
2331
-        ofn.nFilterIndex = 1;
2332
-        ofn.lpstrFile = lBuff;
2333
+		ofn.lStructSize = sizeof(OPENFILENAMEW);
2334
+		ofn.hwndOwner = GetForegroundWindow();
2335
+		ofn.hInstance = 0;
2336
+		ofn.lpstrFilter = wcslen(lFilterPatterns) ? lFilterPatterns : NULL;
2337
+		ofn.lpstrCustomFilter = NULL;
2338
+		ofn.nMaxCustFilter = 0;
2339
+		ofn.nFilterIndex = 1;
2340
+		ofn.lpstrFile = lBuff;
2341
 
2342
-        ofn.nMaxFile = MAX_PATH_OR_CMD;
2343
-        ofn.lpstrFileTitle = NULL;
2344
-        ofn.nMaxFileTitle = MAX_PATH_OR_CMD/2;
2345
-        ofn.lpstrInitialDir = wcslen(lDirname) ? lDirname : NULL;
2346
-        ofn.lpstrTitle = aTitle && wcslen(aTitle) ? aTitle : NULL;
2347
-        ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST ;
2348
-        ofn.nFileOffset = 0;
2349
-        ofn.nFileExtension = 0;
2350
-		ofn.lpstrDefExt = ldefExt;
2351
-        ofn.lCustData = 0L;
2352
-        ofn.lpfnHook = NULL;
2353
-        ofn.lpTemplateName = NULL;
2354
+		ofn.nMaxFile = MAX_PATH_OR_CMD;
2355
+		ofn.lpstrFileTitle = NULL;
2356
+		ofn.nMaxFileTitle = MAX_PATH_OR_CMD/2;
2357
+		ofn.lpstrInitialDir = wcslen(lDirname) ? lDirname : NULL;
2358
+		ofn.lpstrTitle = aTitle && wcslen(aTitle) ? aTitle : NULL;
2359
+		ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST ;
2360
+		ofn.nFileOffset = 0;
2361
+		ofn.nFileExtension = 0;
2362
+				ofn.lpstrDefExt = ldefExt;
2363
+		ofn.lCustData = 0L;
2364
+		ofn.lpfnHook = NULL;
2365
+		ofn.lpTemplateName = NULL;
2366
 
2367
-        if (GetSaveFileNameW(&ofn) == 0)
2368
-        {
2369
-                lRetval = NULL;
2370
-        }
2371
-        else
2372
-        {
2373
-                lRetval = lBuff;
2374
-        }
2375
+		if (GetSaveFileNameW(&ofn) == 0)
2376
+		{
2377
+				lRetval = NULL;
2378
+		}
2379
+		else
2380
+		{
2381
+				lRetval = lBuff;
2382
+		}
2383
 
2384
-        if (lHResult == S_OK || lHResult == S_FALSE)
2385
-        {
2386
-                CoUninitialize();
2387
-        }
2388
-        return lRetval;
2389
+		if (lHResult == S_OK || lHResult == S_FALSE)
2390
+		{
2391
+				CoUninitialize();
2392
+		}
2393
+		return lRetval;
2394
 }
2395
 
2396
 
2397
 wchar_t * tinyfd_openFileDialogW(
2398
-        wchar_t const * aTitle, /* NULL or "" */
2399
-		wchar_t const * aDefaultPathAndFile, /* NULL or "" */
2400
-        int aNumOfFilterPatterns, /* 0 */
2401
+		wchar_t const * aTitle, /* NULL or "" */
2402
+		wchar_t const * aDefaultPathAndOrFile, /* NULL or "" */
2403
+		int aNumOfFilterPatterns, /* 0 */
2404
 		wchar_t const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
2405
 		wchar_t const * aSingleFilterDescription, /* NULL or "image files" */
2406
-        int aAllowMultipleSelects) /* 0 or 1 ; -1 to free allocated memory and return */
2407
+		int aAllowMultipleSelects) /* 0 or 1 ; -1 to free allocated memory and return */
2408
 {
2409
-        size_t lLengths[MAX_MULTIPLE_FILES];
2410
-        wchar_t lDirname[MAX_PATH_OR_CMD];
2411
-        wchar_t lFilterPatterns[MAX_PATH_OR_CMD] = L"";
2412
-        wchar_t lDialogString[MAX_PATH_OR_CMD];
2413
-        wchar_t * lPointers[MAX_MULTIPLE_FILES+1];
2414
-        wchar_t * p;
2415
-        int i, j;
2416
+		size_t lLengths[MAX_MULTIPLE_FILES];
2417
+		wchar_t lDirname[MAX_PATH_OR_CMD];
2418
+		wchar_t lFilterPatterns[MAX_PATH_OR_CMD] = L"";
2419
+		wchar_t lDialogString[MAX_PATH_OR_CMD];
2420
+		wchar_t * lPointers[MAX_MULTIPLE_FILES+1];
2421
+		wchar_t * p;
2422
+		int i, j;
2423
 		size_t lBuffLen;
2424
 		DWORD lFullBuffLen;
2425
-        HRESULT lHResult;
2426
-        OPENFILENAMEW ofn = { 0 };
2427
+		HRESULT lHResult;
2428
+		OPENFILENAMEW ofn = { 0 };
2429
 		static wchar_t * lBuff = NULL;
2430
 
2431
 		free(lBuff);
2432
@@ -1601,120 +1643,121 @@
2433
 
2434
 		if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
2435
 
2436
-		if (quoteDetectedW(aTitle)) return tinyfd_openFileDialogW(L"INVALID TITLE WITH QUOTES", aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
2437
-		if (quoteDetectedW(aDefaultPathAndFile)) return tinyfd_openFileDialogW(aTitle, L"INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
2438
-		if (quoteDetectedW(aSingleFilterDescription)) return tinyfd_openFileDialogW(aTitle, aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, L"INVALID FILTER_DESCRIPTION WITH QUOTES", aAllowMultipleSelects);
2439
+		/*if (quoteDetectedW(aTitle)) return tinyfd_openFileDialogW(L"INVALID TITLE WITH QUOTES", aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
2440
+		if (quoteDetectedW(aDefaultPathAndOrFile)) return tinyfd_openFileDialogW(aTitle, L"INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
2441
+		if (quoteDetectedW(aSingleFilterDescription)) return tinyfd_openFileDialogW(aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, L"INVALID FILTER_DESCRIPTION WITH QUOTES", aAllowMultipleSelects);
2442
 		for (i = 0; i < aNumOfFilterPatterns; i++)
2443
 		{
2444
-			if (quoteDetectedW(aFilterPatterns[i])) return tinyfd_openFileDialogW(L"INVALID FILTER_PATTERN WITH QUOTES", aDefaultPathAndFile, 0, NULL, NULL, aAllowMultipleSelects);
2445
-		}
2446
+				if (quoteDetectedW(aFilterPatterns[i])) return tinyfd_openFileDialogW(L"INVALID FILTER_PATTERN WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultPathAndOrFile, 0, NULL, NULL, aAllowMultipleSelects);
2447
+		}*/
2448
 
2449
 		if (aAllowMultipleSelects)
2450
 		{
2451
-			lFullBuffLen = MAX_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
2452
-			lBuff = (wchar_t*)(malloc(lFullBuffLen * sizeof(wchar_t)));
2453
-			if (!lBuff)
2454
-			{
2455
-				lFullBuffLen = LOW_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
2456
-				lBuff = (wchar_t*)( malloc( lFullBuffLen * sizeof(wchar_t)));
2457
-			}
2458
+				lFullBuffLen = MAX_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
2459
+				lBuff = (wchar_t*) malloc(lFullBuffLen * sizeof(wchar_t));
2460
+				if (!lBuff)
2461
+				{
2462
+						lFullBuffLen = LOW_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
2463
+						lBuff = (wchar_t*) malloc( lFullBuffLen * sizeof(wchar_t));
2464
+				}
2465
 		}
2466
 		else
2467
 		{
2468
-			lFullBuffLen = MAX_PATH_OR_CMD + 1;
2469
-			lBuff = (wchar_t*)(malloc(lFullBuffLen * sizeof(wchar_t)));
2470
+				lFullBuffLen = MAX_PATH_OR_CMD + 1;
2471
+				lBuff = (wchar_t*) malloc(lFullBuffLen * sizeof(wchar_t));
2472
 		}
2473
 		if (!lBuff) return NULL;
2474
 
2475
-        lHResult = CoInitializeEx(NULL, 0);
2476
+		lHResult = CoInitializeEx(NULL, 0);
2477
 
2478
-        getPathWithoutFinalSlashW(lDirname, aDefaultPathAndFile);
2479
-        getLastNameW(lBuff, aDefaultPathAndFile);
2480
+		getPathWithoutFinalSlashW(lDirname, aDefaultPathAndOrFile);
2481
+		getLastNameW(lBuff, aDefaultPathAndOrFile);
2482
 
2483
-        if (aNumOfFilterPatterns > 0)
2484
-        {
2485
-                if (aSingleFilterDescription && wcslen(aSingleFilterDescription))
2486
-                {
2487
-                        wcscpy(lFilterPatterns, aSingleFilterDescription);
2488
-                        wcscat(lFilterPatterns, L"\n");
2489
-                }
2490
-                wcscat(lFilterPatterns, aFilterPatterns[0]);
2491
-                for (i = 1; i < aNumOfFilterPatterns; i++)
2492
-                {
2493
-                        wcscat(lFilterPatterns, L";");
2494
-                        wcscat(lFilterPatterns, aFilterPatterns[i]);
2495
-                }
2496
-                wcscat(lFilterPatterns, L"\n");
2497
-                if (!(aSingleFilterDescription && wcslen(aSingleFilterDescription)))
2498
-                {
2499
-                        wcscpy(lDialogString, lFilterPatterns);
2500
-                        wcscat(lFilterPatterns, lDialogString);
2501
-                }
2502
-                wcscat(lFilterPatterns, L"All Files\n*.*\n");
2503
-                p = lFilterPatterns;
2504
-                while ((p = wcschr(p, L'\n')) != NULL)
2505
-                {
2506
-                        *p = L'\0';
2507
-                        p++;
2508
-                }
2509
-        }
2510
+		if (aNumOfFilterPatterns > 0)
2511
+		{
2512
+			if (aSingleFilterDescription && wcslen(aSingleFilterDescription))
2513
+			{
2514
+				wcscpy(lFilterPatterns, aSingleFilterDescription);
2515
+				wcscat(lFilterPatterns, L"\n");
2516
+			}
2517
+			wcscat(lFilterPatterns, aFilterPatterns[0]);
2518
+			for (i = 1; i < aNumOfFilterPatterns; i++)
2519
+			{
2520
+				wcscat(lFilterPatterns, L";");
2521
+				wcscat(lFilterPatterns, aFilterPatterns[i]);
2522
+			}
2523
+			wcscat(lFilterPatterns, L"\n");
2524
+			if (!(aSingleFilterDescription && wcslen(aSingleFilterDescription)))
2525
+			{
2526
+				wcscpy(lDialogString, lFilterPatterns);
2527
+				wcscat(lFilterPatterns, lDialogString);
2528
+			}
2529
+			wcscat(lFilterPatterns, L"All Files\n*.*\n");
2530
+			p = lFilterPatterns;
2531
+			while ((p = wcschr(p, L'\n')) != NULL)
2532
+			{
2533
+				*p = L'\0';
2534
+				p++;
2535
+			}
2536
+		}
2537
 
2538
-        ofn.lStructSize = sizeof(OPENFILENAME);
2539
-        ofn.hwndOwner = GetForegroundWindow();
2540
-        ofn.hInstance = 0;
2541
-        ofn.lpstrFilter = wcslen(lFilterPatterns) ? lFilterPatterns : NULL;
2542
-        ofn.lpstrCustomFilter = NULL;
2543
-        ofn.nMaxCustFilter = 0;
2544
-        ofn.nFilterIndex = 1;
2545
-        ofn.lpstrFile = lBuff;
2546
+		ofn.lStructSize = sizeof(OPENFILENAME);
2547
+		ofn.hwndOwner = GetForegroundWindow();
2548
+		ofn.hInstance = 0;
2549
+		ofn.lpstrFilter = wcslen(lFilterPatterns) ? lFilterPatterns : NULL;
2550
+		ofn.lpstrCustomFilter = NULL;
2551
+		ofn.nMaxCustFilter = 0;
2552
+		ofn.nFilterIndex = 1;
2553
+		ofn.lpstrFile = lBuff;
2554
 		ofn.nMaxFile = lFullBuffLen;
2555
-        ofn.lpstrFileTitle = NULL;
2556
-        ofn.nMaxFileTitle = MAX_PATH_OR_CMD / 2;
2557
-        ofn.lpstrInitialDir = wcslen(lDirname) ? lDirname : NULL;
2558
-        ofn.lpstrTitle = aTitle && wcslen(aTitle) ? aTitle : NULL;
2559
-        ofn.Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
2560
-        ofn.nFileOffset = 0;
2561
-        ofn.nFileExtension = 0;
2562
-        ofn.lpstrDefExt = NULL;
2563
-        ofn.lCustData = 0L;
2564
-        ofn.lpfnHook = NULL;
2565
-        ofn.lpTemplateName = NULL;
2566
+		ofn.lpstrFileTitle = NULL;
2567
+		ofn.nMaxFileTitle = MAX_PATH_OR_CMD / 2;
2568
+		ofn.lpstrInitialDir = wcslen(lDirname) ? lDirname : NULL;
2569
+		ofn.lpstrTitle = aTitle && wcslen(aTitle) ? aTitle : NULL;
2570
+		ofn.Flags = OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
2571
+		ofn.nFileOffset = 0;
2572
+		ofn.nFileExtension = 0;
2573
+		ofn.lpstrDefExt = NULL;
2574
+		ofn.lCustData = 0L;
2575
+		ofn.lpfnHook = NULL;
2576
+		ofn.lpTemplateName = NULL;
2577
 
2578
-        if (aAllowMultipleSelects)
2579
-        {
2580
-                ofn.Flags |= OFN_ALLOWMULTISELECT;
2581
-        }
2582
+		if (aAllowMultipleSelects)
2583
+		{
2584
+			ofn.Flags |= OFN_ALLOWMULTISELECT;
2585
+		}
2586
 
2587
-        if (GetOpenFileNameW(&ofn) == 0)
2588
-        {
2589
+		if (GetOpenFileNameW(&ofn) == 0)
2590
+		{
2591
 			free(lBuff);
2592
 			lBuff = NULL;
2593
-        }
2594
-        else
2595
-        {
2596
-                lBuffLen = wcslen(lBuff);
2597
-                lPointers[0] = lBuff + lBuffLen + 1;
2598
-                if (aAllowMultipleSelects && (lPointers[0][0] != L'\0'))
2599
+		}
2600
+		else
2601
+		{
2602
+			lBuffLen = wcslen(lBuff);
2603
+			lPointers[0] = lBuff + lBuffLen + 1;
2604
+			if (aAllowMultipleSelects && (lPointers[0][0] != L'\0'))
2605
+			{
2606
+				i = 0;
2607
+				do
2608
 				{
2609
-                        i = 0;
2610
-                        do
2611
-                        {
2612
-                                lLengths[i] = wcslen(lPointers[i]);
2613
-                                lPointers[i + 1] = lPointers[i] + lLengths[i] + 1;
2614
-                                i++;
2615
-						} while (lPointers[i][0] != L'\0' && i < MAX_MULTIPLE_FILES );
2616
-						if (i > MAX_MULTIPLE_FILES)
2617
+					lLengths[i] = wcslen(lPointers[i]);
2618
+					lPointers[i + 1] = lPointers[i] + lLengths[i] + 1;
2619
+					i++;
2620
+				} while (lPointers[i][0] != L'\0' && i < MAX_MULTIPLE_FILES );
2621
+
2622
+				if (i > MAX_MULTIPLE_FILES)
2623
+				{
2624
+						free(lBuff);
2625
+						lBuff = NULL;
2626
+				}
2627
+				else
2628
+				{
2629
+						i--;
2630
+						p = lBuff + lFullBuffLen - 1;
2631
+						*p = L'\0';
2632
+						for (j = i; j >= 0; j--)
2633
 						{
2634
-							free(lBuff);
2635
-							lBuff = NULL;
2636
-						}
2637
-						else
2638
-						{
2639
-							i--;
2640
-							p = lBuff + lFullBuffLen - 1;
2641
-							*p = L'\0';
2642
-							for (j = i; j >= 0; j--)
2643
-							{
2644
 								p -= lLengths[j];
2645
 								memmove(p, lPointers[j], lLengths[j] * sizeof(wchar_t));
2646
 								p--;
2647
@@ -1723,1497 +1766,1504 @@
2648
 								memmove(p, lBuff, lBuffLen*sizeof(wchar_t));
2649
 								p--;
2650
 								*p = L'|';
2651
-							}
2652
-							p++;
2653
-							wcscpy(lBuff, p);
2654
-							lBuffLen = wcslen(lBuff);
2655
 						}
2656
+						p++;
2657
+						wcscpy(lBuff, p);
2658
+						lBuffLen = wcslen(lBuff);
2659
 				}
2660
-				if (lBuff) lBuff = (wchar_t*)(realloc(lBuff, (lBuffLen + 1) * sizeof(wchar_t)));
2661
-        }
2662
+			}
2663
+			if (lBuff) lBuff = (wchar_t*)(realloc(lBuff, (lBuffLen + 1) * sizeof(wchar_t)));
2664
+		}
2665
 
2666
-        if (lHResult == S_OK || lHResult == S_FALSE)
2667
-        {
2668
-                CoUninitialize();
2669
-        }
2670
+		if (lHResult == S_OK || lHResult == S_FALSE)
2671
+		{
2672
+			CoUninitialize();
2673
+		}
2674
+
2675
 		return lBuff;
2676
 }
2677
 
2678
 
2679
 BOOL CALLBACK BrowseCallbackProcW_enum(HWND hWndChild, LPARAM lParam)
2680
 {
2681
-    wchar_t buf[255];
2682
-    GetClassNameW(hWndChild, buf, sizeof(buf));
2683
-    if (wcscmp(buf, L"SysTreeView32") == 0) {
2684
-        HTREEITEM hNode = TreeView_GetSelection(hWndChild);
2685
-        TreeView_EnsureVisible(hWndChild, hNode);
2686
-        return FALSE;
2687
-    }
2688
-    return TRUE;
2689
+	wchar_t buf[255];
2690
+	GetClassNameW(hWndChild, buf, sizeof(buf));
2691
+	if (wcscmp(buf, L"SysTreeView32") == 0)
2692
+	{
2693
+		HTREEITEM hNode = TreeView_GetSelection(hWndChild);
2694
+		TreeView_EnsureVisible(hWndChild, hNode);
2695
+		return FALSE;
2696
+	}
2697
+	return TRUE;
2698
 }
2699
 
2700
 
2701
 static int __stdcall BrowseCallbackProcW(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
2702
 {
2703
-    switch (uMsg) {
2704
-        case BFFM_INITIALIZED:
2705
-            SendMessage(hwnd, BFFM_SETSELECTIONW, TRUE, (LPARAM)pData);
2706
-            break;
2707
-        case BFFM_SELCHANGED:
2708
-            EnumChildWindows(hwnd, BrowseCallbackProcW_enum, 0);
2709
-    }
2710
-    return 0;
2711
+	switch (uMsg)
2712
+	{
2713
+		case BFFM_INITIALIZED:
2714
+			SendMessage(hwnd, BFFM_SETSELECTIONW, TRUE, (LPARAM)pData);
2715
+			break;
2716
+		case BFFM_SELCHANGED:
2717
+			EnumChildWindows(hwnd, BrowseCallbackProcW_enum, 0);
2718
+	}
2719
+	return 0;
2720
 }
2721
 
2722
 wchar_t * tinyfd_selectFolderDialogW(
2723
-        wchar_t const * aTitle, /* NULL or "" */
2724
-        wchar_t const * aDefaultPath) /* NULL or "" */
2725
+		wchar_t const * aTitle, /* NULL or "" */
2726
+		wchar_t const * aDefaultPath) /* NULL or "" */
2727
 {
2728
-        static wchar_t lBuff[MAX_PATH_OR_CMD];
2729
+		static wchar_t lBuff[MAX_PATH_OR_CMD];
2730
 		wchar_t * lRetval;
2731
 
2732
-        BROWSEINFOW bInfo;
2733
-        LPITEMIDLIST lpItem;
2734
-        HRESULT lHResult;
2735
+		BROWSEINFOW bInfo;
2736
+		LPITEMIDLIST lpItem;
2737
+		HRESULT lHResult;
2738
 
2739
-        if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
2740
+		if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
2741
 
2742
-		if (quoteDetectedW(aTitle)) return tinyfd_selectFolderDialogW(L"INVALID TITLE WITH QUOTES", aDefaultPath);
2743
-		if (quoteDetectedW(aDefaultPath)) return tinyfd_selectFolderDialogW(aTitle, L"INVALID DEFAULT_PATH WITH QUOTES");
2744
+		/*if (quoteDetectedW(aTitle)) return tinyfd_selectFolderDialogW(L"INVALID TITLE WITH QUOTES", aDefaultPath);
2745
+		if (quoteDetectedW(aDefaultPath)) return tinyfd_selectFolderDialogW(aTitle, L"INVALID DEFAULT_PATH WITH QUOTES");*/
2746
 
2747
-        lHResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
2748
+		lHResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
2749
 
2750
-        bInfo.hwndOwner = GetForegroundWindow();
2751
-        bInfo.pidlRoot = NULL;
2752
-        bInfo.pszDisplayName = lBuff;
2753
-        bInfo.lpszTitle = aTitle && wcslen(aTitle) ? aTitle : NULL;
2754
-        if (lHResult == S_OK || lHResult == S_FALSE)
2755
-        {
2756
-                bInfo.ulFlags = BIF_USENEWUI;
2757
-        }
2758
-        bInfo.lpfn = BrowseCallbackProcW;
2759
-        bInfo.lParam = (LPARAM)aDefaultPath;
2760
-        bInfo.iImage = -1;
2761
+		bInfo.hwndOwner = GetForegroundWindow();
2762
+		bInfo.pidlRoot = NULL;
2763
+		bInfo.pszDisplayName = lBuff;
2764
+		bInfo.lpszTitle = aTitle && wcslen(aTitle) ? aTitle : NULL;
2765
+		if (lHResult == S_OK || lHResult == S_FALSE)
2766
+		{
2767
+				bInfo.ulFlags = BIF_USENEWUI;
2768
+		}
2769
+		bInfo.lpfn = BrowseCallbackProcW;
2770
+		bInfo.lParam = (LPARAM)aDefaultPath;
2771
+		bInfo.iImage = -1;
2772
 
2773
-        lpItem = SHBrowseForFolderW(&bInfo);
2774
-        if (!lpItem)
2775
+		lpItem = SHBrowseForFolderW(&bInfo);
2776
+		if (!lpItem)
2777
+				{
2778
+						lRetval = NULL;
2779
+				}
2780
+				else
2781
 		{
2782
-			lRetval = NULL;
2783
+				SHGetPathFromIDListW(lpItem, lBuff);
2784
+								lRetval = lBuff ;
2785
 		}
2786
-		else
2787
-        {
2788
-                SHGetPathFromIDListW(lpItem, lBuff);
2789
-				lRetval = lBuff ;
2790
-        }
2791
 
2792
-        if (lHResult == S_OK || lHResult == S_FALSE)
2793
-        {
2794
-                CoUninitialize();
2795
-        }
2796
-		return lRetval;
2797
+		if (lHResult == S_OK || lHResult == S_FALSE)
2798
+		{
2799
+				CoUninitialize();
2800
+		}
2801
+				return lRetval;
2802
 }
2803
 
2804
 
2805
 wchar_t * tinyfd_colorChooserW(
2806
-        wchar_t const * aTitle, /* NULL or "" */
2807
-        wchar_t const * aDefaultHexRGB, /* NULL or "#FF0000"*/
2808
-        unsigned char const aDefaultRGB[3], /* { 0 , 255 , 255 } */
2809
-        unsigned char aoResultRGB[3]) /* { 0 , 0 , 0 } */
2810
+		wchar_t const * aTitle, /* NULL or "" */
2811
+		wchar_t const * aDefaultHexRGB, /* NULL or "#FF0000"*/
2812
+		unsigned char const aDefaultRGB[3], /* { 0 , 255 , 255 } */
2813
+		unsigned char aoResultRGB[3]) /* { 0 , 0 , 0 } */
2814
 {
2815
-        static wchar_t lResultHexRGB[8];
2816
-        CHOOSECOLORW cc;
2817
-        COLORREF crCustColors[16];
2818
-        unsigned char lDefaultRGB[3];
2819
-        int lRet;
2820
+		static wchar_t lResultHexRGB[8];
2821
+		CHOOSECOLORW cc;
2822
+		COLORREF crCustColors[16];
2823
+		unsigned char lDefaultRGB[3];
2824
+		int lRet;
2825
 
2826
-        HRESULT lHResult;
2827
+		HRESULT lHResult;
2828
 
2829
-        if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
2830
+		if (aTitle&&!wcscmp(aTitle, L"tinyfd_query")){ strcpy(tinyfd_response, "windows_wchar"); return (wchar_t *)1; }
2831
 
2832
-		if (quoteDetectedW(aTitle)) return tinyfd_colorChooserW(L"INVALID TITLE WITH QUOTES", aDefaultHexRGB, aDefaultRGB, aoResultRGB);
2833
-		if (quoteDetectedW(aDefaultHexRGB)) return tinyfd_colorChooserW(aTitle, L"INVALID DEFAULT_HEX_RGB WITH QUOTES", aDefaultRGB, aoResultRGB);
2834
+		/*if (quoteDetectedW(aTitle)) return tinyfd_colorChooserW(L"INVALID TITLE WITH QUOTES", aDefaultHexRGB, aDefaultRGB, aoResultRGB);
2835
+		if (quoteDetectedW(aDefaultHexRGB)) return tinyfd_colorChooserW(aTitle, L"INVALID DEFAULT_HEX_RGB WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultRGB, aoResultRGB);*/
2836
 
2837
-        lHResult = CoInitializeEx(NULL, 0);
2838
+		lHResult = CoInitializeEx(NULL, 0);
2839
 
2840
-        if ( aDefaultHexRGB )
2841
-        {
2842
-                Hex2RGBW(aDefaultHexRGB, lDefaultRGB);
2843
-        }
2844
-        else
2845
-        {
2846
-                lDefaultRGB[0] = aDefaultRGB[0];
2847
-                lDefaultRGB[1] = aDefaultRGB[1];
2848
-                lDefaultRGB[2] = aDefaultRGB[2];
2849
-        }
2850
+		if ( aDefaultHexRGB )
2851
+		{
2852
+				Hex2RGBW(aDefaultHexRGB, lDefaultRGB);
2853
+		}
2854
+		else
2855
+		{
2856
+				lDefaultRGB[0] = aDefaultRGB[0];
2857
+				lDefaultRGB[1] = aDefaultRGB[1];
2858
+				lDefaultRGB[2] = aDefaultRGB[2];
2859
+		}
2860
 
2861
-        /* we can't use aTitle */
2862
-        cc.lStructSize = sizeof(CHOOSECOLOR);
2863
-        cc.hwndOwner = GetForegroundWindow();
2864
-        cc.hInstance = NULL;
2865
-        cc.rgbResult = RGB(lDefaultRGB[0], lDefaultRGB[1], lDefaultRGB[2]);
2866
-        cc.lpCustColors = crCustColors;
2867
-        cc.Flags = CC_RGBINIT | CC_FULLOPEN | CC_ANYCOLOR ;
2868
-        cc.lCustData = 0;
2869
-        cc.lpfnHook = NULL;
2870
-        cc.lpTemplateName = NULL;
2871
+		/* we can't use aTitle */
2872
+		cc.lStructSize = sizeof(CHOOSECOLOR);
2873
+		cc.hwndOwner = GetForegroundWindow();
2874
+		cc.hInstance = NULL;
2875
+		cc.rgbResult = RGB(lDefaultRGB[0], lDefaultRGB[1], lDefaultRGB[2]);
2876
+		cc.lpCustColors = crCustColors;
2877
+		cc.Flags = CC_RGBINIT | CC_FULLOPEN | CC_ANYCOLOR ;
2878
+		cc.lCustData = 0;
2879
+		cc.lpfnHook = NULL;
2880
+		cc.lpTemplateName = NULL;
2881
 
2882
-        lRet = ChooseColorW(&cc);
2883
+		lRet = ChooseColorW(&cc);
2884
 
2885
-        if (!lRet)
2886
-        {
2887
-                return NULL;
2888
-        }
2889
+		if (!lRet)
2890
+		{
2891
+				return NULL;
2892
+		}
2893
 
2894
-        aoResultRGB[0] = GetRValue(cc.rgbResult);
2895
-        aoResultRGB[1] = GetGValue(cc.rgbResult);
2896
-        aoResultRGB[2] = GetBValue(cc.rgbResult);
2897
+		aoResultRGB[0] = GetRValue(cc.rgbResult);
2898
+		aoResultRGB[1] = GetGValue(cc.rgbResult);
2899
+		aoResultRGB[2] = GetBValue(cc.rgbResult);
2900
 
2901
-        RGB2HexW(aoResultRGB, lResultHexRGB);
2902
+		RGB2HexW(aoResultRGB, lResultHexRGB);
2903
 
2904
-        if (lHResult == S_OK || lHResult == S_FALSE)
2905
-        {
2906
-                CoUninitialize();
2907
-        }
2908
+		if (lHResult == S_OK || lHResult == S_FALSE)
2909
+		{
2910
+				CoUninitialize();
2911
+		}
2912
 
2913
-        return lResultHexRGB;
2914
+		return lResultHexRGB;
2915
 }
2916
 
2917
 
2918
 static int messageBoxWinGui(
2919
-	char const * aTitle, /* NULL or "" */
2920
-	char const * aMessage, /* NULL or ""  may contain \n and \t */
2921
-	char const * aDialogType, /* "ok" "okcancel" "yesno" "yesnocancel" */
2922
-	char const * aIconType, /* "info" "warning" "error" "question" */
2923
-	int aDefaultButton) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
2924
+		char const * aTitle, /* NULL or "" */
2925
+		char const * aMessage, /* NULL or ""  may contain \n and \t */
2926
+		char const * aDialogType, /* "ok" "okcancel" "yesno" "yesnocancel" */
2927
+		char const * aIconType, /* "info" "warning" "error" "question" */
2928
+		int aDefaultButton) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
2929
 {
2930
-	int lIntRetVal;
2931
-	wchar_t lTitle[128] = L"";
2932
-	wchar_t * lMessage = NULL;
2933
-	wchar_t lDialogType[16] = L"";
2934
-	wchar_t lIconType[16] = L"";
2935
-	wchar_t * lTmpWChar;
2936
+		int lIntRetVal;
2937
+		wchar_t lTitle[128] = L"";
2938
+		wchar_t * lMessage = NULL;
2939
+		wchar_t lDialogType[16] = L"";
2940
+		wchar_t lIconType[16] = L"";
2941
+		wchar_t * lTmpWChar;
2942
 
2943
-	if (aTitle)
2944
-	{
2945
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
2946
-		else lTmpWChar = tinyfd_mbcsTo16(aTitle);
2947
-		wcscpy(lTitle, lTmpWChar);
2948
-	}
2949
-	if (aMessage)
2950
-	{
2951
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aMessage);
2952
-		else lTmpWChar = tinyfd_mbcsTo16(aMessage);
2953
-		lMessage = (wchar_t *) malloc((wcslen(lTmpWChar) + 1)* sizeof(wchar_t));
2954
-		if (lMessage) wcscpy(lMessage, lTmpWChar);
2955
-	}
2956
-	if (aDialogType)
2957
-	{
2958
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDialogType);
2959
-		else lTmpWChar = tinyfd_mbcsTo16(aDialogType);
2960
-		wcscpy(lDialogType, lTmpWChar);
2961
-	}
2962
-	if (aIconType)
2963
-	{
2964
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aIconType);
2965
-		else lTmpWChar = tinyfd_mbcsTo16(aIconType);
2966
-		wcscpy(lIconType, lTmpWChar);
2967
-	}
2968
+		if (aTitle)
2969
+		{
2970
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
2971
+				else lTmpWChar = tinyfd_mbcsTo16(aTitle);
2972
+				wcscpy(lTitle, lTmpWChar);
2973
+		}
2974
+		if (aMessage)
2975
+		{
2976
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aMessage);
2977
+				else lTmpWChar = tinyfd_mbcsTo16(aMessage);
2978
+				lMessage = (wchar_t *) malloc((wcslen(lTmpWChar) + 1)* sizeof(wchar_t));
2979
+				if (lMessage) wcscpy(lMessage, lTmpWChar);
2980
+		}
2981
+		if (aDialogType)
2982
+		{
2983
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDialogType);
2984
+				else lTmpWChar = tinyfd_mbcsTo16(aDialogType);
2985
+				wcscpy(lDialogType, lTmpWChar);
2986
+		}
2987
+		if (aIconType)
2988
+		{
2989
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aIconType);
2990
+				else lTmpWChar = tinyfd_mbcsTo16(aIconType);
2991
+				wcscpy(lIconType, lTmpWChar);
2992
+		}
2993
 
2994
-	lIntRetVal = tinyfd_messageBoxW(lTitle, lMessage, lDialogType, lIconType, aDefaultButton);
2995
+		lIntRetVal = tinyfd_messageBoxW(lTitle, lMessage, lDialogType, lIconType, aDefaultButton);
2996
 
2997
-	free(lMessage);
2998
+		free(lMessage);
2999
 
3000
-	return lIntRetVal;
3001
+		return lIntRetVal;
3002
 }
3003
 
3004
 
3005
 static int notifyWinGui(
3006
-	char const * aTitle, /* NULL or "" */
3007
-	char const * aMessage, /* NULL or "" may NOT contain \n nor \t */
3008
-	char const * aIconType)
3009
+		char const * aTitle, /* NULL or "" */
3010
+		char const * aMessage, /* NULL or "" may NOT contain \n nor \t */
3011
+		char const * aIconType)
3012
 {
3013
-	wchar_t lTitle[128] = L"";
3014
-	wchar_t * lMessage = NULL;
3015
-	wchar_t lIconType[16] = L"";
3016
-	wchar_t * lTmpWChar;
3017
+		wchar_t lTitle[128] = L"";
3018
+		wchar_t * lMessage = NULL;
3019
+		wchar_t lIconType[16] = L"";
3020
+		wchar_t * lTmpWChar;
3021
 
3022
-	if (aTitle)
3023
-	{
3024
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3025
-		else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3026
-		wcscpy(lTitle, lTmpWChar);
3027
-	}
3028
-	if (aMessage)
3029
-	{
3030
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aMessage);
3031
-		else lTmpWChar = tinyfd_mbcsTo16(aMessage);
3032
-		lMessage = (wchar_t *) malloc((wcslen(lTmpWChar) + 1)* sizeof(wchar_t));
3033
-        if (lMessage) wcscpy(lMessage, lTmpWChar);
3034
-	}
3035
-	if (aIconType)
3036
-	{
3037
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aIconType);
3038
-		else lTmpWChar = tinyfd_mbcsTo16(aIconType);
3039
-		wcscpy(lIconType, lTmpWChar);
3040
-	}
3041
+		if (aTitle)
3042
+		{
3043
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3044
+				else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3045
+				wcscpy(lTitle, lTmpWChar);
3046
+		}
3047
+		if (aMessage)
3048
+		{
3049
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aMessage);
3050
+				else lTmpWChar = tinyfd_mbcsTo16(aMessage);
3051
+				lMessage = (wchar_t *) malloc((wcslen(lTmpWChar) + 1)* sizeof(wchar_t));
3052
+		if (lMessage) wcscpy(lMessage, lTmpWChar);
3053
+		}
3054
+		if (aIconType)
3055
+		{
3056
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aIconType);
3057
+				else lTmpWChar = tinyfd_mbcsTo16(aIconType);
3058
+				wcscpy(lIconType, lTmpWChar);
3059
+		}
3060
 
3061
-	tinyfd_notifyPopupW(lTitle, lMessage, lIconType);
3062
+		tinyfd_notifyPopupW(lTitle, lMessage, lIconType);
3063
 
3064
-	free(lMessage);
3065
+		free(lMessage);
3066
 
3067
-	return 1;
3068
+		return 1;
3069
 }
3070
 
3071
 
3072
 static int inputBoxWinGui(
3073
-	char * aoBuff,
3074
-	char const * aTitle, /* NULL or "" */
3075
-	char const * aMessage, /* NULL or "" may NOT contain \n nor \t */
3076
-	char const * aDefaultInput) /* "" , if NULL it's a passwordBox */
3077
+		char * aoBuff,
3078
+		char const * aTitle, /* NULL or "" */
3079
+		char const * aMessage, /* NULL or "" may NOT contain \n nor \t */
3080
+		char const * aDefaultInput) /* "" , if NULL it's a passwordBox */
3081
 {
3082
-	wchar_t lTitle[128] = L"";
3083
-	wchar_t * lMessage = NULL;
3084
-	wchar_t lDefaultInput[MAX_PATH_OR_CMD] = L"";
3085
-	wchar_t * lTmpWChar;
3086
-	char * lTmpChar;
3087
+		wchar_t lTitle[128] = L"";
3088
+		wchar_t * lMessage = NULL;
3089
+		wchar_t lDefaultInput[MAX_PATH_OR_CMD] = L"";
3090
+		wchar_t * lTmpWChar;
3091
+		char * lTmpChar;
3092
 
3093
-	if (aTitle)
3094
-	{
3095
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3096
-		else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3097
-		wcscpy(lTitle, lTmpWChar);
3098
-	}
3099
-	if (aMessage)
3100
-	{
3101
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aMessage);
3102
-		else lTmpWChar = tinyfd_mbcsTo16(aMessage);
3103
-		lMessage = (wchar_t *) malloc((wcslen(lTmpWChar) + 1)* sizeof(wchar_t));
3104
-      if (lMessage) wcscpy(lMessage, lTmpWChar);
3105
-	}
3106
-	if (aDefaultInput)
3107
-	{
3108
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultInput);
3109
-		else lTmpWChar = tinyfd_mbcsTo16(aDefaultInput);
3110
-		wcscpy(lDefaultInput, lTmpWChar);
3111
-        lTmpWChar = tinyfd_inputBoxW(lTitle, lMessage, lDefaultInput);
3112
-	}
3113
-    else lTmpWChar = tinyfd_inputBoxW(lTitle, lMessage, NULL);
3114
+		if (aTitle)
3115
+		{
3116
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3117
+				else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3118
+				wcscpy(lTitle, lTmpWChar);
3119
+		}
3120
+		if (aMessage)
3121
+		{
3122
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aMessage);
3123
+				else lTmpWChar = tinyfd_mbcsTo16(aMessage);
3124
+				lMessage = (wchar_t *) malloc((wcslen(lTmpWChar) + 1)* sizeof(wchar_t));
3125
+	  if (lMessage) wcscpy(lMessage, lTmpWChar);
3126
+		}
3127
+		if (aDefaultInput)
3128
+		{
3129
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultInput);
3130
+				else lTmpWChar = tinyfd_mbcsTo16(aDefaultInput);
3131
+				wcscpy(lDefaultInput, lTmpWChar);
3132
+		lTmpWChar = tinyfd_inputBoxW(lTitle, lMessage, lDefaultInput);
3133
+		}
3134
+	else lTmpWChar = tinyfd_inputBoxW(lTitle, lMessage, NULL);
3135
 
3136
-	free(lMessage);
3137
+		free(lMessage);
3138
 
3139
-	if (!lTmpWChar)
3140
-	{
3141
-		aoBuff[0] = '\0';
3142
-		return 0;
3143
-	}
3144
+		if (!lTmpWChar)
3145
+		{
3146
+				aoBuff[0] = '\0';
3147
+				return 0;
3148
+		}
3149
 
3150
-	if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3151
-	else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3152
+		if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3153
+		else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3154
 
3155
-	strcpy(aoBuff, lTmpChar);
3156
+		strcpy(aoBuff, lTmpChar);
3157
 
3158
-	return 1;
3159
+		return 1;
3160
 }
3161
 
3162
 
3163
 static char * saveFileDialogWinGui(
3164
-	char * aoBuff,
3165
-	char const * aTitle, /* NULL or "" */
3166
-	char const * aDefaultPathAndFile, /* NULL or "" */
3167
-	int aNumOfFilterPatterns, /* 0 */
3168
-	char const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
3169
-	char const * aSingleFilterDescription) /* NULL or "image files" */
3170
+		char * aoBuff,
3171
+		char const * aTitle, /* NULL or "" */
3172
+		char const * aDefaultPathAndOrFile, /* NULL or "" */
3173
+		int aNumOfFilterPatterns, /* 0 */
3174
+		char const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
3175
+		char const * aSingleFilterDescription) /* NULL or "image files" */
3176
 {
3177
-	wchar_t lTitle[128] = L"";
3178
-	wchar_t lDefaultPathAndFile[MAX_PATH_OR_CMD] = L"";
3179
-	wchar_t lSingleFilterDescription[128] = L"";
3180
-	wchar_t * * lFilterPatterns;
3181
-	wchar_t * lTmpWChar;
3182
-	char * lTmpChar;
3183
-	int i;
3184
+		wchar_t lTitle[128] = L"";
3185
+		wchar_t lDefaultPathAndFile[MAX_PATH_OR_CMD] = L"";
3186
+		wchar_t lSingleFilterDescription[128] = L"";
3187
+		wchar_t * * lFilterPatterns;
3188
+		wchar_t * lTmpWChar;
3189
+		char * lTmpChar;
3190
+		int i;
3191
 
3192
-	lFilterPatterns = (wchar_t **)malloc(aNumOfFilterPatterns*sizeof(wchar_t *));
3193
-	for (i = 0; i < aNumOfFilterPatterns; i++)
3194
-	{
3195
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aFilterPatterns[i]);
3196
-		else lTmpWChar = tinyfd_mbcsTo16(aFilterPatterns[i]);
3197
-		lFilterPatterns[i] = (wchar_t *)malloc((wcslen(lTmpWChar) + 1) * sizeof(wchar_t *));
3198
-      if (lFilterPatterns[i]) wcscpy(lFilterPatterns[i], lTmpWChar);
3199
-	}
3200
+		lFilterPatterns = (wchar_t **) malloc(aNumOfFilterPatterns*sizeof(wchar_t *));
3201
+		for (i = 0; i < aNumOfFilterPatterns; i++)
3202
+		{
3203
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aFilterPatterns[i]);
3204
+				else lTmpWChar = tinyfd_mbcsTo16(aFilterPatterns[i]);
3205
+				lFilterPatterns[i] = (wchar_t *) malloc((wcslen(lTmpWChar) + 1) * sizeof(wchar_t *));
3206
+				if (lFilterPatterns[i]) wcscpy(lFilterPatterns[i], lTmpWChar);
3207
+		}
3208
 
3209
-	if (aTitle)
3210
-	{
3211
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3212
-		else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3213
-		wcscpy(lTitle, lTmpWChar);
3214
-	}
3215
-	if (aDefaultPathAndFile)
3216
-	{
3217
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultPathAndFile);
3218
-		else lTmpWChar = tinyfd_mbcsTo16(aDefaultPathAndFile);
3219
-		wcscpy(lDefaultPathAndFile, lTmpWChar);
3220
-	}
3221
-	if (aSingleFilterDescription)
3222
-	{
3223
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aSingleFilterDescription);
3224
-		else lTmpWChar = tinyfd_mbcsTo16(aSingleFilterDescription);
3225
-		wcscpy(lSingleFilterDescription, lTmpWChar);
3226
-	}
3227
+		if (aTitle)
3228
+		{
3229
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3230
+				else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3231
+				wcscpy(lTitle, lTmpWChar);
3232
+		}
3233
+		if (aDefaultPathAndOrFile)
3234
+		{
3235
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultPathAndOrFile);
3236
+				else lTmpWChar = tinyfd_mbcsTo16(aDefaultPathAndOrFile);
3237
+				wcscpy(lDefaultPathAndFile, lTmpWChar);
3238
+		}
3239
+		if (aSingleFilterDescription)
3240
+		{
3241
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aSingleFilterDescription);
3242
+				else lTmpWChar = tinyfd_mbcsTo16(aSingleFilterDescription);
3243
+				wcscpy(lSingleFilterDescription, lTmpWChar);
3244
+		}
3245
 
3246
-	lTmpWChar = tinyfd_saveFileDialogW(
3247
-		lTitle,
3248
-		lDefaultPathAndFile,
3249
-		aNumOfFilterPatterns,
3250
-		(wchar_t const**) lFilterPatterns, /*stupid cast for gcc*/
3251
-		lSingleFilterDescription);
3252
+		lTmpWChar = tinyfd_saveFileDialogW(
3253
+				lTitle,
3254
+				lDefaultPathAndFile,
3255
+				aNumOfFilterPatterns,
3256
+				(wchar_t const**) lFilterPatterns, /*stupid cast for gcc*/
3257
+				lSingleFilterDescription);
3258
 
3259
-	for (i = 0; i < aNumOfFilterPatterns; i++)
3260
-	{
3261
-		free(lFilterPatterns[i]);
3262
-	}
3263
-	free(lFilterPatterns);
3264
+		for (i = 0; i < aNumOfFilterPatterns; i++)
3265
+		{
3266
+				free(lFilterPatterns[i]);
3267
+		}
3268
+		free(lFilterPatterns);
3269
 
3270
-	if (!lTmpWChar)
3271
-	{
3272
-		return NULL;
3273
-	}
3274
+		if (!lTmpWChar)
3275
+		{
3276
+				return NULL;
3277
+		}
3278
 
3279
-	if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3280
-	else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3281
-	strcpy(aoBuff, lTmpChar);
3282
-	if (tinyfd_winUtf8) (void)tinyfd_utf16to8(NULL);
3283
-	else (void)tinyfd_utf16toMbcs(NULL);
3284
+		if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3285
+		else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3286
+		strcpy(aoBuff, lTmpChar);
3287
+		if (tinyfd_winUtf8) (void)tinyfd_utf16to8(NULL);
3288
+		else (void)tinyfd_utf16toMbcs(NULL);
3289
 
3290
-	return aoBuff;
3291
+		return aoBuff;
3292
 }
3293
 
3294
 
3295
 static char * openFileDialogWinGui(
3296
-	char const * aTitle, /*  NULL or "" */
3297
-	char const * aDefaultPathAndFile, /*  NULL or "" */
3298
-	int aNumOfFilterPatterns, /* 0 */
3299
-	char const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
3300
-	char const * aSingleFilterDescription, /* NULL or "image files" */
3301
-	int aAllowMultipleSelects) /* 0 or 1 */
3302
+		char const * aTitle, /*  NULL or "" */
3303
+		char const * aDefaultPathAndOrFile, /*  NULL or "" */
3304
+		int aNumOfFilterPatterns, /* 0 */
3305
+		char const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
3306
+		char const * aSingleFilterDescription, /* NULL or "image files" */
3307
+		int aAllowMultipleSelects) /* 0 or 1 */
3308
 {
3309
-	wchar_t lTitle[128] = L"";
3310
-	wchar_t lDefaultPathAndFile[MAX_PATH_OR_CMD] = L"";
3311
-	wchar_t lSingleFilterDescription[128] = L"";
3312
-	wchar_t * * lFilterPatterns;
3313
-	wchar_t * lTmpWChar;
3314
-	char * lTmpChar;
3315
-	int i;
3316
+		wchar_t lTitle[128] = L"";
3317
+		wchar_t lDefaultPathAndFile[MAX_PATH_OR_CMD] = L"";
3318
+		wchar_t lSingleFilterDescription[128] = L"";
3319
+		wchar_t * * lFilterPatterns;
3320
+		wchar_t * lTmpWChar;
3321
+		char * lTmpChar;
3322
+		int i;
3323
 
3324
-	lFilterPatterns = (wchar_t * *)malloc(aNumOfFilterPatterns*sizeof(wchar_t *));
3325
-	for (i = 0; i < aNumOfFilterPatterns; i++)
3326
-	{
3327
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aFilterPatterns[i]);
3328
-		else lTmpWChar = tinyfd_mbcsTo16(aFilterPatterns[i]);
3329
-		lFilterPatterns[i] = (wchar_t *)malloc((wcslen(lTmpWChar) + 1)*sizeof(wchar_t *));
3330
-      if (lFilterPatterns[i]) wcscpy(lFilterPatterns[i], lTmpWChar);
3331
-	}
3332
+		lFilterPatterns = (wchar_t * *) malloc(aNumOfFilterPatterns*sizeof(wchar_t *));
3333
+		for (i = 0; i < aNumOfFilterPatterns; i++)
3334
+		{
3335
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aFilterPatterns[i]);
3336
+				else lTmpWChar = tinyfd_mbcsTo16(aFilterPatterns[i]);
3337
+				lFilterPatterns[i] = (wchar_t *) malloc((wcslen(lTmpWChar) + 1)*sizeof(wchar_t *));
3338
+	  if (lFilterPatterns[i]) wcscpy(lFilterPatterns[i], lTmpWChar);
3339
+		}
3340
 
3341
-	if (aTitle)
3342
-	{
3343
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3344
-		else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3345
-		wcscpy(lTitle, lTmpWChar);
3346
-	}
3347
-	if (aDefaultPathAndFile)
3348
-	{
3349
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultPathAndFile);
3350
-		else lTmpWChar = tinyfd_mbcsTo16(aDefaultPathAndFile);
3351
-		wcscpy(lDefaultPathAndFile, lTmpWChar);
3352
-	}
3353
-	if (aSingleFilterDescription)
3354
-	{
3355
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aSingleFilterDescription);
3356
-		else lTmpWChar = tinyfd_mbcsTo16(aSingleFilterDescription);
3357
-		wcscpy(lSingleFilterDescription, lTmpWChar);
3358
-	}
3359
+		if (aTitle)
3360
+		{
3361
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3362
+				else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3363
+				wcscpy(lTitle, lTmpWChar);
3364
+		}
3365
+		if (aDefaultPathAndOrFile)
3366
+		{
3367
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultPathAndOrFile);
3368
+				else lTmpWChar = tinyfd_mbcsTo16(aDefaultPathAndOrFile);
3369
+				wcscpy(lDefaultPathAndFile, lTmpWChar);
3370
+		}
3371
+		if (aSingleFilterDescription)
3372
+		{
3373
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aSingleFilterDescription);
3374
+				else lTmpWChar = tinyfd_mbcsTo16(aSingleFilterDescription);
3375
+				wcscpy(lSingleFilterDescription, lTmpWChar);
3376
+		}
3377
 
3378
-	lTmpWChar = tinyfd_openFileDialogW(
3379
-		lTitle,
3380
-		lDefaultPathAndFile,
3381
-		aNumOfFilterPatterns,
3382
-		(wchar_t const**) lFilterPatterns, /*stupid cast for gcc*/
3383
-		lSingleFilterDescription,
3384
-		aAllowMultipleSelects);
3385
+		lTmpWChar = tinyfd_openFileDialogW(
3386
+				lTitle,
3387
+				lDefaultPathAndFile,
3388
+				aNumOfFilterPatterns,
3389
+				(wchar_t const**) lFilterPatterns, /*stupid cast for gcc*/
3390
+				lSingleFilterDescription,
3391
+				aAllowMultipleSelects);
3392
 
3393
-	for (i = 0; i < aNumOfFilterPatterns; i++)
3394
-	{
3395
-		free(lFilterPatterns[i]);
3396
-	}
3397
-	free(lFilterPatterns);
3398
+		for (i = 0; i < aNumOfFilterPatterns; i++)
3399
+		{
3400
+				free(lFilterPatterns[i]);
3401
+		}
3402
+		free(lFilterPatterns);
3403
 
3404
-	if (!lTmpWChar) return NULL;
3405
+		if (!lTmpWChar) return NULL;
3406
 
3407
-	if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3408
-	else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3409
-	(void)tinyfd_openFileDialogW(NULL, NULL, 0, NULL, NULL, -1);
3410
+		if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3411
+		else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3412
+		(void)tinyfd_openFileDialogW(NULL, NULL, 0, NULL, NULL, -1);
3413
 
3414
-	return lTmpChar;
3415
+		return lTmpChar;
3416
 }
3417
 
3418
 
3419
 static char * selectFolderDialogWinGui(
3420
-	char * aoBuff,
3421
-	char const * aTitle, /*  NULL or "" */
3422
-	char const * aDefaultPath) /* NULL or "" */
3423
+		char * aoBuff,
3424
+		char const * aTitle, /*  NULL or "" */
3425
+		char const * aDefaultPath) /* NULL or "" */
3426
 {
3427
-	wchar_t lTitle[128] = L"";
3428
-	wchar_t lDefaultPath[MAX_PATH_OR_CMD] = L"";
3429
-	wchar_t * lTmpWChar;
3430
-	char * lTmpChar;
3431
+		wchar_t lTitle[128] = L"";
3432
+		wchar_t lDefaultPath[MAX_PATH_OR_CMD] = L"";
3433
+		wchar_t * lTmpWChar;
3434
+		char * lTmpChar;
3435
 
3436
-	if (aTitle)
3437
-	{
3438
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3439
-		else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3440
-		wcscpy(lTitle, lTmpWChar);
3441
-	}
3442
-	if (aDefaultPath)
3443
-	{
3444
-		if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultPath);
3445
-		else lTmpWChar = tinyfd_mbcsTo16(aDefaultPath);
3446
-		wcscpy(lDefaultPath, lTmpWChar);
3447
-	}
3448
+		if (aTitle)
3449
+		{
3450
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3451
+				else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3452
+				wcscpy(lTitle, lTmpWChar);
3453
+		}
3454
+		if (aDefaultPath)
3455
+		{
3456
+				if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultPath);
3457
+				else lTmpWChar = tinyfd_mbcsTo16(aDefaultPath);
3458
+				wcscpy(lDefaultPath, lTmpWChar);
3459
+		}
3460
 
3461
-	lTmpWChar = tinyfd_selectFolderDialogW(
3462
-		lTitle,
3463
-		lDefaultPath);
3464
+		lTmpWChar = tinyfd_selectFolderDialogW(
3465
+				lTitle,
3466
+				lDefaultPath);
3467
 
3468
-	if (!lTmpWChar)
3469
-	{
3470
-		return NULL;
3471
-	}
3472
+		if (!lTmpWChar)
3473
+		{
3474
+				return NULL;
3475
+		}
3476
 
3477
-	if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3478
-	else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3479
-	strcpy(aoBuff, lTmpChar);
3480
+		if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3481
+		else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3482
+		strcpy(aoBuff, lTmpChar);
3483
 
3484
-	return aoBuff;
3485
+		return aoBuff;
3486
 }
3487
 
3488
 
3489
 static char * colorChooserWinGui(
3490
-        char const * aTitle, /* NULL or "" */
3491
-        char const * aDefaultHexRGB, /* NULL or "#FF0000"*/
3492
-        unsigned char const aDefaultRGB[3], /* { 0 , 255 , 255 } */
3493
-        unsigned char aoResultRGB[3]) /* { 0 , 0 , 0 } */
3494
+		char const * aTitle, /* NULL or "" */
3495
+		char const * aDefaultHexRGB, /* NULL or "#FF0000"*/
3496
+		unsigned char const aDefaultRGB[3], /* { 0 , 255 , 255 } */
3497
+		unsigned char aoResultRGB[3]) /* { 0 , 0 , 0 } */
3498
 {
3499
-        static char lResultHexRGB[8];
3500
+		static char lResultHexRGB[8];
3501
 
3502
-        wchar_t lTitle[128];
3503
-        wchar_t lDefaultHexRGB[16];
3504
-        wchar_t * lTmpWChar;
3505
-        char * lTmpChar;
3506
+		wchar_t lTitle[128];
3507
+		wchar_t lDefaultHexRGB[16];
3508
+		wchar_t * lTmpWChar;
3509
+		char * lTmpChar;
3510
 
3511
-		if (aTitle)
3512
+				if (aTitle)
3513
+				{
3514
+						if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3515
+						else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3516
+						wcscpy(lTitle, lTmpWChar);
3517
+				}
3518
+				if (aDefaultHexRGB)
3519
+				{
3520
+						if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultHexRGB);
3521
+						else lTmpWChar = tinyfd_mbcsTo16(aDefaultHexRGB);
3522
+						wcscpy(lDefaultHexRGB, lTmpWChar);
3523
+				}
3524
+
3525
+		lTmpWChar = tinyfd_colorChooserW(
3526
+				lTitle,
3527
+				lDefaultHexRGB,
3528
+				aDefaultRGB,
3529
+				aoResultRGB );
3530
+
3531
+		if (!lTmpWChar)
3532
 		{
3533
-			if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aTitle);
3534
-			else lTmpWChar = tinyfd_mbcsTo16(aTitle);
3535
-			wcscpy(lTitle, lTmpWChar);
3536
+				return NULL;
3537
 		}
3538
-		if (aDefaultHexRGB)
3539
-		{
3540
-			if (tinyfd_winUtf8) lTmpWChar = tinyfd_utf8to16(aDefaultHexRGB);
3541
-			else lTmpWChar = tinyfd_mbcsTo16(aDefaultHexRGB);
3542
-			wcscpy(lDefaultHexRGB, lTmpWChar);
3543
-		}
3544
 
3545
-        lTmpWChar = tinyfd_colorChooserW(
3546
-                lTitle,
3547
-                lDefaultHexRGB,
3548
-                aDefaultRGB,
3549
-                aoResultRGB );
3550
+				if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3551
+				else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3552
+				strcpy(lResultHexRGB, lTmpChar);
3553
 
3554
-        if (!lTmpWChar)
3555
-        {
3556
-                return NULL;
3557
-        }
3558
-
3559
-		if (tinyfd_winUtf8) lTmpChar = tinyfd_utf16to8(lTmpWChar);
3560
-		else lTmpChar = tinyfd_utf16toMbcs(lTmpWChar);
3561
-		strcpy(lResultHexRGB, lTmpChar);
3562
-
3563
-        return lResultHexRGB;
3564
+		return lResultHexRGB;
3565
 }
3566
 
3567
 
3568
 static int dialogPresent(void)
3569
 {
3570
-        static int lDialogPresent = -1 ;
3571
-        char lBuff[MAX_PATH_OR_CMD] ;
3572
-        FILE * lIn ;
3573
-        char const * lString = "dialog.exe";
3574
-		if (!tinyfd_allowCursesDialogs) return 0;
3575
-		if (lDialogPresent < 0)
3576
-        {
3577
-                if (!(lIn = _popen("where dialog.exe","r")))
3578
-                {
3579
-                        lDialogPresent = 0 ;
3580
-                        return 0 ;
3581
-                }
3582
-                while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
3583
-                {}
3584
-                _pclose( lIn ) ;
3585
-                if ( lBuff[strlen( lBuff ) -1] == '\n' )
3586
-                {
3587
-                        lBuff[strlen( lBuff ) -1] = '\0' ;
3588
-                }
3589
-                if ( strcmp(lBuff+strlen(lBuff)-strlen(lString),lString) )
3590
-                {
3591
-                        lDialogPresent = 0 ;
3592
-                }
3593
-                else
3594
-                {
3595
-                        lDialogPresent = 1 ;
3596
-                }
3597
-        }
3598
-		return lDialogPresent;
3599
+		static int lDialogPresent = -1 ;
3600
+		char lBuff[MAX_PATH_OR_CMD] ;
3601
+		FILE * lIn ;
3602
+		char const * lString = "dialog.exe";
3603
+				if (!tinyfd_allowCursesDialogs) return 0;
3604
+				if (lDialogPresent < 0)
3605
+		{
3606
+				lIn = _popen("where dialog.exe", "r");
3607
+				if ( ! lIn )
3608
+				{
3609
+						lDialogPresent = 0 ;
3610
+						return 0 ;
3611
+				}
3612
+				while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
3613
+				{}
3614
+				_pclose( lIn ) ;
3615
+				if ( lBuff[strlen( lBuff ) -1] == '\n' )
3616
+				{
3617
+						lBuff[strlen( lBuff ) -1] = '\0' ;
3618
+				}
3619
+				if ( strcmp(lBuff+strlen(lBuff)-strlen(lString),lString) )
3620
+				{
3621
+						lDialogPresent = 0 ;
3622
+				}
3623
+				else
3624
+				{
3625
+						lDialogPresent = 1 ;
3626
+				}
3627
+		}
3628
+				return lDialogPresent;
3629
 }
3630
 
3631
 
3632
 static int messageBoxWinConsole(
3633
-    char const * aTitle , /* NULL or "" */
3634
-    char const * aMessage , /* NULL or ""  may contain \n and \t */
3635
-    char const * aDialogType , /* "ok" "okcancel" "yesno" "yesnocancel" */
3636
-    char const * aIconType , /* "info" "warning" "error" "question" */
3637
-    int aDefaultButton ) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
3638
+	char const * aTitle , /* NULL or "" */
3639
+	char const * aMessage , /* NULL or ""  may contain \n and \t */
3640
+	char const * aDialogType , /* "ok" "okcancel" "yesno" "yesnocancel" */
3641
+	char const * aIconType , /* "info" "warning" "error" "question" */
3642
+	int aDefaultButton ) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
3643
 {
3644
-        char lDialogString[MAX_PATH_OR_CMD];
3645
-        char lDialogFile[MAX_PATH_OR_CMD];
3646
-        FILE * lIn;
3647
-        char lBuff[MAX_PATH_OR_CMD] = "";
3648
+		char lDialogString[MAX_PATH_OR_CMD];
3649
+		char lDialogFile[MAX_PATH_OR_CMD];
3650
+		FILE * lIn;
3651
+		char lBuff[MAX_PATH_OR_CMD] = "";
3652
 
3653
-		strcpy(lDialogString, "dialog ");
3654
-		if (aTitle && strlen(aTitle))
3655
-        {
3656
-                strcat(lDialogString, "--title \"") ;
3657
-                strcat(lDialogString, aTitle) ;
3658
-                strcat(lDialogString, "\" ") ;
3659
-        }
3660
+				strcpy(lDialogString, "dialog ");
3661
+				if (aTitle && strlen(aTitle))
3662
+		{
3663
+				strcat(lDialogString, "--title \"") ;
3664
+				strcat(lDialogString, aTitle) ;
3665
+				strcat(lDialogString, "\" ") ;
3666
+		}
3667
 
3668
-        if ( aDialogType && ( !strcmp( "okcancel" , aDialogType )
3669
-                || !strcmp("yesno", aDialogType) || !strcmp("yesnocancel", aDialogType) ) )
3670
-        {
3671
-                strcat(lDialogString, "--backtitle \"") ;
3672
-                strcat(lDialogString, "tab: move focus") ;
3673
-                strcat(lDialogString, "\" ") ;
3674
-        }
3675
+		if ( aDialogType && ( !strcmp( "okcancel" , aDialogType )
3676
+				|| !strcmp("yesno", aDialogType) || !strcmp("yesnocancel", aDialogType) ) )
3677
+		{
3678
+				strcat(lDialogString, "--backtitle \"") ;
3679
+				strcat(lDialogString, "tab: move focus") ;
3680
+				strcat(lDialogString, "\" ") ;
3681
+		}
3682
 
3683
-        if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
3684
-        {
3685
-                if ( ! aDefaultButton )
3686
-                {
3687
-                        strcat( lDialogString , "--defaultno " ) ;
3688
-                }
3689
-                strcat( lDialogString ,
3690
-                                "--yes-label \"Ok\" --no-label \"Cancel\" --yesno " ) ;
3691
-        }
3692
-        else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
3693
-        {
3694
-                if ( ! aDefaultButton )
3695
-                {
3696
-                        strcat( lDialogString , "--defaultno " ) ;
3697
-                }
3698
-                strcat( lDialogString , "--yesno " ) ;
3699
-        }
3700
-        else if (aDialogType && !strcmp("yesnocancel", aDialogType))
3701
-        {
3702
-                if (!aDefaultButton)
3703
-                {
3704
-                        strcat(lDialogString, "--defaultno ");
3705
-                }
3706
-                strcat(lDialogString, "--menu ");
3707
-        }
3708
-        else
3709
-        {
3710
-                strcat( lDialogString , "--msgbox " ) ;
3711
-        }
3712
+		if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
3713
+		{
3714
+				if ( ! aDefaultButton )
3715
+				{
3716
+						strcat( lDialogString , "--defaultno " ) ;
3717
+				}
3718
+				strcat( lDialogString ,
3719
+								"--yes-label \"Ok\" --no-label \"Cancel\" --yesno " ) ;
3720
+		}
3721
+		else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
3722
+		{
3723
+				if ( ! aDefaultButton )
3724
+				{
3725
+						strcat( lDialogString , "--defaultno " ) ;
3726
+				}
3727
+				strcat( lDialogString , "--yesno " ) ;
3728
+		}
3729
+		else if (aDialogType && !strcmp("yesnocancel", aDialogType))
3730
+		{
3731
+				if (!aDefaultButton)
3732
+				{
3733
+						strcat(lDialogString, "--defaultno ");
3734
+				}
3735
+				strcat(lDialogString, "--menu ");
3736
+		}
3737
+		else
3738
+		{
3739
+				strcat( lDialogString , "--msgbox " ) ;
3740
+		}
3741
 
3742
-        strcat( lDialogString , "\"" ) ;
3743
-        if ( aMessage && strlen(aMessage) )
3744
-        {
3745
-                tfd_replaceSubStr( aMessage , "\n" , "\\n" , lBuff ) ;
3746
-                strcat(lDialogString, lBuff) ;
3747
-                lBuff[0]='\0';
3748
-        }
3749
-        strcat(lDialogString, "\" ");
3750
+		strcat( lDialogString , "\"" ) ;
3751
+		if ( aMessage && strlen(aMessage) )
3752
+		{
3753
+				tfd_replaceSubStr( aMessage , "\n" , "\\n" , lBuff ) ;
3754
+				strcat(lDialogString, lBuff) ;
3755
+				lBuff[0]='\0';
3756
+		}
3757
+		strcat(lDialogString, "\" ");
3758
 
3759
-        if (aDialogType && !strcmp("yesnocancel", aDialogType))
3760
-        {
3761
-                strcat(lDialogString, "0 60 0 Yes \"\" No \"\"");
3762
-                strcat(lDialogString, "2>>");
3763
-        }
3764
-        else
3765
-        {
3766
-                strcat(lDialogString, "10 60");
3767
-                strcat(lDialogString, " && echo 1 > ");
3768
-        }
3769
+		if (aDialogType && !strcmp("yesnocancel", aDialogType))
3770
+		{
3771
+				strcat(lDialogString, "0 60 0 Yes \"\" No \"\"");
3772
+				strcat(lDialogString, "2>>");
3773
+		}
3774
+		else
3775
+		{
3776
+				strcat(lDialogString, "10 60");
3777
+				strcat(lDialogString, " && echo 1 > ");
3778
+		}
3779
 
3780
-        strcpy(lDialogFile, getenv("TEMP"));
3781
-        strcat(lDialogFile, "\\tinyfd.txt");
3782
-        strcat(lDialogString, lDialogFile);
3783
+		strcpy(lDialogFile, getenv("TEMP"));
3784
+		strcat(lDialogFile, "\\tinyfd.txt");
3785
+		strcat(lDialogString, lDialogFile);
3786
 
3787
-        /*if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;*/
3788
-        system( lDialogString ) ;
3789
+		/*if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;*/
3790
+		system( lDialogString ) ;
3791
 
3792
-        if (!(lIn = fopen(lDialogFile, "r")))
3793
-        {
3794
-                remove(lDialogFile);
3795
-                return 0 ;
3796
-        }
3797
-		while (fgets(lBuff, sizeof(lBuff), lIn) != NULL)
3798
-        {}
3799
-        fclose(lIn);
3800
-        remove(lDialogFile);
3801
-    if ( lBuff[strlen( lBuff ) -1] == '\n' )
3802
-    {
3803
-        lBuff[strlen( lBuff ) -1] = '\0' ;
3804
-    }
3805
+		if (!(lIn = fopen(lDialogFile, "r")))
3806
+		{
3807
+				remove(lDialogFile);
3808
+				return 0 ;
3809
+		}
3810
+				while (fgets(lBuff, sizeof(lBuff), lIn) != NULL)
3811
+		{}
3812
+		fclose(lIn);
3813
+		remove(lDialogFile);
3814
+	if ( lBuff[strlen( lBuff ) -1] == '\n' )
3815
+	{
3816
+		lBuff[strlen( lBuff ) -1] = '\0' ;
3817
+	}
3818
 
3819
-        /* if (tinyfd_verbose) printf("lBuff: %s\n", lBuff); */
3820
-        if ( ! strlen(lBuff) )
3821
-        {
3822
-                return 0;
3823
-        }
3824
+		/* if (tinyfd_verbose) printf("lBuff: %s\n", lBuff); */
3825
+		if ( ! strlen(lBuff) )
3826
+		{
3827
+				return 0;
3828
+		}
3829
 
3830
-        if (aDialogType && !strcmp("yesnocancel", aDialogType))
3831
-        {
3832
-                if (lBuff[0] == 'Y') return 1;
3833
-                else return 2;
3834
-        }
3835
+		if (aDialogType && !strcmp("yesnocancel", aDialogType))
3836
+		{
3837
+				if (lBuff[0] == 'Y') return 1;
3838
+				else return 2;
3839
+		}
3840
 
3841
-        return 1;
3842
+		return 1;
3843
 }
3844
 
3845
 
3846
 static int inputBoxWinConsole(
3847
-        char * aoBuff ,
3848
-        char const * aTitle , /* NULL or "" */
3849
-        char const * aMessage , /* NULL or "" may NOT contain \n nor \t */
3850
-        char const * aDefaultInput ) /* "" , if NULL it's a passwordBox */
3851
+		char * aoBuff ,
3852
+		char const * aTitle , /* NULL or "" */
3853
+		char const * aMessage , /* NULL or "" may NOT contain \n nor \t */
3854
+		char const * aDefaultInput ) /* "" , if NULL it's a passwordBox */
3855
 {
3856
-        char lDialogString[MAX_PATH_OR_CMD];
3857
-        char lDialogFile[MAX_PATH_OR_CMD];
3858
-        FILE * lIn;
3859
-        int lResult;
3860
+		char lDialogString[MAX_PATH_OR_CMD];
3861
+		char lDialogFile[MAX_PATH_OR_CMD];
3862
+		FILE * lIn;
3863
+		int lResult;
3864
 
3865
-        strcpy(lDialogFile, getenv("TEMP"));
3866
-        strcat(lDialogFile, "\\tinyfd.txt");
3867
-        strcpy(lDialogString , "echo|set /p=1 >" ) ;
3868
-        strcat(lDialogString, lDialogFile);
3869
-        strcat( lDialogString , " & " ) ;
3870
+		strcpy(lDialogFile, getenv("TEMP"));
3871
+		strcat(lDialogFile, "\\tinyfd.txt");
3872
+		strcpy(lDialogString , "echo|set /p=1 >" ) ;
3873
+		strcat(lDialogString, lDialogFile);
3874
+		strcat( lDialogString , " & " ) ;
3875
 
3876
-        strcat( lDialogString , "dialog " ) ;
3877
-        if ( aTitle && strlen(aTitle) )
3878
-        {
3879
-                strcat(lDialogString, "--title \"") ;
3880
-                strcat(lDialogString, aTitle) ;
3881
-                strcat(lDialogString, "\" ") ;
3882
-        }
3883
+		strcat( lDialogString , "dialog " ) ;
3884
+		if ( aTitle && strlen(aTitle) )
3885
+		{
3886
+				strcat(lDialogString, "--title \"") ;
3887
+				strcat(lDialogString, aTitle) ;
3888
+				strcat(lDialogString, "\" ") ;
3889
+		}
3890
 
3891
-        strcat(lDialogString, "--backtitle \"") ;
3892
-        strcat(lDialogString, "tab: move focus") ;
3893
-        if ( ! aDefaultInput )
3894
-        {
3895
-                strcat(lDialogString, " (sometimes nothing, no blink nor star, is shown in text field)") ;
3896
-        }
3897
+		strcat(lDialogString, "--backtitle \"") ;
3898
+		strcat(lDialogString, "tab: move focus") ;
3899
+		if ( ! aDefaultInput )
3900
+		{
3901
+				strcat(lDialogString, " (sometimes nothing, no blink nor star, is shown in text field)") ;
3902
+		}
3903
 
3904
-        strcat(lDialogString, "\" ") ;
3905
+		strcat(lDialogString, "\" ") ;
3906
 
3907
-        if ( ! aDefaultInput )
3908
-        {
3909
-                strcat( lDialogString , "--insecure --passwordbox" ) ;
3910
-        }
3911
-        else
3912
-        {
3913
-                strcat( lDialogString , "--inputbox" ) ;
3914
-        }
3915
-        strcat( lDialogString , " \"" ) ;
3916
-        if ( aMessage && strlen(aMessage) )
3917
-        {
3918
-                strcat(lDialogString, aMessage) ;
3919
-        }
3920
-        strcat(lDialogString,"\" 10 60 ") ;
3921
-        if ( aDefaultInput && strlen(aDefaultInput) )
3922
-        {
3923
-                strcat(lDialogString, "\"") ;
3924
-                strcat(lDialogString, aDefaultInput) ;
3925
-                strcat(lDialogString, "\" ") ;
3926
-        }
3927
+		if ( ! aDefaultInput )
3928
+		{
3929
+				strcat( lDialogString , "--insecure --passwordbox" ) ;
3930
+		}
3931
+		else
3932
+		{
3933
+				strcat( lDialogString , "--inputbox" ) ;
3934
+		}
3935
+		strcat( lDialogString , " \"" ) ;
3936
+		if ( aMessage && strlen(aMessage) )
3937
+		{
3938
+				strcat(lDialogString, aMessage) ;
3939
+		}
3940
+		strcat(lDialogString,"\" 10 60 ") ;
3941
+		if ( aDefaultInput && strlen(aDefaultInput) )
3942
+		{
3943
+				strcat(lDialogString, "\"") ;
3944
+				strcat(lDialogString, aDefaultInput) ;
3945
+				strcat(lDialogString, "\" ") ;
3946
+		}
3947
 
3948
-        strcat(lDialogString, "2>>");
3949
-        strcpy(lDialogFile, getenv("TEMP"));
3950
-        strcat(lDialogFile, "\\tinyfd.txt");
3951
-        strcat(lDialogString, lDialogFile);
3952
-        strcat(lDialogString, " || echo 0 > ");
3953
-        strcat(lDialogString, lDialogFile);
3954
+		strcat(lDialogString, "2>>");
3955
+		strcpy(lDialogFile, getenv("TEMP"));
3956
+		strcat(lDialogFile, "\\tinyfd.txt");
3957
+		strcat(lDialogString, lDialogFile);
3958
+		strcat(lDialogString, " || echo 0 > ");
3959
+		strcat(lDialogString, lDialogFile);
3960
 
3961
-        /* printf( "lDialogString: %s\n" , lDialogString ) ; */
3962
-        system( lDialogString ) ;
3963
+		/* printf( "lDialogString: %s\n" , lDialogString ) ; */
3964
+		system( lDialogString ) ;
3965
 
3966
-        if (!(lIn = fopen(lDialogFile, "r")))
3967
-        {
3968
-                remove(lDialogFile);
3969
-				aoBuff[0] = '\0';
3970
-				return 0;
3971
-        }
3972
-        while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
3973
-        {}
3974
-        fclose(lIn);
3975
+		if (!(lIn = fopen(lDialogFile, "r")))
3976
+		{
3977
+				remove(lDialogFile);
3978
+								aoBuff[0] = '\0';
3979
+								return 0;
3980
+		}
3981
+		while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
3982
+		{}
3983
+		fclose(lIn);
3984
 
3985
-        wipefile(lDialogFile);
3986
-        remove(lDialogFile);
3987
-    if ( aoBuff[strlen( aoBuff ) -1] == '\n' )
3988
-    {
3989
-        aoBuff[strlen( aoBuff ) -1] = '\0' ;
3990
-    }
3991
-        /* printf( "aoBuff: %s\n" , aoBuff ) ; */
3992
-
3993
-        /* printf( "aoBuff: %s len: %lu \n" , aoBuff , strlen(aoBuff) ) ; */
3994
-    lResult =  strncmp( aoBuff , "1" , 1) ? 0 : 1 ;
3995
-        /* printf( "lResult: %d \n" , lResult ) ; */
3996
-	if ( ! lResult )
3997
+		wipefile(lDialogFile);
3998
+		remove(lDialogFile);
3999
+	if ( aoBuff[strlen( aoBuff ) -1] == '\n' )
4000
 	{
4001
-		aoBuff[0] = '\0';
4002
-		return 0 ;
4003
+		aoBuff[strlen( aoBuff ) -1] = '\0' ;
4004
 	}
4005
-	/* printf( "aoBuff+1: %s\n" , aoBuff+1 ) ; */
4006
-	strcpy(aoBuff, aoBuff+3);
4007
-	return 1;
4008
+		/* printf( "aoBuff: %s\n" , aoBuff ) ; */
4009
+
4010
+		/* printf( "aoBuff: %s len: %lu \n" , aoBuff , strlen(aoBuff) ) ; */
4011
+	lResult =  strncmp( aoBuff , "1" , 1) ? 0 : 1 ;
4012
+		/* printf( "lResult: %d \n" , lResult ) ; */
4013
+		if ( ! lResult )
4014
+		{
4015
+				aoBuff[0] = '\0';
4016
+				return 0 ;
4017
+		}
4018
+		/* printf( "aoBuff+1: %s\n" , aoBuff+1 ) ; */
4019
+		strcpy(aoBuff, aoBuff+3);
4020
+		return 1;
4021
 }
4022
 
4023
 
4024
 static char * saveFileDialogWinConsole(
4025
-        char * aoBuff ,
4026
-        char const * aTitle , /* NULL or "" */
4027
-        char const * aDefaultPathAndFile ) /* NULL or "" */
4028
+		char * aoBuff ,
4029
+		char const * aTitle , /* NULL or "" */
4030
+		char const * aDefaultPathAndOrFile ) /* NULL or "" */
4031
 {
4032
-        char lDialogString[MAX_PATH_OR_CMD];
4033
-        char lPathAndFile[MAX_PATH_OR_CMD] = "";
4034
-        FILE * lIn;
4035
+		char lDialogString[MAX_PATH_OR_CMD];
4036
+		char lPathAndFile[MAX_PATH_OR_CMD] = "";
4037
+		FILE * lIn;
4038
 
4039
-        strcpy( lDialogString , "dialog " ) ;
4040
-        if ( aTitle && strlen(aTitle) )
4041
-        {
4042
-                strcat(lDialogString, "--title \"") ;
4043
-                strcat(lDialogString, aTitle) ;
4044
-                strcat(lDialogString, "\" ") ;
4045
-        }
4046
+		strcpy( lDialogString , "dialog " ) ;
4047
+		if ( aTitle && strlen(aTitle) )
4048
+		{
4049
+				strcat(lDialogString, "--title \"") ;
4050
+				strcat(lDialogString, aTitle) ;
4051
+				strcat(lDialogString, "\" ") ;
4052
+		}
4053
 
4054
-        strcat(lDialogString, "--backtitle \"") ;
4055
-        strcat(lDialogString,
4056
-                "tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
4057
-        strcat(lDialogString, "\" ") ;
4058
+		strcat(lDialogString, "--backtitle \"") ;
4059
+		strcat(lDialogString,
4060
+				"tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
4061
+		strcat(lDialogString, "\" ") ;
4062
 
4063
-        strcat( lDialogString , "--fselect \"" ) ;
4064
-        if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
4065
-        {
4066
-                /* dialog.exe uses unix separators even on windows */
4067
-                strcpy(lPathAndFile, aDefaultPathAndFile);
4068
-                replaceChr( lPathAndFile , '\\' , '/' ) ;
4069
-        }
4070
+		strcat( lDialogString , "--fselect \"" ) ;
4071
+		if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
4072
+		{
4073
+				/* dialog.exe uses unix separators even on windows */
4074
+				strcpy(lPathAndFile, aDefaultPathAndOrFile);
4075
+				replaceChr( lPathAndFile , '\\' , '/' ) ;
4076
+		}
4077
 
4078
-        /* dialog.exe needs at least one separator */
4079
-        if ( ! strchr(lPathAndFile, '/') )
4080
-        {
4081
-                strcat(lDialogString, "./") ;
4082
-        }
4083
-        strcat(lDialogString, lPathAndFile) ;
4084
-        strcat(lDialogString, "\" 0 60 2>");
4085
-        strcpy(lPathAndFile, getenv("TEMP"));
4086
-        strcat(lPathAndFile, "\\tinyfd.txt");
4087
-        strcat(lDialogString, lPathAndFile);
4088
+		/* dialog.exe needs at least one separator */
4089
+		if ( ! strchr(lPathAndFile, '/') )
4090
+		{
4091
+				strcat(lDialogString, "./") ;
4092
+		}
4093
+		strcat(lDialogString, lPathAndFile) ;
4094
+		strcat(lDialogString, "\" 0 60 2>");
4095
+		strcpy(lPathAndFile, getenv("TEMP"));
4096
+		strcat(lPathAndFile, "\\tinyfd.txt");
4097
+		strcat(lDialogString, lPathAndFile);
4098
 
4099
-        /* printf( "lDialogString: %s\n" , lDialogString ) ; */
4100
-        system( lDialogString ) ;
4101
+		/* printf( "lDialogString: %s\n" , lDialogString ) ; */
4102
+		system( lDialogString ) ;
4103
 
4104
-        if (!(lIn = fopen(lPathAndFile, "r")))
4105
-        {
4106
-                remove(lPathAndFile);
4107
-                return NULL;
4108
-        }
4109
-        while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
4110
-        {}
4111
-        fclose(lIn);
4112
-        remove(lPathAndFile);
4113
-        replaceChr( aoBuff , '/' , '\\' ) ;
4114
-        /* printf( "aoBuff: %s\n" , aoBuff ) ; */
4115
-        getLastName(lDialogString,aoBuff);
4116
-        if ( ! strlen(lDialogString) )
4117
-        {
4118
-                return NULL;
4119
-        }
4120
-        return aoBuff;
4121
+		if (!(lIn = fopen(lPathAndFile, "r")))
4122
+		{
4123
+				remove(lPathAndFile);
4124
+				return NULL;
4125
+		}
4126
+		while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
4127
+		{}
4128
+		fclose(lIn);
4129
+		remove(lPathAndFile);
4130
+		replaceChr( aoBuff , '/' , '\\' ) ;
4131
+		/* printf( "aoBuff: %s\n" , aoBuff ) ; */
4132
+		getLastName(lDialogString,aoBuff);
4133
+		if ( ! strlen(lDialogString) )
4134
+		{
4135
+				return NULL;
4136
+		}
4137
+		return aoBuff;
4138
 }
4139
 
4140
 
4141
 static char * openFileDialogWinConsole(
4142
-        char const * aTitle , /*  NULL or "" */
4143
-        char const * aDefaultPathAndFile ) /*  NULL or "" */
4144
+		char const * aTitle , /*  NULL or "" */
4145
+		char const * aDefaultPathAndOrFile ) /*  NULL or "" */
4146
 {
4147
-        char lFilterPatterns[MAX_PATH_OR_CMD] = "";
4148
-        char lDialogString[MAX_PATH_OR_CMD] ;
4149
-        FILE * lIn;
4150
+		char lFilterPatterns[MAX_PATH_OR_CMD] = "";
4151
+		char lDialogString[MAX_PATH_OR_CMD] ;
4152
+		FILE * lIn;
4153
 
4154
-		static char aoBuff[MAX_PATH_OR_CMD];
4155
+				static char aoBuff[MAX_PATH_OR_CMD];
4156
 
4157
-        strcpy( lDialogString , "dialog " ) ;
4158
-        if ( aTitle && strlen(aTitle) )
4159
-        {
4160
-                strcat(lDialogString, "--title \"") ;
4161
-                strcat(lDialogString, aTitle) ;
4162
-                strcat(lDialogString, "\" ") ;
4163
-        }
4164
+		strcpy( lDialogString , "dialog " ) ;
4165
+		if ( aTitle && strlen(aTitle) )
4166
+		{
4167
+				strcat(lDialogString, "--title \"") ;
4168
+				strcat(lDialogString, aTitle) ;
4169
+				strcat(lDialogString, "\" ") ;
4170
+		}
4171
 
4172
-        strcat(lDialogString, "--backtitle \"") ;
4173
-        strcat(lDialogString,
4174
-                "tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
4175
-        strcat(lDialogString, "\" ") ;
4176
+		strcat(lDialogString, "--backtitle \"") ;
4177
+		strcat(lDialogString,
4178
+				"tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
4179
+		strcat(lDialogString, "\" ") ;
4180
 
4181
-        strcat( lDialogString , "--fselect \"" ) ;
4182
-        if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
4183
-        {
4184
-                /* dialog.exe uses unix separators even on windows */
4185
-                strcpy(lFilterPatterns, aDefaultPathAndFile);
4186
-                replaceChr( lFilterPatterns , '\\' , '/' ) ;
4187
-        }
4188
+		strcat( lDialogString , "--fselect \"" ) ;
4189
+		if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
4190
+		{
4191
+				/* dialog.exe uses unix separators even on windows */
4192
+				strcpy(lFilterPatterns, aDefaultPathAndOrFile);
4193
+				replaceChr( lFilterPatterns , '\\' , '/' ) ;
4194
+		}
4195
 
4196
-        /* dialog.exe needs at least one separator */
4197
-        if ( ! strchr(lFilterPatterns, '/') )
4198
-        {
4199
-                strcat(lDialogString, "./") ;
4200
-        }
4201
-        strcat(lDialogString, lFilterPatterns) ;
4202
-        strcat(lDialogString, "\" 0 60 2>");
4203
-        strcpy(lFilterPatterns, getenv("TEMP"));
4204
-        strcat(lFilterPatterns, "\\tinyfd.txt");
4205
-        strcat(lDialogString, lFilterPatterns);
4206
+		/* dialog.exe needs at least one separator */
4207
+		if ( ! strchr(lFilterPatterns, '/') )
4208
+		{
4209
+				strcat(lDialogString, "./") ;
4210
+		}
4211
+		strcat(lDialogString, lFilterPatterns) ;
4212
+		strcat(lDialogString, "\" 0 60 2>");
4213
+		strcpy(lFilterPatterns, getenv("TEMP"));
4214
+		strcat(lFilterPatterns, "\\tinyfd.txt");
4215
+		strcat(lDialogString, lFilterPatterns);
4216
 
4217
-        /* printf( "lDialogString: %s\n" , lDialogString ) ; */
4218
-        system( lDialogString ) ;
4219
+		/* printf( "lDialogString: %s\n" , lDialogString ) ; */
4220
+		system( lDialogString ) ;
4221
 
4222
-        if (!(lIn = fopen(lFilterPatterns, "r")))
4223
-        {
4224
-                remove(lFilterPatterns);
4225
-                return NULL;
4226
-        }
4227
-        while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
4228
-        {}
4229
-        fclose(lIn);
4230
-        remove(lFilterPatterns);
4231
-        replaceChr( aoBuff , '/' , '\\' ) ;
4232
-        /* printf( "aoBuff: %s\n" , aoBuff ) ; */
4233
-        return aoBuff;
4234
+		if (!(lIn = fopen(lFilterPatterns, "r")))
4235
+		{
4236
+				remove(lFilterPatterns);
4237
+				return NULL;
4238
+		}
4239
+		while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
4240
+		{}
4241
+		fclose(lIn);
4242
+		remove(lFilterPatterns);
4243
+		replaceChr( aoBuff , '/' , '\\' ) ;
4244
+		/* printf( "aoBuff: %s\n" , aoBuff ) ; */
4245
+		return aoBuff;
4246
 }
4247
 
4248
 
4249
 static char * selectFolderDialogWinConsole(
4250
-        char * aoBuff ,
4251
-        char const * aTitle , /*  NULL or "" */
4252
-        char const * aDefaultPath ) /* NULL or "" */
4253
+		char * aoBuff ,
4254
+		char const * aTitle , /*  NULL or "" */
4255
+		char const * aDefaultPath ) /* NULL or "" */
4256
 {
4257
-        char lDialogString[MAX_PATH_OR_CMD] ;
4258
-        char lString[MAX_PATH_OR_CMD] ;
4259
-        FILE * lIn ;
4260
+		char lDialogString[MAX_PATH_OR_CMD] ;
4261
+		char lString[MAX_PATH_OR_CMD] ;
4262
+		FILE * lIn ;
4263
 
4264
-        strcpy( lDialogString , "dialog " ) ;
4265
-        if ( aTitle && strlen(aTitle) )
4266
-        {
4267
-                strcat(lDialogString, "--title \"") ;
4268
-                strcat(lDialogString, aTitle) ;
4269
-                strcat(lDialogString, "\" ") ;
4270
-        }
4271
+		strcpy( lDialogString , "dialog " ) ;
4272
+		if ( aTitle && strlen(aTitle) )
4273
+		{
4274
+				strcat(lDialogString, "--title \"") ;
4275
+				strcat(lDialogString, aTitle) ;
4276
+				strcat(lDialogString, "\" ") ;
4277
+		}
4278
 
4279
-        strcat(lDialogString, "--backtitle \"") ;
4280
-        strcat(lDialogString,
4281
-                "tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
4282
-        strcat(lDialogString, "\" ") ;
4283
+		strcat(lDialogString, "--backtitle \"") ;
4284
+		strcat(lDialogString,
4285
+				"tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
4286
+		strcat(lDialogString, "\" ") ;
4287
 
4288
-        strcat( lDialogString , "--dselect \"" ) ;
4289
-        if ( aDefaultPath && strlen(aDefaultPath) )
4290
-        {
4291
-                /* dialog.exe uses unix separators even on windows */
4292
-                strcpy(lString, aDefaultPath) ;
4293
-                ensureFinalSlash(lString);
4294
-                replaceChr( lString , '\\' , '/' ) ;
4295
-                strcat(lDialogString, lString) ;
4296
-        }
4297
-        else
4298
-        {
4299
-                /* dialog.exe needs at least one separator */
4300
-                strcat(lDialogString, "./") ;
4301
-        }
4302
-        strcat(lDialogString, "\" 0 60 2>");
4303
-        strcpy(lString, getenv("TEMP"));
4304
-        strcat(lString, "\\tinyfd.txt");
4305
-        strcat(lDialogString, lString);
4306
+		strcat( lDialogString , "--dselect \"" ) ;
4307
+		if ( aDefaultPath && strlen(aDefaultPath) )
4308
+		{
4309
+				/* dialog.exe uses unix separators even on windows */
4310
+				strcpy(lString, aDefaultPath) ;
4311
+				ensureFinalSlash(lString);
4312
+				replaceChr( lString , '\\' , '/' ) ;
4313
+				strcat(lDialogString, lString) ;
4314
+		}
4315
+		else
4316
+		{
4317
+				/* dialog.exe needs at least one separator */
4318
+				strcat(lDialogString, "./") ;
4319
+		}
4320
+		strcat(lDialogString, "\" 0 60 2>");
4321
+		strcpy(lString, getenv("TEMP"));
4322
+		strcat(lString, "\\tinyfd.txt");
4323
+		strcat(lDialogString, lString);
4324
 
4325
-        /* printf( "lDialogString: %s\n" , lDialogString ) ; */
4326
-        system( lDialogString ) ;
4327
+		/* printf( "lDialogString: %s\n" , lDialogString ) ; */
4328
+		system( lDialogString ) ;
4329
 
4330
-        if (!(lIn = fopen(lString, "r")))
4331
-        {
4332
-                remove(lString);
4333
-                return NULL;
4334
-        }
4335
-        while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
4336
-        {}
4337
-        fclose(lIn);
4338
-        remove(lString);
4339
-        replaceChr( aoBuff , '/' , '\\' ) ;
4340
-        /* printf( "aoBuff: %s\n" , aoBuff ) ; */
4341
-        return aoBuff;
4342
+		if (!(lIn = fopen(lString, "r")))
4343
+		{
4344
+				remove(lString);
4345
+				return NULL;
4346
+		}
4347
+		while (fgets(aoBuff, MAX_PATH_OR_CMD, lIn) != NULL)
4348
+		{}
4349
+		fclose(lIn);
4350
+		remove(lString);
4351
+		replaceChr( aoBuff , '/' , '\\' ) ;
4352
+		/* printf( "aoBuff: %s\n" , aoBuff ) ; */
4353
+		return aoBuff;
4354
 }
4355
 
4356
 static void writeUtf8( char const * aUtf8String )
4357
 {
4358
-	unsigned long lNum;
4359
-	void * lConsoleHandle;
4360
-	wchar_t * lTmpWChar;
4361
+		unsigned long lNum;
4362
+		void * lConsoleHandle;
4363
+		wchar_t * lTmpWChar;
4364
 
4365
-	lConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
4366
-	lTmpWChar = tinyfd_utf8to16(aUtf8String);
4367
-	(void)WriteConsoleW(lConsoleHandle, lTmpWChar, (DWORD) wcslen(lTmpWChar), &lNum, NULL);
4368
+		lConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
4369
+		lTmpWChar = tinyfd_utf8to16(aUtf8String);
4370
+		(void)WriteConsoleW(lConsoleHandle, lTmpWChar, (DWORD) wcslen(lTmpWChar), &lNum, NULL);
4371
 }
4372
 
4373
 
4374
 int tinyfd_messageBox(
4375
-	char const * aTitle, /* NULL or "" */
4376
-	char const * aMessage, /* NULL or ""  may contain \n and \t */
4377
-	char const * aDialogType, /* "ok" "okcancel" "yesno" "yesnocancel" */
4378
-	char const * aIconType, /* "info" "warning" "error" "question" */
4379
-	int aDefaultButton) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
4380
+		char const * aTitle, /* NULL or "" */
4381
+		char const * aMessage, /* NULL or ""  may contain \n and \t */
4382
+		char const * aDialogType, /* "ok" "okcancel" "yesno" "yesnocancel" */
4383
+		char const * aIconType, /* "info" "warning" "error" "question" */
4384
+		int aDefaultButton) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
4385
 {
4386
-	char lChar;
4387
-	UINT lOriginalCP = 0;
4388
-	UINT lOriginalOutputCP = 0;
4389
+		char lChar;
4390
+		UINT lOriginalCP = 0;
4391
+		UINT lOriginalOutputCP = 0;
4392
 
4393
-	if (tfd_quoteDetected(aTitle)) return tinyfd_messageBox("INVALID TITLE WITH QUOTES", aMessage, aDialogType, aIconType, aDefaultButton);
4394
-	if (tfd_quoteDetected(aMessage)) return tinyfd_messageBox(aTitle, "INVALID MESSAGE WITH QUOTES", aDialogType, aIconType, aDefaultButton);
4395
+		if (tfd_quoteDetected(aTitle)) return tinyfd_messageBox("INVALID TITLE WITH QUOTES", aMessage, aDialogType, aIconType, aDefaultButton);
4396
+		if (tfd_quoteDetected(aMessage)) return tinyfd_messageBox(aTitle, "INVALID MESSAGE WITH QUOTES", aDialogType, aIconType, aDefaultButton);
4397
 
4398
-	if ((!tinyfd_forceConsole || !(GetConsoleWindow() || dialogPresent()))
4399
-		&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
4400
-	{
4401
-		if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "windows"); return 1; }
4402
-		return messageBoxWinGui(aTitle, aMessage, aDialogType, aIconType, aDefaultButton);
4403
-	}
4404
-	else if (dialogPresent())
4405
-	{
4406
-		if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return 0; }
4407
-		return messageBoxWinConsole(
4408
-			aTitle, aMessage, aDialogType, aIconType, aDefaultButton);
4409
-	}
4410
-	else
4411
-	{
4412
-		if (!tinyfd_winUtf8)
4413
+		if ((!tinyfd_forceConsole || !(GetConsoleWindow() || dialogPresent()))
4414
+				&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
4415
 		{
4416
-			lOriginalCP = GetConsoleCP();
4417
-			lOriginalOutputCP = GetConsoleOutputCP();
4418
-			(void)SetConsoleCP(GetACP());
4419
-			(void)SetConsoleOutputCP(GetACP());
4420
+				if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "windows"); return 1; }
4421
+				return messageBoxWinGui(aTitle, aMessage, aDialogType, aIconType, aDefaultButton);
4422
 		}
4423
-
4424
-		if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return 0; }
4425
-		if (!gWarningDisplayed && !tinyfd_forceConsole)
4426
+		else if (dialogPresent())
4427
 		{
4428
-			gWarningDisplayed = 1;
4429
-			printf("\n\n%s\n", gTitle);
4430
-			printf("%s\n\n", tinyfd_needs);
4431
+				if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return 0; }
4432
+				return messageBoxWinConsole(
4433
+						aTitle, aMessage, aDialogType, aIconType, aDefaultButton);
4434
 		}
4435
-
4436
-		if (aTitle && strlen(aTitle))
4437
+		else
4438
 		{
4439
-			printf("\n");
4440
-			if (tinyfd_winUtf8) writeUtf8(aTitle);
4441
-			else printf("%s", aTitle);
4442
-			printf("\n\n");
4443
-		}
4444
-		if (aDialogType && !strcmp("yesno", aDialogType))
4445
-		{
4446
-			do
4447
-			{
4448
-				if (aMessage && strlen(aMessage))
4449
+				if (!tinyfd_winUtf8)
4450
 				{
4451
-					if (tinyfd_winUtf8) writeUtf8(aMessage);
4452
-					else printf("%s", aMessage);
4453
-					printf("\n");
4454
+						lOriginalCP = GetConsoleCP();
4455
+						lOriginalOutputCP = GetConsoleOutputCP();
4456
+						(void)SetConsoleCP(GetACP());
4457
+						(void)SetConsoleOutputCP(GetACP());
4458
 				}
4459
-				printf("y/n: ");
4460
-				lChar = (char)tolower(_getch());
4461
-				printf("\n\n");
4462
-			} while (lChar != 'y' && lChar != 'n');
4463
-			if (!tinyfd_winUtf8) { (void)SetConsoleCP(lOriginalCP); (void)SetConsoleOutputCP(lOriginalOutputCP); }
4464
-			return lChar == 'y' ? 1 : 0;
4465
-		}
4466
-		else if (aDialogType && !strcmp("okcancel", aDialogType))
4467
-		{
4468
-			do
4469
-			{
4470
-				if (aMessage && strlen(aMessage))
4471
+
4472
+				if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return 0; }
4473
+				if (!gWarningDisplayed && !tinyfd_forceConsole)
4474
 				{
4475
-					if (tinyfd_winUtf8) writeUtf8(aMessage);
4476
-					else printf("%s", aMessage);
4477
-					printf("\n");
4478
+						gWarningDisplayed = 1;
4479
+						printf("\n\n%s\n", gTitle);
4480
+						printf("%s\n\n", tinyfd_needs);
4481
 				}
4482
-				printf("[O]kay/[C]ancel: ");
4483
-				lChar = (char)tolower(_getch());
4484
-				printf("\n\n");
4485
-			} while (lChar != 'o' && lChar != 'c');
4486
-			if (!tinyfd_winUtf8) { (void)SetConsoleCP(lOriginalCP); (void)SetConsoleOutputCP(lOriginalOutputCP); }
4487
-			return lChar == 'o' ? 1 : 0;
4488
-		}
4489
-		else if (aDialogType && !strcmp("yesnocancel", aDialogType))
4490
-		{
4491
-			do
4492
-			{
4493
-				if (aMessage && strlen(aMessage))
4494
+
4495
+				if (aTitle && strlen(aTitle))
4496
 				{
4497
-					if (tinyfd_winUtf8) writeUtf8(aMessage);
4498
-					else printf("%s", aMessage);
4499
-					printf("\n");
4500
+						printf("\n");
4501
+						if (tinyfd_winUtf8) writeUtf8(aTitle);
4502
+						else printf("%s", aTitle);
4503
+						printf("\n\n");
4504
 				}
4505
-				printf("[Y]es/[N]o/[C]ancel: ");
4506
-				lChar = (char)tolower(_getch());
4507
-				printf("\n\n");
4508
-			} while (lChar != 'y' && lChar != 'n' && lChar != 'c');
4509
-			if (!tinyfd_winUtf8) { (void)SetConsoleCP(lOriginalCP); (void)SetConsoleOutputCP(lOriginalOutputCP); }
4510
-			return (lChar == 'y') ? 1 : (lChar == 'n') ? 2 : 0;
4511
+				if (aDialogType && !strcmp("yesno", aDialogType))
4512
+				{
4513
+						do
4514
+						{
4515
+								if (aMessage && strlen(aMessage))
4516
+								{
4517
+										if (tinyfd_winUtf8) writeUtf8(aMessage);
4518
+										else printf("%s", aMessage);
4519
+										printf("\n");
4520
+								}
4521
+								printf("y/n: ");
4522
+								lChar = (char)tolower(_getch());
4523
+								printf("\n\n");
4524
+						} while (lChar != 'y' && lChar != 'n');
4525
+						if (!tinyfd_winUtf8) { (void)SetConsoleCP(lOriginalCP); (void)SetConsoleOutputCP(lOriginalOutputCP); }
4526
+						return lChar == 'y' ? 1 : 0;
4527
+				}
4528
+				else if (aDialogType && !strcmp("okcancel", aDialogType))
4529
+				{
4530
+						do
4531
+						{
4532
+								if (aMessage && strlen(aMessage))
4533
+								{
4534
+										if (tinyfd_winUtf8) writeUtf8(aMessage);
4535
+										else printf("%s", aMessage);
4536
+										printf("\n");
4537
+								}
4538
+								printf("[O]kay/[C]ancel: ");
4539
+								lChar = (char)tolower(_getch());
4540
+								printf("\n\n");
4541
+						} while (lChar != 'o' && lChar != 'c');
4542
+						if (!tinyfd_winUtf8) { (void)SetConsoleCP(lOriginalCP); (void)SetConsoleOutputCP(lOriginalOutputCP); }
4543
+						return lChar == 'o' ? 1 : 0;
4544
+				}
4545
+				else if (aDialogType && !strcmp("yesnocancel", aDialogType))
4546
+				{
4547
+						do
4548
+						{
4549
+								if (aMessage && strlen(aMessage))
4550
+								{
4551
+										if (tinyfd_winUtf8) writeUtf8(aMessage);
4552
+										else printf("%s", aMessage);
4553
+										printf("\n");
4554
+								}
4555
+								printf("[Y]es/[N]o/[C]ancel: ");
4556
+								lChar = (char)tolower(_getch());
4557
+								printf("\n\n");
4558
+						} while (lChar != 'y' && lChar != 'n' && lChar != 'c');
4559
+						if (!tinyfd_winUtf8) { (void)SetConsoleCP(lOriginalCP); (void)SetConsoleOutputCP(lOriginalOutputCP); }
4560
+						return (lChar == 'y') ? 1 : (lChar == 'n') ? 2 : 0;
4561
+				}
4562
+				else
4563
+				{
4564
+						if (aMessage && strlen(aMessage))
4565
+						{
4566
+								if (tinyfd_winUtf8) writeUtf8(aMessage);
4567
+								else printf("%s", aMessage);
4568
+								printf("\n\n");
4569
+						}
4570
+						printf("press enter to continue ");
4571
+						lChar = (char)_getch();
4572
+						printf("\n\n");
4573
+						if (!tinyfd_winUtf8) { (void)SetConsoleCP(lOriginalCP); (void)SetConsoleOutputCP(lOriginalOutputCP); }
4574
+						return 1;
4575
+				}
4576
 		}
4577
-		else
4578
-		{
4579
-			if (aMessage && strlen(aMessage))
4580
-			{
4581
-				if (tinyfd_winUtf8) writeUtf8(aMessage);
4582
-				else printf("%s", aMessage);
4583
-				printf("\n\n");
4584
-			}
4585
-			printf("press enter to continue ");
4586
-			lChar = (char)_getch();
4587
-			printf("\n\n");
4588
-			if (!tinyfd_winUtf8) { (void)SetConsoleCP(lOriginalCP); (void)SetConsoleOutputCP(lOriginalOutputCP); }
4589
-			return 1;
4590
-		}
4591
-	}
4592
 }
4593
 
4594
 
4595
 /* return has only meaning for tinyfd_query */
4596
 int tinyfd_notifyPopup(
4597
-        char const * aTitle, /* NULL or "" */
4598
-        char const * aMessage , /* NULL or "" may contain \n \t */
4599
-        char const * aIconType ) /* "info" "warning" "error" */
4600
+		char const * aTitle, /* NULL or "" */
4601
+		char const * aMessage , /* NULL or "" may contain \n \t */
4602
+		char const * aIconType ) /* "info" "warning" "error" */
4603
 {
4604
-	if (tfd_quoteDetected(aTitle)) return tinyfd_notifyPopup("INVALID TITLE WITH QUOTES", aMessage, aIconType);
4605
-	if (tfd_quoteDetected(aMessage)) return tinyfd_notifyPopup(aTitle, "INVALID MESSAGE WITH QUOTES", aIconType);
4606
+		if (tfd_quoteDetected(aTitle)) return tinyfd_notifyPopup("INVALID TITLE WITH QUOTES", aMessage, aIconType);
4607
+		if (tfd_quoteDetected(aMessage)) return tinyfd_notifyPopup(aTitle, "INVALID MESSAGE WITH QUOTES", aIconType);
4608
 
4609
-    if ( powershellPresent() && (!tinyfd_forceConsole || !(
4610
-            GetConsoleWindow() ||
4611
-            dialogPresent()))
4612
-			&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
4613
-    {
4614
-            if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return 1;}
4615
-            return notifyWinGui(aTitle, aMessage, aIconType);
4616
-    }
4617
-    else
4618
-	    return tinyfd_messageBox(aTitle, aMessage, "ok" , aIconType, 0);
4619
+	if ( powershellPresent() && (!tinyfd_forceConsole || !(
4620
+			GetConsoleWindow() ||
4621
+			dialogPresent()))
4622
+						&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
4623
+	{
4624
+			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return 1;}
4625
+			return notifyWinGui(aTitle, aMessage, aIconType);
4626
+	}
4627
+	else
4628
+			return tinyfd_messageBox(aTitle, aMessage, "ok" , aIconType, 0);
4629
 }
4630
 
4631
 
4632
 /* returns NULL on cancel */
4633
 char * tinyfd_inputBox(
4634
-        char const * aTitle , /* NULL or "" */
4635
-        char const * aMessage , /* NULL or "" (\n and \t have no effect) */
4636
-        char const * aDefaultInput ) /* "" , if NULL it's a passwordBox */
4637
+		char const * aTitle , /* NULL or "" */
4638
+		char const * aMessage , /* NULL or "" (\n and \t have no effect) */
4639
+		char const * aDefaultInput ) /* "" , if NULL it's a passwordBox */
4640
 {
4641
-	static char lBuff[MAX_PATH_OR_CMD] = "";
4642
-	char * lEOF;
4643
+		static char lBuff[MAX_PATH_OR_CMD] = "";
4644
+		char * lEOF;
4645
 
4646
-	DWORD mode = 0;
4647
-	HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
4648
+		DWORD mode = 0;
4649
+		HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
4650
 
4651
-	unsigned long lNum;
4652
-	void * lConsoleHandle;
4653
-	char * lTmpChar;
4654
-	wchar_t lBuffW[1024];
4655
+		unsigned long lNum;
4656
+		void * lConsoleHandle;
4657
+		char * lTmpChar;
4658
+		wchar_t lBuffW[1024];
4659
 
4660
-	UINT lOriginalCP = 0;
4661
-	UINT lOriginalOutputCP = 0;
4662
+		UINT lOriginalCP = 0;
4663
+		UINT lOriginalOutputCP = 0;
4664
 
4665
-	if (!aTitle && !aMessage && !aDefaultInput) return lBuff; /* now I can fill lBuff from outside */
4666
+		if (!aTitle && !aMessage && !aDefaultInput) return lBuff; /* now I can fill lBuff from outside */
4667
 
4668
-	if (tfd_quoteDetected(aTitle)) return tinyfd_inputBox("INVALID TITLE WITH QUOTES", aMessage, aDefaultInput);
4669
-	if (tfd_quoteDetected(aMessage)) return tinyfd_inputBox(aTitle, "INVALID MESSAGE WITH QUOTES", aDefaultInput);
4670
-	if (tfd_quoteDetected(aDefaultInput)) return tinyfd_inputBox(aTitle, aMessage, "INVALID DEFAULT_INPUT WITH QUOTES");
4671
+		if (tfd_quoteDetected(aTitle)) return tinyfd_inputBox("INVALID TITLE WITH QUOTES", aMessage, aDefaultInput);
4672
+		if (tfd_quoteDetected(aMessage)) return tinyfd_inputBox(aTitle, "INVALID MESSAGE WITH QUOTES", aDefaultInput);
4673
+		if (tfd_quoteDetected(aDefaultInput)) return tinyfd_inputBox(aTitle, aMessage, "INVALID DEFAULT_INPUT WITH QUOTES: use the GRAVE ACCENT \\x60 instead.");
4674
 
4675
-    mode = 0;
4676
-    hStdin = GetStdHandle(STD_INPUT_HANDLE);
4677
+	mode = 0;
4678
+	hStdin = GetStdHandle(STD_INPUT_HANDLE);
4679
 
4680
-    if ((!tinyfd_forceConsole || !(
4681
-            GetConsoleWindow() ||
4682
-            dialogPresent()))
4683
-			&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
4684
-    {
4685
-        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
4686
-        lBuff[0]='\0';
4687
-		if (inputBoxWinGui(lBuff, aTitle, aMessage, aDefaultInput)) return lBuff;
4688
-		else return NULL;
4689
-	}
4690
-    else if ( dialogPresent() )
4691
-    {
4692
-        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
4693
-        lBuff[0]='\0';
4694
-		if (inputBoxWinConsole(lBuff, aTitle, aMessage, aDefaultInput) ) return lBuff;
4695
-		else return NULL;
4696
-	}
4697
-    else
4698
-    {
4699
-      if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return (char *)0;}
4700
-      lBuff[0]='\0';
4701
-      if (!gWarningDisplayed && !tinyfd_forceConsole)
4702
-      {
4703
-          gWarningDisplayed = 1 ;
4704
-          printf("\n\n%s\n", gTitle);
4705
-          printf("%s\n\n", tinyfd_needs);
4706
-      }
4707
+	if ((!tinyfd_forceConsole || !(
4708
+			GetConsoleWindow() ||
4709
+			dialogPresent()))
4710
+						&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
4711
+	{
4712
+		if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
4713
+		lBuff[0]='\0';
4714
+				if (inputBoxWinGui(lBuff, aTitle, aMessage, aDefaultInput)) return lBuff;
4715
+				else return NULL;
4716
+		}
4717
+	else if ( dialogPresent() )
4718
+	{
4719
+		if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
4720
+		lBuff[0]='\0';
4721
+				if (inputBoxWinConsole(lBuff, aTitle, aMessage, aDefaultInput) ) return lBuff;
4722
+				else return NULL;
4723
+		}
4724
+	else
4725
+	{
4726
+	  if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return (char *)0;}
4727
+	  lBuff[0]='\0';
4728
+	  if (!gWarningDisplayed && !tinyfd_forceConsole)
4729
+	  {
4730
+		  gWarningDisplayed = 1 ;
4731
+		  printf("\n\n%s\n", gTitle);
4732
+		  printf("%s\n\n", tinyfd_needs);
4733
+	  }
4734
 
4735
 	  if (!tinyfd_winUtf8)
4736
 	  {
4737
-		  lOriginalCP = GetConsoleCP();
4738
-		  lOriginalOutputCP = GetConsoleOutputCP();
4739
-		  (void)SetConsoleCP(GetACP());
4740
-		  (void)SetConsoleOutputCP(GetACP());
4741
+			  lOriginalCP = GetConsoleCP();
4742
+			  lOriginalOutputCP = GetConsoleOutputCP();
4743
+			  (void)SetConsoleCP(GetACP());
4744
+			  (void)SetConsoleOutputCP(GetACP());
4745
 	  }
4746
 
4747
 	  if (aTitle && strlen(aTitle))
4748
-      {
4749
-		printf("\n");
4750
-		if (tinyfd_winUtf8) writeUtf8(aTitle);
4751
-		else printf("%s", aTitle);
4752
-		printf("\n\n");
4753
-	  }
4754
-      if ( aMessage && strlen(aMessage) )
4755
-      {
4756
-		if (tinyfd_winUtf8) writeUtf8(aMessage);
4757
-		else printf("%s", aMessage);
4758
-		printf("\n");
4759
-      }
4760
-      printf("(ctrl-Z + enter to cancel): ");
4761
-      if ( ! aDefaultInput )
4762
-      {
4763
-		  (void) GetConsoleMode(hStdin, &mode);
4764
-		  (void) SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT));
4765
-      }
4766
-	  if (tinyfd_winUtf8)
4767
 	  {
4768
-		lConsoleHandle = GetStdHandle(STD_INPUT_HANDLE);
4769
-		(void) ReadConsoleW(lConsoleHandle, lBuffW, MAX_PATH_OR_CMD, &lNum, NULL);
4770
-		if (!aDefaultInput)
4771
-		{
4772
-			(void)SetConsoleMode(hStdin, mode);
4773
-			printf("\n");
4774
-		}
4775
-		lBuffW[lNum] = '\0';
4776
-		if (lBuffW[wcslen(lBuffW) - 1] == '\n') lBuffW[wcslen(lBuffW) - 1] = '\0';
4777
-		if (lBuffW[wcslen(lBuffW) - 1] == '\r') lBuffW[wcslen(lBuffW) - 1] = '\0';
4778
-		lTmpChar = tinyfd_utf16to8(lBuffW);
4779
-		if (lTmpChar)
4780
-		{
4781
-			strcpy(lBuff, lTmpChar);
4782
-			return lBuff;
4783
-		}
4784
-		else
4785
-			return NULL;
4786
+				printf("\n");
4787
+				if (tinyfd_winUtf8) writeUtf8(aTitle);
4788
+				else printf("%s", aTitle);
4789
+				printf("\n\n");
4790
+		  }
4791
+	  if ( aMessage && strlen(aMessage) )
4792
+	  {
4793
+				if (tinyfd_winUtf8) writeUtf8(aMessage);
4794
+				else printf("%s", aMessage);
4795
+				printf("\n");
4796
 	  }
4797
-	  else
4798
+	  printf("(ctrl-Z + enter to cancel): ");
4799
+	  if ( ! aDefaultInput )
4800
 	  {
4801
-		  lEOF = fgets(lBuff, MAX_PATH_OR_CMD, stdin);
4802
-		  if (!aDefaultInput)
4803
+				  (void) GetConsoleMode(hStdin, &mode);
4804
+				  (void) SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT));
4805
+	  }
4806
+		  if (tinyfd_winUtf8)
4807
 		  {
4808
-			  (void)SetConsoleMode(hStdin, mode);
4809
-			  printf("\n");
4810
+				lConsoleHandle = GetStdHandle(STD_INPUT_HANDLE);
4811
+				(void) ReadConsoleW(lConsoleHandle, lBuffW, MAX_PATH_OR_CMD, &lNum, NULL);
4812
+				if (!aDefaultInput)
4813
+				{
4814
+						(void)SetConsoleMode(hStdin, mode);
4815
+						printf("\n");
4816
+				}
4817
+				lBuffW[lNum] = '\0';
4818
+				if (lBuffW[wcslen(lBuffW) - 1] == '\n') lBuffW[wcslen(lBuffW) - 1] = '\0';
4819
+				if (lBuffW[wcslen(lBuffW) - 1] == '\r') lBuffW[wcslen(lBuffW) - 1] = '\0';
4820
+				lTmpChar = tinyfd_utf16to8(lBuffW);
4821
+				if (lTmpChar)
4822
+				{
4823
+						strcpy(lBuff, lTmpChar);
4824
+						return lBuff;
4825
+				}
4826
+				else
4827
+						return NULL;
4828
 		  }
4829
-
4830
-		  if (!tinyfd_winUtf8)
4831
+		  else
4832
 		  {
4833
-			  (void)SetConsoleCP(lOriginalCP);
4834
-			  (void)SetConsoleOutputCP(lOriginalOutputCP);
4835
-		  }
4836
+				  lEOF = fgets(lBuff, MAX_PATH_OR_CMD, stdin);
4837
+				  if (!aDefaultInput)
4838
+				  {
4839
+						  (void)SetConsoleMode(hStdin, mode);
4840
+						  printf("\n");
4841
+				  }
4842
 
4843
-		  if (!lEOF)
4844
-		  {
4845
-			  return NULL;
4846
-		  }
4847
-		  printf("\n");
4848
-		  if (strchr(lBuff, 27))
4849
-		  {
4850
-			  return NULL;
4851
-		  }
4852
-		  if (lBuff[strlen(lBuff) - 1] == '\n')
4853
-		  {
4854
-			  lBuff[strlen(lBuff) - 1] = '\0';
4855
-		  }
4856
-		  return lBuff;
4857
+				  if (!tinyfd_winUtf8)
4858
+				  {
4859
+						  (void)SetConsoleCP(lOriginalCP);
4860
+						  (void)SetConsoleOutputCP(lOriginalOutputCP);
4861
+				  }
4862
+
4863
+				  if (!lEOF)
4864
+				  {
4865
+						  return NULL;
4866
+				  }
4867
+				  printf("\n");
4868
+				  if (strchr(lBuff, 27))
4869
+				  {
4870
+						  return NULL;
4871
+				  }
4872
+				  if (lBuff[strlen(lBuff) - 1] == '\n')
4873
+				  {
4874
+						  lBuff[strlen(lBuff) - 1] = '\0';
4875
+				  }
4876
+				  return lBuff;
4877
+				}
4878
 		}
4879
-	}
4880
 }
4881
 
4882
 
4883
 char * tinyfd_saveFileDialog(
4884
-        char const * aTitle , /* NULL or "" */
4885
-        char const * aDefaultPathAndFile , /* NULL or "" */
4886
-        int aNumOfFilterPatterns , /* 0 */
4887
-        char const * const * aFilterPatterns , /* NULL or {"*.jpg","*.png"} */
4888
-        char const * aSingleFilterDescription ) /* NULL or "image files" */
4889
+		char const * aTitle , /* NULL or "" */
4890
+		char const * aDefaultPathAndOrFile , /* NULL or "" */
4891
+		int aNumOfFilterPatterns , /* 0 */
4892
+		char const * const * aFilterPatterns , /* NULL or {"*.jpg","*.png"} */
4893
+		char const * aSingleFilterDescription ) /* NULL or "image files" */
4894
 {
4895
-        static char lBuff[MAX_PATH_OR_CMD] ;
4896
-        char lString[MAX_PATH_OR_CMD] ;
4897
-        char * p ;
4898
-		char * lPointerInputBox;
4899
-		int i;
4900
+		static char lBuff[MAX_PATH_OR_CMD] ;
4901
+		char lString[MAX_PATH_OR_CMD] ;
4902
+		char * p ;
4903
+				char * lPointerInputBox;
4904
+				int i;
4905
 
4906
-        lBuff[0]='\0';
4907
+		lBuff[0]='\0';
4908
 
4909
-		if (tfd_quoteDetected(aTitle)) return tinyfd_saveFileDialog("INVALID TITLE WITH QUOTES", aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
4910
-		if (tfd_quoteDetected(aDefaultPathAndFile)) return tinyfd_saveFileDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
4911
-		if (tfd_quoteDetected(aSingleFilterDescription)) return tinyfd_saveFileDialog(aTitle, aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, "INVALID FILTER_DESCRIPTION WITH QUOTES");
4912
-		for (i = 0; i < aNumOfFilterPatterns; i++)
4913
+		if ( ! aFilterPatterns ) aNumOfFilterPatterns = 0 ;
4914
+				if (tfd_quoteDetected(aTitle)) return tinyfd_saveFileDialog("INVALID TITLE WITH QUOTES", aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
4915
+				if (tfd_quoteDetected(aDefaultPathAndOrFile)) return tinyfd_saveFileDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
4916
+				if (tfd_quoteDetected(aSingleFilterDescription)) return tinyfd_saveFileDialog(aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, "INVALID FILTER_DESCRIPTION WITH QUOTES");
4917
+				for (i = 0; i < aNumOfFilterPatterns; i++)
4918
+				{
4919
+						if (tfd_quoteDetected(aFilterPatterns[i])) return tinyfd_saveFileDialog("INVALID FILTER_PATTERN WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultPathAndOrFile, 0, NULL, NULL);
4920
+				}
4921
+
4922
+
4923
+				if ( ( !tinyfd_forceConsole || !( GetConsoleWindow() || dialogPresent() ) )
4924
+						&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
4925
 		{
4926
-			if (tfd_quoteDetected(aFilterPatterns[i])) return tinyfd_saveFileDialog("INVALID FILTER_PATTERN WITH QUOTES", aDefaultPathAndFile, 0, NULL, NULL);
4927
+			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
4928
+			p = saveFileDialogWinGui(lBuff,
4929
+								aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns, (char const * const *)aFilterPatterns, aSingleFilterDescription);
4930
 		}
4931
+				else if (dialogPresent())
4932
+				{
4933
+						if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return (char *)0; }
4934
+						p = saveFileDialogWinConsole(lBuff, aTitle, aDefaultPathAndOrFile);
4935
+				}
4936
+				else
4937
+				{
4938
+						if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return (char *)0; }
4939
+						strcpy(lBuff, "Save file in ");
4940
+						strcat(lBuff, getCurDir());
4941
 
4942
+						lPointerInputBox = tinyfd_inputBox(NULL,NULL,NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
4943
+						if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
4944
+						p = tinyfd_inputBox(aTitle, lBuff, "");
4945
+						if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
4946
+						if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
4947
+						p = lBuff;
4948
+				}
4949
 
4950
-		if ( ( !tinyfd_forceConsole || !( GetConsoleWindow() || dialogPresent() ) )
4951
-			&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
4952
-        {
4953
-            if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
4954
-            p = saveFileDialogWinGui(lBuff,
4955
-				aTitle, aDefaultPathAndFile, aNumOfFilterPatterns, (char const * const *)aFilterPatterns, aSingleFilterDescription);
4956
-        }
4957
-		else if (dialogPresent())
4958
+		if ( ! p || ! strlen( p )  )
4959
 		{
4960
-			if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return (char *)0; }
4961
-			p = saveFileDialogWinConsole(lBuff, aTitle, aDefaultPathAndFile);
4962
+				return NULL;
4963
 		}
4964
-		else
4965
+		getPathWithoutFinalSlash( lString , p ) ;
4966
+		if ( strlen( lString ) && ! dirExists( lString ) )
4967
 		{
4968
-			if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return (char *)0; }
4969
-			strcpy(lBuff, "Save file in ");
4970
-			strcat(lBuff, getCurDir());
4971
-
4972
-			lPointerInputBox = tinyfd_inputBox(NULL,NULL,NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
4973
-			if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
4974
-			p = tinyfd_inputBox(aTitle, lBuff, "");
4975
-			if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
4976
-			if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
4977
-			p = lBuff;
4978
+				return NULL ;
4979
 		}
4980
-
4981
-        if ( ! p || ! strlen( p )  )
4982
-        {
4983
-                return NULL;
4984
-        }
4985
-        getPathWithoutFinalSlash( lString , p ) ;
4986
-        if ( strlen( lString ) && ! dirExists( lString ) )
4987
-        {
4988
-                return NULL ;
4989
-        }
4990
-        getLastName(lString,p);
4991
-        if ( ! filenameValid(lString) )
4992
-        {
4993
-                return NULL;
4994
-        }
4995
-        return p ;
4996
+		getLastName(lString,p);
4997
+		if ( ! filenameValid(lString) )
4998
+		{
4999
+				return NULL;
5000
+		}
5001
+		return p ;
5002
 }
5003
 
5004
 
5005
 /* in case of multiple files, the separator is | */
5006
 char * tinyfd_openFileDialog(
5007
-    char const * aTitle , /* NULL or "" */
5008
-	char const * aDefaultPathAndFile, /* NULL or "" */
5009
-    int aNumOfFilterPatterns , /* 0 */
5010
-	char const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
5011
-	char const * aSingleFilterDescription, /* NULL or "image files" */
5012
-    int aAllowMultipleSelects ) /* 0 or 1 */
5013
+	char const * aTitle , /* NULL or "" */
5014
+		char const * aDefaultPathAndOrFile, /* NULL or "" */
5015
+	int aNumOfFilterPatterns , /* 0 */
5016
+		char const * const * aFilterPatterns, /* NULL or {"*.jpg","*.png"} */
5017
+		char const * aSingleFilterDescription, /* NULL or "image files" */
5018
+	int aAllowMultipleSelects ) /* 0 or 1 */
5019
 {
5020
+	static char lBuff[MAX_PATH_OR_CMD];
5021
 	char lString[MAX_PATH_OR_CMD];
5022
-	char lBuff[MAX_PATH_OR_CMD];
5023
-	char * p;
5024
-	char * lPointerInputBox;
5025
-	int i;
5026
+		char * p;
5027
+		char * lPointerInputBox;
5028
+		int i;
5029
 
5030
-	if (tfd_quoteDetected(aTitle)) return tinyfd_openFileDialog("INVALID TITLE WITH QUOTES", aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
5031
-	if (tfd_quoteDetected(aDefaultPathAndFile)) return tinyfd_openFileDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
5032
-	if (tfd_quoteDetected(aSingleFilterDescription)) return tinyfd_openFileDialog(aTitle, aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, "INVALID FILTER_DESCRIPTION WITH QUOTES", aAllowMultipleSelects);
5033
-	for (i = 0; i < aNumOfFilterPatterns; i++)
5034
-	{
5035
-		if (tfd_quoteDetected(aFilterPatterns[i])) return tinyfd_openFileDialog("INVALID FILTER_PATTERN WITH QUOTES", aDefaultPathAndFile, 0, NULL, NULL, aAllowMultipleSelects);
5036
-	}
5037
-
5038
-    if ( ( !tinyfd_forceConsole || !( GetConsoleWindow() || dialogPresent() ) )
5039
-		&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
5040
-        {
5041
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
5042
-                p = openFileDialogWinGui( aTitle, aDefaultPathAndFile, aNumOfFilterPatterns,
5043
-					(char const * const *)aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
5044
-        }
5045
-		else if (dialogPresent())
5046
+	if ( ! aFilterPatterns ) aNumOfFilterPatterns = 0 ;
5047
+		if (tfd_quoteDetected(aTitle)) return tinyfd_openFileDialog("INVALID TITLE WITH QUOTES", aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
5048
+		if (tfd_quoteDetected(aDefaultPathAndOrFile)) return tinyfd_openFileDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
5049
+		if (tfd_quoteDetected(aSingleFilterDescription)) return tinyfd_openFileDialog(aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, "INVALID FILTER_DESCRIPTION WITH QUOTES", aAllowMultipleSelects);
5050
+		for (i = 0; i < aNumOfFilterPatterns; i++)
5051
 		{
5052
-			if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return (char *)0; }
5053
-			p = openFileDialogWinConsole(aTitle, aDefaultPathAndFile);
5054
+				if (tfd_quoteDetected(aFilterPatterns[i])) return tinyfd_openFileDialog("INVALID FILTER_PATTERN WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultPathAndOrFile, 0, NULL, NULL, aAllowMultipleSelects);
5055
 		}
5056
-		else
5057
+
5058
+	if ( ( !tinyfd_forceConsole || !( GetConsoleWindow() || dialogPresent() ) )
5059
+				&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
5060
 		{
5061
-			if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return (char *)0; }
5062
-			strcpy(lBuff, "Open file from ");
5063
-			strcat(lBuff, getCurDir());
5064
-			lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
5065
-			if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
5066
-			p = tinyfd_inputBox(aTitle, lBuff, "");
5067
-			if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
5068
-			if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
5069
-			p = lBuff;
5070
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
5071
+				p = openFileDialogWinGui( aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns,
5072
+										(char const * const *)aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
5073
 		}
5074
+				else if (dialogPresent())
5075
+				{
5076
+						if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return (char *)0; }
5077
+						p = openFileDialogWinConsole(aTitle, aDefaultPathAndOrFile);
5078
+				}
5079
+				else
5080
+				{
5081
+						if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return (char *)0; }
5082
+						strcpy(lBuff, "Open file from ");
5083
+						strcat(lBuff, getCurDir());
5084
+						lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
5085
+						if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
5086
+						p = tinyfd_inputBox(aTitle, lBuff, "");
5087
+						if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
5088
+						if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
5089
+						p = lBuff;
5090
+				}
5091
 
5092
-        if ( ! p || ! strlen( p )  )
5093
-        {
5094
-                return NULL;
5095
-        }
5096
-        if ( aAllowMultipleSelects && strchr(p, '|') )
5097
-        {
5098
-                p = ensureFilesExist( (char *) p , p ) ;
5099
-        }
5100
-        else if ( ! fileExists(p) )
5101
-        {
5102
-                return NULL ;
5103
-        }
5104
-        /* printf( "lBuff3: %s\n" , p ) ; */
5105
-        return p ;
5106
+		if ( ! p || ! strlen( p )  )
5107
+		{
5108
+				return NULL;
5109
+		}
5110
+		if ( aAllowMultipleSelects && strchr(p, '|') )
5111
+		{
5112
+				p = ensureFilesExist( (char *) p , p ) ;
5113
+		}
5114
+		else if ( ! fileExists(p) )
5115
+		{
5116
+				return NULL ;
5117
+		}
5118
+		/* printf( "lBuff3: %s\n" , p ) ; */
5119
+		return p ;
5120
 }
5121
 
5122
 
5123
 char * tinyfd_selectFolderDialog(
5124
-        char const * aTitle , /* NULL or "" */
5125
-        char const * aDefaultPath ) /* NULL or "" */
5126
+		char const * aTitle , /* NULL or "" */
5127
+		char const * aDefaultPath ) /* NULL or "" */
5128
 {
5129
-	static char lBuff[MAX_PATH_OR_CMD];
5130
-	char * p;
5131
-	char * lPointerInputBox;
5132
-	char lString[MAX_PATH_OR_CMD];
5133
+		static char lBuff[MAX_PATH_OR_CMD];
5134
+		char * p;
5135
+		char * lPointerInputBox;
5136
+		char lString[MAX_PATH_OR_CMD];
5137
 
5138
-	if (tfd_quoteDetected(aTitle)) return tinyfd_selectFolderDialog("INVALID TITLE WITH QUOTES", aDefaultPath);
5139
-	if (tfd_quoteDetected(aDefaultPath)) return tinyfd_selectFolderDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES");
5140
+		if (tfd_quoteDetected(aTitle)) return tinyfd_selectFolderDialog("INVALID TITLE WITH QUOTES", aDefaultPath);
5141
+		if (tfd_quoteDetected(aDefaultPath)) return tinyfd_selectFolderDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES");
5142
 
5143
-    if ( ( !tinyfd_forceConsole || !( GetConsoleWindow() || dialogPresent() ) )
5144
-		&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
5145
-        {
5146
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
5147
-                p = selectFolderDialogWinGui(lBuff, aTitle, aDefaultPath);
5148
-        }
5149
-		else
5150
-		if (dialogPresent())
5151
+	if ( ( !tinyfd_forceConsole || !( GetConsoleWindow() || dialogPresent() ) )
5152
+				&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
5153
 		{
5154
-			if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return (char *)0; }
5155
-			p = selectFolderDialogWinConsole(lBuff, aTitle, aDefaultPath);
5156
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
5157
+				p = selectFolderDialogWinGui(lBuff, aTitle, aDefaultPath);
5158
 		}
5159
-		else
5160
+				else
5161
+				if (dialogPresent())
5162
+				{
5163
+						if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return (char *)0; }
5164
+						p = selectFolderDialogWinConsole(lBuff, aTitle, aDefaultPath);
5165
+				}
5166
+				else
5167
+				{
5168
+						if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return (char *)0; }
5169
+						strcpy(lBuff, "Select folder from ");
5170
+						strcat(lBuff, getCurDir());
5171
+						lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
5172
+						if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
5173
+						p = tinyfd_inputBox(aTitle, lBuff, "");
5174
+						if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
5175
+						if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
5176
+						p = lBuff;
5177
+				}
5178
+
5179
+		if ( ! p || ! strlen( p ) || ! dirExists( p ) )
5180
 		{
5181
-			if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return (char *)0; }
5182
-			strcpy(lBuff, "Select folder from ");
5183
-			strcat(lBuff, getCurDir());
5184
-			lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
5185
-			if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
5186
-			p = tinyfd_inputBox(aTitle, lBuff, "");
5187
-			if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
5188
-			if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
5189
-			p = lBuff;
5190
+				return NULL ;
5191
 		}
5192
-
5193
-        if ( ! p || ! strlen( p ) || ! dirExists( p ) )
5194
-        {
5195
-                return NULL ;
5196
-        }
5197
-        return p ;
5198
+		return p ;
5199
 }
5200
 
5201
 
5202
+/* aDefaultRGB is used only if aDefaultHexRGB is absent */
5203
+/* aDefaultRGB and aoResultRGB can be the same array */
5204
+/* returns NULL on cancel */
5205
 /* returns the hexcolor as a string "#FF0000" */
5206
 /* aoResultRGB also contains the result */
5207
-/* aDefaultRGB is used only if aDefaultHexRGB is NULL */
5208
-/* aDefaultRGB and aoResultRGB can be the same array */
5209
 char * tinyfd_colorChooser(
5210
-        char const * aTitle, /* NULL or "" */
5211
-        char const * aDefaultHexRGB, /* NULL or "#FF0000"*/
5212
-        unsigned char const aDefaultRGB[3], /* { 0 , 255 , 255 } */
5213
-        unsigned char aoResultRGB[3]) /* { 0 , 0 , 0 } */
5214
+		char const * aTitle, /* NULL or "" */
5215
+		char const * aDefaultHexRGB, /* NULL or "" or "#FF0000"*/
5216
+		unsigned char const aDefaultRGB[3], /* { 0 , 255 , 255 } */
5217
+		unsigned char aoResultRGB[3]) /* { 0 , 0 , 0 } */
5218
 {
5219
-	static char lDefaultHexRGB[16];
5220
-    int i;
5221
-    char * p ;
5222
-	char * lPointerInputBox;
5223
-	char lString[MAX_PATH_OR_CMD];
5224
+		static char lDefaultHexRGB[16];
5225
+	int i;
5226
+	char * p ;
5227
+		char * lPointerInputBox;
5228
+		char lString[MAX_PATH_OR_CMD];
5229
 
5230
-	lDefaultHexRGB[0] = '\0';
5231
+		lDefaultHexRGB[0] = '\0';
5232
 
5233
-	if (tfd_quoteDetected(aTitle)) return tinyfd_colorChooser("INVALID TITLE WITH QUOTES", aDefaultHexRGB, aDefaultRGB, aoResultRGB);
5234
-	if (tfd_quoteDetected(aDefaultHexRGB)) return tinyfd_colorChooser(aTitle, "INVALID DEFAULT_HEX_RGB WITH QUOTES", aDefaultRGB, aoResultRGB);
5235
+		if (tfd_quoteDetected(aTitle)) return tinyfd_colorChooser("INVALID TITLE WITH QUOTES", aDefaultHexRGB, aDefaultRGB, aoResultRGB);
5236
+		if (tfd_quoteDetected(aDefaultHexRGB)) return tinyfd_colorChooser(aTitle, "INVALID DEFAULT_HEX_RGB WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultRGB, aoResultRGB);
5237
 
5238
-    if ( (!tinyfd_forceConsole || !( GetConsoleWindow() || dialogPresent()) )
5239
-		&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
5240
-    {
5241
-		if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
5242
-		p = colorChooserWinGui(aTitle, aDefaultHexRGB, aDefaultRGB, aoResultRGB);
5243
-        if (p)
5244
-        {
5245
-            strcpy(lDefaultHexRGB, p);
5246
-            return lDefaultHexRGB;
5247
-        }
5248
-        return NULL;
5249
-    }
5250
-	else if (dialogPresent())
5251
+	if ( (!tinyfd_forceConsole || !( GetConsoleWindow() || dialogPresent()) )
5252
+				&& (!getenv("SSH_CLIENT") || getenvDISPLAY()))
5253
 	{
5254
-		if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return (char *)0; }
5255
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"windows");return (char *)1;}
5256
+				p = colorChooserWinGui(aTitle, aDefaultHexRGB, aDefaultRGB, aoResultRGB);
5257
+		if (p)
5258
+		{
5259
+			strcpy(lDefaultHexRGB, p);
5260
+			return lDefaultHexRGB;
5261
+		}
5262
+		return NULL;
5263
 	}
5264
-	else
5265
-	{
5266
-		if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return (char *)0; }
5267
-	}
5268
+		else if (dialogPresent())
5269
+		{
5270
+				if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "dialog"); return (char *)0; }
5271
+		}
5272
+		else
5273
+		{
5274
+				if (aTitle&&!strcmp(aTitle, "tinyfd_query")){ strcpy(tinyfd_response, "basicinput"); return (char *)0; }
5275
+		}
5276
 
5277
-	if (aDefaultHexRGB)
5278
+		if (aDefaultHexRGB && (strlen(aDefaultHexRGB)==7) )
5279
+		{
5280
+				strncpy(lDefaultHexRGB, aDefaultHexRGB,7);
5281
+				lDefaultHexRGB[7]='\0';
5282
+		}
5283
+		else
5284
+		{
5285
+				RGB2Hex(aDefaultRGB, lDefaultHexRGB);
5286
+		}
5287
+
5288
+		lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
5289
+		if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
5290
+		p = tinyfd_inputBox(aTitle, "Enter hex rgb color (i.e. #f5ca20)", lDefaultHexRGB);
5291
+
5292
+	if ( !p || (strlen(p) != 7) || (p[0] != '#') )
5293
 	{
5294
-		strncpy(lDefaultHexRGB, aDefaultHexRGB,7);
5295
-		lDefaultHexRGB[7]='\0';
5296
+			return NULL ;
5297
 	}
5298
-	else
5299
+	for ( i = 1 ; i < 7 ; i ++ )
5300
 	{
5301
-		RGB2Hex(aDefaultRGB, lDefaultHexRGB);
5302
+			if ( ! isxdigit( (int) p[i] ) )
5303
+			{
5304
+					return NULL ;
5305
+			}
5306
 	}
5307
+	Hex2RGB(p,aoResultRGB);
5308
 
5309
-	lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
5310
-	if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
5311
-	p = tinyfd_inputBox(aTitle, "Enter hex rgb color (i.e. #f5ca20)", lDefaultHexRGB);
5312
+		strcpy(lDefaultHexRGB, p);
5313
 
5314
-    if ( !p || (strlen(p) != 7) || (p[0] != '#') )
5315
-    {
5316
-            return NULL ;
5317
-    }
5318
-    for ( i = 1 ; i < 7 ; i ++ )
5319
-    {
5320
-            if ( ! isxdigit( (int) p[i] ) )
5321
-            {
5322
-                    return NULL ;
5323
-            }
5324
-    }
5325
-    Hex2RGB(p,aoResultRGB);
5326
+		if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
5327
 
5328
-	strcpy(lDefaultHexRGB, p);
5329
-
5330
-	if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
5331
-
5332
-	return lDefaultHexRGB;
5333
+		return lDefaultHexRGB;
5334
 }
5335
 
5336
 
5337
@@ -3225,35 +3275,35 @@
5338
 
5339
 int tfd_isDarwin(void)
5340
 {
5341
-        static int lsIsDarwin = -1 ;
5342
-        struct utsname lUtsname ;
5343
-        if ( lsIsDarwin < 0 )
5344
-        {
5345
-                lsIsDarwin = !uname(&lUtsname) && !strcmp(lUtsname.sysname,"Darwin") ;
5346
-        }
5347
-        return lsIsDarwin ;
5348
+		static int lsIsDarwin = -1 ;
5349
+		struct utsname lUtsname ;
5350
+		if ( lsIsDarwin < 0 )
5351
+		{
5352
+				lsIsDarwin = !uname(&lUtsname) && !strcmp(lUtsname.sysname,"Darwin") ;
5353
+		}
5354
+		return lsIsDarwin ;
5355
 }
5356
 
5357
 
5358
 static int dirExists( char const * aDirPath )
5359
 {
5360
-        DIR * lDir ;
5361
-        if ( ! aDirPath || ! strlen( aDirPath ) )
5362
-                return 0 ;
5363
-        lDir = opendir( aDirPath ) ;
5364
-        if ( ! lDir )
5365
-        {
5366
-            return 0 ;
5367
-        }
5368
-        closedir( lDir ) ;
5369
-        return 1 ;
5370
+		DIR * lDir ;
5371
+		if ( ! aDirPath || ! strlen( aDirPath ) )
5372
+				return 0 ;
5373
+		lDir = opendir( aDirPath ) ;
5374
+		if ( ! lDir )
5375
+		{
5376
+			return 0 ;
5377
+		}
5378
+		closedir( lDir ) ;
5379
+		return 1 ;
5380
 }
5381
 
5382
 
5383
 static int detectPresence( char const * aExecutable )
5384
 {
5385
    char lBuff[MAX_PATH_OR_CMD] ;
5386
-   char lTestedString[MAX_PATH_OR_CMD] = "which " ;
5387
+   char lTestedString[MAX_PATH_OR_CMD] = "command -v " ;
5388
    FILE * lIn ;
5389
 #ifdef _GNU_SOURCE
5390
    char* lAllocatedCharString;
5391
@@ -3264,439 +3314,493 @@
5392
    strcat( lTestedString, " 2>/dev/null ");
5393
    lIn = popen( lTestedString , "r" ) ;
5394
    if ( ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
5395
-    && ( ! strchr( lBuff , ':' ) ) && ( strncmp(lBuff, "no ", 3) ) )
5396
+	&& ( ! strchr( lBuff , ':' ) ) && ( strncmp(lBuff, "no ", 3) ) )
5397
    {   /* present */
5398
-      pclose( lIn ) ;
5399
+	  pclose( lIn ) ;
5400
 
5401
 #ifdef _GNU_SOURCE /*to bypass this, just comment out "#define _GNU_SOURCE" at the top of the file*/
5402
-      if ( lBuff[strlen( lBuff ) -1] == '\n' ) lBuff[strlen( lBuff ) -1] = '\0' ;
5403
-      lAllocatedCharString = realpath(lBuff,NULL); /*same as canonicalize_file_name*/
5404
-      lSubstringUndetected = ! strstr(lAllocatedCharString, aExecutable);
5405
-      free(lAllocatedCharString);
5406
-      if (lSubstringUndetected)
5407
-      {
5408
-         if (tinyfd_verbose) printf("detectPresence %s %d\n", aExecutable, 0);
5409
-         return 0;
5410
-      }
5411
+	  if ( lBuff[strlen( lBuff ) -1] == '\n' ) lBuff[strlen( lBuff ) -1] = '\0' ;
5412
+	  lAllocatedCharString = realpath(lBuff,NULL); /*same as canonicalize_file_name*/
5413
+	  lSubstringUndetected = ! strstr(lAllocatedCharString, aExecutable);
5414
+	  free(lAllocatedCharString);
5415
+	  if (lSubstringUndetected)
5416
+	  {
5417
+		 if (tinyfd_verbose) printf("detectPresence %s %d\n", aExecutable, 0);
5418
+		 return 0;
5419
+	  }
5420
 #endif /*_GNU_SOURCE*/
5421
 
5422
-      if (tinyfd_verbose) printf("detectPresence %s %d\n", aExecutable, 1);
5423
-      return 1 ;
5424
+	  if (tinyfd_verbose) printf("detectPresence %s %d\n", aExecutable, 1);
5425
+	  return 1 ;
5426
    }
5427
    else
5428
    {
5429
-      pclose( lIn ) ;
5430
-      if (tinyfd_verbose) printf("detectPresence %s %d\n", aExecutable, 0);
5431
-      return 0 ;
5432
+	  pclose( lIn ) ;
5433
+	  if (tinyfd_verbose) printf("detectPresence %s %d\n", aExecutable, 0);
5434
+	  return 0 ;
5435
    }
5436
 }
5437
 
5438
 
5439
 static char * getVersion( char const * aExecutable ) /*version must be first numeral*/
5440
 {
5441
-	static char lBuff[MAX_PATH_OR_CMD] ;
5442
-	char lTestedString[MAX_PATH_OR_CMD] ;
5443
-	FILE * lIn ;
5444
-	char * lTmp ;
5445
+		static char lBuff[MAX_PATH_OR_CMD] ;
5446
+		char lTestedString[MAX_PATH_OR_CMD] ;
5447
+		FILE * lIn ;
5448
+		char * lTmp ;
5449
 
5450
-    strcpy( lTestedString , aExecutable ) ;
5451
-    strcat( lTestedString , " --version" ) ;
5452
+	strcpy( lTestedString , aExecutable ) ;
5453
+	strcat( lTestedString , " --version" ) ;
5454
 
5455
-    lIn = popen( lTestedString , "r" ) ;
5456
-        lTmp = fgets( lBuff , sizeof( lBuff ) , lIn ) ;
5457
-        pclose( lIn ) ;
5458
+	lIn = popen( lTestedString , "r" ) ;
5459
+		lTmp = fgets( lBuff , sizeof( lBuff ) , lIn ) ;
5460
+		pclose( lIn ) ;
5461
 
5462
-	lTmp += strcspn(lTmp,"0123456789");
5463
-	/* printf("lTmp:%s\n", lTmp); */
5464
-	return lTmp ;
5465
+		lTmp += strcspn(lTmp,"0123456789");
5466
+		 /* printf("lTmp:%s\n", lTmp); */
5467
+		return lTmp ;
5468
 }
5469
 
5470
 
5471
 static int * getMajorMinorPatch( char const * aExecutable )
5472
 {
5473
-	static int lArray[3] ;
5474
-	char * lTmp ;
5475
+		static int lArray[3] ;
5476
+		char * lTmp ;
5477
 
5478
-	lTmp = (char *) getVersion(aExecutable);
5479
-	lArray[0] = atoi( strtok(lTmp," ,.-") ) ;
5480
-	/* printf("lArray0 %d\n", lArray[0]); */
5481
-	lArray[1] = atoi( strtok(0," ,.-") ) ;
5482
-	/* printf("lArray1 %d\n", lArray[1]); */
5483
-	lArray[2] = atoi( strtok(0," ,.-") ) ;
5484
-	/* printf("lArray2 %d\n", lArray[2]); */
5485
+		lTmp = (char *) getVersion(aExecutable);
5486
+		lArray[0] = atoi( strtok(lTmp," ,.-") ) ;
5487
+		/* printf("lArray0 %d\n", lArray[0]); */
5488
+		lArray[1] = atoi( strtok(0," ,.-") ) ;
5489
+		/* printf("lArray1 %d\n", lArray[1]); */
5490
+		lArray[2] = atoi( strtok(0," ,.-") ) ;
5491
+		/* printf("lArray2 %d\n", lArray[2]); */
5492
 
5493
-	if ( !lArray[0] && !lArray[1] && !lArray[2] ) return NULL;
5494
-	return lArray ;
5495
+		if ( !lArray[0] && !lArray[1] && !lArray[2] ) return NULL;
5496
+		return lArray ;
5497
 }
5498
 
5499
 
5500
 static int tryCommand( char const * aCommand )
5501
 {
5502
-        char lBuff[MAX_PATH_OR_CMD] ;
5503
-        FILE * lIn ;
5504
+		char lBuff[MAX_PATH_OR_CMD] ;
5505
+		FILE * lIn ;
5506
 
5507
-        lIn = popen( aCommand , "r" ) ;
5508
-        if ( fgets( lBuff , sizeof( lBuff ) , lIn ) == NULL )
5509
-        {       /* present */
5510
-                pclose( lIn ) ;
5511
-                return 1 ;
5512
-        }
5513
-        else
5514
-        {
5515
-                pclose( lIn ) ;
5516
-                return 0 ;
5517
-        }
5518
+		lIn = popen( aCommand , "r" ) ;
5519
+		if ( fgets( lBuff , sizeof( lBuff ) , lIn ) == NULL )
5520
+		{       /* present */
5521
+				pclose( lIn ) ;
5522
+				return 1 ;
5523
+		}
5524
+		else
5525
+		{
5526
+				pclose( lIn ) ;
5527
+				return 0 ;
5528
+		}
5529
 
5530
 }
5531
 
5532
 
5533
 static int isTerminalRunning(void)
5534
 {
5535
-	static int lIsTerminalRunning = -1 ;
5536
-	if ( lIsTerminalRunning < 0 )
5537
-	{
5538
-		lIsTerminalRunning = isatty(1);
5539
-		if (tinyfd_verbose) printf("isTerminalRunning %d\n", lIsTerminalRunning );
5540
-	}
5541
-	return lIsTerminalRunning;
5542
+		static int lIsTerminalRunning = -1 ;
5543
+		if ( lIsTerminalRunning < 0 )
5544
+		{
5545
+				lIsTerminalRunning = isatty(1);
5546
+				if (tinyfd_verbose) printf("isTerminalRunning %d\n", lIsTerminalRunning );
5547
+		}
5548
+		return lIsTerminalRunning;
5549
 }
5550
 
5551
 
5552
 static char * dialogNameOnly(void)
5553
 {
5554
-	static char lDialogName[128] = "*" ;
5555
-	if ( lDialogName[0] == '*' )
5556
-	{
5557
-		if (!tinyfd_allowCursesDialogs)
5558
+		static char lDialogName[128] = "*" ;
5559
+		if ( lDialogName[0] == '*' )
5560
 		{
5561
-			strcpy(lDialogName , "" );
5562
+				if (!tinyfd_allowCursesDialogs)
5563
+				{
5564
+						strcpy(lDialogName , "" );
5565
+				}
5566
+				else if ( tfd_isDarwin() && * strcpy(lDialogName , "/opt/local/bin/dialog" )
5567
+						&& detectPresence( lDialogName ) )
5568
+				{}
5569
+				else if ( * strcpy(lDialogName , "dialog" )
5570
+						&& detectPresence( lDialogName ) )
5571
+				{}
5572
+				else
5573
+				{
5574
+						strcpy(lDialogName , "" );
5575
+				}
5576
 		}
5577
-		else if ( tfd_isDarwin() && * strcpy(lDialogName , "/opt/local/bin/dialog" )
5578
-			&& detectPresence( lDialogName ) )
5579
-		{}
5580
-		else if ( * strcpy(lDialogName , "dialog" )
5581
-			&& detectPresence( lDialogName ) )
5582
-		{}
5583
-		else
5584
-		{
5585
-			strcpy(lDialogName , "" );
5586
-		}
5587
-	}
5588
-	return lDialogName ;
5589
+		return lDialogName ;
5590
 }
5591
 
5592
 
5593
 int isDialogVersionBetter09b(void)
5594
 {
5595
-        char const * lDialogName ;
5596
-        char * lVersion ;
5597
-        int lMajor ;
5598
-        int lMinor ;
5599
-        int lDate ;
5600
-        int lResult ;
5601
-        char * lMinorP ;
5602
-        char * lLetter ;
5603
-        char lBuff[128] ;
5604
+		char const * lDialogName ;
5605
+		char * lVersion ;
5606
+		int lMajor ;
5607
+		int lMinor ;
5608
+		int lDate ;
5609
+		int lResult ;
5610
+		char * lMinorP ;
5611
+		char * lLetter ;
5612
+		char lBuff[128] ;
5613
 
5614
-        /*char lTest[128] = " 0.9b-20031126" ;*/
5615
+		/*char lTest[128] = " 0.9b-20031126" ;*/
5616
 
5617
-        lDialogName = dialogNameOnly() ;
5618
-        if ( ! strlen(lDialogName) || !(lVersion = (char *) getVersion(lDialogName)) ) return 0 ;
5619
-        /*lVersion = lTest ;*/
5620
-        /*printf("lVersion %s\n", lVersion);*/
5621
-        strcpy(lBuff,lVersion);
5622
-        lMajor = atoi( strtok(lVersion," ,.-") ) ;
5623
-        /*printf("lMajor %d\n", lMajor);*/
5624
-        lMinorP = strtok(0," ,.-abcdefghijklmnopqrstuvxyz");
5625
-        lMinor = atoi( lMinorP ) ;
5626
-        /*printf("lMinor %d\n", lMinor );*/
5627
-        lDate = atoi( strtok(0," ,.-") ) ;
5628
-        if (lDate<0) lDate = - lDate;
5629
-        /*printf("lDate %d\n", lDate);*/
5630
-        lLetter = lMinorP + strlen(lMinorP) ;
5631
-        strcpy(lVersion,lBuff);
5632
-        strtok(lLetter," ,.-");
5633
-        /*printf("lLetter %s\n", lLetter);*/
5634
-        lResult = (lMajor > 0) || ( ( lMinor == 9 ) && (*lLetter == 'b') && (lDate >= 20031126) );
5635
-        /*printf("lResult %d\n", lResult);*/
5636
-        return lResult;
5637
+		lDialogName = dialogNameOnly() ;
5638
+		if ( ! strlen(lDialogName) || !(lVersion = (char *) getVersion(lDialogName)) ) return 0 ;
5639
+		/*lVersion = lTest ;*/
5640
+		/*printf("lVersion %s\n", lVersion);*/
5641
+		strcpy(lBuff,lVersion);
5642
+		lMajor = atoi( strtok(lVersion," ,.-") ) ;
5643
+		/*printf("lMajor %d\n", lMajor);*/
5644
+		lMinorP = strtok(0," ,.-abcdefghijklmnopqrstuvxyz");
5645
+		lMinor = atoi( lMinorP ) ;
5646
+		/*printf("lMinor %d\n", lMinor );*/
5647
+		lDate = atoi( strtok(0," ,.-") ) ;
5648
+		if (lDate<0) lDate = - lDate;
5649
+		/*printf("lDate %d\n", lDate);*/
5650
+		lLetter = lMinorP + strlen(lMinorP) ;
5651
+		strcpy(lVersion,lBuff);
5652
+		strtok(lLetter," ,.-");
5653
+		/*printf("lLetter %s\n", lLetter);*/
5654
+		lResult = (lMajor > 0) || ( ( lMinor == 9 ) && (*lLetter == 'b') && (lDate >= 20031126) );
5655
+		/*printf("lResult %d\n", lResult);*/
5656
+		return lResult;
5657
 }
5658
 
5659
 
5660
 static int whiptailPresentOnly(void)
5661
 {
5662
-        static int lWhiptailPresent = -1 ;
5663
-		if (!tinyfd_allowCursesDialogs) return 0;
5664
-        if ( lWhiptailPresent < 0 )
5665
-        {
5666
-                lWhiptailPresent = detectPresence( "whiptail" ) ;
5667
-        }
5668
-        return lWhiptailPresent ;
5669
+		static int lWhiptailPresent = -1 ;
5670
+				if (!tinyfd_allowCursesDialogs) return 0;
5671
+		if ( lWhiptailPresent < 0 )
5672
+		{
5673
+				lWhiptailPresent = detectPresence( "whiptail" ) ;
5674
+		}
5675
+		return lWhiptailPresent ;
5676
 }
5677
 
5678
 
5679
 static char * terminalName(void)
5680
 {
5681
-        static char lTerminalName[128] = "*" ;
5682
-        char lShellName[64] = "*" ;
5683
-        int * lArray;
5684
+		static char lTerminalName[128] = "*" ;
5685
+		char lShellName[64] = "*" ;
5686
+		int * lArray;
5687
 
5688
-        if ( lTerminalName[0] == '*' )
5689
-        {
5690
-                if ( detectPresence( "bash" ) )
5691
-                {
5692
-                        strcpy(lShellName , "bash -c " ) ; /*good for basic input*/
5693
-                }
5694
-				else if ( strlen(dialogNameOnly()) || whiptailPresentOnly() )
5695
+		if ( lTerminalName[0] == '*' )
5696
+		{
5697
+				if ( detectPresence( "bash" ) )
5698
 				{
5699
-						strcpy(lShellName , "sh -c " ) ; /*good enough for dialog & whiptail*/
5700
+						strcpy(lShellName , "bash -c " ) ; /*good for basic input*/
5701
 				}
5702
+								else if ( strlen(dialogNameOnly()) || whiptailPresentOnly() )
5703
+								{
5704
+												strcpy(lShellName , "sh -c " ) ; /*good enough for dialog & whiptail*/
5705
+								}
5706
+								else
5707
+								{
5708
+										strcpy(lTerminalName , "" ) ;
5709
+										return NULL ;
5710
+								}
5711
+
5712
+				if ( tfd_isDarwin() )
5713
+				{
5714
+										if ( * strcpy(lTerminalName , "/opt/X11/bin/xterm" )
5715
+					  && detectPresence( lTerminalName ) )
5716
+						{
5717
+								strcat(lTerminalName , " -fa 'DejaVu Sans Mono' -fs 10 -title tinyfiledialogs -e " ) ;
5718
+								strcat(lTerminalName , lShellName ) ;
5719
+						}
5720
+						else
5721
+						{
5722
+								strcpy(lTerminalName , "" ) ;
5723
+						}
5724
+				}
5725
+				else if ( * strcpy(lTerminalName,"xterm") /*good (small without parameters)*/
5726
+						&& detectPresence(lTerminalName) )
5727
+				{
5728
+						strcat(lTerminalName , " -fa 'DejaVu Sans Mono' -fs 10 -title tinyfiledialogs -e " ) ;
5729
+						strcat(lTerminalName , lShellName ) ;
5730
+				}
5731
+				else if ( * strcpy(lTerminalName,"terminator") /*good*/
5732
+						  && detectPresence(lTerminalName) )
5733
+				{
5734
+						strcat(lTerminalName , " -x " ) ;
5735
+						strcat(lTerminalName , lShellName ) ;
5736
+				}
5737
+				else if ( * strcpy(lTerminalName,"lxterminal") /*good*/
5738
+						  && detectPresence(lTerminalName) )
5739
+				{
5740
+						strcat(lTerminalName , " -e " ) ;
5741
+						strcat(lTerminalName , lShellName ) ;
5742
+				}
5743
+				else if ( * strcpy(lTerminalName,"konsole") /*good*/
5744
+						  && detectPresence(lTerminalName) )
5745
+				{
5746
+						strcat(lTerminalName , " -e " ) ;
5747
+						strcat(lTerminalName , lShellName ) ;
5748
+				}
5749
+				else if ( * strcpy(lTerminalName,"kterm") /*good*/
5750
+						  && detectPresence(lTerminalName) )
5751
+				{
5752
+						strcat(lTerminalName , " -e " ) ;
5753
+						strcat(lTerminalName , lShellName ) ;
5754
+				}
5755
+				else if ( * strcpy(lTerminalName,"tilix") /*good*/
5756
+						  && detectPresence(lTerminalName) )
5757
+				{
5758
+						strcat(lTerminalName , " -e " ) ;
5759
+						strcat(lTerminalName , lShellName ) ;
5760
+				}
5761
+				else if ( * strcpy(lTerminalName,"xfce4-terminal") /*good*/
5762
+						  && detectPresence(lTerminalName) )
5763
+				{
5764
+						strcat(lTerminalName , " -x " ) ;
5765
+						strcat(lTerminalName , lShellName ) ;
5766
+				}
5767
+				else if ( * strcpy(lTerminalName,"mate-terminal") /*good*/
5768
+						  && detectPresence(lTerminalName) )
5769
+				{
5770
+						strcat(lTerminalName , " -x " ) ;
5771
+						strcat(lTerminalName , lShellName ) ;
5772
+				}
5773
+				else if ( * strcpy(lTerminalName,"Eterm") /*good*/
5774
+						  && detectPresence(lTerminalName) )
5775
+				{
5776
+						strcat(lTerminalName , " -e " ) ;
5777
+						strcat(lTerminalName , lShellName ) ;
5778
+				}
5779
+				else if ( * strcpy(lTerminalName,"evilvte") /*good*/
5780
+						  && detectPresence(lTerminalName) )
5781
+				{
5782
+						strcat(lTerminalName , " -e " ) ;
5783
+						strcat(lTerminalName , lShellName ) ;
5784
+				}
5785
+				else if ( * strcpy(lTerminalName,"pterm") /*good (only letters)*/
5786
+						  && detectPresence(lTerminalName) )
5787
+				{
5788
+						strcat(lTerminalName , " -e " ) ;
5789
+						strcat(lTerminalName , lShellName ) ;
5790
+				}
5791
+								else if ( * strcpy(lTerminalName,"gnome-terminal")
5792
+				&& detectPresence(lTerminalName) && (lArray = getMajorMinorPatch(lTerminalName))
5793
+								&& ((lArray[0]<3) || (lArray[0]==3 && lArray[1]<=6)) )
5794
+				{
5795
+						strcat(lTerminalName , " --disable-factory -x " ) ;
5796
+						strcat(lTerminalName , lShellName ) ;
5797
+				}
5798
 				else
5799
 				{
5800
-					strcpy(lTerminalName , "" ) ;
5801
-					return NULL ;
5802
+						strcpy(lTerminalName , "" ) ;
5803
 				}
5804
-
5805
-                if ( tfd_isDarwin() )
5806
-                {
5807
-					if ( * strcpy(lTerminalName , "/opt/X11/bin/xterm" )
5808
-                      && detectPresence( lTerminalName ) )
5809
-                        {
5810
-                                strcat(lTerminalName , " -fa 'DejaVu Sans Mono' -fs 10 -title tinyfiledialogs -e " ) ;
5811
-                                strcat(lTerminalName , lShellName ) ;
5812
-                        }
5813
-                        else
5814
-                        {
5815
-                                strcpy(lTerminalName , "" ) ;
5816
-                        }
5817
-                }
5818
-                else if ( * strcpy(lTerminalName,"xterm") /*good (small without parameters)*/
5819
-                        && detectPresence(lTerminalName) )
5820
-                {
5821
-                        strcat(lTerminalName , " -fa 'DejaVu Sans Mono' -fs 10 -title tinyfiledialogs -e " ) ;
5822
-                        strcat(lTerminalName , lShellName ) ;
5823
-                }
5824
-                else if ( * strcpy(lTerminalName,"terminator") /*good*/
5825
-                          && detectPresence(lTerminalName) )
5826
-                {
5827
-                        strcat(lTerminalName , " -x " ) ;
5828
-                        strcat(lTerminalName , lShellName ) ;
5829
-                }
5830
-                else if ( * strcpy(lTerminalName,"lxterminal") /*good*/
5831
-                          && detectPresence(lTerminalName) )
5832
-                {
5833
-                        strcat(lTerminalName , " -e " ) ;
5834
-                        strcat(lTerminalName , lShellName ) ;
5835
-                }
5836
-                else if ( * strcpy(lTerminalName,"konsole") /*good*/
5837
-                          && detectPresence(lTerminalName) )
5838
-                {
5839
-                        strcat(lTerminalName , " -e " ) ;
5840
-                        strcat(lTerminalName , lShellName ) ;
5841
-                }
5842
-                else if ( * strcpy(lTerminalName,"kterm") /*good*/
5843
-                          && detectPresence(lTerminalName) )
5844
-                {
5845
-                        strcat(lTerminalName , " -e " ) ;
5846
-                        strcat(lTerminalName , lShellName ) ;
5847
-                }
5848
-                else if ( * strcpy(lTerminalName,"tilix") /*good*/
5849
-                          && detectPresence(lTerminalName) )
5850
-                {
5851
-                        strcat(lTerminalName , " -e " ) ;
5852
-                        strcat(lTerminalName , lShellName ) ;
5853
-                }
5854
-                else if ( * strcpy(lTerminalName,"xfce4-terminal") /*good*/
5855
-                          && detectPresence(lTerminalName) )
5856
-                {
5857
-                        strcat(lTerminalName , " -x " ) ;
5858
-                        strcat(lTerminalName , lShellName ) ;
5859
-                }
5860
-                else if ( * strcpy(lTerminalName,"mate-terminal") /*good*/
5861
-                          && detectPresence(lTerminalName) )
5862
-                {
5863
-                        strcat(lTerminalName , " -x " ) ;
5864
-                        strcat(lTerminalName , lShellName ) ;
5865
-                }
5866
-                else if ( * strcpy(lTerminalName,"Eterm") /*good*/
5867
-                          && detectPresence(lTerminalName) )
5868
-                {
5869
-                        strcat(lTerminalName , " -e " ) ;
5870
-                        strcat(lTerminalName , lShellName ) ;
5871
-                }
5872
-                else if ( * strcpy(lTerminalName,"evilvte") /*good*/
5873
-                          && detectPresence(lTerminalName) )
5874
-                {
5875
-                        strcat(lTerminalName , " -e " ) ;
5876
-                        strcat(lTerminalName , lShellName ) ;
5877
-                }
5878
-                else if ( * strcpy(lTerminalName,"pterm") /*good (only letters)*/
5879
-                          && detectPresence(lTerminalName) )
5880
-                {
5881
-                        strcat(lTerminalName , " -e " ) ;
5882
-                        strcat(lTerminalName , lShellName ) ;
5883
-                }
5884
-				else if ( * strcpy(lTerminalName,"gnome-terminal")
5885
-                && detectPresence(lTerminalName) && (lArray = getMajorMinorPatch(lTerminalName))
5886
-				&& ((lArray[0]<3) || (lArray[0]==3 && lArray[1]<=6)) )
5887
-                {
5888
-                        strcat(lTerminalName , " --disable-factory -x " ) ;
5889
-                        strcat(lTerminalName , lShellName ) ;
5890
-                }
5891
-                else
5892
-                {
5893
-                        strcpy(lTerminalName , "" ) ;
5894
-                }
5895
-                /* bad: koi rxterm guake tilda vala-terminal qterminal
5896
-                aterm Terminal terminology sakura lilyterm weston-terminal
5897
-                roxterm termit xvt rxvt mrxvt urxvt */
5898
-        }
5899
-        if ( strlen(lTerminalName) )
5900
-        {
5901
-                return lTerminalName ;
5902
-        }
5903
-        else
5904
-        {
5905
-                return NULL ;
5906
-        }
5907
+				/* bad: koi rxterm guake tilda vala-terminal qterminal kgx
5908
+				aterm Terminal terminology sakura lilyterm weston-terminal
5909
+				roxterm termit xvt rxvt mrxvt urxvt */
5910
+		}
5911
+		if ( strlen(lTerminalName) )
5912
+		{
5913
+				return lTerminalName ;
5914
+		}
5915
+		else
5916
+		{
5917
+				return NULL ;
5918
+		}
5919
 }
5920
 
5921
 
5922
 static char * dialogName(void)
5923
 {
5924
-    char * lDialogName ;
5925
-    lDialogName = dialogNameOnly( ) ;
5926
-        if ( strlen(lDialogName) && ( isTerminalRunning() || terminalName() ) )
5927
-        {
5928
-                return lDialogName ;
5929
-        }
5930
-        else
5931
-        {
5932
-                return NULL ;
5933
-        }
5934
+	char * lDialogName ;
5935
+	lDialogName = dialogNameOnly( ) ;
5936
+		if ( strlen(lDialogName) && ( isTerminalRunning() || terminalName() ) )
5937
+		{
5938
+				return lDialogName ;
5939
+		}
5940
+		else
5941
+		{
5942
+				return NULL ;
5943
+		}
5944
 }
5945
 
5946
 
5947
 static int whiptailPresent(void)
5948
 {
5949
-        int lWhiptailPresent ;
5950
-    lWhiptailPresent = whiptailPresentOnly( ) ;
5951
-        if ( lWhiptailPresent && ( isTerminalRunning() || terminalName() ) )
5952
-        {
5953
-                return lWhiptailPresent ;
5954
-        }
5955
-        else
5956
-        {
5957
-                return 0 ;
5958
-        }
5959
+		int lWhiptailPresent ;
5960
+	lWhiptailPresent = whiptailPresentOnly( ) ;
5961
+		if ( lWhiptailPresent && ( isTerminalRunning() || terminalName() ) )
5962
+		{
5963
+				return lWhiptailPresent ;
5964
+		}
5965
+		else
5966
+		{
5967
+				return 0 ;
5968
+		}
5969
 }
5970
 
5971
 
5972
 
5973
 static int graphicMode(void)
5974
 {
5975
-        return !( tinyfd_forceConsole && (isTerminalRunning() || terminalName()) )
5976
-			&& ( getenvDISPLAY()
5977
-			|| (tfd_isDarwin() && (!getenv("SSH_TTY") || getenvDISPLAY() ) ) ) ;
5978
+		return !( tinyfd_forceConsole && (isTerminalRunning() || terminalName()) )
5979
+						&& ( getenvDISPLAY()
5980
+						|| (tfd_isDarwin() && (!getenv("SSH_TTY") || getenvDISPLAY() ) ) ) ;
5981
 }
5982
 
5983
 
5984
-static int pactlPresent(void)
5985
+static int ffplayPresent(void)
5986
 {
5987
-        static int lPactlPresent = -1 ;
5988
-        if ( lPactlPresent < 0 )
5989
-        {
5990
-                lPactlPresent = detectPresence("pactl") ;
5991
-        }
5992
-        return lPactlPresent ;
5993
+   static int lFFplayPresent = -1;
5994
+   if (lFFplayPresent < 0)
5995
+   {
5996
+	  lFFplayPresent = detectPresence("ffplay");
5997
+   }
5998
+   return lFFplayPresent;
5999
 }
6000
 
6001
 
6002
+static int pactlPresent( void )
6003
+{
6004
+	static int lPactlPresent = -1 ;
6005
+	char lBuff [256] ;
6006
+	FILE * lIn ;
6007
+
6008
+	if ( lPactlPresent < 0 )
6009
+	{
6010
+		lPactlPresent = detectPresence("pactl") ;
6011
+		if ( lPactlPresent )
6012
+		{
6013
+			lIn = popen( "pactl info | grep -iF pulseaudio" , "r" ) ;
6014
+			if ( ! (fgets( lBuff , sizeof( lBuff ) , lIn ) && ! strstr(lBuff, "PipeWire") ) )
6015
+			{
6016
+				lPactlPresent = 0 ;
6017
+			}
6018
+			pclose( lIn ) ;
6019
+			if (tinyfd_verbose) printf("is pactl valid ? %d\n", lPactlPresent);
6020
+		}
6021
+	}
6022
+	return lPactlPresent ;
6023
+}
6024
+
6025
+
6026
 static int speakertestPresent(void)
6027
 {
6028
-        static int lSpeakertestPresent = -1 ;
6029
-        if ( lSpeakertestPresent < 0 )
6030
-        {
6031
-                lSpeakertestPresent = detectPresence("speaker-test") ;
6032
-        }
6033
-        return lSpeakertestPresent ;
6034
+		static int lSpeakertestPresent = -1 ;
6035
+		if ( lSpeakertestPresent < 0 )
6036
+		{
6037
+				lSpeakertestPresent = detectPresence("speaker-test") ;
6038
+		}
6039
+		return lSpeakertestPresent ;
6040
 }
6041
 
6042
 
6043
-static int playPresent()
6044
+static int playPresent(void) /* play is part of sox */
6045
 {
6046
    static int lPlayPresent = -1;
6047
    if (lPlayPresent < 0)
6048
    {
6049
-      lPlayPresent = detectPresence("sox"); /*if sox is present, play is ready*/
6050
+	  lPlayPresent = detectPresence("sox"); /*if sox is present, play is ready*/
6051
    }
6052
    return lPlayPresent;
6053
 }
6054
 
6055
 
6056
-static int beepexePresent()
6057
+static int beepexePresent(void)
6058
 {
6059
    static int lBeepexePresent = -1;
6060
    if (lBeepexePresent < 0)
6061
    {
6062
-      lBeepexePresent = detectPresence("beep.exe");
6063
+	  lBeepexePresent = detectPresence("beep.exe");
6064
    }
6065
    return lBeepexePresent;
6066
 }
6067
 
6068
 
6069
-static int beepPresent(void)
6070
+/*static int beepPresent(void)
6071
 {
6072
-        static int lBeepPresent = -1 ;
6073
-        if ( lBeepPresent < 0 )
6074
+		static int lBeepPresent = -1 ;
6075
+		if ( lBeepPresent < 0 )
6076
+		{
6077
+				lBeepPresent = detectPresence("beep") ;
6078
+		}
6079
+		return lBeepPresent ;
6080
+}*/
6081
+
6082
+
6083
+static int playsoundPresent(void) /* playsound is part of pipewire */
6084
+{
6085
+    static int lPlaysoundPresent = -1 ;
6086
+    if (lPlaysoundPresent < 0)
6087
+    {
6088
+        lPlaysoundPresent = detectPresence("playsound_simple");
6089
+        if ( lPlaysoundPresent && ! fileExists("/usr/share/sounds/freedesktop/stereo/bell.oga") )
6090
         {
6091
-                lBeepPresent = detectPresence("beep") ;
6092
+            lPlaysoundPresent = 0 ;
6093
         }
6094
-        return lBeepPresent ;
6095
+    }
6096
+    return lPlaysoundPresent;
6097
 }
6098
 
6099
 
6100
-static int xmessagePresent(void)
6101
+static int paplayPresent(void) /* playsound is part of pipewire */
6102
 {
6103
-        static int lXmessagePresent = -1 ;
6104
-        if ( lXmessagePresent < 0 )
6105
+    static int lPaplayPresent = -1 ;
6106
+    if (lPaplayPresent < 0)
6107
+    {
6108
+        lPaplayPresent = detectPresence("paplay");
6109
+        if ( lPaplayPresent && ! fileExists("/usr/share/sounds/freedesktop/stereo/bell.oga") )
6110
         {
6111
-                lXmessagePresent = detectPresence("xmessage");/*if not tty,not on osxpath*/
6112
+            lPaplayPresent = 0 ;
6113
         }
6114
-        return lXmessagePresent && graphicMode( ) ;
6115
+    }
6116
+    return lPaplayPresent;
6117
 }
6118
 
6119
 
6120
+static int xmessagePresent(void)
6121
+{
6122
+		static int lXmessagePresent = -1 ;
6123
+		if ( lXmessagePresent < 0 )
6124
+		{
6125
+				lXmessagePresent = detectPresence("xmessage");/*if not tty,not on osxpath*/
6126
+		}
6127
+		return lXmessagePresent && graphicMode( ) ;
6128
+}
6129
+
6130
+
6131
 static int gxmessagePresent(void)
6132
 {
6133
-    static int lGxmessagePresent = -1 ;
6134
-    if ( lGxmessagePresent < 0 )
6135
-    {
6136
-        lGxmessagePresent = detectPresence("gxmessage") ;
6137
-    }
6138
-    return lGxmessagePresent && graphicMode( ) ;
6139
+	static int lGxmessagePresent = -1 ;
6140
+	if ( lGxmessagePresent < 0 )
6141
+	{
6142
+		lGxmessagePresent = detectPresence("gxmessage") ;
6143
+	}
6144
+	return lGxmessagePresent && graphicMode( ) ;
6145
 }
6146
 
6147
 
6148
 static int gmessagePresent(void)
6149
 {
6150
-        static int lGmessagePresent = -1 ;
6151
-        if ( lGmessagePresent < 0 )
6152
-        {
6153
-                lGmessagePresent = detectPresence("gmessage") ;
6154
-        }
6155
-        return lGmessagePresent && graphicMode( ) ;
6156
+		static int lGmessagePresent = -1 ;
6157
+		if ( lGmessagePresent < 0 )
6158
+		{
6159
+				lGmessagePresent = detectPresence("gmessage") ;
6160
+		}
6161
+		return lGmessagePresent && graphicMode( ) ;
6162
 }
6163
 
6164
 
6165
 static int notifysendPresent(void)
6166
 {
6167
-    static int lNotifysendPresent = -1 ;
6168
-    if ( lNotifysendPresent < 0 )
6169
-    {
6170
-        lNotifysendPresent = detectPresence("notify-send") ;
6171
-    }
6172
-    return lNotifysendPresent && graphicMode( ) ;
6173
+	static int lNotifysendPresent = -1 ;
6174
+	if ( lNotifysendPresent < 0 )
6175
+	{
6176
+		lNotifysendPresent = detectPresence("notify-send") ;
6177
+	}
6178
+	return lNotifysendPresent && graphicMode( ) ;
6179
 }
6180
 
6181
 
6182
@@ -3708,17 +3812,17 @@
6183
 
6184
    if ( lPerlPresent < 0 )
6185
    {
6186
-      lPerlPresent = detectPresence("perl") ;
6187
-      if (lPerlPresent)
6188
-      {
6189
-         lIn = popen("perl -MNet::DBus -e \"Net::DBus->session->get_service('org.freedesktop.Notifications')\" 2>&1", "r");
6190
-         if (fgets(lBuff, sizeof(lBuff), lIn) == NULL)
6191
-         {
6192
-            lPerlPresent = 2;
6193
-         }
6194
-         pclose(lIn);
6195
-         if (tinyfd_verbose) printf("perl-dbus %d\n", lPerlPresent);
6196
-      }
6197
+	  lPerlPresent = detectPresence("perl") ;
6198
+	  if (lPerlPresent)
6199
+	  {
6200
+		 lIn = popen("perl -MNet::DBus -e \"Net::DBus->session->get_service('org.freedesktop.Notifications')\" 2>&1", "r");
6201
+		 if (fgets(lBuff, sizeof(lBuff), lIn) == NULL)
6202
+		 {
6203
+			lPerlPresent = 2;
6204
+		 }
6205
+		 pclose(lIn);
6206
+		 if (tinyfd_verbose) printf("perl-dbus %d\n", lPerlPresent);
6207
+	  }
6208
    }
6209
    return graphicMode() ? lPerlPresent : 0 ;
6210
 }
6211
@@ -3726,114 +3830,181 @@
6212
 
6213
 static int afplayPresent(void)
6214
 {
6215
-        static int lAfplayPresent = -1 ;
6216
-        char lBuff[MAX_PATH_OR_CMD] ;
6217
-        FILE * lIn ;
6218
+		static int lAfplayPresent = -1 ;
6219
+		char lBuff[MAX_PATH_OR_CMD] ;
6220
+		FILE * lIn ;
6221
 
6222
-        if ( lAfplayPresent < 0 )
6223
-        {
6224
-                lAfplayPresent = detectPresence("afplay") ;
6225
-                if ( lAfplayPresent )
6226
-                {
6227
-                        lIn = popen( "test -e /System/Library/Sounds/Ping.aiff || echo Ping" , "r" ) ;
6228
-                        if ( fgets( lBuff , sizeof( lBuff ) , lIn ) == NULL )
6229
-                        {
6230
-                                lAfplayPresent = 2 ;
6231
-                        }
6232
-                        pclose( lIn ) ;
6233
-                        if (tinyfd_verbose) printf("afplay %d\n", lAfplayPresent);
6234
-                }
6235
-        }
6236
-        return graphicMode() ? lAfplayPresent : 0 ;
6237
+		if ( lAfplayPresent < 0 )
6238
+		{
6239
+				lAfplayPresent = detectPresence("afplay") ;
6240
+				if ( lAfplayPresent )
6241
+				{
6242
+						lIn = popen( "test -e /System/Library/Sounds/Ping.aiff || echo Ping" , "r" ) ;
6243
+						if ( fgets( lBuff , sizeof( lBuff ) , lIn ) == NULL )
6244
+						{
6245
+								lAfplayPresent = 2 ;
6246
+						}
6247
+						pclose( lIn ) ;
6248
+						if (tinyfd_verbose) printf("afplay %d\n", lAfplayPresent);
6249
+				}
6250
+		}
6251
+		return graphicMode() ? lAfplayPresent : 0 ;
6252
 }
6253
 
6254
 
6255
 static int xdialogPresent(void)
6256
 {
6257
-    static int lXdialogPresent = -1 ;
6258
-    if ( lXdialogPresent < 0 )
6259
-    {
6260
-        lXdialogPresent = detectPresence("Xdialog") ;
6261
-    }
6262
-    return lXdialogPresent && graphicMode( ) ;
6263
+	static int lXdialogPresent = -1 ;
6264
+	if ( lXdialogPresent < 0 )
6265
+	{
6266
+		lXdialogPresent = detectPresence("Xdialog") ;
6267
+	}
6268
+	return lXdialogPresent && graphicMode( ) ;
6269
 }
6270
 
6271
 
6272
 static int gdialogPresent(void)
6273
 {
6274
-    static int lGdialoglPresent = -1 ;
6275
-    if ( lGdialoglPresent < 0 )
6276
-    {
6277
-        lGdialoglPresent = detectPresence( "gdialog" ) ;
6278
-    }
6279
-    return lGdialoglPresent && graphicMode( ) ;
6280
+	static int lGdialoglPresent = -1 ;
6281
+	if ( lGdialoglPresent < 0 )
6282
+	{
6283
+		lGdialoglPresent = detectPresence( "gdialog" ) ;
6284
+	}
6285
+	return lGdialoglPresent && graphicMode( ) ;
6286
 }
6287
 
6288
 
6289
 static int osascriptPresent(void)
6290
 {
6291
-    static int lOsascriptPresent = -1 ;
6292
-    if ( lOsascriptPresent < 0 )
6293
-    {
6294
-                gWarningDisplayed |= !!getenv("SSH_TTY");
6295
-                lOsascriptPresent = detectPresence( "osascript" ) ;
6296
-    }
6297
-        return lOsascriptPresent && graphicMode() && !getenv("SSH_TTY") ;
6298
+	static int lOsascriptPresent = -1 ;
6299
+	if ( lOsascriptPresent < 0 )
6300
+	{
6301
+				gWarningDisplayed |= !!getenv("SSH_TTY");
6302
+				lOsascriptPresent = detectPresence( "osascript" ) ;
6303
+	}
6304
+		return lOsascriptPresent && graphicMode() && !getenv("SSH_TTY") ;
6305
 }
6306
 
6307
 
6308
+static int dunstifyPresent(void)
6309
+{
6310
+	static int lDunstifyPresent = -1 ;
6311
+		static char lBuff[MAX_PATH_OR_CMD] ;
6312
+		FILE * lIn ;
6313
+		char * lTmp ;
6314
+
6315
+	if ( lDunstifyPresent < 0 )
6316
+	{
6317
+		lDunstifyPresent = detectPresence( "dunstify" ) ;
6318
+		if ( lDunstifyPresent )
6319
+		{
6320
+			lIn = popen( "dunstify -s" , "r" ) ;
6321
+			lTmp = fgets( lBuff , sizeof( lBuff ) , lIn ) ;
6322
+			pclose( lIn ) ;
6323
+			/* printf("lTmp:%s\n", lTmp); */
6324
+			lDunstifyPresent = strstr(lTmp,"name:dunst\n") ? 1 : 0 ;
6325
+			if (tinyfd_verbose) printf("lDunstifyPresent %d\n", lDunstifyPresent);
6326
+		}
6327
+	}
6328
+	return lDunstifyPresent && graphicMode( ) ;
6329
+}
6330
+
6331
+
6332
+static int dunstPresent(void)
6333
+{
6334
+	static int lDunstPresent = -1 ;
6335
+		static char lBuff[MAX_PATH_OR_CMD] ;
6336
+		FILE * lIn ;
6337
+		char * lTmp ;
6338
+
6339
+	if ( lDunstPresent < 0 )
6340
+	{
6341
+		lDunstPresent = detectPresence( "dunst" ) ;
6342
+		if ( lDunstPresent )
6343
+		{
6344
+			lIn = popen( "ps -e | grep dunst | grep -v grep" , "r" ) ; /* add "| wc -l" to receive the number of lines */
6345
+			lTmp = fgets( lBuff , sizeof( lBuff ) , lIn ) ;
6346
+			pclose( lIn ) ;
6347
+			/* if ( lTmp ) printf("lTmp:%s\n", lTmp); */
6348
+			if ( lTmp ) lDunstPresent = 1 ;
6349
+			else lDunstPresent = 0 ;
6350
+			if (tinyfd_verbose) printf("lDunstPresent %d\n", lDunstPresent);
6351
+		}
6352
+	}
6353
+	return lDunstPresent && graphicMode( ) ;
6354
+}
6355
+
6356
+
6357
 int tfd_qarmaPresent(void)
6358
 {
6359
-        static int lQarmaPresent = -1 ;
6360
-        if ( lQarmaPresent < 0 )
6361
-        {
6362
-                lQarmaPresent = detectPresence("qarma") ;
6363
-        }
6364
-        return lQarmaPresent && graphicMode( ) ;
6365
+		static int lQarmaPresent = -1 ;
6366
+		if ( lQarmaPresent < 0 )
6367
+		{
6368
+				lQarmaPresent = detectPresence("qarma") ;
6369
+		}
6370
+		return lQarmaPresent && graphicMode( ) ;
6371
 }
6372
 
6373
 
6374
 int tfd_matedialogPresent(void)
6375
 {
6376
-        static int lMatedialogPresent = -1 ;
6377
-        if ( lMatedialogPresent < 0 )
6378
-        {
6379
-                lMatedialogPresent = detectPresence("matedialog") ;
6380
-        }
6381
-        return lMatedialogPresent && graphicMode( ) ;
6382
+		static int lMatedialogPresent = -1 ;
6383
+		if ( lMatedialogPresent < 0 )
6384
+		{
6385
+				lMatedialogPresent = detectPresence("matedialog") ;
6386
+		}
6387
+		return lMatedialogPresent && graphicMode( ) ;
6388
 }
6389
 
6390
 
6391
 int tfd_shellementaryPresent(void)
6392
 {
6393
-        static int lShellementaryPresent = -1 ;
6394
-        if ( lShellementaryPresent < 0 )
6395
-        {
6396
-                lShellementaryPresent = 0 ; /*detectPresence("shellementary"); shellementary is not ready yet */
6397
-        }
6398
-        return lShellementaryPresent && graphicMode( ) ;
6399
+		static int lShellementaryPresent = -1 ;
6400
+		if ( lShellementaryPresent < 0 )
6401
+		{
6402
+				lShellementaryPresent = 0 ; /*detectPresence("shellementary"); shellementary is not ready yet */
6403
+		}
6404
+		return lShellementaryPresent && graphicMode( ) ;
6405
 }
6406
 
6407
 
6408
 int tfd_xpropPresent(void)
6409
 {
6410
-	static int lXpropPresent = -1 ;
6411
-	if ( lXpropPresent < 0 )
6412
+	static int lXpropReady = 0 ;
6413
+	static int lXpropDetected = -1 ;
6414
+	char lBuff[MAX_PATH_OR_CMD] ;
6415
+	FILE * lIn ;
6416
+
6417
+	if ( lXpropDetected < 0 )
6418
 	{
6419
-		lXpropPresent = detectPresence("xprop") ;
6420
+		lXpropDetected = detectPresence("xprop") ;
6421
 	}
6422
-	return lXpropPresent && graphicMode( ) ;
6423
+
6424
+	if ( !lXpropReady && lXpropDetected )
6425
+	{	/* xwayland Debian issue reported by Kay F. Jahnke and solved with his help */
6426
+		lIn = popen( "xprop -root 32x '	$0' _NET_ACTIVE_WINDOW" , "r" ) ;
6427
+		if ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
6428
+		{
6429
+			if ( ! strstr( lBuff , "not found" ) )
6430
+			{
6431
+				if (tinyfd_verbose) printf("xprop is ready\n");
6432
+				lXpropReady = 1 ;
6433
+			}
6434
+		}
6435
+		pclose( lIn ) ;
6436
+	}
6437
+	return graphicMode() ? lXpropReady : 0 ;
6438
 }
6439
 
6440
 
6441
 int tfd_zenityPresent(void)
6442
 {
6443
-        static int lZenityPresent = -1 ;
6444
-        if ( lZenityPresent < 0 )
6445
-        {
6446
-                lZenityPresent = detectPresence("zenity") ;
6447
-        }
6448
-        return lZenityPresent && graphicMode( ) ;
6449
+		static int lZenityPresent = -1 ;
6450
+		if ( lZenityPresent < 0 )
6451
+		{
6452
+				lZenityPresent = detectPresence("zenity") ;
6453
+		}
6454
+		return lZenityPresent && graphicMode( ) ;
6455
 }
6456
 
6457
 
6458
@@ -3842,7 +4013,7 @@
6459
    static int lYadPresent = -1;
6460
    if (lYadPresent < 0)
6461
    {
6462
-      lYadPresent = detectPresence("yad");
6463
+	  lYadPresent = detectPresence("yad");
6464
    }
6465
    return lYadPresent && graphicMode();
6466
 }
6467
@@ -3850,1428 +4021,1422 @@
6468
 
6469
 int tfd_zenity3Present(void)
6470
 {
6471
-        static int lZenity3Present = -1 ;
6472
-        char lBuff[MAX_PATH_OR_CMD] ;
6473
-        FILE * lIn ;
6474
-		int lIntTmp ;
6475
+		static int lZenity3Present = -1 ;
6476
+		char lBuff[MAX_PATH_OR_CMD] ;
6477
+		FILE * lIn ;
6478
+				int lIntTmp ;
6479
 
6480
-        if ( lZenity3Present < 0 )
6481
-        {
6482
-                lZenity3Present = 0 ;
6483
-                if ( tfd_zenityPresent() )
6484
-                {
6485
-                        lIn = popen( "zenity --version" , "r" ) ;
6486
-                        if ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
6487
-                        {
6488
-                                if ( atoi(lBuff) >= 3 )
6489
-                                {
6490
-                                        lZenity3Present = 3 ;
6491
-										lIntTmp = atoi(strtok(lBuff,".")+2 ) ;
6492
-										if ( lIntTmp >= 18 )
6493
-										{
6494
+		if ( lZenity3Present < 0 )
6495
+		{
6496
+				lZenity3Present = 0 ;
6497
+				if ( tfd_zenityPresent() )
6498
+				{
6499
+						lIn = popen( "zenity --version" , "r" ) ;
6500
+						if ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
6501
+						{
6502
+								if ( atoi(lBuff) >= 3 )
6503
+								{
6504
+									lZenity3Present = 3 ;
6505
+									lIntTmp = atoi(strtok(lBuff,".")+2 ) ;
6506
+									if ( lIntTmp >= 18 )
6507
+									{
6508
 											lZenity3Present = 5 ;
6509
-										}
6510
-										else if ( lIntTmp >= 10 )
6511
-										{
6512
+									}
6513
+									else if ( lIntTmp >= 10 )
6514
+									{
6515
 											lZenity3Present = 4 ;
6516
-										}
6517
+									}
6518
+																}
6519
+								else if ( ( atoi(lBuff) == 2 ) && ( atoi(strtok(lBuff,".")+2 ) >= 32 ) )
6520
+								{
6521
+										lZenity3Present = 2 ;
6522
 								}
6523
-                                else if ( ( atoi(lBuff) == 2 ) && ( atoi(strtok(lBuff,".")+2 ) >= 32 ) )
6524
-                                {
6525
-                                        lZenity3Present = 2 ;
6526
-                                }
6527
-                                if (tinyfd_verbose) printf("zenity type %d\n", lZenity3Present);
6528
-                        }
6529
-                        pclose( lIn ) ;
6530
-                }
6531
-        }
6532
-        return graphicMode() ? lZenity3Present : 0 ;
6533
+								if (tinyfd_verbose) printf("zenity type %d\n", lZenity3Present);
6534
+						}
6535
+						pclose( lIn ) ;
6536
+				}
6537
+		}
6538
+		return graphicMode() ? lZenity3Present : 0 ;
6539
 }
6540
 
6541
 
6542
 int tfd_kdialogPresent(void)
6543
 {
6544
-	static int lKdialogPresent = -1 ;
6545
-	char lBuff[MAX_PATH_OR_CMD] ;
6546
-	FILE * lIn ;
6547
-	char * lDesktop;
6548
+    static int lKdialogPresent = -1 ;
6549
+    char lBuff[MAX_PATH_OR_CMD] ;
6550
+    FILE * lIn ;
6551
+    char * lDesktop;
6552
 
6553
-	if ( lKdialogPresent < 0 )
6554
-	{
6555
-		if ( tfd_zenityPresent() )
6556
-		{
6557
-			lDesktop = getenv("XDG_SESSION_DESKTOP");
6558
-			if ( !lDesktop  || ( strcmp(lDesktop, "KDE") && strcmp(lDesktop, "lxqt") ) )
6559
-			{
6560
-				lKdialogPresent = 0 ;
6561
-				return lKdialogPresent ;
6562
-			}
6563
-		}
6564
+    if ( lKdialogPresent < 0 )
6565
+    {
6566
+        lDesktop = getenv("XDG_SESSION_DESKTOP");
6567
+        if ( !lDesktop  || ( strcmp(lDesktop, "KDE") && strcmp(lDesktop, "lxqt") ) )
6568
+        {
6569
+            if ( tfd_zenityPresent() )
6570
+            {
6571
+                lKdialogPresent = 0 ;
6572
+                return lKdialogPresent ;
6573
+            }
6574
+        }
6575
 
6576
-		lKdialogPresent = detectPresence("kdialog") ;
6577
-		if ( lKdialogPresent && !getenv("SSH_TTY") )
6578
-		{
6579
-			lIn = popen( "kdialog --attach 2>&1" , "r" ) ;
6580
-			if ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
6581
-			{
6582
-				if ( ! strstr( "Unknown" , lBuff ) )
6583
-				{
6584
-					lKdialogPresent = 2 ;
6585
-					if (tinyfd_verbose) printf("kdialog-attach %d\n", lKdialogPresent);
6586
-				}
6587
-			}
6588
-			pclose( lIn ) ;
6589
+        lKdialogPresent = detectPresence("kdialog") ;
6590
+        if ( lKdialogPresent && !getenv("SSH_TTY") )
6591
+        {
6592
+            lIn = popen( "kdialog --attach 2>&1" , "r" ) ;
6593
+            if ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
6594
+            {
6595
+                if ( ! strstr( "Unknown" , lBuff ) )
6596
+                {
6597
+                    lKdialogPresent = 2 ;
6598
+                    if (tinyfd_verbose) printf("kdialog-attach %d\n", lKdialogPresent);
6599
+                }
6600
+            }
6601
+            pclose( lIn ) ;
6602
 
6603
-			if (lKdialogPresent == 2)
6604
-			{
6605
-				lKdialogPresent = 1 ;
6606
-				lIn = popen( "kdialog --passivepopup 2>&1" , "r" ) ;
6607
-				if ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
6608
-				{
6609
-					if ( ! strstr( "Unknown" , lBuff ) )
6610
-					{
6611
-						lKdialogPresent = 2 ;
6612
-						if (tinyfd_verbose) printf("kdialog-popup %d\n", lKdialogPresent);
6613
-					}
6614
-				}
6615
-				pclose( lIn ) ;
6616
-			}
6617
-		}
6618
-	}
6619
-	return graphicMode() ? lKdialogPresent : 0 ;
6620
+            if (lKdialogPresent == 2)
6621
+            {
6622
+                lKdialogPresent = 1 ;
6623
+                lIn = popen( "kdialog --passivepopup 2>&1" , "r" ) ;
6624
+                if ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
6625
+                {
6626
+                    if ( ! strstr( "Unknown" , lBuff ) )
6627
+                    {
6628
+                        lKdialogPresent = 2 ;
6629
+                        if (tinyfd_verbose) printf("kdialog-popup %d\n", lKdialogPresent);
6630
+                    }
6631
+                }
6632
+                pclose( lIn ) ;
6633
+            }
6634
+        }
6635
+    }
6636
+    return graphicMode() ? lKdialogPresent : 0 ;
6637
 }
6638
 
6639
 
6640
 static int osx9orBetter(void)
6641
 {
6642
-        static int lOsx9orBetter = -1 ;
6643
-        char lBuff[MAX_PATH_OR_CMD] ;
6644
-        FILE * lIn ;
6645
-        int V,v;
6646
+		static int lOsx9orBetter = -1 ;
6647
+		char lBuff[MAX_PATH_OR_CMD] ;
6648
+		FILE * lIn ;
6649
+		int V,v;
6650
 
6651
-        if ( lOsx9orBetter < 0 )
6652
-        {
6653
-                lOsx9orBetter = 0 ;
6654
-                lIn = popen( "osascript -e 'set osver to system version of (system info)'" , "r" ) ;
6655
-                if ( ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
6656
-                        && ( 2 == sscanf(lBuff, "%d.%d", &V, &v) ) )
6657
-                {
6658
-                        V = V * 100 + v;
6659
-                        if ( V >= 1009 )
6660
-                        {
6661
-                                lOsx9orBetter = 1 ;
6662
-                        }
6663
-                }
6664
-                pclose( lIn ) ;
6665
-                if (tinyfd_verbose) printf("Osx10 = %d, %d = %s\n", lOsx9orBetter, V, lBuff) ;
6666
-        }
6667
-        return lOsx9orBetter ;
6668
+		if ( lOsx9orBetter < 0 )
6669
+		{
6670
+				lOsx9orBetter = 0 ;
6671
+				lIn = popen( "osascript -e 'set osver to system version of (system info)'" , "r" ) ;
6672
+				V = 0 ;
6673
+				if ( ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
6674
+						&& ( 2 == sscanf(lBuff, "%d.%d", &V, &v) ) )
6675
+				{
6676
+						V = V * 100 + v;
6677
+						if ( V >= 1009 )
6678
+						{
6679
+								lOsx9orBetter = 1 ;
6680
+						}
6681
+				}
6682
+				pclose( lIn ) ;
6683
+				if (tinyfd_verbose) printf("Osx10 = %d, %d = %s\n", lOsx9orBetter, V, lBuff) ;
6684
+		}
6685
+		return lOsx9orBetter ;
6686
 }
6687
 
6688
 
6689
 static int python3Present(void)
6690
 {
6691
-        static int lPython3Present = -1 ;
6692
-        int i;
6693
+		static int lPython3Present = -1 ;
6694
 
6695
-        if ( lPython3Present < 0 )
6696
-        {
6697
-                lPython3Present = 0 ;
6698
-                strcpy(gPython3Name , "python3" ) ;
6699
-                if ( detectPresence(gPython3Name) ) lPython3Present = 1;
6700
-                else
6701
-                {
6702
-                        for ( i = 9 ; i >= 0 ; i -- )
6703
-                        {
6704
-                                sprintf( gPython3Name , "python3.%d" , i ) ;
6705
-                                if ( detectPresence(gPython3Name) )
6706
-                                {
6707
-                                        lPython3Present = 1;
6708
-                                        break;
6709
-                                }
6710
-                        }
6711
-                }
6712
-                if (tinyfd_verbose) printf("lPython3Present %d\n", lPython3Present) ;
6713
-                if (tinyfd_verbose) printf("gPython3Name %s\n", gPython3Name) ;
6714
-        }
6715
-		return lPython3Present ;
6716
+		if ( lPython3Present < 0 )
6717
+		{
6718
+				lPython3Present = 0 ;
6719
+				strcpy(gPython3Name , "python3" ) ;
6720
+				if ( detectPresence(gPython3Name) ) lPython3Present = 1;
6721
+				if (tinyfd_verbose) printf("lPython3Present %d\n", lPython3Present) ;
6722
+				if (tinyfd_verbose) printf("gPython3Name %s\n", gPython3Name) ;
6723
+		}
6724
+				return lPython3Present ;
6725
 }
6726
 
6727
 
6728
 static int python2Present(void)
6729
 {
6730
-	static int lPython2Present = -1 ;
6731
-	int i;
6732
+		static int lPython2Present = -1 ;
6733
 
6734
-	if ( lPython2Present < 0 )
6735
-	{
6736
-		lPython2Present = 0 ;
6737
-		strcpy(gPython2Name , "python2" ) ;
6738
-		if ( detectPresence(gPython2Name) ) lPython2Present = 1;
6739
-		else
6740
+		if ( lPython2Present < 0 )
6741
 		{
6742
-			for ( i = 9 ; i >= 0 ; i -- )
6743
-			{
6744
-				sprintf( gPython2Name , "python2.%d" , i ) ;
6745
-				if ( detectPresence(gPython2Name) )
6746
-				{
6747
-					lPython2Present = 1;
6748
-					break;
6749
-				}
6750
-			}
6751
+				lPython2Present = 0 ;
6752
+				strcpy(gPython2Name , "python2" ) ;
6753
+				if ( detectPresence(gPython2Name) ) lPython2Present = 1;
6754
+				if (tinyfd_verbose) printf("lPython2Present %d\n", lPython2Present) ;
6755
+				if (tinyfd_verbose) printf("gPython2Name %s\n", gPython2Name) ;
6756
 		}
6757
-		if (tinyfd_verbose) printf("lPython2Present %d\n", lPython2Present) ;
6758
-		if (tinyfd_verbose) printf("gPython2Name %s\n", gPython2Name) ;
6759
-	}
6760
-	return lPython2Present ;
6761
+		return lPython2Present ;
6762
 }
6763
 
6764
 
6765
 static int tkinter3Present(void)
6766
 {
6767
-        static int lTkinter3Present = -1 ;
6768
-        char lPythonCommand[256];
6769
-        char lPythonParams[128] =
6770
-                "-S -c \"try:\n\timport tkinter;\nexcept:\n\tprint(0);\"";
6771
+		static int lTkinter3Present = -1 ;
6772
+		char lPythonCommand[256];
6773
+		char lPythonParams[128] =
6774
+				"-S -c \"try:\n\timport tkinter;\nexcept:\n\tprint(0);\"";
6775
 
6776
-        if ( lTkinter3Present < 0 )
6777
-        {
6778
-                lTkinter3Present = 0 ;
6779
-                if ( python3Present() )
6780
-                {
6781
-                        sprintf( lPythonCommand , "%s %s" , gPython3Name , lPythonParams ) ;
6782
-                        lTkinter3Present = tryCommand(lPythonCommand) ;
6783
-                }
6784
-                if (tinyfd_verbose) printf("lTkinter3Present %d\n", lTkinter3Present) ;
6785
-        }
6786
-		return lTkinter3Present && graphicMode() && !(tfd_isDarwin() && getenv("SSH_TTY") );
6787
+		if ( lTkinter3Present < 0 )
6788
+		{
6789
+				lTkinter3Present = 0 ;
6790
+				if ( python3Present() )
6791
+				{
6792
+						sprintf( lPythonCommand , "%s %s" , gPython3Name , lPythonParams ) ;
6793
+						lTkinter3Present = tryCommand(lPythonCommand) ;
6794
+				}
6795
+				if (tinyfd_verbose) printf("lTkinter3Present %d\n", lTkinter3Present) ;
6796
+		}
6797
+				return lTkinter3Present && graphicMode() && !(tfd_isDarwin() && getenv("SSH_TTY") );
6798
 }
6799
 
6800
 
6801
 static int tkinter2Present(void)
6802
 {
6803
-	static int lTkinter2Present = -1 ;
6804
-	char lPythonCommand[256];
6805
-	char lPythonParams[128] =
6806
-		"-S -c \"try:\n\timport Tkinter;\nexcept:\n\tprint 0;\"";
6807
+		static int lTkinter2Present = -1 ;
6808
+		char lPythonCommand[256];
6809
+		char lPythonParams[128] =
6810
+				"-S -c \"try:\n\timport Tkinter;\nexcept:\n\tprint 0;\"";
6811
 
6812
-	if ( lTkinter2Present < 0 )
6813
-	{
6814
-		lTkinter2Present = 0 ;
6815
-		if ( python2Present() )
6816
+		if ( lTkinter2Present < 0 )
6817
 		{
6818
-			sprintf( lPythonCommand , "%s %s" , gPython2Name , lPythonParams ) ;
6819
-			lTkinter2Present = tryCommand(lPythonCommand) ;
6820
+				lTkinter2Present = 0 ;
6821
+				if ( python2Present() )
6822
+				{
6823
+						sprintf( lPythonCommand , "%s %s" , gPython2Name , lPythonParams ) ;
6824
+						lTkinter2Present = tryCommand(lPythonCommand) ;
6825
+				}
6826
+				if (tinyfd_verbose) printf("lTkinter2Present %d graphicMode %d \n", lTkinter2Present, graphicMode() ) ;
6827
 		}
6828
-		if (tinyfd_verbose) printf("lTkinter2Present %d\n", lTkinter2Present) ;
6829
-	}
6830
-	return lTkinter2Present && graphicMode() && !(tfd_isDarwin() && getenv("SSH_TTY") );
6831
+		return lTkinter2Present && graphicMode() && !(tfd_isDarwin() && getenv("SSH_TTY") );
6832
 }
6833
 
6834
 
6835
 static int pythonDbusPresent(void)
6836
 {
6837
-    static int lPythonDbusPresent = -1 ;
6838
-        char lPythonCommand[384];
6839
-        char lPythonParams[256] =
6840
+	static int lPythonDbusPresent = -1 ;
6841
+		char lPythonCommand[384];
6842
+		char lPythonParams[256] =
6843
 "-c \"try:\n\timport dbus;bus=dbus.SessionBus();\
6844
 notif=bus.get_object('org.freedesktop.Notifications','/org/freedesktop/Notifications');\
6845
 notify=dbus.Interface(notif,'org.freedesktop.Notifications');\nexcept:\n\tprint(0);\"";
6846
 
6847
-        if (lPythonDbusPresent < 0 )
6848
-        {
6849
-           lPythonDbusPresent = 0 ;
6850
-                if ( python2Present() )
6851
-                {
6852
-                        strcpy(gPythonName , gPython2Name ) ;
6853
-                        sprintf( lPythonCommand , "%s %s" , gPythonName , lPythonParams ) ;
6854
-                        lPythonDbusPresent = tryCommand(lPythonCommand) ;
6855
-                }
6856
+		if (lPythonDbusPresent < 0 )
6857
+		{
6858
+		   lPythonDbusPresent = 0 ;
6859
+				if ( python2Present() )
6860
+				{
6861
+						strcpy(gPythonName , gPython2Name ) ;
6862
+						sprintf( lPythonCommand , "%s %s" , gPythonName , lPythonParams ) ;
6863
+						lPythonDbusPresent = tryCommand(lPythonCommand) ;
6864
+				}
6865
 
6866
-                if ( !lPythonDbusPresent && python3Present() )
6867
-                {
6868
-                        strcpy(gPythonName , gPython3Name ) ;
6869
-                        sprintf( lPythonCommand , "%s %s" , gPythonName , lPythonParams ) ;
6870
-                        lPythonDbusPresent = tryCommand(lPythonCommand) ;
6871
-                }
6872
+				if ( !lPythonDbusPresent && python3Present() )
6873
+				{
6874
+						strcpy(gPythonName , gPython3Name ) ;
6875
+						sprintf( lPythonCommand , "%s %s" , gPythonName , lPythonParams ) ;
6876
+						lPythonDbusPresent = tryCommand(lPythonCommand) ;
6877
+				}
6878
 
6879
-                if (tinyfd_verbose) printf("lPythonDbusPresent %d\n", lPythonDbusPresent) ;
6880
-                if (tinyfd_verbose) printf("gPythonName %s\n", gPythonName) ;
6881
-        }
6882
-        return lPythonDbusPresent && graphicMode() && !(tfd_isDarwin() && getenv("SSH_TTY") );
6883
+				if (tinyfd_verbose) printf("lPythonDbusPresent %d\n", lPythonDbusPresent) ;
6884
+				if (tinyfd_verbose) printf("gPythonName %s\n", gPythonName) ;
6885
+		}
6886
+		return lPythonDbusPresent && graphicMode() && !(tfd_isDarwin() && getenv("SSH_TTY") );
6887
 }
6888
 
6889
 
6890
 static void sigHandler(int signum)
6891
 {
6892
-        FILE * lIn ;
6893
-        if ( ( lIn = popen( "pactl unload-module module-sine" , "r" ) ) )
6894
-        {
6895
-                pclose( lIn ) ;
6896
-        }
6897
-		if (tinyfd_verbose) printf("tinyfiledialogs caught signal %d\n", signum);
6898
+    FILE * lIn ;
6899
+    if ( ( lIn = popen( "pactl unload-module module-sine" , "r" ) ) )
6900
+    {
6901
+        pclose( lIn ) ;
6902
+    }
6903
+    if (tinyfd_verbose) printf("tinyfiledialogs caught signal %d\n", signum);
6904
 }
6905
 
6906
+
6907
 void tinyfd_beep(void)
6908
 {
6909
-        char lDialogString[256] ;
6910
-        FILE * lIn ;
6911
+    char lDialogString[256] ;
6912
+    FILE * lIn ;
6913
 
6914
-        if ( osascriptPresent() )
6915
+    if ( pactlPresent() )
6916
+    {
6917
+        signal(SIGINT, sigHandler);
6918
+        strcpy( lDialogString ,
6919
+            "thnum=$(pactl load-module module-sine frequency=440);sleep .3;pactl unload-module $thnum" ) ;
6920
+    }
6921
+    else if ( osascriptPresent() )
6922
+    {
6923
+        if ( afplayPresent() >= 2 )
6924
         {
6925
-                if ( afplayPresent() >= 2 )
6926
-                {
6927
-                        strcpy( lDialogString , "afplay /System/Library/Sounds/Ping.aiff") ;
6928
-                }
6929
-                else
6930
-                {
6931
-                        strcpy( lDialogString , "osascript -e 'tell application \"System Events\" to beep'") ;
6932
-                }
6933
+            strcpy( lDialogString , "afplay /System/Library/Sounds/Ping.aiff") ;
6934
         }
6935
-        else if ( pactlPresent() )
6936
-        {
6937
-                signal(SIGINT, sigHandler);
6938
-                /*strcpy( lDialogString , "pactl load-module module-sine frequency=440;sleep .3;pactl unload-module module-sine" ) ;*/
6939
-                strcpy( lDialogString , "thnum=$(pactl load-module module-sine frequency=440);sleep .3;pactl unload-module $thnum" ) ;
6940
-        }
6941
-        else if ( speakertestPresent() )
6942
-        {
6943
-                /*strcpy( lDialogString , "timeout -k .3 .3 speaker-test --frequency 440 --test sine > /dev/tty" ) ;*/
6944
-                strcpy( lDialogString , "( speaker-test -t sine -f 440 > /dev/tty )& pid=$!;sleep .4; kill -9 $pid" ) ; /*.3 was too short for mac g3*/
6945
-        }
6946
-        else if (beepexePresent())
6947
-        {
6948
-                strcpy(lDialogString, "beep.exe 440 300");
6949
-        }
6950
-        else if (playPresent()) /* play is part of sox */
6951
-        {
6952
-                strcpy(lDialogString, "play -q -n synth .3 sine 440");
6953
-        }
6954
-        else if ( beepPresent() )
6955
-        {
6956
-                strcpy( lDialogString , "beep -f 440 -l 300" ) ;
6957
-        }
6958
         else
6959
         {
6960
-                strcpy( lDialogString , "printf '\a' > /dev/tty" ) ;
6961
+            strcpy( lDialogString , "osascript -e 'tell application \"System Events\" to beep'") ;
6962
         }
6963
+    }
6964
+    else if ( speakertestPresent() )
6965
+    {
6966
+        /*strcpy( lDialogString , "timeout -k .3 .3 speaker-test --frequency 440 --test sine > /dev/tty" ) ;*/
6967
+        strcpy( lDialogString , "( speaker-test -t sine -f 440 > /dev/tty )& pid=$!;sleep .5; kill -9 $pid" ) ; /*.3 was too short for mac g3*/
6968
+    }
6969
+    else if ( ffplayPresent() )
6970
+    {
6971
+        strcpy(lDialogString, "ffplay -f lavfi -i sine=f=440:d=0.15 -autoexit -nodisp" );
6972
+    }
6973
+    else if (playPresent()) /* play is part of sox */
6974
+    {
6975
+        strcpy(lDialogString, "play -q -n synth .3 sine 440");
6976
+    }
6977
+    else if ( playsoundPresent() )
6978
+    {
6979
+        strcpy( lDialogString , "playsound_simple /usr/share/sounds/freedesktop/stereo/bell.oga") ;
6980
+    }
6981
+    else if ( paplayPresent() )
6982
+    {
6983
+        strcpy( lDialogString , "paplay /usr/share/sounds/freedesktop/stereo/bell.oga") ;
6984
+    }
6985
+    else if (beepexePresent())
6986
+    {
6987
+        strcpy(lDialogString, "beep.exe 440 300");
6988
+    }
6989
+    /*else if ( beepPresent() )
6990
+    {
6991
+        strcpy( lDialogString , "beep -f 440 -l 300" ) ;
6992
+    }*/
6993
+    else
6994
+    {
6995
+        strcpy( lDialogString , "printf '\\a' > /dev/tty" ) ;
6996
+    }
6997
 
6998
-        if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
6999
+    if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
7000
 
7001
-        if ( ( lIn = popen( lDialogString , "r" ) ) )
7002
-        {
7003
-                pclose( lIn ) ;
7004
-        }
7005
+    if ( ( lIn = popen( lDialogString , "r" ) ) )
7006
+    {
7007
+            pclose( lIn ) ;
7008
+    }
7009
 
7010
-        if ( pactlPresent() )
7011
-        {
7012
-                signal(SIGINT, SIG_DFL);
7013
-        }
7014
+    if ( pactlPresent() )
7015
+    {
7016
+            signal(SIGINT, SIG_DFL);
7017
+    }
7018
 }
7019
 
7020
 
7021
 int tinyfd_messageBox(
7022
-        char const * aTitle , /* NULL or "" */
7023
-        char const * aMessage , /* NULL or ""  may contain \n and \t */
7024
-        char const * aDialogType , /* "ok" "okcancel" "yesno" "yesnocancel" */
7025
-        char const * aIconType , /* "info" "warning" "error" "question" */
7026
-        int aDefaultButton ) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
7027
+		char const * aTitle , /* NULL or "" */
7028
+		char const * aMessage , /* NULL or ""  may contain \n and \t */
7029
+		char const * aDialogType , /* "ok" "okcancel" "yesno" "yesnocancel" */
7030
+		char const * aIconType , /* "info" "warning" "error" "question" */
7031
+		int aDefaultButton ) /* 0 for cancel/no , 1 for ok/yes , 2 for no in yesnocancel */
7032
 {
7033
-        char lBuff[MAX_PATH_OR_CMD] ;
7034
-        char * lDialogString = NULL ;
7035
-        char * lpDialogString;
7036
-        FILE * lIn ;
7037
-        int lWasGraphicDialog = 0 ;
7038
-        int lWasXterm = 0 ;
7039
-        int lResult ;
7040
-        char lChar ;
7041
-        struct termios infoOri;
7042
-        struct termios info;
7043
-        size_t lTitleLen ;
7044
-        size_t lMessageLen ;
7045
+		char lBuff[MAX_PATH_OR_CMD] ;
7046
+		char * lDialogString = NULL ;
7047
+		char * lpDialogString;
7048
+		FILE * lIn ;
7049
+		int lWasGraphicDialog = 0 ;
7050
+		int lWasXterm = 0 ;
7051
+		int lResult ;
7052
+		char lChar ;
7053
+		struct termios infoOri;
7054
+		struct termios info;
7055
+		size_t lTitleLen ;
7056
+		size_t lMessageLen ;
7057
 
7058
-        lBuff[0]='\0';
7059
+		lBuff[0]='\0';
7060
 
7061
-		if (tfd_quoteDetected(aTitle)) return tinyfd_messageBox("INVALID TITLE WITH QUOTES", aMessage, aDialogType, aIconType, aDefaultButton);
7062
-		if (tfd_quoteDetected(aMessage)) return tinyfd_messageBox(aTitle, "INVALID MESSAGE WITH QUOTES", aDialogType, aIconType, aDefaultButton);
7063
+				if (tfd_quoteDetected(aTitle)) return tinyfd_messageBox("INVALID TITLE WITH QUOTES", aMessage, aDialogType, aIconType, aDefaultButton);
7064
+				if (tfd_quoteDetected(aMessage)) return tinyfd_messageBox(aTitle, "INVALID MESSAGE WITH QUOTES", aDialogType, aIconType, aDefaultButton);
7065
 
7066
-        lTitleLen =  aTitle ? strlen(aTitle) : 0 ;
7067
-        lMessageLen =  aMessage ? strlen(aMessage) : 0 ;
7068
-        if ( !aTitle || strcmp(aTitle,"tinyfd_query") )
7069
-        {
7070
-                lDialogString = (char *) malloc( MAX_PATH_OR_CMD + lTitleLen + lMessageLen );
7071
-        }
7072
+		lTitleLen =  aTitle ? strlen(aTitle) : 0 ;
7073
+		lMessageLen =  aMessage ? strlen(aMessage) : 0 ;
7074
+		if ( !aTitle || strcmp(aTitle,"tinyfd_query") )
7075
+		{
7076
+				lDialogString = (char *) malloc( MAX_PATH_OR_CMD + lTitleLen + lMessageLen );
7077
+		}
7078
 
7079
-        if ( osascriptPresent( ) )
7080
-        {
7081
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return 1;}
7082
+		if ( osascriptPresent( ) )
7083
+		{
7084
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return 1;}
7085
 
7086
-                strcpy( lDialogString , "osascript ");
7087
-                if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
7088
-                strcat( lDialogString , " -e 'try' -e 'set {vButton} to {button returned} of ( display dialog \"") ;
7089
-                if ( aMessage && strlen(aMessage) )
7090
-                {
7091
-                        strcat(lDialogString, aMessage) ;
7092
-                }
7093
-                strcat(lDialogString, "\" ") ;
7094
-                if ( aTitle && strlen(aTitle) )
7095
-                {
7096
-                        strcat(lDialogString, "with title \"") ;
7097
-                        strcat(lDialogString, aTitle) ;
7098
-                        strcat(lDialogString, "\" ") ;
7099
-                }
7100
-                strcat(lDialogString, "with icon ") ;
7101
-                if ( aIconType && ! strcmp( "error" , aIconType ) )
7102
-                {
7103
-                        strcat(lDialogString, "stop " ) ;
7104
-                }
7105
-                else if ( aIconType && ! strcmp( "warning" , aIconType ) )
7106
-                {
7107
-                        strcat(lDialogString, "caution " ) ;
7108
-                }
7109
-                else /* question or info */
7110
-                {
7111
-                        strcat(lDialogString, "note " ) ;
7112
-                }
7113
-                if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7114
-                {
7115
-                        if ( ! aDefaultButton )
7116
-                        {
7117
-                                strcat( lDialogString ,"default button \"Cancel\" " ) ;
7118
-                        }
7119
-                }
7120
-                else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
7121
-                {
7122
-                        strcat( lDialogString ,"buttons {\"No\", \"Yes\"} " ) ;
7123
-                        if (aDefaultButton)
7124
-                        {
7125
-                                strcat( lDialogString ,"default button \"Yes\" " ) ;
7126
-                        }
7127
-                        else
7128
-                        {
7129
-                                strcat( lDialogString ,"default button \"No\" " ) ;
7130
-                        }
7131
-                        strcat( lDialogString ,"cancel button \"No\"" ) ;
7132
-                }
7133
-                else if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7134
-                {
7135
-                        strcat( lDialogString ,"buttons {\"No\", \"Yes\", \"Cancel\"} " ) ;
7136
-                        switch (aDefaultButton)
7137
-                        {
7138
-                                case 1: strcat( lDialogString ,"default button \"Yes\" " ) ; break;
7139
-                                case 2: strcat( lDialogString ,"default button \"No\" " ) ; break;
7140
-                                case 0: strcat( lDialogString ,"default button \"Cancel\" " ) ; break;
7141
-                        }
7142
-                        strcat( lDialogString ,"cancel button \"Cancel\"" ) ;
7143
-                }
7144
-                else
7145
-                {
7146
-                        strcat( lDialogString ,"buttons {\"OK\"} " ) ;
7147
-                        strcat( lDialogString ,"default button \"OK\" " ) ;
7148
-                }
7149
-                strcat( lDialogString, ")' ") ;
7150
+				strcpy( lDialogString , "osascript ");
7151
+				if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
7152
+				strcat( lDialogString , " -e 'try' -e 'set {vButton} to {button returned} of ( display dialog \"") ;
7153
+				if ( aMessage && strlen(aMessage) )
7154
+				{
7155
+						strcat(lDialogString, aMessage) ;
7156
+				}
7157
+				strcat(lDialogString, "\" ") ;
7158
+				if ( aTitle && strlen(aTitle) )
7159
+				{
7160
+						strcat(lDialogString, "with title \"") ;
7161
+						strcat(lDialogString, aTitle) ;
7162
+						strcat(lDialogString, "\" ") ;
7163
+				}
7164
+				strcat(lDialogString, "with icon ") ;
7165
+				if ( aIconType && ! strcmp( "error" , aIconType ) )
7166
+				{
7167
+						strcat(lDialogString, "stop " ) ;
7168
+				}
7169
+				else if ( aIconType && ! strcmp( "warning" , aIconType ) )
7170
+				{
7171
+						strcat(lDialogString, "caution " ) ;
7172
+				}
7173
+				else /* question or info */
7174
+				{
7175
+						strcat(lDialogString, "note " ) ;
7176
+				}
7177
+				if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7178
+				{
7179
+						if ( ! aDefaultButton )
7180
+						{
7181
+								strcat( lDialogString ,"default button \"Cancel\" " ) ;
7182
+						}
7183
+				}
7184
+				else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
7185
+				{
7186
+						strcat( lDialogString ,"buttons {\"No\", \"Yes\"} " ) ;
7187
+						if (aDefaultButton)
7188
+						{
7189
+								strcat( lDialogString ,"default button \"Yes\" " ) ;
7190
+						}
7191
+						else
7192
+						{
7193
+								strcat( lDialogString ,"default button \"No\" " ) ;
7194
+						}
7195
+						strcat( lDialogString ,"cancel button \"No\"" ) ;
7196
+				}
7197
+				else if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7198
+				{
7199
+						strcat( lDialogString ,"buttons {\"No\", \"Yes\", \"Cancel\"} " ) ;
7200
+						switch (aDefaultButton)
7201
+						{
7202
+								case 1: strcat( lDialogString ,"default button \"Yes\" " ) ; break;
7203
+								case 2: strcat( lDialogString ,"default button \"No\" " ) ; break;
7204
+								case 0: strcat( lDialogString ,"default button \"Cancel\" " ) ; break;
7205
+						}
7206
+						strcat( lDialogString ,"cancel button \"Cancel\"" ) ;
7207
+				}
7208
+				else
7209
+				{
7210
+						strcat( lDialogString ,"buttons {\"OK\"} " ) ;
7211
+						strcat( lDialogString ,"default button \"OK\" " ) ;
7212
+				}
7213
+				strcat( lDialogString, ")' ") ;
7214
 
7215
-                strcat( lDialogString,
7216
+				strcat( lDialogString,
7217
 "-e 'if vButton is \"Yes\" then' -e 'return 1'\
7218
  -e 'else if vButton is \"OK\" then' -e 'return 1'\
7219
  -e 'else if vButton is \"No\" then' -e 'return 2'\
7220
  -e 'else' -e 'return 0' -e 'end if' " );
7221
 
7222
-                strcat( lDialogString, "-e 'on error number -128' " ) ;
7223
-                strcat( lDialogString, "-e '0' " );
7224
+				strcat( lDialogString, "-e 'on error number -128' " ) ;
7225
+				strcat( lDialogString, "-e '0' " );
7226
 
7227
-                strcat( lDialogString, "-e 'end try'") ;
7228
-                if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
7229
-        }
7230
-        else if ( tfd_kdialogPresent() )
7231
-        {
7232
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return 1;}
7233
+				strcat( lDialogString, "-e 'end try'") ;
7234
+				if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
7235
+		}
7236
+		else if ( tfd_kdialogPresent() )
7237
+		{
7238
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return 1;}
7239
 
7240
-                strcpy( lDialogString , "kdialog" ) ;
7241
-				if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
7242
-                {
7243
-                        strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
7244
-                }
7245
+				strcpy( lDialogString , "kdialog" ) ;
7246
+								if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
7247
+				{
7248
+						strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
7249
+				}
7250
 
7251
-                strcat( lDialogString , " --" ) ;
7252
-                if ( aDialogType && ( ! strcmp( "okcancel" , aDialogType )
7253
-                        || ! strcmp( "yesno" , aDialogType ) || ! strcmp( "yesnocancel" , aDialogType ) ) )
7254
-                {
7255
-                        if ( aIconType && ( ! strcmp( "warning" , aIconType )
7256
-                                || ! strcmp( "error" , aIconType ) ) )
7257
-                        {
7258
-                                strcat( lDialogString , "warning" ) ;
7259
-                        }
7260
-                        if ( ! strcmp( "yesnocancel" , aDialogType ) )
7261
-                        {
7262
-                                strcat( lDialogString , "yesnocancel" ) ;
7263
-                        }
7264
-                        else
7265
-                        {
7266
-                                strcat( lDialogString , "yesno" ) ;
7267
-                        }
7268
-                }
7269
-                else if ( aIconType && ! strcmp( "error" , aIconType ) )
7270
-                {
7271
-                        strcat( lDialogString , "error" ) ;
7272
-                }
7273
-                else if ( aIconType && ! strcmp( "warning" , aIconType ) )
7274
-                {
7275
-                        strcat( lDialogString , "sorry" ) ;
7276
-                }
7277
-                else
7278
-                {
7279
-                        strcat( lDialogString , "msgbox" ) ;
7280
-                }
7281
-                strcat( lDialogString , " \"" ) ;
7282
-                if ( aMessage )
7283
-                {
7284
-                        strcat( lDialogString , aMessage ) ;
7285
-                }
7286
-                strcat( lDialogString , "\"" ) ;
7287
-                if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7288
-                {
7289
-                        strcat( lDialogString ,
7290
-                                " --yes-label Ok --no-label Cancel" ) ;
7291
-                }
7292
-                if ( aTitle && strlen(aTitle) )
7293
-                {
7294
-                        strcat(lDialogString, " --title \"") ;
7295
-                        strcat(lDialogString, aTitle) ;
7296
-                        strcat(lDialogString, "\"") ;
7297
-                }
7298
+				strcat( lDialogString , " --" ) ;
7299
+				if ( aDialogType && ( ! strcmp( "okcancel" , aDialogType )
7300
+						|| ! strcmp( "yesno" , aDialogType ) || ! strcmp( "yesnocancel" , aDialogType ) ) )
7301
+				{
7302
+						if ( aIconType && ( ! strcmp( "warning" , aIconType )
7303
+								|| ! strcmp( "error" , aIconType ) ) )
7304
+						{
7305
+								strcat( lDialogString , "warning" ) ;
7306
+						}
7307
+						if ( ! strcmp( "yesnocancel" , aDialogType ) )
7308
+						{
7309
+								strcat( lDialogString , "yesnocancel" ) ;
7310
+						}
7311
+						else
7312
+						{
7313
+								strcat( lDialogString , "yesno" ) ;
7314
+						}
7315
+				}
7316
+				else if ( aIconType && ! strcmp( "error" , aIconType ) )
7317
+				{
7318
+						strcat( lDialogString , "error" ) ;
7319
+				}
7320
+				else if ( aIconType && ! strcmp( "warning" , aIconType ) )
7321
+				{
7322
+						strcat( lDialogString , "sorry" ) ;
7323
+				}
7324
+				else
7325
+				{
7326
+						strcat( lDialogString , "msgbox" ) ;
7327
+				}
7328
+				strcat( lDialogString , " \"" ) ;
7329
+				if ( aMessage )
7330
+				{
7331
+						strcat( lDialogString , aMessage ) ;
7332
+				}
7333
+				strcat( lDialogString , "\"" ) ;
7334
+				if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7335
+				{
7336
+						strcat( lDialogString ,
7337
+								" --yes-label Ok --no-label Cancel" ) ;
7338
+				}
7339
+				if ( aTitle && strlen(aTitle) )
7340
+				{
7341
+						strcat(lDialogString, " --title \"") ;
7342
+						strcat(lDialogString, aTitle) ;
7343
+						strcat(lDialogString, "\"") ;
7344
+				}
7345
 
7346
-                if ( ! strcmp( "yesnocancel" , aDialogType ) )
7347
-                {
7348
-                        strcat( lDialogString , "; x=$? ;if [ $x = 0 ] ;then echo 1;elif [ $x = 1 ] ;then echo 2;else echo 0;fi");
7349
-                }
7350
-                else
7351
-                {
7352
-                        strcat( lDialogString , ";if [ $? = 0 ];then echo 1;else echo 0;fi");
7353
-                }
7354
-        }
7355
-        else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
7356
-        {
7357
-                if ( tfd_zenityPresent() )
7358
-                {
7359
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return 1;}
7360
-                        strcpy( lDialogString , "szAnswer=$(zenity" ) ;
7361
-						if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
7362
-                        {
7363
-                                strcat(lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
7364
-                        }
7365
-                }
7366
-                else if ( tfd_matedialogPresent() )
7367
-                {
7368
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return 1;}
7369
-                        strcpy( lDialogString , "szAnswer=$(matedialog" ) ;
7370
-                }
7371
-                else if ( tfd_shellementaryPresent() )
7372
-                {
7373
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return 1;}
7374
-                        strcpy( lDialogString , "szAnswer=$(shellementary" ) ;
7375
-                }
7376
-                else
7377
-                {
7378
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return 1;}
7379
-                        strcpy( lDialogString , "szAnswer=$(qarma" ) ;
7380
-						if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
7381
-                        {
7382
-                                strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
7383
-                        }
7384
-                }
7385
-                strcat(lDialogString, " --");
7386
-
7387
-                if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7388
-                {
7389
-                                strcat( lDialogString ,
7390
-                                                "question --ok-label=Ok --cancel-label=Cancel" ) ;
7391
-                }
7392
-                else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
7393
-                {
7394
-                                strcat( lDialogString , "question" ) ;
7395
-                }
7396
-                else if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7397
-                {
7398
-                        strcat( lDialogString , "list --column \"\" --hide-header \"Yes\" \"No\"" ) ;
7399
-                }
7400
-                else if ( aIconType && ! strcmp( "error" , aIconType ) )
7401
-                {
7402
-                    strcat( lDialogString , "error" ) ;
7403
-                }
7404
-                else if ( aIconType && ! strcmp( "warning" , aIconType ) )
7405
-                {
7406
-                    strcat( lDialogString , "warning" ) ;
7407
-                }
7408
-                else
7409
-                {
7410
-                    strcat( lDialogString , "info" ) ;
7411
-                }
7412
-                if ( aTitle && strlen(aTitle) )
7413
-                {
7414
-                        strcat(lDialogString, " --title=\"") ;
7415
-                        strcat(lDialogString, aTitle) ;
7416
-                        strcat(lDialogString, "\"") ;
7417
-                }
7418
-                if ( aMessage && strlen(aMessage) )
7419
-                {
7420
-                  if (strcmp("yesnocancel", aDialogType)) strcat(lDialogString, " --no-wrap");
7421
-                  strcat(lDialogString, " --text=\"") ;
7422
-                  strcat(lDialogString, aMessage) ;
7423
-                  strcat(lDialogString, "\"") ;
7424
-                }
7425
-                if ( (tfd_zenity3Present() >= 3) || (!tfd_zenityPresent() && (tfd_shellementaryPresent() || tfd_qarmaPresent()) ) )
7426
-                {
7427
-                        strcat( lDialogString , " --icon-name=dialog-" ) ;
7428
-                        if ( aIconType && (! strcmp( "question" , aIconType )
7429
-                          || ! strcmp( "error" , aIconType )
7430
-                          || ! strcmp( "warning" , aIconType ) ) )
7431
-                        {
7432
-                                strcat( lDialogString , aIconType ) ;
7433
-                        }
7434
-                        else
7435
-                        {
7436
-                                strcat( lDialogString , "information" ) ;
7437
-                        }
7438
-                }
7439
-
7440
-                if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
7441
-
7442
-                if ( ! strcmp( "yesnocancel" , aDialogType ) )
7443
-                {
7444
-                        strcat( lDialogString ,
7445
-");if [ $? = 1 ];then echo 0;elif [ $szAnswer = \"No\" ];then echo 2;else echo 1;fi");
7446
-                }
7447
-                else
7448
-                {
7449
-                        strcat( lDialogString , ");if [ $? = 0 ];then echo 1;else echo 0;fi");
7450
-                }
7451
-      }
7452
-
7453
-      else if (tfd_yadPresent())
7454
-      {
7455
-         if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return 1; }
7456
-         strcpy(lDialogString, "szAnswer=$(yad --");
7457
-         if (aDialogType && !strcmp("ok", aDialogType))
7458
-         {
7459
-            strcat(lDialogString,"button=Ok:1");
7460
-         }
7461
-         else if (aDialogType && !strcmp("okcancel", aDialogType))
7462
-         {
7463
-            strcat(lDialogString,"button=Ok:1 --button=Cancel:0");
7464
-         }
7465
-         else if (aDialogType && !strcmp("yesno", aDialogType))
7466
-         {
7467
-            strcat(lDialogString, "button=Yes:1 --button=No:0");
7468
-         }
7469
-         else if (aDialogType && !strcmp("yesnocancel", aDialogType))
7470
-         {
7471
-            strcat(lDialogString, "button=Yes:1 --button=No:2 --button=Cancel:0");
7472
-         }
7473
-         else if (aIconType && !strcmp("error", aIconType))
7474
-         {
7475
-            strcat(lDialogString, "error");
7476
-         }
7477
-         else if (aIconType && !strcmp("warning", aIconType))
7478
-         {
7479
-            strcat(lDialogString, "warning");
7480
-         }
7481
-         else
7482
-         {
7483
-            strcat(lDialogString, "info");
7484
-         }
7485
-         if (aTitle && strlen(aTitle))
7486
-         {
7487
-            strcat(lDialogString, " --title=\"");
7488
-            strcat(lDialogString, aTitle);
7489
-            strcat(lDialogString, "\"");
7490
-         }
7491
-         if (aMessage && strlen(aMessage))
7492
-         {
7493
-            strcat(lDialogString, " --text=\"");
7494
-            strcat(lDialogString, aMessage);
7495
-            strcat(lDialogString, "\"");
7496
-         }
7497
-
7498
-         strcat(lDialogString, " --icon-name=dialog-");
7499
-         if (aIconType && (!strcmp("question", aIconType)
7500
-            || !strcmp("error", aIconType)
7501
-            || !strcmp("warning", aIconType)))
7502
-         {
7503
-            strcat(lDialogString, aIconType);
7504
-         }
7505
-         else
7506
-         {
7507
-            strcat(lDialogString, "information");
7508
-         }
7509
-
7510
-         if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
7511
-         strcat(lDialogString,");echo $?");
7512
-      }
7513
-
7514
-      else if ( !gxmessagePresent() && !gmessagePresent() && !gdialogPresent() && !xdialogPresent() && tkinter3Present() )
7515
+				if ( ! strcmp( "yesnocancel" , aDialogType ) )
7516
+				{
7517
+						strcat( lDialogString , "; x=$? ;if [ $x = 0 ] ;then echo 1;elif [ $x = 1 ] ;then echo 2;else echo 0;fi");
7518
+				}
7519
+				else
7520
+				{
7521
+						strcat( lDialogString , ";if [ $? = 0 ];then echo 1;else echo 0;fi");
7522
+				}
7523
+		}
7524
+		else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
7525
 		{
7526
-			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return 1;}
7527
-
7528
-			strcpy( lDialogString , gPython3Name ) ;
7529
-			strcat( lDialogString ,
7530
-				" -S -c \"import tkinter;from tkinter import messagebox;root=tkinter.Tk();root.withdraw();");
7531
-
7532
-			strcat( lDialogString ,"res=messagebox." ) ;
7533
-			if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7534
-			{
7535
-				strcat( lDialogString , "askokcancel(" ) ;
7536
-				if ( aDefaultButton )
7537
+				if ( tfd_zenityPresent() )
7538
 				{
7539
-					strcat( lDialogString , "default=messagebox.OK," ) ;
7540
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return 1;}
7541
+						strcpy( lDialogString , "szAnswer=$(zenity" ) ;
7542
+												if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
7543
+						{
7544
+								strcat(lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
7545
+						}
7546
 				}
7547
+				else if ( tfd_matedialogPresent() )
7548
+				{
7549
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return 1;}
7550
+						strcpy( lDialogString , "szAnswer=$(matedialog" ) ;
7551
+				}
7552
+				else if ( tfd_shellementaryPresent() )
7553
+				{
7554
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return 1;}
7555
+						strcpy( lDialogString , "szAnswer=$(shellementary" ) ;
7556
+				}
7557
 				else
7558
 				{
7559
-					strcat( lDialogString , "default=messagebox.CANCEL," ) ;
7560
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return 1;}
7561
+						strcpy( lDialogString , "szAnswer=$(qarma" ) ;
7562
+												if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
7563
+						{
7564
+								strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
7565
+						}
7566
 				}
7567
-			}
7568
-			else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
7569
-			{
7570
-				strcat( lDialogString , "askyesno(" ) ;
7571
-				if ( aDefaultButton )
7572
+				strcat(lDialogString, " --");
7573
+
7574
+				if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7575
 				{
7576
-					strcat( lDialogString , "default=messagebox.YES," ) ;
7577
+								strcat( lDialogString ,
7578
+												"question --ok-label=Ok --cancel-label=Cancel" ) ;
7579
 				}
7580
+				else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
7581
+				{
7582
+								strcat( lDialogString , "question" ) ;
7583
+				}
7584
+				else if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7585
+				{
7586
+						strcat( lDialogString , "list --column \"\" --hide-header \"Yes\" \"No\"" ) ;
7587
+				}
7588
+				else if ( aIconType && ! strcmp( "error" , aIconType ) )
7589
+				{
7590
+					strcat( lDialogString , "error" ) ;
7591
+				}
7592
+				else if ( aIconType && ! strcmp( "warning" , aIconType ) )
7593
+				{
7594
+					strcat( lDialogString , "warning" ) ;
7595
+				}
7596
 				else
7597
 				{
7598
-					strcat( lDialogString , "default=messagebox.NO," ) ;
7599
+					strcat( lDialogString , "info" ) ;
7600
 				}
7601
-			}
7602
-			else if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7603
-			{
7604
-				strcat( lDialogString , "askyesnocancel(" ) ;
7605
-				switch ( aDefaultButton )
7606
+
7607
+				strcat(lDialogString, " --title=\"");
7608
+				if ( aTitle && strlen(aTitle) ) strcat(lDialogString, aTitle) ;
7609
+				strcat(lDialogString, "\"");
7610
+
7611
+				if (strcmp("yesnocancel", aDialogType)) strcat(lDialogString, " --no-wrap");
7612
+
7613
+				strcat(lDialogString, " --text=\"") ;
7614
+				if (aMessage && strlen(aMessage)) strcat(lDialogString, aMessage) ;
7615
+				strcat(lDialogString, "\"") ;
7616
+
7617
+				if ( (tfd_zenity3Present() >= 3) || (!tfd_zenityPresent() && (tfd_shellementaryPresent() || tfd_qarmaPresent()) ) )
7618
 				{
7619
-				case 1: strcat( lDialogString , "default=messagebox.YES," ); break;
7620
-				case 2: strcat( lDialogString , "default=messagebox.NO," ); break;
7621
-				case 0: strcat( lDialogString , "default=messagebox.CANCEL," ); break;
7622
+						strcat( lDialogString , " --icon-name=dialog-" ) ;
7623
+						if ( aIconType && (! strcmp( "question" , aIconType )
7624
+						  || ! strcmp( "error" , aIconType )
7625
+						  || ! strcmp( "warning" , aIconType ) ) )
7626
+						{
7627
+								strcat( lDialogString , aIconType ) ;
7628
+						}
7629
+						else
7630
+						{
7631
+								strcat( lDialogString , "information" ) ;
7632
+						}
7633
 				}
7634
-			}
7635
-			else
7636
-			{
7637
-				strcat( lDialogString , "showinfo(" ) ;
7638
-			}
7639
 
7640
-			strcat( lDialogString , "icon='" ) ;
7641
-			if ( aIconType && (! strcmp( "question" , aIconType )
7642
-				|| ! strcmp( "error" , aIconType )
7643
-				|| ! strcmp( "warning" , aIconType ) ) )
7644
-			{
7645
-				strcat( lDialogString , aIconType ) ;
7646
-			}
7647
-			else
7648
-			{
7649
-				strcat( lDialogString , "info" ) ;
7650
-			}
7651
+				if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
7652
 
7653
-			strcat(lDialogString, "',") ;
7654
-			if ( aTitle && strlen(aTitle) )
7655
-			{
7656
-				strcat(lDialogString, "title='") ;
7657
-				strcat(lDialogString, aTitle) ;
7658
-				strcat(lDialogString, "',") ;
7659
-			}
7660
-			if ( aMessage && strlen(aMessage) )
7661
-			{
7662
-				strcat(lDialogString, "message='") ;
7663
-				lpDialogString = lDialogString + strlen(lDialogString);
7664
-				tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
7665
-				strcat(lDialogString, "'") ;
7666
-			}
7667
+				if ( ! strcmp( "yesnocancel" , aDialogType ) )
7668
+				{
7669
+						strcat( lDialogString ,
7670
+");if [ $? = 1 ];then echo 0;elif [ $szAnswer = \"No\" ];then echo 2;else echo 1;fi");
7671
+				}
7672
+				else
7673
+				{
7674
+						strcat( lDialogString , ");if [ $? = 0 ];then echo 1;else echo 0;fi");
7675
+				}
7676
+	  }
7677
 
7678
-			if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7679
-			{
7680
-				strcat(lDialogString, ");\n\
7681
+	  else if (tfd_yadPresent())
7682
+	  {
7683
+		 if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return 1; }
7684
+		 strcpy(lDialogString, "szAnswer=$(yad --");
7685
+		 if (aDialogType && !strcmp("ok", aDialogType))
7686
+		 {
7687
+			strcat(lDialogString,"button=Ok:1");
7688
+		 }
7689
+		 else if (aDialogType && !strcmp("okcancel", aDialogType))
7690
+		 {
7691
+			strcat(lDialogString,"button=Ok:1 --button=Cancel:0");
7692
+		 }
7693
+		 else if (aDialogType && !strcmp("yesno", aDialogType))
7694
+		 {
7695
+			strcat(lDialogString, "button=Yes:1 --button=No:0");
7696
+		 }
7697
+		 else if (aDialogType && !strcmp("yesnocancel", aDialogType))
7698
+		 {
7699
+			strcat(lDialogString, "button=Yes:1 --button=No:2 --button=Cancel:0");
7700
+		 }
7701
+		 else if (aIconType && !strcmp("error", aIconType))
7702
+		 {
7703
+			strcat(lDialogString, "error");
7704
+		 }
7705
+		 else if (aIconType && !strcmp("warning", aIconType))
7706
+		 {
7707
+			strcat(lDialogString, "warning");
7708
+		 }
7709
+		 else
7710
+		 {
7711
+			strcat(lDialogString, "info");
7712
+		 }
7713
+		 if (aTitle && strlen(aTitle))
7714
+		 {
7715
+			strcat(lDialogString, " --title=\"");
7716
+			strcat(lDialogString, aTitle);
7717
+			strcat(lDialogString, "\"");
7718
+		 }
7719
+		 if (aMessage && strlen(aMessage))
7720
+		 {
7721
+			strcat(lDialogString, " --text=\"");
7722
+			strcat(lDialogString, aMessage);
7723
+			strcat(lDialogString, "\"");
7724
+		 }
7725
+
7726
+		 strcat(lDialogString, " --image=dialog-");
7727
+		 if (aIconType && (!strcmp("question", aIconType)
7728
+			|| !strcmp("error", aIconType)
7729
+			|| !strcmp("warning", aIconType)))
7730
+		 {
7731
+			strcat(lDialogString, aIconType);
7732
+		 }
7733
+		 else
7734
+		 {
7735
+			strcat(lDialogString, "information");
7736
+		 }
7737
+
7738
+		 if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
7739
+		 strcat(lDialogString,");echo $?");
7740
+	  }
7741
+
7742
+	  else if ( !gxmessagePresent() && !gmessagePresent() && !gdialogPresent() && !xdialogPresent() && tkinter3Present() )
7743
+				{
7744
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return 1;}
7745
+
7746
+						strcpy( lDialogString , gPython3Name ) ;
7747
+						strcat( lDialogString ,
7748
+								" -S -c \"import tkinter;from tkinter import messagebox;root=tkinter.Tk();root.withdraw();");
7749
+
7750
+						strcat( lDialogString ,"res=messagebox." ) ;
7751
+						if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7752
+						{
7753
+								strcat( lDialogString , "askokcancel(" ) ;
7754
+								if ( aDefaultButton )
7755
+								{
7756
+										strcat( lDialogString , "default=messagebox.OK," ) ;
7757
+								}
7758
+								else
7759
+								{
7760
+										strcat( lDialogString , "default=messagebox.CANCEL," ) ;
7761
+								}
7762
+						}
7763
+						else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
7764
+						{
7765
+								strcat( lDialogString , "askyesno(" ) ;
7766
+								if ( aDefaultButton )
7767
+								{
7768
+										strcat( lDialogString , "default=messagebox.YES," ) ;
7769
+								}
7770
+								else
7771
+								{
7772
+										strcat( lDialogString , "default=messagebox.NO," ) ;
7773
+								}
7774
+						}
7775
+						else if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7776
+						{
7777
+								strcat( lDialogString , "askyesnocancel(" ) ;
7778
+								switch ( aDefaultButton )
7779
+								{
7780
+								case 1: strcat( lDialogString , "default=messagebox.YES," ); break;
7781
+								case 2: strcat( lDialogString , "default=messagebox.NO," ); break;
7782
+								case 0: strcat( lDialogString , "default=messagebox.CANCEL," ); break;
7783
+								}
7784
+						}
7785
+						else
7786
+						{
7787
+								strcat( lDialogString , "showinfo(" ) ;
7788
+						}
7789
+
7790
+						strcat( lDialogString , "icon='" ) ;
7791
+						if ( aIconType && (! strcmp( "question" , aIconType )
7792
+								|| ! strcmp( "error" , aIconType )
7793
+								|| ! strcmp( "warning" , aIconType ) ) )
7794
+						{
7795
+								strcat( lDialogString , aIconType ) ;
7796
+						}
7797
+						else
7798
+						{
7799
+								strcat( lDialogString , "info" ) ;
7800
+						}
7801
+
7802
+						strcat(lDialogString, "',") ;
7803
+						if ( aTitle && strlen(aTitle) )
7804
+						{
7805
+								strcat(lDialogString, "title='") ;
7806
+								strcat(lDialogString, aTitle) ;
7807
+								strcat(lDialogString, "',") ;
7808
+						}
7809
+						if ( aMessage && strlen(aMessage) )
7810
+						{
7811
+								strcat(lDialogString, "message='") ;
7812
+								lpDialogString = lDialogString + strlen(lDialogString);
7813
+								tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
7814
+								strcat(lDialogString, "'") ;
7815
+						}
7816
+
7817
+						if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7818
+						{
7819
+								strcat(lDialogString, ");\n\
7820
 if res is None :\n\tprint(0)\n\
7821
 elif res is False :\n\tprint(2)\n\
7822
 else :\n\tprint (1)\n\"" ) ;
7823
-			}
7824
-			else
7825
-			{
7826
-				strcat(lDialogString, ");\n\
7827
+						}
7828
+						else
7829
+						{
7830
+								strcat(lDialogString, ");\n\
7831
 if res is False :\n\tprint(0)\n\
7832
 else :\n\tprint(1)\n\"" ) ;
7833
-			}
7834
-		}
7835
-		else if ( !gxmessagePresent() && !gmessagePresent() && !gdialogPresent() && !xdialogPresent() && tkinter2Present() )
7836
-        {
7837
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return 1;}
7838
-				strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
7839
-				strcat( lDialogString , gPython2Name ) ;
7840
-				if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
7841
-                {
7842
-                        strcat( lDialogString , " -i" ) ;  /* for osx without console */
7843
-                }
7844
+						}
7845
+				}
7846
+				else if ( !gxmessagePresent() && !gmessagePresent() && !gdialogPresent() && !xdialogPresent() && tkinter2Present() )
7847
+		{
7848
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return 1;}
7849
+								strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
7850
+								strcat( lDialogString , gPython2Name ) ;
7851
+								if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
7852
+				{
7853
+						strcat( lDialogString , " -i" ) ;  /* for osx without console */
7854
+				}
7855
 
7856
-                strcat( lDialogString ,
7857
+				strcat( lDialogString ,
7858
 " -S -c \"import Tkinter,tkMessageBox;root=Tkinter.Tk();root.withdraw();");
7859
 
7860
-                if ( tfd_isDarwin( ) )
7861
-                {
7862
-                        strcat( lDialogString ,
7863
+				if ( tfd_isDarwin( ) )
7864
+				{
7865
+						strcat( lDialogString ,
7866
 "import os;os.system('''/usr/bin/osascript -e 'tell app \\\"Finder\\\" to set \
7867
 frontmost of process \\\"Python\\\" to true' ''');");
7868
-                }
7869
+				}
7870
 
7871
-                strcat( lDialogString ,"res=tkMessageBox." ) ;
7872
-                if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7873
-                {
7874
-                  strcat( lDialogString , "askokcancel(" ) ;
7875
-                  if ( aDefaultButton )
7876
-                        {
7877
-                                strcat( lDialogString , "default=tkMessageBox.OK," ) ;
7878
-                        }
7879
-                        else
7880
-                        {
7881
-                                strcat( lDialogString , "default=tkMessageBox.CANCEL," ) ;
7882
-                        }
7883
-                }
7884
-                else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
7885
-                {
7886
-                        strcat( lDialogString , "askyesno(" ) ;
7887
-                        if ( aDefaultButton )
7888
-                        {
7889
-                                strcat( lDialogString , "default=tkMessageBox.YES," ) ;
7890
-                        }
7891
-                        else
7892
-                        {
7893
-                                strcat( lDialogString , "default=tkMessageBox.NO," ) ;
7894
-                        }
7895
-                }
7896
-                else if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7897
-                {
7898
-                        strcat( lDialogString , "askyesnocancel(" ) ;
7899
-                        switch ( aDefaultButton )
7900
-                        {
7901
-                                case 1: strcat( lDialogString , "default=tkMessageBox.YES," ); break;
7902
-                                case 2: strcat( lDialogString , "default=tkMessageBox.NO," ); break;
7903
-                                case 0: strcat( lDialogString , "default=tkMessageBox.CANCEL," ); break;
7904
-                        }
7905
-                }
7906
-                else
7907
-                {
7908
-                                strcat( lDialogString , "showinfo(" ) ;
7909
-                }
7910
+				strcat( lDialogString ,"res=tkMessageBox." ) ;
7911
+				if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
7912
+				{
7913
+				  strcat( lDialogString , "askokcancel(" ) ;
7914
+				  if ( aDefaultButton )
7915
+						{
7916
+								strcat( lDialogString , "default=tkMessageBox.OK," ) ;
7917
+						}
7918
+						else
7919
+						{
7920
+								strcat( lDialogString , "default=tkMessageBox.CANCEL," ) ;
7921
+						}
7922
+				}
7923
+				else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
7924
+				{
7925
+						strcat( lDialogString , "askyesno(" ) ;
7926
+						if ( aDefaultButton )
7927
+						{
7928
+								strcat( lDialogString , "default=tkMessageBox.YES," ) ;
7929
+						}
7930
+						else
7931
+						{
7932
+								strcat( lDialogString , "default=tkMessageBox.NO," ) ;
7933
+						}
7934
+				}
7935
+				else if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
7936
+				{
7937
+						strcat( lDialogString , "askyesnocancel(" ) ;
7938
+						switch ( aDefaultButton )
7939
+						{
7940
+								case 1: strcat( lDialogString , "default=tkMessageBox.YES," ); break;
7941
+								case 2: strcat( lDialogString , "default=tkMessageBox.NO," ); break;
7942
+								case 0: strcat( lDialogString , "default=tkMessageBox.CANCEL," ); break;
7943
+						}
7944
+				}
7945
+				else
7946
+				{
7947
+								strcat( lDialogString , "showinfo(" ) ;
7948
+				}
7949
 
7950
-                strcat( lDialogString , "icon='" ) ;
7951
-                if ( aIconType && (! strcmp( "question" , aIconType )
7952
-                  || ! strcmp( "error" , aIconType )
7953
-                  || ! strcmp( "warning" , aIconType ) ) )
7954
-                {
7955
-                                strcat( lDialogString , aIconType ) ;
7956
-                }
7957
-                else
7958
-                {
7959
-                                strcat( lDialogString , "info" ) ;
7960
-                }
7961
+				strcat( lDialogString , "icon='" ) ;
7962
+				if ( aIconType && (! strcmp( "question" , aIconType )
7963
+				  || ! strcmp( "error" , aIconType )
7964
+				  || ! strcmp( "warning" , aIconType ) ) )
7965
+				{
7966
+								strcat( lDialogString , aIconType ) ;
7967
+				}
7968
+				else
7969
+				{
7970
+								strcat( lDialogString , "info" ) ;
7971
+				}
7972
 
7973
-                strcat(lDialogString, "',") ;
7974
-                if ( aTitle && strlen(aTitle) )
7975
-                {
7976
-                                strcat(lDialogString, "title='") ;
7977
-                                strcat(lDialogString, aTitle) ;
7978
-                                strcat(lDialogString, "',") ;
7979
-                }
7980
-                if ( aMessage && strlen(aMessage) )
7981
-                {
7982
-                        strcat(lDialogString, "message='") ;
7983
-                        lpDialogString = lDialogString + strlen(lDialogString);
7984
-                        tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
7985
-                        strcat(lDialogString, "'") ;
7986
-                }
7987
+				strcat(lDialogString, "',") ;
7988
+				if ( aTitle && strlen(aTitle) )
7989
+				{
7990
+								strcat(lDialogString, "title='") ;
7991
+								strcat(lDialogString, aTitle) ;
7992
+								strcat(lDialogString, "',") ;
7993
+				}
7994
+				if ( aMessage && strlen(aMessage) )
7995
+				{
7996
+						strcat(lDialogString, "message='") ;
7997
+						lpDialogString = lDialogString + strlen(lDialogString);
7998
+						tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
7999
+						strcat(lDialogString, "'") ;
8000
+				}
8001
 
8002
-                if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
8003
-                {
8004
-                        strcat(lDialogString, ");\n\
8005
+				if ( aDialogType && ! strcmp( "yesnocancel" , aDialogType ) )
8006
+				{
8007
+						strcat(lDialogString, ");\n\
8008
 if res is None :\n\tprint 0\n\
8009
 elif res is False :\n\tprint 2\n\
8010
 else :\n\tprint 1\n\"" ) ;
8011
-                }
8012
-                else
8013
-                {
8014
-                        strcat(lDialogString, ");\n\
8015
+				}
8016
+				else
8017
+				{
8018
+						strcat(lDialogString, ");\n\
8019
 if res is False :\n\tprint 0\n\
8020
 else :\n\tprint 1\n\"" ) ;
8021
-                }
8022
-    }
8023
-        else if ( gxmessagePresent() || gmessagePresent() || (!gdialogPresent() && !xdialogPresent() && xmessagePresent()) )
8024
-        {
8025
-                if ( gxmessagePresent() )
8026
-                {
8027
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gxmessage");return 1;}
8028
-                        strcpy( lDialogString , "gxmessage");
8029
-                }
8030
-                else if ( gmessagePresent() )
8031
-                {
8032
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gmessage");return 1;}
8033
-                        strcpy( lDialogString , "gmessage");
8034
-                }
8035
-                else
8036
-                {
8037
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xmessage");return 1;}
8038
-                        strcpy( lDialogString , "xmessage");
8039
-                }
8040
+				}
8041
+	}
8042
+		else if ( gxmessagePresent() || gmessagePresent() || (!gdialogPresent() && !xdialogPresent() && xmessagePresent()) )
8043
+		{
8044
+				if ( gxmessagePresent() )
8045
+				{
8046
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gxmessage");return 1;}
8047
+						strcpy( lDialogString , "gxmessage");
8048
+				}
8049
+				else if ( gmessagePresent() )
8050
+				{
8051
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gmessage");return 1;}
8052
+						strcpy( lDialogString , "gmessage");
8053
+				}
8054
+				else
8055
+				{
8056
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xmessage");return 1;}
8057
+						strcpy( lDialogString , "xmessage");
8058
+				}
8059
 
8060
-                if ( aDialogType && ! strcmp("okcancel" , aDialogType) )
8061
-                {
8062
-                        strcat( lDialogString , " -buttons Ok:1,Cancel:0");
8063
-                        switch ( aDefaultButton )
8064
-                        {
8065
-                                case 1: strcat( lDialogString , " -default Ok"); break;
8066
-                                case 0: strcat( lDialogString , " -default Cancel"); break;
8067
-                        }
8068
-                }
8069
-                else if ( aDialogType && ! strcmp("yesno" , aDialogType) )
8070
-                {
8071
-                        strcat( lDialogString , " -buttons Yes:1,No:0");
8072
-                        switch ( aDefaultButton )
8073
-                        {
8074
-                                case 1: strcat( lDialogString , " -default Yes"); break;
8075
-                                case 0: strcat( lDialogString , " -default No"); break;
8076
-                        }
8077
-                }
8078
-                else if ( aDialogType && ! strcmp("yesnocancel" , aDialogType) )
8079
-                {
8080
-                        strcat( lDialogString , " -buttons Yes:1,No:2,Cancel:0");
8081
-                        switch ( aDefaultButton )
8082
-                        {
8083
-                                case 1: strcat( lDialogString , " -default Yes"); break;
8084
-                                case 2: strcat( lDialogString , " -default No"); break;
8085
-                                case 0: strcat( lDialogString , " -default Cancel"); break;
8086
-                        }
8087
-                }
8088
-                else
8089
-                {
8090
-                        strcat( lDialogString , " -buttons Ok:1");
8091
-                        strcat( lDialogString , " -default Ok");
8092
-                }
8093
+				if ( aDialogType && ! strcmp("okcancel" , aDialogType) )
8094
+				{
8095
+						strcat( lDialogString , " -buttons Ok:1,Cancel:0");
8096
+						switch ( aDefaultButton )
8097
+						{
8098
+								case 1: strcat( lDialogString , " -default Ok"); break;
8099
+								case 0: strcat( lDialogString , " -default Cancel"); break;
8100
+						}
8101
+				}
8102
+				else if ( aDialogType && ! strcmp("yesno" , aDialogType) )
8103
+				{
8104
+						strcat( lDialogString , " -buttons Yes:1,No:0");
8105
+						switch ( aDefaultButton )
8106
+						{
8107
+								case 1: strcat( lDialogString , " -default Yes"); break;
8108
+								case 0: strcat( lDialogString , " -default No"); break;
8109
+						}
8110
+				}
8111
+				else if ( aDialogType && ! strcmp("yesnocancel" , aDialogType) )
8112
+				{
8113
+						strcat( lDialogString , " -buttons Yes:1,No:2,Cancel:0");
8114
+						switch ( aDefaultButton )
8115
+						{
8116
+								case 1: strcat( lDialogString , " -default Yes"); break;
8117
+								case 2: strcat( lDialogString , " -default No"); break;
8118
+								case 0: strcat( lDialogString , " -default Cancel"); break;
8119
+						}
8120
+				}
8121
+				else
8122
+				{
8123
+						strcat( lDialogString , " -buttons Ok:1");
8124
+						strcat( lDialogString , " -default Ok");
8125
+				}
8126
 
8127
-                strcat( lDialogString , " -center \"");
8128
-                if ( aMessage && strlen(aMessage) )
8129
-                {
8130
-                        strcat( lDialogString , aMessage ) ;
8131
-                }
8132
-                strcat(lDialogString, "\"" ) ;
8133
-                if ( aTitle && strlen(aTitle) )
8134
-                {
8135
-                        strcat( lDialogString , " -title  \"");
8136
-                        strcat( lDialogString , aTitle ) ;
8137
-                        strcat( lDialogString, "\"" ) ;
8138
-                }
8139
-                strcat( lDialogString , " ; echo $? ");
8140
-        }
8141
-        else if ( xdialogPresent() || gdialogPresent() || dialogName() || whiptailPresent() )
8142
-        {
8143
-                if ( gdialogPresent( ) )
8144
-                {
8145
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gdialog");return 1;}
8146
-                        lWasGraphicDialog = 1 ;
8147
-                        strcpy( lDialogString , "(gdialog " ) ;
8148
-                }
8149
-                else if ( xdialogPresent( ) )
8150
-                {
8151
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return 1;}
8152
-                        lWasGraphicDialog = 1 ;
8153
-                        strcpy( lDialogString , "(Xdialog " ) ;
8154
-                }
8155
-                else if ( dialogName( ) )
8156
-                {
8157
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return 0;}
8158
-                        if ( isTerminalRunning( ) )
8159
-                        {
8160
-                                strcpy( lDialogString , "(dialog " ) ;
8161
-                        }
8162
-                        else
8163
-                        {
8164
-                                lWasXterm = 1 ;
8165
-                                strcpy( lDialogString , terminalName() ) ;
8166
-                                strcat( lDialogString , "'(" ) ;
8167
-                                strcat( lDialogString , dialogName() ) ;
8168
-                                strcat( lDialogString , " " ) ;
8169
-                        }
8170
-                }
8171
-                else if ( isTerminalRunning( ) )
8172
-                {
8173
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"whiptail");return 0;}
8174
-                        strcpy( lDialogString , "(whiptail " ) ;
8175
-                }
8176
-                else
8177
-                {
8178
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"whiptail");return 0;}
8179
-                        lWasXterm = 1 ;
8180
-                        strcpy( lDialogString , terminalName() ) ;
8181
-                        strcat( lDialogString , "'(whiptail " ) ;
8182
-                }
8183
+				strcat( lDialogString , " -center \"");
8184
+				if ( aMessage && strlen(aMessage) )
8185
+				{
8186
+						strcat( lDialogString , aMessage ) ;
8187
+				}
8188
+				strcat(lDialogString, "\"" ) ;
8189
+				if ( aTitle && strlen(aTitle) )
8190
+				{
8191
+						strcat( lDialogString , " -title  \"");
8192
+						strcat( lDialogString , aTitle ) ;
8193
+						strcat( lDialogString, "\"" ) ;
8194
+				}
8195
+				strcat( lDialogString , " ; echo $? ");
8196
+		}
8197
+		else if ( xdialogPresent() || gdialogPresent() || dialogName() || whiptailPresent() )
8198
+		{
8199
+				if ( gdialogPresent( ) )
8200
+				{
8201
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gdialog");return 1;}
8202
+						lWasGraphicDialog = 1 ;
8203
+						strcpy( lDialogString , "(gdialog " ) ;
8204
+				}
8205
+				else if ( xdialogPresent( ) )
8206
+				{
8207
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return 1;}
8208
+						lWasGraphicDialog = 1 ;
8209
+						strcpy( lDialogString , "(Xdialog " ) ;
8210
+				}
8211
+				else if ( dialogName( ) )
8212
+				{
8213
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return 0;}
8214
+						if ( isTerminalRunning( ) )
8215
+						{
8216
+								strcpy( lDialogString , "(dialog " ) ;
8217
+						}
8218
+						else
8219
+						{
8220
+								lWasXterm = 1 ;
8221
+								strcpy( lDialogString , terminalName() ) ;
8222
+								strcat( lDialogString , "'(" ) ;
8223
+								strcat( lDialogString , dialogName() ) ;
8224
+								strcat( lDialogString , " " ) ;
8225
+						}
8226
+				}
8227
+				else if ( isTerminalRunning( ) )
8228
+				{
8229
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"whiptail");return 0;}
8230
+						strcpy( lDialogString , "(whiptail " ) ;
8231
+				}
8232
+				else
8233
+				{
8234
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"whiptail");return 0;}
8235
+						lWasXterm = 1 ;
8236
+						strcpy( lDialogString , terminalName() ) ;
8237
+						strcat( lDialogString , "'(whiptail " ) ;
8238
+				}
8239
 
8240
-                if ( aTitle && strlen(aTitle) )
8241
-                {
8242
-                        strcat(lDialogString, "--title \"") ;
8243
-                        strcat(lDialogString, aTitle) ;
8244
-                        strcat(lDialogString, "\" ") ;
8245
-                }
8246
+				if ( aTitle && strlen(aTitle) )
8247
+				{
8248
+						strcat(lDialogString, "--title \"") ;
8249
+						strcat(lDialogString, aTitle) ;
8250
+						strcat(lDialogString, "\" ") ;
8251
+				}
8252
 
8253
-                if ( !xdialogPresent() && !gdialogPresent() )
8254
-                {
8255
-                        if ( aDialogType && ( !strcmp( "okcancel" , aDialogType ) || !strcmp( "yesno" , aDialogType )
8256
-                                || !strcmp( "yesnocancel" , aDialogType ) ) )
8257
-                        {
8258
-                                strcat(lDialogString, "--backtitle \"") ;
8259
-                                strcat(lDialogString, "tab: move focus") ;
8260
-                                strcat(lDialogString, "\" ") ;
8261
-                        }
8262
-                }
8263
+				if ( !xdialogPresent() && !gdialogPresent() )
8264
+				{
8265
+						if ( aDialogType && ( !strcmp( "okcancel" , aDialogType ) || !strcmp( "yesno" , aDialogType )
8266
+								|| !strcmp( "yesnocancel" , aDialogType ) ) )
8267
+						{
8268
+								strcat(lDialogString, "--backtitle \"") ;
8269
+								strcat(lDialogString, "tab: move focus") ;
8270
+								strcat(lDialogString, "\" ") ;
8271
+						}
8272
+				}
8273
 
8274
-                if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
8275
-                {
8276
-                        if ( ! aDefaultButton )
8277
-                        {
8278
-                                strcat( lDialogString , "--defaultno " ) ;
8279
-                        }
8280
-                        strcat( lDialogString ,
8281
-                                        "--yes-label \"Ok\" --no-label \"Cancel\" --yesno " ) ;
8282
-                }
8283
-                else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
8284
-                {
8285
-                        if ( ! aDefaultButton )
8286
-                        {
8287
-                                strcat( lDialogString , "--defaultno " ) ;
8288
-                        }
8289
-                        strcat( lDialogString , "--yesno " ) ;
8290
-                }
8291
-                else if (aDialogType && !strcmp("yesnocancel", aDialogType))
8292
-                {
8293
-                        if (!aDefaultButton)
8294
-                        {
8295
-                                strcat(lDialogString, "--defaultno ");
8296
-                        }
8297
-                        strcat(lDialogString, "--menu ");
8298
-                }
8299
-                else
8300
-                {
8301
-                        strcat( lDialogString , "--msgbox " ) ;
8302
+				if ( aDialogType && ! strcmp( "okcancel" , aDialogType ) )
8303
+				{
8304
+						if ( ! aDefaultButton )
8305
+						{
8306
+								strcat( lDialogString , "--defaultno " ) ;
8307
+						}
8308
+						strcat( lDialogString ,
8309
+										"--yes-label \"Ok\" --no-label \"Cancel\" --yesno " ) ;
8310
+				}
8311
+				else if ( aDialogType && ! strcmp( "yesno" , aDialogType ) )
8312
+				{
8313
+						if ( ! aDefaultButton )
8314
+						{
8315
+								strcat( lDialogString , "--defaultno " ) ;
8316
+						}
8317
+						strcat( lDialogString , "--yesno " ) ;
8318
+				}
8319
+				else if (aDialogType && !strcmp("yesnocancel", aDialogType))
8320
+				{
8321
+						if (!aDefaultButton)
8322
+						{
8323
+								strcat(lDialogString, "--defaultno ");
8324
+						}
8325
+						strcat(lDialogString, "--menu ");
8326
+				}
8327
+				else
8328
+				{
8329
+						strcat( lDialogString , "--msgbox " ) ;
8330
 
8331
-                }
8332
-                strcat( lDialogString , "\"" ) ;
8333
-                if ( aMessage && strlen(aMessage) )
8334
-                {
8335
-                        strcat(lDialogString, aMessage) ;
8336
-                }
8337
-                strcat(lDialogString, "\" ");
8338
+				}
8339
+				strcat( lDialogString , "\"" ) ;
8340
+				if ( aMessage && strlen(aMessage) )
8341
+				{
8342
+						strcat(lDialogString, aMessage) ;
8343
+				}
8344
+				strcat(lDialogString, "\" ");
8345
 
8346
-                if ( lWasGraphicDialog )
8347
-                {
8348
-                        if (aDialogType && !strcmp("yesnocancel", aDialogType))
8349
-                        {
8350
-                                strcat(lDialogString,"0 60 0 Yes \"\" No \"\") 2>/tmp/tinyfd.txt;\
8351
+				if ( lWasGraphicDialog )
8352
+				{
8353
+						if (aDialogType && !strcmp("yesnocancel", aDialogType))
8354
+						{
8355
+								strcat(lDialogString,"0 60 0 Yes \"\" No \"\") 2>/tmp/tinyfd.txt;\
8356
 if [ $? = 0 ];then tinyfdBool=1;else tinyfdBool=0;fi;\
8357
 tinyfdRes=$(cat /tmp/tinyfd.txt);echo $tinyfdBool$tinyfdRes") ;
8358
-                        }
8359
-                        else
8360
-                        {
8361
-                                strcat(lDialogString,
8362
-                                   "10 60 ) 2>&1;if [ $? = 0 ];then echo 1;else echo 0;fi");
8363
-                        }
8364
-                }
8365
-                else
8366
-                {
8367
-                        if (aDialogType && !strcmp("yesnocancel", aDialogType))
8368
-                        {
8369
-                                strcat(lDialogString,"0 60 0 Yes \"\" No \"\" >/dev/tty ) 2>/tmp/tinyfd.txt;\
8370
-                if [ $? = 0 ];then tinyfdBool=1;else tinyfdBool=0;fi;\
8371
-                tinyfdRes=$(cat /tmp/tinyfd.txt);echo $tinyfdBool$tinyfdRes") ;
8372
+						}
8373
+						else
8374
+						{
8375
+								strcat(lDialogString,
8376
+								   "10 60 ) 2>&1;if [ $? = 0 ];then echo 1;else echo 0;fi");
8377
+						}
8378
+				}
8379
+				else
8380
+				{
8381
+						if (aDialogType && !strcmp("yesnocancel", aDialogType))
8382
+						{
8383
+								strcat(lDialogString,"0 60 0 Yes \"\" No \"\" >/dev/tty ) 2>/tmp/tinyfd.txt;\
8384
+				if [ $? = 0 ];then tinyfdBool=1;else tinyfdBool=0;fi;\
8385
+				tinyfdRes=$(cat /tmp/tinyfd.txt);echo $tinyfdBool$tinyfdRes") ;
8386
 
8387
-                                if ( lWasXterm )
8388
-                                {
8389
-                                        strcat(lDialogString," >/tmp/tinyfd0.txt';cat /tmp/tinyfd0.txt");
8390
-                                }
8391
-                                else
8392
-                                {
8393
-                                        strcat(lDialogString, "; clear >/dev/tty") ;
8394
-                                }
8395
-                        }
8396
-                        else
8397
-                        {
8398
-                                strcat(lDialogString, "10 60 >/dev/tty) 2>&1;if [ $? = 0 ];");
8399
-                                if ( lWasXterm )
8400
-                                {
8401
-                                        strcat( lDialogString ,
8402
+								if ( lWasXterm )
8403
+								{
8404
+										strcat(lDialogString," >/tmp/tinyfd0.txt';cat /tmp/tinyfd0.txt");
8405
+								}
8406
+								else
8407
+								{
8408
+										strcat(lDialogString, "; clear >/dev/tty") ;
8409
+								}
8410
+						}
8411
+						else
8412
+						{
8413
+								strcat(lDialogString, "10 60 >/dev/tty) 2>&1;if [ $? = 0 ];");
8414
+								if ( lWasXterm )
8415
+								{
8416
+										strcat( lDialogString ,
8417
 "then\n\techo 1\nelse\n\techo 0\nfi >/tmp/tinyfd.txt';cat /tmp/tinyfd.txt;rm /tmp/tinyfd.txt");
8418
-                                }
8419
-                                else
8420
-                                {
8421
-                                   strcat(lDialogString,
8422
-                                                  "then echo 1;else echo 0;fi;clear >/dev/tty");
8423
-                                }
8424
-                        }
8425
-                }
8426
-        }
8427
-        else if (  !isTerminalRunning() && terminalName() )
8428
-        {
8429
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return 0;}
8430
-                strcpy( lDialogString , terminalName() ) ;
8431
-                strcat( lDialogString , "'" ) ;
8432
-                if ( !gWarningDisplayed && !tinyfd_forceConsole)
8433
-                {
8434
-                        gWarningDisplayed = 1 ;
8435
-                        strcat( lDialogString , "echo \"" ) ;
8436
-                        strcat( lDialogString, gTitle) ;
8437
-                        strcat( lDialogString , "\";" ) ;
8438
-                        strcat( lDialogString , "echo \"" ) ;
8439
-                        strcat( lDialogString, tinyfd_needs) ;
8440
-                        strcat( lDialogString , "\";echo;echo;" ) ;
8441
-                }
8442
-                if ( aTitle && strlen(aTitle) )
8443
-                {
8444
-                        strcat( lDialogString , "echo \"" ) ;
8445
-                        strcat( lDialogString, aTitle) ;
8446
-                        strcat( lDialogString , "\";echo;" ) ;
8447
-                }
8448
-                if ( aMessage && strlen(aMessage) )
8449
-                {
8450
-                        strcat( lDialogString , "echo \"" ) ;
8451
-                        strcat( lDialogString, aMessage) ;
8452
-                        strcat( lDialogString , "\"; " ) ;
8453
-                }
8454
-                if ( aDialogType && !strcmp("yesno",aDialogType) )
8455
-                {
8456
-                        strcat( lDialogString , "echo -n \"y/n: \"; " ) ;
8457
-                        strcat( lDialogString , "stty sane -echo;" ) ;
8458
-                        strcat( lDialogString ,
8459
-                                "answer=$( while ! head -c 1 | grep -i [ny];do true ;done);");
8460
-                        strcat( lDialogString ,
8461
-                                "if echo \"$answer\" | grep -iq \"^y\";then\n");
8462
-                        strcat( lDialogString , "\techo 1\nelse\n\techo 0\nfi" ) ;
8463
-                }
8464
-                else if ( aDialogType && !strcmp("okcancel",aDialogType) )
8465
-                {
8466
-                        strcat( lDialogString , "echo -n \"[O]kay/[C]ancel: \"; " ) ;
8467
-                        strcat( lDialogString , "stty sane -echo;" ) ;
8468
-                        strcat( lDialogString ,
8469
-                                "answer=$( while ! head -c 1 | grep -i [oc];do true ;done);");
8470
-                        strcat( lDialogString ,
8471
-                                "if echo \"$answer\" | grep -iq \"^o\";then\n");
8472
-                        strcat( lDialogString , "\techo 1\nelse\n\techo 0\nfi" ) ;
8473
-                }
8474
-                else if ( aDialogType && !strcmp("yesnocancel",aDialogType) )
8475
-                {
8476
-                        strcat( lDialogString , "echo -n \"[Y]es/[N]o/[C]ancel: \"; " ) ;
8477
-                        strcat( lDialogString , "stty sane -echo;" ) ;
8478
-                        strcat( lDialogString ,
8479
-                                "answer=$( while ! head -c 1 | grep -i [nyc];do true ;done);");
8480
-                        strcat( lDialogString ,
8481
-                                "if echo \"$answer\" | grep -iq \"^y\";then\n\techo 1\n");
8482
-                        strcat( lDialogString , "elif echo \"$answer\" | grep -iq \"^n\";then\n\techo 2\n" ) ;
8483
-                        strcat( lDialogString , "else\n\techo 0\nfi" ) ;
8484
-                }
8485
-                else
8486
-                {
8487
-                        strcat(lDialogString , "echo -n \"press enter to continue \"; ");
8488
-                        strcat( lDialogString , "stty sane -echo;" ) ;
8489
-                        strcat( lDialogString ,
8490
-                                "answer=$( while ! head -c 1;do true ;done);echo 1");
8491
-                }
8492
-                strcat( lDialogString ,
8493
-                        " >/tmp/tinyfd.txt';cat /tmp/tinyfd.txt;rm /tmp/tinyfd.txt");
8494
-        }
8495
-        else if ( !isTerminalRunning() && pythonDbusPresent() && !strcmp("ok" , aDialogType) )
8496
-        {
8497
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python-dbus");return 1;}
8498
-                strcpy( lDialogString , gPythonName ) ;
8499
-                strcat( lDialogString ," -c \"import dbus;bus=dbus.SessionBus();");
8500
-                strcat( lDialogString ,"notif=bus.get_object('org.freedesktop.Notifications','/org/freedesktop/Notifications');" ) ;
8501
-                strcat( lDialogString ,"notify=dbus.Interface(notif,'org.freedesktop.Notifications');" ) ;
8502
-                strcat( lDialogString ,"notify.Notify('',0,'" ) ;
8503
-                if ( aIconType && strlen(aIconType) )
8504
-                {
8505
-                        strcat( lDialogString , aIconType ) ;
8506
-                }
8507
-                strcat(lDialogString, "','") ;
8508
-                if ( aTitle && strlen(aTitle) )
8509
-                {
8510
-                        strcat(lDialogString, aTitle) ;
8511
-                }
8512
-                strcat(lDialogString, "','") ;
8513
-                if ( aMessage && strlen(aMessage) )
8514
-                {
8515
-                        lpDialogString = lDialogString + strlen(lDialogString);
8516
-                        tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
8517
-                }
8518
-                strcat(lDialogString, "','','',5000)\"") ;
8519
-        }
8520
-        else if ( !isTerminalRunning() && (perlPresent() >= 2)  && !strcmp("ok" , aDialogType) )
8521
-        {
8522
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"perl-dbus");return 1;}
8523
+								}
8524
+								else
8525
+								{
8526
+								   strcat(lDialogString,
8527
+												  "then echo 1;else echo 0;fi;clear >/dev/tty");
8528
+								}
8529
+						}
8530
+				}
8531
+		}
8532
+		else if (  !isTerminalRunning() && terminalName() )
8533
+		{
8534
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return 0;}
8535
+				strcpy( lDialogString , terminalName() ) ;
8536
+				strcat( lDialogString , "'" ) ;
8537
+				if ( !gWarningDisplayed && !tinyfd_forceConsole)
8538
+				{
8539
+						gWarningDisplayed = 1 ;
8540
+						strcat( lDialogString , "echo \"" ) ;
8541
+						strcat( lDialogString, gTitle) ;
8542
+						strcat( lDialogString , "\";" ) ;
8543
+						strcat( lDialogString , "echo \"" ) ;
8544
+						strcat( lDialogString, tinyfd_needs) ;
8545
+						strcat( lDialogString , "\";echo;echo;" ) ;
8546
+				}
8547
+				if ( aTitle && strlen(aTitle) )
8548
+				{
8549
+						strcat( lDialogString , "echo \"" ) ;
8550
+						strcat( lDialogString, aTitle) ;
8551
+						strcat( lDialogString , "\";echo;" ) ;
8552
+				}
8553
+				if ( aMessage && strlen(aMessage) )
8554
+				{
8555
+						strcat( lDialogString , "echo \"" ) ;
8556
+						strcat( lDialogString, aMessage) ;
8557
+						strcat( lDialogString , "\"; " ) ;
8558
+				}
8559
+				if ( aDialogType && !strcmp("yesno",aDialogType) )
8560
+				{
8561
+						strcat( lDialogString , "echo -n \"y/n: \"; " ) ;
8562
+						strcat( lDialogString , "stty sane -echo;" ) ;
8563
+						strcat( lDialogString ,
8564
+								"answer=$( while ! head -c 1 | grep -i [ny];do true ;done);");
8565
+						strcat( lDialogString ,
8566
+								"if echo \"$answer\" | grep -iq \"^y\";then\n");
8567
+						strcat( lDialogString , "\techo 1\nelse\n\techo 0\nfi" ) ;
8568
+				}
8569
+				else if ( aDialogType && !strcmp("okcancel",aDialogType) )
8570
+				{
8571
+						strcat( lDialogString , "echo -n \"[O]kay/[C]ancel: \"; " ) ;
8572
+						strcat( lDialogString , "stty sane -echo;" ) ;
8573
+						strcat( lDialogString ,
8574
+								"answer=$( while ! head -c 1 | grep -i [oc];do true ;done);");
8575
+						strcat( lDialogString ,
8576
+								"if echo \"$answer\" | grep -iq \"^o\";then\n");
8577
+						strcat( lDialogString , "\techo 1\nelse\n\techo 0\nfi" ) ;
8578
+				}
8579
+				else if ( aDialogType && !strcmp("yesnocancel",aDialogType) )
8580
+				{
8581
+						strcat( lDialogString , "echo -n \"[Y]es/[N]o/[C]ancel: \"; " ) ;
8582
+						strcat( lDialogString , "stty sane -echo;" ) ;
8583
+						strcat( lDialogString ,
8584
+								"answer=$( while ! head -c 1 | grep -i [nyc];do true ;done);");
8585
+						strcat( lDialogString ,
8586
+								"if echo \"$answer\" | grep -iq \"^y\";then\n\techo 1\n");
8587
+						strcat( lDialogString , "elif echo \"$answer\" | grep -iq \"^n\";then\n\techo 2\n" ) ;
8588
+						strcat( lDialogString , "else\n\techo 0\nfi" ) ;
8589
+				}
8590
+				else
8591
+				{
8592
+						strcat(lDialogString , "echo -n \"press enter to continue \"; ");
8593
+						strcat( lDialogString , "stty sane -echo;" ) ;
8594
+						strcat( lDialogString ,
8595
+								"answer=$( while ! head -c 1;do true ;done);echo 1");
8596
+				}
8597
+				strcat( lDialogString ,
8598
+						" >/tmp/tinyfd.txt';cat /tmp/tinyfd.txt;rm /tmp/tinyfd.txt");
8599
+		}
8600
+		else if ( !isTerminalRunning() && pythonDbusPresent() && !strcmp("ok" , aDialogType) )
8601
+		{
8602
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python-dbus");return 1;}
8603
+				strcpy( lDialogString , gPythonName ) ;
8604
+				strcat( lDialogString ," -c \"import dbus;bus=dbus.SessionBus();");
8605
+				strcat( lDialogString ,"notif=bus.get_object('org.freedesktop.Notifications','/org/freedesktop/Notifications');" ) ;
8606
+				strcat( lDialogString ,"notify=dbus.Interface(notif,'org.freedesktop.Notifications');" ) ;
8607
+				strcat( lDialogString ,"notify.Notify('',0,'" ) ;
8608
+				if ( aIconType && strlen(aIconType) )
8609
+				{
8610
+						strcat( lDialogString , aIconType ) ;
8611
+				}
8612
+				strcat(lDialogString, "','") ;
8613
+				if ( aTitle && strlen(aTitle) )
8614
+				{
8615
+						strcat(lDialogString, aTitle) ;
8616
+				}
8617
+				strcat(lDialogString, "','") ;
8618
+				if ( aMessage && strlen(aMessage) )
8619
+				{
8620
+						lpDialogString = lDialogString + strlen(lDialogString);
8621
+						tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
8622
+				}
8623
+				strcat(lDialogString, "','','',5000)\"") ;
8624
+		}
8625
+		else if ( !isTerminalRunning() && (perlPresent() >= 2)  && !strcmp("ok" , aDialogType) )
8626
+		{
8627
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"perl-dbus");return 1;}
8628
 
8629
-				strcpy( lDialogString ,  "perl -e \"use Net::DBus;\
8630
+								strcpy( lDialogString ,  "perl -e \"use Net::DBus;\
8631
 my \\$sessionBus = Net::DBus->session;\
8632
 my \\$notificationsService = \\$sessionBus->get_service('org.freedesktop.Notifications');\
8633
 my \\$notificationsObject = \\$notificationsService->get_object('/org/freedesktop/Notifications',\
8634
 'org.freedesktop.Notifications');");
8635
 
8636
-				sprintf( lDialogString + strlen(lDialogString),
8637
+								sprintf( lDialogString + strlen(lDialogString),
8638
 "my \\$notificationId;\\$notificationId = \\$notificationsObject->Notify(shift, 0, '%s', '%s', '%s', [], {}, -1);\" ",
8639
-							aIconType?aIconType:"", aTitle?aTitle:"", aMessage?aMessage:"" ) ;
8640
-        }
8641
-        else if ( !isTerminalRunning() && notifysendPresent() && !strcmp("ok" , aDialogType) )
8642
-        {
8643
+														aIconType?aIconType:"", aTitle?aTitle:"", aMessage?aMessage:"" ) ;
8644
+		}
8645
+		else if ( !isTerminalRunning() && notifysendPresent() && !strcmp("ok" , aDialogType) )
8646
+		{
8647
 
8648
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"notifysend");return 1;}
8649
-                strcpy( lDialogString , "notify-send" ) ;
8650
-                if ( aIconType && strlen(aIconType) )
8651
-                {
8652
-                        strcat( lDialogString , " -i '" ) ;
8653
-                        strcat( lDialogString , aIconType ) ;
8654
-                        strcat( lDialogString , "'" ) ;
8655
-                }
8656
-        strcat( lDialogString , " \"" ) ;
8657
-                if ( aTitle && strlen(aTitle) )
8658
-                {
8659
-                        strcat(lDialogString, aTitle) ;
8660
-                        strcat( lDialogString , " | " ) ;
8661
-                }
8662
-                if ( aMessage && strlen(aMessage) )
8663
-                {
8664
-            tfd_replaceSubStr( aMessage , "\n\t" , " |  " , lBuff ) ;
8665
-            tfd_replaceSubStr( aMessage , "\n" , " | " , lBuff ) ;
8666
-            tfd_replaceSubStr( aMessage , "\t" , "  " , lBuff ) ;
8667
-                        strcat(lDialogString, lBuff) ;
8668
-                }
8669
-                strcat( lDialogString , "\"" ) ;
8670
-        }
8671
-        else
8672
-        {
8673
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return 0;}
8674
-                if ( !gWarningDisplayed && !tinyfd_forceConsole)
8675
-                {
8676
-                        gWarningDisplayed = 1 ;
8677
-                        printf("\n\n%s\n", gTitle);
8678
-                        printf("%s\n\n", tinyfd_needs);
8679
-                }
8680
-                if ( aTitle && strlen(aTitle) )
8681
-                {
8682
-                        printf("\n%s\n", aTitle);
8683
-                }
8684
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"notifysend");return 1;}
8685
+				strcpy( lDialogString , "notify-send" ) ;
8686
+				if ( aIconType && strlen(aIconType) )
8687
+				{
8688
+						strcat( lDialogString , " -i '" ) ;
8689
+						strcat( lDialogString , aIconType ) ;
8690
+						strcat( lDialogString , "'" ) ;
8691
+				}
8692
+		strcat( lDialogString , " \"" ) ;
8693
+				if ( aTitle && strlen(aTitle) )
8694
+				{
8695
+						strcat(lDialogString, aTitle) ;
8696
+						strcat( lDialogString , " | " ) ;
8697
+				}
8698
+				if ( aMessage && strlen(aMessage) )
8699
+				{
8700
+			tfd_replaceSubStr( aMessage , "\n\t" , " |  " , lBuff ) ;
8701
+			tfd_replaceSubStr( aMessage , "\n" , " | " , lBuff ) ;
8702
+			tfd_replaceSubStr( aMessage , "\t" , "  " , lBuff ) ;
8703
+						strcat(lDialogString, lBuff) ;
8704
+				}
8705
+				strcat( lDialogString , "\"" ) ;
8706
+		}
8707
+		else
8708
+		{
8709
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return 0;}
8710
+				if ( !gWarningDisplayed && !tinyfd_forceConsole)
8711
+				{
8712
+						gWarningDisplayed = 1 ;
8713
+						printf("\n\n%s\n", gTitle);
8714
+						printf("%s\n\n", tinyfd_needs);
8715
+				}
8716
+				if ( aTitle && strlen(aTitle) )
8717
+				{
8718
+						printf("\n%s\n", aTitle);
8719
+				}
8720
 
8721
-                tcgetattr(0, &infoOri);
8722
-                tcgetattr(0, &info);
8723
-                info.c_lflag &= ~ICANON;
8724
-                info.c_cc[VMIN] = 1;
8725
-                info.c_cc[VTIME] = 0;
8726
-                tcsetattr(0, TCSANOW, &info);
8727
-                if ( aDialogType && !strcmp("yesno",aDialogType) )
8728
-                {
8729
-                        do
8730
-                        {
8731
-                                if ( aMessage && strlen(aMessage) )
8732
-                                {
8733
-                                        printf("\n%s\n",aMessage);
8734
-                                }
8735
-                                printf("y/n: "); fflush(stdout);
8736
-                                lChar = tolower( getchar() ) ;
8737
-                                printf("\n\n");
8738
-                        }
8739
-                        while ( lChar != 'y' && lChar != 'n' );
8740
-                        lResult = lChar == 'y' ? 1 : 0 ;
8741
-                }
8742
-                else if ( aDialogType && !strcmp("okcancel",aDialogType) )
8743
-                {
8744
-                        do
8745
-                        {
8746
-                                if ( aMessage && strlen(aMessage) )
8747
-                                {
8748
-                                        printf("\n%s\n",aMessage);
8749
-                                }
8750
-                                printf("[O]kay/[C]ancel: "); fflush(stdout);
8751
-                                lChar = tolower( getchar() ) ;
8752
-                                printf("\n\n");
8753
-                        }
8754
-                        while ( lChar != 'o' && lChar != 'c' );
8755
-                        lResult = lChar == 'o' ? 1 : 0 ;
8756
-                }
8757
-                else if ( aDialogType && !strcmp("yesnocancel",aDialogType) )
8758
-                {
8759
-                        do
8760
-                        {
8761
-                                if ( aMessage && strlen(aMessage) )
8762
-                                {
8763
-                                        printf("\n%s\n",aMessage);
8764
-                                }
8765
-                                printf("[Y]es/[N]o/[C]ancel: "); fflush(stdout);
8766
-                                lChar = tolower( getchar() ) ;
8767
-                                printf("\n\n");
8768
-                        }
8769
-                        while ( lChar != 'y' && lChar != 'n' && lChar != 'c' );
8770
-                        lResult = (lChar == 'y') ? 1 : (lChar == 'n') ? 2 : 0 ;
8771
-                }
8772
-                else
8773
-                {
8774
-                        if ( aMessage && strlen(aMessage) )
8775
-                        {
8776
-                                printf("\n%s\n\n",aMessage);
8777
-                        }
8778
-                        printf("press enter to continue "); fflush(stdout);
8779
-                        getchar() ;
8780
-                        printf("\n\n");
8781
-                        lResult = 1 ;
8782
-                }
8783
-                tcsetattr(0, TCSANOW, &infoOri);
8784
-                free(lDialogString);
8785
-                return lResult ;
8786
-        }
8787
+				tcgetattr(0, &infoOri);
8788
+				tcgetattr(0, &info);
8789
+				info.c_lflag &= ~ICANON;
8790
+				info.c_cc[VMIN] = 1;
8791
+				info.c_cc[VTIME] = 0;
8792
+				tcsetattr(0, TCSANOW, &info);
8793
+				if ( aDialogType && !strcmp("yesno",aDialogType) )
8794
+				{
8795
+						do
8796
+						{
8797
+								if ( aMessage && strlen(aMessage) )
8798
+								{
8799
+										printf("\n%s\n",aMessage);
8800
+								}
8801
+								printf("y/n: "); fflush(stdout);
8802
+								lChar = (char) tolower( getchar() ) ;
8803
+								printf("\n\n");
8804
+						}
8805
+						while ( lChar != 'y' && lChar != 'n' );
8806
+						lResult = lChar == 'y' ? 1 : 0 ;
8807
+				}
8808
+				else if ( aDialogType && !strcmp("okcancel",aDialogType) )
8809
+				{
8810
+						do
8811
+						{
8812
+								if ( aMessage && strlen(aMessage) )
8813
+								{
8814
+										printf("\n%s\n",aMessage);
8815
+								}
8816
+								printf("[O]kay/[C]ancel: "); fflush(stdout);
8817
+								lChar = (char) tolower( getchar() ) ;
8818
+								printf("\n\n");
8819
+						}
8820
+						while ( lChar != 'o' && lChar != 'c' );
8821
+						lResult = lChar == 'o' ? 1 : 0 ;
8822
+				}
8823
+				else if ( aDialogType && !strcmp("yesnocancel",aDialogType) )
8824
+				{
8825
+						do
8826
+						{
8827
+								if ( aMessage && strlen(aMessage) )
8828
+								{
8829
+										printf("\n%s\n",aMessage);
8830
+								}
8831
+								printf("[Y]es/[N]o/[C]ancel: "); fflush(stdout);
8832
+								lChar = (char) tolower( getchar() ) ;
8833
+								printf("\n\n");
8834
+						}
8835
+						while ( lChar != 'y' && lChar != 'n' && lChar != 'c' );
8836
+						lResult = (lChar == 'y') ? 1 : (lChar == 'n') ? 2 : 0 ;
8837
+				}
8838
+				else
8839
+				{
8840
+						if ( aMessage && strlen(aMessage) )
8841
+						{
8842
+								printf("\n%s\n\n",aMessage);
8843
+						}
8844
+						printf("press enter to continue "); fflush(stdout);
8845
+						getchar() ;
8846
+						printf("\n\n");
8847
+						lResult = 1 ;
8848
+				}
8849
+				tcsetattr(0, TCSANOW, &infoOri);
8850
+				free(lDialogString);
8851
+				return lResult ;
8852
+		}
8853
 
8854
-        if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
8855
+		if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
8856
 
8857
-        if ( ! ( lIn = popen( lDialogString , "r" ) ) )
8858
-        {
8859
-                free(lDialogString);
8860
-                return 0 ;
8861
-        }
8862
-        while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
8863
-        {}
8864
+		if ( ! ( lIn = popen( lDialogString , "r" ) ) )
8865
+		{
8866
+				free(lDialogString);
8867
+				return 0 ;
8868
+		}
8869
+		while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
8870
+		{}
8871
 
8872
-        pclose( lIn ) ;
8873
+		pclose( lIn ) ;
8874
 
8875
-        /* printf( "lBuff: %s len: %lu \n" , lBuff , strlen(lBuff) ) ; */
8876
-        if ( lBuff[strlen( lBuff ) -1] == '\n' )
8877
-        {
8878
-                lBuff[strlen( lBuff ) -1] = '\0' ;
8879
-        }
8880
-        /* printf( "lBuff1: %s len: %lu \n" , lBuff , strlen(lBuff) ) ; */
8881
+		/* printf( "lBuff: %s len: %lu \n" , lBuff , strlen(lBuff) ) ; */
8882
+		if ( strlen( lBuff ) && lBuff[strlen( lBuff ) -1] == '\n' )
8883
+		{
8884
+				lBuff[strlen( lBuff ) -1] = '\0' ;
8885
+		}
8886
+		/* printf( "lBuff1: %s len: %lu \n" , lBuff , strlen(lBuff) ) ; */
8887
 
8888
-        if (aDialogType && !strcmp("yesnocancel", aDialogType))
8889
-        {
8890
-                if ( lBuff[0]=='1' )
8891
-                {
8892
-                        if ( !strcmp( lBuff+1 , "Yes" )) strcpy(lBuff,"1");
8893
-                        else if ( !strcmp( lBuff+1 , "No" )) strcpy(lBuff,"2");
8894
-                }
8895
-        }
8896
-        /* printf( "lBuff2: %s len: %lu \n" , lBuff , strlen(lBuff) ) ; */
8897
+		if (aDialogType && !strcmp("yesnocancel", aDialogType))
8898
+		{
8899
+				if ( lBuff[0]=='1' )
8900
+				{
8901
+						if ( !strcmp( lBuff+1 , "Yes" )) strcpy(lBuff,"1");
8902
+						else if ( !strcmp( lBuff+1 , "No" )) strcpy(lBuff,"2");
8903
+				}
8904
+		}
8905
+		/* printf( "lBuff2: %s len: %lu \n" , lBuff , strlen(lBuff) ) ; */
8906
 
8907
-        lResult =  !strcmp( lBuff , "2" ) ? 2 : !strcmp( lBuff , "1" ) ? 1 : 0;
8908
+		lResult =  !strcmp( lBuff , "2" ) ? 2 : !strcmp( lBuff , "1" ) ? 1 : 0;
8909
 
8910
-        /* printf( "lResult: %d\n" , lResult ) ; */
8911
-        free(lDialogString);
8912
-        return lResult ;
8913
+		/* printf( "lResult: %d\n" , lResult ) ; */
8914
+		free(lDialogString);
8915
+		return lResult ;
8916
 }
8917
 
8918
 
8919
 /* return has only meaning for tinyfd_query */
8920
 int tinyfd_notifyPopup(
8921
-        char const * aTitle , /* NULL or "" */
8922
-        char const * aMessage , /* NULL or ""  may contain \n and \t */
8923
-        char const * aIconType ) /* "info" "warning" "error" */
8924
+		char const * aTitle , /* NULL or "" */
8925
+		char const * aMessage , /* NULL or ""  may contain \n and \t */
8926
+		char const * aIconType ) /* "info" "warning" "error" */
8927
 {
8928
-    char lBuff[MAX_PATH_OR_CMD];
8929
-        char * lDialogString = NULL ;
8930
-    char * lpDialogString ;
8931
-        FILE * lIn ;
8932
-        size_t lTitleLen ;
8933
-        size_t lMessageLen ;
8934
+		char lBuff[MAX_PATH_OR_CMD];
8935
+		char * lDialogString = NULL ;
8936
+		char * lpDialogString ;
8937
+		FILE * lIn ;
8938
+		size_t lTitleLen ;
8939
+		size_t lMessageLen ;
8940
 
8941
-		if (tfd_quoteDetected(aTitle)) return tinyfd_notifyPopup("INVALID TITLE WITH QUOTES", aMessage, aIconType);
8942
-		if (tfd_quoteDetected(aMessage)) return tinyfd_notifyPopup(aTitle, "INVALID MESSAGE WITH QUOTES", aIconType);
8943
+				if (tfd_quoteDetected(aTitle)) return tinyfd_notifyPopup("INVALID TITLE WITH QUOTES", aMessage, aIconType);
8944
+				if (tfd_quoteDetected(aMessage)) return tinyfd_notifyPopup(aTitle, "INVALID MESSAGE WITH QUOTES", aIconType);
8945
 
8946
-        if ( getenv("SSH_TTY") )
8947
-        {
8948
-                return tinyfd_messageBox(aTitle, aMessage, "ok", aIconType, 0);
8949
-        }
8950
+		if ( getenv("SSH_TTY") && !dunstifyPresent() && !dunstPresent() )
8951
+		{
8952
+			return tinyfd_messageBox(aTitle, aMessage, "ok", aIconType, 0);
8953
+		}
8954
 
8955
-        lTitleLen =  aTitle ? strlen(aTitle) : 0 ;
8956
-        lMessageLen =  aMessage ? strlen(aMessage) : 0 ;
8957
-        if ( !aTitle || strcmp(aTitle,"tinyfd_query") )
8958
-        {
8959
-                lDialogString = (char *) malloc( MAX_PATH_OR_CMD + lTitleLen + lMessageLen );
8960
-        }
8961
+		lTitleLen =  aTitle ? strlen(aTitle) : 0 ;
8962
+		lMessageLen =  aMessage ? strlen(aMessage) : 0 ;
8963
+		if ( !aTitle || strcmp(aTitle,"tinyfd_query") )
8964
+		{
8965
+			lDialogString = (char *) malloc( MAX_PATH_OR_CMD + lTitleLen + lMessageLen );
8966
+		}
8967
 
8968
-        if ( osascriptPresent( ) )
8969
-        {
8970
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return 1;}
8971
+		if ( getenv("SSH_TTY") )
8972
+		{
8973
+			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dunst");return 1;}
8974
+			strcpy( lDialogString , "notify-send \"" ) ;
8975
+			if ( aTitle && strlen(aTitle) )
8976
+			{
8977
+				strcat( lDialogString , aTitle ) ;
8978
+				strcat( lDialogString , "\" \"" ) ;
8979
+			}
8980
+			if ( aMessage && strlen(aMessage) )
8981
+			{
8982
+				strcat(lDialogString, aMessage) ;
8983
+			}
8984
+			strcat( lDialogString , "\"" ) ;
8985
+		}
8986
+		else if ( osascriptPresent( ) )
8987
+		{
8988
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return 1;}
8989
 
8990
-                strcpy( lDialogString , "osascript ");
8991
-                if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
8992
-                strcat( lDialogString , " -e 'try' -e 'display notification \"") ;
8993
-                if ( aMessage && strlen(aMessage) )
8994
-                {
8995
-                        strcat(lDialogString, aMessage) ;
8996
-                }
8997
-                strcat(lDialogString, " \" ") ;
8998
-                if ( aTitle && strlen(aTitle) )
8999
-                {
9000
-                        strcat(lDialogString, "with title \"") ;
9001
-                        strcat(lDialogString, aTitle) ;
9002
-                        strcat(lDialogString, "\" ") ;
9003
-                }
9004
+				strcpy( lDialogString , "osascript ");
9005
+				if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
9006
+				strcat( lDialogString , " -e 'try' -e 'display notification \"") ;
9007
+				if ( aMessage && strlen(aMessage) )
9008
+				{
9009
+						strcat(lDialogString, aMessage) ;
9010
+				}
9011
+				strcat(lDialogString, " \" ") ;
9012
+				if ( aTitle && strlen(aTitle) )
9013
+				{
9014
+						strcat(lDialogString, "with title \"") ;
9015
+						strcat(lDialogString, aTitle) ;
9016
+						strcat(lDialogString, "\" ") ;
9017
+				}
9018
 
9019
-                strcat( lDialogString, "' -e 'end try'") ;
9020
-                if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
9021
-        }
9022
-        else if ( tfd_kdialogPresent() )
9023
-        {
9024
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return 1;}
9025
-                strcpy( lDialogString , "kdialog" ) ;
9026
+				strcat( lDialogString, "' -e 'end try'") ;
9027
+				if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
9028
+		}
9029
+		else if ( tfd_kdialogPresent() )
9030
+		{
9031
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return 1;}
9032
+				strcpy( lDialogString , "kdialog" ) ;
9033
 
9034
-                if ( aIconType && strlen(aIconType) )
9035
-                {
9036
-                        strcat( lDialogString , " --icon '" ) ;
9037
-                        strcat( lDialogString , aIconType ) ;
9038
-                        strcat( lDialogString , "'" ) ;
9039
-                }
9040
-                if ( aTitle && strlen(aTitle) )
9041
-                {
9042
-                        strcat( lDialogString , " --title \"" ) ;
9043
-                        strcat( lDialogString , aTitle ) ;
9044
-                        strcat( lDialogString , "\"" ) ;
9045
-                }
9046
+				if ( aIconType && strlen(aIconType) )
9047
+				{
9048
+						strcat( lDialogString , " --icon '" ) ;
9049
+						strcat( lDialogString , aIconType ) ;
9050
+						strcat( lDialogString , "'" ) ;
9051
+				}
9052
+				if ( aTitle && strlen(aTitle) )
9053
+				{
9054
+						strcat( lDialogString , " --title \"" ) ;
9055
+						strcat( lDialogString , aTitle ) ;
9056
+						strcat( lDialogString , "\"" ) ;
9057
+				}
9058
 
9059
-                strcat( lDialogString , " --passivepopup" ) ;
9060
-                strcat( lDialogString , " \"" ) ;
9061
-                if ( aMessage )
9062
-                {
9063
-                        strcat( lDialogString , aMessage ) ;
9064
-                }
9065
-                strcat( lDialogString , " \" 5" ) ;
9066
-        }
9067
-        else if ( (tfd_zenity3Present()>=5) )
9068
-        {
9069
-                /* zenity 2.32 & 3.14 has the notification but with a bug: it doesnt return from it */
9070
-                /* zenity 3.8 show the notification as an alert ok cancel box */
9071
-                if ( tfd_zenity3Present()>=5 )
9072
-                {
9073
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return 1;}
9074
-                        strcpy( lDialogString , "zenity" ) ;
9075
-                }
9076
+				strcat( lDialogString , " --passivepopup" ) ;
9077
+				strcat( lDialogString , " \"" ) ;
9078
+				if ( aMessage )
9079
+				{
9080
+						strcat( lDialogString , aMessage ) ;
9081
+				}
9082
+				strcat( lDialogString , " \" 5" ) ;
9083
+		}
9084
+		else if ( tfd_yadPresent() )
9085
+		{
9086
+			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"yad");return 1;}
9087
+			strcpy( lDialogString , "yad --notification");
9088
 
9089
-                strcat( lDialogString , " --notification");
9090
+			if ( aIconType && strlen( aIconType ) )
9091
+			{
9092
+					strcat( lDialogString , " --image=\"");
9093
+					strcat( lDialogString , aIconType ) ;
9094
+					strcat( lDialogString , "\"" ) ;
9095
+			}
9096
 
9097
-                if ( aIconType && strlen( aIconType ) )
9098
-                {
9099
-                        strcat( lDialogString , " --window-icon '");
9100
-                        strcat( lDialogString , aIconType ) ;
9101
-                        strcat( lDialogString , "'" ) ;
9102
-                }
9103
+			strcat( lDialogString , " --text=\"" ) ;
9104
+			if ( aTitle && strlen(aTitle) )
9105
+			{
9106
+					strcat(lDialogString, aTitle) ;
9107
+					strcat(lDialogString, "\n") ;
9108
+			}
9109
+			if ( aMessage && strlen( aMessage ) )
9110
+			{
9111
+					strcat( lDialogString , aMessage ) ;
9112
+			}
9113
+			strcat( lDialogString , " \"" ) ;
9114
+		}
9115
+		else if ( perlPresent() >= 2 )
9116
+		{
9117
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"perl-dbus");return 1;}
9118
 
9119
-                strcat( lDialogString , " --text \"" ) ;
9120
-                if ( aTitle && strlen(aTitle) )
9121
-                {
9122
-                        strcat(lDialogString, aTitle) ;
9123
-                        strcat(lDialogString, "\n") ;
9124
-                }
9125
-                if ( aMessage && strlen( aMessage ) )
9126
-                {
9127
-                        strcat( lDialogString , aMessage ) ;
9128
-                }
9129
-                strcat( lDialogString , " \"" ) ;
9130
-        }
9131
-        else if ( perlPresent() >= 2 )
9132
-        {
9133
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"perl-dbus");return 1;}
9134
-
9135
 				strcpy( lDialogString , "perl -e \"use Net::DBus;\
9136
 my \\$sessionBus = Net::DBus->session;\
9137
 my \\$notificationsService = \\$sessionBus->get_service('org.freedesktop.Notifications');\
9138
@@ -5281,2303 +5446,2445 @@
9139
 				sprintf( lDialogString + strlen(lDialogString) ,
9140
 "my \\$notificationId;\\$notificationId = \\$notificationsObject->Notify(shift, 0, '%s', '%s', '%s', [], {}, -1);\" ",
9141
 aIconType?aIconType:"", aTitle?aTitle:"", aMessage?aMessage:"" ) ;
9142
-        }
9143
-        else if ( pythonDbusPresent( ) )
9144
-        {
9145
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python-dbus");return 1;}
9146
-                strcpy( lDialogString , gPythonName ) ;
9147
-                strcat( lDialogString ," -c \"import dbus;bus=dbus.SessionBus();");
9148
-                strcat( lDialogString ,"notif=bus.get_object('org.freedesktop.Notifications','/org/freedesktop/Notifications');" ) ;
9149
-                strcat( lDialogString ,"notify=dbus.Interface(notif,'org.freedesktop.Notifications');" ) ;
9150
-                strcat( lDialogString ,"notify.Notify('',0,'" ) ;
9151
-                if ( aIconType && strlen(aIconType) )
9152
-                {
9153
-                        strcat( lDialogString , aIconType ) ;
9154
-                }
9155
-                strcat(lDialogString, "','") ;
9156
-                if ( aTitle && strlen(aTitle) )
9157
-                {
9158
-                        strcat(lDialogString, aTitle) ;
9159
-                }
9160
-                strcat(lDialogString, "','") ;
9161
-                if ( aMessage && strlen(aMessage) )
9162
-                {
9163
-                        lpDialogString = lDialogString + strlen(lDialogString);
9164
-                        tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
9165
-                }
9166
-                strcat(lDialogString, "','','',5000)\"") ;
9167
-        }
9168
-        else if ( notifysendPresent() )
9169
-        {
9170
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"notifysend");return 1;}
9171
-                strcpy( lDialogString , "notify-send" ) ;
9172
-                if ( aIconType && strlen(aIconType) )
9173
-                {
9174
-                        strcat( lDialogString , " -i '" ) ;
9175
-                        strcat( lDialogString , aIconType ) ;
9176
-                        strcat( lDialogString , "'" ) ;
9177
-                }
9178
-        strcat( lDialogString , " \"" ) ;
9179
-                if ( aTitle && strlen(aTitle) )
9180
-                {
9181
-                        strcat(lDialogString, aTitle) ;
9182
-                        strcat( lDialogString , " | " ) ;
9183
-                }
9184
-                if ( aMessage && strlen(aMessage) )
9185
-                {
9186
-            tfd_replaceSubStr( aMessage , "\n\t" , " |  " , lBuff ) ;
9187
-            tfd_replaceSubStr( aMessage , "\n" , " | " , lBuff ) ;
9188
-            tfd_replaceSubStr( aMessage , "\t" , "  " , lBuff ) ;
9189
-                        strcat(lDialogString, lBuff) ;
9190
-                }
9191
-                strcat( lDialogString , "\"" ) ;
9192
-        }
9193
-        else
9194
-        {
9195
-                return tinyfd_messageBox(aTitle, aMessage, "ok", aIconType, 0);
9196
-        }
9197
+		}
9198
+		else if ( pythonDbusPresent( ) )
9199
+		{
9200
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python-dbus");return 1;}
9201
+				strcpy( lDialogString , gPythonName ) ;
9202
+				strcat( lDialogString ," -c \"import dbus;bus=dbus.SessionBus();");
9203
+				strcat( lDialogString ,"notif=bus.get_object('org.freedesktop.Notifications','/org/freedesktop/Notifications');" ) ;
9204
+				strcat( lDialogString ,"notify=dbus.Interface(notif,'org.freedesktop.Notifications');" ) ;
9205
+				strcat( lDialogString ,"notify.Notify('',0,'" ) ;
9206
+				if ( aIconType && strlen(aIconType) )
9207
+				{
9208
+						strcat( lDialogString , aIconType ) ;
9209
+				}
9210
+				strcat(lDialogString, "','") ;
9211
+				if ( aTitle && strlen(aTitle) )
9212
+				{
9213
+						strcat(lDialogString, aTitle) ;
9214
+				}
9215
+				strcat(lDialogString, "','") ;
9216
+				if ( aMessage && strlen(aMessage) )
9217
+				{
9218
+						lpDialogString = lDialogString + strlen(lDialogString);
9219
+						tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
9220
+				}
9221
+				strcat(lDialogString, "','','',5000)\"") ;
9222
+		}
9223
+		else if ( notifysendPresent() )
9224
+		{
9225
+			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"notifysend");return 1;}
9226
+			strcpy( lDialogString , "notify-send" ) ;
9227
+			if ( aIconType && strlen(aIconType) )
9228
+			{
9229
+					strcat( lDialogString , " -i '" ) ;
9230
+					strcat( lDialogString , aIconType ) ;
9231
+					strcat( lDialogString , "'" ) ;
9232
+			}
9233
+			strcat( lDialogString , " \"" ) ;
9234
+			if ( aTitle && strlen(aTitle) )
9235
+			{
9236
+					strcat(lDialogString, aTitle) ;
9237
+					strcat( lDialogString , " | " ) ;
9238
+			}
9239
+			if ( aMessage && strlen(aMessage) )
9240
+			{
9241
+				tfd_replaceSubStr( aMessage , "\n\t" , " |  " , lBuff ) ;
9242
+				tfd_replaceSubStr( aMessage , "\n" , " | " , lBuff ) ;
9243
+				tfd_replaceSubStr( aMessage , "\t" , "  " , lBuff ) ;
9244
+				strcat(lDialogString, lBuff) ;
9245
+			}
9246
+			strcat( lDialogString , "\"" ) ;
9247
+		}
9248
+		else if ( (tfd_zenity3Present()>=5) )
9249
+		{
9250
+				/* zenity 2.32 & 3.14 has the notification but with a bug: it doesnt return from it */
9251
+				/* zenity 3.8 show the notification as an alert ok cancel box */
9252
+				/* zenity 3.44 doesn't have the notification (3.42 has it) */
9253
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return 1;}
9254
+				strcpy( lDialogString , "zenity --notification");
9255
 
9256
-        if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
9257
+				if ( aIconType && strlen( aIconType ) )
9258
+				{
9259
+						strcat( lDialogString , " --window-icon '");
9260
+						strcat( lDialogString , aIconType ) ;
9261
+						strcat( lDialogString , "'" ) ;
9262
+				}
9263
 
9264
-        if ( ! ( lIn = popen( lDialogString , "r" ) ) )
9265
-        {
9266
-                free(lDialogString);
9267
-                return 0 ;
9268
-        }
9269
+				strcat( lDialogString , " --text \"" ) ;
9270
+				if ( aTitle && strlen(aTitle) )
9271
+				{
9272
+						strcat(lDialogString, aTitle) ;
9273
+						strcat(lDialogString, "\n") ;
9274
+				}
9275
+				if ( aMessage && strlen( aMessage ) )
9276
+				{
9277
+						strcat( lDialogString , aMessage ) ;
9278
+				}
9279
+				strcat( lDialogString , " \"" ) ;
9280
+		}
9281
+		else
9282
+		{
9283
+			if (lDialogString) free(lDialogString);
9284
+			return tinyfd_messageBox(aTitle, aMessage, "ok", aIconType, 0);
9285
+		}
9286
 
9287
-        pclose( lIn ) ;
9288
-        free(lDialogString);
9289
-        return 1;
9290
+		if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
9291
+
9292
+		if ( ! ( lIn = popen( lDialogString , "r" ) ) )
9293
+		{
9294
+				free(lDialogString);
9295
+				return 0 ;
9296
+		}
9297
+
9298
+		pclose( lIn ) ;
9299
+		free(lDialogString);
9300
+		return 1;
9301
 }
9302
 
9303
 
9304
 /* returns NULL on cancel */
9305
 char * tinyfd_inputBox(
9306
-        char const * aTitle , /* NULL or "" */
9307
-        char const * aMessage , /* NULL or "" (\n and \t have no effect) */
9308
-        char const * aDefaultInput ) /* "" , if NULL it's a passwordBox */
9309
+		char const * aTitle , /* NULL or "" */
9310
+		char const * aMessage , /* NULL or "" (\n and \t have no effect) */
9311
+		char const * aDefaultInput ) /* "" , if NULL it's a passwordBox */
9312
 {
9313
-        static char lBuff[MAX_PATH_OR_CMD];
9314
-        char * lDialogString = NULL;
9315
-        char * lpDialogString;
9316
-        FILE * lIn ;
9317
-        int lResult ;
9318
-        int lWasGdialog = 0 ;
9319
-        int lWasGraphicDialog = 0 ;
9320
-        int lWasXterm = 0 ;
9321
-        int lWasBasicXterm = 0 ;
9322
-        struct termios oldt ;
9323
-        struct termios newt ;
9324
-        char * lEOF;
9325
-        size_t lTitleLen ;
9326
-        size_t lMessageLen ;
9327
+		static char lBuff[MAX_PATH_OR_CMD];
9328
+		char * lDialogString = NULL;
9329
+		char * lpDialogString;
9330
+		FILE * lIn ;
9331
+		int lResult ;
9332
+		int lWasGdialog = 0 ;
9333
+		int lWasGraphicDialog = 0 ;
9334
+		int lWasXterm = 0 ;
9335
+		int lWasBasicXterm = 0 ;
9336
+		struct termios oldt ;
9337
+		struct termios newt ;
9338
+		char * lEOF;
9339
+		size_t lTitleLen ;
9340
+		size_t lMessageLen ;
9341
 
9342
-		if (!aTitle && !aMessage && !aDefaultInput) return lBuff; /* now I can fill lBuff from outside */
9343
+				if (!aTitle && !aMessage && !aDefaultInput) return lBuff; /* now I can fill lBuff from outside */
9344
 
9345
-        lBuff[0]='\0';
9346
+		lBuff[0]='\0';
9347
 
9348
-		if (tfd_quoteDetected(aTitle)) return tinyfd_inputBox("INVALID TITLE WITH QUOTES", aMessage, aDefaultInput);
9349
-		if (tfd_quoteDetected(aMessage)) return tinyfd_inputBox(aTitle, "INVALID MESSAGE WITH QUOTES", aDefaultInput);
9350
-		if (tfd_quoteDetected(aDefaultInput)) return tinyfd_inputBox(aTitle, aMessage, "INVALID DEFAULT_INPUT WITH QUOTES");
9351
+				if (tfd_quoteDetected(aTitle)) return tinyfd_inputBox("INVALID TITLE WITH QUOTES", aMessage, aDefaultInput);
9352
+				if (tfd_quoteDetected(aMessage)) return tinyfd_inputBox(aTitle, "INVALID MESSAGE WITH QUOTES", aDefaultInput);
9353
+				if (tfd_quoteDetected(aDefaultInput)) return tinyfd_inputBox(aTitle, aMessage, "INVALID DEFAULT_INPUT WITH QUOTES: use the GRAVE ACCENT \\x60 instead.");
9354
 
9355
-        lTitleLen =  aTitle ? strlen(aTitle) : 0 ;
9356
-        lMessageLen =  aMessage ? strlen(aMessage) : 0 ;
9357
-        if ( !aTitle || strcmp(aTitle,"tinyfd_query") )
9358
-        {
9359
-                lDialogString = (char *) malloc( MAX_PATH_OR_CMD + lTitleLen + lMessageLen );
9360
-        }
9361
+		lTitleLen =  aTitle ? strlen(aTitle) : 0 ;
9362
+		lMessageLen =  aMessage ? strlen(aMessage) : 0 ;
9363
+		if ( !aTitle || strcmp(aTitle,"tinyfd_query") )
9364
+		{
9365
+				lDialogString = (char *) malloc( MAX_PATH_OR_CMD + lTitleLen + lMessageLen );
9366
+		}
9367
 
9368
-        if ( osascriptPresent( ) )
9369
-        {
9370
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
9371
-                strcpy( lDialogString , "osascript ");
9372
-                if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
9373
-                strcat( lDialogString , " -e 'try' -e 'display dialog \"") ;
9374
-                if ( aMessage && strlen(aMessage) )
9375
-                {
9376
-                        strcat(lDialogString, aMessage) ;
9377
-                }
9378
-                strcat(lDialogString, "\" ") ;
9379
-                strcat(lDialogString, "default answer \"") ;
9380
-                if ( aDefaultInput && strlen(aDefaultInput) )
9381
-                {
9382
-                        strcat(lDialogString, aDefaultInput) ;
9383
-                }
9384
-                strcat(lDialogString, "\" ") ;
9385
-                if ( ! aDefaultInput )
9386
-                {
9387
-                        strcat(lDialogString, "hidden answer true ") ;
9388
-                }
9389
-                if ( aTitle && strlen(aTitle) )
9390
-                {
9391
-                        strcat(lDialogString, "with title \"") ;
9392
-                        strcat(lDialogString, aTitle) ;
9393
-                        strcat(lDialogString, "\" ") ;
9394
-                }
9395
-                strcat(lDialogString, "with icon note' ") ;
9396
-                strcat(lDialogString, "-e '\"1\" & text returned of result' " );
9397
-                strcat(lDialogString, "-e 'on error number -128' " ) ;
9398
-                strcat(lDialogString, "-e '0' " );
9399
-                strcat(lDialogString, "-e 'end try'") ;
9400
-                if ( ! osx9orBetter() ) strcat(lDialogString, " -e 'end tell'") ;
9401
-        }
9402
-        else if ( tfd_kdialogPresent() )
9403
-        {
9404
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
9405
-                strcpy( lDialogString , "szAnswer=$(kdialog" ) ;
9406
+		if ( osascriptPresent( ) )
9407
+		{
9408
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
9409
+				strcpy( lDialogString , "osascript ");
9410
+				if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
9411
+				strcat( lDialogString , " -e 'try' -e 'display dialog \"") ;
9412
+				if ( aMessage && strlen(aMessage) )
9413
+				{
9414
+						strcat(lDialogString, aMessage) ;
9415
+				}
9416
+				strcat(lDialogString, "\" ") ;
9417
+				strcat(lDialogString, "default answer \"") ;
9418
+				if ( aDefaultInput && strlen(aDefaultInput) )
9419
+				{
9420
+						strcat(lDialogString, aDefaultInput) ;
9421
+				}
9422
+				strcat(lDialogString, "\" ") ;
9423
+				if ( ! aDefaultInput )
9424
+				{
9425
+						strcat(lDialogString, "hidden answer true ") ;
9426
+				}
9427
+				if ( aTitle && strlen(aTitle) )
9428
+				{
9429
+						strcat(lDialogString, "with title \"") ;
9430
+						strcat(lDialogString, aTitle) ;
9431
+						strcat(lDialogString, "\" ") ;
9432
+				}
9433
+				strcat(lDialogString, "with icon note' ") ;
9434
+				strcat(lDialogString, "-e '\"1\" & text returned of result' " );
9435
+				strcat(lDialogString, "-e 'on error number -128' " ) ;
9436
+				strcat(lDialogString, "-e '0' " );
9437
+				strcat(lDialogString, "-e 'end try'") ;
9438
+				if ( ! osx9orBetter() ) strcat(lDialogString, " -e 'end tell'") ;
9439
+		}
9440
+		else if ( tfd_kdialogPresent() )
9441
+		{
9442
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
9443
+				strcpy( lDialogString , "szAnswer=$(kdialog" ) ;
9444
 
9445
-				if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
9446
-                {
9447
-                        strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
9448
-                }
9449
+								if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
9450
+				{
9451
+						strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
9452
+				}
9453
 
9454
-                if ( ! aDefaultInput )
9455
-                {
9456
-                        strcat(lDialogString, " --password ") ;
9457
-                }
9458
-                else
9459
-                {
9460
-                        strcat(lDialogString, " --inputbox ") ;
9461
+				if ( ! aDefaultInput )
9462
+				{
9463
+						strcat(lDialogString, " --password ") ;
9464
+				}
9465
+				else
9466
+				{
9467
+						strcat(lDialogString, " --inputbox ") ;
9468
 
9469
-                }
9470
-                strcat(lDialogString, "\"") ;
9471
-                if ( aMessage && strlen(aMessage) )
9472
-                {
9473
-                        strcat(lDialogString, aMessage ) ;
9474
-                }
9475
-                strcat(lDialogString , "\" \"" ) ;
9476
-                if ( aDefaultInput && strlen(aDefaultInput) )
9477
-                {
9478
-                        strcat(lDialogString, aDefaultInput ) ;
9479
-                }
9480
-                strcat(lDialogString , "\"" ) ;
9481
-                if ( aTitle && strlen(aTitle) )
9482
-                {
9483
-                        strcat(lDialogString, " --title \"") ;
9484
-                        strcat(lDialogString, aTitle) ;
9485
-                        strcat(lDialogString, "\"") ;
9486
-                }
9487
-                strcat( lDialogString ,
9488
-                        ");if [ $? = 0 ];then echo 1$szAnswer;else echo 0$szAnswer;fi");
9489
-        }
9490
-        else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
9491
-        {
9492
-                if ( tfd_zenityPresent() )
9493
-                {
9494
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return (char *)1;}
9495
-                        strcpy( lDialogString , "szAnswer=$(zenity" ) ;
9496
-						if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
9497
-                        {
9498
-                                strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
9499
-                        }
9500
-                }
9501
-                else if ( tfd_matedialogPresent() )
9502
-                {
9503
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
9504
-                        strcpy( lDialogString ,  "szAnswer=$(matedialog" ) ;
9505
-                }
9506
-                else if ( tfd_shellementaryPresent() )
9507
-                {
9508
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
9509
-                        strcpy( lDialogString , "szAnswer=$(shellementary" ) ;
9510
-                }
9511
-                else
9512
-                {
9513
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
9514
-                        strcpy( lDialogString ,  "szAnswer=$(qarma" ) ;
9515
-						if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
9516
-                        {
9517
-                                strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
9518
-                        }
9519
-                }
9520
-                strcat( lDialogString ," --entry" ) ;
9521
+				}
9522
+				strcat(lDialogString, "\"") ;
9523
+				if ( aMessage && strlen(aMessage) )
9524
+				{
9525
+						strcat(lDialogString, aMessage ) ;
9526
+				}
9527
+				strcat(lDialogString , "\" \"" ) ;
9528
+				if ( aDefaultInput && strlen(aDefaultInput) )
9529
+				{
9530
+						strcat(lDialogString, aDefaultInput ) ;
9531
+				}
9532
+				strcat(lDialogString , "\"" ) ;
9533
+				if ( aTitle && strlen(aTitle) )
9534
+				{
9535
+						strcat(lDialogString, " --title \"") ;
9536
+						strcat(lDialogString, aTitle) ;
9537
+						strcat(lDialogString, "\"") ;
9538
+				}
9539
+				strcat( lDialogString ,
9540
+						");if [ $? = 0 ];then echo 1$szAnswer;else echo 0$szAnswer;fi");
9541
+		}
9542
+		else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
9543
+		{
9544
+				if ( tfd_zenityPresent() )
9545
+				{
9546
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return (char *)1;}
9547
+						strcpy( lDialogString , "szAnswer=$(zenity" ) ;
9548
+												if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
9549
+						{
9550
+								strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
9551
+						}
9552
+				}
9553
+				else if ( tfd_matedialogPresent() )
9554
+				{
9555
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
9556
+						strcpy( lDialogString ,  "szAnswer=$(matedialog" ) ;
9557
+				}
9558
+				else if ( tfd_shellementaryPresent() )
9559
+				{
9560
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
9561
+						strcpy( lDialogString , "szAnswer=$(shellementary" ) ;
9562
+				}
9563
+				else
9564
+				{
9565
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
9566
+						strcpy( lDialogString ,  "szAnswer=$(qarma" ) ;
9567
+												if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
9568
+						{
9569
+								strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
9570
+						}
9571
+				}
9572
+				strcat( lDialogString ," --entry" ) ;
9573
 
9574
-                if ( aTitle && strlen(aTitle) )
9575
-                {
9576
-                        strcat(lDialogString, " --title=\"") ;
9577
-                        strcat(lDialogString, aTitle) ;
9578
-                        strcat(lDialogString, "\"") ;
9579
-                }
9580
-                if ( aMessage && strlen(aMessage) )
9581
-                {
9582
-                        strcat(lDialogString, " --text=\"") ;
9583
-                        strcat(lDialogString, aMessage) ;
9584
-                        strcat(lDialogString, "\"") ;
9585
-                }
9586
-                if ( aDefaultInput && strlen(aDefaultInput) )
9587
-                {
9588
-                        strcat(lDialogString, " --entry-text=\"") ;
9589
-                        strcat(lDialogString, aDefaultInput) ;
9590
-                        strcat(lDialogString, "\"") ;
9591
-                }
9592
-                else
9593
-                {
9594
-                        strcat(lDialogString, " --hide-text") ;
9595
-                }
9596
-                if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
9597
-                strcat( lDialogString ,
9598
-                                ");if [ $? = 0 ];then echo 1$szAnswer;else echo 0$szAnswer;fi");
9599
-        }
9600
-        else if (tfd_yadPresent())
9601
-        {
9602
-           if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
9603
-           strcpy(lDialogString, "szAnswer=$(yad --entry");
9604
-           if (aTitle && strlen(aTitle))
9605
-           {
9606
-              strcat(lDialogString, " --title=\"");
9607
-              strcat(lDialogString, aTitle);
9608
-              strcat(lDialogString, "\"");
9609
-           }
9610
-           if (aMessage && strlen(aMessage))
9611
-           {
9612
-              strcat(lDialogString, " --text=\"");
9613
-              strcat(lDialogString, aMessage);
9614
-              strcat(lDialogString, "\"");
9615
-           }
9616
-           if (aDefaultInput && strlen(aDefaultInput))
9617
-           {
9618
-              strcat(lDialogString, " --entry-text=\"");
9619
-              strcat(lDialogString, aDefaultInput);
9620
-              strcat(lDialogString, "\"");
9621
-           }
9622
-           else
9623
-           {
9624
-              strcat(lDialogString, " --hide-text");
9625
-           }
9626
-           if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
9627
-           strcat(lDialogString,
9628
-              ");if [ $? = 0 ];then echo 1$szAnswer;else echo 0$szAnswer;fi");
9629
-        }
9630
-        else if ( gxmessagePresent() || gmessagePresent() )
9631
-        {
9632
-                if ( gxmessagePresent() ) {
9633
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gxmessage");return (char *)1;}
9634
-                        strcpy( lDialogString , "szAnswer=$(gxmessage -buttons Ok:1,Cancel:0 -center \"");
9635
-                }
9636
-                else
9637
-                {
9638
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gmessage");return (char *)1;}
9639
-                        strcpy( lDialogString , "szAnswer=$(gmessage -buttons Ok:1,Cancel:0 -center \"");
9640
-                }
9641
+				strcat(lDialogString, " --title=\"") ;
9642
+				if (aTitle && strlen(aTitle)) strcat(lDialogString, aTitle) ;
9643
+				strcat(lDialogString, "\"") ;
9644
 
9645
-                if ( aMessage && strlen(aMessage) )
9646
-                {
9647
-                        strcat( lDialogString , aMessage ) ;
9648
-                }
9649
-                strcat(lDialogString, "\"" ) ;
9650
-                if ( aTitle && strlen(aTitle) )
9651
-                {
9652
-                        strcat( lDialogString , " -title  \"");
9653
-                        strcat( lDialogString , aTitle ) ;
9654
-                        strcat(lDialogString, "\" " ) ;
9655
-                }
9656
-                strcat(lDialogString, " -entrytext \"" ) ;
9657
-                if ( aDefaultInput && strlen(aDefaultInput) )
9658
-                {
9659
-                        strcat( lDialogString , aDefaultInput ) ;
9660
-                }
9661
-                strcat(lDialogString, "\"" ) ;
9662
-                strcat( lDialogString , ");echo $?$szAnswer");
9663
-        }
9664
-		else if ( !gdialogPresent() && !xdialogPresent() && tkinter3Present( ) )
9665
+				strcat(lDialogString, " --text=\"") ;
9666
+				if (aMessage && strlen(aMessage)) strcat(lDialogString, aMessage) ;
9667
+				strcat(lDialogString, "\"") ;
9668
+
9669
+				if ( aDefaultInput )
9670
+				{
9671
+						strcat(lDialogString, " --entry-text=\"") ;
9672
+						strcat(lDialogString, aDefaultInput) ;
9673
+						strcat(lDialogString, "\"") ;
9674
+				}
9675
+				else
9676
+				{
9677
+						strcat(lDialogString, " --hide-text") ;
9678
+				}
9679
+				if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
9680
+				strcat( lDialogString ,
9681
+								");if [ $? = 0 ];then echo 1$szAnswer;else echo 0$szAnswer;fi");
9682
+		}
9683
+		else if (tfd_yadPresent())
9684
 		{
9685
-			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
9686
-			strcpy( lDialogString , gPython3Name ) ;
9687
-			strcat( lDialogString ,
9688
-				" -S -c \"import tkinter; from tkinter import simpledialog;root=tkinter.Tk();root.withdraw();");
9689
-			strcat( lDialogString ,"res=simpledialog.askstring(" ) ;
9690
-			if ( aTitle && strlen(aTitle) )
9691
-			{
9692
-				strcat(lDialogString, "title='") ;
9693
-				strcat(lDialogString, aTitle) ;
9694
-				strcat(lDialogString, "',") ;
9695
-			}
9696
-			if ( aMessage && strlen(aMessage) )
9697
-			{
9698
+		   if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
9699
+		   strcpy(lDialogString, "szAnswer=$(yad --entry");
9700
+		   if (aTitle && strlen(aTitle))
9701
+		   {
9702
+			  strcat(lDialogString, " --title=\"");
9703
+			  strcat(lDialogString, aTitle);
9704
+			  strcat(lDialogString, "\"");
9705
+		   }
9706
+		   if (aMessage && strlen(aMessage))
9707
+		   {
9708
+			  strcat(lDialogString, " --text=\"");
9709
+			  strcat(lDialogString, aMessage);
9710
+			  strcat(lDialogString, "\"");
9711
+		   }
9712
+		   if (aDefaultInput && strlen(aDefaultInput))
9713
+		   {
9714
+			  strcat(lDialogString, " --entry-text=\"");
9715
+			  strcat(lDialogString, aDefaultInput);
9716
+			  strcat(lDialogString, "\"");
9717
+		   }
9718
+		   else
9719
+		   {
9720
+			  strcat(lDialogString, " --hide-text");
9721
+		   }
9722
+		   if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
9723
+		   strcat(lDialogString,
9724
+			  ");if [ $? = 0 ];then echo 1$szAnswer;else echo 0$szAnswer;fi");
9725
+		}
9726
+		else if ( gxmessagePresent() || gmessagePresent() )
9727
+		{
9728
+				if ( gxmessagePresent() ) {
9729
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gxmessage");return (char *)1;}
9730
+						strcpy( lDialogString , "szAnswer=$(gxmessage -buttons Ok:1,Cancel:0 -center \"");
9731
+				}
9732
+				else
9733
+				{
9734
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gmessage");return (char *)1;}
9735
+						strcpy( lDialogString , "szAnswer=$(gmessage -buttons Ok:1,Cancel:0 -center \"");
9736
+				}
9737
 
9738
-				strcat(lDialogString, "prompt='") ;
9739
-				lpDialogString = lDialogString + strlen(lDialogString);
9740
-				tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
9741
-				strcat(lDialogString, "',") ;
9742
-			}
9743
-			if ( aDefaultInput )
9744
-			{
9745
-				if ( strlen(aDefaultInput) )
9746
+				if ( aMessage && strlen(aMessage) )
9747
 				{
9748
-					strcat(lDialogString, "initialvalue='") ;
9749
-					strcat(lDialogString, aDefaultInput) ;
9750
-					strcat(lDialogString, "',") ;
9751
+						strcat( lDialogString , aMessage ) ;
9752
 				}
9753
-			}
9754
-			else
9755
-			{
9756
-				strcat(lDialogString, "show='*'") ;
9757
-			}
9758
-			strcat(lDialogString, ");\nif res is None :\n\tprint(0)");
9759
-			strcat(lDialogString, "\nelse :\n\tprint('1'+res)\n\"" ) ;
9760
+				strcat(lDialogString, "\"" ) ;
9761
+				if ( aTitle && strlen(aTitle) )
9762
+				{
9763
+						strcat( lDialogString , " -title  \"");
9764
+						strcat( lDialogString , aTitle ) ;
9765
+						strcat(lDialogString, "\" " ) ;
9766
+				}
9767
+				strcat(lDialogString, " -entrytext \"" ) ;
9768
+				if ( aDefaultInput && strlen(aDefaultInput) )
9769
+				{
9770
+						strcat( lDialogString , aDefaultInput ) ;
9771
+				}
9772
+				strcat(lDialogString, "\"" ) ;
9773
+				strcat( lDialogString , ");echo $?$szAnswer");
9774
 		}
9775
-		else if ( !gdialogPresent() && !xdialogPresent() && tkinter2Present( ) )
9776
-        {
9777
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
9778
-				strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
9779
-				strcat( lDialogString , gPython2Name ) ;
9780
-				if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
9781
-                {
9782
-                strcat( lDialogString , " -i" ) ;  /* for osx without console */
9783
-                }
9784
+				else if ( !gdialogPresent() && !xdialogPresent() && tkinter3Present( ) )
9785
+				{
9786
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
9787
+						strcpy( lDialogString , gPython3Name ) ;
9788
+						strcat( lDialogString ,
9789
+								" -S -c \"import tkinter; from tkinter import simpledialog;root=tkinter.Tk();root.withdraw();");
9790
+						strcat( lDialogString ,"res=simpledialog.askstring(" ) ;
9791
+						if ( aTitle && strlen(aTitle) )
9792
+						{
9793
+								strcat(lDialogString, "title='") ;
9794
+								strcat(lDialogString, aTitle) ;
9795
+								strcat(lDialogString, "',") ;
9796
+						}
9797
+						if ( aMessage && strlen(aMessage) )
9798
+						{
9799
 
9800
-				strcat( lDialogString ,
9801
-					" -S -c \"import Tkinter,tkSimpleDialog;root=Tkinter.Tk();root.withdraw();");
9802
+								strcat(lDialogString, "prompt='") ;
9803
+								lpDialogString = lDialogString + strlen(lDialogString);
9804
+								tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
9805
+								strcat(lDialogString, "',") ;
9806
+						}
9807
+						if ( aDefaultInput )
9808
+						{
9809
+								if ( strlen(aDefaultInput) )
9810
+								{
9811
+										strcat(lDialogString, "initialvalue='") ;
9812
+										strcat(lDialogString, aDefaultInput) ;
9813
+										strcat(lDialogString, "',") ;
9814
+								}
9815
+						}
9816
+						else
9817
+						{
9818
+								strcat(lDialogString, "show='*'") ;
9819
+						}
9820
+						strcat(lDialogString, ");\nif res is None :\n\tprint(0)");
9821
+						strcat(lDialogString, "\nelse :\n\tprint('1'+res)\n\"" ) ;
9822
+				}
9823
+				else if ( !gdialogPresent() && !xdialogPresent() && tkinter2Present( ) )
9824
+		{
9825
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
9826
+								strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
9827
+								strcat( lDialogString , gPython2Name ) ;
9828
+								if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
9829
+				{
9830
+				strcat( lDialogString , " -i" ) ;  /* for osx without console */
9831
+				}
9832
 
9833
-                if ( tfd_isDarwin( ) )
9834
-                {
9835
-                        strcat( lDialogString ,
9836
+								strcat( lDialogString ,
9837
+										" -S -c \"import Tkinter,tkSimpleDialog;root=Tkinter.Tk();root.withdraw();");
9838
+
9839
+				if ( tfd_isDarwin( ) )
9840
+				{
9841
+						strcat( lDialogString ,
9842
 "import os;os.system('''/usr/bin/osascript -e 'tell app \\\"Finder\\\" to set \
9843
 frontmost of process \\\"Python\\\" to true' ''');");
9844
-                }
9845
+				}
9846
 
9847
-                strcat( lDialogString ,"res=tkSimpleDialog.askstring(" ) ;
9848
-                if ( aTitle && strlen(aTitle) )
9849
-                {
9850
-                        strcat(lDialogString, "title='") ;
9851
-                        strcat(lDialogString, aTitle) ;
9852
-                        strcat(lDialogString, "',") ;
9853
-                }
9854
-                if ( aMessage && strlen(aMessage) )
9855
-                {
9856
+				strcat( lDialogString ,"res=tkSimpleDialog.askstring(" ) ;
9857
+				if ( aTitle && strlen(aTitle) )
9858
+				{
9859
+						strcat(lDialogString, "title='") ;
9860
+						strcat(lDialogString, aTitle) ;
9861
+						strcat(lDialogString, "',") ;
9862
+				}
9863
+				if ( aMessage && strlen(aMessage) )
9864
+				{
9865
 
9866
-                        strcat(lDialogString, "prompt='") ;
9867
-                        lpDialogString = lDialogString + strlen(lDialogString);
9868
-                        tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
9869
-                        strcat(lDialogString, "',") ;
9870
-                }
9871
-                if ( aDefaultInput )
9872
-                {
9873
-                        if ( strlen(aDefaultInput) )
9874
-                        {
9875
-                                strcat(lDialogString, "initialvalue='") ;
9876
-                                strcat(lDialogString, aDefaultInput) ;
9877
-                                strcat(lDialogString, "',") ;
9878
-                        }
9879
-                }
9880
-                else
9881
-                {
9882
-                        strcat(lDialogString, "show='*'") ;
9883
-                }
9884
-                strcat(lDialogString, ");\nif res is None :\n\tprint 0");
9885
-                strcat(lDialogString, "\nelse :\n\tprint '1'+res\n\"" ) ;
9886
-        }
9887
-        else if ( gdialogPresent() || xdialogPresent() || dialogName() || whiptailPresent() )
9888
-        {
9889
-                if ( gdialogPresent( ) )
9890
-                {
9891
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gdialog");return (char *)1;}
9892
-                        lWasGraphicDialog = 1 ;
9893
-                        lWasGdialog = 1 ;
9894
-                        strcpy( lDialogString , "(gdialog " ) ;
9895
-                }
9896
-                else if ( xdialogPresent( ) )
9897
-                {
9898
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
9899
-                        lWasGraphicDialog = 1 ;
9900
-                        strcpy( lDialogString , "(Xdialog " ) ;
9901
-                }
9902
-                else if ( dialogName( ) )
9903
-                {
9904
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
9905
-                        if ( isTerminalRunning( ) )
9906
-                        {
9907
-                                strcpy( lDialogString , "(dialog " ) ;
9908
-                        }
9909
-                        else
9910
-                        {
9911
-                                lWasXterm = 1 ;
9912
-                                strcpy( lDialogString , terminalName() ) ;
9913
-                                strcat( lDialogString , "'(" ) ;
9914
-                                strcat( lDialogString , dialogName() ) ;
9915
-                                strcat( lDialogString , " " ) ;
9916
-                        }
9917
-                }
9918
-                else if ( isTerminalRunning( ) )
9919
-                {
9920
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"whiptail");return (char *)0;}
9921
-                        strcpy( lDialogString , "(whiptail " ) ;
9922
-                }
9923
-                else
9924
-                {
9925
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"whiptail");return (char *)0;}
9926
-                        lWasXterm = 1 ;
9927
-                        strcpy( lDialogString , terminalName() ) ;
9928
-                        strcat( lDialogString , "'(whiptail " ) ;
9929
-                }
9930
+						strcat(lDialogString, "prompt='") ;
9931
+						lpDialogString = lDialogString + strlen(lDialogString);
9932
+						tfd_replaceSubStr( aMessage , "\n" , "\\n" , lpDialogString ) ;
9933
+						strcat(lDialogString, "',") ;
9934
+				}
9935
+				if ( aDefaultInput )
9936
+				{
9937
+						if ( strlen(aDefaultInput) )
9938
+						{
9939
+								strcat(lDialogString, "initialvalue='") ;
9940
+								strcat(lDialogString, aDefaultInput) ;
9941
+								strcat(lDialogString, "',") ;
9942
+						}
9943
+				}
9944
+				else
9945
+				{
9946
+						strcat(lDialogString, "show='*'") ;
9947
+				}
9948
+				strcat(lDialogString, ");\nif res is None :\n\tprint 0");
9949
+				strcat(lDialogString, "\nelse :\n\tprint '1'+res\n\"" ) ;
9950
+		}
9951
+		else if ( gdialogPresent() || xdialogPresent() || dialogName() || whiptailPresent() )
9952
+		{
9953
+				if ( gdialogPresent( ) )
9954
+				{
9955
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"gdialog");return (char *)1;}
9956
+						lWasGraphicDialog = 1 ;
9957
+						lWasGdialog = 1 ;
9958
+						strcpy( lDialogString , "(gdialog " ) ;
9959
+				}
9960
+				else if ( xdialogPresent( ) )
9961
+				{
9962
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
9963
+						lWasGraphicDialog = 1 ;
9964
+						strcpy( lDialogString , "(Xdialog " ) ;
9965
+				}
9966
+				else if ( dialogName( ) )
9967
+				{
9968
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
9969
+						if ( isTerminalRunning( ) )
9970
+						{
9971
+								strcpy( lDialogString , "(dialog " ) ;
9972
+						}
9973
+						else
9974
+						{
9975
+								lWasXterm = 1 ;
9976
+								strcpy( lDialogString , terminalName() ) ;
9977
+								strcat( lDialogString , "'(" ) ;
9978
+								strcat( lDialogString , dialogName() ) ;
9979
+								strcat( lDialogString , " " ) ;
9980
+						}
9981
+				}
9982
+				else if ( isTerminalRunning( ) )
9983
+				{
9984
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"whiptail");return (char *)0;}
9985
+						strcpy( lDialogString , "(whiptail " ) ;
9986
+				}
9987
+				else
9988
+				{
9989
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"whiptail");return (char *)0;}
9990
+						lWasXterm = 1 ;
9991
+						strcpy( lDialogString , terminalName() ) ;
9992
+						strcat( lDialogString , "'(whiptail " ) ;
9993
+				}
9994
 
9995
-                if ( aTitle && strlen(aTitle) )
9996
-                {
9997
-                        strcat(lDialogString, "--title \"") ;
9998
-                        strcat(lDialogString, aTitle) ;
9999
-                        strcat(lDialogString, "\" ") ;
10000
-                }
10001
+				if ( aTitle && strlen(aTitle) )
10002
+				{
10003
+						strcat(lDialogString, "--title \"") ;
10004
+						strcat(lDialogString, aTitle) ;
10005
+						strcat(lDialogString, "\" ") ;
10006
+				}
10007
 
10008
-                if ( !xdialogPresent() && !gdialogPresent() )
10009
-                {
10010
-                        strcat(lDialogString, "--backtitle \"") ;
10011
-                        strcat(lDialogString, "tab: move focus") ;
10012
-                        if ( ! aDefaultInput && !lWasGdialog )
10013
-                        {
10014
-                                strcat(lDialogString, " (sometimes nothing, no blink nor star, is shown in text field)") ;
10015
-                        }
10016
-                        strcat(lDialogString, "\" ") ;
10017
-                }
10018
+				if ( !xdialogPresent() && !gdialogPresent() )
10019
+				{
10020
+						strcat(lDialogString, "--backtitle \"") ;
10021
+						strcat(lDialogString, "tab: move focus") ;
10022
+						if ( ! aDefaultInput && !lWasGdialog )
10023
+						{
10024
+								strcat(lDialogString, " (sometimes nothing, no blink nor star, is shown in text field)") ;
10025
+						}
10026
+						strcat(lDialogString, "\" ") ;
10027
+				}
10028
 
10029
-                if ( aDefaultInput || lWasGdialog )
10030
-                {
10031
-                        strcat( lDialogString , "--inputbox" ) ;
10032
-                }
10033
-                else
10034
-                {
10035
-                        if ( !lWasGraphicDialog && dialogName() && isDialogVersionBetter09b() )
10036
-                        {
10037
-                                strcat( lDialogString , "--insecure " ) ;
10038
-                        }
10039
-                        strcat( lDialogString , "--passwordbox" ) ;
10040
-                }
10041
-                strcat( lDialogString , " \"" ) ;
10042
-                if ( aMessage && strlen(aMessage) )
10043
-                {
10044
-                        strcat(lDialogString, aMessage) ;
10045
-                }
10046
-                strcat(lDialogString,"\" 10 60 ") ;
10047
-                if ( aDefaultInput && strlen(aDefaultInput) )
10048
-                {
10049
-                        strcat(lDialogString, "\"") ;
10050
-                        strcat(lDialogString, aDefaultInput) ;
10051
-                        strcat(lDialogString, "\" ") ;
10052
-                }
10053
-                if ( lWasGraphicDialog )
10054
-                {
10055
-                        strcat(lDialogString,") 2>/tmp/tinyfd.txt;\
10056
-        if [ $? = 0 ];then tinyfdBool=1;else tinyfdBool=0;fi;\
10057
-        tinyfdRes=$(cat /tmp/tinyfd.txt);echo $tinyfdBool$tinyfdRes") ;
10058
-                }
10059
-                else
10060
-                {
10061
-                        strcat(lDialogString,">/dev/tty ) 2>/tmp/tinyfd.txt;\
10062
-        if [ $? = 0 ];then tinyfdBool=1;else tinyfdBool=0;fi;\
10063
-        tinyfdRes=$(cat /tmp/tinyfd.txt);echo $tinyfdBool$tinyfdRes") ;
10064
+				if ( aDefaultInput || lWasGdialog )
10065
+				{
10066
+						strcat( lDialogString , "--inputbox" ) ;
10067
+				}
10068
+				else
10069
+				{
10070
+						if ( !lWasGraphicDialog && dialogName() && isDialogVersionBetter09b() )
10071
+						{
10072
+								strcat( lDialogString , "--insecure " ) ;
10073
+						}
10074
+						strcat( lDialogString , "--passwordbox" ) ;
10075
+				}
10076
+				strcat( lDialogString , " \"" ) ;
10077
+				if ( aMessage && strlen(aMessage) )
10078
+				{
10079
+						strcat(lDialogString, aMessage) ;
10080
+				}
10081
+				strcat(lDialogString,"\" 10 60 ") ;
10082
+				if ( aDefaultInput && strlen(aDefaultInput) )
10083
+				{
10084
+						strcat(lDialogString, "\"") ;
10085
+						strcat(lDialogString, aDefaultInput) ;
10086
+						strcat(lDialogString, "\" ") ;
10087
+				}
10088
+				if ( lWasGraphicDialog )
10089
+				{
10090
+						strcat(lDialogString,") 2>/tmp/tinyfd.txt;\
10091
+		if [ $? = 0 ];then tinyfdBool=1;else tinyfdBool=0;fi;\
10092
+		tinyfdRes=$(cat /tmp/tinyfd.txt);echo $tinyfdBool$tinyfdRes") ;
10093
+				}
10094
+				else
10095
+				{
10096
+						strcat(lDialogString,">/dev/tty ) 2>/tmp/tinyfd.txt;\
10097
+		if [ $? = 0 ];then tinyfdBool=1;else tinyfdBool=0;fi;\
10098
+		tinyfdRes=$(cat /tmp/tinyfd.txt);echo $tinyfdBool$tinyfdRes") ;
10099
 
10100
-                        if ( lWasXterm )
10101
-                        {
10102
-                strcat(lDialogString," >/tmp/tinyfd0.txt';cat /tmp/tinyfd0.txt");
10103
-                        }
10104
-                        else
10105
-                        {
10106
-                                strcat(lDialogString, "; clear >/dev/tty") ;
10107
-                        }
10108
-                }
10109
-        }
10110
-        else if ( ! isTerminalRunning( ) && terminalName() )
10111
-        {
10112
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return (char *)0;}
10113
-                lWasBasicXterm = 1 ;
10114
-                strcpy( lDialogString , terminalName() ) ;
10115
-                strcat( lDialogString , "'" ) ;
10116
-                if ( !gWarningDisplayed && !tinyfd_forceConsole)
10117
-                {
10118
-					gWarningDisplayed = 1 ;
10119
-					tinyfd_messageBox(gTitle,tinyfd_needs,"ok","warning",0);
10120
-                }
10121
-                if ( aTitle && strlen(aTitle) && !tinyfd_forceConsole)
10122
-                {
10123
-                        strcat( lDialogString , "echo \"" ) ;
10124
-                        strcat( lDialogString, aTitle) ;
10125
-                        strcat( lDialogString , "\";echo;" ) ;
10126
-                }
10127
+						if ( lWasXterm )
10128
+						{
10129
+				strcat(lDialogString," >/tmp/tinyfd0.txt';cat /tmp/tinyfd0.txt");
10130
+						}
10131
+						else
10132
+						{
10133
+								strcat(lDialogString, "; clear >/dev/tty") ;
10134
+						}
10135
+				}
10136
+		}
10137
+		else if ( ! isTerminalRunning( ) && terminalName() )
10138
+		{
10139
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return (char *)0;}
10140
+				lWasBasicXterm = 1 ;
10141
+				strcpy( lDialogString , terminalName() ) ;
10142
+				strcat( lDialogString , "'" ) ;
10143
+				if ( !gWarningDisplayed && !tinyfd_forceConsole)
10144
+				{
10145
+										gWarningDisplayed = 1 ;
10146
+										tinyfd_messageBox(gTitle,tinyfd_needs,"ok","warning",0);
10147
+				}
10148
+				if ( aTitle && strlen(aTitle) && !tinyfd_forceConsole)
10149
+				{
10150
+						strcat( lDialogString , "echo \"" ) ;
10151
+						strcat( lDialogString, aTitle) ;
10152
+						strcat( lDialogString , "\";echo;" ) ;
10153
+				}
10154
 
10155
-                strcat( lDialogString , "echo \"" ) ;
10156
-                if ( aMessage && strlen(aMessage) )
10157
-                {
10158
-                        strcat( lDialogString, aMessage) ;
10159
-                }
10160
-                strcat( lDialogString , "\";read " ) ;
10161
-                if ( ! aDefaultInput )
10162
-                {
10163
-                        strcat( lDialogString , "-s " ) ;
10164
-                }
10165
-                strcat( lDialogString , "-p \"" ) ;
10166
-                strcat( lDialogString , "(esc+enter to cancel): \" ANSWER " ) ;
10167
-                strcat( lDialogString , ";echo 1$ANSWER >/tmp/tinyfd.txt';" ) ;
10168
-                strcat( lDialogString , "cat -v /tmp/tinyfd.txt");
10169
-        }
10170
-        else if ( !gWarningDisplayed && ! isTerminalRunning( ) && ! terminalName() ) {
10171
-			gWarningDisplayed = 1 ;
10172
-			tinyfd_messageBox(gTitle,tinyfd_needs,"ok","warning",0);
10173
-			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"no_solution");return (char *)0;}
10174
-			free(lDialogString);
10175
-			return NULL;
10176
-        }
10177
-        else
10178
-        {
10179
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return (char *)0;}
10180
-                if ( !gWarningDisplayed && !tinyfd_forceConsole)
10181
-                {
10182
-                        gWarningDisplayed = 1 ;
10183
-                        tinyfd_messageBox(gTitle,tinyfd_needs,"ok","warning",0);
10184
-                }
10185
-                if ( aTitle && strlen(aTitle) )
10186
-                {
10187
-                        printf("\n%s\n", aTitle);
10188
-                }
10189
-                if ( aMessage && strlen(aMessage) )
10190
-                {
10191
-                        printf("\n%s\n",aMessage);
10192
-                }
10193
-                printf("(esc+enter to cancel): "); fflush(stdout);
10194
-                if ( ! aDefaultInput )
10195
-                {
10196
-                        tcgetattr(STDIN_FILENO, & oldt) ;
10197
-                        newt = oldt ;
10198
-                        newt.c_lflag &= ~ECHO ;
10199
-                        tcsetattr(STDIN_FILENO, TCSANOW, & newt);
10200
-                }
10201
+				strcat( lDialogString , "echo \"" ) ;
10202
+				if ( aMessage && strlen(aMessage) )
10203
+				{
10204
+						strcat( lDialogString, aMessage) ;
10205
+				}
10206
+				strcat( lDialogString , "\";read " ) ;
10207
+				if ( ! aDefaultInput )
10208
+				{
10209
+						strcat( lDialogString , "-s " ) ;
10210
+				}
10211
+				strcat( lDialogString , "-p \"" ) ;
10212
+				strcat( lDialogString , "(esc+enter to cancel): \" ANSWER " ) ;
10213
+				strcat( lDialogString , ";echo 1$ANSWER >/tmp/tinyfd.txt';" ) ;
10214
+				strcat( lDialogString , "cat -v /tmp/tinyfd.txt");
10215
+		}
10216
+		else if ( !gWarningDisplayed && ! isTerminalRunning( ) && ! terminalName() ) {
10217
+						gWarningDisplayed = 1 ;
10218
+						tinyfd_messageBox(gTitle,tinyfd_needs,"ok","warning",0);
10219
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"no_solution");return (char *)0;}
10220
+						free(lDialogString);
10221
+						return NULL;
10222
+		}
10223
+		else
10224
+		{
10225
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"basicinput");return (char *)0;}
10226
+				if ( !gWarningDisplayed && !tinyfd_forceConsole)
10227
+				{
10228
+						gWarningDisplayed = 1 ;
10229
+						tinyfd_messageBox(gTitle,tinyfd_needs,"ok","warning",0);
10230
+				}
10231
+				if ( aTitle && strlen(aTitle) )
10232
+				{
10233
+						printf("\n%s\n", aTitle);
10234
+				}
10235
+				if ( aMessage && strlen(aMessage) )
10236
+				{
10237
+						printf("\n%s\n",aMessage);
10238
+				}
10239
+				printf("(esc+enter to cancel): "); fflush(stdout);
10240
+				if ( ! aDefaultInput )
10241
+				{
10242
+						tcgetattr(STDIN_FILENO, & oldt) ;
10243
+						newt = oldt ;
10244
+						newt.c_lflag &= ~ECHO ;
10245
+						tcsetattr(STDIN_FILENO, TCSANOW, & newt);
10246
+				}
10247
 
10248
-                lEOF = fgets(lBuff, MAX_PATH_OR_CMD, stdin);
10249
-                /* printf("lbuff<%c><%d>\n",lBuff[0],lBuff[0]); */
10250
-                if ( ! lEOF  || (lBuff[0] == '\0') )
10251
-                {
10252
-                        free(lDialogString);
10253
-                        return NULL;
10254
-                }
10255
+				lEOF = fgets(lBuff, MAX_PATH_OR_CMD, stdin);
10256
+				/* printf("lbuff<%c><%d>\n",lBuff[0],lBuff[0]); */
10257
+				if ( ! lEOF  || (lBuff[0] == '\0') )
10258
+				{
10259
+						free(lDialogString);
10260
+						return NULL;
10261
+				}
10262
 
10263
-                if ( lBuff[0] == '\n' )
10264
-                {
10265
-                        lEOF = fgets(lBuff, MAX_PATH_OR_CMD, stdin);
10266
-                        /* printf("lbuff<%c><%d>\n",lBuff[0],lBuff[0]); */
10267
-                        if ( ! lEOF  || (lBuff[0] == '\0') )
10268
-                        {
10269
-                                free(lDialogString);
10270
-                                return NULL;
10271
-                        }
10272
-                }
10273
+				if ( lBuff[0] == '\n' )
10274
+				{
10275
+						lEOF = fgets(lBuff, MAX_PATH_OR_CMD, stdin);
10276
+						/* printf("lbuff<%c><%d>\n",lBuff[0],lBuff[0]); */
10277
+						if ( ! lEOF  || (lBuff[0] == '\0') )
10278
+						{
10279
+								free(lDialogString);
10280
+								return NULL;
10281
+						}
10282
+				}
10283
 
10284
-                if ( ! aDefaultInput )
10285
-                {
10286
-                        tcsetattr(STDIN_FILENO, TCSANOW, & oldt);
10287
-                        printf("\n");
10288
-                }
10289
-                printf("\n");
10290
-                if ( strchr(lBuff,27) )
10291
-                {
10292
-                        free(lDialogString);
10293
-                        return NULL ;
10294
-                }
10295
-                if ( lBuff[strlen( lBuff ) -1] == '\n' )
10296
-                {
10297
-                        lBuff[strlen( lBuff ) -1] = '\0' ;
10298
-                }
10299
-                free(lDialogString);
10300
-                return lBuff ;
10301
-        }
10302
+				if ( ! aDefaultInput )
10303
+				{
10304
+						tcsetattr(STDIN_FILENO, TCSANOW, & oldt);
10305
+						printf("\n");
10306
+				}
10307
+				printf("\n");
10308
+				if ( strchr(lBuff,27) )
10309
+				{
10310
+						free(lDialogString);
10311
+						return NULL ;
10312
+				}
10313
+				if ( lBuff[strlen( lBuff ) -1] == '\n' )
10314
+				{
10315
+						lBuff[strlen( lBuff ) -1] = '\0' ;
10316
+				}
10317
+				free(lDialogString);
10318
+				return lBuff ;
10319
+		}
10320
 
10321
-        if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
10322
-        lIn = popen( lDialogString , "r" );
10323
-        if ( ! lIn  )
10324
-        {
10325
-                if ( fileExists("/tmp/tinyfd.txt") )
10326
-                {
10327
-                        wipefile("/tmp/tinyfd.txt");
10328
-                        remove("/tmp/tinyfd.txt");
10329
-                }
10330
-                if ( fileExists("/tmp/tinyfd0.txt") )
10331
-                {
10332
-                        wipefile("/tmp/tinyfd0.txt");
10333
-                        remove("/tmp/tinyfd0.txt");
10334
-                }
10335
-                free(lDialogString);
10336
-                return NULL ;
10337
-        }
10338
-        while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
10339
-        {}
10340
+		if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
10341
+		lIn = popen( lDialogString , "r" );
10342
+		if ( ! lIn  )
10343
+		{
10344
+				if ( fileExists("/tmp/tinyfd.txt") )
10345
+				{
10346
+						wipefile("/tmp/tinyfd.txt");
10347
+						remove("/tmp/tinyfd.txt");
10348
+				}
10349
+				if ( fileExists("/tmp/tinyfd0.txt") )
10350
+				{
10351
+						wipefile("/tmp/tinyfd0.txt");
10352
+						remove("/tmp/tinyfd0.txt");
10353
+				}
10354
+				free(lDialogString);
10355
+				return NULL ;
10356
+		}
10357
+		while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
10358
+		{}
10359
 
10360
-        pclose( lIn ) ;
10361
+		pclose( lIn ) ;
10362
 
10363
-        if ( fileExists("/tmp/tinyfd.txt") )
10364
-        {
10365
-                wipefile("/tmp/tinyfd.txt");
10366
-                remove("/tmp/tinyfd.txt");
10367
-        }
10368
-        if ( fileExists("/tmp/tinyfd0.txt") )
10369
-        {
10370
-                wipefile("/tmp/tinyfd0.txt");
10371
-                remove("/tmp/tinyfd0.txt");
10372
-        }
10373
+		if ( fileExists("/tmp/tinyfd.txt") )
10374
+		{
10375
+				wipefile("/tmp/tinyfd.txt");
10376
+				remove("/tmp/tinyfd.txt");
10377
+		}
10378
+		if ( fileExists("/tmp/tinyfd0.txt") )
10379
+		{
10380
+				wipefile("/tmp/tinyfd0.txt");
10381
+				remove("/tmp/tinyfd0.txt");
10382
+		}
10383
 
10384
-        /* printf( "len Buff: %lu\n" , strlen(lBuff) ) ; */
10385
-        /* printf( "lBuff0: %s\n" , lBuff ) ; */
10386
-        if ( lBuff[strlen( lBuff ) -1] == '\n' )
10387
-        {
10388
-                lBuff[strlen( lBuff ) -1] = '\0' ;
10389
-        }
10390
-        /* printf( "lBuff1: %s len: %lu \n" , lBuff , strlen(lBuff) ) ; */
10391
-        if ( lWasBasicXterm )
10392
-        {
10393
-                if ( strstr(lBuff,"^[") ) /* esc was pressed */
10394
-                {
10395
-                        free(lDialogString);
10396
-                        return NULL ;
10397
-                }
10398
-        }
10399
+		/* printf( "len Buff: %lu\n" , strlen(lBuff) ) ; */
10400
+		/* printf( "lBuff0: %s\n" , lBuff ) ; */
10401
+		if ( strlen( lBuff ) && lBuff[strlen( lBuff ) -1] == '\n' )
10402
+		{
10403
+				lBuff[strlen( lBuff ) -1] = '\0' ;
10404
+		}
10405
+		/* printf( "lBuff1: %s len: %lu \n" , lBuff , strlen(lBuff) ) ; */
10406
+		if ( lWasBasicXterm )
10407
+		{
10408
+				if ( strstr(lBuff,"^[") ) /* esc was pressed */
10409
+				{
10410
+						free(lDialogString);
10411
+						return NULL ;
10412
+				}
10413
+		}
10414
 
10415
-        lResult =  strncmp( lBuff , "1" , 1) ? 0 : 1 ;
10416
-        /* printf( "lResult: %d \n" , lResult ) ; */
10417
-        if ( ! lResult )
10418
-        {
10419
-                free(lDialogString);
10420
-                return NULL ;
10421
-        }
10422
+		lResult =  strncmp( lBuff , "1" , 1) ? 0 : 1 ;
10423
+		/* printf( "lResult: %d \n" , lResult ) ; */
10424
+		if ( ! lResult )
10425
+		{
10426
+				free(lDialogString);
10427
+				return NULL ;
10428
+		}
10429
 
10430
-        /* printf( "lBuff+1: %s\n" , lBuff+1 ) ; */
10431
-        free(lDialogString);
10432
-        return lBuff+1 ;
10433
+		/* printf( "lBuff+1: %s\n" , lBuff+1 ) ; */
10434
+		free(lDialogString);
10435
+		return lBuff+1 ;
10436
 }
10437
 
10438
 
10439
 char * tinyfd_saveFileDialog(
10440
-    char const * aTitle , /* NULL or "" */
10441
-    char const * aDefaultPathAndFile , /* NULL or "" */
10442
-    int aNumOfFilterPatterns , /* 0 */
10443
-    char const * const * aFilterPatterns , /* NULL or {"*.jpg","*.png"} */
10444
-    char const * aSingleFilterDescription ) /* NULL or "image files" */
10445
+        char const * aTitle , /* NULL or "" */
10446
+        char const * aDefaultPathAndOrFile , /* NULL or "" , ends with / to set only a directory */
10447
+        int aNumOfFilterPatterns , /* 0 */
10448
+        char const * const * aFilterPatterns , /* NULL or {"*.txt","*.doc"} */
10449
+        char const * aSingleFilterDescription ) /* NULL or "text files" */
10450
 {
10451
-        static char lBuff[MAX_PATH_OR_CMD] ;
10452
-        char lDialogString[MAX_PATH_OR_CMD] ;
10453
-        char lString[MAX_PATH_OR_CMD] ;
10454
-        int i ;
10455
-        int lWasGraphicDialog = 0 ;
10456
-        int lWasXterm = 0 ;
10457
-        char * p ;
10458
-		char * lPointerInputBox ;
10459
-        FILE * lIn ;
10460
-        lBuff[0]='\0';
10461
+		static char lBuff[MAX_PATH_OR_CMD] ;
10462
+		static char lLastDirectory[MAX_PATH_OR_CMD] = "$PWD" ;
10463
 
10464
-		if (tfd_quoteDetected(aTitle)) return tinyfd_saveFileDialog("INVALID TITLE WITH QUOTES", aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
10465
-		if (tfd_quoteDetected(aDefaultPathAndFile)) return tinyfd_saveFileDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
10466
-		if (tfd_quoteDetected(aSingleFilterDescription)) return tinyfd_saveFileDialog(aTitle, aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, "INVALID FILTER_DESCRIPTION WITH QUOTES");
10467
-		for (i = 0; i < aNumOfFilterPatterns; i++)
10468
+		char lDialogString[MAX_PATH_OR_CMD] ;
10469
+		char lString[MAX_PATH_OR_CMD] ;
10470
+		int i ;
10471
+		int lWasGraphicDialog = 0 ;
10472
+		int lWasXterm = 0 ;
10473
+		char * p ;
10474
+        char * lPointerInputBox ;
10475
+		FILE * lIn ;
10476
+		lBuff[0]='\0';
10477
+
10478
+		if ( ! aFilterPatterns ) aNumOfFilterPatterns = 0 ;
10479
+				if (tfd_quoteDetected(aTitle)) return tinyfd_saveFileDialog("INVALID TITLE WITH QUOTES", aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
10480
+				if (tfd_quoteDetected(aDefaultPathAndOrFile)) return tinyfd_saveFileDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription);
10481
+				if (tfd_quoteDetected(aSingleFilterDescription)) return tinyfd_saveFileDialog(aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, "INVALID FILTER_DESCRIPTION WITH QUOTES");
10482
+				for (i = 0; i < aNumOfFilterPatterns; i++)
10483
+				{
10484
+						if (tfd_quoteDetected(aFilterPatterns[i])) return tinyfd_saveFileDialog("INVALID FILTER_PATTERN WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultPathAndOrFile, 0, NULL, NULL);
10485
+				}
10486
+
10487
+		if ( osascriptPresent( ) )
10488
 		{
10489
-			if (tfd_quoteDetected(aFilterPatterns[i])) return tinyfd_saveFileDialog("INVALID FILTER_PATTERN WITH QUOTES", aDefaultPathAndFile, 0, NULL, NULL);
10490
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
10491
+				strcpy( lDialogString , "osascript ");
10492
+				if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"Finder\"' -e 'Activate'");
10493
+				strcat( lDialogString , " -e 'try' -e 'POSIX path of ( choose file name " );
10494
+				if ( aTitle && strlen(aTitle) )
10495
+				{
10496
+						strcat(lDialogString, "with prompt \"") ;
10497
+						strcat(lDialogString, aTitle) ;
10498
+						strcat(lDialogString, "\" ") ;
10499
+				}
10500
+				getPathWithoutFinalSlash( lString , aDefaultPathAndOrFile ) ;
10501
+				if ( strlen(lString) )
10502
+				{
10503
+						strcat(lDialogString, "default location \"") ;
10504
+						strcat(lDialogString, lString ) ;
10505
+						strcat(lDialogString , "\" " ) ;
10506
+				}
10507
+				getLastName( lString , aDefaultPathAndOrFile ) ;
10508
+				if ( strlen(lString) )
10509
+				{
10510
+						strcat(lDialogString, "default name \"") ;
10511
+						strcat(lDialogString, lString ) ;
10512
+						strcat(lDialogString , "\" " ) ;
10513
+				}
10514
+				strcat( lDialogString , ")' " ) ;
10515
+				strcat(lDialogString, "-e 'on error number -128' " ) ;
10516
+				strcat(lDialogString, "-e 'end try'") ;
10517
+				if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
10518
 		}
10519
+		else if ( tfd_kdialogPresent() )
10520
+		{
10521
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
10522
 
10523
-        if ( osascriptPresent( ) )
10524
-        {
10525
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
10526
-                strcpy( lDialogString , "osascript ");
10527
-                if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"Finder\"' -e 'Activate'");
10528
-                strcat( lDialogString , " -e 'try' -e 'POSIX path of ( choose file name " );
10529
-                if ( aTitle && strlen(aTitle) )
10530
-                {
10531
-                        strcat(lDialogString, "with prompt \"") ;
10532
-                        strcat(lDialogString, aTitle) ;
10533
-                        strcat(lDialogString, "\" ") ;
10534
-                }
10535
-                getPathWithoutFinalSlash( lString , aDefaultPathAndFile ) ;
10536
-                if ( strlen(lString) )
10537
-                {
10538
-                        strcat(lDialogString, "default location \"") ;
10539
-                        strcat(lDialogString, lString ) ;
10540
-                        strcat(lDialogString , "\" " ) ;
10541
-                }
10542
-                getLastName( lString , aDefaultPathAndFile ) ;
10543
-                if ( strlen(lString) )
10544
-                {
10545
-                        strcat(lDialogString, "default name \"") ;
10546
-                        strcat(lDialogString, lString ) ;
10547
-                        strcat(lDialogString , "\" " ) ;
10548
-                }
10549
-                strcat( lDialogString , ")' " ) ;
10550
-                strcat(lDialogString, "-e 'on error number -128' " ) ;
10551
-                strcat(lDialogString, "-e 'end try'") ;
10552
-                if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
10553
-        }
10554
-        else if ( tfd_kdialogPresent() )
10555
-        {
10556
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
10557
+				strcpy( lDialogString , "kdialog" ) ;
10558
+                if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
10559
+				{
10560
+                    strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
10561
+				}
10562
+				strcat( lDialogString , " --getsavefilename " ) ;
10563
 
10564
-                strcpy( lDialogString , "kdialog" ) ;
10565
-				if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
10566
-                {
10567
-                        strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
10568
-                }
10569
-                strcat( lDialogString , " --getsavefilename " ) ;
10570
+				if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
10571
+				{
10572
+                    if ( aDefaultPathAndOrFile[0] != '/' )
10573
+                    {
10574
+                        strcat(lDialogString, lLastDirectory) ;
10575
+                        strcat(lDialogString , "/" ) ;
10576
+                    }
10577
+                    strcat(lDialogString, "\"") ;
10578
+                    strcat(lDialogString, aDefaultPathAndOrFile ) ;
10579
+                    strcat(lDialogString , "\"" ) ;
10580
+				}
10581
+				else
10582
+				{
10583
+                    strcat(lDialogString, lLastDirectory) ;
10584
+                    strcat(lDialogString , "/" ) ;
10585
+				}
10586
 
10587
-                if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
10588
-                {
10589
-                        if ( aDefaultPathAndFile[0] != '/' )
10590
-                        {
10591
-                                strcat(lDialogString, "$PWD/") ;
10592
-                        }
10593
-                        strcat(lDialogString, "\"") ;
10594
-                        strcat(lDialogString, aDefaultPathAndFile ) ;
10595
-                        strcat(lDialogString , "\"" ) ;
10596
-                }
10597
-                else
10598
-                {
10599
-                        strcat(lDialogString, "$PWD/") ;
10600
-                }
10601
-
10602
-                if ( aNumOfFilterPatterns > 0 )
10603
-                {
10604
-                        strcat(lDialogString , " \"" ) ;
10605
-						strcat( lDialogString , aFilterPatterns[0] ) ;
10606
-                        for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ )
10607
-                        {
10608
-							strcat( lDialogString , " " ) ;
10609
-							strcat( lDialogString , aFilterPatterns[i] ) ;
10610
-                        }
10611
-                        if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
10612
-                        {
10613
-                                strcat( lDialogString , " | " ) ;
10614
-                                strcat( lDialogString , aSingleFilterDescription ) ;
10615
-                        }
10616
-                        strcat( lDialogString , "\"" ) ;
10617
-                }
10618
-                if ( aTitle && strlen(aTitle) )
10619
-                {
10620
-                        strcat(lDialogString, " --title \"") ;
10621
-                        strcat(lDialogString, aTitle) ;
10622
-                        strcat(lDialogString, "\"") ;
10623
-                }
10624
-        }
10625
-        else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
10626
-        {
10627
-                if ( tfd_zenityPresent() )
10628
-                {
10629
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return (char *)1;}
10630
-                        strcpy( lDialogString , "zenity" ) ;
10631
-						if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
10632
-                        {
10633
-                                strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
10634
-                        }
10635
-                }
10636
-                else if ( tfd_matedialogPresent() )
10637
-                {
10638
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
10639
-                        strcpy( lDialogString , "matedialog" ) ;
10640
-                }
10641
-                else if ( tfd_shellementaryPresent() )
10642
-                {
10643
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
10644
-                        strcpy( lDialogString , "shellementary" ) ;
10645
-                }
10646
-                else
10647
-                {
10648
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
10649
-                        strcpy( lDialogString , "qarma" ) ;
10650
-						if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
10651
-                        {
10652
-                                strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
10653
-                        }
10654
-                }
10655
-                strcat(lDialogString, " --file-selection --save --confirm-overwrite" ) ;
10656
-
10657
-                if ( aTitle && strlen(aTitle) )
10658
-                {
10659
-                        strcat(lDialogString, " --title=\"") ;
10660
-                        strcat(lDialogString, aTitle) ;
10661
-                        strcat(lDialogString, "\"") ;
10662
-                }
10663
-                if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
10664
-                {
10665
-                        strcat(lDialogString, " --filename=\"") ;
10666
-                        strcat(lDialogString, aDefaultPathAndFile) ;
10667
-                        strcat(lDialogString, "\"") ;
10668
-                }
10669
-                if ( aNumOfFilterPatterns > 0 )
10670
-                {
10671
-                        strcat( lDialogString , " --file-filter='" ) ;
10672
-                        if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
10673
-                        {
10674
-                                strcat( lDialogString , aSingleFilterDescription ) ;
10675
-                                strcat( lDialogString , " |" ) ;
10676
-                        }
10677
-                        for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
10678
-                        {
10679
-							strcat( lDialogString , " " ) ;
10680
-							strcat( lDialogString , aFilterPatterns[i] ) ;
10681
-                        }
10682
-                        strcat( lDialogString , "' --file-filter='All files | *'" ) ;
10683
-                }
10684
-                if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
10685
-        }
10686
-        else if (tfd_yadPresent())
10687
-        {
10688
-           if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
10689
-           strcpy(lDialogString, "yad --file-selection --save --confirm-overwrite");
10690
-           if (aTitle && strlen(aTitle))
10691
-           {
10692
-              strcat(lDialogString, " --title=\"");
10693
-              strcat(lDialogString, aTitle);
10694
-              strcat(lDialogString, "\"");
10695
-           }
10696
-           if (aDefaultPathAndFile && strlen(aDefaultPathAndFile))
10697
-           {
10698
-              strcat(lDialogString, " --filename=\"");
10699
-              strcat(lDialogString, aDefaultPathAndFile);
10700
-              strcat(lDialogString, "\"");
10701
-           }
10702
-           if (aNumOfFilterPatterns > 0)
10703
-           {
10704
-              strcat(lDialogString, " --file-filter='");
10705
-              if (aSingleFilterDescription && strlen(aSingleFilterDescription))
10706
-              {
10707
-                 strcat(lDialogString, aSingleFilterDescription);
10708
-                 strcat(lDialogString, " |");
10709
-              }
10710
-              for (i = 0; i < aNumOfFilterPatterns; i++)
10711
-              {
10712
-                 strcat(lDialogString, " ");
10713
-                 strcat(lDialogString, aFilterPatterns[i]);
10714
-              }
10715
-              strcat(lDialogString, "' --file-filter='All files | *'");
10716
-           }
10717
-           if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
10718
-      }
10719
-      else if ( !xdialogPresent() && tkinter3Present( ) )
10720
+				if ( aNumOfFilterPatterns > 0 )
10721
+				{
10722
+						strcat(lDialogString , " \"" ) ;
10723
+                        strcat( lDialogString , aFilterPatterns[0] ) ;
10724
+						for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ )
10725
+						{
10726
+														strcat( lDialogString , " " ) ;
10727
+														strcat( lDialogString , aFilterPatterns[i] ) ;
10728
+						}
10729
+						if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
10730
+						{
10731
+								strcat( lDialogString , " | " ) ;
10732
+								strcat( lDialogString , aSingleFilterDescription ) ;
10733
+						}
10734
+						strcat( lDialogString , "\"" ) ;
10735
+				}
10736
+				if ( aTitle && strlen(aTitle) )
10737
+				{
10738
+						strcat(lDialogString, " --title \"") ;
10739
+						strcat(lDialogString, aTitle) ;
10740
+						strcat(lDialogString, "\"") ;
10741
+				}
10742
+		}
10743
+		else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
10744
 		{
10745
-			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
10746
-			strcpy( lDialogString , gPython3Name ) ;
10747
-			strcat( lDialogString ,
10748
-				" -S -c \"import tkinter;from tkinter import filedialog;root=tkinter.Tk();root.withdraw();");
10749
-			strcat( lDialogString , "res=filedialog.asksaveasfilename(");
10750
-			if ( aTitle && strlen(aTitle) )
10751
-			{
10752
-				strcat(lDialogString, "title='") ;
10753
-				strcat(lDialogString, aTitle) ;
10754
-				strcat(lDialogString, "',") ;
10755
-			}
10756
-			if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
10757
-			{
10758
-				getPathWithoutFinalSlash( lString , aDefaultPathAndFile ) ;
10759
-				if ( strlen(lString) )
10760
+				if ( tfd_zenityPresent() )
10761
 				{
10762
-					strcat(lDialogString, "initialdir='") ;
10763
-					strcat(lDialogString, lString ) ;
10764
-					strcat(lDialogString , "'," ) ;
10765
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return (char *)1;}
10766
+						strcpy( lDialogString , "zenity" ) ;
10767
+												if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
10768
+						{
10769
+								strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
10770
+						}
10771
 				}
10772
-				getLastName( lString , aDefaultPathAndFile ) ;
10773
-				if ( strlen(lString) )
10774
+				else if ( tfd_matedialogPresent() )
10775
 				{
10776
-					strcat(lDialogString, "initialfile='") ;
10777
-					strcat(lDialogString, lString ) ;
10778
-					strcat(lDialogString , "'," ) ;
10779
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
10780
+						strcpy( lDialogString , "matedialog" ) ;
10781
 				}
10782
-			}
10783
-			if ( ( aNumOfFilterPatterns > 1 )
10784
-				|| ( (aNumOfFilterPatterns == 1) /* test because poor osx behaviour */
10785
-				&& ( aFilterPatterns[0][strlen(aFilterPatterns[0])-1] != '*' ) ) )
10786
-			{
10787
-				strcat(lDialogString , "filetypes=(" ) ;
10788
-				strcat( lDialogString , "('" ) ;
10789
-				if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
10790
+				else if ( tfd_shellementaryPresent() )
10791
 				{
10792
-					strcat( lDialogString , aSingleFilterDescription ) ;
10793
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
10794
+						strcpy( lDialogString , "shellementary" ) ;
10795
 				}
10796
-				strcat( lDialogString , "',(" ) ;
10797
-				for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
10798
+				else
10799
 				{
10800
-					strcat( lDialogString , "'" ) ;
10801
-					strcat( lDialogString , aFilterPatterns[i] ) ;
10802
-					strcat( lDialogString , "'," ) ;
10803
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
10804
+						strcpy( lDialogString , "qarma" ) ;
10805
+												if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
10806
+						{
10807
+								strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
10808
+						}
10809
 				}
10810
-				strcat( lDialogString , "))," ) ;
10811
-				strcat( lDialogString , "('All files','*'))" ) ;
10812
-			}
10813
-			strcat( lDialogString, ");\nif not isinstance(res, tuple):\n\tprint(res)\n\"" ) ;
10814
+				strcat(lDialogString, " --file-selection --save --confirm-overwrite" ) ;
10815
+
10816
+				strcat(lDialogString, " --title=\"") ;
10817
+				if (aTitle && strlen(aTitle)) strcat(lDialogString, aTitle) ;
10818
+				strcat(lDialogString, "\"") ;
10819
+
10820
+				if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
10821
+				{
10822
+						strcat(lDialogString, " --filename=\"") ;
10823
+						strcat(lDialogString, aDefaultPathAndOrFile) ;
10824
+						strcat(lDialogString, "\"") ;
10825
+				}
10826
+				if ( aNumOfFilterPatterns > 0 )
10827
+				{
10828
+						strcat( lDialogString , " --file-filter='" ) ;
10829
+						if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
10830
+						{
10831
+								strcat( lDialogString , aSingleFilterDescription ) ;
10832
+								strcat( lDialogString , " |" ) ;
10833
+						}
10834
+						for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
10835
+						{
10836
+														strcat( lDialogString , " " ) ;
10837
+														strcat( lDialogString , aFilterPatterns[i] ) ;
10838
+						}
10839
+						strcat( lDialogString , "' --file-filter='All files | *'" ) ;
10840
+				}
10841
+				if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
10842
 		}
10843
-		else if ( !xdialogPresent() && tkinter2Present( ) )
10844
-        {
10845
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
10846
-				strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
10847
-				strcat( lDialogString , gPython2Name ) ;
10848
-				if ( ! isTerminalRunning( ) && tfd_isDarwin( ))
10849
-                {
10850
-                strcat( lDialogString , " -i" ) ;  /* for osx without console */
10851
-                }
10852
-            strcat( lDialogString ,
10853
+		else if (tfd_yadPresent())
10854
+		{
10855
+		   if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
10856
+		   strcpy(lDialogString, "yad --file --save --confirm-overwrite");
10857
+		   if (aTitle && strlen(aTitle))
10858
+		   {
10859
+			  strcat(lDialogString, " --title=\"");
10860
+			  strcat(lDialogString, aTitle);
10861
+			  strcat(lDialogString, "\"");
10862
+		   }
10863
+		   if (aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile))
10864
+		   {
10865
+			  strcat(lDialogString, " --filename=\"");
10866
+			  strcat(lDialogString, aDefaultPathAndOrFile);
10867
+			  strcat(lDialogString, "\"");
10868
+		   }
10869
+		   if (aNumOfFilterPatterns > 0)
10870
+		   {
10871
+			  strcat(lDialogString, " --file-filter='");
10872
+			  if (aSingleFilterDescription && strlen(aSingleFilterDescription))
10873
+			  {
10874
+				 strcat(lDialogString, aSingleFilterDescription);
10875
+				 strcat(lDialogString, " |");
10876
+			  }
10877
+			  for (i = 0; i < aNumOfFilterPatterns; i++)
10878
+			  {
10879
+				 strcat(lDialogString, " ");
10880
+				 strcat(lDialogString, aFilterPatterns[i]);
10881
+			  }
10882
+			  strcat(lDialogString, "' --file-filter='All files | *'");
10883
+		   }
10884
+		   if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
10885
+	  }
10886
+	  else if ( !xdialogPresent() && tkinter3Present( ) )
10887
+				{
10888
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
10889
+						strcpy( lDialogString , gPython3Name ) ;
10890
+						strcat( lDialogString ,
10891
+								" -S -c \"import tkinter;from tkinter import filedialog;root=tkinter.Tk();root.withdraw();");
10892
+						strcat( lDialogString , "res=filedialog.asksaveasfilename(");
10893
+						if ( aTitle && strlen(aTitle) )
10894
+						{
10895
+								strcat(lDialogString, "title='") ;
10896
+								strcat(lDialogString, aTitle) ;
10897
+								strcat(lDialogString, "',") ;
10898
+						}
10899
+						if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
10900
+						{
10901
+								getPathWithoutFinalSlash( lString , aDefaultPathAndOrFile ) ;
10902
+								if ( strlen(lString) )
10903
+								{
10904
+										strcat(lDialogString, "initialdir='") ;
10905
+										strcat(lDialogString, lString ) ;
10906
+										strcat(lDialogString , "'," ) ;
10907
+								}
10908
+								getLastName( lString , aDefaultPathAndOrFile ) ;
10909
+								if ( strlen(lString) )
10910
+								{
10911
+										strcat(lDialogString, "initialfile='") ;
10912
+										strcat(lDialogString, lString ) ;
10913
+										strcat(lDialogString , "'," ) ;
10914
+								}
10915
+						}
10916
+						if ( ( aNumOfFilterPatterns > 1 )
10917
+								|| ( (aNumOfFilterPatterns == 1) /* test because poor osx behaviour */
10918
+								&& ( aFilterPatterns[0][strlen(aFilterPatterns[0])-1] != '*' ) ) )
10919
+						{
10920
+								strcat(lDialogString , "filetypes=(" ) ;
10921
+								strcat( lDialogString , "('" ) ;
10922
+								if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
10923
+								{
10924
+										strcat( lDialogString , aSingleFilterDescription ) ;
10925
+								}
10926
+								strcat( lDialogString , "',(" ) ;
10927
+								for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
10928
+								{
10929
+										strcat( lDialogString , "'" ) ;
10930
+										strcat( lDialogString , aFilterPatterns[i] ) ;
10931
+										strcat( lDialogString , "'," ) ;
10932
+								}
10933
+								strcat( lDialogString , "))," ) ;
10934
+								strcat( lDialogString , "('All files','*'))" ) ;
10935
+						}
10936
+						strcat( lDialogString, ");\nif not isinstance(res, tuple):\n\tprint(res)\n\"" ) ;
10937
+				}
10938
+				else if ( !xdialogPresent() && tkinter2Present( ) )
10939
+		{
10940
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
10941
+								strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
10942
+								strcat( lDialogString , gPython2Name ) ;
10943
+								if ( ! isTerminalRunning( ) && tfd_isDarwin( ))
10944
+				{
10945
+				strcat( lDialogString , " -i" ) ;  /* for osx without console */
10946
+				}
10947
+			strcat( lDialogString ,
10948
 " -S -c \"import Tkinter,tkFileDialog;root=Tkinter.Tk();root.withdraw();");
10949
 
10950
-        if ( tfd_isDarwin( ) )
10951
-        {
10952
-                        strcat( lDialogString ,
10953
+		if ( tfd_isDarwin( ) )
10954
+		{
10955
+                strcat( lDialogString ,
10956
 "import os;os.system('''/usr/bin/osascript -e 'tell app \\\"Finder\\\" to set\
10957
  frontmost of process \\\"Python\\\" to true' ''');");
10958
-                }
10959
+				}
10960
 
10961
-                strcat( lDialogString , "res=tkFileDialog.asksaveasfilename(");
10962
-                if ( aTitle && strlen(aTitle) )
10963
-                {
10964
-                        strcat(lDialogString, "title='") ;
10965
-                        strcat(lDialogString, aTitle) ;
10966
-                        strcat(lDialogString, "',") ;
10967
-                }
10968
-            if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
10969
-            {
10970
-                        getPathWithoutFinalSlash( lString , aDefaultPathAndFile ) ;
10971
-                        if ( strlen(lString) )
10972
-                        {
10973
-                                strcat(lDialogString, "initialdir='") ;
10974
-                                strcat(lDialogString, lString ) ;
10975
-                                strcat(lDialogString , "'," ) ;
10976
-                        }
10977
-                        getLastName( lString , aDefaultPathAndFile ) ;
10978
-                        if ( strlen(lString) )
10979
-                        {
10980
-                                strcat(lDialogString, "initialfile='") ;
10981
-                                strcat(lDialogString, lString ) ;
10982
-                                strcat(lDialogString , "'," ) ;
10983
-                        }
10984
-                }
10985
-            if ( ( aNumOfFilterPatterns > 1 )
10986
-                  || ( (aNumOfFilterPatterns == 1) /* test because poor osx behaviour */
10987
-                        && ( aFilterPatterns[0][strlen(aFilterPatterns[0])-1] != '*' ) ) )
10988
-            {
10989
-                        strcat(lDialogString , "filetypes=(" ) ;
10990
-                        strcat( lDialogString , "('" ) ;
10991
-                        if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
10992
-                        {
10993
-                                strcat( lDialogString , aSingleFilterDescription ) ;
10994
-                        }
10995
-                        strcat( lDialogString , "',(" ) ;
10996
-                        for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
10997
-                        {
10998
-                                strcat( lDialogString , "'" ) ;
10999
-                                strcat( lDialogString , aFilterPatterns[i] ) ;
11000
-                                strcat( lDialogString , "'," ) ;
11001
-                        }
11002
-                        strcat( lDialogString , "))," ) ;
11003
-                        strcat( lDialogString , "('All files','*'))" ) ;
11004
-            }
11005
-			strcat( lDialogString, ");\nif not isinstance(res, tuple):\n\tprint res \n\"" ) ;
11006
-		}
11007
-        else if ( xdialogPresent() || dialogName() )
11008
-        {
11009
-                if ( xdialogPresent( ) )
11010
-                {
11011
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
11012
-                        lWasGraphicDialog = 1 ;
11013
-                        strcpy( lDialogString , "(Xdialog " ) ;
11014
-                }
11015
-                else if ( isTerminalRunning( ) )
11016
-                {
11017
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
11018
-                        strcpy( lDialogString , "(dialog " ) ;
11019
-                }
11020
-                else
11021
-                {
11022
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
11023
-                        lWasXterm = 1 ;
11024
-                        strcpy( lDialogString , terminalName() ) ;
11025
-                        strcat( lDialogString , "'(" ) ;
11026
-                        strcat( lDialogString , dialogName() ) ;
11027
-                        strcat( lDialogString , " " ) ;
11028
-                }
11029
+				strcat( lDialogString , "res=tkFileDialog.asksaveasfilename(");
11030
+				if ( aTitle && strlen(aTitle) )
11031
+				{
11032
+						strcat(lDialogString, "title='") ;
11033
+						strcat(lDialogString, aTitle) ;
11034
+						strcat(lDialogString, "',") ;
11035
+				}
11036
+			if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
11037
+			{
11038
+						getPathWithoutFinalSlash( lString , aDefaultPathAndOrFile ) ;
11039
+						if ( strlen(lString) )
11040
+						{
11041
+								strcat(lDialogString, "initialdir='") ;
11042
+								strcat(lDialogString, lString ) ;
11043
+								strcat(lDialogString , "'," ) ;
11044
+						}
11045
+						getLastName( lString , aDefaultPathAndOrFile ) ;
11046
+						if ( strlen(lString) )
11047
+						{
11048
+								strcat(lDialogString, "initialfile='") ;
11049
+								strcat(lDialogString, lString ) ;
11050
+								strcat(lDialogString , "'," ) ;
11051
+						}
11052
+				}
11053
+			if ( ( aNumOfFilterPatterns > 1 )
11054
+				  || ( (aNumOfFilterPatterns == 1) /* test because poor osx behaviour */
11055
+						&& ( aFilterPatterns[0][strlen(aFilterPatterns[0])-1] != '*' ) ) )
11056
+			{
11057
+						strcat(lDialogString , "filetypes=(" ) ;
11058
+						strcat( lDialogString , "('" ) ;
11059
+						if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
11060
+						{
11061
+								strcat( lDialogString , aSingleFilterDescription ) ;
11062
+						}
11063
+						strcat( lDialogString , "',(" ) ;
11064
+						for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
11065
+						{
11066
+								strcat( lDialogString , "'" ) ;
11067
+								strcat( lDialogString , aFilterPatterns[i] ) ;
11068
+								strcat( lDialogString , "'," ) ;
11069
+						}
11070
+						strcat( lDialogString , "))," ) ;
11071
+						strcat( lDialogString , "('All files','*'))" ) ;
11072
+			}
11073
+						strcat( lDialogString, ");\nif not isinstance(res, tuple):\n\tprint res \n\"" ) ;
11074
+				}
11075
+		else if ( xdialogPresent() || dialogName() )
11076
+		{
11077
+				if ( xdialogPresent( ) )
11078
+				{
11079
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
11080
+						lWasGraphicDialog = 1 ;
11081
+						strcpy( lDialogString , "(Xdialog " ) ;
11082
+				}
11083
+				else if ( isTerminalRunning( ) )
11084
+				{
11085
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
11086
+						strcpy( lDialogString , "(dialog " ) ;
11087
+				}
11088
+				else
11089
+				{
11090
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
11091
+						lWasXterm = 1 ;
11092
+						strcpy( lDialogString , terminalName() ) ;
11093
+						strcat( lDialogString , "'(" ) ;
11094
+						strcat( lDialogString , dialogName() ) ;
11095
+						strcat( lDialogString , " " ) ;
11096
+				}
11097
 
11098
-                if ( aTitle && strlen(aTitle) )
11099
-                {
11100
-                        strcat(lDialogString, "--title \"") ;
11101
-                        strcat(lDialogString, aTitle) ;
11102
-                        strcat(lDialogString, "\" ") ;
11103
-                }
11104
+				if ( aTitle && strlen(aTitle) )
11105
+				{
11106
+						strcat(lDialogString, "--title \"") ;
11107
+						strcat(lDialogString, aTitle) ;
11108
+						strcat(lDialogString, "\" ") ;
11109
+				}
11110
 
11111
-                if ( !xdialogPresent() && !gdialogPresent() )
11112
-                {
11113
-                        strcat(lDialogString, "--backtitle \"") ;
11114
-                        strcat(lDialogString,
11115
-                                "tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
11116
-                        strcat(lDialogString, "\" ") ;
11117
-                }
11118
+				if ( !xdialogPresent() && !gdialogPresent() )
11119
+				{
11120
+						strcat(lDialogString, "--backtitle \"") ;
11121
+						strcat(lDialogString,
11122
+								"tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
11123
+						strcat(lDialogString, "\" ") ;
11124
+				}
11125
 
11126
-                strcat( lDialogString , "--fselect \"" ) ;
11127
-                if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
11128
-                {
11129
-                        if ( ! strchr(aDefaultPathAndFile, '/') )
11130
-                        {
11131
-                                strcat(lDialogString, "./") ;
11132
-                        }
11133
-                        strcat(lDialogString, aDefaultPathAndFile) ;
11134
-                }
11135
-                else if ( ! isTerminalRunning( ) && !lWasGraphicDialog )
11136
-                {
11137
-                        strcat(lDialogString, getenv("HOME")) ;
11138
-                        strcat(lDialogString, "/") ;
11139
-                }
11140
-                else
11141
-                {
11142
-                        strcat(lDialogString, "./") ;
11143
-                }
11144
+				strcat( lDialogString , "--fselect \"" ) ;
11145
+				if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
11146
+				{
11147
+						if ( ! strchr(aDefaultPathAndOrFile, '/') )
11148
+						{
11149
+								strcat(lDialogString, "./") ;
11150
+						}
11151
+						strcat(lDialogString, aDefaultPathAndOrFile) ;
11152
+				}
11153
+				else if ( ! isTerminalRunning( ) && !lWasGraphicDialog )
11154
+				{
11155
+						strcat(lDialogString, getenv("HOME")) ;
11156
+						strcat(lDialogString, "/") ;
11157
+				}
11158
+				else
11159
+				{
11160
+						strcat(lDialogString, "./") ;
11161
+				}
11162
 
11163
-                if ( lWasGraphicDialog )
11164
-                {
11165
-                        strcat(lDialogString, "\" 0 60 ) 2>&1 ") ;
11166
-                }
11167
-                else
11168
-                {
11169
-                        strcat(lDialogString, "\" 0 60  >/dev/tty) ") ;
11170
-                        if ( lWasXterm )
11171
-                        {
11172
-                          strcat( lDialogString ,
11173
-                                "2>/tmp/tinyfd.txt';cat /tmp/tinyfd.txt;rm /tmp/tinyfd.txt");
11174
-                        }
11175
-                        else
11176
-                        {
11177
-                                strcat(lDialogString, "2>&1 ; clear >/dev/tty") ;
11178
-                        }
11179
-                }
11180
-        }
11181
-        else
11182
-        {
11183
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){return tinyfd_inputBox(aTitle,NULL,NULL);}
11184
-				strcpy(lBuff, "Save file in ");
11185
-				strcat(lBuff, getCurDir());
11186
-				lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
11187
-				if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
11188
-				p = tinyfd_inputBox(aTitle, lBuff, "");
11189
-				if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
11190
-				if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
11191
-				p = lBuff;
11192
+				if ( lWasGraphicDialog )
11193
+				{
11194
+						strcat(lDialogString, "\" 0 60 ) 2>&1 ") ;
11195
+				}
11196
+				else
11197
+				{
11198
+						strcat(lDialogString, "\" 0 60  >/dev/tty) ") ;
11199
+						if ( lWasXterm )
11200
+						{
11201
+						  strcat( lDialogString ,
11202
+								"2>/tmp/tinyfd.txt';cat /tmp/tinyfd.txt;rm /tmp/tinyfd.txt");
11203
+						}
11204
+						else
11205
+						{
11206
+								strcat(lDialogString, "2>&1 ; clear >/dev/tty") ;
11207
+						}
11208
+				}
11209
+		}
11210
+		else
11211
+		{
11212
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){return tinyfd_inputBox(aTitle,NULL,NULL);}
11213
+								strcpy(lBuff, "Save file in ");
11214
+								strcat(lBuff, getCurDir());
11215
+								lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
11216
+								if (lPointerInputBox) strcpy(lString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
11217
+								p = tinyfd_inputBox(aTitle, lBuff, "");
11218
+								if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
11219
+								if (lPointerInputBox) strcpy(lPointerInputBox, lString); /* restore its previous content to tinyfd_inputBox */
11220
+								p = lBuff;
11221
 
11222
-				getPathWithoutFinalSlash( lString , p ) ;
11223
-                if ( strlen( lString ) && ! dirExists( lString ) )
11224
-                {
11225
-                        return NULL ;
11226
-                }
11227
-                getLastName(lString,p);
11228
-                if ( ! strlen(lString) )
11229
-                {
11230
-                        return NULL;
11231
-                }
11232
-                return p ;
11233
-        }
11234
+								getPathWithoutFinalSlash( lString , p ) ;
11235
+				if ( strlen( lString ) && ! dirExists( lString ) )
11236
+				{
11237
+						return NULL ;
11238
+				}
11239
+				getLastName(lString,p);
11240
+				if ( ! strlen(lString) )
11241
+				{
11242
+						return NULL;
11243
+				}
11244
+				return p ;
11245
+		}
11246
 
11247
-        if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
11248
-    if ( ! ( lIn = popen( lDialogString , "r" ) ) )
11249
+		if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
11250
+	if ( ! ( lIn = popen( lDialogString , "r" ) ) )
11251
+	{
11252
+		return NULL ;
11253
+	}
11254
+	while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
11255
+	{}
11256
+	pclose( lIn ) ;
11257
+	if ( strlen(lBuff) && lBuff[strlen( lBuff ) -1] == '\n' )
11258
+	{
11259
+		lBuff[strlen( lBuff ) -1] = '\0' ;
11260
+	}
11261
+    /* printf( "lBuff: %s\n" , lBuff ) ; */
11262
+    if ( ! strlen(lBuff) )
11263
     {
11264
-        return NULL ;
11265
+            return NULL;
11266
     }
11267
-    while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
11268
-    {}
11269
-    pclose( lIn ) ;
11270
-    if ( lBuff[strlen( lBuff ) -1] == '\n' )
11271
+
11272
+	getPathWithoutFinalSlash( lString , lBuff ) ;
11273
+	if ( strlen( lString ) && ! dirExists( lString ) )
11274
+	{
11275
+		return NULL ;
11276
+	}
11277
+	strcpy(lLastDirectory, lString) ;
11278
+
11279
+    getLastName(lString,lBuff);
11280
+    if ( ! filenameValid(lString) )
11281
     {
11282
-        lBuff[strlen( lBuff ) -1] = '\0' ;
11283
+            return NULL;
11284
     }
11285
-        /* printf( "lBuff: %s\n" , lBuff ) ; */
11286
-        if ( ! strlen(lBuff) )
11287
-        {
11288
-                return NULL;
11289
-        }
11290
-    getPathWithoutFinalSlash( lString , lBuff ) ;
11291
-    if ( strlen( lString ) && ! dirExists( lString ) )
11292
-    {
11293
-        return NULL ;
11294
-    }
11295
-        getLastName(lString,lBuff);
11296
-        if ( ! filenameValid(lString) )
11297
-        {
11298
-                return NULL;
11299
-        }
11300
-    return lBuff ;
11301
+	return lBuff ;
11302
 }
11303
 
11304
 
11305
 /* in case of multiple files, the separator is | */
11306
 char * tinyfd_openFileDialog(
11307
-	char const * aTitle , /* NULL or "" */
11308
-	char const * aDefaultPathAndFile , /* NULL or "" */
11309
-    int aNumOfFilterPatterns , /* 0 */
11310
-	char const * const * aFilterPatterns , /* NULL or {"*.jpg","*.png"} */
11311
-    char const * aSingleFilterDescription , /* NULL or "image files" */
11312
-    int aAllowMultipleSelects ) /* 0 or 1 */
11313
+    char const * aTitle , /* NULL or "" */
11314
+    char const * aDefaultPathAndOrFile , /* NULL or "" , ends with / to set only a directory */
11315
+	int aNumOfFilterPatterns , /* 0 */
11316
+    char const * const * aFilterPatterns , /* NULL or {"*.jpg","*.png"} */
11317
+	char const * aSingleFilterDescription , /* NULL or "image files" */
11318
+	int aAllowMultipleSelects ) /* 0 or 1 */
11319
 {
11320
-      char lDialogString[MAX_PATH_OR_CMD] ;
11321
-      char lString[MAX_PATH_OR_CMD] ;
11322
-      int i ;
11323
-      FILE * lIn ;
11324
-      char * p ;
11325
-      char * lPointerInputBox ;
11326
-      int lWasKdialog = 0 ;
11327
-      int lWasGraphicDialog = 0 ;
11328
-      int lWasXterm = 0 ;
11329
-      size_t lFullBuffLen ;
11330
-      static char * lBuff = NULL;
11331
+    static char * lBuff = NULL;
11332
+    static char lLastDirectory[MAX_PATH_OR_CMD] = "$PWD" ;
11333
 
11334
-		if (tfd_quoteDetected(aTitle)) return tinyfd_openFileDialog("INVALID TITLE WITH QUOTES", aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
11335
-		if (tfd_quoteDetected(aDefaultPathAndFile)) return tinyfd_openFileDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
11336
-		if (tfd_quoteDetected(aSingleFilterDescription)) return tinyfd_openFileDialog(aTitle, aDefaultPathAndFile, aNumOfFilterPatterns, aFilterPatterns, "INVALID FILTER_DESCRIPTION WITH QUOTES", aAllowMultipleSelects);
11337
-		for (i = 0; i < aNumOfFilterPatterns; i++)
11338
-		{
11339
-			if (tfd_quoteDetected(aFilterPatterns[i])) return tinyfd_openFileDialog("INVALID FILTER_PATTERN WITH QUOTES", aDefaultPathAndFile, 0, NULL, NULL, aAllowMultipleSelects);
11340
-		}
11341
+    char lDialogString[MAX_PATH_OR_CMD] ;
11342
+    char lString[MAX_PATH_OR_CMD] ;
11343
+    int i ;
11344
+    FILE * lIn ;
11345
+    char * p ;
11346
+    char * lPointerInputBox ;
11347
+    size_t lFullBuffLen ;
11348
+    int lWasKdialog = 0 ;
11349
+    int lWasGraphicDialog = 0 ;
11350
+    int lWasXterm = 0 ;
11351
 
11352
-		free(lBuff);
11353
-		if (aTitle&&!strcmp(aTitle,"tinyfd_query"))
11354
-		{
11355
-			lBuff = NULL;
11356
-		}
11357
-		else
11358
-		{
11359
-			if (aAllowMultipleSelects)
11360
-			{
11361
-				lFullBuffLen = MAX_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
11362
-				lBuff = (char *)(malloc(lFullBuffLen * sizeof(char)));
11363
-				if (!lBuff)
11364
+		if ( ! aFilterPatterns ) aNumOfFilterPatterns = 0 ;
11365
+				if (tfd_quoteDetected(aTitle)) return tinyfd_openFileDialog("INVALID TITLE WITH QUOTES", aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
11366
+				if (tfd_quoteDetected(aDefaultPathAndOrFile)) return tinyfd_openFileDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES", aNumOfFilterPatterns, aFilterPatterns, aSingleFilterDescription, aAllowMultipleSelects);
11367
+				if (tfd_quoteDetected(aSingleFilterDescription)) return tinyfd_openFileDialog(aTitle, aDefaultPathAndOrFile, aNumOfFilterPatterns, aFilterPatterns, "INVALID FILTER_DESCRIPTION WITH QUOTES", aAllowMultipleSelects);
11368
+				for (i = 0; i < aNumOfFilterPatterns; i++)
11369
 				{
11370
-					lFullBuffLen = LOW_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
11371
-					lBuff = (char *)( malloc( lFullBuffLen * sizeof(char)));
11372
+						if (tfd_quoteDetected(aFilterPatterns[i])) return tinyfd_openFileDialog("INVALID FILTER_PATTERN WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultPathAndOrFile, 0, NULL, NULL, aAllowMultipleSelects);
11373
 				}
11374
-			}
11375
-			else
11376
-			{
11377
-				lFullBuffLen = MAX_PATH_OR_CMD + 1;
11378
-				lBuff = (char *)(malloc(lFullBuffLen * sizeof(char)));
11379
-			}
11380
-			if (!lBuff) return NULL;
11381
-			lBuff[0]='\0';
11382
-		}
11383
 
11384
-        if ( osascriptPresent( ) )
11385
-        {
11386
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
11387
-                strcpy( lDialogString , "osascript ");
11388
-                if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
11389
-                strcat( lDialogString , " -e 'try' -e '" );
11390
-    if ( ! aAllowMultipleSelects )
11391
-    {
11392
+				free(lBuff);
11393
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query"))
11394
+				{
11395
+						lBuff = NULL;
11396
+				}
11397
+				else
11398
+				{
11399
+						if (aAllowMultipleSelects)
11400
+						{
11401
+								lFullBuffLen = MAX_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
11402
+								lBuff = (char *) malloc(lFullBuffLen * sizeof(char));
11403
+								if (!lBuff)
11404
+								{
11405
+										lFullBuffLen = LOW_MULTIPLE_FILES * MAX_PATH_OR_CMD + 1;
11406
+										lBuff = (char *) malloc( lFullBuffLen * sizeof(char));
11407
+								}
11408
+						}
11409
+						else
11410
+						{
11411
+								lFullBuffLen = MAX_PATH_OR_CMD + 1;
11412
+								lBuff = (char *) malloc(lFullBuffLen * sizeof(char));
11413
+						}
11414
+						if (!lBuff) return NULL;
11415
+						lBuff[0]='\0';
11416
+				}
11417
 
11418
+		if ( osascriptPresent( ) )
11419
+		{
11420
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
11421
+				strcpy( lDialogString , "osascript ");
11422
+				if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
11423
+				strcat( lDialogString , " -e 'try' -e '" );
11424
+	if ( ! aAllowMultipleSelects )
11425
+	{
11426
 
11427
-                        strcat( lDialogString , "POSIX path of ( " );
11428
-                }
11429
-                else
11430
-                {
11431
-                        strcat( lDialogString , "set mylist to " );
11432
-                }
11433
-                strcat( lDialogString , "choose file " );
11434
-            if ( aTitle && strlen(aTitle) )
11435
-            {
11436
-                        strcat(lDialogString, "with prompt \"") ;
11437
-                        strcat(lDialogString, aTitle) ;
11438
-                        strcat(lDialogString, "\" ") ;
11439
-            }
11440
-                getPathWithoutFinalSlash( lString , aDefaultPathAndFile ) ;
11441
-                if ( strlen(lString) )
11442
-                {
11443
-                        strcat(lDialogString, "default location \"") ;
11444
-                        strcat(lDialogString, lString ) ;
11445
-                        strcat(lDialogString , "\" " ) ;
11446
-                }
11447
-                if ( aNumOfFilterPatterns > 0 )
11448
-                {
11449
-                        strcat(lDialogString , "of type {\"" );
11450
-                        strcat( lDialogString , aFilterPatterns[0] + 2 ) ;
11451
-                        strcat( lDialogString , "\"" ) ;
11452
-                        for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ )
11453
-                        {
11454
-                                strcat( lDialogString , ",\"" ) ;
11455
-                                strcat( lDialogString , aFilterPatterns[i] + 2) ;
11456
-                                strcat( lDialogString , "\"" ) ;
11457
-                        }
11458
-                        strcat( lDialogString , "} " ) ;
11459
-                }
11460
-                if ( aAllowMultipleSelects )
11461
-                {
11462
-                        strcat( lDialogString , "multiple selections allowed true ' " ) ;
11463
-                        strcat( lDialogString ,
11464
-                                        "-e 'set mystring to POSIX path of item 1 of mylist' " );
11465
-                        strcat( lDialogString ,
11466
-                                        "-e 'repeat with  i from 2 to the count of mylist' " );
11467
-                        strcat( lDialogString , "-e 'set mystring to mystring & \"|\"' " );
11468
-                        strcat( lDialogString ,
11469
-                        "-e 'set mystring to mystring & POSIX path of item i of mylist' " );
11470
-                        strcat( lDialogString , "-e 'end repeat' " );
11471
-                        strcat( lDialogString , "-e 'mystring' " );
11472
-                }
11473
-                else
11474
-                {
11475
-                        strcat( lDialogString , ")' " ) ;
11476
-                }
11477
-                strcat(lDialogString, "-e 'on error number -128' " ) ;
11478
-                strcat(lDialogString, "-e 'end try'") ;
11479
-                if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
11480
-        }
11481
-        else if ( tfd_kdialogPresent() )
11482
-        {
11483
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
11484
-                lWasKdialog = 1 ;
11485
 
11486
-                strcpy( lDialogString , "kdialog" ) ;
11487
-				if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
11488
-                {
11489
-                        strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
11490
-                }
11491
-                strcat( lDialogString , " --getopenfilename " ) ;
11492
-
11493
-                if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
11494
-                {
11495
-                        if ( aDefaultPathAndFile[0] != '/' )
11496
-                        {
11497
-                                strcat(lDialogString, "$PWD/") ;
11498
-                        }
11499
-                        strcat(lDialogString, "\"") ;
11500
-                        strcat(lDialogString, aDefaultPathAndFile ) ;
11501
-                        strcat(lDialogString , "\"" ) ;
11502
-                }
11503
-                else
11504
-                {
11505
-                        strcat(lDialogString, "$PWD/") ;
11506
-                }
11507
-
11508
-                if ( aNumOfFilterPatterns > 0 )
11509
-                {
11510
-                        strcat(lDialogString , " \"" ) ;
11511
-						strcat( lDialogString , aFilterPatterns[0] ) ;
11512
-                        for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ )
11513
-                        {
11514
-							strcat( lDialogString , " " ) ;
11515
-							strcat( lDialogString , aFilterPatterns[i] ) ;
11516
-                        }
11517
-                        if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
11518
-                        {
11519
-                                strcat( lDialogString , " | " ) ;
11520
-                                strcat( lDialogString , aSingleFilterDescription ) ;
11521
-                        }
11522
-                        strcat( lDialogString , "\"" ) ;
11523
-                }
11524
-                if ( aAllowMultipleSelects )
11525
-                {
11526
-                        strcat( lDialogString , " --multiple --separate-output" ) ;
11527
-                }
11528
-                if ( aTitle && strlen(aTitle) )
11529
-                {
11530
-                        strcat(lDialogString, " --title \"") ;
11531
-                        strcat(lDialogString, aTitle) ;
11532
-                        strcat(lDialogString, "\"") ;
11533
-                }
11534
-        }
11535
-        else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
11536
-        {
11537
-                if ( tfd_zenityPresent() )
11538
-                {
11539
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return (char *)1;}
11540
-                        strcpy( lDialogString , "zenity" ) ;
11541
-						if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
11542
-                        {
11543
-                                strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
11544
-                        }
11545
-                }
11546
-                else if ( tfd_matedialogPresent() )
11547
-                {
11548
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
11549
-                        strcpy( lDialogString , "matedialog" ) ;
11550
-                }
11551
-                else if ( tfd_shellementaryPresent() )
11552
-                {
11553
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
11554
-                        strcpy( lDialogString , "shellementary" ) ;
11555
-                }
11556
-                else
11557
-                {
11558
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
11559
-                        strcpy( lDialogString , "qarma" ) ;
11560
-						if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
11561
-                        {
11562
-                                strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
11563
-                        }
11564
-                }
11565
-                strcat( lDialogString , " --file-selection" ) ;
11566
-
11567
-                if ( aAllowMultipleSelects )
11568
-                {
11569
-                        strcat( lDialogString , " --multiple" ) ;
11570
-                }
11571
-                if ( aTitle && strlen(aTitle) )
11572
-                {
11573
-                        strcat(lDialogString, " --title=\"") ;
11574
-                        strcat(lDialogString, aTitle) ;
11575
-                        strcat(lDialogString, "\"") ;
11576
-                }
11577
-                if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
11578
-                {
11579
-                        strcat(lDialogString, " --filename=\"") ;
11580
-                        strcat(lDialogString, aDefaultPathAndFile) ;
11581
-                        strcat(lDialogString, "\"") ;
11582
-                }
11583
-                if ( aNumOfFilterPatterns > 0 )
11584
-                {
11585
-                        strcat( lDialogString , " --file-filter='" ) ;
11586
-                        if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
11587
-                        {
11588
-                                strcat( lDialogString , aSingleFilterDescription ) ;
11589
-                                strcat( lDialogString , " |" ) ;
11590
-                        }
11591
-                        for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
11592
-                        {
11593
-							strcat( lDialogString , " " ) ;
11594
-							strcat( lDialogString , aFilterPatterns[i] ) ;
11595
-                        }
11596
-                        strcat( lDialogString , "' --file-filter='All files | *'" ) ;
11597
-                }
11598
-                if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
11599
-        }
11600
-        else if (tfd_yadPresent())
11601
-        {
11602
-           if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
11603
-           strcpy(lDialogString, "yad --file-selection");
11604
-           if (aAllowMultipleSelects)
11605
-           {
11606
-              strcat(lDialogString, " --multiple");
11607
-           }
11608
-           if (aTitle && strlen(aTitle))
11609
-           {
11610
-              strcat(lDialogString, " --title=\"");
11611
-              strcat(lDialogString, aTitle);
11612
-              strcat(lDialogString, "\"");
11613
-           }
11614
-           if (aDefaultPathAndFile && strlen(aDefaultPathAndFile))
11615
-           {
11616
-              strcat(lDialogString, " --filename=\"");
11617
-              strcat(lDialogString, aDefaultPathAndFile);
11618
-              strcat(lDialogString, "\"");
11619
-           }
11620
-           if (aNumOfFilterPatterns > 0)
11621
-           {
11622
-              strcat(lDialogString, " --file-filter='");
11623
-              if (aSingleFilterDescription && strlen(aSingleFilterDescription))
11624
-              {
11625
-                 strcat(lDialogString, aSingleFilterDescription);
11626
-                 strcat(lDialogString, " |");
11627
-              }
11628
-              for (i = 0; i < aNumOfFilterPatterns; i++)
11629
-              {
11630
-                 strcat(lDialogString, " ");
11631
-                 strcat(lDialogString, aFilterPatterns[i]);
11632
-              }
11633
-              strcat(lDialogString, "' --file-filter='All files | *'");
11634
-           }
11635
-           if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
11636
-      }
11637
-      else if ( tkinter3Present( ) )
11638
-		{
11639
-			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
11640
-			strcpy( lDialogString , gPython3Name ) ;
11641
-			strcat( lDialogString ,
11642
-				" -S -c \"import tkinter;from tkinter import filedialog;root=tkinter.Tk();root.withdraw();");
11643
-			strcat( lDialogString , "lFiles=filedialog.askopenfilename(");
11644
-			if ( aAllowMultipleSelects )
11645
-			{
11646
-				strcat( lDialogString , "multiple=1," ) ;
11647
-			}
11648
+						strcat( lDialogString , "POSIX path of ( " );
11649
+				}
11650
+				else
11651
+				{
11652
+						strcat( lDialogString , "set mylist to " );
11653
+				}
11654
+				strcat( lDialogString , "choose file " );
11655
 			if ( aTitle && strlen(aTitle) )
11656
 			{
11657
-				strcat(lDialogString, "title='") ;
11658
-				strcat(lDialogString, aTitle) ;
11659
-				strcat(lDialogString, "',") ;
11660
+						strcat(lDialogString, "with prompt \"") ;
11661
+						strcat(lDialogString, aTitle) ;
11662
+						strcat(lDialogString, "\" ") ;
11663
 			}
11664
-			if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
11665
-			{
11666
-				getPathWithoutFinalSlash( lString , aDefaultPathAndFile ) ;
11667
+				getPathWithoutFinalSlash( lString , aDefaultPathAndOrFile ) ;
11668
 				if ( strlen(lString) )
11669
 				{
11670
-					strcat(lDialogString, "initialdir='") ;
11671
-					strcat(lDialogString, lString ) ;
11672
-					strcat(lDialogString , "'," ) ;
11673
+						strcat(lDialogString, "default location \"") ;
11674
+						strcat(lDialogString, lString ) ;
11675
+						strcat(lDialogString , "\" " ) ;
11676
 				}
11677
-				getLastName( lString , aDefaultPathAndFile ) ;
11678
-				if ( strlen(lString) )
11679
+				if ( aNumOfFilterPatterns > 0 )
11680
 				{
11681
-					strcat(lDialogString, "initialfile='") ;
11682
-					strcat(lDialogString, lString ) ;
11683
-					strcat(lDialogString , "'," ) ;
11684
+						strcat(lDialogString , "of type {\"" );
11685
+						strcat( lDialogString , aFilterPatterns[0] + 2 ) ;
11686
+						strcat( lDialogString , "\"" ) ;
11687
+						for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ )
11688
+						{
11689
+								strcat( lDialogString , ",\"" ) ;
11690
+								strcat( lDialogString , aFilterPatterns[i] + 2) ;
11691
+								strcat( lDialogString , "\"" ) ;
11692
+						}
11693
+						strcat( lDialogString , "} " ) ;
11694
 				}
11695
-			}
11696
-			if ( ( aNumOfFilterPatterns > 1 )
11697
-				|| ( ( aNumOfFilterPatterns == 1 ) /*test because poor osx behaviour*/
11698
-				&& ( aFilterPatterns[0][strlen(aFilterPatterns[0])-1] != '*' ) ) )
11699
-			{
11700
-				strcat(lDialogString , "filetypes=(" ) ;
11701
-				strcat( lDialogString , "('" ) ;
11702
-				if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
11703
+				if ( aAllowMultipleSelects )
11704
 				{
11705
-					strcat( lDialogString , aSingleFilterDescription ) ;
11706
+						strcat( lDialogString , "multiple selections allowed true ' " ) ;
11707
+						strcat( lDialogString ,
11708
+										"-e 'set mystring to POSIX path of item 1 of mylist' " );
11709
+						strcat( lDialogString ,
11710
+										"-e 'repeat with  i from 2 to the count of mylist' " );
11711
+						strcat( lDialogString , "-e 'set mystring to mystring & \"|\"' " );
11712
+						strcat( lDialogString ,
11713
+						"-e 'set mystring to mystring & POSIX path of item i of mylist' " );
11714
+						strcat( lDialogString , "-e 'end repeat' " );
11715
+						strcat( lDialogString , "-e 'mystring' " );
11716
 				}
11717
-				strcat( lDialogString , "',(" ) ;
11718
-				for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
11719
+				else
11720
 				{
11721
-					strcat( lDialogString , "'" ) ;
11722
-					strcat( lDialogString , aFilterPatterns[i] ) ;
11723
-					strcat( lDialogString , "'," ) ;
11724
+						strcat( lDialogString , ")' " ) ;
11725
 				}
11726
-				strcat( lDialogString , "))," ) ;
11727
-				strcat( lDialogString , "('All files','*'))" ) ;
11728
-			}
11729
-			strcat( lDialogString , ");\
11730
+				strcat(lDialogString, "-e 'on error number -128' " ) ;
11731
+				strcat(lDialogString, "-e 'end try'") ;
11732
+				if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
11733
+		}
11734
+		else if ( tfd_kdialogPresent() )
11735
+		{
11736
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
11737
+				lWasKdialog = 1 ;
11738
+
11739
+				strcpy( lDialogString , "kdialog" ) ;
11740
+								if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
11741
+				{
11742
+						strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
11743
+				}
11744
+				strcat( lDialogString , " --getopenfilename " ) ;
11745
+
11746
+				if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
11747
+				{
11748
+                    if ( aDefaultPathAndOrFile[0] != '/' )
11749
+                    {
11750
+                        strcat(lDialogString, lLastDirectory) ;
11751
+                        strcat(lDialogString , "/" ) ;
11752
+                    }
11753
+                    strcat(lDialogString, "\"") ;
11754
+                    strcat(lDialogString, aDefaultPathAndOrFile ) ;
11755
+                    strcat(lDialogString , "\"" ) ;
11756
+				}
11757
+				else
11758
+				{
11759
+                    strcat(lDialogString, lLastDirectory) ;
11760
+                    strcat(lDialogString , "/" ) ;
11761
+				}
11762
+
11763
+				if ( aNumOfFilterPatterns > 0 )
11764
+				{
11765
+						strcat(lDialogString , " \"" ) ;
11766
+												strcat( lDialogString , aFilterPatterns[0] ) ;
11767
+						for ( i = 1 ; i < aNumOfFilterPatterns ; i ++ )
11768
+						{
11769
+														strcat( lDialogString , " " ) ;
11770
+														strcat( lDialogString , aFilterPatterns[i] ) ;
11771
+						}
11772
+						if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
11773
+						{
11774
+								strcat( lDialogString , " | " ) ;
11775
+								strcat( lDialogString , aSingleFilterDescription ) ;
11776
+						}
11777
+						strcat( lDialogString , "\"" ) ;
11778
+				}
11779
+				if ( aAllowMultipleSelects )
11780
+				{
11781
+						strcat( lDialogString , " --multiple --separate-output" ) ;
11782
+				}
11783
+				if ( aTitle && strlen(aTitle) )
11784
+				{
11785
+						strcat(lDialogString, " --title \"") ;
11786
+						strcat(lDialogString, aTitle) ;
11787
+						strcat(lDialogString, "\"") ;
11788
+				}
11789
+		}
11790
+		else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
11791
+		{
11792
+				if ( tfd_zenityPresent() )
11793
+				{
11794
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return (char *)1;}
11795
+						strcpy( lDialogString , "zenity" ) ;
11796
+												if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
11797
+						{
11798
+								strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
11799
+						}
11800
+				}
11801
+				else if ( tfd_matedialogPresent() )
11802
+				{
11803
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
11804
+						strcpy( lDialogString , "matedialog" ) ;
11805
+				}
11806
+				else if ( tfd_shellementaryPresent() )
11807
+				{
11808
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
11809
+						strcpy( lDialogString , "shellementary" ) ;
11810
+				}
11811
+				else
11812
+				{
11813
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
11814
+						strcpy( lDialogString , "qarma" ) ;
11815
+												if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
11816
+						{
11817
+								strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
11818
+						}
11819
+				}
11820
+				strcat( lDialogString , " --file-selection" ) ;
11821
+
11822
+				if ( aAllowMultipleSelects )
11823
+				{
11824
+						strcat( lDialogString , " --multiple" ) ;
11825
+				}
11826
+
11827
+				strcat(lDialogString, " --title=\"") ;
11828
+				if (aTitle && strlen(aTitle)) strcat(lDialogString, aTitle) ;
11829
+				strcat(lDialogString, "\"") ;
11830
+
11831
+				if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
11832
+				{
11833
+						strcat(lDialogString, " --filename=\"") ;
11834
+						strcat(lDialogString, aDefaultPathAndOrFile) ;
11835
+						strcat(lDialogString, "\"") ;
11836
+				}
11837
+				if ( aNumOfFilterPatterns > 0 )
11838
+				{
11839
+						strcat( lDialogString , " --file-filter='" ) ;
11840
+						if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
11841
+						{
11842
+								strcat( lDialogString , aSingleFilterDescription ) ;
11843
+								strcat( lDialogString , " |" ) ;
11844
+						}
11845
+						for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
11846
+						{
11847
+														strcat( lDialogString , " " ) ;
11848
+														strcat( lDialogString , aFilterPatterns[i] ) ;
11849
+						}
11850
+						strcat( lDialogString , "' --file-filter='All files | *'" ) ;
11851
+				}
11852
+				if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
11853
+		}
11854
+		else if (tfd_yadPresent())
11855
+		{
11856
+		   if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
11857
+		   strcpy(lDialogString, "yad --file");
11858
+		   if (aAllowMultipleSelects)
11859
+		   {
11860
+			  strcat(lDialogString, " --multiple");
11861
+		   }
11862
+		   if (aTitle && strlen(aTitle))
11863
+		   {
11864
+			  strcat(lDialogString, " --title=\"");
11865
+			  strcat(lDialogString, aTitle);
11866
+			  strcat(lDialogString, "\"");
11867
+		   }
11868
+		   if (aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile))
11869
+		   {
11870
+			  strcat(lDialogString, " --filename=\"");
11871
+			  strcat(lDialogString, aDefaultPathAndOrFile);
11872
+			  strcat(lDialogString, "\"");
11873
+		   }
11874
+		   if (aNumOfFilterPatterns > 0)
11875
+		   {
11876
+			  strcat(lDialogString, " --file-filter='");
11877
+			  if (aSingleFilterDescription && strlen(aSingleFilterDescription))
11878
+			  {
11879
+				 strcat(lDialogString, aSingleFilterDescription);
11880
+				 strcat(lDialogString, " |");
11881
+			  }
11882
+			  for (i = 0; i < aNumOfFilterPatterns; i++)
11883
+			  {
11884
+				 strcat(lDialogString, " ");
11885
+				 strcat(lDialogString, aFilterPatterns[i]);
11886
+			  }
11887
+			  strcat(lDialogString, "' --file-filter='All files | *'");
11888
+		   }
11889
+		   if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
11890
+	  }
11891
+	  else if ( tkinter3Present( ) )
11892
+				{
11893
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
11894
+						strcpy( lDialogString , gPython3Name ) ;
11895
+						strcat( lDialogString ,
11896
+								" -S -c \"import tkinter;from tkinter import filedialog;root=tkinter.Tk();root.withdraw();");
11897
+						strcat( lDialogString , "lFiles=filedialog.askopenfilename(");
11898
+						if ( aAllowMultipleSelects )
11899
+						{
11900
+								strcat( lDialogString , "multiple=1," ) ;
11901
+						}
11902
+						if ( aTitle && strlen(aTitle) )
11903
+						{
11904
+								strcat(lDialogString, "title='") ;
11905
+								strcat(lDialogString, aTitle) ;
11906
+								strcat(lDialogString, "',") ;
11907
+						}
11908
+						if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
11909
+						{
11910
+								getPathWithoutFinalSlash( lString , aDefaultPathAndOrFile ) ;
11911
+								if ( strlen(lString) )
11912
+								{
11913
+										strcat(lDialogString, "initialdir='") ;
11914
+										strcat(lDialogString, lString ) ;
11915
+										strcat(lDialogString , "'," ) ;
11916
+								}
11917
+								getLastName( lString , aDefaultPathAndOrFile ) ;
11918
+								if ( strlen(lString) )
11919
+								{
11920
+										strcat(lDialogString, "initialfile='") ;
11921
+										strcat(lDialogString, lString ) ;
11922
+										strcat(lDialogString , "'," ) ;
11923
+								}
11924
+						}
11925
+						if ( ( aNumOfFilterPatterns > 1 )
11926
+								|| ( ( aNumOfFilterPatterns == 1 ) /*test because poor osx behaviour*/
11927
+								&& ( aFilterPatterns[0][strlen(aFilterPatterns[0])-1] != '*' ) ) )
11928
+						{
11929
+								strcat(lDialogString , "filetypes=(" ) ;
11930
+								strcat( lDialogString , "('" ) ;
11931
+								if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
11932
+								{
11933
+										strcat( lDialogString , aSingleFilterDescription ) ;
11934
+								}
11935
+								strcat( lDialogString , "',(" ) ;
11936
+								for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
11937
+								{
11938
+										strcat( lDialogString , "'" ) ;
11939
+										strcat( lDialogString , aFilterPatterns[i] ) ;
11940
+										strcat( lDialogString , "'," ) ;
11941
+								}
11942
+								strcat( lDialogString , "))," ) ;
11943
+								strcat( lDialogString , "('All files','*'))" ) ;
11944
+						}
11945
+						strcat( lDialogString , ");\
11946
 \nif not isinstance(lFiles, tuple):\n\tprint(lFiles)\nelse:\
11947
 \n\tlFilesString=''\n\tfor lFile in lFiles:\n\t\tlFilesString+=str(lFile)+'|'\
11948
 \n\tprint(lFilesString[:-1])\n\"" ) ;
11949
-		}
11950
-		else if ( tkinter2Present( ) )
11951
-        {
11952
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
11953
-				strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
11954
-				strcat( lDialogString , gPython2Name ) ;
11955
-				if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
11956
-                {
11957
-                strcat( lDialogString , " -i" ) ;  /* for osx without console */
11958
-                }
11959
-                strcat( lDialogString ,
11960
+				}
11961
+				else if ( tkinter2Present( ) )
11962
+		{
11963
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
11964
+								strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
11965
+								strcat( lDialogString , gPython2Name ) ;
11966
+								if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
11967
+				{
11968
+				strcat( lDialogString , " -i" ) ;  /* for osx without console */
11969
+				}
11970
+				strcat( lDialogString ,
11971
 " -S -c \"import Tkinter,tkFileDialog;root=Tkinter.Tk();root.withdraw();");
11972
 
11973
-        if ( tfd_isDarwin( ) )
11974
-        {
11975
-                        strcat( lDialogString ,
11976
+		if ( tfd_isDarwin( ) )
11977
+		{
11978
+						strcat( lDialogString ,
11979
 "import os;os.system('''/usr/bin/osascript -e 'tell app \\\"Finder\\\" to set \
11980
 frontmost of process \\\"Python\\\" to true' ''');");
11981
-                }
11982
-                strcat( lDialogString , "lFiles=tkFileDialog.askopenfilename(");
11983
-    if ( aAllowMultipleSelects )
11984
-    {
11985
-                        strcat( lDialogString , "multiple=1," ) ;
11986
-    }
11987
-    if ( aTitle && strlen(aTitle) )
11988
-    {
11989
-                        strcat(lDialogString, "title='") ;
11990
-                        strcat(lDialogString, aTitle) ;
11991
-                        strcat(lDialogString, "',") ;
11992
-    }
11993
-    if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
11994
-    {
11995
-                        getPathWithoutFinalSlash( lString , aDefaultPathAndFile ) ;
11996
-                        if ( strlen(lString) )
11997
-                        {
11998
-                                strcat(lDialogString, "initialdir='") ;
11999
-                                strcat(lDialogString, lString ) ;
12000
-                                strcat(lDialogString , "'," ) ;
12001
-                        }
12002
-                        getLastName( lString , aDefaultPathAndFile ) ;
12003
-                        if ( strlen(lString) )
12004
-                        {
12005
-                                strcat(lDialogString, "initialfile='") ;
12006
-                                strcat(lDialogString, lString ) ;
12007
-                                strcat(lDialogString , "'," ) ;
12008
-                        }
12009
-                }
12010
-                if ( ( aNumOfFilterPatterns > 1 )
12011
-                        || ( ( aNumOfFilterPatterns == 1 ) /*test because poor osx behaviour*/
12012
-                                && ( aFilterPatterns[0][strlen(aFilterPatterns[0])-1] != '*' ) ) )
12013
-                {
12014
-                        strcat(lDialogString , "filetypes=(" ) ;
12015
-                        strcat( lDialogString , "('" ) ;
12016
-                        if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
12017
-                        {
12018
-                                strcat( lDialogString , aSingleFilterDescription ) ;
12019
-                        }
12020
-                        strcat( lDialogString , "',(" ) ;
12021
-                        for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
12022
-                        {
12023
-                                strcat( lDialogString , "'" ) ;
12024
-                                strcat( lDialogString , aFilterPatterns[i] ) ;
12025
-                                strcat( lDialogString , "'," ) ;
12026
-                        }
12027
-                        strcat( lDialogString , "))," ) ;
12028
-                        strcat( lDialogString , "('All files','*'))" ) ;
12029
-                }
12030
-                strcat( lDialogString , ");\
12031
+				}
12032
+				strcat( lDialogString , "lFiles=tkFileDialog.askopenfilename(");
12033
+	if ( aAllowMultipleSelects )
12034
+	{
12035
+						strcat( lDialogString , "multiple=1," ) ;
12036
+	}
12037
+	if ( aTitle && strlen(aTitle) )
12038
+	{
12039
+						strcat(lDialogString, "title='") ;
12040
+						strcat(lDialogString, aTitle) ;
12041
+						strcat(lDialogString, "',") ;
12042
+	}
12043
+	if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
12044
+	{
12045
+						getPathWithoutFinalSlash( lString , aDefaultPathAndOrFile ) ;
12046
+						if ( strlen(lString) )
12047
+						{
12048
+								strcat(lDialogString, "initialdir='") ;
12049
+								strcat(lDialogString, lString ) ;
12050
+								strcat(lDialogString , "'," ) ;
12051
+						}
12052
+						getLastName( lString , aDefaultPathAndOrFile ) ;
12053
+						if ( strlen(lString) )
12054
+						{
12055
+								strcat(lDialogString, "initialfile='") ;
12056
+								strcat(lDialogString, lString ) ;
12057
+								strcat(lDialogString , "'," ) ;
12058
+						}
12059
+				}
12060
+				if ( ( aNumOfFilterPatterns > 1 )
12061
+						|| ( ( aNumOfFilterPatterns == 1 ) /*test because poor osx behaviour*/
12062
+								&& ( aFilterPatterns[0][strlen(aFilterPatterns[0])-1] != '*' ) ) )
12063
+				{
12064
+						strcat(lDialogString , "filetypes=(" ) ;
12065
+						strcat( lDialogString , "('" ) ;
12066
+						if ( aSingleFilterDescription && strlen(aSingleFilterDescription) )
12067
+						{
12068
+								strcat( lDialogString , aSingleFilterDescription ) ;
12069
+						}
12070
+						strcat( lDialogString , "',(" ) ;
12071
+						for ( i = 0 ; i < aNumOfFilterPatterns ; i ++ )
12072
+						{
12073
+								strcat( lDialogString , "'" ) ;
12074
+								strcat( lDialogString , aFilterPatterns[i] ) ;
12075
+								strcat( lDialogString , "'," ) ;
12076
+						}
12077
+						strcat( lDialogString , "))," ) ;
12078
+						strcat( lDialogString , "('All files','*'))" ) ;
12079
+				}
12080
+				strcat( lDialogString , ");\
12081
 \nif not isinstance(lFiles, tuple):\n\tprint lFiles\nelse:\
12082
 \n\tlFilesString=''\n\tfor lFile in lFiles:\n\t\tlFilesString+=str(lFile)+'|'\
12083
 \n\tprint lFilesString[:-1]\n\"" ) ;
12084
-        }
12085
-        else if ( xdialogPresent() || dialogName() )
12086
-        {
12087
-                if ( xdialogPresent( ) )
12088
-                {
12089
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
12090
-                        lWasGraphicDialog = 1 ;
12091
-                        strcpy( lDialogString , "(Xdialog " ) ;
12092
-                }
12093
-                else if ( isTerminalRunning( ) )
12094
-                {
12095
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
12096
-                        strcpy( lDialogString , "(dialog " ) ;
12097
-                }
12098
-                else
12099
-                {
12100
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
12101
-                        lWasXterm = 1 ;
12102
-                        strcpy( lDialogString , terminalName() ) ;
12103
-                        strcat( lDialogString , "'(" ) ;
12104
-                        strcat( lDialogString , dialogName() ) ;
12105
-                        strcat( lDialogString , " " ) ;
12106
-                }
12107
+		}
12108
+		else if ( xdialogPresent() || dialogName() )
12109
+		{
12110
+				if ( xdialogPresent( ) )
12111
+				{
12112
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
12113
+						lWasGraphicDialog = 1 ;
12114
+						strcpy( lDialogString , "(Xdialog " ) ;
12115
+				}
12116
+				else if ( isTerminalRunning( ) )
12117
+				{
12118
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
12119
+						strcpy( lDialogString , "(dialog " ) ;
12120
+				}
12121
+				else
12122
+				{
12123
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
12124
+						lWasXterm = 1 ;
12125
+						strcpy( lDialogString , terminalName() ) ;
12126
+						strcat( lDialogString , "'(" ) ;
12127
+						strcat( lDialogString , dialogName() ) ;
12128
+						strcat( lDialogString , " " ) ;
12129
+				}
12130
 
12131
-                if ( aTitle && strlen(aTitle) )
12132
-                {
12133
-                        strcat(lDialogString, "--title \"") ;
12134
-                        strcat(lDialogString, aTitle) ;
12135
-                        strcat(lDialogString, "\" ") ;
12136
-                }
12137
+				if ( aTitle && strlen(aTitle) )
12138
+				{
12139
+						strcat(lDialogString, "--title \"") ;
12140
+						strcat(lDialogString, aTitle) ;
12141
+						strcat(lDialogString, "\" ") ;
12142
+				}
12143
 
12144
-                if ( !xdialogPresent() && !gdialogPresent() )
12145
-                {
12146
-                        strcat(lDialogString, "--backtitle \"") ;
12147
-                        strcat(lDialogString,
12148
-                                "tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
12149
-                        strcat(lDialogString, "\" ") ;
12150
-                }
12151
+				if ( !xdialogPresent() && !gdialogPresent() )
12152
+				{
12153
+						strcat(lDialogString, "--backtitle \"") ;
12154
+						strcat(lDialogString,
12155
+								"tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
12156
+						strcat(lDialogString, "\" ") ;
12157
+				}
12158
 
12159
-                strcat( lDialogString , "--fselect \"" ) ;
12160
-                if ( aDefaultPathAndFile && strlen(aDefaultPathAndFile) )
12161
-                {
12162
-                        if ( ! strchr(aDefaultPathAndFile, '/') )
12163
-                        {
12164
-                                strcat(lDialogString, "./") ;
12165
-                        }
12166
-                        strcat(lDialogString, aDefaultPathAndFile) ;
12167
-                }
12168
-                else if ( ! isTerminalRunning( ) && !lWasGraphicDialog )
12169
-                {
12170
-                        strcat(lDialogString, getenv("HOME")) ;
12171
-                        strcat(lDialogString, "/");
12172
-                }
12173
-                else
12174
-                {
12175
-                        strcat(lDialogString, "./") ;
12176
-                }
12177
-
12178
-                if ( lWasGraphicDialog )
12179
-                {
12180
-                        strcat(lDialogString, "\" 0 60 ) 2>&1 ") ;
12181
-                }
12182
-                else
12183
-                {
12184
-                        strcat(lDialogString, "\" 0 60  >/dev/tty) ") ;
12185
-                        if ( lWasXterm )
12186
-                        {
12187
-                                strcat( lDialogString ,
12188
-                                "2>/tmp/tinyfd.txt';cat /tmp/tinyfd.txt;rm /tmp/tinyfd.txt");
12189
-                        }
12190
-                        else
12191
-                        {
12192
-                                strcat(lDialogString, "2>&1 ; clear >/dev/tty") ;
12193
-                        }
12194
-                }
12195
-        }
12196
-        else
12197
-        {
12198
-            if (aTitle&&!strcmp(aTitle,"tinyfd_query")){return tinyfd_inputBox(aTitle,NULL,NULL);}
12199
-				strcpy(lBuff, "Open file from ");
12200
-				strcat(lBuff, getCurDir());
12201
-				lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
12202
-				if (lPointerInputBox) strcpy(lDialogString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
12203
-				p = tinyfd_inputBox(aTitle, lBuff, "");
12204
-				if ( p ) strcpy(lBuff, p); else lBuff[0] = '\0';
12205
-				if (lPointerInputBox) strcpy(lPointerInputBox, lDialogString); /* restore its previous content to tinyfd_inputBox */
12206
-            if ( ! fileExists(lBuff) )
12207
-            {
12208
-					free(lBuff);
12209
-					lBuff = NULL;
12210
-            }
12211
+				strcat( lDialogString , "--fselect \"" ) ;
12212
+				if ( aDefaultPathAndOrFile && strlen(aDefaultPathAndOrFile) )
12213
+				{
12214
+						if ( ! strchr(aDefaultPathAndOrFile, '/') )
12215
+						{
12216
+								strcat(lDialogString, "./") ;
12217
+						}
12218
+						strcat(lDialogString, aDefaultPathAndOrFile) ;
12219
+				}
12220
+				else if ( ! isTerminalRunning( ) && !lWasGraphicDialog )
12221
+				{
12222
+						strcat(lDialogString, getenv("HOME")) ;
12223
+						strcat(lDialogString, "/");
12224
+				}
12225
 				else
12226
 				{
12227
-					lBuff = (char *)( realloc( lBuff, (strlen(lBuff)+1) * sizeof(char)));
12228
+						strcat(lDialogString, "./") ;
12229
 				}
12230
-				return lBuff ;
12231
-        }
12232
 
12233
-    if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
12234
-    if ( ! ( lIn = popen( lDialogString , "r" ) ) )
12235
-    {
12236
-		free(lBuff);
12237
-		lBuff = NULL;
12238
-		return NULL ;
12239
-    }
12240
-        lBuff[0]='\0';
12241
-        p = lBuff;
12242
-        while ( fgets( p , sizeof( lBuff ) , lIn ) != NULL )
12243
-        {
12244
-                p += strlen( p );
12245
-        }
12246
-    pclose( lIn ) ;
12247
-    if ( lBuff[strlen( lBuff ) -1] == '\n' )
12248
-    {
12249
-        lBuff[strlen( lBuff ) -1] = '\0' ;
12250
-    }
12251
-    /* printf( "lBuff: %s\n" , lBuff ) ; */
12252
-        if ( lWasKdialog && aAllowMultipleSelects )
12253
-        {
12254
-                p = lBuff ;
12255
-                while ( ( p = strchr( p , '\n' ) ) )
12256
-                        * p = '|' ;
12257
-        }
12258
-        /* printf( "lBuff2: %s\n" , lBuff ) ; */
12259
-        if ( ! strlen( lBuff )  )
12260
-        {
12261
-			free(lBuff);
12262
-			lBuff = NULL;
12263
-			return NULL;
12264
-        }
12265
-        if ( aAllowMultipleSelects && strchr(lBuff, '|') )
12266
-        {
12267
-			if( ! ensureFilesExist( lBuff , lBuff ) )
12268
+				if ( lWasGraphicDialog )
12269
+				{
12270
+						strcat(lDialogString, "\" 0 60 ) 2>&1 ") ;
12271
+				}
12272
+				else
12273
+				{
12274
+						strcat(lDialogString, "\" 0 60  >/dev/tty) ") ;
12275
+						if ( lWasXterm )
12276
+						{
12277
+								strcat( lDialogString ,
12278
+								"2>/tmp/tinyfd.txt';cat /tmp/tinyfd.txt;rm /tmp/tinyfd.txt");
12279
+						}
12280
+						else
12281
+						{
12282
+								strcat(lDialogString, "2>&1 ; clear >/dev/tty") ;
12283
+						}
12284
+				}
12285
+		}
12286
+		else
12287
+		{
12288
+			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){return tinyfd_inputBox(aTitle,NULL,NULL);}
12289
+								strcpy(lBuff, "Open file from ");
12290
+								strcat(lBuff, getCurDir());
12291
+								lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
12292
+								if (lPointerInputBox) strcpy(lDialogString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
12293
+								p = tinyfd_inputBox(aTitle, lBuff, "");
12294
+								if ( p ) strcpy(lBuff, p); else lBuff[0] = '\0';
12295
+								if (lPointerInputBox) strcpy(lPointerInputBox, lDialogString); /* restore its previous content to tinyfd_inputBox */
12296
+			if ( ! fileExists(lBuff) )
12297
 			{
12298
+										free(lBuff);
12299
+										lBuff = NULL;
12300
+			}
12301
+								else
12302
+								{
12303
+										lBuff = (char *)( realloc( lBuff, (strlen(lBuff)+1) * sizeof(char)));
12304
+								}
12305
+								return lBuff ;
12306
+		}
12307
+
12308
+	if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
12309
+	if ( ! ( lIn = popen( lDialogString , "r" ) ) )
12310
+	{
12311
 				free(lBuff);
12312
 				lBuff = NULL;
12313
-				return NULL;
12314
-			}
12315
+				return NULL ;
12316
+	}
12317
+		lBuff[0]='\0';
12318
+		p = lBuff;
12319
+		while ( fgets( p , sizeof( lBuff ) , lIn ) != NULL )
12320
+		{
12321
+				p += strlen( p );
12322
+		}
12323
+	pclose( lIn ) ;
12324
+
12325
+	if ( strlen( lBuff ) && lBuff[strlen( lBuff ) -1] == '\n' )
12326
+	{
12327
+		lBuff[strlen( lBuff ) -1] = '\0' ;
12328
+	}
12329
+	/* printf( "strlen lBuff: %d\n" , strlen( lBuff ) ) ; */
12330
+		if ( lWasKdialog && aAllowMultipleSelects )
12331
+		{
12332
+				p = lBuff ;
12333
+				while ( ( p = strchr( p , '\n' ) ) )
12334
+						* p = '|' ;
12335
+		}
12336
+		/* printf( "lBuff2: %s\n" , lBuff ) ; */
12337
+		if ( ! strlen( lBuff )  )
12338
+		{
12339
+						free(lBuff);
12340
+						lBuff = NULL;
12341
+						return NULL;
12342
+		}
12343
+		if ( aAllowMultipleSelects && strchr(lBuff, '|') )
12344
+		{
12345
+            if( ! ensureFilesExist( lBuff , lBuff ) )
12346
+            {
12347
+                    free(lBuff);
12348
+                    lBuff = NULL;
12349
+                    return NULL;
12350
+            }
12351
+		}
12352
+		else if ( !fileExists(lBuff) )
12353
+		{
12354
+						free(lBuff);
12355
+						lBuff = NULL;
12356
+						return NULL;
12357
         }
12358
-        else if ( !fileExists(lBuff) )
12359
+
12360
+        p = strrchr(lBuff, '|');
12361
+        if ( !p ) p = lBuff ;
12362
+        else p ++ ;
12363
+        getPathWithoutFinalSlash( lString , p ) ;
12364
+        /* printf( "lString [%lu]: %s\n" , strlen(lString) , lString ) ; */
12365
+        if ( strlen( lString ) && ! dirExists( lString ) )
12366
         {
12367
-			free(lBuff);
12368
-			lBuff = NULL;
12369
-			return NULL;
12370
-		}
12371
+            return NULL ;
12372
+        }
12373
+        strcpy(lLastDirectory, lString) ;
12374
 
12375
-		lBuff = (char *)( realloc( lBuff, (strlen(lBuff)+1) * sizeof(char)));
12376
+        lBuff = (char *)( realloc( lBuff, (strlen(lBuff)+1) * sizeof(char)));
12377
 
12378
-        /*printf( "lBuff3: %s\n" , lBuff ) ; */
12379
-		return lBuff ;
12380
+        /*printf( "lBuff3 [%lu]: %s\n" , strlen(lBuff) , lBuff ) ; */
12381
+        return lBuff ;
12382
 }
12383
 
12384
 
12385
 char * tinyfd_selectFolderDialog(
12386
-        char const * aTitle , /* "" */
12387
-        char const * aDefaultPath ) /* "" */
12388
+    char const * aTitle , /* "" */
12389
+    char const * aDefaultPath ) /* "" */
12390
 {
12391
-        static char lBuff[MAX_PATH_OR_CMD] ;
12392
-        char lDialogString[MAX_PATH_OR_CMD] ;
12393
-        FILE * lIn ;
12394
-        char * p ;
12395
-		char * lPointerInputBox ;
12396
-        int lWasGraphicDialog = 0 ;
12397
-        int lWasXterm = 0 ;
12398
-        lBuff[0]='\0';
12399
+    static char lBuff[MAX_PATH_OR_CMD] ;
12400
+    static char lLastDirectory[MAX_PATH_OR_CMD] = "$PWD" ;
12401
 
12402
-		if (tfd_quoteDetected(aTitle)) return tinyfd_selectFolderDialog("INVALID TITLE WITH QUOTES", aDefaultPath);
12403
-		if (tfd_quoteDetected(aDefaultPath)) return tinyfd_selectFolderDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES");
12404
+    char lDialogString[MAX_PATH_OR_CMD] ;
12405
+    FILE * lIn ;
12406
+    char * p ;
12407
+    char * lPointerInputBox ;
12408
+    int lWasGraphicDialog = 0 ;
12409
+    int lWasXterm = 0 ;
12410
+    lBuff[0]='\0';
12411
 
12412
-        if ( osascriptPresent( ))
12413
-        {
12414
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
12415
-                strcpy( lDialogString , "osascript ");
12416
-                if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
12417
-                strcat( lDialogString , " -e 'try' -e 'POSIX path of ( choose folder ");
12418
-                if ( aTitle && strlen(aTitle) )
12419
-                {
12420
-                strcat(lDialogString, "with prompt \"") ;
12421
-                strcat(lDialogString, aTitle) ;
12422
-                strcat(lDialogString, "\" ") ;
12423
-                }
12424
-                if ( aDefaultPath && strlen(aDefaultPath) )
12425
-                {
12426
-                        strcat(lDialogString, "default location \"") ;
12427
-                        strcat(lDialogString, aDefaultPath ) ;
12428
-                        strcat(lDialogString , "\" " ) ;
12429
-                }
12430
-                strcat( lDialogString , ")' " ) ;
12431
-                strcat(lDialogString, "-e 'on error number -128' " ) ;
12432
-                strcat(lDialogString, "-e 'end try'") ;
12433
-                if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
12434
-        }
12435
-        else if ( tfd_kdialogPresent() )
12436
-        {
12437
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
12438
-                strcpy( lDialogString , "kdialog" ) ;
12439
-				if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
12440
-                {
12441
-                        strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
12442
-                }
12443
-                strcat( lDialogString , " --getexistingdirectory " ) ;
12444
+    if (tfd_quoteDetected(aTitle)) return tinyfd_selectFolderDialog("INVALID TITLE WITH QUOTES", aDefaultPath);
12445
+    if (tfd_quoteDetected(aDefaultPath)) return tinyfd_selectFolderDialog(aTitle, "INVALID DEFAULT_PATH WITH QUOTES");
12446
 
12447
-                if ( aDefaultPath && strlen(aDefaultPath) )
12448
-                {
12449
-                        if ( aDefaultPath[0] != '/' )
12450
-                        {
12451
-                                strcat(lDialogString, "$PWD/") ;
12452
-                        }
12453
-                        strcat(lDialogString, "\"") ;
12454
-                        strcat(lDialogString, aDefaultPath ) ;
12455
-                        strcat(lDialogString , "\"" ) ;
12456
-                }
12457
-                else
12458
-                {
12459
-                        strcat(lDialogString, "$PWD/") ;
12460
-                }
12461
+		if ( osascriptPresent( ))
12462
+		{
12463
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
12464
+				strcpy( lDialogString , "osascript ");
12465
+				if ( ! osx9orBetter() ) strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
12466
+				strcat( lDialogString , " -e 'try' -e 'POSIX path of ( choose folder ");
12467
+				if ( aTitle && strlen(aTitle) )
12468
+				{
12469
+				strcat(lDialogString, "with prompt \"") ;
12470
+				strcat(lDialogString, aTitle) ;
12471
+				strcat(lDialogString, "\" ") ;
12472
+				}
12473
+				if ( aDefaultPath && strlen(aDefaultPath) )
12474
+				{
12475
+						strcat(lDialogString, "default location \"") ;
12476
+						strcat(lDialogString, aDefaultPath ) ;
12477
+						strcat(lDialogString , "\" " ) ;
12478
+				}
12479
+				strcat( lDialogString , ")' " ) ;
12480
+				strcat(lDialogString, "-e 'on error number -128' " ) ;
12481
+				strcat(lDialogString, "-e 'end try'") ;
12482
+				if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
12483
+		}
12484
+		else if ( tfd_kdialogPresent() )
12485
+		{
12486
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
12487
+				strcpy( lDialogString , "kdialog" ) ;
12488
+								if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
12489
+				{
12490
+						strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
12491
+				}
12492
+				strcat( lDialogString , " --getexistingdirectory " ) ;
12493
 
12494
-                if ( aTitle && strlen(aTitle) )
12495
-                {
12496
-                        strcat(lDialogString, " --title \"") ;
12497
-                        strcat(lDialogString, aTitle) ;
12498
-                        strcat(lDialogString, "\"") ;
12499
-                }
12500
-        }
12501
-        else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
12502
-        {
12503
-                if ( tfd_zenityPresent() )
12504
-                {
12505
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return (char *)1;}
12506
-                        strcpy( lDialogString , "zenity" ) ;
12507
-						if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
12508
-                        {
12509
-                                strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
12510
-                        }
12511
-                }
12512
-                else if ( tfd_matedialogPresent() )
12513
-                {
12514
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
12515
-                        strcpy( lDialogString , "matedialog" ) ;
12516
-                }
12517
-                else if ( tfd_shellementaryPresent() )
12518
-                {
12519
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
12520
-                        strcpy( lDialogString , "shellementary" ) ;
12521
-                }
12522
-                else
12523
-                {
12524
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
12525
-                        strcpy( lDialogString , "qarma" ) ;
12526
-						if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
12527
-                        {
12528
-                                strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
12529
-                        }
12530
-                }
12531
-                strcat( lDialogString , " --file-selection --directory" ) ;
12532
+				if ( aDefaultPath && strlen(aDefaultPath) )
12533
+				{
12534
+						if ( aDefaultPath[0] != '/' )
12535
+						{
12536
+                            strcat(lDialogString, lLastDirectory) ;
12537
+                            strcat(lDialogString , "/" ) ;
12538
+						}
12539
+						strcat(lDialogString, "\"") ;
12540
+						strcat(lDialogString, aDefaultPath ) ;
12541
+						strcat(lDialogString , "\"" ) ;
12542
+				}
12543
+				else
12544
+				{
12545
+                        strcat(lDialogString, lLastDirectory) ;
12546
+                        strcat(lDialogString , "/" ) ;
12547
+				}
12548
 
12549
-                if ( aTitle && strlen(aTitle) )
12550
-                {
12551
-                        strcat(lDialogString, " --title=\"") ;
12552
-                        strcat(lDialogString, aTitle) ;
12553
-                        strcat(lDialogString, "\"") ;
12554
-                }
12555
-                if ( aDefaultPath && strlen(aDefaultPath) )
12556
-                {
12557
-                        strcat(lDialogString, " --filename=\"") ;
12558
-                        strcat(lDialogString, aDefaultPath) ;
12559
-                        strcat(lDialogString, "\"") ;
12560
-                }
12561
-                if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
12562
-        }
12563
-        else if (tfd_yadPresent())
12564
-        {
12565
-           if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
12566
-           strcpy(lDialogString, "yad --file-selection --directory");
12567
-           if (aTitle && strlen(aTitle))
12568
-           {
12569
-              strcat(lDialogString, " --title=\"");
12570
-              strcat(lDialogString, aTitle);
12571
-              strcat(lDialogString, "\"");
12572
-           }
12573
-           if (aDefaultPath && strlen(aDefaultPath))
12574
-           {
12575
-              strcat(lDialogString, " --filename=\"");
12576
-              strcat(lDialogString, aDefaultPath);
12577
-              strcat(lDialogString, "\"");
12578
-           }
12579
-           if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
12580
-      }
12581
-      else if ( !xdialogPresent() && tkinter3Present( ) )
12582
+				if ( aTitle && strlen(aTitle) )
12583
+				{
12584
+						strcat(lDialogString, " --title \"") ;
12585
+						strcat(lDialogString, aTitle) ;
12586
+						strcat(lDialogString, "\"") ;
12587
+				}
12588
+		}
12589
+		else if ( tfd_zenityPresent() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
12590
 		{
12591
-			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
12592
-			strcpy( lDialogString , gPython3Name ) ;
12593
-			strcat( lDialogString ,
12594
-				" -S -c \"import tkinter;from tkinter import filedialog;root=tkinter.Tk();root.withdraw();");
12595
-			strcat( lDialogString , "res=filedialog.askdirectory(");
12596
-			if ( aTitle && strlen(aTitle) )
12597
-			{
12598
-				strcat(lDialogString, "title='") ;
12599
-				strcat(lDialogString, aTitle) ;
12600
-				strcat(lDialogString, "',") ;
12601
-			}
12602
-			if ( aDefaultPath && strlen(aDefaultPath) )
12603
-			{
12604
-				strcat(lDialogString, "initialdir='") ;
12605
-				strcat(lDialogString, aDefaultPath ) ;
12606
-				strcat(lDialogString , "'" ) ;
12607
-			}
12608
-			strcat( lDialogString, ");\nif not isinstance(res, tuple):\n\tprint(res)\n\"" ) ;
12609
+				if ( tfd_zenityPresent() )
12610
+				{
12611
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity");return (char *)1;}
12612
+						strcpy( lDialogString , "zenity" ) ;
12613
+												if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
12614
+						{
12615
+								strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
12616
+						}
12617
+				}
12618
+				else if ( tfd_matedialogPresent() )
12619
+				{
12620
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
12621
+						strcpy( lDialogString , "matedialog" ) ;
12622
+				}
12623
+				else if ( tfd_shellementaryPresent() )
12624
+				{
12625
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
12626
+						strcpy( lDialogString , "shellementary" ) ;
12627
+				}
12628
+				else
12629
+				{
12630
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
12631
+						strcpy( lDialogString , "qarma" ) ;
12632
+												if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
12633
+						{
12634
+								strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
12635
+						}
12636
+				}
12637
+				strcat( lDialogString , " --file-selection --directory" ) ;
12638
+
12639
+				strcat(lDialogString, " --title=\"") ;
12640
+				if (aTitle && strlen(aTitle)) strcat(lDialogString, aTitle) ;
12641
+				strcat(lDialogString, "\"") ;
12642
+
12643
+				if ( aDefaultPath && strlen(aDefaultPath) )
12644
+				{
12645
+						strcat(lDialogString, " --filename=\"") ;
12646
+						strcat(lDialogString, aDefaultPath) ;
12647
+						strcat(lDialogString, "\"") ;
12648
+				}
12649
+				if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
12650
 		}
12651
-		else if ( !xdialogPresent() && tkinter2Present( ) )
12652
-        {
12653
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
12654
-				strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
12655
-                strcat( lDialogString , gPython2Name ) ;
12656
-                if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
12657
-                {
12658
-                strcat( lDialogString , " -i" ) ;  /* for osx without console */
12659
-                }
12660
-        strcat( lDialogString ,
12661
+		else if (tfd_yadPresent())
12662
+		{
12663
+		   if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
12664
+		   strcpy(lDialogString, "yad --file --directory");
12665
+		   if (aTitle && strlen(aTitle))
12666
+		   {
12667
+			  strcat(lDialogString, " --title=\"");
12668
+			  strcat(lDialogString, aTitle);
12669
+			  strcat(lDialogString, "\"");
12670
+		   }
12671
+		   if (aDefaultPath && strlen(aDefaultPath))
12672
+		   {
12673
+			  strcat(lDialogString, " --filename=\"");
12674
+			  strcat(lDialogString, aDefaultPath);
12675
+			  strcat(lDialogString, "\"");
12676
+		   }
12677
+		   if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
12678
+	  }
12679
+	  else if ( !xdialogPresent() && tkinter3Present( ) )
12680
+				{
12681
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
12682
+						strcpy( lDialogString , gPython3Name ) ;
12683
+						strcat( lDialogString ,
12684
+								" -S -c \"import tkinter;from tkinter import filedialog;root=tkinter.Tk();root.withdraw();");
12685
+						strcat( lDialogString , "res=filedialog.askdirectory(");
12686
+						if ( aTitle && strlen(aTitle) )
12687
+						{
12688
+								strcat(lDialogString, "title='") ;
12689
+								strcat(lDialogString, aTitle) ;
12690
+								strcat(lDialogString, "',") ;
12691
+						}
12692
+						if ( aDefaultPath && strlen(aDefaultPath) )
12693
+						{
12694
+								strcat(lDialogString, "initialdir='") ;
12695
+								strcat(lDialogString, aDefaultPath ) ;
12696
+								strcat(lDialogString , "'" ) ;
12697
+						}
12698
+						strcat( lDialogString, ");\nif not isinstance(res, tuple):\n\tprint(res)\n\"" ) ;
12699
+				}
12700
+				else if ( !xdialogPresent() && tkinter2Present( ) )
12701
+		{
12702
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
12703
+								strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
12704
+				strcat( lDialogString , gPython2Name ) ;
12705
+				if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
12706
+				{
12707
+				strcat( lDialogString , " -i" ) ;  /* for osx without console */
12708
+				}
12709
+		strcat( lDialogString ,
12710
 " -S -c \"import Tkinter,tkFileDialog;root=Tkinter.Tk();root.withdraw();");
12711
 
12712
-        if ( tfd_isDarwin( ) )
12713
-        {
12714
-                        strcat( lDialogString ,
12715
+		if ( tfd_isDarwin( ) )
12716
+		{
12717
+						strcat( lDialogString ,
12718
 "import os;os.system('''/usr/bin/osascript -e 'tell app \\\"Finder\\\" to set \
12719
 frontmost of process \\\"Python\\\" to true' ''');");
12720
-                }
12721
+				}
12722
 
12723
-                strcat( lDialogString , "print tkFileDialog.askdirectory(");
12724
-            if ( aTitle && strlen(aTitle) )
12725
-            {
12726
-                        strcat(lDialogString, "title='") ;
12727
-                        strcat(lDialogString, aTitle) ;
12728
-                        strcat(lDialogString, "',") ;
12729
-            }
12730
-        if ( aDefaultPath && strlen(aDefaultPath) )
12731
-        {
12732
-                                strcat(lDialogString, "initialdir='") ;
12733
-                                strcat(lDialogString, aDefaultPath ) ;
12734
-                                strcat(lDialogString , "'" ) ;
12735
-                }
12736
-                strcat( lDialogString , ")\"" ) ;
12737
-        }
12738
-        else if ( xdialogPresent() || dialogName() )
12739
-        {
12740
-                if ( xdialogPresent( ) )
12741
-                {
12742
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
12743
-                        lWasGraphicDialog = 1 ;
12744
-                        strcpy( lDialogString , "(Xdialog " ) ;
12745
-                }
12746
-                else if ( isTerminalRunning( ) )
12747
-                {
12748
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
12749
-                        strcpy( lDialogString , "(dialog " ) ;
12750
-                }
12751
-                else
12752
-                {
12753
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
12754
-                        lWasXterm = 1 ;
12755
-                        strcpy( lDialogString , terminalName() ) ;
12756
-                        strcat( lDialogString , "'(" ) ;
12757
-                        strcat( lDialogString , dialogName() ) ;
12758
-                        strcat( lDialogString , " " ) ;
12759
-                }
12760
+				strcat( lDialogString , "print tkFileDialog.askdirectory(");
12761
+			if ( aTitle && strlen(aTitle) )
12762
+			{
12763
+						strcat(lDialogString, "title='") ;
12764
+						strcat(lDialogString, aTitle) ;
12765
+						strcat(lDialogString, "',") ;
12766
+			}
12767
+		if ( aDefaultPath && strlen(aDefaultPath) )
12768
+		{
12769
+								strcat(lDialogString, "initialdir='") ;
12770
+								strcat(lDialogString, aDefaultPath ) ;
12771
+								strcat(lDialogString , "'" ) ;
12772
+				}
12773
+				strcat( lDialogString , ")\"" ) ;
12774
+		}
12775
+		else if ( xdialogPresent() || dialogName() )
12776
+		{
12777
+				if ( xdialogPresent( ) )
12778
+				{
12779
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
12780
+						lWasGraphicDialog = 1 ;
12781
+						strcpy( lDialogString , "(Xdialog " ) ;
12782
+				}
12783
+				else if ( isTerminalRunning( ) )
12784
+				{
12785
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
12786
+						strcpy( lDialogString , "(dialog " ) ;
12787
+				}
12788
+				else
12789
+				{
12790
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"dialog");return (char *)0;}
12791
+						lWasXterm = 1 ;
12792
+						strcpy( lDialogString , terminalName() ) ;
12793
+						strcat( lDialogString , "'(" ) ;
12794
+						strcat( lDialogString , dialogName() ) ;
12795
+						strcat( lDialogString , " " ) ;
12796
+				}
12797
 
12798
-                if ( aTitle && strlen(aTitle) )
12799
-                {
12800
-                        strcat(lDialogString, "--title \"") ;
12801
-                        strcat(lDialogString, aTitle) ;
12802
-                        strcat(lDialogString, "\" ") ;
12803
-                }
12804
+				if ( aTitle && strlen(aTitle) )
12805
+				{
12806
+						strcat(lDialogString, "--title \"") ;
12807
+						strcat(lDialogString, aTitle) ;
12808
+						strcat(lDialogString, "\" ") ;
12809
+				}
12810
 
12811
-                if ( !xdialogPresent() && !gdialogPresent() )
12812
-                {
12813
-                        strcat(lDialogString, "--backtitle \"") ;
12814
-                        strcat(lDialogString,
12815
-                                "tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
12816
-                        strcat(lDialogString, "\" ") ;
12817
-                }
12818
+				if ( !xdialogPresent() && !gdialogPresent() )
12819
+				{
12820
+						strcat(lDialogString, "--backtitle \"") ;
12821
+						strcat(lDialogString,
12822
+								"tab: focus | /: populate | spacebar: fill text field | ok: TEXT FIELD ONLY") ;
12823
+						strcat(lDialogString, "\" ") ;
12824
+				}
12825
 
12826
-                strcat( lDialogString , "--dselect \"" ) ;
12827
-                if ( aDefaultPath && strlen(aDefaultPath) )
12828
-                {
12829
-                        strcat(lDialogString, aDefaultPath) ;
12830
-                        ensureFinalSlash(lDialogString);
12831
-                }
12832
-                else if ( ! isTerminalRunning( ) && !lWasGraphicDialog )
12833
-                {
12834
-                        strcat(lDialogString, getenv("HOME")) ;
12835
-                        strcat(lDialogString, "/");
12836
-                }
12837
-                else
12838
-                {
12839
-                        strcat(lDialogString, "./") ;
12840
-                }
12841
+				strcat( lDialogString , "--dselect \"" ) ;
12842
+				if ( aDefaultPath && strlen(aDefaultPath) )
12843
+				{
12844
+						strcat(lDialogString, aDefaultPath) ;
12845
+						ensureFinalSlash(lDialogString);
12846
+				}
12847
+				else if ( ! isTerminalRunning( ) && !lWasGraphicDialog )
12848
+				{
12849
+						strcat(lDialogString, getenv("HOME")) ;
12850
+						strcat(lDialogString, "/");
12851
+				}
12852
+				else
12853
+				{
12854
+						strcat(lDialogString, "./") ;
12855
+				}
12856
 
12857
-                if ( lWasGraphicDialog )
12858
-                {
12859
-                        strcat(lDialogString, "\" 0 60 ) 2>&1 ") ;
12860
-                }
12861
-                else
12862
-                {
12863
-                        strcat(lDialogString, "\" 0 60  >/dev/tty) ") ;
12864
-                        if ( lWasXterm )
12865
-                        {
12866
-                          strcat( lDialogString ,
12867
-                                "2>/tmp/tinyfd.txt';cat /tmp/tinyfd.txt;rm /tmp/tinyfd.txt");
12868
-                        }
12869
-                        else
12870
-                        {
12871
-                                strcat(lDialogString, "2>&1 ; clear >/dev/tty") ;
12872
-                        }
12873
-                }
12874
-        }
12875
-        else
12876
-        {
12877
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){return tinyfd_inputBox(aTitle,NULL,NULL);}
12878
-				strcpy(lBuff, "Select folder from ");
12879
-				strcat(lBuff, getCurDir());
12880
-				lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
12881
-				if (lPointerInputBox) strcpy(lDialogString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
12882
-				p = tinyfd_inputBox(aTitle, lBuff, "");
12883
-				if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
12884
-				if (lPointerInputBox) strcpy(lPointerInputBox, lDialogString); /* restore its previous content to tinyfd_inputBox */
12885
-				p = lBuff;
12886
+				if ( lWasGraphicDialog )
12887
+				{
12888
+						strcat(lDialogString, "\" 0 60 ) 2>&1 ") ;
12889
+				}
12890
+				else
12891
+				{
12892
+						strcat(lDialogString, "\" 0 60  >/dev/tty) ") ;
12893
+						if ( lWasXterm )
12894
+						{
12895
+						  strcat( lDialogString ,
12896
+								"2>/tmp/tinyfd.txt';cat /tmp/tinyfd.txt;rm /tmp/tinyfd.txt");
12897
+						}
12898
+						else
12899
+						{
12900
+								strcat(lDialogString, "2>&1 ; clear >/dev/tty") ;
12901
+						}
12902
+				}
12903
+		}
12904
+		else
12905
+		{
12906
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){return tinyfd_inputBox(aTitle,NULL,NULL);}
12907
+								strcpy(lBuff, "Select folder from ");
12908
+								strcat(lBuff, getCurDir());
12909
+								lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
12910
+								if (lPointerInputBox) strcpy(lDialogString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
12911
+								p = tinyfd_inputBox(aTitle, lBuff, "");
12912
+								if (p) strcpy(lBuff, p); else lBuff[0] = '\0';
12913
+								if (lPointerInputBox) strcpy(lPointerInputBox, lDialogString); /* restore its previous content to tinyfd_inputBox */
12914
+								p = lBuff;
12915
 
12916
-                if ( !p || ! strlen( p ) || ! dirExists( p ) )
12917
-                {
12918
-                        return NULL ;
12919
-                }
12920
-                return p ;
12921
-        }
12922
-    if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
12923
-    if ( ! ( lIn = popen( lDialogString , "r" ) ) )
12924
+				if ( !p || ! strlen( p ) || ! dirExists( p ) )
12925
+				{
12926
+						return NULL ;
12927
+				}
12928
+				return p ;
12929
+		}
12930
+	if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
12931
+	if ( ! ( lIn = popen( lDialogString , "r" ) ) )
12932
+	{
12933
+		return NULL ;
12934
+	}
12935
+    while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
12936
+    {}
12937
+    pclose( lIn ) ;
12938
+	if ( strlen( lBuff ) && lBuff[strlen( lBuff ) -1] == '\n' )
12939
+	{
12940
+		lBuff[strlen( lBuff ) -1] = '\0' ;
12941
+	}
12942
+    /* printf( "lBuff: %s\n" , lBuff ) ; */
12943
+    if ( ! strlen( lBuff ) || ! dirExists( lBuff ) )
12944
     {
12945
-        return NULL ;
12946
+            return NULL ;
12947
     }
12948
-        while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
12949
-        {}
12950
-        pclose( lIn ) ;
12951
-    if ( lBuff[strlen( lBuff ) -1] == '\n' )
12952
-    {
12953
-        lBuff[strlen( lBuff ) -1] = '\0' ;
12954
-    }
12955
-        /* printf( "lBuff: %s\n" , lBuff ) ; */
12956
-        if ( ! strlen( lBuff ) || ! dirExists( lBuff ) )
12957
-        {
12958
-                return NULL ;
12959
-        }
12960
-        return lBuff ;
12961
+
12962
+	getPathWithoutFinalSlash( lLastDirectory , lBuff ) ;
12963
+
12964
+    return lBuff ;
12965
 }
12966
 
12967
 
12968
+/* aDefaultRGB is used only if aDefaultHexRGB is absent */
12969
+/* aDefaultRGB and aoResultRGB can be the same array */
12970
+/* returns NULL on cancel */
12971
 /* returns the hexcolor as a string "#FF0000" */
12972
 /* aoResultRGB also contains the result */
12973
-/* aDefaultRGB is used only if aDefaultHexRGB is NULL */
12974
-/* aDefaultRGB and aoResultRGB can be the same array */
12975
 char * tinyfd_colorChooser(
12976
-        char const * aTitle , /* NULL or "" */
12977
-        char const * aDefaultHexRGB , /* NULL or "#FF0000"*/
12978
-        unsigned char const aDefaultRGB[3] , /* { 0 , 255 , 255 } */
12979
-        unsigned char aoResultRGB[3] ) /* { 0 , 0 , 0 } */
12980
+		char const * aTitle , /* NULL or "" */
12981
+		char const * aDefaultHexRGB , /* NULL or "#FF0000"*/
12982
+		unsigned char const aDefaultRGB[3] , /* { 0 , 255 , 255 } */
12983
+		unsigned char aoResultRGB[3] ) /* { 0 , 0 , 0 } */
12984
 {
12985
-	static char lDefaultHexRGB[16];
12986
-	char lBuff[128] ;
12987
+		static char lDefaultHexRGB[16];
12988
+		char lBuff[128] ;
12989
 
12990
-        char lTmp[128] ;
12991
+		char lTmp[128] ;
12992
 #if !((defined(__cplusplus ) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__clang__))
12993
-		char * lTmp2 ;
12994
+				char * lTmp2 ;
12995
 #endif
12996
-        char lDialogString[MAX_PATH_OR_CMD] ;
12997
-        unsigned char lDefaultRGB[3];
12998
-        char * p;
12999
-		char * lPointerInputBox;
13000
-        FILE * lIn ;
13001
-        int i ;
13002
-        int lWasZenity3 = 0 ;
13003
-        int lWasOsascript = 0 ;
13004
-        int lWasXdialog = 0 ;
13005
-        lBuff[0]='\0';
13006
+		char lDialogString[MAX_PATH_OR_CMD] ;
13007
+		unsigned char lDefaultRGB[3];
13008
+		char * p;
13009
+				char * lPointerInputBox;
13010
+		FILE * lIn ;
13011
+		int i ;
13012
+		int lWasZenity3 = 0 ;
13013
+		int lWasOsascript = 0 ;
13014
+		int lWasXdialog = 0 ;
13015
+		lBuff[0]='\0';
13016
 
13017
-		if (tfd_quoteDetected(aTitle)) return tinyfd_colorChooser("INVALID TITLE WITH QUOTES", aDefaultHexRGB, aDefaultRGB, aoResultRGB);
13018
-		if (tfd_quoteDetected(aDefaultHexRGB)) return tinyfd_colorChooser(aTitle, "INVALID DEFAULT_HEX_RGB WITH QUOTES", aDefaultRGB, aoResultRGB);
13019
+				if (tfd_quoteDetected(aTitle)) return tinyfd_colorChooser("INVALID TITLE WITH QUOTES", aDefaultHexRGB, aDefaultRGB, aoResultRGB);
13020
+				if (tfd_quoteDetected(aDefaultHexRGB)) return tinyfd_colorChooser(aTitle, "INVALID DEFAULT_HEX_RGB WITH QUOTES: use the GRAVE ACCENT \\x60 instead.", aDefaultRGB, aoResultRGB);
13021
 
13022
-		if (aDefaultHexRGB)
13023
+				if (aDefaultHexRGB && (strlen(aDefaultHexRGB)==7) )
13024
+				{
13025
+						Hex2RGB(aDefaultHexRGB, lDefaultRGB);
13026
+			strcpy(lDefaultHexRGB, aDefaultHexRGB);
13027
+				}
13028
+				else
13029
+				{
13030
+						lDefaultRGB[0] = aDefaultRGB[0];
13031
+						lDefaultRGB[1] = aDefaultRGB[1];
13032
+						lDefaultRGB[2] = aDefaultRGB[2];
13033
+			RGB2Hex(aDefaultRGB, lDefaultHexRGB);
13034
+				}
13035
+
13036
+		if ( osascriptPresent( ) )
13037
 		{
13038
-			Hex2RGB(aDefaultHexRGB, lDefaultRGB);
13039
-         strcpy(lDefaultHexRGB, aDefaultHexRGB);
13040
-		}
13041
-		else
13042
-		{
13043
-			lDefaultRGB[0] = aDefaultRGB[0];
13044
-			lDefaultRGB[1] = aDefaultRGB[1];
13045
-			lDefaultRGB[2] = aDefaultRGB[2];
13046
-         RGB2Hex(aDefaultRGB, lDefaultHexRGB);
13047
-		}
13048
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
13049
+				lWasOsascript = 1 ;
13050
+				strcpy( lDialogString , "osascript");
13051
 
13052
-        if ( osascriptPresent( ) )
13053
-        {
13054
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"applescript");return (char *)1;}
13055
-                lWasOsascript = 1 ;
13056
-                strcpy( lDialogString , "osascript");
13057
-
13058
-                if ( ! osx9orBetter() )
13059
-                {
13060
-                        strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
13061
-                        strcat( lDialogString , " -e 'try' -e 'set mycolor to choose color default color {");
13062
-                }
13063
-                else
13064
-                {
13065
-                        strcat( lDialogString ,
13066
+				if ( ! osx9orBetter() )
13067
+				{
13068
+						strcat( lDialogString , " -e 'tell application \"System Events\"' -e 'Activate'");
13069
+						strcat( lDialogString , " -e 'try' -e 'set mycolor to choose color default color {");
13070
+				}
13071
+				else
13072
+				{
13073
+						strcat( lDialogString ,
13074
 " -e 'try' -e 'tell app (path to frontmost application as Unicode text) \
13075
 to set mycolor to choose color default color {");
13076
-                }
13077
+				}
13078
 
13079
-                sprintf(lTmp, "%d", 256 * lDefaultRGB[0] ) ;
13080
-                strcat(lDialogString, lTmp ) ;
13081
-                strcat(lDialogString, "," ) ;
13082
-                sprintf(lTmp, "%d", 256 * lDefaultRGB[1] ) ;
13083
-                strcat(lDialogString, lTmp ) ;
13084
-                strcat(lDialogString, "," ) ;
13085
-                sprintf(lTmp, "%d", 256 * lDefaultRGB[2] ) ;
13086
-                strcat(lDialogString, lTmp ) ;
13087
-                strcat(lDialogString, "}' " ) ;
13088
-                strcat( lDialogString ,
13089
+				sprintf(lTmp, "%d", 256 * lDefaultRGB[0] ) ;
13090
+				strcat(lDialogString, lTmp ) ;
13091
+				strcat(lDialogString, "," ) ;
13092
+				sprintf(lTmp, "%d", 256 * lDefaultRGB[1] ) ;
13093
+				strcat(lDialogString, lTmp ) ;
13094
+				strcat(lDialogString, "," ) ;
13095
+				sprintf(lTmp, "%d", 256 * lDefaultRGB[2] ) ;
13096
+				strcat(lDialogString, lTmp ) ;
13097
+				strcat(lDialogString, "}' " ) ;
13098
+				strcat( lDialogString ,
13099
 "-e 'set mystring to ((item 1 of mycolor) div 256 as integer) as string' " );
13100
-                strcat( lDialogString ,
13101
+				strcat( lDialogString ,
13102
 "-e 'repeat with i from 2 to the count of mycolor' " );
13103
-                strcat( lDialogString ,
13104
+				strcat( lDialogString ,
13105
 "-e 'set mystring to mystring & \" \" & ((item i of mycolor) div 256 as integer) as string' " );
13106
-                strcat( lDialogString , "-e 'end repeat' " );
13107
-                strcat( lDialogString , "-e 'mystring' ");
13108
-                strcat(lDialogString, "-e 'on error number -128' " ) ;
13109
-                strcat(lDialogString, "-e 'end try'") ;
13110
-                if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
13111
-        }
13112
-        else if ( tfd_kdialogPresent() )
13113
-        {
13114
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
13115
-                strcpy( lDialogString , "kdialog" ) ;
13116
-				if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
13117
-                {
13118
-                        strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
13119
-                }
13120
-                sprintf( lDialogString + strlen(lDialogString) , " --getcolor --default '%s'" , lDefaultHexRGB ) ;
13121
+				strcat( lDialogString , "-e 'end repeat' " );
13122
+				strcat( lDialogString , "-e 'mystring' ");
13123
+				strcat(lDialogString, "-e 'on error number -128' " ) ;
13124
+				strcat(lDialogString, "-e 'end try'") ;
13125
+				if ( ! osx9orBetter() ) strcat( lDialogString, " -e 'end tell'") ;
13126
+		}
13127
+		else if ( tfd_kdialogPresent() )
13128
+		{
13129
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"kdialog");return (char *)1;}
13130
+				strcpy( lDialogString , "kdialog" ) ;
13131
+								if ( (tfd_kdialogPresent() == 2) && tfd_xpropPresent() )
13132
+				{
13133
+						strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
13134
+				}
13135
+				sprintf( lDialogString + strlen(lDialogString) , " --getcolor --default '%s'" , lDefaultHexRGB ) ;
13136
 
13137
-                if ( aTitle && strlen(aTitle) )
13138
-                {
13139
-                        strcat(lDialogString, " --title \"") ;
13140
-                        strcat(lDialogString, aTitle) ;
13141
-                        strcat(lDialogString, "\"") ;
13142
-                }
13143
-        }
13144
-        else if ( tfd_zenity3Present() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
13145
-        {
13146
-                lWasZenity3 = 1 ;
13147
-                if ( tfd_zenity3Present() )
13148
-                {
13149
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity3");return (char *)1;}
13150
-                        strcpy( lDialogString , "zenity" );
13151
-						if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
13152
-                        {
13153
-                                strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
13154
-                        }
13155
-                }
13156
-                else if ( tfd_matedialogPresent() )
13157
-                {
13158
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
13159
-                        strcpy( lDialogString , "matedialog" ) ;
13160
-                }
13161
-                else if ( tfd_shellementaryPresent() )
13162
-                {
13163
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
13164
-                        strcpy( lDialogString , "shellementary" ) ;
13165
-                }
13166
-                else
13167
-                {
13168
-                        if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
13169
-                        strcpy( lDialogString , "qarma" ) ;
13170
-						if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
13171
-                        {
13172
-                                strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
13173
-                        }
13174
-                }
13175
-                strcat( lDialogString , " --color-selection --show-palette" ) ;
13176
-                sprintf( lDialogString + strlen(lDialogString), " --color=%s" , lDefaultHexRGB ) ;
13177
+				if ( aTitle && strlen(aTitle) )
13178
+				{
13179
+						strcat(lDialogString, " --title \"") ;
13180
+						strcat(lDialogString, aTitle) ;
13181
+						strcat(lDialogString, "\"") ;
13182
+				}
13183
+		}
13184
+		else if ( tfd_zenity3Present() || tfd_matedialogPresent() || tfd_shellementaryPresent() || tfd_qarmaPresent() )
13185
+		{
13186
+				lWasZenity3 = 1 ;
13187
+				if ( tfd_zenity3Present() )
13188
+				{
13189
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"zenity3");return (char *)1;}
13190
+						strcpy( lDialogString , "zenity" );
13191
+												if ( (tfd_zenity3Present() >= 4) && !getenv("SSH_TTY") && tfd_xpropPresent() )
13192
+						{
13193
+								strcat( lDialogString, " --attach=$(sleep .01;xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
13194
+						}
13195
+				}
13196
+				else if ( tfd_matedialogPresent() )
13197
+				{
13198
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"matedialog");return (char *)1;}
13199
+						strcpy( lDialogString , "matedialog" ) ;
13200
+				}
13201
+				else if ( tfd_shellementaryPresent() )
13202
+				{
13203
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"shellementary");return (char *)1;}
13204
+						strcpy( lDialogString , "shellementary" ) ;
13205
+				}
13206
+				else
13207
+				{
13208
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"qarma");return (char *)1;}
13209
+						strcpy( lDialogString , "qarma" ) ;
13210
+												if ( !getenv("SSH_TTY") && tfd_xpropPresent() )
13211
+						{
13212
+								strcat(lDialogString, " --attach=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)"); /* contribution: Paul Rouget */
13213
+						}
13214
+				}
13215
+				strcat( lDialogString , " --color-selection --show-palette" ) ;
13216
+				sprintf( lDialogString + strlen(lDialogString), " --color=%s" , lDefaultHexRGB ) ;
13217
 
13218
-                if ( aTitle && strlen(aTitle) )
13219
-                {
13220
-                        strcat(lDialogString, " --title=\"") ;
13221
-                        strcat(lDialogString, aTitle) ;
13222
-                        strcat(lDialogString, "\"") ;
13223
-                }
13224
-                if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
13225
-        }
13226
-        else if (tfd_yadPresent())
13227
-        {
13228
-           if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
13229
-           strcpy(lDialogString, "yad --color");
13230
-           sprintf(lDialogString + strlen(lDialogString), " --init-color=%s", lDefaultHexRGB);
13231
-           if (aTitle && strlen(aTitle))
13232
-           {
13233
-              strcat(lDialogString, " --title=\"");
13234
-              strcat(lDialogString, aTitle);
13235
-              strcat(lDialogString, "\"");
13236
-           }
13237
-           if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
13238
-        }
13239
-        else if ( xdialogPresent() )
13240
-        {
13241
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
13242
-                lWasXdialog = 1 ;
13243
-                strcpy( lDialogString , "Xdialog --colorsel \"" ) ;
13244
-                if ( aTitle && strlen(aTitle) )
13245
-                {
13246
-                        strcat(lDialogString, aTitle) ;
13247
-                }
13248
-                strcat(lDialogString, "\" 0 60 ") ;
13249
+				strcat(lDialogString, " --title=\"") ;
13250
+				if (aTitle && strlen(aTitle)) strcat(lDialogString, aTitle) ;
13251
+				strcat(lDialogString, "\"") ;
13252
+
13253
+				if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
13254
+		}
13255
+		else if (tfd_yadPresent())
13256
+		{
13257
+		   if (aTitle && !strcmp(aTitle, "tinyfd_query")) { strcpy(tinyfd_response, "yad"); return (char*)1; }
13258
+		   strcpy(lDialogString, "yad --color");
13259
+		   sprintf(lDialogString + strlen(lDialogString), " --init-color=%s", lDefaultHexRGB);
13260
+		   if (aTitle && strlen(aTitle))
13261
+		   {
13262
+			  strcat(lDialogString, " --title=\"");
13263
+			  strcat(lDialogString, aTitle);
13264
+			  strcat(lDialogString, "\"");
13265
+		   }
13266
+		   if (tinyfd_silent) strcat(lDialogString, " 2>/dev/null ");
13267
+		}
13268
+		else if ( xdialogPresent() )
13269
+		{
13270
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"xdialog");return (char *)1;}
13271
+				lWasXdialog = 1 ;
13272
+				strcpy( lDialogString , "Xdialog --colorsel \"" ) ;
13273
+				if ( aTitle && strlen(aTitle) )
13274
+				{
13275
+						strcat(lDialogString, aTitle) ;
13276
+				}
13277
+				strcat(lDialogString, "\" 0 60 ") ;
13278
 #if (defined(__cplusplus ) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__clang__)
13279
-				sprintf(lTmp,"%hhu %hhu %hhu",lDefaultRGB[0],lDefaultRGB[1],lDefaultRGB[2]);
13280
+								sprintf(lTmp,"%hhu %hhu %hhu",lDefaultRGB[0],lDefaultRGB[1],lDefaultRGB[2]);
13281
 #else
13282
-                sprintf(lTmp,"%hu %hu %hu",lDefaultRGB[0],lDefaultRGB[1],lDefaultRGB[2]);
13283
+				sprintf(lTmp,"%hu %hu %hu",lDefaultRGB[0],lDefaultRGB[1],lDefaultRGB[2]);
13284
 #endif
13285
-                strcat(lDialogString, lTmp) ;
13286
-                strcat(lDialogString, " 2>&1");
13287
-        }
13288
-		else if ( tkinter3Present( ) )
13289
-		{
13290
-			if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
13291
-			strcpy( lDialogString , gPython3Name ) ;
13292
-			strcat( lDialogString ,
13293
-				" -S -c \"import tkinter;from tkinter import colorchooser;root=tkinter.Tk();root.withdraw();");
13294
-			strcat( lDialogString , "res=colorchooser.askcolor(color='" ) ;
13295
-			strcat(lDialogString, lDefaultHexRGB ) ;
13296
-			strcat(lDialogString, "'") ;
13297
+				strcat(lDialogString, lTmp) ;
13298
+				strcat(lDialogString, " 2>&1");
13299
+		}
13300
+				else if ( tkinter3Present( ) )
13301
+				{
13302
+						if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python3-tkinter");return (char *)1;}
13303
+						strcpy( lDialogString , gPython3Name ) ;
13304
+						strcat( lDialogString ,
13305
+								" -S -c \"import tkinter;from tkinter import colorchooser;root=tkinter.Tk();root.withdraw();");
13306
+						strcat( lDialogString , "res=colorchooser.askcolor(color='" ) ;
13307
+						strcat(lDialogString, lDefaultHexRGB ) ;
13308
+						strcat(lDialogString, "'") ;
13309
 
13310
-			if ( aTitle && strlen(aTitle) )
13311
-			{
13312
-				strcat(lDialogString, ",title='") ;
13313
-				strcat(lDialogString, aTitle) ;
13314
-				strcat(lDialogString, "'") ;
13315
-			}
13316
-			strcat( lDialogString , ");\
13317
+						if ( aTitle && strlen(aTitle) )
13318
+						{
13319
+								strcat(lDialogString, ",title='") ;
13320
+								strcat(lDialogString, aTitle) ;
13321
+								strcat(lDialogString, "'") ;
13322
+						}
13323
+						strcat( lDialogString , ");\
13324
 \nif res[1] is not None:\n\tprint(res[1])\"" ) ;
13325
-		}
13326
-		else if ( tkinter2Present( ) )
13327
-        {
13328
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
13329
-				strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
13330
-				strcat( lDialogString , gPython2Name ) ;
13331
-				if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
13332
-                {
13333
-                strcat( lDialogString , " -i" ) ;  /* for osx without console */
13334
-                }
13335
+				}
13336
+				else if ( tkinter2Present( ) )
13337
+		{
13338
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){strcpy(tinyfd_response,"python2-tkinter");return (char *)1;}
13339
+								strcpy( lDialogString , "export PYTHONIOENCODING=utf-8;" ) ;
13340
+								strcat( lDialogString , gPython2Name ) ;
13341
+								if ( ! isTerminalRunning( ) && tfd_isDarwin( ) )
13342
+				{
13343
+				strcat( lDialogString , " -i" ) ;  /* for osx without console */
13344
+				}
13345
 
13346
-                strcat( lDialogString ,
13347
+				strcat( lDialogString ,
13348
 " -S -c \"import Tkinter,tkColorChooser;root=Tkinter.Tk();root.withdraw();");
13349
 
13350
-                if ( tfd_isDarwin( ) )
13351
-                {
13352
-                        strcat( lDialogString ,
13353
+				if ( tfd_isDarwin( ) )
13354
+				{
13355
+						strcat( lDialogString ,
13356
 "import os;os.system('''osascript -e 'tell app \\\"Finder\\\" to set \
13357
 frontmost of process \\\"Python\\\" to true' ''');");
13358
-                }
13359
+				}
13360
 
13361
-                strcat( lDialogString , "res=tkColorChooser.askcolor(color='" ) ;
13362
-                strcat(lDialogString, lDefaultHexRGB ) ;
13363
-                strcat(lDialogString, "'") ;
13364
+				strcat( lDialogString , "res=tkColorChooser.askcolor(color='" ) ;
13365
+				strcat(lDialogString, lDefaultHexRGB ) ;
13366
+				strcat(lDialogString, "'") ;
13367
 
13368
 
13369
-            if ( aTitle && strlen(aTitle) )
13370
-            {
13371
-                        strcat(lDialogString, ",title='") ;
13372
-                        strcat(lDialogString, aTitle) ;
13373
-                        strcat(lDialogString, "'") ;
13374
-            }
13375
-                strcat( lDialogString , ");\
13376
+			if ( aTitle && strlen(aTitle) )
13377
+			{
13378
+						strcat(lDialogString, ",title='") ;
13379
+						strcat(lDialogString, aTitle) ;
13380
+						strcat(lDialogString, "'") ;
13381
+			}
13382
+				strcat( lDialogString , ");\
13383
 \nif res[1] is not None:\n\tprint res[1]\"" ) ;
13384
-        }
13385
-        else
13386
-        {
13387
-                if (aTitle&&!strcmp(aTitle,"tinyfd_query")){return tinyfd_inputBox(aTitle,NULL,NULL);}
13388
-				lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
13389
-				if (lPointerInputBox) strcpy(lDialogString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
13390
-				p = tinyfd_inputBox(aTitle, "Enter hex rgb color (i.e. #f5ca20)", lDefaultHexRGB);
13391
+		}
13392
+		else
13393
+		{
13394
+				if (aTitle&&!strcmp(aTitle,"tinyfd_query")){return tinyfd_inputBox(aTitle,NULL,NULL);}
13395
+								lPointerInputBox = tinyfd_inputBox(NULL, NULL, NULL); /* obtain a pointer on the current content of tinyfd_inputBox */
13396
+								if (lPointerInputBox) strcpy(lDialogString, lPointerInputBox); /* preserve the current content of tinyfd_inputBox */
13397
+								p = tinyfd_inputBox(aTitle, "Enter hex rgb color (i.e. #f5ca20)", lDefaultHexRGB);
13398
 
13399
-                if ( !p || (strlen(p) != 7) || (p[0] != '#') )
13400
-                {
13401
-                        return NULL ;
13402
-                }
13403
-                for ( i = 1 ; i < 7 ; i ++ )
13404
-                {
13405
-                        if ( ! isxdigit( (int) p[i] ) )
13406
-                        {
13407
-                                return NULL ;
13408
-                        }
13409
-                }
13410
-				Hex2RGB(p,aoResultRGB);
13411
-				strcpy(lDefaultHexRGB, p);
13412
-				if (lPointerInputBox) strcpy(lPointerInputBox, lDialogString); /* restore its previous content to tinyfd_inputBox */
13413
-				return lDefaultHexRGB;
13414
-        }
13415
+				if ( !p || (strlen(p) != 7) || (p[0] != '#') )
13416
+				{
13417
+						return NULL ;
13418
+				}
13419
+				for ( i = 1 ; i < 7 ; i ++ )
13420
+				{
13421
+						if ( ! isxdigit( (int) p[i] ) )
13422
+						{
13423
+								return NULL ;
13424
+						}
13425
+				}
13426
+								Hex2RGB(p,aoResultRGB);
13427
+								strcpy(lDefaultHexRGB, p);
13428
+								if (lPointerInputBox) strcpy(lPointerInputBox, lDialogString); /* restore its previous content to tinyfd_inputBox */
13429
+								return lDefaultHexRGB;
13430
+		}
13431
 
13432
-        if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
13433
-        if ( ! ( lIn = popen( lDialogString , "r" ) ) )
13434
-        {
13435
-                return NULL ;
13436
-    }
13437
-        while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
13438
-        {
13439
-        }
13440
-        pclose( lIn ) ;
13441
-    if ( ! strlen( lBuff ) )
13442
-    {
13443
-        return NULL ;
13444
-    }
13445
-        /* printf( "len Buff: %lu\n" , strlen(lBuff) ) ; */
13446
-        /* printf( "lBuff0: %s\n" , lBuff ) ; */
13447
-    if ( lBuff[strlen( lBuff ) -1] == '\n' )
13448
-    {
13449
-        lBuff[strlen( lBuff ) -1] = '\0' ;
13450
-    }
13451
+		if (tinyfd_verbose) printf( "lDialogString: %s\n" , lDialogString ) ;
13452
+		if ( ! ( lIn = popen( lDialogString , "r" ) ) )
13453
+		{
13454
+				return NULL ;
13455
+	}
13456
+		while ( fgets( lBuff , sizeof( lBuff ) , lIn ) != NULL )
13457
+		{
13458
+		}
13459
+		pclose( lIn ) ;
13460
+	if ( ! strlen( lBuff ) )
13461
+	{
13462
+		return NULL ;
13463
+	}
13464
+		/* printf( "len Buff: %lu\n" , strlen(lBuff) ) ; */
13465
+		/* printf( "lBuff0: %s\n" , lBuff ) ; */
13466
+	if ( lBuff[strlen( lBuff ) -1] == '\n' )
13467
+	{
13468
+		lBuff[strlen( lBuff ) -1] = '\0' ;
13469
+	}
13470
 
13471
-        if ( lWasZenity3 )
13472
-    {
13473
-                if ( lBuff[0] == '#' )
13474
-                {
13475
-                        if ( strlen(lBuff)>7 )
13476
-                        {
13477
-                                lBuff[3]=lBuff[5];
13478
-                                lBuff[4]=lBuff[6];
13479
-                                lBuff[5]=lBuff[9];
13480
-                                lBuff[6]=lBuff[10];
13481
-                                lBuff[7]='\0';
13482
-                        }
13483
-                Hex2RGB(lBuff,aoResultRGB);
13484
-                }
13485
-                else if ( lBuff[3] == '(' ) {
13486
+		if ( lWasZenity3 )
13487
+	{
13488
+				if ( lBuff[0] == '#' )
13489
+				{
13490
+						if ( strlen(lBuff)>7 )
13491
+						{
13492
+								lBuff[3]=lBuff[5];
13493
+								lBuff[4]=lBuff[6];
13494
+								lBuff[5]=lBuff[9];
13495
+								lBuff[6]=lBuff[10];
13496
+								lBuff[7]='\0';
13497
+						}
13498
+				Hex2RGB(lBuff,aoResultRGB);
13499
+				}
13500
+				else if ( lBuff[3] == '(' ) {
13501
 #if (defined(__cplusplus ) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__clang__)
13502
-    sscanf(lBuff,"rgb(%hhu,%hhu,%hhu", & aoResultRGB[0], & aoResultRGB[1],& aoResultRGB[2]);
13503
+	sscanf(lBuff,"rgb(%hhu,%hhu,%hhu", & aoResultRGB[0], & aoResultRGB[1],& aoResultRGB[2]);
13504
 #else
13505
-    aoResultRGB[0] = strtol(lBuff+4, & lTmp2, 10 );
13506
-    aoResultRGB[1] = strtol(lTmp2+1, & lTmp2, 10 );
13507
-    aoResultRGB[2] = strtol(lTmp2+1, NULL, 10 );
13508
+	aoResultRGB[0] = (unsigned char) strtol(lBuff+4, & lTmp2, 10 );
13509
+	aoResultRGB[1] = (unsigned char) strtol(lTmp2+1, & lTmp2, 10 );
13510
+	aoResultRGB[2] = (unsigned char) strtol(lTmp2+1, NULL, 10 );
13511
 #endif
13512
-    RGB2Hex(aoResultRGB,lBuff);
13513
-                }
13514
-                else if ( lBuff[4] == '(' ) {
13515
+	RGB2Hex(aoResultRGB,lBuff);
13516
+				}
13517
+				else if ( lBuff[4] == '(' ) {
13518
 #if (defined(__cplusplus ) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__clang__)
13519
-    sscanf(lBuff,"rgba(%hhu,%hhu,%hhu",  & aoResultRGB[0], & aoResultRGB[1],& aoResultRGB[2]);
13520
+	sscanf(lBuff,"rgba(%hhu,%hhu,%hhu",  & aoResultRGB[0], & aoResultRGB[1],& aoResultRGB[2]);
13521
 #else
13522
-    aoResultRGB[0] = strtol(lBuff+5, & lTmp2, 10 );
13523
-    aoResultRGB[1] = strtol(lTmp2+1, & lTmp2, 10 );
13524
-    aoResultRGB[2] = strtol(lTmp2+1, NULL, 10 );
13525
+	aoResultRGB[0] = (unsigned char) strtol(lBuff+5, & lTmp2, 10 );
13526
+	aoResultRGB[1] = (unsigned char) strtol(lTmp2+1, & lTmp2, 10 );
13527
+	aoResultRGB[2] = (unsigned char) strtol(lTmp2+1, NULL, 10 );
13528
 #endif
13529
-    RGB2Hex(aoResultRGB,lBuff);
13530
-                }
13531
-    }
13532
-    else if ( lWasOsascript || lWasXdialog )
13533
-    {
13534
-                /* printf( "lBuff: %s\n" , lBuff ) ; */
13535
+	RGB2Hex(aoResultRGB,lBuff);
13536
+				}
13537
+	}
13538
+	else if ( lWasOsascript || lWasXdialog )
13539
+	{
13540
+				/* printf( "lBuff: %s\n" , lBuff ) ; */
13541
 #if (defined(__cplusplus ) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__clang__)
13542
-    sscanf(lBuff,"%hhu %hhu %hhu", & aoResultRGB[0], & aoResultRGB[1],& aoResultRGB[2]);
13543
+	sscanf(lBuff,"%hhu %hhu %hhu", & aoResultRGB[0], & aoResultRGB[1],& aoResultRGB[2]);
13544
 #else
13545
-    aoResultRGB[0] = strtol(lBuff, & lTmp2, 10 );
13546
-    aoResultRGB[1] = strtol(lTmp2+1, & lTmp2, 10 );
13547
-    aoResultRGB[2] = strtol(lTmp2+1, NULL, 10 );
13548
+	aoResultRGB[0] = (unsigned char) strtol(lBuff, & lTmp2, 10 );
13549
+	aoResultRGB[1] = (unsigned char) strtol(lTmp2+1, & lTmp2, 10 );
13550
+	aoResultRGB[2] = (unsigned char) strtol(lTmp2+1, NULL, 10 );
13551
 #endif
13552
-    RGB2Hex(aoResultRGB,lBuff);
13553
-    }
13554
-    else
13555
-    {
13556
-                Hex2RGB(lBuff,aoResultRGB);
13557
-    }
13558
-    /* printf("%d %d %d\n", aoResultRGB[0],aoResultRGB[1],aoResultRGB[2]); */
13559
-    /* printf( "lBuff: %s\n" , lBuff ) ; */
13560
+	RGB2Hex(aoResultRGB,lBuff);
13561
+	}
13562
+	else
13563
+	{
13564
+				Hex2RGB(lBuff,aoResultRGB);
13565
+	}
13566
+	/* printf("%d %d %d\n", aoResultRGB[0],aoResultRGB[1],aoResultRGB[2]); */
13567
+	/* printf( "lBuff: %s\n" , lBuff ) ; */
13568
 
13569
-	strcpy(lDefaultHexRGB,lBuff);
13570
-	return lDefaultHexRGB ;
13571
+		strcpy(lDefaultHexRGB,lBuff);
13572
+		return lDefaultHexRGB ;
13573
 }
13574
 
13575
 #endif /* _WIN32 */
13576
 
13577
 
13578
+/* Modified prototypes for R */
13579
+
13580
+void tfd_messageBox(
13581
+	char const * aTitle ,
13582
+	char const * aMessage ,
13583
+	char const * aDialogType ,
13584
+	char const * aIconType ,
13585
+	int * aiDefaultButton )
13586
+{
13587
+	* aiDefaultButton = tinyfd_messageBox( aTitle , aMessage , aDialogType , aIconType , * aiDefaultButton ) ;
13588
+}
13589
+
13590
+
13591
+void tfd_inputBox(
13592
+	char const * aTitle ,
13593
+	char const * aMessage ,
13594
+	char * * aiDefaultInput )
13595
+{
13596
+	char * lReturnedInput ;
13597
+	if ( ! strcmp( * aiDefaultInput , "NULL") )  lReturnedInput = tinyfd_inputBox( aTitle , aMessage , NULL ) ;
13598
+	else lReturnedInput = tinyfd_inputBox( aTitle , aMessage , * aiDefaultInput ) ;
13599
+
13600
+	if ( lReturnedInput ) strcpy ( * aiDefaultInput , lReturnedInput ) ;
13601
+	else strcpy ( * aiDefaultInput , "NULL" ) ;
13602
+}
13603
+
13604
+
13605
+void tfd_saveFileDialog(
13606
+	char const * aTitle ,
13607
+	char * * aiDefaultPathAndFile ,
13608
+	int const * aNumOfFilterPatterns ,
13609
+	char const * const * aFilterPatterns ,
13610
+	char const * aSingleFilterDescription )
13611
+{
13612
+	char * lSavefile ;
13613
+
13614
+	/* printf( "aFilterPatterns %s\n" , aFilterPatterns [0]); */
13615
+
13616
+	lSavefile = tinyfd_saveFileDialog( aTitle , * aiDefaultPathAndFile , * aNumOfFilterPatterns ,
13617
+										aFilterPatterns, aSingleFilterDescription ) ;
13618
+	if ( lSavefile ) strcpy ( * aiDefaultPathAndFile , lSavefile ) ;
13619
+	else strcpy ( * aiDefaultPathAndFile , "NULL" ) ;
13620
+}
13621
+
13622
+
13623
+void tfd_openFileDialog(
13624
+	char const * aTitle ,
13625
+	char * * aiDefaultPathAndFile ,
13626
+	int const * aNumOfFilterPatterns ,
13627
+	char const * const * aFilterPatterns ,
13628
+	char const * aSingleFilterDescription ,
13629
+	int const * aAllowMultipleSelects )
13630
+{
13631
+	char * lOpenfile ;
13632
+
13633
+	/* printf( "aFilterPatterns %s\n" , aFilterPatterns [0]); */
13634
+
13635
+	lOpenfile = tinyfd_openFileDialog( aTitle , * aiDefaultPathAndFile , * aNumOfFilterPatterns ,
13636
+									aFilterPatterns , aSingleFilterDescription , * aAllowMultipleSelects ) ;
13637
+
13638
+	if ( lOpenfile ) strcpy ( * aiDefaultPathAndFile , lOpenfile ) ;
13639
+	else strcpy ( * aiDefaultPathAndFile , "NULL" ) ;
13640
+}
13641
+
13642
+
13643
+void tfd_selectFolderDialog(
13644
+	char const * aTitle ,
13645
+	char * * aiDefaultPath )
13646
+{
13647
+	char * lSelectedfolder ;
13648
+	lSelectedfolder = tinyfd_selectFolderDialog( aTitle, * aiDefaultPath ) ;
13649
+	if ( lSelectedfolder ) strcpy ( * aiDefaultPath , lSelectedfolder ) ;
13650
+	else strcpy ( * aiDefaultPath , "NULL" ) ;
13651
+}
13652
+
13653
+
13654
+void tfd_colorChooser(
13655
+	char const * aTitle ,
13656
+	char * * aiDefaultHexRGB )
13657
+{
13658
+	unsigned char const aDefaultRGB [ 3 ] = {128,128,128} ;
13659
+	unsigned char aoResultRGB [ 3 ] =  {128,128,128} ;
13660
+	char * lChosenColor ;
13661
+	lChosenColor = tinyfd_colorChooser( aTitle, * aiDefaultHexRGB, aDefaultRGB, aoResultRGB ) ;
13662
+	if ( lChosenColor ) strcpy ( * aiDefaultHexRGB , lChosenColor ) ;
13663
+	else strcpy ( * aiDefaultHexRGB , "NULL" ) ;
13664
+}
13665
+
13666
+/* end of Modified prototypes for R */
13667
+
13668
+
13669
+
13670
 /*
13671
 int main( int argc , char * argv[] )
13672
 {
13673
@@ -7602,11 +7909,11 @@
13674
 strcat(lBuffer, tinyfd_version);
13675
 if (lWillBeGraphicMode)
13676
 {
13677
-    strcat(lBuffer, "\ngraphic mode: ");
13678
+	strcat(lBuffer, "\ngraphic mode: ");
13679
 }
13680
 else
13681
 {
13682
-    strcat(lBuffer, "\nconsole mode: ");
13683
+	strcat(lBuffer, "\nconsole mode: ");
13684
 }
13685
 strcat(lBuffer, tinyfd_response);
13686
 strcat(lBuffer, "\n");
13687
@@ -7618,128 +7925,128 @@
13688
 
13689
 if (lWillBeGraphicMode && !tinyfd_forceConsole)
13690
 {
13691
-        tinyfd_forceConsole = ! tinyfd_messageBox("Hello World",
13692
-                "graphic dialogs [yes] / console mode [no]?",
13693
-                "yesno", "question", 1);
13694
+		tinyfd_forceConsole = ! tinyfd_messageBox("Hello World",
13695
+				"graphic dialogs [yes] / console mode [no]?",
13696
+				"yesno", "question", 1);
13697
 }
13698
 
13699
 lTmp = tinyfd_inputBox(
13700
-        "a password box", "your password will be revealed", NULL);
13701
+		"a password box", "your password will be revealed", NULL);
13702
 
13703
 if (!lTmp) return 1;
13704
 
13705
 strcpy(lString, lTmp);
13706
 
13707
 lTheSaveFileName = tinyfd_saveFileDialog(
13708
-        "let us save this password",
13709
-        "passwordFile.txt",
13710
-        2,
13711
-        lFilterPatterns,
13712
-        NULL);
13713
+		"let us save this password",
13714
+		"passwordFile.txt",
13715
+		2,
13716
+		lFilterPatterns,
13717
+		NULL);
13718
 
13719
 if (!lTheSaveFileName)
13720
 {
13721
-        tinyfd_messageBox(
13722
-                "Error",
13723
-                "Save file name is NULL",
13724
-                "ok",
13725
-                "error",
13726
-                1);
13727
-        return 1;
13728
+		tinyfd_messageBox(
13729
+				"Error",
13730
+				"Save file name is NULL",
13731
+				"ok",
13732
+				"error",
13733
+				1);
13734
+		return 1;
13735
 }
13736
 
13737
 lIn = fopen(lTheSaveFileName, "w");
13738
 if (!lIn)
13739
 {
13740
-        tinyfd_messageBox(
13741
-                "Error",
13742
-                "Can not open this file in write mode",
13743
-                "ok",
13744
-                "error",
13745
-                1);
13746
-        return 1;
13747
+		tinyfd_messageBox(
13748
+				"Error",
13749
+				"Can not open this file in write mode",
13750
+				"ok",
13751
+				"error",
13752
+				1);
13753
+		return 1;
13754
 }
13755
 fputs(lString, lIn);
13756
 fclose(lIn);
13757
 
13758
 lTheOpenFileName = tinyfd_openFileDialog(
13759
-        "let us read the password back",
13760
-        "",
13761
-        2,
13762
-        lFilterPatterns,
13763
-        NULL,
13764
-        0);
13765
+		"let us read the password back",
13766
+		"",
13767
+		2,
13768
+		lFilterPatterns,
13769
+		NULL,
13770
+		0);
13771
 
13772
 if (!lTheOpenFileName)
13773
 {
13774
-        tinyfd_messageBox(
13775
-                "Error",
13776
-                "Open file name is NULL",
13777
-                "ok",
13778
-                "error",
13779
-                1);
13780
-        return 1;
13781
+		tinyfd_messageBox(
13782
+				"Error",
13783
+				"Open file name is NULL",
13784
+				"ok",
13785
+				"error",
13786
+				1);
13787
+		return 1;
13788
 }
13789
 
13790
 lIn = fopen(lTheOpenFileName, "r");
13791
 
13792
 if (!lIn)
13793
 {
13794
-        tinyfd_messageBox(
13795
-                "Error",
13796
-                "Can not open this file in read mode",
13797
-                "ok",
13798
-                "error",
13799
-                1);
13800
-        return(1);
13801
+		tinyfd_messageBox(
13802
+				"Error",
13803
+				"Can not open this file in read mode",
13804
+				"ok",
13805
+				"error",
13806
+				1);
13807
+		return(1);
13808
 }
13809
 lBuffer[0] = '\0';
13810
 fgets(lBuffer, sizeof(lBuffer), lIn);
13811
 fclose(lIn);
13812
 
13813
 tinyfd_messageBox("your password is",
13814
-        lBuffer, "ok", "info", 1);
13815
+		lBuffer, "ok", "info", 1);
13816
 
13817
 lTheSelectFolderName = tinyfd_selectFolderDialog(
13818
-        "let us just select a directory", NULL);
13819
+		"let us just select a directory", NULL);
13820
 
13821
 if (!lTheSelectFolderName)
13822
 {
13823
-        tinyfd_messageBox(
13824
-                "Error",
13825
-                "Select folder name is NULL",
13826
-                "ok",
13827
-                "error",
13828
-                1);
13829
-        return 1;
13830
+		tinyfd_messageBox(
13831
+				"Error",
13832
+				"Select folder name is NULL",
13833
+				"ok",
13834
+				"error",
13835
+				1);
13836
+		return 1;
13837
 }
13838
 
13839
 tinyfd_messageBox("The selected folder is",
13840
-        lTheSelectFolderName, "ok", "info", 1);
13841
+		lTheSelectFolderName, "ok", "info", 1);
13842
 
13843
 lTheHexColor = tinyfd_colorChooser(
13844
-        "choose a nice color",
13845
-        "#FF0077",
13846
-        lRgbColor,
13847
-        lRgbColor);
13848
+		"choose a nice color",
13849
+		"#FF0077",
13850
+		lRgbColor,
13851
+		lRgbColor);
13852
 
13853
 if (!lTheHexColor)
13854
 {
13855
-        tinyfd_messageBox(
13856
-                "Error",
13857
-                "hexcolor is NULL",
13858
-                "ok",
13859
-                "error",
13860
-                1);
13861
-        return 1;
13862
+		tinyfd_messageBox(
13863
+				"Error",
13864
+				"hexcolor is NULL",
13865
+				"ok",
13866
+				"error",
13867
+				1);
13868
+		return 1;
13869
 }
13870
 
13871
 tinyfd_messageBox("The selected hexcolor is",
13872
-        lTheHexColor, "ok", "info", 1);
13873
+		lTheHexColor, "ok", "info", 1);
13874
 
13875
-        tinyfd_beep();
13876
+		tinyfd_beep();
13877
 
13878
-        return 0;
13879
+		return 0;
13880
 }
13881
 */
13882
 
(-)b/games/renpy/files/renpy.sh (-1 / +3 lines)
Added Link Here
0
- 
1
#!/bin/sh
2
3
exec replace/renpy.py "$@"

Return to bug 278181