bool ThreadSearchThread::AddNewItem(wxSortedArrayString& sortedArrayString, const wxString& newItem, const wxArrayString& mask)
{
    // Adds item to array only if it does not exist
    bool added = false;
    if ( sortedArrayString.Index(newItem.c_str()) == wxNOT_FOUND )
    {
        // Looks if current file matches one of the file patterns
        size_t maskCount = mask.GetCount();
        if (maskCount == 0)
        {
            sortedArrayString.Add(newItem);
            added = true;
        }
        else
        {
            for (size_t i = 0; i < maskCount; ++i)
            {
                if ( newItem.Matches(mask[i].c_str() ) )
                {
                    sortedArrayString.Add(newItem);
                    added = true;
                    break;
                }
            }
        }
    }
    return added;
}
Пример #2
0
void mmAssetsPanel::OnSearchTxtEntered(wxCommandEvent& event)
{
    const wxString search_string = event.GetString().Lower();
    if (search_string.IsEmpty()) return;

    long last = m_listCtrlAssets->GetItemCount();
    long selectedItem = m_listCtrlAssets->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
    if (selectedItem < 0) //nothing selected
        selectedItem = m_listCtrlAssets->m_asc ? last - 1 : 0;

    while (selectedItem > 0 && selectedItem <= last)
    {
        m_listCtrlAssets->m_asc ? selectedItem-- : selectedItem++;
        const wxString t = getItem(selectedItem, COL_NOTES).Lower();
        if (t.Matches(search_string + "*"))
        {
            //First of all any items should be unselected
            long cursel = m_listCtrlAssets->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
            if (cursel != wxNOT_FOUND)
                m_listCtrlAssets->SetItemState(cursel, 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);

            //Then finded item will be selected
            m_listCtrlAssets->SetItemState(selectedItem, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
            m_listCtrlAssets->EnsureVisible(selectedItem);
            break;
        }
    }
}
Пример #3
0
	bool ScriptFactory::CanHandleScriptFormat(wxString const& filename)
	{
		using std::placeholders::_1;
		// Just make this always return true to bitch about unknown script formats in autoload
		return any_of(Factories().begin(), Factories().end(),
			[&](ScriptFactory *sf) { return filename.Matches(sf->GetFilenamePattern()); });
	}
Пример #4
0
cbWorkspace::cbWorkspace(const wxString& filename) :
    m_IsOK(true),
    m_IsDefault(true),
    m_Modified(false),
    m_Filename(DEFAULT_WORKSPACE),
    m_Title(_("Default workspace"))
{
    //ctor
    if ( filename.Matches(DEFAULT_WORKSPACE) || filename.IsEmpty() )
    {
        // if no filename given, use the default workspace
        wxString tmp = ConfigManager::GetConfigFolder() + wxFILE_SEP_PATH;

        if (!wxDirExists(tmp))
            wxMkdir(tmp, 0755);

        tmp << wxFILE_SEP_PATH << DEFAULT_WORKSPACE;
        m_Filename = tmp;
    }
    else
    {
        m_Filename = filename;
        m_IsDefault = false;
    }

    if ( !filename.IsEmpty() )
    {
        Load();
    }
}
void progress_dialog::extract_progress_from_stderr( const wxString& stdout_string )
{        
    // If it is a progress string (matches this mask using * and ?)...
    if ( stdout_string.Matches( "*collected, * to do*" ) ) {
    
        wxString    value_string;
        wxString    range_string;        
        long        value_long;
        long        range_long;
        wxString    searchable_string = stdout_string;   
    
        // The string starts like this: "---- 1 collected, 9 to do ----"
        searchable_string.Replace( "---- ", "" );
        // The string now looks like this "1 collected, 9 still to do---\n"
        searchable_string.Replace( " collected, ", "R" );         
        // The string now looks like this: "1R9 still to do---\n"        
        value_string = searchable_string.BeforeFirst( 'R' );
        // The value string is now "1".
        range_string = searchable_string.AfterFirst( 'R' );
        // The range string is now "9 still to ----\n"
        range_string = range_string.BeforeFirst( ' ' );
        // The range string is now "9"        

        // Try to convert these strings to longs (returns false if conversion failed).. 
        if ( value_string.ToLong( &value_long ) ) {
            if ( range_string.ToLong( &range_long ) ) {
                // Note that range_long is current still the number remaining. 
                // Add it to value to get a proper range.
                range_long = range_long + value_long;
                // ...If successfully got two longs, cast to ints, and send to 
                // our channel gaugue function
                set_current_channel_gauge( (int)value_long, (int)range_long );
            }
        }
        
    // If it was a "converting the retrieved files" message...            
    } else if ( stdout_string.StartsWith( "Convert" ) ) {
        // ...Update the static text with a message
        XMLCTRL( *this, "progress_dialog_current_channel_value_statictext", wxStaticText )
            ->SetLabel( _( "Converting retrieved files...." ) );
    // If it was a "writing the files into pdb" message...
    } else if ( stdout_string.StartsWith( "Wrote " ) ) {
        // ...Update the static text with a message
        XMLCTRL( *this, "progress_dialog_current_channel_value_statictext", wxStaticText )
            ->SetLabel( _( "Conversion complete. Writing output file..." ) );      
     // It was a "retrieval of files is complete" message:
    } else if ( stdout_string.StartsWith( "---- all" ) ) {
        // ...Set the progress bar to max (range is always plkrFIXED_PERCENTAGE_GAUGE_RANGE 
        // to stop flicker, see notes in plucker_defines.h
        XMLCTRL( *this, "progress_dialog_current_channel_gauge", wxGauge )
            ->SetValue( plkrFIXED_PERCENTAGE_GAUGE_RANGE ); 
        // ...Update the static text with a message
        XMLCTRL( *this, "progress_dialog_current_channel_value_statictext", wxStaticText )
            ->SetLabel( _( "All pages retrieved and parsed. Starting conversion..." ) );    
    }
}
Пример #6
0
bool MainFrame::SameConfig(const wxString& filename, wxTextCtrl* txt)
{
  if (txt && filename.Matches(txt->GetValue()))
  {
    wxMessageBox(wxT("Cannot transfer configurations between the same file.\n"
                     "Please select two different configuration files!"),
                 wxT("Error"), wxICON_EXCLAMATION | wxOK);
    return true;
  }

  return false;
}// SameConfig
Пример #7
0
bool wxExMatchesOneOf(const wxFileName& filename, const wxString& pattern)
{
    if (pattern == "*") return true; // asterix matches always.

    const wxString fullname_uppercase = filename.GetFullName().Upper();

    wxStringTokenizer tkz(pattern.Upper(), ";");

    while (tkz.HasMoreTokens())
    {
        const wxString token = tkz.GetNextToken();

        if (fullname_uppercase.Matches(token)) return true;
    }

    return false;
}
Пример #8
0
void wxStandardPaths::IgnoreAppSubDir(const wxString& subdirPattern)
{
    wxFileName fn = wxFileName::DirName(GetAppDir());

    if ( !fn.GetDirCount() )
    {
        // no last directory to ignore anyhow
        return;
    }

    const wxString lastdir = fn.GetDirs().Last().Lower();
    if ( lastdir.Matches(subdirPattern.Lower()) )
    {
        fn.RemoveLastDir();

        // store the cached value so that subsequent calls to GetAppDir() will
        // reuse it instead of using just the program binary directory
        m_appDir = fn.GetPath();
    }
}
wxDirTraverseResult ThreadSearchThread::OnFile(const wxString& fileName)
{
    // Tests thread termination (user cancelled)
    if ( TestDestroy() == true )
    {
        return wxDIR_STOP;
    }

    // Looks if current file matches one of the file patterns
    for (size_t i = 0; i < m_Masks.GetCount(); ++i)
    {
        if ( fileName.Matches(m_Masks[i].c_str() ) )
        {
            // Adds it to list of files to parse
            m_FilePaths.Add(fileName);
            break;
        }
    }

    return wxDIR_CONTINUE;
}
Пример #10
0
void wxExEx::SetLastCommand(
  const wxString& command,
  bool always)
{
  // First test on '.' and ';' these should never be the last command,
  // even if always were true.
  // Also, undo or placing a marker should not be a last command.
  if (
    command == "." || command == ";" || 
    command == "u" || command.Matches("m?"))
  {
    return;
  }
  
  if (
      always || 
    ( command.StartsWith(":") && command.size() > 2) ||
    (!command.StartsWith(":") && command.size() > 1 && !command.StartsWith("\t")))
  {
    m_LastCommand = command;
  }
}
Пример #11
0
wxString FileFilters::GetFilterString(const wxString& ext)
{
    size_t count = 0;
    wxString ret;
    for (FileFiltersMap::iterator it = s_Filters.begin(); it != s_Filters.end(); ++it)
    {
        if (!ext.IsEmpty())
        {
            // filter based on parameter
            bool match = false;
            wxArrayString array = GetArrayFromString(it->second, _T(";"), true);
            for (size_t i = 0; i < array.GetCount(); ++i)
            {
                if (ext.Matches(array[i]))
                {
                    match = true;
                    break;
                }
            }
            if (!match)
                continue; // filtered
        }
        ++count;
        if (!ret.IsEmpty())
            ret << _T('|');
        ret << it->first << _T('|') << it->second;
    }

    // last filter is always "All"
    if (!ret.IsEmpty())
        ret << _T('|');
    ret << GetFilterAll();

    s_LastFilterAllIndex = count;

    return ret;
}
Пример #12
0
void MainFrame::OfferNode(TiXmlNode** node,               wxListBox* listbox,
                          std::vector<TiXmlNode*> *nodes, const wxString& prefix)
{
  wxString section((*node)->Value(), wxConvLocal);

  if      (section.MakeLower().Matches(wxT("code_completion"))) // code completion plugin token replacements
  {
    TiXmlNode* child = NULL;
    for (child = (*node)->FirstChild(); child; child = child->NextSibling())
    {
      if (child->Type()==TiXmlNode::ELEMENT)
        OfferNode(&child, listbox, nodes, wxT("<code_completion>")); // recursive call
    }
  }
  else if (section.MakeLower().Matches(wxT("envvars")))     // envvar plugin variables
  {
    listbox->Append(wxT("<") + section + wxT(">"));
    nodes->push_back(*node);
  }
  else if (section.MakeLower().Matches(wxT("gcv")))         // global variables
  {
    listbox->Append(wxT("<") + section + wxT(">"));
    nodes->push_back(*node);
  }
  else if (section.MakeLower().Matches(wxT("help_plugin"))) // help plugin files
  {
    listbox->Append(wxT("<") + section + wxT(">"));
    nodes->push_back(*node);
  }
  else if (section.MakeLower().Matches(wxT("tools")))       // tools setup by the user
  {
    listbox->Append(wxT("<") + section + wxT(">"));
    nodes->push_back(*node);
  }
  else if (section.MakeLower().Matches(wxT("compiler")))    // compiler sets
  {
    TiXmlNode* child = NULL;
    for (child = (*node)->FirstChild(); child; child = child->NextSibling())
    {
      if (child->Type()==TiXmlNode::ELEMENT)
        OfferNode(&child, listbox, nodes, wxT("<compiler>")); // recursive call
    }
  }
  else if (section.MakeLower().Matches(wxT("editor")))      // editor colour sets
  {
    TiXmlNode* child = NULL;
    for (child = (*node)->FirstChild(); child; child = child->NextSibling())
    {
      if (child->Type()==TiXmlNode::ELEMENT)
        OfferNode(&child, listbox, nodes, wxT("<editor>")); // recursive call
    }
  }
  else if (section.MakeLower().Matches(wxT("project_manager"))) // file groups
  {
    TiXmlNode* child = NULL;
    for (child = (*node)->FirstChild(); child; child = child->NextSibling())
    {
      if (child->Type()==TiXmlNode::ELEMENT)
        OfferNode(&child, listbox, nodes, wxT("<project_manager>")); // recursive call
    }
  }

  // ----------------------------------------------------------
  // 1st recursion level: code_completion -> token_replacements
  // ----------------------------------------------------------
  else if (   prefix.Matches(wxT("<code_completion>"))
           && section.MakeLower().Matches(wxT("token_replacements")))// token replacements
  {
    listbox->Append(prefix + wxT("<") + section + wxT(">"));
    nodes->push_back(*node);
  }

  // -----------------------------------------------
  // 1st recursion level: compiler -> sets/user sets
  // -----------------------------------------------
  else if (   prefix.Matches(wxT("<compiler>"))
           && section.MakeLower().Matches(wxT("sets")))     // compiler sets
  {
    TiXmlNode* child = NULL;
    for (child = (*node)->FirstChild(); child; child = child->NextSibling())
    {
      if (child->Type()==TiXmlNode::ELEMENT)
        OfferNode(&child, listbox, nodes, wxT("<compiler><sets>")); // recursive call
    }
  }
  else if (   prefix.Matches(wxT("<compiler>"))
           && section.MakeLower().Matches(wxT("user_sets")))// compiler user sets
  {
    TiXmlNode* child = NULL;
    for (child = (*node)->FirstChild(); child; child = child->NextSibling())
    {
      if (child->Type()==TiXmlNode::ELEMENT)
        OfferNode(&child, listbox, nodes, wxT("<compiler><user_sets>")); // recursive call
    }
  }

  // --------------------------------------------------------
  // 2nd recursion level: compiler -> sets -> individual sets
  // --------------------------------------------------------
  else if (prefix.Matches(wxT("<compiler><sets>")))         // individual compiler sets
  {
    listbox->Append(prefix + wxT("<") + section + wxT(">"));
    nodes->push_back(*node);
  }

  // -------------------------------------------------------------
  // 2nd recursion level: compiler -> user sets -> individual sets
  // -------------------------------------------------------------
  else if (prefix.Matches(wxT("<compiler><user_sets>")))    // individual compiler user sets
  {
    listbox->Append(prefix + wxT("<") + section + wxT(">"));
    nodes->push_back(*node);
  }

  // ------------------------------------------
  // 1st recursion level: editor -> colour sets
  // ------------------------------------------
  else if (   prefix.Matches(wxT("<editor>"))
           && section.MakeLower().Matches(wxT("colour_sets")))// colour sets
  {
    listbox->Append(prefix + wxT("<") + section + wxT(">"));
    nodes->push_back(*node);
  }

  // ---------------------------------------------------
  // 1st recursion level: project_manager -> file_groups
  // ---------------------------------------------------
  else if (   prefix.Matches(wxT("<project_manager>"))
           && section.MakeLower().Matches(wxT("file_groups")))// file groups
  {
    listbox->Append(prefix + wxT("<") + section + wxT(">"));
    nodes->push_back(*node);
  }
}// OfferNode
Пример #13
0
/*! \brief Get the list of input files for the doxygen configuration file.
 *
 * \param    prj            cbProject*        The project.
 * \param     fnDoxyfile     wxFileName    Doxyfile filename object.
 * \return    wxString    The input file list.
 *
 * This function queries the cbProject object for a list of files actually attached to the project.
 * Other  files in the project directory are ignored.
 */
wxString DoxyBlocks::GetInputList(cbProject *prj, wxFileName fnDoxyfile)
{
    // only files with extensions named here will be included in the documentation
    wxArrayString asExtList;
    asExtList.Add(wxT("*.c"));
    asExtList.Add(wxT("*.cc"));
    asExtList.Add(wxT("*.cxx"));
    asExtList.Add(wxT("*.cpp"));
    asExtList.Add(wxT("*.c++"));
    asExtList.Add(wxT("*.java"));
    asExtList.Add(wxT("*.ii"));
    asExtList.Add(wxT("*.ixx"));
    asExtList.Add(wxT("*.ipp"));
    asExtList.Add(wxT("*.i++"));
    asExtList.Add(wxT("*.inl"));
    asExtList.Add(wxT("*.h"));
    asExtList.Add(wxT("*.hh"));
    asExtList.Add(wxT("*.hxx"));
    asExtList.Add(wxT("*.hpp"));
    asExtList.Add(wxT("*.h++"));
    asExtList.Add(wxT("*.idl"));
    asExtList.Add(wxT("*.odl"));
    asExtList.Add(wxT("*.cs"));
    asExtList.Add(wxT("*.php"));
    asExtList.Add(wxT("*.php3"));
    asExtList.Add(wxT("*.inc"));
    asExtList.Add(wxT("*.m"));
    asExtList.Add(wxT("*.mm"));
    asExtList.Add(wxT("*.py"));
    asExtList.Add(wxT("*.f90"));

     // now let's build a string containing all the project files. To be on the safe side,
     // we will quote them all so spaces and other special chars don't break the actual
     // command later...
     wxString sInputList;
     const int cnt = prj->GetFilesCount();
     const int cntExtList = asExtList.GetCount();

     sInputList += wxT("INPUT                  = ");

    for (int i = 0; i < cnt; ++i)
    {
           const ProjectFile* prjFile = prj->GetFile(i);
           if(prjFile)
        {
            const wxString sFileName = prjFile->relativeFilename;
            wxFileName fnFileName = prjFile->file;
            fnFileName.MakeRelativeTo(fnDoxyfile.GetPath());
            const wxString RelName = fnFileName.GetFullPath();

            /* if the file matches one of the abovementioned filters, add it */
            for(int n = 0; n < cntExtList; ++n)
            {
               if(sFileName.Matches(asExtList.Item(n)))
               {
                  sInputList += wxT("\\\n\t\"") + RelName + wxT("\" ");
                  break;
               }
            }
        }
    }
     sInputList += wxT("\n");
     return sInputList;
}
Пример #14
0
wxDirTraverseResult DuplicateFilesFinder::OnFile(const wxString &filename, const wxULongLong *pSize)
{
	assert(m_current_spi);
	const SearchPathInfo *spi = m_current_spi;

	if(IsSymLink(filename)) {
		return UpdateInfo(NULL);
	}

	bool bMatches = false;
	for(list<wxString>::iterator it = m_ExcludeMasks.begin(); it != m_ExcludeMasks.end(); it ++) {
		if(filename.Matches(*it) ) {
			bMatches = true;
			break;
		}
	}

	if(bMatches) { 
		return UpdateInfo(NULL);
	}

	File f;
	multiset_fileinfosize::iterator it2;
	wxULongLong size;
	STARTTIME(__OnFile);
	STARTTIME(__findsize);
	if(pSize == NULL) {
		// slow
		size = wxFileName::GetSize(filename);
	} else {
		size = *pSize;
	}
	STOPTIME(__findsize);
	fileinfosize fis(size);
	
	bool bFitsMinSize = size >= spi->nMinSize;
	bool bFitsMaxSize = size <= spi->nMaxSize || spi->nMaxSize == 0;

	assert(spi->nMaxSize >= spi->nMinSize || spi->nMaxSize == 0);
		
	if(size != wxInvalidSize && 
		(size != 0 || spi->bEmptyFiles) &&
		bFitsMinSize &&
		bFitsMaxSize) {
		// init structure
		STARTTIME(__insert);
		f.SetName(filename);

		it2 = m_sortedbysize.find(fis);

		if(it2 != m_sortedbysize.end()) {
			unconst(*it2).files.push_back(f);
		}
		else {
			fis.files.push_back(f);
			m_sortedbysize.insert(fis);
			m_nSumSizes++;
		}
		STOPTIME(__insert);
	}
	STOPTIME(__OnFile);

	m_nSumFiles++;
	m_nSumBytes += size;

	return UpdateInfo(NULL);
}