MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / Style_Import

Function Style_Import

src/Styles.c:1226–1266  ·  view source on GitHub ↗

============================================================================= Style_Import()

Source from the content-addressed store, hash-verified

1224// Style_Import()
1225//
1226BOOL Style_Import ( HWND hwnd )
1227{
1228 WCHAR szFile[MAX_PATH * 2] = L"";
1229 WCHAR szFilter[256];
1230 OPENFILENAME ofn;
1231 ZeroMemory ( &ofn, sizeof ( OPENFILENAME ) );
1232 GetString ( IDS_FILTER_INI, szFilter, COUNTOF ( szFilter ) );
1233 PrepareFilterStr ( szFilter );
1234 ofn.lStructSize = sizeof ( OPENFILENAME );
1235 ofn.hwndOwner = hwnd;
1236 ofn.lpstrFilter = szFilter;
1237 ofn.lpstrFile = szFile;
1238 ofn.lpstrDefExt = L"ini";
1239 ofn.nMaxFile = COUNTOF ( szFile );
1240 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
1241 | OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/;
1242 if ( GetOpenFileName ( &ofn ) ) {
1243 int i, iLexer;
1244 WCHAR *pIniSection = LocalAlloc ( LPTR, sizeof ( WCHAR ) * 32 * 1024 );
1245 int cchIniSection = ( int ) LocalSize ( pIniSection ) / sizeof ( WCHAR );
1246 for ( iLexer = 0; iLexer < NUMLEXERS; iLexer++ ) {
1247 if ( GetPrivateProfileSection ( pLexArray[iLexer]->pszName, pIniSection, cchIniSection, szFile ) ) {
1248 if ( !IniSectionGetString ( pIniSection, L"FileNameExtensions", pLexArray[iLexer]->pszDefExt,
1249 pLexArray[iLexer]->szExtensions, COUNTOF ( pLexArray[iLexer]->szExtensions ) ) )
1250 lstrcpyn ( pLexArray[iLexer]->szExtensions, pLexArray[iLexer]->pszDefExt,
1251 COUNTOF ( pLexArray[iLexer]->szExtensions ) );
1252 i = 0;
1253 while ( pLexArray[iLexer]->Styles[i].iStyle != -1 ) {
1254 IniSectionGetString ( pIniSection, pLexArray[iLexer]->Styles[i].pszName,
1255 pLexArray[iLexer]->Styles[i].pszDefault,
1256 pLexArray[iLexer]->Styles[i].szValue,
1257 COUNTOF ( pLexArray[iLexer]->Styles[i].szValue ) );
1258 i++;
1259 }
1260 }
1261 }
1262 LocalFree ( pIniSection );
1263 return ( TRUE );
1264 }
1265 return ( FALSE );
1266}
1267
1268//=============================================================================
1269//

Callers 1

Style_ConfigDlgProcFunction · 0.85

Calls 2

PrepareFilterStrFunction · 0.85
IniSectionGetStringFunction · 0.85

Tested by

no test coverage detected