From 6b4c318e4b6206a06daa28a940f6c9a1901b6fa9 Mon Sep 17 00:00:00 2001 From: joostverburg Date: Sat, 15 Mar 2003 12:55:31 +0000 Subject: [PATCH] InstallOptions 2.1, always \r\n for newline git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2298 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/InstallOptions/Changelog.txt | 11 +++ Contrib/InstallOptions/InstallerOptions.cpp | 77 ++++++++++---------- Contrib/InstallOptions/Readme.html | 18 ++++- Plugins/InstallOptions.dll | Bin 12800 -> 12800 bytes 4 files changed, 63 insertions(+), 43 deletions(-) diff --git a/Contrib/InstallOptions/Changelog.txt b/Contrib/InstallOptions/Changelog.txt index 81869375..fa117061 100644 --- a/Contrib/InstallOptions/Changelog.txt +++ b/Contrib/InstallOptions/Changelog.txt @@ -1,3 +1,14 @@ +DLL version 2.1 (3/15/2003) +* \r\n converts to newline in both label Text and ValidateText +* New browse dialog style (modern) +* Word wrapping for check boxes and radio buttons +* No ugly border for edit fields under XP +* Scroll bar for list boxes +* Works with SetStaticBkColor +* DISABLED dir and file request fields now disable the browse button too +* No more STATE value for labels +* Minor fixes + DLL version 2.0 (1/4/2003) * Supports custom font and DPI settings (by Joost Verburg) * INI files should contain dialog units now, no pixels (by Joost Verburg) diff --git a/Contrib/InstallOptions/InstallerOptions.cpp b/Contrib/InstallOptions/InstallerOptions.cpp index 1121c008..9d8167b6 100644 --- a/Contrib/InstallOptions/InstallerOptions.cpp +++ b/Contrib/InstallOptions/InstallerOptions.cpp @@ -32,6 +32,35 @@ char *STRDUP(const char *c) return t; } +void ConvertNewLines(char *str) { + char *p1, *p2; + for (p1=p2=str; *p1; p1++, p2++) { + if (*p1 == '\\') { + switch (p1[1]) { + case 'n': + *p2 = '\n'; + break; + case 'r': + *p2 = '\r'; + break; + case 't': + *p2 = '\t'; + break; + case '\\': + *p2 = '\\'; + break; + default: + p1--; + p2--; + break; + } + p1++; + } + else *p2 = *p1; + } + *p2 = 0; +} + #define FIELD_LABEL (1) #define FIELD_ICON (2) #define FIELD_BITMAP (3) @@ -482,33 +511,11 @@ bool ReadSettings(void) { pFields[nIdx].nFlags |= LookupToken(FlagTable, szResult); pFields[nIdx].pszText = myGetProfileStringDup(szField, "TEXT"); + + // Label Text - convert newline + if (pFields[nIdx].nType == FIELD_LABEL && pFields[nIdx].pszText) { - char *p1, *p2; - for (p1=p2=pFields[nIdx].pszText; *p1; p1++, p2++) { - if (*p1 == '\\') { - switch (p1[1]) { - case 'n': - *p2 = '\n'; - break; - case 'r': - *p2 = '\r'; - break; - case 't': - *p2 = '\t'; - break; - case '\\': - *p2 = '\\'; - break; - default: - p1--; - p2--; - break; - } - p1++; - } - else *p2 = *p1; - } - *p2 = 0; + ConvertNewLines(pFields[nIdx].pszText); } // pszState cannot be NULL (?) @@ -531,21 +538,11 @@ bool ReadSettings(void) { pFields[nIdx].nMinLength = GetPrivateProfileInt(szField, "MinLen", 0, pszFilename); pFields[nIdx].pszValidateText = myGetProfileStringDup(szField, "ValidateText"); + + // ValidateText - convert newline + if (pFields[nIdx].pszValidateText) { - // translate backslash-n in the input into actual carriage-return/line-feed characters. - for (char *pPos = pFields[nIdx].pszValidateText; *pPos; pPos++) { - if (*pPos == '\\') { - if ((*(pPos + 1) == 'n') || (*(pPos + 1) == 'N')) { - *pPos = '\r'; - *(pPos + 1) = '\n'; -/* - } else if (*(pPos + 1) == '\\') { - // if it's 2 backslash in a row, then skip the second. - pPos++; -*/ - } - } - } + ConvertNewLines(pFields[nIdx].pszValidateText); } { diff --git a/Contrib/InstallOptions/Readme.html b/Contrib/InstallOptions/Readme.html index 642c0b07..253fa010 100644 --- a/Contrib/InstallOptions/Readme.html +++ b/Contrib/InstallOptions/Readme.html @@ -235,7 +235,7 @@ numbers from 1 to NumFields. Each Field section can contain the following values (optional) Specifies the caption of a label, checkbox, or radio button control. For icon and bitmaps control this specifies the path to the image.

- Note: \r\n will be replaced by a newline for labels. + Note: For labels, \r\n will be converted to a newline. State @@ -280,8 +280,7 @@ numbers from 1 to NumFields. Each Field section can contain the following values If a particular field fails the test for "MinLen" or "MaxLen", a messagebox will be displayed with this text.

- Note: The only formatting performed on this text is "\n" will be - replaced with a newline in the messagebox. + Note: \r\n will be converted to a newline. Left
Right
Top
Bottom
(required) @@ -511,6 +510,19 @@ FunctionEnd

Version history