Пример #1
1
void CLocalListView::DisplayShares(wxString computer)
{
	// Cast through a union to avoid warning about breaking strict aliasing rule
	union
	{
		SHARE_INFO_1* pShareInfo;
		LPBYTE pShareInfoBlob;
	} si;

	DWORD read, total;
	DWORD resume_handle = 0;

	if (computer.Last() == '\\')
		computer.RemoveLast();

	int j = m_fileData.size();
	int share_count = 0;
	int res = 0;
	do
	{
		const wxWX2WCbuf buf = computer.wc_str(wxConvLocal);
		res = NetShareEnum((wchar_t*)(const wchar_t*)buf, 1, &si.pShareInfoBlob, MAX_PREFERRED_LENGTH, &read, &total, &resume_handle);

		if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA)
			break;

		SHARE_INFO_1* p = si.pShareInfo;
		for (unsigned int i = 0; i < read; i++, p++)
		{
			if (p->shi1_type != STYPE_DISKTREE)
				continue;

			CLocalFileData data;
			data.flags = normal;
			data.name = p->shi1_netname;
#ifdef __WXMSW__
			data.label = data.name;
#endif
			data.dir = true;
			data.icon = -2;
			data.size = -1;

			m_fileData.push_back(data);
			m_indexMapping.push_back(j++);

			share_count++;
		}

		NetApiBufferFree(si.pShareInfo);
	}
	while (res == ERROR_MORE_DATA);

	if (m_pFilelistStatusBar)
		m_pFilelistStatusBar->SetDirectoryContents(0, share_count, 0, false, 0);
}
Пример #2
0
void SPICE_VALUE::stripZeros( wxString& aString )
{
    if ( aString.Find( ',' ) >= 0 || aString.Find( '.' ) >= 0 )
    {
        while( aString.EndsWith( '0' ) )
            aString.RemoveLast();

        if( aString.EndsWith( '.' ) || aString.EndsWith( ',' ) )
            aString.RemoveLast();
    }
}
Пример #3
0
void DrawingUtils::TruncateText(const wxString& text, int maxWidth, wxDC& dc, wxString& fixedText)
{
    int textH, textW;
    int rectSize = maxWidth + 4; // error size
    int textLen = (int)text.Length();
    wxString tempText = text;

    fixedText = wxT("");
    dc.GetTextExtent(text, &textW, &textH);
    if(rectSize >= textW) {
        fixedText = text;
        return;
    }

    // The text does not fit in the designated area,
    // so we need to truncate it a bit
    wxString suffix = wxT("..");
    int w, h;
    dc.GetTextExtent(suffix, &w, &h);
    rectSize -= w;

    for(int i = textLen; i >= 0; i--) {
        dc.GetTextExtent(tempText, &textW, &textH);
        if(rectSize > textW) {
            fixedText = tempText;
            fixedText.RemoveLast(2); // remove last 2 chars, make room for the ".."
            fixedText += wxT("..");
            return;
        }
        tempText = tempText.RemoveLast();
    }
}
Пример #4
0
void StringUtil::StripQuotes(wxString &value){
	size_t len = value.Length();
	if (len > 0 && value[0] == '"' && value[len - 1] == '"'){
		value.Remove(0,1);
		value.RemoveLast(1);
		value.Replace(STRING_DELIMITER_ESCAPE, STRING_DELIMETER, true);
	}
}
Пример #5
0
bool CState::RecursiveCopy(wxString source, wxString target)
{
	if (source == _T(""))
		return false;

	if (target == _T(""))
		return false;

	if (target.Last() != wxFileName::GetPathSeparator())
		target += wxFileName::GetPathSeparator();

	if (source.Last() == wxFileName::GetPathSeparator())
		source.RemoveLast();

	if (source + wxFileName::GetPathSeparator() == target)
		return false;

	if (target.Len() > source.Len() && source == target.Left(source.Len()) && target[source.Len()] == wxFileName::GetPathSeparator())
		return false;
	
	int pos = source.Find(wxFileName::GetPathSeparator(), true);
	if (pos == -1 || pos == (int)source.Len() - 1)
		return false;

	std::list<wxString> dirsToVisit;
	dirsToVisit.push_back(source.Mid(pos + 1) + wxFileName::GetPathSeparator());
	source = source.Left(pos + 1);

	// Process any subdirs which still have to be visited
	while (!dirsToVisit.empty())
	{
		wxString dirname = dirsToVisit.front();
		dirsToVisit.pop_front();
		wxMkdir(target + dirname);
		wxDir dir;
		if (!dir.Open(source + dirname))
			continue;

		wxString file;
		for (bool found = dir.GetFirst(&file); found; found = dir.GetNext(&file))
		{
			if (file == _T(""))
			{
				wxGetApp().DisplayEncodingWarning();
				continue;
			}
			if (wxFileName::DirExists(source + dirname + file))
			{
				const wxString subDir = dirname + file + wxFileName::GetPathSeparator();
				dirsToVisit.push_back(subDir);
			}
			else
				wxCopyFile(source + dirname + file, target + dirname + file);
		}
	}

	return true;
}
Пример #6
0
jewel::Decimal
wx_to_decimal
(   wxString wxs,
    wxLocale const& loc,
    DecimalParsingFlags p_flags
)
{
    bool const allow_parens =
        p_flags.test(string_flags::allow_negative_parens);
    wxs = wxs.Trim().Trim(false);  // trim both right and left.
    typedef wxChar CharT;
    static CharT const open_paren = wxChar('(');
    static CharT const close_paren = wxChar(')');
    static CharT const minus_sign = wxChar('-');
    wxString const decimal_point_s = loc.GetInfo
    (   wxLOCALE_DECIMAL_POINT,
        wxLOCALE_CAT_MONEY
    );
    wxString const thousands_sep_s = loc.GetInfo
    (   wxLOCALE_THOUSANDS_SEP,
        wxLOCALE_CAT_MONEY
    );
    if (wxs.IsEmpty())
    {
        return Decimal(0, 0);
    }
    JEWEL_ASSERT (wxs.Len() >= 1);
    if ((wxs.Len() == 1) && (*(wxs.begin()) == minus_sign))
    {
        return Decimal(0, 0);
    }

    // We first convert wxs into a canonical form in which there are no
    // thousands separators, negativity is indicated only by a minus
    // sign, and the decimal point is '.'.
    if (allow_parens && (wxs[0] == open_paren) && (wxs.Last() == close_paren))
    {
        wxs[0] = minus_sign;  // Replace left parenthesis with minus sign
        wxs.RemoveLast();  // Drop right parenthesis
    }
    wxs.Replace(thousands_sep_s, wxEmptyString);

    // We need to get the std::locale (not wxLocale) related decimal point
    // character, so that we can ensure the Decimal constructor-from-string
    // sees that appropriate decimal point character.
    locale const gloc;  // global locale
    char const spot_char = use_facet<numpunct<char> >(gloc).decimal_point();
    char const spot_str[] = { spot_char, '\0' };
    wxs.Replace(decimal_point_s, wxString(spot_str));

    string const s = wx_to_std8(wxs);
    Decimal const ret(s);
    return ret;
}
Пример #7
0
int AutoCompData::BuildMemberList( const wxString& name, wxString& list ) const
{
   // First find the object...
   const AutoCompClass* found = FindClassOrObject( name );
   if ( !found )
      return 0;

   // TODO: Should we add members of dupes?

   // Now loop till we run out of base classes.
   wxArrayString tempArray;
   wxString temp;
   size_t len = 0;
   while ( found )
   {
      for ( int i=0; i < found->GetFunctions().GetCount(); i++ ) 
      {
         temp = found->GetFunctions()[i]->GetMethodName() + IDENT_FUNCTION;
         len += temp.Len() + 1;
         tempArray.Add( temp );
      }

      for ( int i=0; i < found->GetVars().GetCount(); i++ ) 
      {
         temp = found->GetVars()[i]->GetName() + IDENT_VAR;
         len += temp.Len() + 1;
         tempArray.Add( temp );
      }

      const wxString& base = found->GetBase();
      if ( base.IsEmpty() )
         break;

      found = FindClassOrObject( base );
   }

   wxString last, member;
   tempArray.Sort( CmpStringNoCase );
   list.Alloc( len - 1 );
   for ( int i=0; i < tempArray.GetCount(); i++ ) {
      member = tempArray[i];
      if ( member.CmpNoCase( last ) == 0 )
         continue;
      list.Append( member );
      list.Append( ' ' );
      last = member;
   }
   list.RemoveLast();
   list.Shrink();

   return (int)tempArray.GetCount();
}
bool cbResolveSymLinkedDirPath(wxString& dirpath)
{
#ifdef _WIN32
    return false;
#else
    if (dirpath.Last() == wxFILE_SEP_PATH)
        dirpath.RemoveLast();

    struct stat fileStats;
    if (lstat(dirpath.mb_str(wxConvUTF8), &fileStats) != 0)
        return false;

    // If the path is a symbolic link, then try to resolve it.
    // This is needed to prevent infinite loops, when a folder is pointing to itself or its parent folder.
    if (S_ISLNK(fileStats.st_mode))
    {
        char buffer[4096];
        int result = readlink(dirpath.mb_str(wxConvUTF8), buffer, WXSIZEOF(buffer) - 1);
        if (result != -1)
        {
            buffer[result] = '\0'; // readlink() doesn't NUL-terminate the buffer
            wxString pathStr(buffer, wxConvUTF8);
            wxFileName fileName = wxFileName::DirName(pathStr);

            // If this is a relative symbolic link, we need to make it absolute.
            if (!fileName.IsAbsolute())
            {
                wxFileName dirNamePath;
                if (dirpath.Last() == wxFILE_SEP_PATH)
                    dirNamePath = wxFileName::DirName(dirpath);
                else
                    dirNamePath = wxFileName::DirName(dirpath + wxFILE_SEP_PATH);
                dirNamePath.RemoveLastDir();
                // Make the new filename absolute relative to the parent folder.
                fileName.MakeAbsolute(dirNamePath.GetFullPath());
            }

            wxString fullPath = fileName.GetFullPath();
            if (fullPath.Last() == wxT('.')) // this case should be handled because of a bug in wxWidgets
                fullPath.RemoveLast();
            if (fullPath.Last() == wxFILE_SEP_PATH)
                fullPath.RemoveLast();
            dirpath = fullPath;
            return true;
        }
    }

    return false;
#endif // _WIN32
}
Пример #9
0
bool CLocalFileSystem::BeginFindFiles(wxString path, bool dirs_only)
{
	EndFindFiles();

	m_dirs_only = dirs_only;
#ifdef __WXMSW__
	if (path.Last() != '/' && path.Last() != '\\') {
		m_find_path = path + _T("\\");
		path += _T("\\*");
	}
	else {
		m_find_path = path;
		path += '*';
	}

	m_hFind = FindFirstFileEx(path, FindExInfoStandard, &m_find_data, dirs_only ? FindExSearchLimitToDirectories : FindExSearchNameMatch, 0, 0);
	if (m_hFind == INVALID_HANDLE_VALUE) {
		m_found = false;
		return false;
	}

	m_found = true;
	return true;
#else
	if (path != _T("/") && path.Last() == '/')
		path.RemoveLast();

	const wxCharBuffer s = path.fn_str();

	m_dir = opendir(s);
	if (!m_dir)
		return false;

	const wxCharBuffer p = path.fn_str();
	const int len = strlen(p);
	m_raw_path = new char[len + 2048 + 2];
	m_buffer_length = len + 2048 + 2;
	strcpy(m_raw_path, p);
	if (len > 1)
	{
		m_raw_path[len] = '/';
		m_file_part = m_raw_path + len + 1;
	}
	else
		m_file_part = m_raw_path + len;

	return true;
#endif
}
Пример #10
0
/*
 * Compute the 'next' pad number for autoincrement
 * aPadName is the last pad name used
 * */
