void ProcessingDlg::ProcessLibrary(const LibraryDetectionConfig* Config,const LibraryDetectionConfigSet* Set) { Status->SetLabel( wxString::Format( _("Searching library \"%s\""), Set->ShortCode.c_str())); CheckFilter(_T(""),wxStringStringMap(),wxArrayString(),Config,Set,0); }
void ProcessingDlg::CheckFilter( const wxString& OldBasePath, const wxStringStringMap& OldVars, const wxArrayString& OldCompilers, const LibraryDetectionConfig* Config, const LibraryDetectionConfigSet* Set, int WhichFilter) { if ( (int)Config->Filters.size() <= WhichFilter ) { FoundLibrary(OldBasePath,OldVars,OldCompilers,Config,Set); return; } const LibraryDetectionFilter& Filter = Config->Filters[WhichFilter]; switch ( Filter.Type ) { case LibraryDetectionFilter::File: { // Split path wxArrayString Pattern; SplitPath(Filter.Value,Pattern); // Fetch list of files with filename matching last pattern's element const wxArrayString& PathArray = Map[Pattern[Pattern.Count()-1]]; if ( PathArray.empty() ) return; // Process those files for ( size_t i=0; i<PathArray.Count(); i++ ) { wxArrayString Path; wxStringStringMap Vars = OldVars; SplitPath(PathArray[i],Path); int path_index = (int)Path.Count() - 1; int pattern_index = (int)Pattern.Count() - 1; // Check if patterns do match while ( ( path_index >= 0 ) && ( pattern_index >= 0 ) ) { wxString& PatternPart = Pattern[pattern_index]; if ( IsVariable(PatternPart) ) { wxString VarName = PatternPart.Mid(3,PatternPart.Len()-4); if ( Vars[VarName].empty() ) { Vars[VarName] = Path[path_index]; } else { if ( Vars[VarName] != Path[path_index] ) break; } } else { if ( PatternPart != Path[path_index] ) break; } path_index--; pattern_index--; } // This is when patterns did not match if ( pattern_index >= 0 ) continue; // Construct base path from the rest of file's name wxString BasePath; for ( int j=0; j<=path_index; j++ ) { BasePath += Path[j] + wxFileName::GetPathSeparator(); } // And check if base path match the previous one if ( !OldBasePath.IsEmpty() ) { if ( BasePath != OldBasePath ) continue; } // Ok, this filter matches, let's advance to next filet CheckFilter(BasePath,Vars,OldCompilers,Config,Set,WhichFilter+1); } break; } case LibraryDetectionFilter::Platform: { wxStringTokenizer Tokenizer(Filter.Value,_T("| \t")); bool IsPlatform = false; while ( Tokenizer.HasMoreTokens() ) { wxString Platform = Tokenizer.GetNextToken(); if ( platform::windows ) { if ( Platform==_T("win") || Platform==_T("windows") ) { IsPlatform = true; break; } } if ( platform::macosx ) { if ( Platform==_T("mac") || Platform==_T("macosx") ) { IsPlatform = true; break; } } if ( platform::linux ) { if ( Platform==_T("lin") || Platform==_T("linux") ) { IsPlatform = true; break; } } if ( platform::freebsd ) { if ( Platform==_T("bsd") || Platform==_T("freebsd") ) { IsPlatform = true; break; } } if ( platform::netbsd ) { if ( Platform==_T("bsd") || Platform==_T("netbsd") ) { IsPlatform = true; break; } } if ( platform::openbsd ) { if ( Platform==_T("bsd") || Platform==_T("openbsd") ) { IsPlatform = true; break; } } if ( platform::darwin ) { if ( Platform==_T("darwin") ) { IsPlatform = true; break; } } if ( platform::solaris ) { if ( Platform==_T("solaris") ) { IsPlatform = true; break; } } if ( platform::unix ) { if ( Platform==_T("unix") || Platform==_T("un*x") ) { IsPlatform = true; break; } } } if ( IsPlatform ) { CheckFilter(OldBasePath,OldVars,OldCompilers,Config,Set,WhichFilter+1); } break; } case LibraryDetectionFilter::Exec: { bool IsExec = false; if ( wxIsAbsolutePath(Filter.Value) ) { // If this is absolute path, we don't search in PATH evironment var IsExec = wxFileName::IsFileExecutable(Filter.Value); } else { // Let's search for the name in search paths wxString Path; if ( wxGetEnv(_T("PATH"),&Path) ) { wxString Splitter = _T(":"); if ( platform::windows ) Splitter = _T(";"); wxStringTokenizer Tokenizer(Path,Splitter); while ( Tokenizer.HasMoreTokens() ) { wxString OnePath = Tokenizer.GetNextToken(); // Let's skip relative paths (f.ex. ".") if ( !wxIsAbsolutePath(OnePath) ) continue; OnePath += wxFileName::GetPathSeparator()+Filter.Value; if ( wxFileName::IsFileExecutable(OnePath) ) { IsExec = true; break; } } } } if ( IsExec ) { CheckFilter(OldBasePath,OldVars,OldCompilers,Config,Set,WhichFilter+1); } break; } case LibraryDetectionFilter::PkgConfig: { if ( m_KnownResults[rtPkgConfig].IsShortCode(Filter.Value) ) { CheckFilter(OldBasePath,OldVars,OldCompilers,Config,Set,WhichFilter+1); } break; } case LibraryDetectionFilter::Compiler: { if ( OldCompilers.IsEmpty() ) { // If this is the first compiler filter, let's build new list and continue CheckFilter(OldBasePath,OldVars,wxStringTokenize(Filter.Value,_T("| \t")),Config,Set,WhichFilter+1); } else { // We've set compiler list before, leave only the intersection // of previous and current list wxArrayString Compilers; wxStringTokenizer Tokenizer(Filter.Value,_T("| \t")); while ( Tokenizer.HasMoreTokens() ) { wxString Comp = Tokenizer.GetNextToken(); if ( OldCompilers.Index(Comp) != wxNOT_FOUND ) { Compilers.Add(Comp); } } if ( !Compilers.IsEmpty() ) { CheckFilter(OldBasePath,OldVars,Compilers,Config,Set,WhichFilter+1); } } break; } case LibraryDetectionFilter::None: { CheckFilter(OldBasePath,OldVars,OldCompilers,Config,Set,WhichFilter+1); break; } } }
void ShortcutMapper::populateShortCuts() { TCHAR filter1[40]={0},filter2[40]={0}; NppParameters *nppParam = NppParameters::getInstance(); size_t nrItems = 0; switch(_currentState) { case STATE_MENU: { nrItems = nppParam->getUserShortcuts().size(); break; } case STATE_MACRO: { nrItems = nppParam->getMacroList().size(); break; } case STATE_USER: { nrItems = nppParam->getUserCommandList().size(); break; } case STATE_PLUGIN: { nrItems = nppParam->getPluginCommandList().size(); break; } case STATE_SCINTILLA: { nrItems = nppParam->getScintillaKeyList().size(); break; } } ListView_DeleteAllItems(hlistview); if(nrItems==0){ ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); return; } else ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), true); switch(_currentState) { case STATE_MENU: { ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } case STATE_MACRO: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled); break; } case STATE_USER: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled); break; } case STATE_PLUGIN: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } case STATE_SCINTILLA: { ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } } int index=0; int widths[3]; widths[0]=gettextwidth(hlistview,L"Index"); widths[1]=gettextwidth(hlistview,L"Name"); widths[2]=gettextwidth(hlistview,L"Shortcut"); GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER1),filter1,sizeof(filter2)/sizeof(TCHAR)); GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER2),filter2,sizeof(filter2)/sizeof(TCHAR)); _tcslwr(filter1); _tcslwr(filter2); for(size_t i = 0; i < nrItems; i++) { TCHAR keys[40]={0}; const TCHAR *name=GetShortcutName(_currentState,i,nppParam); GetShortcutKeys(_currentState,i,nppParam,keys,sizeof(keys)/sizeof(TCHAR)); if((filter1[0]==L'\0' && filter2[0]==L'\0') || (filter1[0]!=L'\0' && CheckFilter(name,filter1)) || (filter2[0]!=L'\0' && CheckFilter(keys,filter2))){ TCHAR str[10]={0}; LV_ITEM lvitem={0}; int w; _sntprintf_s(str,sizeof(str)/sizeof(TCHAR),_TRUNCATE,L"%i",i); w=gettextwidth(hlistview,str); if(w>widths[0]) widths[0]=w; w=gettextwidth(hlistview,name); if(w>widths[1]) widths[1]=w; w=gettextwidth(hlistview,keys); if(w>widths[2]) widths[2]=w; lvitem.mask=LVIF_TEXT|LVIF_PARAM; lvitem.iItem=index; lvitem.pszText=(LPWSTR)str; lvitem.lParam=i; ListView_InsertItem(hlistview,&lvitem); lvitem.mask=LVIF_TEXT; lvitem.iSubItem=1; lvitem.pszText=(LPWSTR)name; ListView_SetItem(hlistview,&lvitem); lvitem.iSubItem=2; lvitem.pszText=(LPWSTR)keys; ListView_SetItem(hlistview,&lvitem); index++; } } ListView_SetColumnWidth(hlistview,0,widths[0]); ListView_SetColumnWidth(hlistview,1,widths[1]); ListView_SetColumnWidth(hlistview,2,widths[2]); ListView_SetItemState(hlistview,0,LVIS_SELECTED,LVIS_SELECTED); if(index==0){ ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); } }
void CClientDlg::UpdateServersList() { m_pServerList.SetRedraw(FALSE); //------------------------------------------- int m_nItemSelected = -1; for (int i=0; i<m_pServerList.GetItemCount(); i++) { if (m_pServerList.GetItemState(i, (UINT)-1)& LVIS_SELECTED) { m_nItemSelected = i; break; } } //------------------------------------------- m_pServerList.DeleteAllItems(); if (!net_Hosts.size()) { m_pServerList.SetRedraw(TRUE); m_pServerList.Invalidate(TRUE); return; }; int NumItems = 0; for (u32 I=0; I<net_Hosts.size(); I++) { HOST_NODE& N = net_Hosts [I]; switch (N.dpServerGameType) { // case GAME_UNKNOWN: case GAME_END_LIST: continue; } if (!CheckFilter(&N)) { continue; } LVITEM iItem; iItem.mask = LVIF_TEXT | LVIF_IMAGE; iItem.iItem = NumItems; iItem.iSubItem = 0; iItem.pszText = N.dpServerName; iItem.iImage = (N.dpPassword == 0) ? 0 : 1; CString tmp; tmp.Format("%d/%d", N.dpServerNumPlayers, (N.dpServerMaxPlayers == 0) ? 32 : N.dpServerMaxPlayers); m_pServerList.InsertItem(&iItem); m_pServerList.SetItemText(NumItems, 0, N.dpServerName); m_pServerList.SetItemText(NumItems, 1, N.dpSessionName); m_pServerList.SetItemText(NumItems, 2, g_GameTypeName[N.dpServerGameType]); m_pServerList.SetItemText(NumItems, 3, tmp); tmp.Format("%d", N.dpPing); m_pServerList.SetItemText(NumItems, 4, tmp); // tmp.Format("%s", N.dpPassword ? "Yes" : "No"); // m_pServerList.SetItemText(NumItems, 5, tmp); m_pServerList.SetItemData(NumItems, I); NumItems++; }; // m_pServerList.SetItemState(NumItems-1, LVIS_SELECTED) if (m_nItemSelected != -1) { UINT NewItemState = m_pServerList.GetItemState(m_nItemSelected, (UINT)-1) | LVIS_SELECTED; m_pServerList.SetItemState(m_nItemSelected, NewItemState, (UINT)-1); } m_pServerList.SetRedraw(TRUE); m_pServerList.Invalidate(TRUE); };
static int checkFlat (Hdr *phdr, WF3Info *wf32d, int *missing, int *nsteps) { /* arguments: Hdr *phdr i: primary header WF3Info *wf32d i: switches, file names, etc int *missing io: incremented if a file is missing int *nsteps io: incremented if this step can be performed */ extern int status; int calswitch; int GetSwitch (Hdr *, char *, int *); int GotFileName (char *); int GetImageRef (RefFileInfo *, Hdr *, char *, RefImage *, int *); void MissingFile (char *, char *, int *); void CheckImgType (RefImage *, char *, char *, int *); int CheckFilter (char *, char *, char *, int *); int CheckDetector (char *, int, char *, int *); /* Are we supposed to do this step? */ if (wf32d->flatcorr == PERFORM) { if (GetSwitch (phdr, "FLATCORR", &calswitch)) return (status); if (calswitch == COMPLETE) { wf32d->flatcorr = OMIT; return (status); } /* Initial values; may be reset below. */ wf32d->pfltcorr = PERFORM; wf32d->dfltcorr = PERFORM; wf32d->lfltcorr = PERFORM; if (GetImageRef (wf32d->refnames, phdr, "PFLTFILE", &wf32d->pflt, &wf32d->pfltcorr)) return (status); if (wf32d->pflt.exists != EXISTS_YES) { if (GotFileName (wf32d->pflt.name)) { /* name specified? */ MissingFile ("PFLTFILE", wf32d->pflt.name, missing); } else { wf32d->pfltcorr = OMIT; /* name was blank or "N/A" */ } } else { /* Is the FILETYPE appropriate for a PFLT file? */ CheckImgType (&wf32d->pflt, "PIXEL-TO-PIXEL FLAT", "PFLTFILE", missing); /* Does it have the correct FILTER value? */ if (CheckFilter(wf32d->pflt.name, wf32d->filter, "FILTER", missing)) return (status); /* Does it have the correct DETECTOR value? */ if (CheckDetector(wf32d->pflt.name, wf32d->detector, "DETECTOR", missing)) return (status); } if (GetImageRef (wf32d->refnames, phdr, "DFLTFILE", &wf32d->dflt, &wf32d->dfltcorr)) return (status); if (wf32d->dflt.exists != EXISTS_YES) { if (GotFileName (wf32d->dflt.name)) { MissingFile ("DFLTFILE", wf32d->dflt.name, missing); } else { wf32d->dfltcorr = OMIT; } } else { /* Is the FILETYPE appropriate for a DFLT file? */ CheckImgType (&wf32d->dflt, "DELTA FLAT", "DFLTFILE", missing); /* Does it have the correct FILTER value? */ if (CheckFilter(wf32d->dflt.name, wf32d->filter, "FILTER", missing)) return (status); /* Does it have the correct DETECTOR value? */ if (CheckDetector(wf32d->dflt.name, wf32d->detector, "DETECTOR", missing)) return (status); } if (GetImageRef (wf32d->refnames, phdr, "LFLTFILE", &wf32d->lflt, &wf32d->lfltcorr)) return (status); if (wf32d->lflt.exists != EXISTS_YES) { if (GotFileName (wf32d->lflt.name)) { MissingFile ("LFLTFILE", wf32d->lflt.name, missing); } else { wf32d->lfltcorr = OMIT; } } else { /* Is the FILETYPE appropriate for a LFLT file? */ CheckImgType (&wf32d->lflt, "LARGE SCALE FLAT", "LFLTFILE", missing); /* Does it have the correct FILTER value? */ if (CheckFilter(wf32d->lflt.name, wf32d->filter, "FILTER", missing)) return (status); /* Does it have the correct DETECTOR value? */ if (CheckDetector(wf32d->lflt.name, wf32d->detector, "DETECTOR", missing)) return (status); } /* If any of the three parts of flat fielding is set to PERFORM, then we can do this step. If not, and if any part is DUMMY because of the reference file, reset the flat field flag to DUMMY; this will mean that all the files that were specified have pedigree=dummy. */ if (wf32d->pfltcorr == PERFORM || wf32d->dfltcorr == PERFORM || wf32d->lfltcorr == PERFORM) { (*nsteps)++; } else if (wf32d->pfltcorr == OMIT && wf32d->dfltcorr == OMIT && wf32d->lfltcorr == OMIT) { (*missing)++; trlerror ("PFLTFILE, DFLTFILE, and LFLTFILE are all blank."); } else if (wf32d->pfltcorr == DUMMY || wf32d->dfltcorr == DUMMY || wf32d->lfltcorr == DUMMY) { wf32d->flatcorr = DUMMY; } } return (status); }