void
hoxChesscapePlayer::_HandleCmd_Logout( const wxString& cmdStr )
{
    const wxString sPlayerId = cmdStr.BeforeFirst( 0x10 );

    m_site->OnPlayerLoggedOut( sPlayerId );
}
bool 
hoxChesscapePlayer::_ParseIncomingCommand( const wxMemoryBuffer& data,
										   wxString&       command,
										   wxString&       paramsStr ) const
{
    /* TODO: Force to convert the buffer to a string. */

    const wxString contentStr =
        wxString::FromUTF8( (const char*) data.GetData(), data.GetDataLen() );
    if ( data.GetDataLen() > 0 && contentStr.empty() ) // failed?
    {
        wxLogDebug("%s: *WARN* Fail to convert [%d] data to string.", 
            __FUNCTION__, data.GetDataLen());
        return false;
    }

	/* CHECK: The first character must be 0x10 */
	if ( contentStr.empty() || contentStr[0] != 0x10 )
	{
		wxLogDebug("%s: *WARN* Invalid command = [%s].", __FUNCTION__, contentStr.c_str());
		return false;
	}

	/* Chop off the 1st character */
	const wxString actualContent = contentStr.Mid(1);

	/* Extract the command and its parameters-string */
	command = actualContent.BeforeFirst( '=' );
	paramsStr = actualContent.AfterFirst('=');

	return true;  // success
}
Example #3
0
wxRegKey::StdKey wxRegKey::ExtractKeyName(wxString& strKey)
{
  wxString strRoot = strKey.BeforeFirst(REG_SEPARATOR);

  size_t ui;
  for ( ui = 0; ui < nStdKeys; ui++ ) {
    if ( strRoot.CmpNoCase(aStdKeys[ui].szName) == 0 ||
         strRoot.CmpNoCase(aStdKeys[ui].szShortName) == 0 ) {
      break;
    }
  }

  if ( ui == nStdKeys ) {
    wxFAIL_MSG(wxT("invalid key prefix in wxRegKey::ExtractKeyName."));

    ui = HKCR;
  }
  else {
    strKey = strKey.After(REG_SEPARATOR);
    if ( !strKey.empty() && strKey.Last() == REG_SEPARATOR )
      strKey.Truncate(strKey.Len() - 1);
  }

  return (StdKey)ui;
}
int mxVarWindow::GetVarType (int &line, wxString var_name) {

	if (var_name.Contains("[")) var_name=var_name.BeforeFirst('[');
	var_name.MakeUpper();
	
	wxTreeItemIdValue cookie;
	wxTreeItemId it = tree->GetFirstChild(tree->GetRootItem(),cookie);
	while (it.IsOk()) {
		range *r=(range*)tree->GetItemData(it);
		if (/*r && */line>=r->from && line<=r->to) {
			line = r->from;
			break;
		}
		it = tree->GetNextSibling(it);
	}
	if (!it.IsOk()) return -1;
	it = tree->GetFirstChild(it,cookie);
	while (it.IsOk()) {
		wxString it_text = tree->GetItemText(it);
		if (it_text.Contains("[")) {
			if (it_text.BeforeFirst('[').Upper()==var_name) 
				return GetVarType(it);
		} else {
			if (it_text.Upper()==var_name) 
				return GetVarType(it);
		}
		it = tree->GetNextSibling(it);
	}
	return -1;
	
}
Example #5
0
bool User::ExecuteSayCommand( const wxString& cmd ) const
{
  if ( cmd.BeforeFirst(' ').Lower() == _T("/me") ) {
    GetServer().DoActionPrivate( m_nick, cmd.AfterFirst(' ') );
    return true;
  }  else return false;
}
Example #6
0
void wxSheetCellFloatRendererRefData::SetParameters(const wxString& params)
{
    if ( params.IsEmpty() )
    {
        // reset to defaults
        SetWidth(-1);
        SetPrecision(-1);
    }
    else
    {
        wxString tmp( params.BeforeFirst(_T(',')) );
        if ( !tmp.IsEmpty() )
        {
            long width;
            if ( tmp.ToLong(&width) )
                SetWidth((int)width);
            else
                wxLogDebug(_T("Invalid wxSheetCellFloatRenderer width parameter string '%s ignored"), params.c_str());
        }
        tmp = params.AfterFirst(_T(','));
        if ( !tmp.IsEmpty() )
        {
            long precision;
            if ( tmp.ToLong(&precision) )
                SetPrecision((int)precision);
            else
                wxLogDebug(_T("Invalid wxSheetCellFloatRenderer precision parameter string '%s ignored"), params.c_str());
        }
    }
}
Example #7
0
wxString conv_g_func(wxString input)//input =  Function func_name parameters: int var1,char * var2,int var3 returns char*
{
	wxString output,fname,rtype,params;
	input = input.AfterFirst(' '); //input contains "func_name parameters: int var1,char * var2,int var3 returns char*"
	fname = input.BeforeFirst(' ');
	input = input.AfterFirst(' ');//input contains "parameters: int var1,char * var2,int var3 returns char*"
	input = input.AfterFirst(' ');//input contains "int var1,char * var2,int var3 returns char*"
	input.Replace("returns","%returns");//input contains "int var1,char * var2,int var3 %returns char*"
	params = input.BeforeFirst('%');
	if(params.Contains(wxT("none"))) params.Empty();
	input = input.AfterFirst('%');
	rtype = input.AfterFirst(' ');
	output.Empty();
	output<< rtype <<" " << fname << "(" << params <<");"; //output =  char* func_name(int var1,char * var2,int var3);
	return output;
}
void
hoxChesscapePlayer::_HandleTableCmd( const wxString& cmdStr )
{
	const wxString tCmd = cmdStr.BeforeFirst(0x10);
	wxString subCmdStr = cmdStr.AfterFirst(0x10);
    if (!subCmdStr.empty() && subCmdStr[subCmdStr.size()-1] == 0x10)
        subCmdStr = subCmdStr.substr(0, subCmdStr.size()-1);
	wxLogDebug("%s: Processing tCmd = [%s]...", __FUNCTION__, tCmd.c_str());
	
    if      ( tCmd == "Settings" ) _HandleTableCmd_Settings( subCmdStr );
    else if ( tCmd == "Invite" )   _HandleTableCmd_Invite( subCmdStr );
    else
    {
	    /* NOTE: The Chesscape server only support 1 table for now. */

        hoxTable_SPtr pTable = _GetMyTable();
	    if ( ! pTable )
	    {
		    wxLogDebug("%s: *WARN* This player [%s] not yet joined any table.", 
			    __FUNCTION__, this->GetId().c_str());
		    return;
	    }

	    if      ( tCmd == "MvPts" )     _HandleTableCmd_PastMoves( pTable, subCmdStr );
	    else if ( tCmd == "Move" )      _HandleTableCmd_Move( pTable, subCmdStr );
	    else if ( tCmd == "GameOver" )  _HandleTableCmd_GameOver( pTable, subCmdStr );
	    else if ( tCmd == "OfferDraw" ) _HandleTableCmd_OfferDraw( pTable );
        else if ( tCmd == "Clients" )   _HandleTableCmd_Clients( pTable, subCmdStr );
        else if ( tCmd == "Unjoin" )    _HandleTableCmd_Unjoin( pTable, subCmdStr );
	    else
	    {
		    wxLogDebug("%s: *** Ignore this Table-command = [%s].", __FUNCTION__, tCmd.c_str());
	    }
    }
}
void
hoxChesscapePlayer::_HandleTableCmd_Invite( const wxString& cmdStr )
{
    wxLogDebug("%s: ENTER. cmdStr = [%s].", __FUNCTION__, cmdStr.c_str());

	const wxString sInvitorId = cmdStr.BeforeFirst(0x10);
	const wxString sTableId = cmdStr.AfterFirst(0x10);

    /* Look up the Invitor's score. */
    int nInvitorScore = m_site->GetScoreOfOnlinePlayer( sInvitorId );
    if ( nInvitorScore == hoxSCORE_UNKNOWN )
    {
        wxLogDebug("%s: *WARN* Player [%s] not found.", __FUNCTION__, sInvitorId.c_str());
        nInvitorScore = 0;
    }

    const wxString sMessage =
        wxString::Format("*INVITE from [%s (%d)] to Table [%s]",
        sInvitorId.c_str(), nInvitorScore,
        sTableId.c_str());

    hoxTable_SPtr pTable = _GetMyTable();
    if ( pTable )
    {
        pTable->PostBoardMessage( sMessage );
    }
    else
    {
        ::wxMessageBox( sMessage, _("Invitation from Player"),
                        wxOK | wxICON_INFORMATION );
    }
}
Example #10
0
wxString wxFileDialogBase::AppendExtension(const wxString &filePath,
                                           const wxString &extensionList)
{
    // strip off path, to avoid problems with "path.bar/foo"
    wxString fileName = filePath.AfterLast(wxFILE_SEP_PATH);

    // if fileName is of form "foo.bar" it's ok, return it
    int idx_dot = fileName.Find(wxT('.'), true);
    if ((idx_dot != wxNOT_FOUND) && (idx_dot < (int)fileName.length() - 1))
        return filePath;

    // get the first extension from extensionList, or all of it
    wxString ext = extensionList.BeforeFirst(wxT(';'));

    // if ext == "foo" or "foo." there's no extension
    int idx_ext_dot = ext.Find(wxT('.'), true);
    if ((idx_ext_dot == wxNOT_FOUND) || (idx_ext_dot == (int)ext.length() - 1))
        return filePath;
    else
        ext = ext.AfterLast(wxT('.'));

    // if ext == "*" or "bar*" or "b?r" or " " then its not valid
    if ((ext.Find(wxT('*')) != wxNOT_FOUND) ||
        (ext.Find(wxT('?')) != wxNOT_FOUND) ||
        (ext.Strip(wxString::both).empty()))
        return filePath;

    // if fileName doesn't have a '.' then add one
    if (filePath.Last() != wxT('.'))
        ext = wxT(".") + ext;

    return filePath + ext;
}
Example #11
0
void ClassListDialog::UpdateClassInfo(const wxString &itemName)
{
    wxString classname = itemName.BeforeFirst(' ');
    wxCheckBox *cb = static_cast<wxCheckBox*>(FindWindow(ID_SHOW_PROPERTIES_RECURSIVELY));

    m_pTextCtrl->SetValue(
        DumpClassInfo(wxClassInfo::FindClass(classname), cb->IsChecked()));
}
bool ArchiveTestSuite::IsInPath(const wxString& cmd)
{
    wxString c = cmd.BeforeFirst(_T(' '));
#ifdef __WXMSW__
    c += _T(".exe");
#endif
    return !m_path.FindValidPath(c).empty();
}
Example #13
0
void StringTestCase::BeforeAndAfter()
{
    // Construct a string with 2 equal signs in it by concatenating its three
    // parts: before the first "=", in between the two "="s and after the last
    // one. This allows to avoid duplicating the string contents (which has to
    // be different for Unicode and ANSI builds) in the tests below.
#if wxUSE_UNICODE
    #define FIRST_PART L"letter"
    #define MIDDLE_PART L"\xe9;\xe7a"
    #define LAST_PART L"l\xe0"
#else // !wxUSE_UNICODE
    #define FIRST_PART "letter"
    #define MIDDLE_PART "e;ca"
    #define LAST_PART "la"
#endif // wxUSE_UNICODE/!wxUSE_UNICODE

    const wxString s(FIRST_PART wxT("=") MIDDLE_PART wxT("=") LAST_PART);

    wxString r;

    CPPUNIT_ASSERT_EQUAL( FIRST_PART, s.BeforeFirst('=', &r) );
    CPPUNIT_ASSERT_EQUAL( MIDDLE_PART wxT("=") LAST_PART, r );

    CPPUNIT_ASSERT_EQUAL( s, s.BeforeFirst('!', &r) );
    CPPUNIT_ASSERT_EQUAL( "", r );


    CPPUNIT_ASSERT_EQUAL( FIRST_PART wxT("=") MIDDLE_PART, s.BeforeLast('=', &r) );
    CPPUNIT_ASSERT_EQUAL( LAST_PART, r );

    CPPUNIT_ASSERT_EQUAL( "", s.BeforeLast('!', &r) );
    CPPUNIT_ASSERT_EQUAL( s, r );


    CPPUNIT_ASSERT_EQUAL( MIDDLE_PART wxT("=") LAST_PART, s.AfterFirst('=') );
    CPPUNIT_ASSERT_EQUAL( "", s.AfterFirst('!') );


    CPPUNIT_ASSERT_EQUAL( LAST_PART, s.AfterLast('=') );
    CPPUNIT_ASSERT_EQUAL( s, s.AfterLast('!') );

    #undef LAST_PART
    #undef MIDDLE_PART
    #undef FIRST_PART
}
Example #14
0
// static
void AudacityApp::AddMultiPathsToPathList(wxString multiPathString,
                                          wxArrayString &pathList)
{
   while (multiPathString != wxT("")) {
      wxString onePath = multiPathString.BeforeFirst(wxPATH_SEP[0]);
      multiPathString = multiPathString.AfterFirst(wxPATH_SEP[0]);
      AddUniquePathToPathList(onePath, pathList);
   }
}
Example #15
0
void CxxPreProcessor::AddDefinition(const wxString& def)
{
    wxString macroName = def.BeforeFirst('=');
    wxString macroValue = def.AfterFirst('=');

    CxxPreProcessorToken token;
    token.name = macroName;
    token.value = macroValue;
    m_tokens.insert(std::make_pair(macroName, token));
}
wxString nomFromPlantePlusId0(wxString nom, int &idx, wxArrayInt *comboItems) { // specifique !!!
    wxUniChar sep0 = '[';
    wxUniChar sep1 = ']';
    wxString beg0, rest0, beg1, rest1;
    beg0 = nom.BeforeFirst(sep0, &rest0);
    beg1 = rest0.BeforeFirst(sep1, &rest1);
    idx = atoi(beg1);
    comboItems->Add(atoi(beg1));
    return rest1;
}
void BattleOptionsTab::UpdateBattle( const wxString& Tag )
{
	if ( !m_battle ) return;
	long type;
	Tag.BeforeFirst( '_' ).ToLong( &type );
	wxString key = Tag.AfterFirst( '_' );
	if ( type == LSL::Enum::PrivateOptions ) {
		if ( key == _T( "restrictions" ) ) ReloadRestrictions();
	}
}
Example #18
0
// returns TRUE if the parse is valid, or FALSE if it's a comment.
bool pxParseAssignmentString( const wxString& src, wxString& ldest, wxString& rdest )
{
	if( src.StartsWith(L"--") || src.StartsWith( L"//" ) || src.StartsWith( L";" ) )
		return false;

	ldest = src.BeforeFirst(L'=').Trim(true).Trim(false);
	rdest = src.AfterFirst(L'=').Trim(true).Trim(false);
	
	return true;
}
Example #19
0
void DebuggerTree::FixupVarNameForChange(wxString& str)
{
    // remove everything from '=' and after
    str = str.BeforeFirst(_T('='));
    str.Trim(false);
    str.Trim(true);

    // if it contains invalid chars, clear it
    if (str.find_first_of(_T(" \t")) != wxString::npos)
        str.Clear();
}
Example #20
0
///Changes the label text of a menu item
void CommandManager::Modify(wxString name, wxString newLabel)
{
   CommandListEntry *entry = mCommandNameHash[name];
   if (entry && entry->menu) {
      newLabel = newLabel.BeforeFirst(wxT('\t'));
      if (!entry->key.IsEmpty())
         newLabel = newLabel + wxT("\t") + entry->key;
      entry->label = newLabel;
      entry->menu->SetLabel(entry->id, newLabel);
   }
}
Example #21
0
wxString cbAuiNotebook::UniqueIdFromTooltip(const wxString& text)
{
    ProjectFile* pf = nullptr;
    cbProject* prj = nullptr;
    wxString id =  wxT("");
    wxString fn = text.BeforeFirst(wxT('\n'));
    prj = Manager::Get()->GetProjectManager()->FindProjectForFile(fn, &pf, false, true);
    if (prj && pf)
        id = prj->GetTitle() + wxT(':') + pf->relativeFilename;
    return id;
}
Example #22
0
//starting of funcs to conv globals...
wxString conv_variable(wxString input) //converts input of form "Variable vame[23] as datatype*"  to datatype* vname[23];
{
	wxString output,vname,datatype;
	input = input.AfterFirst(' '); //input contains "vame[23] as datatype*"
	vname = input.BeforeFirst(' ');
	input = input.AfterFirst(' ');//input contains "as datatype*
	datatype= input.AfterFirst(' ');
	output.Empty();
	output<<datatype<<" "<<vname<<";";
	return output;	
}
Example #23
0
void 
hoxChesscapePlayer::_HandleCmd_Unshow(const wxString& cmdStr)
{
	const wxString tableId = cmdStr.BeforeFirst(0x10);
	wxLogDebug("%s: Processing UNSHOW [%s] command...", __FUNCTION__, tableId.c_str());

	if ( ! _RemoveTableFromList( tableId ) ) // not found?
	{
		wxLogDebug("%s: *WARN* Table [%s] to be deleted NOT FOUND.", 
			__FUNCTION__, tableId.c_str());
	}
}
Example #24
0
void BattleRoomTab::UpdateBattleInfo(const wxString& Tag)
{
	if (!m_battle)
		return;

	const long index = m_opt_list_map[Tag];
	if (index >= m_opts_list->GetItemCount()) {
		wxLogDebug(_T("UpdateBattleInfo: Invalid index %d %d %s"), index, m_opts_list->GetItemCount(), Tag.c_str());
		return;
	}

	LSL::Enum::GameOption type = (LSL::Enum::GameOption)FromwxString(Tag.BeforeFirst('_'));
	wxString key = Tag.AfterFirst('_');
	if ((type == LSL::Enum::MapOption) || (type == LSL::Enum::ModOption) || (type == LSL::Enum::EngineOption)) {
		LSL::Enum::OptionType DataType = m_battle->CustomBattleOptions().GetSingleOptionType(STD_STRING(key));
		wxString value = TowxString(m_battle->CustomBattleOptions().getSingleValue(STD_STRING(key), (LSL::Enum::GameOption)type));
		if (TowxString(m_battle->CustomBattleOptions().getDefaultValue(STD_STRING(key), type)) == value) {
			m_opts_list->SetItemFont(index, wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT));
		} else {
			m_opts_list->SetItemFont(index, wxFont(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
		}
		if (DataType == LSL::Enum::opt_bool) {
			value = bool2yn(FromwxString(value)); // convert from 0/1 to literal Yes/No
		} else if (DataType == LSL::Enum::opt_list) {
			value = TowxString(m_battle->CustomBattleOptions().GetNameListOptValue(STD_STRING(key), type)); // get the key full name not short key
		}
		m_opts_list->SetItem(index, 1, value);
	} else // if ( type == OptionsWrapper::PrivateOptions )
	{
		if (key == _T( "mapname" )) // the map has been changed
		{
			UpdateMapInfoSummary();

			wxString mapname = TowxString(m_battle->GetHostMapName());
			int index_ = m_map_combo->FindString(mapname);
			if (index_ != wxNOT_FOUND)
				m_map_combo->SetSelection(index_);
			else
				m_map_combo->SetValue(mapname);

			//delete any eventual map option from the list and add options of the new map
			for (int i = m_map_opts_index; i < m_opts_list->GetItemCount();) {
				m_opts_list->DeleteItem(i);
			}
			AddMMOptionsToList(m_map_opts_index, LSL::Enum::MapOption);

			m_minimap->UpdateMinimap();

		} else if (key == _T( "restrictions" )) {
			m_opts_list->SetItem(index, 1, bool2yn(m_battle->RestrictedUnits().size() > 0));
		}
	}
}
Example #25
0
//! @brief Output a message said in the channel.
//!
//! @param who nick of the person who said something.
//! @param message the message to be outputted.
void ChatPanel::Said( const wxString& who, const wxString& message )
{
	wxString me = GetMe().GetNick();
	wxColour col;
	bool req_user = false;
	if ( who.Upper() == me.Upper() )
  {
		col = sett().GetChatColorMine();
	} else
	{
    // change the image of the tab to show new events
    SetIconHighlight( highlight_say );
    if ( m_type == CPT_User ) req_user = true;
    //process logic for custom word highlights
    if ( ContainsWordToHighlight( message ) )
    {
        req_user = sett().GetRequestAttOnHighlight();
        col = sett().GetChatColorHighlight();
    }
    else
        col = sett().GetChatColorNormal();
  }

	if ( ( who == _T( "MelBot" ) || who == _T( "[BOT]tizbacbridgebot" ) )
            && message.StartsWith( _T( "<" ) ) && message.Find( _T( ">" ) ) != wxNOT_FOUND )
    {
		wxString who2;
		wxString message2;
		who2 = message.BeforeFirst( '>' ).AfterFirst( '<' );
		if ( who != _T( "[BOT]tizbacbridgebot" ) ) who2 += _T( "@IRC" );
		//don't highlight if i'm talking from irc to channel
		if ( who2.Upper().BeforeLast(_T('@')) == me.Upper() )
		{
		    req_user = false;
		    col = sett().GetChatColorNormal();
		}
		message2 = message.AfterFirst( '>' );
		OutputLine( _T( " <" ) + who2 + _T( "> " ) + message2, col, sett().GetChatFont() );
	} else {
		OutputLine( _T( " <" ) + who + _T( "> " ) + message, col, sett().GetChatFont() );
	}


	if ( req_user ) {
		bool inactive = ui().GetActiveChatPanel() != this  || !wxTheApp->IsActive() ;
		ui().mw().RequestUserAttention();
		if ( inactive )
			UiEvents::GetNotificationEventSender().SendEvent(
					UiEvents::NotficationData( UiEvents::PrivateMessage,
											   wxString::Format( _T("%s:\n%s"), who.c_str(), message.Left(50).c_str() ) ) );
	}
}
NewVirtualFolderDlg::NewVirtualFolderDlg(wxWindow* parent, const wxString& currentVD)
    : NewVirtualFolderDlgBase(parent)
{
    m_checkBoxCreateOnDisk->SetValue( clConfig::Get().Read("CreateVirtualFoldersOnDisk", false) );
    wxString project_name = currentVD.BeforeFirst(':');
    wxString vd_path = currentVD.AfterFirst(':');
    vd_path.Replace(":", wxFILE_SEP_PATH);
    wxString errmsg;
    ProjectPtr proj = WorkspaceST::Get()->FindProjectByName(project_name, errmsg);
    wxString projectPath = proj->GetFileName().GetPath();
    m_basePath = wxFileName(projectPath + wxFILE_SEP_PATH + vd_path, "").GetPath();
    WindowAttrManager::Load(this, "NewVirtualFolderDlg");
}
inline void VersionStringToNumbers(const wxString& version, long* major, long* minor, long* release)
{
    wxString majorS = version.BeforeFirst(_T('.')); // 6.3.2 -> 6
    wxString minorS = version.AfterFirst(_T('.')); // 6.3.2 -> 3.2
    wxString releaseS = version.AfterLast(_T('.')); // 6.3.2 -> 2
    minorS = minorS.BeforeFirst(_T('.')); // 3.2 -> 3
    if (major)
        majorS.ToLong(major);
    if (minor)
        minorS.ToLong(minor);
    if (release)
        releaseS.ToLong(release);
}
Example #28
0
void wxGradient::fromString(wxString str)
{
	if(str.length()<=1)
	{
		addColorStop(wxColour(0,0,0));
		addColorStop(wxColour(255,255,255));
	}
	while(str.length()>1)
	{
		addColorStop(wxColour(str.BeforeFirst(';')));
		str = str.AfterFirst(';');
	}
}
Example #29
0
bool wxMimeTypesManager::IsOfType(const wxString& mimeType,
                                  const wxString& wildcard)
{
    wxASSERT_MSG( mimeType.Find(wxT('*')) == wxNOT_FOUND,
                  wxT("first MIME type can't contain wildcards") );

    // all comparaisons are case insensitive (2nd arg of IsSameAs() is false)
    if ( wildcard.BeforeFirst(wxT('/')).
            IsSameAs(mimeType.BeforeFirst(wxT('/')), false) )
    {
        wxString strSubtype = wildcard.AfterFirst(wxT('/'));

        if ( strSubtype == wxT("*") ||
             strSubtype.IsSameAs(mimeType.AfterFirst(wxT('/')), false) )
        {
            // matches (either exactly or it's a wildcard)
            return true;
        }
    }

    return false;
}
void FindSequenceDialog::aaSubSearch ( const wxString &s , int start , int dir , wxString rf )
	{
	int a ;
	wxChar codon[4] ;
	codon[3] = 0 ;
	wxString res ;
	wxArrayInt ai ;
    TVector *v = c->vec ;
    wxString sub = getQuery() ;
    int ostart = start < 0 ? 2 : 0 ;
    
    res.Alloc ( s.length() / 3 + 10 ) ;
    ai.Alloc ( s.length() / 3 + 10 ) ;
    
    if ( start < 0 )
    	{
	    for ( start = -start ; start + 3 < s.length() ; start += 3 ) ;
    	}
   	
	for ( a = start ; a + dir * 2 >= 0 && a + dir * 2 < s.length() ; a += dir * 3 )
		{
 		codon[0] = s.GetChar ( a ) ;
 		codon[1] = s.GetChar ( a + dir ) ;
 		codon[2] = s.GetChar ( a + dir * 2 ) ;

        wxChar c2 = codonhash[codon] ;
        if ( c2 < 'A' ) c2 = codonhash[codon] = v->dna2aa ( codon ) . GetChar ( 0 ) ;
        res += c2 ;

		ai.Add ( a ) ;
		}    
		
	a = subsearch ( res , sub , 0 ) ;
	//a = res.Find ( sub ) ;
	while ( a != -1 )
		{
  		if ( lb->GetCount() > FIND_MAX ) return ;
		int from = ai[a] + 1 - ostart ;
		int to = ai[a+sub.length()-1] + dir * 2 + 1 - ostart ;
		if ( from > to ) { int z = from ; from = to ; to = z ; }
		wxString msg = rf.BeforeFirst ( '\t' ) ;
      lb->Append ( wxString::Format ( _T("%s: %s (%d-%d)") ,
                          txt("amino_acid").c_str() ,
                          msg.c_str() ,
                          from , to ) ) ;
      vi.Add ( -1 ) ;
		res.SetChar ( a , '_' ) ; // Invalidating
		a = subsearch ( res , sub , a+1 ) ;
//		a = res.Find ( sub ) ;
		}    
	}