From b623f5953691b2a0614e6f1f4def86bdbb9a4113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 8 Aug 2020 11:53:00 +0200 Subject: New upstream version 5.2.0Beta2.1 --- app/bin/misc.c | 2972 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 1633 insertions(+), 1339 deletions(-) (limited to 'app/bin/misc.c') diff --git a/app/bin/misc.c b/app/bin/misc.c index 827c2db..2ac1e2f 100644 --- a/app/bin/misc.c +++ b/app/bin/misc.c @@ -1,4 +1,4 @@ -/* \file misc.c +/* file misc.c * Main routine and initialization for the application */ @@ -40,7 +40,7 @@ #define R_OK (02) #define access _access #if _MSC_VER >1300 - #define strdup _strdup +#define strdup _strdup #endif #else #include @@ -62,6 +62,7 @@ #include "messages.h" #include "misc.h" #include "param.h" +#include "include/paramfilelist.h" #include "paths.h" #include "smalldlg.h" #include "track.h" @@ -72,6 +73,10 @@ char *userLocale = NULL; extern wBalloonHelp_t balloonHelp[]; + +static wMenuToggle_p mapShowMI; +static wMenuToggle_p magnetsMI; + #ifdef DEBUG #define CHECK_BALLOONHELP /*#define CHECK_UNUSED_BALLOONHELP*/ @@ -83,7 +88,7 @@ void DoCarDlg(void); /**************************************************************************** * - EXPORTED VARIABLES + EXPORTED VARIABLES * */ @@ -96,7 +101,7 @@ EXPORT wWin_p mainW; EXPORT wIndex_t changed = 0; -EXPORT char message[STR_LONG_SIZE]; +EXPORT char message[STR_HUGE_SIZE]; static char message2[STR_LONG_SIZE]; EXPORT REGION_T curRegion = 0; @@ -107,7 +112,7 @@ EXPORT coOrd zero = { 0.0, 0.0 }; EXPORT wBool_t extraButtons = FALSE; -EXPORT long onStartup; /**< controls behaviour after startup: load last layout if zero, else start with blank canvas */ +EXPORT long onStartup; /**< controls behaviour after startup: load last layout if zero, else start with blank canvas */ EXPORT wButton_p undoB; EXPORT wButton_p redoB; @@ -115,13 +120,15 @@ EXPORT wButton_p redoB; EXPORT wButton_p zoomUpB; EXPORT wButton_p zoomDownB; wButton_p mapShowB; +wButton_p magnetsB; +wButton_p backgroundB; EXPORT wIndex_t checkPtMark = 0; EXPORT wMenu_p demoM; EXPORT wMenu_p popup1M, popup2M; EXPORT wMenu_p popup1aM, popup2aM; - +EXPORT wMenu_p popup1mM, popup2mM; static wIndex_t curCommand = 0; EXPORT void * commandContext; @@ -129,6 +136,8 @@ EXPORT wIndex_t cmdGroup; EXPORT wIndex_t joinCmdInx; EXPORT wIndex_t modifyCmdInx; EXPORT long rightClickMode = 0; +EXPORT long selectMode = 0; +EXPORT long selectZero = 1; EXPORT DIST_T easementVal = 0.0; EXPORT DIST_T easeR = 0.0; EXPORT DIST_T easeL = 0.0; @@ -151,7 +160,7 @@ static int verbose = 0; static wMenuList_p winList_mi; static BOOL_T inMainW = TRUE; -static long stickySet; +static long stickySet = 0; static long stickyCnt = 0; static char * stickyLabels[33]; #define TOOLBARSET_INIT (0xFFFF) @@ -168,10 +177,11 @@ static BOOL_T messageListEmpty = TRUE; extern long curTurnoutEp; static wIndex_t printCmdInx; static wIndex_t gridCmdInx; -static paramData_t menuPLs[101] = { - { PD_LONG, &toolbarSet, "toolbarset" }, - { PD_LONG, &curTurnoutEp, "cur-turnout-ep" } }; +static paramData_t menuPLs[101] = { { PD_LONG, &toolbarSet, "toolbarset" }, { + PD_LONG, &curTurnoutEp, "cur-turnout-ep" } }; static paramGroup_t menuPG = { "misc", PGO_RECORD, menuPLs, 2 }; + +extern wBool_t wDrawDoTempDraw; /**************************************************************************** * @@ -186,12 +196,11 @@ EXPORT long totalReallocs = 0; EXPORT long totalFreeed = 0; EXPORT long totalFrees = 0; -static unsigned long guard0 = 0xDEADBEEF; -static unsigned long guard1 = 0xAF00BA8A; +static unsigned long guard0 = 0xDEADBEEF; +static unsigned long guard1 = 0xAF00BA8A; static int log_malloc; -EXPORT void * MyMalloc ( long size ) -{ +EXPORT void * MyMalloc(long size) { void * p; totalMallocs++; totalMalloced += size; @@ -200,29 +209,26 @@ EXPORT void * MyMalloc ( long size ) AbortProg( "mallocing > 65500 bytes" ); } #endif - p = malloc( (size_t)size + sizeof (size_t) + 2 * sizeof (unsigned long) ); + p = malloc((size_t) size + sizeof(size_t) + 2 * sizeof(unsigned long)); if (p == NULL) - AbortProg( "No memory" ); - -LOG1( log_malloc, ( "Malloc(%ld) = %lx (%lx-%lx)\n", size, - (long)((char*)p+sizeof (size_t) + sizeof (unsigned long)), - (long)p, - (long)((char*)p+size+sizeof (size_t) + 2 * sizeof(unsigned long)) )); - *(size_t*)p = (size_t)size; - p = (char*)p + sizeof (size_t); - *(unsigned long*)p = guard0; - p = (char*)p + sizeof (unsigned long); - *(unsigned long*)((char*)p+size) = guard1; - memset( p, 0, (size_t)size ); + AbortProg("No memory"); + + LOG1(log_malloc, + ( "Malloc(%ld) = %lx (%lx-%lx)\n", size, (long)((char*)p+sizeof (size_t) + sizeof (unsigned long)), (long)p, (long)((char*)p+size+sizeof (size_t) + 2 * sizeof(unsigned long)) )); + *(size_t*) p = (size_t) size; + p = (char*) p + sizeof(size_t); + *(unsigned long*) p = guard0; + p = (char*) p + sizeof(unsigned long); + *(unsigned long*) ((char*) p + size) = guard1; + memset(p, 0, (size_t )size); return p; } -EXPORT void * MyRealloc( void * old, long size ) -{ +EXPORT void * MyRealloc(void * old, long size) { size_t oldSize; void * new; - if (old==NULL) - return MyMalloc( size ); + if (old == NULL) + return MyMalloc(size); totalReallocs++; totalRealloced += size; #if defined(WINDOWS) && ! defined(WIN32) @@ -230,67 +236,61 @@ EXPORT void * MyRealloc( void * old, long size ) AbortProg( "reallocing > 65500 bytes" ); } #endif - if ( *(unsigned long*)((char*)old - sizeof (unsigned long)) != guard0 ) { - AbortProg( "Guard0 is hosed" ); + if (*(unsigned long*) ((char*) old - sizeof(unsigned long)) != guard0) { + AbortProg("Guard0 is hosed"); } - oldSize = *(size_t*)((char*)old - sizeof (unsigned long) - sizeof (size_t)); - if ( *(unsigned long*)((char*)old + oldSize) != guard1 ) { - AbortProg( "Guard1 is hosed" ); + oldSize = *(size_t*) ((char*) old - sizeof(unsigned long) - sizeof(size_t)); + if (*(unsigned long*) ((char*) old + oldSize) != guard1) { + AbortProg("Guard1 is hosed"); } -LOG1( log_malloc, ("Realloc(%lx,%ld) was %d\n", (long)old, size, oldSize ) ) - if ((long)oldSize == size) { + LOG1(log_malloc, ("Realloc(%lx,%ld) was %d\n", (long)old, size, oldSize )) + if ((long) oldSize == size) { return old; } if (size == 0) { - free( (char*)old - sizeof *(long*)0 - sizeof *(size_t*)0 ); + free((char*) old - sizeof *(long*) 0 - sizeof *(size_t*) 0); return NULL; } - new = MyMalloc( size ); + new = MyMalloc(size); if (new == NULL && size) - AbortProg( "No memory" ); - memcpy( new, old, min((size_t)size, oldSize) ); + AbortProg("No memory"); + memcpy(new, old, min((size_t )size, oldSize)); MyFree(old); return new; } - -EXPORT void MyFree( void * ptr ) -{ +EXPORT void MyFree(void * ptr) { size_t oldSize; totalFrees++; if (ptr) { - if ( *(unsigned long*)((char*)ptr - sizeof (unsigned long)) != guard0 ) { - AbortProg( "Guard0 is hosed" ); + if (*(unsigned long*) ((char*) ptr - sizeof(unsigned long)) != guard0) { + AbortProg("Guard0 is hosed"); } - oldSize = *(size_t*)((char*)ptr - sizeof (unsigned long) - sizeof (size_t)); - if ( *(unsigned long*)((char*)ptr + oldSize) != guard1 ) { - AbortProg( "Guard1 is hosed" ); + oldSize = *(size_t*) ((char*) ptr - sizeof(unsigned long) + - sizeof(size_t)); + if (*(unsigned long*) ((char*) ptr + oldSize) != guard1) { + AbortProg("Guard1 is hosed"); } -LOG1( log_malloc, ("Free %d at %lx (%lx-%lx)\n", oldSize, (long)ptr, - (long)((char*)ptr-sizeof *(size_t*)0-sizeof *(long*)0), - (long)((char*)ptr+oldSize+sizeof *(long*)0)) ) + LOG1(log_malloc, + ("Free %d at %lx (%lx-%lx)\n", oldSize, (long)ptr, (long)((char*)ptr-sizeof *(size_t*)0-sizeof *(long*)0), (long)((char*)ptr+oldSize+sizeof *(long*)0))) totalFreeed += oldSize; - free( (char*)ptr - sizeof *(long*)0 - sizeof *(size_t*)0 ); + free((char*) ptr - sizeof *(long*) 0 - sizeof *(size_t*) 0); } } - -EXPORT void * memdup( void * src, size_t size ) -{ +EXPORT void * memdup(void * src, size_t size) { void * p; - p = MyMalloc( size ); + p = MyMalloc(size); if (p == NULL) - AbortProg( "No memory" ); - memcpy( p, src, size ); + AbortProg("No memory"); + memcpy(p, src, size); return p; } - -EXPORT char * MyStrdup( const char * str ) -{ +EXPORT char * MyStrdup(const char * str) { char * ret; - ret = (char*)MyMalloc( strlen( str ) + 1 ); - strcpy( ret, str ); + ret = (char*) MyMalloc(strlen(str) + 1); + strcpy(ret, str); return ret; } @@ -304,32 +304,70 @@ EXPORT char * MyStrdup( const char * str ) * */ EXPORT char * ConvertToEscapedText(const char * text) { - int text_i=0; + int text_i = 0; int add = 0; //extra chars for escape - while(text[text_i]) { + while (text[text_i]) { switch (text[text_i]) { - case '\n': add++; break; - case '\t': add++; break; - case '\\': add++; break; - case '\"': add++; break; + case '\n': + add++; + break; + case '\t': + add++; + break; + case '\\': + add++; + break; + case '\"': + add++; + break; } text_i++; } - char * cout = MyMalloc(strlen(text)+1+add); + unsigned cnt = strlen(text) + 1 + add; +#ifdef WINDOWS + cnt *= 2; +#endif + char * cout = MyMalloc(cnt); int cout_i = 0; text_i = 0; - while(text[text_i]) { + while (text[text_i]) { char c = text[text_i]; switch (c) { - case '\n': cout[cout_i] = '\\'; cout_i++; cout[cout_i] = 'n'; cout_i++; break; // Line Feed - case '\t': cout[cout_i] = '\\'; cout_i++; cout[cout_i] = 't'; cout_i++; break; // Tab - case '\\': cout[cout_i] = '\\'; cout_i++; cout[cout_i] = '\\'; cout_i++; break; // BackSlash - case '\"': cout[cout_i] = '\"'; cout_i++; cout[cout_i] = '\"'; cout_i++; break; // Double Quotes - default: cout[cout_i] = c; cout_i++; + case '\n': + cout[cout_i] = '\\'; + cout_i++; + cout[cout_i] = 'n'; + cout_i++; + break; // Line Feed + case '\t': + cout[cout_i] = '\\'; + cout_i++; + cout[cout_i] = 't'; + cout_i++; + break; // Tab + case '\\': + cout[cout_i] = '\\'; + cout_i++; + cout[cout_i] = '\\'; + cout_i++; + break; // BackSlash + case '\"': + cout[cout_i] = '\"'; + cout_i++; + cout[cout_i] = '\"'; + cout_i++; + break; // Double Quotes + default: + cout[cout_i] = c; + cout_i++; } text_i++; } cout[cout_i] = '\0'; +#ifdef WINDOWS + wSystemToUTF8(cout, cout, cnt); +#endif // WINDOWS + return cout; } @@ -340,83 +378,82 @@ EXPORT char * ConvertToEscapedText(const char * text) { * \n = LineFeed 0x0A * \t = Tab 0x09 * \\ = \ The way to still produce backslash - * "" = " Take out quotes included so that other (CSV-like) programs could read the files * */ EXPORT char * ConvertFromEscapedText(const char * text) { - enum { CHARACTER, ESCAPE, QUOTE } state = CHARACTER; - char * cout = MyMalloc(strlen(text)+1); //always equal to or shorter than - int text_i = 0; - int cout_i = 0; - int c; - while (text[text_i]) { - c = text[text_i]; - switch (state) { - case CHARACTER: - if (c == '\\') { - state = ESCAPE; - } else if (c == '\"') { - state = QUOTE; - } else { - cout[cout_i] = c; - cout_i++; - } - break; - - case ESCAPE: - switch (c) { - case '\\': cout[cout_i] = '\\'; cout_i++; break; // "\\" = "\" - case 'n': cout[cout_i] = '\n'; cout_i++; break; // LF - case 't': cout[cout_i] = '\t'; cout_i++; break; // TAB - } - state = CHARACTER; - break; - case QUOTE: - switch(c) { - case '\"': cout[cout_i] = c; cout_i++; break; //One quote = NULL, Two quotes = 1 quote - } - state = CHARACTER; - } - text_i++; - } - cout[cout_i] = '\0'; - return cout; -} + enum { + CHARACTER, ESCAPE + } state = CHARACTER; + char * cout = MyMalloc(strlen(text) + 1); //always equal to or shorter than + int text_i = 0; + int cout_i = 0; + int c; + while (text[text_i]) { + c = text[text_i]; + switch (state) { + case CHARACTER: + if (c == '\\') { + state = ESCAPE; + } else { + cout[cout_i] = c; + cout_i++; + } + break; + case ESCAPE: + switch (c) { + case '\\': + cout[cout_i] = '\\'; + cout_i++; + break; // "\\" = "\" + case 'n': + cout[cout_i] = '\n'; + cout_i++; + break; // LF + case 't': + cout[cout_i] = '\t'; + cout_i++; + break; // TAB + } + state = CHARACTER; + break; + } + text_i++; + } + cout[cout_i] = '\0'; + return cout; +} -EXPORT void AbortProg( - char * msg, - ... ) -{ +EXPORT void AbortProg(char * msg, ...) { static BOOL_T abort2 = FALSE; int rc; va_list ap; - va_start( ap, msg ); - vsprintf( message, msg, ap ); - va_end( ap ); + va_start(ap, msg); + vsprintf(message, msg, ap); + va_end(ap); if (abort2) { - wNoticeEx( NT_ERROR, message, _("ABORT"), NULL ); + wNoticeEx( NT_ERROR, message, _("ABORT"), NULL); } else { - strcat( message, _("\nDo you want to save your layout?") ); - rc = wNoticeEx( NT_ERROR, message, _("Ok"), _("ABORT") ); + strcat(message, _("\nDo you want to save your layout?")); + rc = wNoticeEx( NT_ERROR, message, _("Ok"), _("ABORT")); if (rc) { - DoSaveAs( (doSaveCallBack_p)abort ); + DoSaveAs((doSaveCallBack_p) abort); } else { abort(); } } } - -EXPORT char * Strcpytrimed( char * dst, char * src, BOOL_T double_quotes ) -{ +EXPORT char * Strcpytrimed(char * dst, char * src, BOOL_T double_quotes) { char * cp; - while (*src && isspace((unsigned char)*src) ) src++; + while (*src && isspace((unsigned char) *src)) + src++; if (!*src) return dst; - cp = src+strlen(src)-1; - while ( cp>src && isspace((unsigned char)*cp) ) cp--; - while ( src<=cp ) { + cp = src + strlen(src) - 1; + while (cp > src && isspace((unsigned char) *cp)) + cp--; + while (src <= cp) { if (*src == '"' && double_quotes) *dst++ = '"'; *dst++ = *src++; @@ -425,50 +462,83 @@ EXPORT char * Strcpytrimed( char * dst, char * src, BOOL_T double_quotes ) return dst; } +static char * directory; -EXPORT char * BuildTrimedTitle( char * cp, char * sep, char * mfg, char * desc, char * partno ) -{ - cp = Strcpytrimed( cp, mfg, FALSE ); - strcpy( cp, sep ); +#ifdef WINDOWS +#define F_OK (0) +#endif + +EXPORT wBool_t CheckHelpTopicExists(const char * topic) { + + char * htmlFile; + + // Check the file exits in the distro + + if (!directory) + directory = malloc(BUFSIZ); + + if (directory == NULL) return 0; + + sprintf(directory, "%s/html/", wGetAppLibDir()); + + htmlFile = malloc(strlen(directory)+strlen(topic) + 6); + + sprintf(htmlFile, "%s%s.html", directory, topic); + + if( access( htmlFile, F_OK ) == -1 ) { + + printf("Missing help topic %s\n",topic); + + free(htmlFile); + + return 0; + + } + + free(htmlFile); + + return 1; + +} + +EXPORT char * BuildTrimedTitle(char * cp, char * sep, char * mfg, char * desc, + char * partno) { + cp = Strcpytrimed(cp, mfg, FALSE); + strcpy(cp, sep); cp += strlen(cp); - cp = Strcpytrimed( cp, desc, FALSE ); - strcpy( cp, sep ); + cp = Strcpytrimed(cp, desc, FALSE); + strcpy(cp, sep); cp += strlen(cp); - cp = Strcpytrimed( cp, partno, FALSE ); + cp = Strcpytrimed(cp, partno, FALSE); return cp; } - -static void ShowMessageHelp( int index, const char * label, void * data ) -{ +static void ShowMessageHelp(int index, const char * label, void * data) { char msgKey[STR_SIZE], *cp, *msgSrc; - msgSrc = (char*)data; + msgSrc = (char*) data; if (!msgSrc) return; - cp = strchr( msgSrc, '\t' ); - if (cp==NULL) { - sprintf( msgKey, _("No help for %s"), msgSrc ); - wNoticeEx( NT_INFORMATION, msgKey, _("Ok"), NULL ); + cp = strchr(msgSrc, '\t'); + if (cp == NULL) { + sprintf(msgKey, _("No help for %s"), msgSrc); + wNoticeEx( NT_INFORMATION, msgKey, _("Ok"), NULL); return; } - memcpy( msgKey, msgSrc, cp-msgSrc ); - msgKey[cp-msgSrc] = 0; - wHelp( msgKey ); + memcpy(msgKey, msgSrc, cp - msgSrc); + msgKey[cp - msgSrc] = 0; + wHelp(msgKey); } - -static char * ParseMessage( - char *msgSrc ) -{ - char *cp1=NULL, *cp2=NULL; +static char * ParseMessage(char *msgSrc) { + char *cp1 = NULL, *cp2 = NULL; static char shortMsg[STR_SIZE]; - cp1 = strchr( _(msgSrc), '\t' ); + cp1 = strchr(_(msgSrc), '\t'); if (cp1) { - cp2 = strchr( cp1+1, '\t' ); + cp2 = strchr(cp1 + 1, '\t'); if (cp2) { cp1++; - memcpy( shortMsg, cp1, cp2-cp1 ); - shortMsg[cp2-cp1] = 0; + memcpy(shortMsg, cp1, cp2 - cp1); + shortMsg[cp2 - cp1] = 0; cp1 = shortMsg; cp2++; } else { @@ -476,157 +546,177 @@ static char * ParseMessage( cp2 = cp1; } if (messageListEmpty) { - wMenuListDelete( messageList_ml, _(MESSAGE_LIST_EMPTY) ); + wMenuListDelete(messageList_ml, _(MESSAGE_LIST_EMPTY)); messageListEmpty = FALSE; } - wMenuListAdd( messageList_ml, 0, cp1, _(msgSrc) ); + wMenuListAdd(messageList_ml, 0, cp1, _(msgSrc)); return cp2; } else { return _(msgSrc); } } - -EXPORT void InfoMessage( char * format, ... ) -{ +EXPORT void InfoMessage(char * format, ...) { va_list ap; - va_start( ap, format ); - format = ParseMessage( format ); - vsprintf( message2, format, ap ); - va_end( ap ); + va_start(ap, format); + format = ParseMessage(format); + vsprintf(message2, format, ap); + va_end(ap); /*InfoSubstituteControl( NULL, NULL );*/ if (inError) return; - SetMessage( message2 ); + SetMessage(message2); } - -EXPORT void ErrorMessage( char * format, ... ) -{ +EXPORT void ErrorMessage(char * format, ...) { va_list ap; - va_start( ap, format ); - format = ParseMessage( format ); - vsprintf( message2, format, ap ); - va_end( ap ); - InfoSubstituteControls( NULL, NULL ); - SetMessage( message2 ); + va_start(ap, format); + format = ParseMessage(format); + vsprintf(message2, format, ap); + va_end(ap); + InfoSubstituteControls( NULL, NULL); + SetMessage(message2); wBeep(); inError = TRUE; } +EXPORT int NoticeMessage(char * format, char * yes, char * no, ...) { + va_list ap; + va_start(ap, no); + format = ParseMessage(format); + vsprintf(message2, format, ap); + va_end(ap); + return wNotice(message2, yes, no); +} -EXPORT int NoticeMessage( char * format, char * yes, char * no, ... ) -{ +EXPORT int NoticeMessage2(int playbackRC, char * format, char * yes, char * no, + ...) { va_list ap; - va_start( ap, no ); - format = ParseMessage( format ); - vsprintf( message2, format, ap ); - va_end( ap ); - return wNotice( message2, yes, no ); + if (inPlayback) + return playbackRC; + va_start(ap, no); + format = ParseMessage(format); + vsprintf(message2, format, ap); + va_end(ap); + return wNoticeEx( NT_INFORMATION, message2, yes, no); } +/** +* Set the file's changed flag and update the window title. +*/ -EXPORT int NoticeMessage2( int playbackRC, char * format, char * yes, char * no, ... ) +void +FileIsChanged(void) { - va_list ap; - if ( inPlayback ) - return playbackRC; - va_start( ap, no ); - format = ParseMessage( format ); - vsprintf( message2, format, ap ); - va_end( ap ); - return wNoticeEx( NT_INFORMATION, message2, yes, no ); + changed++; + SetWindowTitle(); } - + /***************************************************************************** * * MAIN BUTTON HANDLERS * */ + /** + * Confirm a requested operation in case of possible loss of changes. + * + * \param label2 IN operation to be cancelled, unused at the moment + * \param after IN function to be executed on positive confirmation + * \return true if proceed, false if cancel operation + */ +/** TODO: make sensible messages when requesting confirmation */ -EXPORT void Confirm( char * label2, doSaveCallBack_p after ) +bool +Confirm(char * label2, doSaveCallBack_p after) { - int rc; + int rc = -1; if (changed) { - rc = wNotice3( - _("Save changes to the layout design before closing?\n\n" - "If you don't save now, your unsaved changes will be discarded."), - _("&Save"), _("&Cancel"), _("&Don't Save") ); - if (rc == 1) { - DoSave( after ); - return; - } else if (rc == 0) { - return; - } + rc = wNotice3(_("Save changes to the layout design before closing?\n\n" + "If you don't save now, your unsaved changes will be discarded."), + _("&Save"), _("&Cancel"), _("&Don't Save")); } - after(); - return; + + switch (rc) { + case -1: /* do not save */ + after(); + break; + case 0: /* cancel operation */ + break; + case 1: /* save */ + LayoutBackGroundInit(FALSE); + LayoutBackGroundSave(); + DoSave(after); + break; + } + return(rc != 0); } -static void ChkLoad( void ) -{ +static void ChkLoad(void) { Confirm(_("Load"), DoLoad); } -static void ChkRevert( void ) +static void ChkExamples( void ) { - int rc; - - if( changed) { - rc = wNoticeEx( NT_WARNING, _("Do you want to return to the last saved state?\n\n" - "Revert will cause all changes done since last save to be lost."), - _("&Revert"), _("&Cancel") ); - if( rc ) { - /* load the file */ - char *filename = GetLayoutFullPath(); - LoadTracks( 1, &filename, NULL ); - } - } + Confirm(_("examples"), DoExamples); } +static void ChkRevert(void) +{ + int rc; + + if (changed) { + rc = wNoticeEx(NT_WARNING, + _("Do you want to return to the last saved state?\n\n" + "Revert will cause all changes done since last save to be lost."), + _("&Revert"), _("&Cancel")); + if (rc) { + /* load the file */ + char *filename = GetLayoutFullPath(); + LoadTracks(1, &filename, NULL); + } + } +} static char * fileListPathName; -static void AfterFileList( void ) -{ - DoFileList( 0, NULL, fileListPathName ); +static void AfterFileList(void) { + DoFileList(0, NULL, fileListPathName); } -static void ChkFileList( int index, const char * label, void * data ) -{ - fileListPathName = (char*)data; - Confirm( _("Load"), AfterFileList ); +static void ChkFileList(int index, const char * label, void * data) { + fileListPathName = (char*) data; + Confirm(_("Load"), AfterFileList); } /** * Save information about current files and some settings to preferences file. */ -EXPORT void SaveState( void ) -{ +EXPORT void SaveState(void) { wPos_t width, height; const char * fileName; void * pathName; char file[6]; int inx; - wWinGetSize( mainW, &width, &height ); - wPrefSetInteger( "draw", "mainwidth", width ); - wPrefSetInteger( "draw", "mainheight", height ); - RememberParamFiles(); + wWinGetSize(mainW, &width, &height); + wPrefSetInteger("draw", "mainwidth", width); + wPrefSetInteger("draw", "mainheight", height); + SaveParamFileList(); ParamUpdatePrefs(); wPrefSetString( "misc", "lastlayout", GetLayoutFullPath()); + wPrefSetInteger( "misc", "lastlayoutexample", bExample ); - if ( fileList_ml ) { - strcpy( file, "file" ); + if (fileList_ml) { + strcpy(file, "file"); file[5] = 0; - for ( inx=0; inx