Working on tool

This commit is contained in:
Ray 2016-09-14 09:39:42 +02:00
parent 47dc4455e2
commit 9a7082c4ea
3 changed files with 53 additions and 41 deletions

View File

@ -1,10 +1,10 @@
/* /*
_________ _________
/ \ tinyfiledialogs.c v2.5.6 [August 6, 2016] zlib licence / \ tinyfiledialogs.c v2.5.8 [September 13, 2016] zlib licence
|tiny file| Unique code file of "tiny file dialogs" created [November 9, 2014] |tiny file| Unique code file of "tiny file dialogs" created [November 9, 2014]
| dialogs | Copyright (c) 2014 - 2016 Guillaume Vareille http://ysengrin.com | dialogs | Copyright (c) 2014 - 2016 Guillaume Vareille http://ysengrin.com
\____ ___/ http://tinyfiledialogs.sourceforge.net \____ ___/ http://tinyfiledialogs.sourceforge.net
\| mailto:tinfyfiledialogs@ysengrin.com \| mailto:tinyfiledialogs@ysengrin.com
A big thank you to Don Heyse http://ldglite.sf.net for A big thank you to Don Heyse http://ldglite.sf.net for
his code contributions, bug corrections & thorough testing! his code contributions, bug corrections & thorough testing!
@ -39,7 +39,7 @@ NO MAIN LOOP
The dialogs can be forced into console mode The dialogs can be forced into console mode
Windows [UTF-8 + UTF-16] Windows [MBCS + UTF-8 + UTF-16]
- native code & some vbs create the graphic dialogs - native code & some vbs create the graphic dialogs
- enhanced console mode can use dialog.exe from - enhanced console mode can use dialog.exe from
http://andrear.altervista.org/home/cdialog.php http://andrear.altervista.org/home/cdialog.php
@ -87,13 +87,10 @@ misrepresented as being the original software.
#include "tinyfiledialogs.h" #include "tinyfiledialogs.h"
/* #define TINYFD_NOLIB //*/ /* #define TINYFD_NOLIB //*/
#define _MAX_FNAME 128 // Ray #define _MAX_FNAME 256 // Ray
#define _MAX_EXT 16 // Ray #define _MAX_EXT 256 // Ray
#ifdef _WIN32 #ifdef _WIN32
#pragma warning(disable:4996) /* allows usage of strncpy, strcpy, strcat, sprintf, fopen */
#pragma warning(disable:4100) /* allows usage of strncpy, strcpy, strcat, sprintf, fopen */
#pragma warning(disable:4706) /* allows usage of strncpy, strcpy, strcat, sprintf, fopen */
#ifndef _WIN32_WINNT #ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500 #define _WIN32_WINNT 0x0500
#endif #endif
@ -105,6 +102,7 @@ misrepresented as being the original software.
#include <conio.h> #include <conio.h>
/*#include <io.h>*/ /*#include <io.h>*/
#define SLASH "\\" #define SLASH "\\"
/* tinyfd_winUtf8 is not ready yet, do not modify */
int tinyfd_winUtf8 = 0 ; /* on windows string char can be 0:MBSC or 1:UTF-8 */ int tinyfd_winUtf8 = 0 ; /* on windows string char can be 0:MBSC or 1:UTF-8 */
#else #else
#include <limits.h> #include <limits.h>
@ -118,7 +116,7 @@ misrepresented as being the original software.
#define MAX_PATH_OR_CMD 1024 /* _MAX_PATH or MAX_PATH */ #define MAX_PATH_OR_CMD 1024 /* _MAX_PATH or MAX_PATH */
#define MAX_MULTIPLE_FILES 32 #define MAX_MULTIPLE_FILES 32
char tinyfd_version [8] = "2.5.6"; char tinyfd_version [8] = "2.5.8";
#if defined(TINYFD_NOLIB) && defined(_WIN32) #if defined(TINYFD_NOLIB) && defined(_WIN32)
int tinyfd_forceConsole = 1 ; int tinyfd_forceConsole = 1 ;
@ -159,6 +157,11 @@ static char gAsciiArt[] ="\
\\_____ ____/\n\ \\_____ ____/\n\
\\|"; \\|";
#ifdef _WIN32
static char gMessageWin[] = "tiny file dialogs on Windows needs:\n\t\
a graphic display\nor\tdialog.exe (enhanced console mode)\
\nor\ta console for basic input";
#else
static char gMessageUnix[] = "tiny file dialogs on UNIX needs:\n\tapplescript\ static char gMessageUnix[] = "tiny file dialogs on UNIX needs:\n\tapplescript\
\nor\tzenity (version 3 for the color chooser)\ \nor\tzenity (version 3 for the color chooser)\
\nor\tmatedialog\nor\tkdialog\ \nor\tmatedialog\nor\tkdialog\
@ -166,10 +169,13 @@ static char gMessageUnix[] = "tiny file dialogs on UNIX needs:\n\tapplescript\
\nor\tdialog (opens a console if needed)\ \nor\tdialog (opens a console if needed)\
\nor\twhiptail, gdialog, gxmessage or xmessage (really?)\ \nor\twhiptail, gdialog, gxmessage or xmessage (really?)\
\nor\tit will open a console (if needed) for basic input (you had it comming!)"; \nor\tit will open a console (if needed) for basic input (you had it comming!)";
#endif
static char gMessageWin[] = "tiny file dialogs on Windows needs:\n\t\ #ifdef _MSC_VER
a graphic display\nor\tdialog.exe (enhanced console mode)\ #pragma warning(disable:4996) /* allows usage of strncpy, strcpy, strcat, sprintf, fopen */
\nor\ta console for basic input"; #pragma warning(disable:4100) /* allows usage of strncpy, strcpy, strcat, sprintf, fopen */
#pragma warning(disable:4706) /* allows usage of strncpy, strcpy, strcat, sprintf, fopen */
#endif
static char * getPathWithoutFinalSlash( static char * getPathWithoutFinalSlash(
char * const aoDestination, /* make sure it is allocated, use _MAX_PATH */ char * const aoDestination, /* make sure it is allocated, use _MAX_PATH */
@ -276,8 +282,12 @@ static void RGB2Hex( unsigned char const aRGB [3] ,
{ {
if ( aRGB ) if ( aRGB )
{ {
sprintf(aoResultHexRGB,"#%02hhx%02hhx%02hhx", #if defined(__GNUC__) && defined(_WIN32)
aRGB[0],aRGB[1],aRGB[2]); sprintf(aoResultHexRGB, "#%02hx%02hx%02hx",
#else
sprintf(aoResultHexRGB, "#%02hhx%02hhx%02hhx",
#endif
aRGB[0], aRGB[1], aRGB[2]);
/* printf("aoResultHexRGB %s\n", aoResultHexRGB); //*/ /* printf("aoResultHexRGB %s\n", aoResultHexRGB); //*/
} }
else else
@ -610,7 +620,7 @@ static char * utf16to8(wchar_t const * const aUtf16string)
} }
static DWORD const runSilentA(char const * const aString) static void runSilentA(char const * const aString)
{ {
STARTUPINFOA StartupInfo; STARTUPINFOA StartupInfo;
PROCESS_INFORMATION ProcessInfo; PROCESS_INFORMATION ProcessInfo;
@ -652,7 +662,7 @@ static DWORD const runSilentA(char const * const aString)
&StartupInfo, &ProcessInfo)) &StartupInfo, &ProcessInfo))
{ {
free(lArgs); free(lArgs);
return GetLastError(); return; /* GetLastError(); */
} }
WaitForSingleObject(ProcessInfo.hProcess, INFINITE); WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
@ -663,11 +673,11 @@ static DWORD const runSilentA(char const * const aString)
CloseHandle(ProcessInfo.hProcess); CloseHandle(ProcessInfo.hProcess);
free(lArgs); free(lArgs);
return rc; return; /* rc */
} }
static DWORD const runSilentW(wchar_t const * const aString) static void runSilentW(wchar_t const * const aString)
{ {
STARTUPINFOW StartupInfo; STARTUPINFOW StartupInfo;
PROCESS_INFORMATION ProcessInfo; PROCESS_INFORMATION ProcessInfo;
@ -710,7 +720,7 @@ static DWORD const runSilentW(wchar_t const * const aString)
&StartupInfo, &ProcessInfo)) &StartupInfo, &ProcessInfo))
{ {
free(lArgs); free(lArgs);
return GetLastError(); return; /* GetLastError(); */
} }
WaitForSingleObject(ProcessInfo.hProcess, INFINITE); WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
@ -723,7 +733,7 @@ static DWORD const runSilentW(wchar_t const * const aString)
CloseHandle(ProcessInfo.hProcess); CloseHandle(ProcessInfo.hProcess);
free(lArgs); free(lArgs);
return rc; return; /* rc */
} }
@ -837,7 +847,6 @@ static char const * inputBoxWinGui(
#ifndef TINYFD_NOLIB #ifndef TINYFD_NOLIB
wchar_t * lDialogStringW; wchar_t * lDialogStringW;
DWORD lDword;
#endif #endif
lTitleLen = aTitle ? strlen(aTitle) : 0 ; lTitleLen = aTitle ? strlen(aTitle) : 0 ;
@ -1013,12 +1022,12 @@ name = 'txt_input' style = 'font-size: 11px;' value = '' ><BR>\n\
if (tinyfd_winUtf8) if (tinyfd_winUtf8)
{ {
lDialogStringW = utf8to16(lDialogString); lDialogStringW = utf8to16(lDialogString);
lDword = runSilentW(lDialogStringW); runSilentW(lDialogStringW);
free(lDialogStringW); free(lDialogStringW);
} }
else else
{ {
lDword = runSilentA(lDialogString); runSilentA(lDialogString);
} }
} }
else else
@ -3323,7 +3332,7 @@ int tinyfd_messageBox (
strcat ( lDialogString , "information" ) ; strcat ( lDialogString , "information" ) ;
} }
} }
strcat ( lDialogString , ";if [$? = 0];then echo 1;else echo 0;fi"); strcat ( lDialogString , ";if [ $? = 0 ];then echo 1;else echo 0;fi");
} }
else if ( kdialogPresent() ) else if ( kdialogPresent() )
{ {
@ -3369,7 +3378,7 @@ int tinyfd_messageBox (
strcat(lDialogString, aTitle) ; strcat(lDialogString, aTitle) ;
strcat(lDialogString, "\"") ; strcat(lDialogString, "\"") ;
} }
strcat ( lDialogString , ";if [$? = 0];then echo 1;else echo 0;fi"); strcat ( lDialogString , ";if [ $? = 0 ];then echo 1;else echo 0;fi");
} }
else if ( ! xdialogPresent() && tkinter2Present ( ) ) else if ( ! xdialogPresent() && tkinter2Present ( ) )
{ {
@ -3609,11 +3618,11 @@ else :\n\tprint 1\n\"" ) ;
if ( lWasGraphicDialog ) if ( lWasGraphicDialog )
{ {
strcat(lDialogString, strcat(lDialogString,
"\" 10 60 ) 2>&1;if [$? = 0];then echo 1;else echo 0;fi"); "\" 10 60 ) 2>&1;if [ $? = 0 ];then echo 1;else echo 0;fi");
} }
else else
{ {
strcat(lDialogString, "\" 10 60 >/dev/tty) 2>&1;if [$? = 0];"); strcat(lDialogString, "\" 10 60 >/dev/tty) 2>&1;if [ $? = 0 ];");
if ( lWasXterm ) if ( lWasXterm )
{ {
strcat ( lDialogString , strcat ( lDialogString ,
@ -3879,7 +3888,7 @@ char const * tinyfd_inputBox(
strcat(lDialogString, " --hide-text") ; strcat(lDialogString, " --hide-text") ;
} }
strcat ( lDialogString , strcat ( lDialogString ,
");if [$? = 0];then echo 1$szAnswer;else echo 0$szAnswer;fi"); ");if [ $? = 0 ];then echo 1$szAnswer;else echo 0$szAnswer;fi");
} }
else if ( kdialogPresent() ) else if ( kdialogPresent() )
{ {
@ -3912,7 +3921,7 @@ char const * tinyfd_inputBox(
strcat(lDialogString, "\"") ; strcat(lDialogString, "\"") ;
} }
strcat ( lDialogString , strcat ( lDialogString ,
");if [$? = 0];then echo 1$szAnswer;else echo 0$szAnswer;fi"); ");if [ $? = 0 ];then echo 1$szAnswer;else echo 0$szAnswer;fi");
} }
else if ( ! xdialogPresent() && tkinter2Present ( ) ) else if ( ! xdialogPresent() && tkinter2Present ( ) )
{ {
@ -4074,14 +4083,14 @@ frontmost of process \\\"Python\\\" to true' ''');");
if ( lWasGraphicDialog ) if ( lWasGraphicDialog )
{ {
strcat(lDialogString,") 2>/tmp/tinyfd.txt;\ strcat(lDialogString,") 2>/tmp/tinyfd.txt;\
if [$? = 0];then tinyfdBool=1;else tinyfdBool=0;fi;\ if [ $? = 0 ];then tinyfdBool=1;else tinyfdBool=0;fi;\
tinyfdRes=$(cat /tmp/tinyfd.txt);\ tinyfdRes=$(cat /tmp/tinyfd.txt);\
rm /tmp/tinyfd.txt;echo $tinyfdBool$tinyfdRes") ; rm /tmp/tinyfd.txt;echo $tinyfdBool$tinyfdRes") ;
} }
else else
{ {
strcat(lDialogString,">/dev/tty ) 2>/tmp/tinyfd.txt;\ strcat(lDialogString,">/dev/tty ) 2>/tmp/tinyfd.txt;\
if [$? = 0];then tinyfdBool=1;else tinyfdBool=0;fi;\ if [ $? = 0 ];then tinyfdBool=1;else tinyfdBool=0;fi;\
tinyfdRes=$(cat /tmp/tinyfd.txt);\ tinyfdRes=$(cat /tmp/tinyfd.txt);\
rm /tmp/tinyfd.txt;echo $tinyfdBool$tinyfdRes") ; rm /tmp/tinyfd.txt;echo $tinyfdBool$tinyfdRes") ;
if ( lWasXterm ) if ( lWasXterm )
@ -5447,7 +5456,7 @@ char const * tinyfd_arrayDialog (
/* /*
int main() int main(void)
{ {
char const * lTmp; char const * lTmp;
char const * lTheSaveFileName; char const * lTheSaveFileName;
@ -5598,10 +5607,12 @@ if (!lTheHexColor)
tinyfd_messageBox("The selected hexcolor is", tinyfd_messageBox("The selected hexcolor is",
lTheHexColor, "ok", "info", 1); lTheHexColor, "ok", "info", 1);
return 0;
} }
//*/ //*/
#ifdef _WIN32 #ifdef _MSC_VER
#pragma warning(default:4996) #pragma warning(default:4996)
#pragma warning(default:4100) #pragma warning(default:4100)
#pragma warning(default:4706) #pragma warning(default:4706)

View File

@ -1,10 +1,10 @@
/* /*
_________ _________
/ \ tinyfiledialogs.h v2.5.6 [August 6, 2016] zlib licence / \ tinyfiledialogs.h v2.5.8 [September 13, 2016] zlib licence
|tiny file| Unique header file of "tiny file dialogs" created [November 9, 2014] |tiny file| Unique header file of "tiny file dialogs" created [November 9, 2014]
| dialogs | Copyright (c) 2014 - 2016 Guillaume Vareille http://ysengrin.com | dialogs | Copyright (c) 2014 - 2016 Guillaume Vareille http://ysengrin.com
\____ ___/ http://tinyfiledialogs.sourceforge.net \____ ___/ http://tinyfiledialogs.sourceforge.net
\| mailto:tinfyfiledialogs@ysengrin.com \| mailto:tinyfiledialogs@ysengrin.com
A big thank you to Don Heyse http://ldglite.sf.net for A big thank you to Don Heyse http://ldglite.sf.net for
his code contributions, bug corrections & thorough testing! his code contributions, bug corrections & thorough testing!
@ -39,7 +39,7 @@ NO MAIN LOOP
The dialogs can be forced into console mode The dialogs can be forced into console mode
Windows [UTF-8 + UTF-16] Windows [MBCS + UTF-8 + UTF-16]
- native code & some vbs create the graphic dialogs - native code & some vbs create the graphic dialogs
- enhanced console mode can use dialog.exe from - enhanced console mode can use dialog.exe from
http://andrear.altervista.org/home/cdialog.php http://andrear.altervista.org/home/cdialog.php
@ -100,6 +100,7 @@ extern "C" {
extern char tinyfd_version[8]; /* contains tinyfd current version number */ extern char tinyfd_version[8]; /* contains tinyfd current version number */
#ifdef _WIN32 #ifdef _WIN32
/* tinyfd_winUtf8 is not ready yet, do not modify */
extern int tinyfd_winUtf8; /* 0 (default) or 1 */ extern int tinyfd_winUtf8; /* 0 (default) or 1 */
/* on windows string char can be 0:MBSC or 1:UTF-8 (work in progress) /* on windows string char can be 0:MBSC or 1:UTF-8 (work in progress)
unless your code is really prepared for it, leave this on MBSC. unless your code is really prepared for it, leave this on MBSC.

View File

@ -293,15 +293,13 @@ int main()
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsFileDropped()) if (IsFileDropped())
{ {
/*
guiPropertySelected = -1; guiPropertySelected = -1;
droppedFiles = GetDroppedFiles(&count); droppedFiles = GetDroppedFiles(&count);
fileName = droppedFiles[0]; //fileName = droppedFiles[0];
//BtnLoadStyle(); //BtnLoadStyle();
//ClearDroppedFiles(); ClearDroppedFiles();
*/
} }
if (guiElementSelected == PROGRESSBAR) if (guiElementSelected == PROGRESSBAR)
@ -310,6 +308,8 @@ int main()
progressValue += 0.005f; progressValue += 0.005f;
} }
// NOTE: REVIEW!!! -> CRASHES APP... (ironically, in MSVC works perfectly)
/*
for (int i = 0; i < NUM_ELEMENTS; i++) for (int i = 0; i < NUM_ELEMENTS; i++)
{ {
if (CheckCollisionPointRec(GetMousePosition(), guiElementRec[i])) if (CheckCollisionPointRec(GetMousePosition(), guiElementRec[i]))
@ -457,7 +457,7 @@ int main()
bgColor = GetColor(GetStyleProperty(BACKGROUND_COLOR)); bgColor = GetColor(GetStyleProperty(BACKGROUND_COLOR));
SetStyleProperty(guiPropertySelected, GetHexValue(colorPickerValue)); SetStyleProperty(guiPropertySelected, GetHexValue(colorPickerValue));
} }
*/
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw