void luConsoleEdit::writeLine(const wxString& line, bool newLine) { AppendText(line); //long pos = GetLastPosition(); //Replace(pos, pos, line); if (newLine) AppendText("\n"); }
void CChatSession::AddText(const wxString& text, const wxTextAttr& style, bool newline) { // Split multi-line messages into individual lines wxStringTokenizer tokens( text, wxT("\n") ); while ( tokens.HasMoreTokens() ) { // Check if we should add a time-stamp if ( GetNumberOfLines() > 1 ) { // Check if the last line ended with a newline wxString line = GetLineText( GetNumberOfLines() - 1 ); if ( line.IsEmpty() ) { SetDefaultStyle( COLOR_BLACK ); AppendText( wxT(" [") + wxDateTime::Now().FormatISOTime() + wxT("] ") ); } } SetDefaultStyle(style); AppendText( tokens.GetNextToken() ); // Only add newlines after the last line if it is desired if ( tokens.HasMoreTokens() || newline ) { AppendText( wxT("\n") ); } } }
void SvnConsole::Stop() { if (m_process) { delete m_process; m_process = NULL; } AppendText(_("Aborted.\n")); AppendText(wxT("--------\n")); }
void FindResultsTab::OnSearchMatch(wxCommandEvent& e) { SearchResultList* res = (SearchResultList*)e.GetClientData(); if(!res) return; int m = m_book ? m_book->GetPageIndex(m_recv) : 0; if(m == wxNOT_FOUND) { wxDELETE(res); return; } MatchInfo& matchInfo = GetMatchInfo(m); for(SearchResultList::iterator iter = res->begin(); iter != res->end(); iter++) { if(matchInfo.empty() || matchInfo.rbegin()->second.GetFileName() != iter->GetFileName()) { if(!matchInfo.empty()) { AppendText("\n"); } wxFileName fn(iter->GetFileName()); fn.MakeRelativeTo(); AppendText(fn.GetFullPath() + wxT("\n")); } int lineno = m_recv->GetLineCount() - 1; matchInfo.insert(std::make_pair(lineno, *iter)); wxString text = iter->GetPattern(); int delta = -text.Length(); text.Trim(false); delta += text.Length(); text.Trim(); wxString linenum; if(iter->GetMatchState() == CppWordScanner::STATE_CPP_COMMENT || iter->GetMatchState() == CppWordScanner::STATE_C_COMMENT) linenum = wxString::Format(wxT(" %5u //"), iter->GetLineNumber()); else linenum = wxString::Format(wxT(" %5u "), iter->GetLineNumber()); SearchData* d = GetSearchData(m_recv); // Print the scope name if(d->GetDisplayScope()) { TagEntryPtr tag = TagsManagerST::Get()->FunctionFromFileLine(iter->GetFileName(), iter->GetLineNumber()); wxString scopeName(wxT("global")); if(tag) { scopeName = tag->GetPath(); } linenum << wxT("[ ") << scopeName << wxT(" ] "); iter->SetScope(scopeName); } delta += linenum.Length(); AppendText(linenum + text + wxT("\n")); m_recv->IndicatorFillRange(m_sci->PositionFromLine(lineno) + iter->GetColumn() + delta, iter->GetLen()); } wxDELETE(res); }
void CLogView::Log(LogFacility logType, BSTR bsSource, BSTR bsModuleID, VARIANT vtValue) { CHARFORMAT cf = {0}; cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_COLOR; CString sType; switch(logType) { case LT_DEBUG: sType = _T("debug"); cf.crTextColor = LOG_COLOR_DEBUG; break; case LT_INFO: sType = _T("info"); cf.crTextColor = LOG_COLOR_INFO; break; case LT_WARN: sType = _T("warning"); cf.crTextColor = LOG_COLOR_WARN; break; case LT_ERROR: sType = _T("error"); cf.crTextColor = LOG_COLOR_ERROR; break; default: sType = _T("log"); cf.crTextColor = LOG_DEFAULTCOLOR; break; } CTime ts = CTime::GetCurrentTime(); CString sDate(ts.Format(_T("%H:%M:%S"))); CComVariant vt; vt.ChangeType(VT_BSTR, &vtValue); if (vt.vt != VT_BSTR) { vt = _T("???"); } CString s; s.Format(_T("%s %s [%s: %s]: "), sDate, sType, bsSource, bsModuleID); SetSelectionCharFormat(cf); AppendText(s); cf.dwMask |= CFM_BOLD; cf.dwEffects = CFE_BOLD; SetSelectionCharFormat(cf); AppendText(vt.bstrVal); cf.dwMask = CFM_COLOR; cf.crTextColor = LOG_DEFAULTCOLOR; SetSelectionCharFormat(cf); AppendText(_T("\r\n")); }
void write_file(JJGui *jibber_ui) { GError *err = NULL; gchar *text; gboolean result; GtkTextBuffer *buffer; GtkTextIter start, end; char szFilename[35] = ""; time_t t; struct tm *tmNow; // make sure the gui is finished with any queued instructions before going further while (gtk_events_pending()) gtk_main_iteration(); // get contents of buffer buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (jibber_ui->text_view)); gtk_text_buffer_get_start_iter(buffer, &start); gtk_text_buffer_get_end_iter(buffer, &end); text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE); gtk_text_buffer_set_modified(buffer, FALSE); t = time(NULL); tmNow = localtime(&t); if (tmNow == NULL) { // create a filename from the compile stamp sprintf(szFilename, "jibber_%s_%s.txt", __DATE__, __TIME__); } else { // create a filename from the time strftime(szFilename, 35, "jibber_%F_%H-%M-%S.txt", tmNow); } result = g_file_set_contents (szFilename, text, -1, &err); if (result == FALSE) { // error saving file, show message to user AppendText(jibber_ui, DIR_SYSTEM, "Couldn't save file: %s", szFilename); AppendText(jibber_ui, DIR_SYSTEM, (err->message)); } else AppendText(jibber_ui, DIR_SYSTEM, "Saved file: %s", szFilename); // free the text memory g_free (text); } // end of write_file
void BuildProgressPnl::OnMustRefresh(wxCommandEvent&) { std::vector < CodeCompilerTask > currentTasks = CodeCompiler::Get()->GetCurrentTasks(); if (CodeCompiler::Get()->CompilationInProcess()) { if (!currentTasks.empty()) { if (!CodeCompiler::Get()->LastTaskFailed()) { statusTxt->SetLabel(_("Task in progress:")+currentTasks[0].userFriendlyName); AppendText(_("Task in progress:")+currentTasks[0].userFriendlyName+("...")+"\n"); } else { statusTxt->SetLabel(_("The task ")+currentTasks[0].userFriendlyName+_("failed.")); AppendText(_("The task ")+currentTasks[0].userFriendlyName+_("failed.")+"\n"); } } } else { if (CodeCompiler::Get()->LastTaskFailed()) { statusTxt->SetLabel(_("Some tasks failed.")); AppendText(_("Some tasks failed.")+"\n"); } else { wxString timeStr = wxString::Format(_("( %ld seconds )"), compilationTimer.Time()/1000); if (!currentTasks.empty()) { statusTxt->SetLabel(_("Compilation finished")+timeStr+_(", but ")+gd::String::From(currentTasks.size())+_(" task(s) are waiting.")); AppendText(_("Tasks finished ")+timeStr+_(", but ")+gd::String::From(currentTasks.size())+_(" task(s) are waiting.")+"\n"); } else { statusTxt->SetLabel(_("Compilation finished.")); AppendText(_("All tasks have been completed.")+" "+timeStr+"\n"); } } clearOnNextTextAdding = true; } if (!currentTasks.empty()) progressGauge->SetValue(100.f/static_cast<float>(currentTasks.size())); }
void SearchWindow::SearchMessage(const wxString& message) { Freeze(); SetDefaultStyle(m_messageAttr); AppendText(message + "\n"); Thaw(); }
void wxLuaConsole::DisplayStack(const wxLuaState& wxlState) { wxCHECK_RET(wxlState.Ok(), wxT("Invalid wxLuaState")); int nIndex = 0; lua_Debug luaDebug = INIT_LUA_DEBUG; wxString buffer; lua_State* L = wxlState.GetLuaState(); while (lua_getstack(L, nIndex, &luaDebug) != 0) { if (lua_getinfo(L, "Sln", &luaDebug)) { wxString what (luaDebug.what ? lua2wx(luaDebug.what) : wxString(wxT("?"))); wxString nameWhat(luaDebug.namewhat ? lua2wx(luaDebug.namewhat) : wxString(wxT("?"))); wxString name (luaDebug.name ? lua2wx(luaDebug.name) : wxString(wxT("?"))); buffer += wxString::Format(wxT("[%d] %s '%s' '%s' (line %d)\n Line %d src='%s'\n"), nIndex, what.c_str(), nameWhat.c_str(), name.c_str(), luaDebug.linedefined, luaDebug.currentline, lua2wx(luaDebug.short_src).c_str()); } nIndex++; } if (!buffer.empty()) { AppendText(wxT("\n-----------------------------------------------------------") wxT("\n- Backtrace") wxT("\n-----------------------------------------------------------\n") + buffer + wxT("\n-----------------------------------------------------------\n\n")); } }
//setting up the textarea for smooth scrolling, the first //TEXTAREA_OUTOFTEXT callback is called automatically void TextArea::SetupScroll(unsigned long tck) { SetPreservedRow(0); smooth = ftext->maxHeight; startrow = 0; ticks = tck; //clearing the textarea Clear(); unsigned int i = (unsigned int) (Height/smooth); while (i--) { char *str = (char *) malloc(1); str[0]=0; lines.push_back(str); lrows.push_back(0); } i = (unsigned int) lines.size(); Flags |= IE_GUI_TEXTAREA_SMOOTHSCROLL; GetTime( starttime ); if (RunEventHandler( TextAreaOutOfText )) { //event handler destructed this object? return; } if (i==lines.size()) { ResetEventHandler( TextAreaOutOfText ); return; } //recalculates rows AppendText("\n",-1); }
int wxTextCtrlBase::overflow(int c) { AppendText((wxChar)c); // return something different from EOF return 0; }
void SvnConsole::OnProcessEnd(wxCommandEvent& event) { ProcessEventData *ped = (ProcessEventData *)event.GetClientData(); delete ped; if ( m_process ) { delete m_process; m_process = NULL; } if(m_currCmd.handler) { // command ended successfully, invoke the "success" callback m_currCmd.handler->Process(m_output); AppendText(wxT("-----\n")); delete m_currCmd.handler; } // do we have more commands to process? if(!m_queue.empty()) { DoProcessNextCommand(); } else { // Do some cleanup m_output.Clear(); m_url.Clear(); m_currCmd.clean(); } }
void CBExecOutputDocument::ReceiveRecord() { assert( itsRecordLink != NULL ); JString text; const JBoolean ok = itsRecordLink->GetNextMessage(&text); assert( ok ); // remove text that has already been printed if (!itsLastPrompt.IsEmpty() && text.BeginsWith(itsLastPrompt)) { text.RemoveSubstring(1, itsLastPrompt.GetLength()); } itsLastPrompt.Clear(); const JXTEBase::DisplayState state = GetTextEditor()->SaveDisplayState(); AppendText(text); GetTextEditor()->ClearUndo(); if (!itsReceivedDataFlag) { itsReceivedDataFlag = kJTrue; if (!IsActive()) { Activate(); } } GetTextEditor()->RestoreDisplayState(state); }
void FindResultsTab::OnSearchStart(wxCommandEvent& e) { m_searchInProgress = true; SearchData* data = (SearchData*)e.GetClientData(); wxString label = data ? data->GetFindString() : wxT(""); if(e.GetInt() != 0 || m_sci == NULL) { if(m_book) { clWindowUpdateLocker locker(this); MySTC* sci = new MySTC(m_book); SetStyles(sci); sci->Connect(wxEVT_STC_STYLENEEDED, wxStyledTextEventHandler(FindResultsTab::OnStyleNeeded), NULL, this); m_book->AddPage(sci, label, true); #ifdef __WXMAC__ m_book->GetSizer()->Layout(); #endif size_t where = m_book->GetPageCount() - 1; // keep the search data used for this tab wxWindow* tab = m_book->GetPage(where); if(tab) { tab->SetClientData(data); } m_matchInfo.push_back(MatchInfo()); m_sci = sci; } } else if(m_book) { // using current tab, update the tab title and the search data int where = m_book->GetPageIndex(m_sci); if(where != wxNOT_FOUND) { m_book->SetPageText(where, label); // delete the old search data wxWindow* tab = m_book->GetPage(where); SearchData* oldData = (SearchData*)tab->GetClientData(); if(oldData) { delete oldData; } // set the new search data tab->SetClientData(data); } } // This is needed in >=wxGTK-2.9, otherwise the 'Search' pane doesn't fully expand SendSizeEvent(wxSEND_EVENT_POST); m_recv = m_sci; Clear(); if(data) { m_searchData = *data; wxString message; message << _("====== Searching for: '") << data->GetFindString() << _("'; Match case: ") << (data->IsMatchCase() ? _("true") : _("false")) << _(" ; Match whole word: ") << (data->IsMatchWholeWord() ? _("true") : _("false")) << _(" ; Regular expression: ") << (data->IsRegularExpression() ? _("true") : _("false")) << wxT(" ======\n"); AppendText(message); } }
JSDSourceText* jsd_AppendSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc, const char* text, /* *not* zero terminated */ size_t length, JSDSourceStatus status) { jsd_LockSourceTextSubsystem(jsdc); if( ! IsSourceInSourceList( jsdc, jsdsrc ) ) { RemoveSourceFromRemovedList( jsdc, jsdsrc ); jsd_UnlockSourceTextSubsystem(jsdc); return NULL; } if( text && length && ! AppendText( jsdc, jsdsrc, text, length ) ) { jsdsrc->dirty = JS_TRUE; jsdsrc->alterCount = g_alterCount++ ; jsdsrc->status = JSD_SOURCE_FAILED; MoveSourceToRemovedList(jsdc, jsdsrc); jsd_UnlockSourceTextSubsystem(jsdc); return NULL; } jsdsrc->dirty = JS_TRUE; jsdsrc->alterCount = g_alterCount++ ; jsdsrc->status = status; DEBUG_ITERATE_SOURCES(jsdc); jsd_UnlockSourceTextSubsystem(jsdc); return jsdsrc; }
wxTextCtrl& wxTextCtrlBase::operator<<(long i) { wxString str; str.Printf(wxT("%ld"), i); AppendText(str); return *TEXTCTRL(this); }
void CRedirect::ShowLastError(LPCTSTR szText) { LPVOID lpMsgBuf; DWORD Success; //-------------------------------------------------------------------------- // Get the system error message. //-------------------------------------------------------------------------- Success = FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), //lint !e1924 (warning about C-style cast) LPTSTR(&lpMsgBuf), 0, NULL ); CString Msg; Msg = szText; Msg += _T("\r\n"); if ( Success ) { Msg += LPTSTR(lpMsgBuf); } else { Msg += _T("No status because FormatMessage failed.\r\n"); } AppendText(Msg); }
AUI_ERRCODE aui_TextBox::AppendText ( MBCHAR const * text, COLORREF color, sint32 bold, sint32 italic ) { Assert( text != NULL ); if ( !text ) return AUI_ERRCODE_INVALIDPARAM; if ( !strlen( text ) ) return AppendText(" ", color, bold, italic ); m_curColor = color; m_curBold = bold; m_curItalic = italic; CalculateAppendedItems( text ); Assert( m_curLength + strlen( text ) <= m_maxLength ); strncat( m_text, text, m_maxLength - m_curLength ); m_curLength = strlen( m_text ); return AUI_ERRCODE_OK; }
wxTextCtrl& wxTextCtrlBase::operator<<(double d) { wxString str; str.Printf(wxT("%.2f"), d); AppendText(str); return *TEXTCTRL(this); }
void SvnConsole::OnReadProcessOutput(wxCommandEvent& event) { ProcessEventData *ped = (ProcessEventData *)event.GetClientData(); if (ped) { m_output.Append(ped->GetData().c_str()); } wxString s (ped->GetData()); s.MakeLower(); if (m_currCmd.printProcessOutput) AppendText( ped->GetData() ); static wxRegEx reUsername("username[ \t]*:", wxRE_DEFAULT|wxRE_ICASE); wxArrayString lines = wxStringTokenize(s, wxT("\n"), wxTOKEN_STRTOK); if( !lines.IsEmpty() && lines.Last().StartsWith(wxT("password for '")) ) { m_output.Clear(); wxString pass = wxGetPasswordFromUser(ped->GetData(), wxT("Subversion")); if(!pass.IsEmpty() && m_process) { m_process->WriteToConsole(pass); } } else if ( !lines.IsEmpty() && reUsername.IsValid() && reUsername.Matches( lines.Last() ) ) { // Prompt the user for "Username:"******"Subversion"); if ( !username.IsEmpty() && m_process ) { m_process->Write(username + "\n"); } } delete ped; }
NyqRedirector::~NyqRedirector() { std::cout.flush(); std::cout.rdbuf(mOld); if (s.length() > 0) { AppendText(); } }
SourceView::SourceView(wxWindow *parent, MainWin* mainwin_) : wxTextCtrl(parent, SOURCE_VIEW, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY | wxTE_DONTWRAP | wxTE_RICH2 ), mainwin(mainwin_) { AppendText("Select a procedure from the list above."); }
void HotKeyPressed(WPARAM wParam) { //AppendText(txtbox, _T("hotkey test")); if (wParam == (pauseHotKey + hotkeyIdOffset)) { if (!isPaused) { AppendText(txtbox, _T("Paused\r\n")); isPaused = true; } else { isPaused = false; AppendText(txtbox, _T("Unpaused\r\n")); } } }
void FindResultsTab::OnSearchCancel(wxCommandEvent& e) { m_searchInProgress = false; wxString* str = (wxString*)e.GetClientData(); if(!str) return; AppendText((*str) + wxT("\n")); wxDELETE(str); }
/************************************************************************* errorType STLServerCommandWaitForCompletionXXX::Read() will have already read the Socket command type and the command id now need to read the command specific data from the client. Should only be called from a GSISocket server or derived class Note that the corresponding ::Write function will be waiting for a ServerReturnRecord. This function does not return this record as it doesn't know if the task was completed without error. The calling code will need to perform the required hardware (or other) tasks and return the ServerReturnRecord indicating status of the function Reads: nothing to read *************************************************************************/ errorType STLServerCommandWaitForCompletionXXX::Read(wxSocketBase &sock) { errorType rv; rv=ReadFixedFields(sock); //reads qflag, at_tick FillGSIRecord(); //fill in the Hdw record AppendText("Read WaitForCompletion from client\n"); return errNone; }
void FindResultsTab::OnSearchMatch(wxCommandEvent& e) { SearchResultList* res = (SearchResultList*)e.GetClientData(); if(!res) return; SearchResultList::iterator iter = res->begin(); for(; iter != res->end(); ++iter) { if(m_matchInfo.empty() || m_matchInfo.rbegin()->second.GetFileName() != iter->GetFileName()) { if(!m_matchInfo.empty()) { AppendText("\n"); } wxFileName fn(iter->GetFileName()); fn.MakeRelativeTo(); AppendText(fn.GetFullPath() + wxT("\n")); } int lineno = m_sci->GetLineCount() - 1; m_matchInfo.insert(std::make_pair(lineno, *iter)); wxString text = iter->GetPattern(); // int delta = -text.Length(); // text.Trim(false); // delta += text.Length(); // text.Trim(); wxString linenum = wxString::Format(wxT(" %5u: "), iter->GetLineNumber()); SearchData* d = GetSearchData(); // Print the scope name if(d->GetDisplayScope()) { TagEntryPtr tag = TagsManagerST::Get()->FunctionFromFileLine(iter->GetFileName(), iter->GetLineNumber()); wxString scopeName(wxT("global")); if(tag) { scopeName = tag->GetPath(); } linenum << wxT("[ ") << scopeName << wxT(" ] "); iter->SetScope(scopeName); } AppendText(linenum + text + wxT("\n")); int indicatorStartPos = m_sci->PositionFromLine(lineno) + iter->GetColumn() + linenum.Length(); int indicatorLen = iter->GetLen(); m_indicators.push_back(indicatorStartPos); m_sci->IndicatorFillRange(indicatorStartPos, indicatorLen); } wxDELETE(res); }
void StopMessageHook() { EnableMenuItem(mainMenu, ID_FILE_STOPHOOK, MF_DISABLED | MF_GRAYED); EnableMenuItem(mainMenu, ID_FILE_STARTHOOK, MF_ENABLED); AppendText(txtbox, TEXT("Stopping Message Hook\r\n")); //KillHook(); RemoveHook(); msgCount = 0; }
int NyqRedirector::overflow(int c) { s += (char)c; if (c == '\n') { AppendText(); } return 0; }
static void PrintResult(HWND hText, number_t number) { char buf[MAX_RESULT_BUFFER]; unsigned long print_format; unsigned long print_format_float; print_format = GetIdentifierValueAsNativeInteger("print_format"); if (print_format == 0) { print_format = PRINT_FORMAT_DEC; } print_format_float = GetIdentifierValueAsNativeInteger("print_format_float"); if (print_format_float == 0) { print_format_float = PRINT_FORMAT_FLOAT_AUTO; } if ((print_format & PRINT_FORMAT_BIN) || (print_format & PRINT_FORMAT_HEX)) { integer_t *integer_result; char *str_result; integer_result = AllocateAndInitInteger(); mpz_set_f(*integer_result, number); if (print_format & PRINT_FORMAT_BIN) { str_result = mpz_get_str(NULL, 2, *integer_result); AppendText(hText, NEWLINE"=0b"); AppendText(hText, str_result); free(str_result); } if (print_format & PRINT_FORMAT_HEX) { str_result = mpz_get_str(NULL, 16, *integer_result); AppendText(hText, NEWLINE"=0x"); AppendText(hText, str_result); free(str_result); } FreeInteger(integer_result); } if (print_format & PRINT_FORMAT_DEC) { char format_str[] = NEWLINE"=%F "; format_str[strlen(format_str)-1] = print_format_float == PRINT_FORMAT_FLOAT_AUTO ? 'G' : print_format_float == PRINT_FORMAT_FLOAT_FIXED ? 'f' : print_format_float == PRINT_FORMAT_FLOAT_SCIENTIFIC ? 'e' : print_format_float == PRINT_FORMAT_FLOAT_HEX ? 'X' : 'g'; gmp_snprintf(buf, sizeof(buf), format_str, number); AppendText(hText, buf); } }
/// outputs text by appending and scrolling to the output line void OutputText(LPCTSTR pszText) { CStringA cszaText(pszText); SetReadOnly(false); AppendText(cszaText.GetString(), cszaText.GetLength()); SetReadOnly(true); ScrollToLine(GetLineCount()); }