static void end_protected_command(){ if(Uci->ready){ // not init faze uci_send_isready_sync(Uci); // gobble up spurious "bestmove" } update_remaining_time(); search_update(); // relaunch search if necessary }
void mux_dialog::on_output_available(wxCommandEvent &evt) { wxString line = evt.GetString(); log += line; if (line.Right(1) != wxT("\r")) log += wxT("\n"); if (line.Find(Z("Warning:")) == 0) tc_warnings->AppendText(line + wxT("\n")); else if (line.Find(Z("Error:")) == 0) tc_errors->AppendText(line + wxT("\n")); else if (line.Find(Z("Progress")) == 0) { if (line.Find(wxT("%")) != 0) { line.Remove(line.Find(wxT("%"))); auto tmp = line.AfterLast(wxT(' ')); long value = 0; tmp.ToLong(&value); if ((value >= 0) && (value <= 100)) update_gauge(value); } } else if (line.Length() > 0) tc_output->AppendText(line + wxT("\n")); update_remaining_time(); }
void job_run_dialog::process_input() { if (!process) return; while (process->IsInputAvailable()) { bool got_char = false; char c = 0; if (!out->Eof()) { c = out->GetC(); got_char = true; } if (got_char && ((c == '\n') || (c == '\r') || out->Eof())) { wxString wx_line = wxU(line); if (wx_line.Find(wxT("#GUI#begin_scanning_playlists")) == 0) m_scanning_playlists = true; else if (wx_line.Find(wxT("#GUI#end_scanning_playlists")) == 0) { m_scanning_playlists = false; m_start_time = mtx::sys::get_current_time_millis(); m_next_remaining_time_update = m_start_time + 8000; if (!current_job) { m_start_time_total = m_start_time; m_next_remaining_time_update_total = m_next_remaining_time_update; } } else if (wx_line.Find(wxT("#GUI#progress")) == 0) { int percent_pos = wx_line.Find(wxT("%")); if (0 < percent_pos) { wx_line.Remove(percent_pos); wxString tmp = wx_line.AfterLast(wxT(' ')); long value; tmp.ToLong(&value); if ((value >= 0) && (value <= 100)) set_progress_value(value); } } else if (wx_line.Length() > 0) *jobs[jobs_to_start[current_job]].log += wx_line + wxT("\n"); line = ""; } else if ((unsigned char)c != 0xff) line += c; update_remaining_time(); if (out->Eof()) break; } }
void mux_dialog::on_output_available(wxCommandEvent &evt) { wxString line = evt.GetString(); log += line; if (line.Right(1) != wxT("\r")) log += wxT("\n"); if (line.Find(Z("Warning:")) == 0) tc_warnings->AppendText(line + wxT("\n")); else if (line.Find(Z("Error:")) == 0) tc_errors->AppendText(line + wxT("\n")); else if (line.Find(wxT("#GUI#begin_scanning_playlists")) == 0) m_scanning_playlists = true; else if (line.Find(wxT("#GUI#end_scanning_playlists")) == 0) { m_scanning_playlists = false; m_start_time = mtx::sys::get_current_time_millis(); m_next_remaining_time_update = m_start_time + 8000; } else if (line.Find(wxT("#GUI#progress ")) == 0) { if (line.Find(wxT("%")) != 0) { line.Remove(line.Find(wxT("%"))); auto tmp = line.AfterLast(wxT(' ')); long value = 0; tmp.ToLong(&value); if ((value >= 0) && (value <= 100)) update_gauge(value); } } else if (line.Length() > 0) tc_output->AppendText(line + wxT("\n")); update_remaining_time(); }
mux_dialog::mux_dialog(wxWindow *parent): wxDialog(parent, -1, Z("mkvmerge is running"), wxDefaultPosition, #ifdef SYS_WINDOWS wxSize(700, 560), #else wxSize(700, 520), #endif wxDEFAULT_FRAME_STYLE) #if defined(SYS_WINDOWS) , pid(0) , m_taskbar_progress(NULL) , m_abort_button_changed(false) #endif // SYS_WINDOWS , m_exit_code(0) , m_progress(0) { char c; std::string arg_utf8, line; long value; wxString wx_line, tmp; wxInputStream *out; wxFile *opt_file; uint32_t i; wxArrayString *arg_list; wxBoxSizer *siz_all, *siz_buttons, *siz_line; wxStaticBoxSizer *siz_status, *siz_output; m_window_disabler = new wxWindowDisabler(this); c = 0; siz_status = new wxStaticBoxSizer(new wxStaticBox(this, -1, Z("Status and progress")), wxVERTICAL); st_label = new wxStaticText(this, -1, wxEmptyString); st_remaining_time_label = new wxStaticText(this, -1, Z("Remaining time:")); st_remaining_time = new wxStaticText(this, -1, Z("is being estimated")); siz_line = new wxBoxSizer(wxHORIZONTAL); siz_line->Add(st_label); siz_line->AddSpacer(5); siz_line->Add(st_remaining_time_label); siz_line->AddSpacer(5); siz_line->Add(st_remaining_time); siz_status->Add(siz_line, 0, wxGROW | wxALIGN_LEFT | wxALL, 5); g_progress = new wxGauge(this, -1, 100, wxDefaultPosition, wxSize(250, 15)); siz_status->Add(g_progress, 1, wxALL | wxGROW, 5); siz_output = new wxStaticBoxSizer(new wxStaticBox(this, -1, Z("Output")), wxVERTICAL); siz_output->Add(new wxStaticText(this, -1, Z("mkvmerge output:")), 0, wxALIGN_LEFT | wxALL, 5); tc_output = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE); siz_output->Add(tc_output, 2, wxGROW | wxALL, 5); siz_output->Add(new wxStaticText(this, -1, Z("Warnings:")), 0, wxALIGN_LEFT | wxALL, 5); tc_warnings = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE); siz_output->Add(tc_warnings, 1, wxGROW | wxALL, 5); siz_output->Add(new wxStaticText(this, -1, Z("Errors:")), 0, wxALIGN_LEFT | wxALL, 5); tc_errors = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_BESTWRAP | wxTE_MULTILINE); siz_output->Add(tc_errors, 1, wxGROW | wxALL, 5); siz_buttons = new wxBoxSizer(wxHORIZONTAL); siz_buttons->AddStretchSpacer(); b_ok = new wxButton(this, ID_B_MUX_OK, Z("Ok")); b_ok->Enable(false); siz_buttons->Add(b_ok, 0, wxGROW); siz_buttons->AddStretchSpacer(); b_abort = new wxButton(this, ID_B_MUX_ABORT, Z("Abort")); siz_buttons->Add(b_abort, 0, wxGROW); siz_buttons->AddStretchSpacer(); b_save_log = new wxButton(this, ID_B_MUX_SAVELOG, Z("Save log")); siz_buttons->Add(b_save_log, 0, wxGROW); siz_buttons->AddStretchSpacer(); siz_all = new wxBoxSizer(wxVERTICAL); siz_all->Add(siz_status, 0, wxGROW | wxALL, 5); siz_all->Add(siz_output, 1, wxGROW | wxALL, 5); siz_all->Add(siz_buttons, 0, wxGROW | wxALL, 10); SetSizer(siz_all); update_window(Z("Muxing in progress.")); Show(true); process = new mux_process(this); opt_file_name.Printf(wxT("%smmg-mkvmerge-options-%d-%d"), get_temp_dir().c_str(), (int)wxGetProcessId(), (int)wxGetUTCTime()); try { const unsigned char utf8_bom[3] = {0xef, 0xbb, 0xbf}; opt_file = new wxFile(opt_file_name, wxFile::write); opt_file->Write(utf8_bom, 3); } catch (...) { wxString error; error.Printf(Z("Could not create a temporary file for mkvmerge's command line option called '%s' (error code %d, %s)."), opt_file_name.c_str(), errno, wxUCS(strerror(errno))); wxMessageBox(error, Z("File creation failed"), wxOK | wxCENTER | wxICON_ERROR); throw 0; } arg_list = &static_cast<mmg_dialog *>(parent)->get_command_line_args(); for (i = 1; i < arg_list->Count(); i++) { if ((*arg_list)[i].Length() == 0) opt_file->Write(wxT("#EMPTY#")); else { arg_utf8 = escape(wxMB((*arg_list)[i])); opt_file->Write(arg_utf8.c_str(), arg_utf8.length()); } opt_file->Write(wxT("\n")); } delete opt_file; #if defined(SYS_WINDOWS) if (get_windows_version() >= WINDOWS_VERSION_7) { m_taskbar_progress = new taskbar_progress_c(mdlg); m_taskbar_progress->set_state(TBPF_NORMAL); m_taskbar_progress->set_value(0, 100); } #endif // SYS_WINDOWS m_start_time = get_current_time_millis(); m_next_remaining_time_update = m_start_time + 8000; wxString command_line = wxString::Format(wxT("\"%s\" \"@%s\""), (*arg_list)[0].c_str(), opt_file_name.c_str()); pid = wxExecute(command_line, wxEXEC_ASYNC, process); if (0 == pid) { wxLogError(wxT("Execution of '%s' failed."), command_line.c_str()); done(2); return; } out = process->GetInputStream(); line = ""; log = wxEmptyString; while (1) { while (app->Pending()) app->Dispatch(); if (!out->CanRead() && !out->Eof()) { wxMilliSleep(5); continue; } if (!out->Eof()) c = out->GetC(); else c = '\n'; if ((c == '\n') || (c == '\r') || out->Eof()) { wx_line = wxU(line); log += wx_line; if (c != '\r') log += wxT("\n"); if (wx_line.Find(Z("Warning:")) == 0) tc_warnings->AppendText(wx_line + wxT("\n")); else if (wx_line.Find(Z("Error:")) == 0) tc_errors->AppendText(wx_line + wxT("\n")); else if (wx_line.Find(Z("Progress")) == 0) { if (wx_line.Find(wxT("%")) != 0) { wx_line.Remove(wx_line.Find(wxT("%"))); tmp = wx_line.AfterLast(wxT(' ')); tmp.ToLong(&value); if ((value >= 0) && (value <= 100)) update_gauge(value); } } else if (wx_line.Length() > 0) tc_output->AppendText(wx_line + wxT("\n")); line = ""; update_remaining_time(); } else if ((unsigned char)c != 0xff) line += c; if (out->Eof()) break; } }