static wxString GetNextPadName( wxString aPadName )
{
    // Automatically increment the current pad number.
    int num    = 0;
    int ponder = 1;

    // Trim and extract the trailing numeric part
    while( aPadName.Len() && aPadName.Last() >= '0' && aPadName.Last() <= '9' )
    {
        num += ( aPadName.Last() - '0' ) * ponder;
        aPadName.RemoveLast();
        ponder *= 10;
    }

    num++;  // Use next number for the new pad
    aPadName << num;

    return aPadName;
}
Пример #11
0
/* Remove trailing 0 from a string containing a converted float number.
 * the trailing 0 are removed if the mantissa has more
 * than aTrailingZeroAllowed digits and some trailing 0
 */
void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed )
{
    struct lconv * lc = localeconv();
    char sep = lc->decimal_point[0];
    unsigned sep_pos = aStringValue.Find( sep );

    if( sep_pos > 0 )
    {
        // We want to keep at least aTrailingZeroAllowed digits after the separator
        unsigned min_len = sep_pos + aTrailingZeroAllowed + 1;

        while( aStringValue.Len() > min_len )
        {
            if( aStringValue.Last() == '0' )
                aStringValue.RemoveLast();
            else
                break;
        }
    }
}
Пример #12
0
void CLocalListView::DisplayShares(wxString computer)
{
	SHARE_INFO_1* pShareInfo = 0;

	DWORD read, total;
	DWORD resume_handle = 0;

	if (computer.Last() == '\\')
		computer.RemoveLast();

	int j = m_fileData.size();
	int res = 0;
	do
	{
		const wxWX2WCbuf buf = computer.wc_str(wxConvLocal);
		res = NetShareEnum((wchar_t*)(const wchar_t*)buf, 1, (LPBYTE*)&pShareInfo, MAX_PREFERRED_LENGTH, &read, &total, &resume_handle);

		if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA)
			break;

		SHARE_INFO_1* p = pShareInfo;
		for (unsigned int i = 0; i < read; i++, p++)
		{
			if (p->shi1_type != STYPE_DISKTREE)
				continue;

			t_fileData data;
			data.name = p->shi1_netname;
			data.dir = true;
			data.icon = -2;
			data.size = -1;
			data.hasTime = false;

			m_fileData.push_back(data);
			m_indexMapping.push_back(j++);
		}

		NetApiBufferFree(pShareInfo);
	}
	while (res == ERROR_MORE_DATA);
}
Пример #13
0
/* static */
wxProtocolError wxProtocol::ReadLine(wxSocketBase *sock, wxString& result)
{
    static const int LINE_BUF = 4095;

    result.clear();

    wxCharBuffer buf(LINE_BUF);
    char *pBuf = buf.data();
    while ( sock->WaitForRead() )
    {
        // peek at the socket to see if there is a CRLF
        sock->Peek(pBuf, LINE_BUF);

        size_t nRead = sock->LastCount();
        if ( !nRead && sock->Error() )
            return wxPROTO_NETERR;

        // look for "\r\n" paying attention to a special case: "\r\n" could
        // have been split by buffer boundary, so check also for \r at the end
        // of the last chunk and \n at the beginning of this one
        pBuf[nRead] = '\0';
        const char *eol = strchr(pBuf, '\n');

        // if we found '\n', is there a '\r' as well?
        if ( eol )
        {
            if ( eol == pBuf )
            {
                // check for case of "\r\n" being split
                if ( result.empty() || result.Last() != _T('\r') )
                {
                    // ignore the stray '\n'
                    eol = NULL;
                }
                //else: ok, got real EOL

                // read just this '\n' and restart
                nRead = 1;
            }
            else // '\n' in the middle of the buffer
            {
                // in any case, read everything up to and including '\n'
                nRead = eol - pBuf + 1;

                if ( eol[-1] != '\r' )
                {
                    // as above, simply ignore stray '\n'
                    eol = NULL;
                }
            }
        }

        sock->Read(pBuf, nRead);
        if ( sock->LastCount() != nRead )
            return wxPROTO_NETERR;

        pBuf[nRead] = '\0';
        result += wxString::FromAscii(pBuf);

        if ( eol )
        {
            // remove trailing "\r\n"
            result.RemoveLast(2);

            return wxPROTO_NOERR;
        }
    }

    return wxPROTO_NETERR;
}
Пример #14
0
wxString GetIPV6LongForm(wxString short_address)
{
	if (!short_address.empty() && short_address[0] == '[') {
		if (short_address.Last() != ']')
			return wxString();
		short_address.RemoveLast();
		short_address = short_address.Mid(1);
	}
	short_address.MakeLower();

	wxChar buffer[40] = { '0', '0', '0', '0', ':',
						  '0', '0', '0', '0', ':',
						  '0', '0', '0', '0', ':',
						  '0', '0', '0', '0', ':',
						  '0', '0', '0', '0', ':',
						  '0', '0', '0', '0', ':',
						  '0', '0', '0', '0', ':',
						  '0', '0', '0', '0', 0
						};
	wxChar* out = buffer;

	const unsigned int len = short_address.Len();
	if (len > 39)
		return wxString();

	// First part, before possible ::
	unsigned int i = 0;
	unsigned int grouplength = 0;

	wxChar const* s = short_address.c_str(); // Get it zero-terminated.
	for (i = 0; i < len + 1; ++i) {
		const wxChar& c = s[i];
		if (c == ':' || !c) {
			if (!grouplength) {
				// Empty group length, not valid
				if (!c || s[i + 1] != ':')
					return wxString();
				++i;
				break;
			}

			out += 4 - grouplength;
			for (unsigned int j = grouplength; j > 0; j--)
				*out++ = s[i - j];
			// End of string...
			if (!c) {
				if (!*out)
					// ...on time
					return buffer;
				else
					// ...premature
					return wxString();
			}
			else if (!*out) {
				// Too long
				return wxString();
			}

			++out;

			grouplength = 0;
			if (s[i + 1] == ':') {
				++i;
				break;
			}
			continue;
		}
		else if ((c < '0' || c > '9') &&
				 (c < 'a' || c > 'f'))
		{
			// Invalid character
			return wxString();
		}
		// Too long group
		if (++grouplength > 4)
			return wxString();
	}

	// Second half after ::

	wxChar* end_first = out;
	out = &buffer[38];
	unsigned int stop = i;
	for (i = len - 1; i > stop; i--)
	{
		if (out < end_first)
		{
			// Too long
			return wxString();
		}

		const wxChar& c = s[i];
		if (c == ':')
		{
			if (!grouplength)
			{
				// Empty group length, not valid
				return wxString();
			}

			out -= 5 - grouplength;

			grouplength = 0;
			continue;
		}
		else if ((c < '0' || c > '9') &&
				 (c < 'a' || c > 'f'))
		{
			// Invalid character
			return wxString();
		}
		// Too long group
		if (++grouplength > 4)
			return wxString();
		*out-- = c;
	}
	if (!grouplength)
	{
		// Empty group length, not valid
		return wxString();
	}
	out -= 5 - grouplength;
	out += 2;

	int diff = out - end_first;
	if (diff < 0 || diff % 5)
		return wxString();

	return buffer;
}
Пример #15
0
wxString CState::Canonicalize(wxString oldDir, wxString newDir, wxString *error /*=0*/)
{
#ifdef __WXMSW__
	if (newDir == _T("\\") || newDir == _T("/") || newDir == _T(""))
		return _T("\\");

	// "Go up one level" is a little bit difficult under Windows due to 
	// things like "My Computer" and "Desktop"
	if (newDir == _T(".."))
	{
		newDir = oldDir;
		if (newDir != _T("\\"))
		{
			newDir.RemoveLast();
			int pos = newDir.Find('\\', true);
			if (pos == -1)
				return _T("\\");
			else
				newDir = newDir.Left(pos + 1);
		}
	}
	else
#endif
	{
		wxFileName dir(newDir, _T(""));
		{
			wxLogNull noLog;
			if (!dir.MakeAbsolute(oldDir))
				return _T("");
		}
		newDir = dir.GetFullPath();
		if (newDir.Right(1) != wxFileName::GetPathSeparator())
			newDir += wxFileName::GetPathSeparator();
	}

	// Check for partial UNC paths
	if (newDir.Left(2) == _T("\\\\"))
	{
		int pos = newDir.Mid(2).Find('\\');
		if (pos == -1 || pos + 3 == (int)newDir.Len())
		{
			// Partial UNC path, no share given
			return newDir;
		}

		pos = newDir.Mid(pos + 3).Find('\\');
		if (pos == -1)
		{
			// Partial UNC path, no full share yet, skip further processing
			return _T("");
		}
	}

	if (!wxDir::Exists(newDir))
	{
		if (!error)
			return _T("");

		*error = wxString::Format(_("'%s' does not exist or cannot be accessed."), newDir.c_str());

#ifdef __WXMSW__
		if (newDir[0] == '\\')
			return _T("");

		// Check for removable drive, display a more specific error message in that case
		if (::GetLastError() != ERROR_NOT_READY)
			return _T("");
		int type = GetDriveType(newDir.Left(3));
		if (type == DRIVE_REMOVABLE || type == DRIVE_CDROM)

			*error = wxString::Format(_("Cannot access '%s', no media inserted or drive not ready."), newDir.c_str());
#endif
			
		return _T("");
	}

	return newDir;
}
Пример #16
0
/*
 *  Prints data received from director to the console, and forwards it to the panels
 */
