Example #1
0
static wxString gdAuiChopText(wxDC& dc, const wxString& text, int max_size)
{
    wxCoord x,y;

    // first check if the text fits with no problems
    dc.GetTextExtent(text, &x, &y);
    if (x <= max_size)
        return text;

    size_t i, len = text.Length();
    size_t last_good_length = 0;
    for (i = 0; i < len; ++i)
    {
        wxString s = text.Left(i);
        s += wxT("...");

        dc.GetTextExtent(s, &x, &y);
        if (x > max_size)
            break;

        last_good_length = i;
    }

    wxString ret = text.Left(last_good_length);
    ret += wxT("...");
    return ret;
}
wxArrayString nsEnvVars::GetEnvvarsBySetPath(const wxString& set_path)
{
#if defined(TRACE_ENVVARS)
  Manager::Get()->GetLogManager()->DebugLog(F(_T("GetEnvvarsBySetPath")));
#endif

  wxArrayString envvars;
  EV_DBGLOG(_T("EnvVars: Searching for envvars in path '%s'."), set_path.wx_str());

  ConfigManager *cfg = Manager::Get()->GetConfigManager(_T("envvars"));
  if (!cfg || set_path.IsEmpty())
    return envvars;

  wxArrayString envvars_keys = cfg->EnumerateKeys(set_path);
  unsigned int  num_envvars  = envvars_keys.GetCount();
  for (unsigned int i=0; i<num_envvars; ++i)
  {
    wxString envvar = cfg->Read(set_path+_T("/")+envvars_keys[i]);
    if (!envvar.IsEmpty())
      envvars.Add(envvar);
    else
      EV_DBGLOG(_T("EnvVars: Warning: empty envvar detected and skipped."));
  }
  EV_DBGLOG(_T("EnvVars: Read %lu/%u envvars in path '%s'."),
    static_cast<unsigned long>(envvars.GetCount()), num_envvars, set_path.wx_str());

  return envvars;
}// GetEnvvarsBySetPath
HighlightLanguage EditorColourSet::AddHighlightLanguage(int lexer, const wxString& name)
{
    if (   lexer <= wxSCI_LEX_NULL
        || lexer >  wxSCI_LEX_LAST // this is a C::B extension to wxscintilla.h
        || name.IsEmpty() )
    {
        return HL_NONE;
    }

    // fix name to be XML compliant
    wxString newID;
    size_t pos = 0;
    while (pos < name.Length())
    {
        wxChar ch = name[pos];
        if      (wxIsalnum(ch) || ch == _T('_'))
            newID.Append(ch); // valid character
        else if (wxIsspace(ch))
            newID.Append(_T('_')); // convert spaces to underscores
        ++pos;
    }
    // make sure it's not starting with a number or underscore.
    // if it is, prepend an 'A'
    if (wxIsdigit(newID.GetChar(0)) || newID.GetChar(0) == _T('_'))
        newID.Prepend(_T('A'));

    if (GetHighlightLanguage(newID) != HL_NONE)
        return HL_NONE;

    m_Sets[newID].m_Langs = name;
    m_Sets[newID].m_Lexers = lexer;
    return newID;
}
Example #4
0
extern bool
wxGetDirectoryTimes(const wxString& dirname,
                    FILETIME *ftAccess, FILETIME *ftCreate, FILETIME *ftMod)
{
#ifdef __WXWINCE__
    // FindFirst() is going to fail
    wxASSERT_MSG( !dirname.empty(),
                  wxT("incorrect directory name format in wxGetDirectoryTimes") );
#else
    // FindFirst() is going to fail
    wxASSERT_MSG( !dirname.empty() && dirname.Last() != wxT('\\'),
                  wxT("incorrect directory name format in wxGetDirectoryTimes") );
#endif

    FIND_STRUCT fs;
    FIND_DATA fd = FindFirst(dirname, &fs);
    if ( !IsFindDataOk(fd) )
    {
        return false;
    }

    *ftAccess = fs.ftLastAccessTime;
    *ftCreate = fs.ftCreationTime;
    *ftMod = fs.ftLastWriteTime;

    FindClose(fd);

    return true;
}
Example #5
0
wxString
wxPdfUtility::GetUniqueId(const wxString& prefix)
{
  wxString uid = (prefix.Length() <= 114) ? prefix : prefix.Left(114);

  wxDateTime ts;
  ts.SetToCurrent();

  int q;
  int z;
  if (!ms_seeded)
  {
    ms_seeded = true;
    ms_s1 = ts.GetSecond() ^ (~ts.GetMillisecond());
    if (ms_s1 == 0) ms_s1 = 1;
    ms_s2 = wxGetProcessId();
  }
  MODMULT(53668, 40014, 12211, 2147483563L, ms_s1);
  MODMULT(52774, 40692,  3791, 2147483399L, ms_s2);

  z = ms_s1 - ms_s2;
  if (z < 1)
  {
    z += 2147483562;
  }

  uid += wxString::Format(wxT("%08x%05x"), ts.GetSecond(), ts.GetMillisecond());
  uid += Double2String(z * 4.656613e-9,8);

  return uid;
}
Example #6
0
// On Windows, DrawText doesn't work with multiline text. This function also
// should take into account line wrapping.
static int
draw_ml(wxDC &dc, const wxString &text, int x, int y, int width) {
    int height = 0;
    int last_nl_pos = 0;
    int nl_pos = text.find('\n');
    wxString line;
    while (true) {
        line = text.substr(last_nl_pos, nl_pos);
        last_nl_pos = nl_pos + 1;
        
        if (line.empty()) {
            int lw, lh;
            dc.GetTextExtent(wxT("X"), &lw, &lh);
            height += lh;
        } else {
            dc.DrawText(line, x, y + height);
            
            int lw, lh;
            dc.GetTextExtent(line, &lw, &lh);
            height += lh;
        }
        
        if (nl_pos == -1)
            break;
        nl_pos = text.find('\n', last_nl_pos);
    }

    return height;
}
void CRCppEmitter::AddComment (wxString str)
{
    wxArrayString COMMENT_BREAK_CHARS;
    COMMENT_BREAK_CHARS.Add (_T(" "));
    COMMENT_BREAK_CHARS.Add (_T(","));
    COMMENT_BREAK_CHARS.Add (_T("."));
    COMMENT_BREAK_CHARS.Add (_T(":"));
    COMMENT_BREAK_CHARS.Add (_T("!"));
    COMMENT_BREAK_CHARS.Add (_T("?"));

    wxString pre = m_tab + _T("// ");
    const unsigned int MIN_CONTENT_LEN = 20;
    str.Prepend (pre);

    unsigned int idx;
    do {

        m_newFile.AddLine (this->BreakString (str, COMMENT_BREAK_CHARS, idx,
                                              pre.Length () + MIN_CONTENT_LEN));
        if (idx != 0) {

            str = str.Mid (idx);
            str.Prepend (pre);
        }

    } while (idx != 0);
    // Again, flush current file status (but not finished yet):
    m_newFile.Write ();
}
Example #8
0
wxTreeItemId CLocalTreeView::MakeSubdirs(wxTreeItemId parent, wxString dirname, wxString subDir)
{
	const wxString& separator = wxFileName::GetPathSeparator();

	while (!subDir.empty()) {
		int pos = subDir.Find(separator);
		wxString segment;
		if (pos == -1) {
			segment = subDir;
			subDir = _T("");
		}
		else {
			segment = subDir.Left(pos);
			subDir = subDir.Mid(pos + 1);
		}

		DisplayDir(parent, dirname, segment);

		wxTreeItemId item = GetSubdir(parent, segment);
		if (!item)
			return wxTreeItemId();

		parent = item;
		dirname += segment + separator;
	}

	// Not needed, stays unexpanded by default
	// DisplayDir(parent, dirname);
	return parent;
}
Example #9
0
bool wxRedirectableFd::Reopen(const wxString& name, int flags)
{
    wxASSERT(m_dup == -1);
    bool result = false;

    // save a duplicate so that the descriptor can be closed now and
    // restored later
    m_dup = dup(m_fd);

    if (m_dup != -1)
    {
        int tmp = open(name.mb_str(), flags);

        if (tmp != -1)
        {
            close(m_fd);

            if (flags & O_CREAT)
                m_name = name;

            result = dup2(tmp, m_fd) == m_fd;
            close(tmp);
        }
    }

    if (!result)
    {
        wxLogSysError(_("error opening '%s'"), name.c_str());
    }

    return result;
}
Example #10
0
bool KeyExists(WXHKEY hRootKey,
               const wxString& szKey,
               wxRegKey::WOW64ViewMode viewMode)
{
    // don't close this key itself for the case of empty szKey!
    if ( szKey.empty() )
        return true;

    HKEY hkeyDummy;
    if ( ::RegOpenKeyEx
         (
            (HKEY)hRootKey,
            szKey.t_str(),
            RESERVED,
            // we might not have enough rights for rw access
            GetMSWAccessFlags(wxRegKey::Read, viewMode),
            &hkeyDummy
         ) == ERROR_SUCCESS )
    {
        ::RegCloseKey(hkeyDummy);

        return true;
    }

    return false;
}
Example #11
0
bool FFmpegImportFileHandle::Init()
{
   //FFmpegLibsInst->LoadLibs(NULL,false); //Loaded at startup or from Prefs now

   if (!FFmpegLibsInst->ValidLibsLoaded()) return false;

   FFmpegLibsInst->av_log_set_callback(av_log_wx_callback);

   int err = FFmpegLibsInst->av_open_input_file(&mFormatContext,OSFILENAME(mName),NULL,0, NULL);
   if (err < 0)
   {
      wxLogMessage(wxT("FFmpeg : av_open_input_file() failed for file %s"),mName.c_str());
      return false;
   }

   err = FFmpegLibsInst->av_find_stream_info(mFormatContext);
   if (err < 0)
   {
      wxLogMessage(wxT("FFmpeg : av_find_stream_info() failed for file %s"),mName.c_str());
      return false;
   }

   InitCodecs();
   return true;
}
Example #12
0
bool wxRegKey::DoExportValue(wxOutputStream& ostr, const wxString& name) const
{
    // first examine the value type: if it's unsupported, simply skip it
    // instead of aborting the entire export process because we failed to
    // export a single value
    wxString value = FormatValue(name);
    if ( value.empty() )
    {
        wxLogWarning(_("Ignoring value \"%s\" of the key \"%s\"."),
                     name.c_str(), GetName().c_str());
        return true;
    }

    // we do have the text representation of the value, now write everything
    // out

    // special case: unnamed/default value is represented as just "@"
    if ( name.empty() )
    {
        if ( !WriteAsciiChar(ostr, '@') )
            return false;
    }
    else // normal, named, value
    {
        if ( !WriteAsciiChar(ostr, '"') ||
                !WriteAsciiString(ostr, name) ||
                    !WriteAsciiChar(ostr, '"') )
            return false;
    }

    if ( !WriteAsciiChar(ostr, '=') )
        return false;

    return WriteAsciiString(ostr, value) && WriteAsciiEOL(ostr);
}
Example #13
0
int ALMRunConfig::AddDir(const wxString& path,const wxString& inc,const wxString& exc,const int sub,const UINT id)
{
	if (!conf)
		return -1;
	int i = 0;
	wxString entry;
	if (id == -1)
	{
		do
		{
			entry.Printf("/dirs/%d",i++);
			if (i == 1000)
				return -1;
		
		} while (conf->HasGroup(entry));
	}
	else
	{
		i = id;
		entry.Printf("/dirs/%d",i);
	}
	wxString oldPath = conf->GetPath();
	conf->SetPath(entry);
	conf->Write("path",path);
	conf->Write("sub",sub);
	if (!inc.empty())
		conf->Write("include",inc);
	if (!exc.empty())
		conf->Write("exclude",exc);
	cfg_changed = true;
	return i;
}
Example #14
0
bool ALMRunConfig::ModifyCmd(const int id,const wxString& cmd,const wxString& name,const wxString& key,const wxString& desc)
{
	if (!conf || id < 0)
		return false;
	if (cmd.empty() && !conf->DeleteGroup(wxString::Format("/cmds/%d",id)))
		return false;

	wxString oldPath = conf->GetPath();
	conf->SetPath(wxString::Format("/cmds/%d",id));
	conf->Write("cmd",cmd);
	if (!name.empty())
		conf->Write("name",name);
	else
		conf->DeleteEntry("name");

	if (!key.empty())
		conf->Write("key",key);
	else
		conf->DeleteEntry("key");

	if (!desc.empty())
		conf->Write("desc",desc);
	else
		conf->DeleteEntry("desc");

	conf->SetPath(oldPath);
	return (cfg_changed = true);
}
Example #15
0
/*---------------------------------------------------------------------------*/
void wxSQLBook::Describe(const wxString& name)
{
    wxSQLitePlusFrame* frame;
    wxString base, tempname;

    if (!name.IsEmpty())
    {
        tempname = name.AfterLast(('.'));
        base = name.BeforeLast(('.'));

        frame = (wxSQLitePlusFrame*)wxGetApp().GetTopWindow();
        if (frame->ExistDbObject(otTableAndView, tempname, base))
        {
            wxDescribeDlg describeDlg(wxGetApp().GetTopWindow());
            describeDlg.Describe(m_db, tempname, base);
            describeDlg.ShowModal();
        }
        else
        {
            wxString msg = wxString::Format(_("Table or view \"%s\" not found."),
                                            name.c_str());
            wxMessageBox(msg, _("Error"));
        }
    }
}
Example #16
0
bool DbgGdb::FilterMessage( const wxString &msg )
{
    wxString tmpmsg ( msg );
    StripString( tmpmsg );
    tmpmsg.Trim().Trim( false );

    if ( tmpmsg.Contains( wxT( "Variable object not found" ) ) || msg.Contains( wxT( "Variable object not found" ) ) ) {
        return true;
    }

    if ( tmpmsg.Contains( wxT( "mi_cmd_var_create: unable to create variable object" ) )||msg.Contains( wxT( "mi_cmd_var_create: unable to create variable object" ) ) ) {
        return true;
    }

    if ( tmpmsg.Contains( wxT( "Variable object not found" ) )|| msg.Contains( wxT( "Variable object not found" ) ) ) {
        return true;
    }

    if ( tmpmsg.Contains( wxT( "No symbol \"this\" in current context" ) )||msg.Contains( wxT( "No symbol \"this\" in current context" ) ) ) {
        return true;
    }

    if ( tmpmsg.Contains( wxT( "*running,thread-id" ) ) ) {
        return true;
    }

    if ( tmpmsg.StartsWith( wxT( ">" ) )||msg.StartsWith( wxT( ">" ) ) ) {
        // shell line
        return true;
    }
    return false;
}
Example #17
0
void MapDatabase::MapInfoString(const size_t index, StringArray& pieces)
{
	wxASSERT(sMapData.size() > index);

    static const wxString stPlayers = _("players");
    static const wxString stPoints = _("points");

	const MapData &data = sMapData[index];

	//map name
	pieces.push_back(data.name.wx_str());

	//number of players
	if(data.min_players == data.max_players)
	{
		pieces.push_back(wxString::Format(swHTMLListIntString.c_str(), 
            data.min_players, stPlayers.c_str()));
	}
	else
	{
		pieces.push_back(wxString::Format(swHTMLListIntIntString.c_str(), 
            data.min_players, data.max_players, stPlayers.c_str()));
	}

	//number of points
	pieces.push_back(wxString::Format(swHTMLListIntString.c_str(), 
        data.points, stPoints.c_str()));
}
Example #18
0
bool COptions::GetServer(wxString path, CServer& server)
{
	if (path.empty())
		return false;

	if (!m_pXmlFile)
		return false;
	auto element = m_pXmlFile->GetElement();

	while (!path.empty()) {
		wxString sub;
		int pos = path.Find('/');
		if (pos != -1) {
			sub = path.Left(pos);
			path = path.Mid(pos + 1);
		}
		else {
			sub = path;
			path = _T("");
		}
		wxScopedCharBuffer utf8 = sub.utf8_str();
		if (!utf8)
			return false;
		element = element.child(utf8);
		if (!element)
			return false;
	}

	bool res = ::GetServer(element, server);

	return res;
}
Example #19
0
void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
{
    // For compatibility with other ports (notably wxGTK) and because it's
    // genuinely useful, we allow passing multiline strings to DrawText().
    // However there is no native OSX function to draw them directly so we
    // instead reuse the generic DrawLabel() method to render them. Of course,
    // DrawLabel() itself will call back to us but with single line strings
    // only so there won't be any infinite recursion here.
    if ( str.find('\n') != wxString::npos )
    {
        GetOwner()->DrawLabel(str, wxRect(x, y, 0, 0));
        return;
    }

    wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawText - invalid DC") );

    if ( str.empty() )
        return;

    if ( !m_logicalFunctionSupported )
        return;

    if ( m_backgroundMode == wxTRANSPARENT )
        m_graphicContext->DrawText( str, x ,y);
    else
        m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush(m_textBackgroundColour) );
}
Example #20
0
wxVideoMode wxDisplayMSW::GetCurrentMode() const
{
    wxVideoMode mode;

    // The first parameter of EnumDisplaySettings() must be NULL under Win95
    // according to MSDN.  The version of GetName() we implement for Win95
    // returns an empty string.
    const wxString name = GetName();
    const wxChar * const deviceName = name.empty()
                                          ? (const wxChar*)NULL
                                          : (const wxChar*)name.c_str();

    DEVMODE dm;
    dm.dmSize = sizeof(dm);
    dm.dmDriverExtra = 0;

    if ( !::EnumDisplaySettings(deviceName, ENUM_CURRENT_SETTINGS, &dm) )
    {
        wxLogLastError(wxT("EnumDisplaySettings(ENUM_CURRENT_SETTINGS)"));
    }
    else
    {
        mode = ConvertToVideoMode(dm);
    }

    return mode;
}
Example #21
0
void
clPatch::Patch(const wxFileName& patchFile, const wxString& workingDirectory, const wxString& args) 
{
    // Sanity
    if(!m_patch.FileExists()) {
        throw clException("Could not locate patch executable");
    }

    if(!patchFile.FileExists()) {
        throw clException("Patch failed. File: '" + patchFile.GetFullPath() + "' does not exist");
    }

    // Prepare the command
    wxString command;
    command << m_patch.GetFullPath();

    ::WrapWithQuotes(command);

    if(!args.IsEmpty()) {
        command << " " << args;
    }

    // Change directory to the working directory requested by the user
    DirSaver ds;
    wxSetWorkingDirectory(workingDirectory.IsEmpty() ? ::wxGetCwd() : workingDirectory);

    wxString patch = patchFile.GetFullPath();

    command << " " << ::WrapWithQuotes(patch);
    ::WrapInShell(command);

    ProcUtils::SafeExecuteCommand(command);
}
Example #22
0
wxArrayVideoModes wxDisplayMSW::GetModes(const wxVideoMode& modeMatch) const
{
    wxArrayVideoModes modes;

    // The first parameter of EnumDisplaySettings() must be NULL under Win95
    // according to MSDN.  The version of GetName() we implement for Win95
    // returns an empty string.
    const wxString name = GetName();
    const wxChar * const deviceName = name.empty()
                                            ? (const wxChar*)NULL
                                            : (const wxChar*)name.c_str();

    DEVMODE dm;
    dm.dmSize = sizeof(dm);
    dm.dmDriverExtra = 0;

    for ( int iModeNum = 0;
          ::EnumDisplaySettings(deviceName, iModeNum, &dm);
          iModeNum++ )
    {
        const wxVideoMode mode = ConvertToVideoMode(dm);
        if ( mode.Matches(modeMatch) )
        {
            modes.Add(mode);
        }
    }

    return modes;
}
wxString readconfigdata(wxString &configstr)
{
    configstr=configstr.AfterFirst(':');
    wxString data=configstr.BeforeFirst('\n');
    configstr=configstr.AfterFirst('\n');
    return data;
}
Example #24
0
void EDA_MSG_PANEL::AppendMessage( const wxString& aUpperText,
                                   const wxString& aLowerText,
                                   EDA_COLOR_T aColor, int aPad )
{
    wxString    text;
    wxSize      drawSize = GetClientSize();

    text = ( aUpperText.Len() > aLowerText.Len() ) ? aUpperText : aLowerText;
    text.Append( ' ', aPad );

    MSG_PANEL_ITEM item;

    /* Don't put the first message a window client position 0.  Offset by
     * one 'W' character width. */
    if( m_last_x == 0 )
        m_last_x = m_fontSize.x;

    item.m_X = m_last_x;

    item.m_UpperY = ( drawSize.y / 2 ) - m_fontSize.y;
    item.m_LowerY = drawSize.y - m_fontSize.y;

    item.m_UpperText = aUpperText;
    item.m_LowerText = aLowerText;
    item.m_Color = aColor;
    m_Items.push_back( item );
    m_last_x += computeTextSize( text ).x;

    // Add an extra space between texts for a better look:
    m_last_x += m_fontSize.x;

    Refresh();
}
//---------------------------------------------------------
bool CActive_Attributes_Control::_Get_DataSource(wxString &Source)
{
	if( Source.Find("PGSQL:"  ) == 0
	||	Source.Find("ftp://"  ) == 0
	||	Source.Find("http://" ) == 0
	||	Source.Find("https://") == 0
	||	Source.Find("file://" ) == 0
	||  wxFileExists(Source)  )
	{
		return( true );
	}

	if( g_pActive->Get_Active_Data_Item() && g_pActive->Get_Active_Data_Item()->Get_Object()->Get_File_Name(false) )
	{
		wxFileName	fn(Source), dir(g_pActive->Get_Active_Data_Item()->Get_Object()->Get_File_Name(false));

		if( fn.MakeAbsolute(dir.GetPath()) && fn.Exists() )
		{
			Source	= fn.GetFullPath();

			return( true );
		}
	}

	return( false );
}
Example #26
0
wxString t4p::ApacheClass::GetUri(const wxString& fileSystemPath, const wxString& uriPath) const {
    // normalize the given path; also convert to lower case so that we make case-insesitive
    // comparisons (to handle windows paths)
    wxFileName fileToGet(fileSystemPath);
    wxString dir = fileToGet.GetFullPath();
    dir.LowerCase();
    wxString url;
    for (std::map<wxString, wxString>::const_iterator it = VirtualHostMappings.begin(); it != VirtualHostMappings.end(); ++it) {
        wxString hostRoot = it->first;
        hostRoot.LowerCase();
        if (0 == dir.Find(hostRoot)) {
            // file is inside this virtual host. remove the root and append to host
            wxString baseUrl = it->second;

            // look for a port (but careful of the protocol http://
            bool urlHasPort = baseUrl.find_last_of(wxT(":")) > 4;
            if (Port > 0 && Port != 80 && !urlHasPort) {
                // host already has a slash; only append port if virtual host does not have it
                baseUrl.RemoveLast();
                baseUrl += wxString::Format(wxT(":%d/"), Port);
            }
            if (!uriPath.IsEmpty() && uriPath[0] == wxT('/')) {
                url = baseUrl + uriPath.Mid(1);
            } else {
                url = baseUrl + uriPath;
            }
            break;
        }
    }
    return url;
}
Example #27
0
WXDLLIMPEXP_CORE wxCharBuffer
wxConvertToGTK(const wxString& s, wxFontEncoding enc)
{
    wxWCharBuffer wbuf;
    if ( enc == wxFONTENCODING_SYSTEM || enc == wxFONTENCODING_DEFAULT )
    {
        wbuf = wxConvUI->cMB2WC(s.c_str());
    }
    else // another encoding, use generic conversion class
    {
        wbuf = wxCSConv(enc).cMB2WC(s.c_str());
    }

    if ( !wbuf && !s.empty() )
    {
        // conversion failed, but we still want to show something to the user
        // even if it's going to be wrong it is better than nothing
        //
        // we choose ISO8859-1 here arbitrarily, it's just the most common
        // encoding probably and, also importantly here, conversion from it
        // never fails as it's done internally by wxCSConv
        wbuf = wxCSConv(wxFONTENCODING_ISO8859_1).cMB2WC(s.c_str());
    }

    return wxConvUTF8.cWC2MB(wbuf);
}
Example #28
0
synonyms wxThes::Lookup(const wxString &Text)
{
    synonyms syn;
    mentry * pmean;
    int count = m_pMT->Lookup(Text.char_str(), Text.length(),&pmean);
    // don't change value of pmean
    // or count since needed for CleanUpAfterLookup routine
    mentry* pm = pmean;
    if (count)
    {
        //fprintf(stdout,"%s has %d meanings\n",buf,count);
        std::vector< wxString > s;
        for (int  i=0; i < count; i++)
        {
            //fprintf(stdout,"   meaning %d: %s\n",i,pm->defn);
            for (int j=0; j < pm->count; j++)
            {
                //fprintf(stdout,"       %s\n",pm->psyns[j]);
                s.push_back(wxString(pm->psyns[j], wxConvUTF8));
            }
            //fprintf(stdout,"\n");
            syn[wxString( pm->defn, wxConvUTF8 )] = s;

            pm++;
        }
        //fprintf(stdout,"\n\n");
        // now clean up all allocated memory
        m_pMT->CleanUpAfterLookup(&pmean,count);
    }
//    else
//    {
//        fprintf(stdout,"\"%s\" is not in thesaurus!\n",buf);
//    }
    return syn;
}
/**
 * Indicates if the given checksum is valid.
 *
 * @param  checksum  The checksum to check.
 */