void wxbMainFrame::Print(wxString str, int status)
{
   if (lockedbyconsole) {
      EnableConsole(false);
   }
   
   if (status == CS_REMOVEPROMPT) {
      if (consoleCtrl->GetLastPosition() > 0) {
         consoleCtrl->Remove(consoleCtrl->GetLastPosition()-1, consoleCtrl->GetLastPosition()+1);
      }
      return;
   }
   
   if (status == CS_TERMINATED) {
      consoleCtrl->AppendText(consoleBuffer);
      consoleBuffer = wxT("");
      SetStatusText(_("Console thread terminated."));
#ifdef HAVE_WIN32
      consoleCtrl->PageDown();
#else
      consoleCtrl->ScrollLines(1);
#endif
      ct = NULL;
      DisablePanels();
      int answer = wxMessageBox( _("Connection to the director lost. Quit program?"), 
                                 _("Connection lost"),
                        wxYES_NO | wxICON_EXCLAMATION, this);
      if (answer == wxYES) {
         frame = NULL;
         Close(true);
      }
      menuFile->Enable(MenuConnect, true);
      menuFile->SetLabel(MenuConnect, _("Connect"));
      menuFile->SetHelpString(MenuConnect, _("Connect to the director"));
      menuFile->Enable(MenuDisconnect, false);
      menuFile->Enable(ChangeConfigFile, true);
      menuFile->Enable(EditConfigFile, true);
      return;
   }
   
   if (status == CS_CONNECTED) {
      SetStatusText(_("Connected to the director."));
      typeCtrl->ClearCommandList();
      bool parsed = false;
      int retries = 3;
      wxbDataTokenizer* dt = wxbUtils::WaitForEnd(wxT(".help"), true);
      while (true) {
         int i, j;
         wxString str;
         for (i = 0; i < (int)dt->GetCount(); i++) {
            str = (*dt)[i];
            str.RemoveLast();
            if ((j = str.Find(' ')) > -1) {
               typeCtrl->AddCommand(str.Mid(0, j), str.Mid(j+1));
               parsed = true;
            }
         }
         retries--;
         if ((parsed) || (!retries))
            break;
         dt = wxbUtils::WaitForEnd(wxT(""), true);
      }
      EnablePanels();
      menuFile->Enable(MenuConnect, true);
      menuFile->SetLabel(MenuConnect, _("Reconnect"));
      menuFile->SetHelpString(MenuConnect, _("Reconnect to the director"));
      menuFile->Enable(MenuDisconnect, true);
      menuFile->Enable(ChangeConfigFile, true);
      menuFile->Enable(EditConfigFile, true);
      return;
   }
   if (status == CS_DISCONNECTED) {
      consoleCtrl->AppendText(consoleBuffer);
      consoleBuffer = wxT("");
#ifdef HAVE_WIN32
      consoleCtrl->PageDown();
#else
      consoleCtrl->ScrollLines(1);
#endif
      SetStatusText(_("Disconnected of the director."));
      DisablePanels();
      return;
   }
      
   // CS_DEBUG is often sent by panels, 
   // and resend it to them would sometimes cause infinite loops
   
   /* One promptcaught is normal, so we must have two true Print values to be
    * sure that the prompt has effectively been caught.
    */
   int promptcaught = -1;
   
   if (status != CS_DEBUG) {
      for (unsigned int i = 0; i < parsers.GetCount(); i++) {
         promptcaught += parsers[i]->Print(str, status) ? 1 : 0;
      }
         
      if ((status == CS_PROMPT) && (promptcaught < 1) && (promptparser->isPrompt())) {
         Print(_("Unexpected question has been received.\n"), CS_DEBUG);
//         Print(wxString("(") << promptparser->getIntroString() << "/-/" << promptparser->getQuestionString() << ")\n", CS_DEBUG);
         
         wxString message;
         if (promptparser->getIntroString() != wxT("")) {
            message << promptparser->getIntroString() << wxT("\n");
         }
         message << promptparser->getQuestionString();
         
         if (promptparser->getChoices()) {
            wxString *choices = new wxString[promptparser->getChoices()->GetCount()];
            int *numbers = new int[promptparser->getChoices()->GetCount()];
            int n = 0;
            
            for (unsigned int i = 0; i < promptparser->getChoices()->GetCount(); i++) {
               if ((*promptparser->getChoices())[i] != wxT("")) {
                  choices[n] = (*promptparser->getChoices())[i];
                  numbers[n] = i;
                  n++;
               }
            }
            
            int res = ::wxGetSingleChoiceIndex(message,
               _("bwx-console: unexpected director's question."), n, choices, this);
            if (res == -1) { //Cancel pressed
               Send(wxT(".\n"));
            }
            else {
               if (promptparser->isNumericalChoice()) {
                  Send(wxString() << numbers[res] << wxT("\n"));
               }
               else {
                  Send(wxString() << choices[res] << wxT("\n"));
               }
            }
            delete[] choices;
            delete[] numbers;
         }
         else {
            Send(::wxGetTextFromUser(message,
               _("bwx-console: unexpected director's question."),
               wxT(""), this) + wxT("\n"));
         }
      }
   }
      
   if (status == CS_END) {
      if (lockedbyconsole) {
         EnablePanels();
         lockedbyconsole = false;
      }
      str = wxT("#");
   }

   if (status == CS_DEBUG) {
      consoleCtrl->AppendText(consoleBuffer);
      consoleBuffer = wxT("");
#ifdef HAVE_WIN32
      consoleCtrl->PageDown();
#else
      consoleCtrl->ScrollLines(1);
#endif
      consoleCtrl->SetDefaultStyle(wxTextAttr(wxColour(0, 128, 0)));
   }
   else {
      consoleCtrl->SetDefaultStyle(wxTextAttr(*wxBLACK));
   }
   consoleBuffer << wxbUtils::ConvertToPrintable(str);
   if (status == CS_PROMPT) {
      if (lockedbyconsole) {
         EnableConsole(true);
      }
      //consoleBuffer << wxT("<P>");
   }
   
   if ((status == CS_END) || (status == CS_PROMPT) || (str.Find(wxT("\n")) > -1)) {
      consoleCtrl->AppendText(consoleBuffer);
      consoleBuffer = wxT("");

#ifdef HAVE_WIN32
      consoleCtrl->PageDown();
#else
      consoleCtrl->ScrollLines(1);
#endif
   }
   
   //consoleCtrl->ShowPosition(consoleCtrl->GetLastPosition());
   
   /*if (status != CS_DEBUG) {
      consoleCtrl->AppendText("@");
   }*/
   //consoleCtrl->SetInsertionPointEnd();
}