bool MD5File::IsValidChecksum(const wxString& checksum)
{
  const wxString validCaracters = wxT("0123456789abcdefABCDEF");
  wxChar c;
  size_t i, j;
  size_t l = checksum.size();
  size_t s = validCaracters.size();
  bool   OK, found;

  i = 0;
  OK = (checksum.size() == 32);
  while (OK && i < l)
  {
    c = checksum[i];
    j = 0;
    found = false;
    while (!found && j < s)
    {
      if (c == validCaracters[j])
        found = true;
      j++;
    }
    
    if (!found)
      OK = false;
    i++;
  }
  
  return OK;
}
void EditorTweaks::OnMakeIndentsConsistent(wxCommandEvent& /*event*/)
{
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    if (!ed)
        return;
    cbStyledTextCtrl* stc = ed->GetControl();

    const bool useTab     = stc->GetUseTabs();
    const int  tabWidth   = stc->GetTabWidth();
    const int  maxLines   = stc->GetLineCount();
    bool  changed         = false;
    for (int curLine = 0; curLine < maxLines; ++curLine)
    {
        const wxString curInd = ed->GetLineIndentString(curLine);
        wxString indent = curInd;
        if (useTab)
            indent.Replace(wxString(wxT(' '), tabWidth), wxT("\t"));
        else
            indent.Replace(wxT("\t"), wxString(wxT(' '), tabWidth));
        if (indent != curInd)
        {
            if (!changed) // all changes in a single undo step
            {
                stc->BeginUndoAction();
                changed = true;
            }
            stc->SetTargetStart(stc->PositionFromLine(curLine));
            stc->SetTargetEnd(stc->PositionFromLine(curLine) + curInd.Length());
            stc->ReplaceTarget(indent);
        }
    }
    if (changed)
        stc->EndUndoAction();
}