Example #1
0
s32 sceKernelExitDeleteThread(ARMv7Context& context, s32 exitStatus)
{
	sceLibKernel.Warning("sceKernelExitDeleteThread(exitStatus=0x%x)", exitStatus);

	// exit status is stored in r0
	static_cast<ARMv7Thread&>(context).Stop();

	// current thread should be deleted
	const u32 id = static_cast<ARMv7Thread&>(context).GetId();

	CallAfter([id]()
	{
		Emu.GetIdManager().remove<ARMv7Thread>(id);
	});

	return SCE_OK;
}
void wxCodeCompletionBoxManager::ShowCompletionBox(wxStyledTextCtrl* ctrl,
                                                   const wxCodeCompletionBoxEntry::Vec_t& entries,
                                                   const wxCodeCompletionBox::BmpVec_t& bitmaps,
                                                   size_t flags,
                                                   int startPos,
                                                   wxEvtHandler* eventObject)
{
    DestroyCurrent();
    CHECK_PTR_RET(ctrl);
    //CHECK_COND_RET(!entries.empty());

    m_box = new wxCodeCompletionBox(wxTheApp->GetTopWindow(), eventObject);
    m_box->SetBitmaps(bitmaps);
    m_box->SetFlags(flags);
    m_box->SetStartPos(startPos);
    m_stc = ctrl;
    CallAfter(&wxCodeCompletionBoxManager::DoShowCCBoxEntries, entries);
}
Example #3
0
void wxCodeCompletionBox::OnLeftDClick(wxMouseEvent& event)
{
    // Check the scroll area
    if(m_scrollBottomRect.Contains(event.GetPosition())) {
        DoScrollDown();
    } else if(m_scrollTopRect.Contains(event.GetPosition())) {
        DoScrollUp();
    } else {
        for(size_t i = 0; i < m_entries.size(); ++i) {
            if(m_entries.at(i)->m_itemRect.Contains(event.GetPosition())) {
                m_index = i;
                InsertSelection();
                CallAfter(&wxCodeCompletionBox::DoDestroy);
                return;
            }
        }
    }
}
bool NodeJSWorkspace::DoOpen(const wxFileName& filename)
{
    NodeJSWorkspaceConfiguration conf;
    conf.Load(m_filename);
    if(!conf.IsOk()) {
        DoClear();
        return false;
    }

    m_folders = conf.GetFolders();
    GetView()->Clear();
    GetView()->ShowHiddenFiles(conf.IsShowHiddenFiles());

    const wxArrayString& folders = GetFolders();
    for(size_t i = 0; i < folders.size(); ++i) {
        GetView()->AddFolder(folders.Item(i));
    }

    // Notify codelite that NodeJS workspace is opened
    clGetManager()->GetWorkspaceView()->SelectPage(GetWorkspaceType());
    clWorkspaceManager::Get().SetWorkspace(this);

    // Keep the old clang state before we disable it
    const TagsOptionsData& options = TagsManagerST::Get()->GetCtagsOptions();
    m_clangOldFlag = (options.GetClangOptions() & CC_CLANG_ENABLED);

    clGetManager()->EnableClangCodeCompletion(false);

    // Notify that the a new workspace is loaded
    wxCommandEvent event(wxEVT_WORKSPACE_LOADED);
    event.SetString(filename.GetFullPath());
    EventNotifier::Get()->AddPendingEvent(event);

    // and finally, request codelite to keep this workspace in the recently opened workspace list
    clGetManager()->AddWorkspaceToRecentlyUsedList(m_filename);

    // Load the workspace session (if any)
    CallAfter(&NodeJSWorkspace::RestoreSession);

    // Create new debugger for this workspace
    m_debugger.Reset(new NodeJSDebugger());
    return true;
}
Example #5
0
void clMultiBook::MovePageToNotebook(Notebook* srcbook, size_t index, Notebook* destbook)
{
    if(!srcbook || !destbook) return;
    
    bool updateViewNeeded = (destbook->GetPageCount() == 0);
    wxString text = srcbook->GetPageText(index);
    wxBitmap bmp = srcbook->GetPageBitmap(index);
    wxWindow* page = srcbook->GetPage(index);

    srcbook->RemovePage(index, false);
    destbook->AddPage(page, text, true, bmp);
    
    // Make the newly added tab the focused one
    page->CallAfter(&wxWindow::SetFocus);
    
    // If we add the first page to the destination notebook or removing the last page from the source notebook
    // a view update is required
    if(updateViewNeeded || (srcbook->GetPageCount() == 0)) { CallAfter(&clMultiBook::UpdateView); }
}
Example #6
0
void PHPOutlineTree::ItemSelected(const wxTreeItemId& item, bool focusEditor)
{
    QItemData* itemData = dynamic_cast<QItemData*>(GetItemData(item));
    CHECK_PTR_RET(itemData);

    IEditor* editor = m_manager->GetActiveEditor();
    CHECK_PTR_RET(editor);

    // Define the pattern to search

    editor->FindAndSelect(itemData->m_entry->GetShortName(),
                          itemData->m_entry->GetShortName(),
                          editor->PosFromLine(itemData->m_entry->GetLine()),
                          NavMgr::Get());
    // set the focus to the editor
    if(focusEditor) {
        CallAfter(&PHPOutlineTree::SetEditorActive, editor);
    }
}
Example #7
0
void wxFlatButton::DoActivate()
{
    if(!IsEnabled())
        return;

    wxFlatButtonEvent btnEvent(wxEVT_CMD_FLATBUTTON_CLICK);
    btnEvent.SetEventObject(this);

    if(m_kind == kKindChek) {
        if(HasMenu()) {
            if(!IsChecked()) {
                m_state = kStatePressed;
                m_isChecked = true;
                Refresh();
                CallAfter(&wxFlatButton::DoShowContextMenu);

            } else {
                m_state = kStateNormal;
                m_isChecked = false;
                Refresh();
            }

            // We don't fire an event
            return;
        } else {
            if(IsChecked()) {
                // a checked button is about to be unchecked
                btnEvent.SetInt(0);
                m_state = kStateNormal;
                m_isChecked = false;
            } else {
                // Checking the button
                btnEvent.SetInt(1);
                m_isChecked = true;
                m_state = kStatePressed;
            }
        }
    } else {
        m_state = kStateHover;
    }
    GetEventHandler()->AddPendingEvent(btnEvent);
    Refresh();
}
void clTreeCtrlPanel::OnNewFile(wxCommandEvent& event)
{
    wxTreeItemId item = GetTreeCtrl()->GetFocusedItem();
    clTreeCtrlData* cd = GetItemData(item);
    CHECK_PTR_RET(cd);
    CHECK_COND_RET(cd->IsFolder());

    wxString filename =
        ::clGetTextFromUser(_("New File"), _("Set the file name:"), "Untitled.txt", wxStrlen("Untitled"));
    if(filename.IsEmpty()) return; // user cancelled

    wxFileName file(cd->GetPath(), filename);

    // Write the file content
    if(!FileUtils::WriteFileContent(file, "")) return;
    wxTreeItemId newFile = DoAddFile(item, file.GetFullPath());
    GetTreeCtrl()->SortChildren(item);
    CallAfter(&clTreeCtrlPanel::SelectItem, newFile);
}
DiffSideBySidePanel::DiffSideBySidePanel(wxWindow* parent)
    : DiffSideBySidePanelBase(parent)
    , m_flags(0)
{
    Hide();
    m_config.Load();

    EventNotifier::Get()->Connect(
        wxEVT_NOTIFY_PAGE_CLOSING, wxNotifyEventHandler(DiffSideBySidePanel::OnPageClosing), NULL, this);

    Connect(ID_COPY_LEFT_TO_RIGHT, wxEVT_COMMAND_MENU_SELECTED,
        wxCommandEventHandler(DiffSideBySidePanel::OnMenuCopyLeft2Right));
    Connect(ID_COPY_LEFT_TO_RIGHT_AND_MOVE, wxEVT_COMMAND_MENU_SELECTED,
        wxCommandEventHandler(DiffSideBySidePanel::OnMenuCopyLeft2Right));
    Connect(ID_COPY_RIGHT_TO_LEFT, wxEVT_COMMAND_MENU_SELECTED,
        wxCommandEventHandler(DiffSideBySidePanel::OnMenuCopyRight2Left));
    Connect(ID_COPY_RIGHT_TO_LEFT_AND_MOVE, wxEVT_COMMAND_MENU_SELECTED,
        wxCommandEventHandler(DiffSideBySidePanel::OnMenuCopyRight2Left));
    CallAfter(&DiffSideBySidePanel::DoLayout);
}
Example #10
0
int cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta)
{
	cellSysutil->Warning("cellMsgDialogProgressBarInc(progressBarIndex=%d, delta=%d)", progressBarIndex, delta);

	if (g_msg_dialog_state != msgDialogOpen)
	{
		return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
	}

	if (progressBarIndex >= g_msg_dialog_progress_bar_count)
	{
		return CELL_MSGDIALOG_ERROR_PARAM;
	}

	CallAfter([=]()
	{
		MsgDialogProgressBarInc(progressBarIndex, delta);
	});
	return CELL_OK;
}
Example #11
0
void NodeJSDebuggerPane::OnBreakpointSelected(wxDataViewEvent& event)
{
    wxVariant v;
    int line;
    wxString file;
    // sanity
    CHECK_ITEM_RET(event.GetItem());
    wxDataViewItem item = event.GetItem();
    int row = m_dvListCtrlBreakpoints->ItemToRow(item);
    // sanity
    if(row >= m_dvListCtrlBreakpoints->GetItemCount()) return;

    m_dvListCtrlBreakpoints->GetValue(v, row, 1);
    line = v.GetInteger();

    m_dvListCtrlBreakpoints->GetValue(v, row, 2);
    file = v.GetString();

    CallAfter(&NodeJSDebuggerPane::DoOpenFile, file, line);
}
Example #12
0
void clMultiBook::OnEventProxy(wxBookCtrlEvent& event)
{
    if(event.GetEventObject() == this) {
        // Avoid loops
        event.Skip();
        return;
    }
    int selection = event.GetSelection();
    int oldSelection = event.GetOldSelection();

    Notebook* book = dynamic_cast<Notebook*>(event.GetEventObject());
    if(!book) {
        clWARNING() << "clMultiBook::OnEventProxy no notebook event object!";
        return;
    }

    // Convert the event
    wxBookCtrlEvent proxyEvent(event.GetEventType());
    proxyEvent.SetEventObject(this);
    proxyEvent.SetSelection(wxNOT_FOUND);
    proxyEvent.SetOldSelection(wxNOT_FOUND);
    if(selection != wxNOT_FOUND) { proxyEvent.SetSelection(BookIndexToGlobalIndex(book, selection)); }
    if(oldSelection != wxNOT_FOUND) { proxyEvent.SetOldSelection(BookIndexToGlobalIndex(book, oldSelection)); }

    // Process the event
    if((event.GetEventType() == wxEVT_BOOK_TAB_CONTEXT_MENU) || (event.GetEventType() == wxEVT_BOOK_PAGE_CHANGED)) {
        // Use ProcessEvent
        GetEventHandler()->ProcessEvent(proxyEvent);
    } else if((event.GetEventType() == wxEVT_BOOK_PAGE_CLOSING) || (event.GetEventType() == wxEVT_BOOK_PAGE_CHANGING)) {
        // Handle with ProcessEvent with Veto option
        GetEventHandler()->ProcessEvent(proxyEvent);
        if(!proxyEvent.IsAllowed()) { event.Veto(); }
    } else {
        // Handle with AddPendingEvent
        GetEventHandler()->AddPendingEvent(proxyEvent);
        if(event.GetEventType() == wxEVT_BOOK_PAGE_CLOSED) {
            // A page was closed
            CallAfter(&clMultiBook::UpdateView);
        }
    }
}
Example #13
0
void clTreeCtrlPanel::OnNewFolder(wxCommandEvent& event)
{
    wxTreeItemId item = GetTreeCtrl()->GetFocusedItem();
    clTreeCtrlData* cd = GetItemData(item);
    CHECK_PTR_RET(cd);
    CHECK_COND_RET(cd->IsFolder());

    wxString foldername = ::clGetTextFromUser(_("New Folder"), _("Set the folder name:"), "New Folder");
    if(foldername.IsEmpty()) return; // user cancelled

    wxFileName file(cd->GetPath(), "");
    file.AppendDir(foldername);

    // Create the folder
    wxFileName::Mkdir(file.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);

    // Add it to the tree view
    wxTreeItemId newFile = DoAddFolder(item, file.GetPath());
    GetTreeCtrl()->SortChildren(item);
    CallAfter(&clTreeCtrlPanel::SelectItem, newFile);
}
Example #14
0
void CodeFormatterDlg::OnPgmgrastylePgChanged(wxPropertyGridEvent& event)
{
    m_isDirty = true;
    size_t options(0);
    // Build the options

    // Brakcets: Break closing;Attach;Linux;Break;None
    wxString brackets = m_pgPropBrackets->GetValueAsString();
    if(brackets == "Break closing") {
        options |= AS_BRACKETS_BREAK_CLOSING;
    } else if(brackets == "Attach") {
        options |= AS_BRACKETS_ATTACH;
    } else if(brackets == "Linux") {
        options |= AS_BRACKETS_LINUX;
    } else if(brackets == "Break") {
        options |= AS_BRACKETS_BREAK;
    }

    // PreDefined styles
    // GNU;Java;K&R;Linux;ANSI
    wxString predefStyle = m_pgPropPreDefinedStyles->GetValueAsString();
    if(predefStyle == "GNU") {
        options |= AS_GNU;
    } else if(predefStyle == "Java") {
        options |= AS_JAVA;
    } else if(predefStyle == "K&R") {
        options |= AS_KR;
    } else if(predefStyle == "Linux") {
        options |= AS_LINUX;
    } else if(predefStyle == "ANSI") {
        options |= AS_ANSI;
    }

    options |= m_pgPropFormatting->GetValue().GetInteger();
    options |= m_pgPropIndentation->GetValue().GetInteger();
    m_options.SetOption(options);

    CallAfter(&CodeFormatterDlg::UpdatePreview);
}
Example #15
0
void SFTPTreeView::DoLoadSession()
{
    // Now that we have successfully opened the connection, try to load the last saved session for this account
    const SFTPSessionInfo& sess = GetSession(true);
    if(sess.IsOk()) {
        wxString msg;
        msg << _("Would you like to load the saved session for this account?");
        wxStandardID ans = ::PromptForYesNoCancelDialogWithCheckbox(msg, "sftp-load-session-dlg");
        if(ans == wxID_YES) {
            // we have a session for this account, load it
            // Load the files
            const std::vector<wxString>& files = sess.GetFiles();
            std::for_each(files.begin(), files.end(), [&](const wxString& path) { DoOpenFile(path); });

            const wxString& rootFolder = sess.GetRootFolder();
            if(!rootFolder.IsEmpty()) {
                m_textCtrlQuickJump->ChangeValue(rootFolder);
                CallAfter(&SFTPTreeView::DoBuildTree, rootFolder);
            }
        }
    }
}
Example #16
0
void SyntaxHighlightDlg::SaveChanges()
{
    // Save all lexers once
    // Update the lexer
    CHECK_PTR_RET(m_lexer);

    // Make sure we got a valid text selection
    // foreground colour
    StyleProperty& selProp = m_lexer->GetProperty(SEL_TEXT_ATTR_ID);
    if(!selProp.IsNull()) {
        selProp.SetFgColour(m_colourPickerSelTextFgColour->GetColour().GetAsString(wxC2S_HTML_SYNTAX));
    }
    ColoursAndFontsManager::Get().Save(m_lexer);
    // Update the active theme for the lexer
    ColoursAndFontsManager::Get().SetActiveTheme(m_lexer->GetName(), m_choiceLexerThemes->GetStringSelection());
    
    if(m_globalThemeChanged) {
        wxBusyInfo bi(_("Applying changes..."));
        wxBusyCursor bc;
        ColoursAndFontsManager::Get().SetGlobalTheme(m_choiceGlobalTheme->GetStringSelection());
        ColoursAndFontsManager::Get().SetTheme(m_choiceGlobalTheme->GetStringSelection());
        m_globalThemeChanged = false;
        
        m_lexer =  ColoursAndFontsManager::Get().GetLexer(m_lexer->GetName());
        CallAfter(&SyntaxHighlightDlg::LoadLexer, m_lexer->GetThemeName());
    }
    
    wxString oldFg = EditorConfigST::Get()->GetCurrentOutputviewFgColour();
    wxString oldBg = EditorConfigST::Get()->GetCurrentOutputviewBgColour();

    wxString newFg = m_colourPickerOutputPanesFgColour->GetColour().GetAsString(wxC2S_HTML_SYNTAX);
    EditorConfigST::Get()->SetCurrentOutputviewFgColour(newFg);

    wxString newBg = m_colourPickerOutputPanesBgColour->GetColour().GetAsString(wxC2S_HTML_SYNTAX);
    EditorConfigST::Get()->SetCurrentOutputviewBgColour(newBg);
    
    m_isModified = false;
}
Example #17
0
void DebuggerCallstackView::Update(const StackEntryArray& stackArr)
{
    Clear();
    m_stack.insert(m_stack.end(), stackArr.begin(), stackArr.end());
    int activeFrame(-1);
    for(int i = 0; i < (int)m_stack.size(); i++) {
        bool isactive = (i == m_currLevel);
        StackEntry entry = m_stack.at(i);
        wxVector<wxVariant> cols;
        cols.push_back(::MakeBitmapIndexText(entry.level, isactive ? 0 : 1));
        cols.push_back(entry.function);
        cols.push_back(wxFileName(entry.file).GetFullPath());
        cols.push_back(entry.line);
        cols.push_back(entry.address);
        StackEntry* d = new StackEntry(entry);
        m_dvListCtrl->AppendItem(cols, (wxUIntPtr)d);
        if(isactive) { activeFrame = i; }
    }

    // Make sure that everything is drawn before we attempt to select anything
    m_dvListCtrl->Update();
    if(activeFrame != wxNOT_FOUND) { CallAfter(&DebuggerCallstackView::EnsureRowVisible, activeFrame); }
}
Example #18
0
int cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::ptr<const char> msgString)
{
	cellSysutil->Warning("cellMsgDialogProgressBarSetMsg(progressBarIndex=%d, msgString_addr=0x%x ['%s'])",
		progressBarIndex, msgString.addr(), msgString.get_ptr());

	if (g_msg_dialog_state != msgDialogOpen)
	{
		return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
	}

	if (progressBarIndex >= g_msg_dialog_progress_bar_count)
	{
		return CELL_MSGDIALOG_ERROR_PARAM;
	}

	std::string text = msgString.get_ptr();

	CallAfter([text, progressBarIndex]()
	{
		MsgDialogProgressBarSetMsg(progressBarIndex, text.c_str());
	});
	return CELL_OK;
}
Example #19
0
void PHPWorkspaceView::OnSetupRemoteUpload(wxAuiToolBarEvent& event)
{

    if(!event.IsDropDownClicked()) {
        CallAfter(&PHPWorkspaceView::DoOpenSSHAccountManager);

    } else {
        SSHWorkspaceSettings settings;
        settings.Load();

        wxMenu menu;
        if(!settings.IsRemoteUploadSet()) {
            // We never setup remote upload for this workspace
            menu.AppendCheckItem(ID_TOGGLE_AUTOMATIC_UPLOAD, _("Enable automatic upload"));
            menu.Enable(ID_TOGGLE_AUTOMATIC_UPLOAD, false);
            menu.Check(ID_TOGGLE_AUTOMATIC_UPLOAD, false);

        } else {
            menu.AppendCheckItem(ID_TOGGLE_AUTOMATIC_UPLOAD, _("Enable automatic upload"));
            menu.Check(ID_TOGGLE_AUTOMATIC_UPLOAD, settings.IsRemoteUploadEnabled());
            menu.Connect(ID_TOGGLE_AUTOMATIC_UPLOAD,
                         wxEVT_COMMAND_MENU_SELECTED,
                         wxCommandEventHandler(PHPWorkspaceView::OnToggleAutoUpload),
                         NULL,
                         this);
        }

        wxAuiToolBar* auibar = dynamic_cast<wxAuiToolBar*>(event.GetEventObject());
        if(auibar) {
            clAuiToolStickness ts(auibar, event.GetToolId());
            wxRect rect = auibar->GetToolRect(event.GetId());
            wxPoint pt = auibar->ClientToScreen(rect.GetBottomLeft());
            pt = ScreenToClient(pt);
            PopupMenu(&menu, pt);
        }
    }
}
Example #20
0
void xlGLCanvas::SetCurrentGLContext() {
    glGetError();
    if (m_context == nullptr) {
        LOG_GL_ERRORV(CreateGLContext());
    }
    LOG_GL_ERRORV(m_context->SetCurrent(*this));
    if (!functionsLoaded) {
        LOG_GL_ERRORV(DrawGLUtils::LoadGLFunctions());
        functionsLoaded = true;
    }
    if (cache == nullptr) {
        wxConfigBase* config = wxConfigBase::Get();
        int ver = 99;
        config->Read("ForceOpenGLVer", &ver, 99);

        static log4cpp::Category &logger_opengl = log4cpp::Category::getInstance(std::string("log_opengl"));
        const GLubyte* str = glGetString(GL_VERSION);
        const GLubyte* rend = glGetString(GL_RENDERER);
        const GLubyte* vend = glGetString(GL_VENDOR);
        wxString configs = wxString::Format("%s - glVer:  %s  (%s)(%s)",
                                           (const char *)GetName().c_str(),
                                           (const char *)str,
                                           (const char *)rend,
                                           (const char *)vend);

        if (wxString(rend) == "GDI Generic"
            || wxString(vend).Contains("Microsoft")) {

            bool warned;
            config->Read("GDI-Warned", &warned, false);
            if (!warned) {
                config->Write("GDI-Warned", true);
                wxString msg = wxString::Format("Generic non-accelerated graphics driver detected (%s - %s). Performance will be poor.  "
                                               "Please install updated video drivers for your video card.",
                                               vend, rend);
                CallAfter(&xlGLCanvas::DisplayWarning, msg);
            }
            //need to use 1.x
            ver = 1;
        }

        logger_opengl.info(std::string(configs.c_str()));
        printf("%s\n", (const char *)configs.c_str());
        if (ver >= 3 && (str[0] > '3' || (str[0] == '3' && str[2] >= '3'))) {
            if (logger_opengl.isDebugEnabled()) {
                AddDebugLog(this);
            }
            logger_opengl.info("Try creating 3.3 Cache");
            LOG_GL_ERRORV(cache = Create33Cache(UsesVertexTextureAccumulator(),
                                  UsesVertexColorAccumulator(),
                                  UsesVertexAccumulator(),
                                  UsesAddVertex()));
        }
        if (cache == nullptr && ver >=2
            && ((str[0] > '2') || (str[0] == '2' && str[2] >= '1'))) {
            logger_opengl.info("Try creating 2.1 Cache");
            LOG_GL_ERRORV(cache = Create21Cache());
        }
        if (cache == nullptr) {
            logger_opengl.info("Try creating 1.1 Cache");
            LOG_GL_ERRORV(cache = Create11Cache());
        }
        if (cache == nullptr) {
            logger_opengl.error("All attempts at cache creation have failed.");
        }
    }
    LOG_GL_ERRORV(DrawGLUtils::SetCurrentCache(cache));
}
Example #21
0
void CommandProcessorBase::UnBindLabelledStatesMenu(wxMenu* menu)
{
    wxCHECK_RET(menu, "NULL menu");
    CallAfter(&CommandProcessorBase::DoUnBindLabelledStatesMenu, menu); // We can't Unbind yet: the event won't have been caught
}
Example #22
0
void SFTPStatusPage::OnContentMenu(wxDataViewEvent& event)
{
    wxUnusedVar(event);
    CallAfter( &SFTPStatusPage::ShowContextMenu );
}
Example #23
0
PhpPlugin::PhpPlugin(IManager* manager)
    : IPlugin(manager)
    , m_clangOldFlag(false)
    , m_browser(NULL)
    , m_debuggerPane(NULL)
    , m_xdebugLocalsView(NULL)
    , m_xdebugEvalPane(NULL)
    , m_showWelcomePage(false)
{
    m_longName = wxT("PHP Plugin for the codelite IDE");
    m_shortName = wxT("PHP");

    // Instantiate the bitmaps, we do this so they will be populated in wxXmlResource
    // Sigleton class
    PHPImages images;
    PHPWorkspace::Get()->SetPluginManager(m_mgr);
    XDebugManager::Initialize(this);

    // Add our UI
    // create tab (possibly detached)
    Notebook* book = m_mgr->GetWorkspacePaneNotebook();
    if(IsWorkspaceViewDetached()) {
        // Make the window child of the main panel (which is the grand parent of the notebook)
        DockablePane* cp = new DockablePane(
            book->GetParent()->GetParent(), book, PHPStrings::PHP_WORKSPACE_VIEW_TITLE, wxNullBitmap, wxSize(200, 200));
        m_workspaceView = new PHPWorkspaceView(cp, m_mgr);
        cp->SetChildNoReparent(m_workspaceView);

    } else {
        m_workspaceView = new PHPWorkspaceView(book, m_mgr);
        book->InsertPage(0, m_workspaceView, PHPStrings::PHP_WORKSPACE_VIEW_TITLE, true);
    }

    PHPCodeCompletion::Instance()->SetManager(m_mgr);

    PHPEditorContextMenu::Instance()->ConnectEvents();
    PHPParserThread::Instance()->Start();

    // Pass the manager class to the context menu manager
    PHPEditorContextMenu::Instance()->SetManager(m_mgr);

    // Connect events
    EventNotifier::Get()->Connect(
        wxEVT_CC_SHOW_QUICK_OUTLINE, clCodeCompletionEventHandler(PhpPlugin::OnShowQuickOutline), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_DBG_UI_DELTE_ALL_BREAKPOINTS, clDebugEventHandler(PhpPlugin::OnXDebugDeleteAllBreakpoints), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_CMD_CREATE_NEW_WORKSPACE, wxCommandEventHandler(PhpPlugin::OnNewWorkspace), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_NEW_PROJECT_WIZARD_SHOWING, clNewProjectEventHandler(PhpPlugin::OnNewProject), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_NEW_PROJECT_WIZARD_FINISHED, clNewProjectEventHandler(PhpPlugin::OnNewProjectFinish), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_CMD_IS_WORKSPACE_OPEN, clCommandEventHandler(PhpPlugin::OnIsWorkspaceOpen), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_CMD_CLOSE_WORKSPACE, clCommandEventHandler(PhpPlugin::OnCloseWorkspace), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_CMD_OPEN_WORKSPACE, clCommandEventHandler(PhpPlugin::OnOpenWorkspace), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_CMD_RELOAD_WORKSPACE, clCommandEventHandler(PhpPlugin::OnReloadWorkspace), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_CMD_OPEN_RESOURCE, wxCommandEventHandler(PhpPlugin::OnOpenResource), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_CMD_GET_WORKSPACE_FILES, wxCommandEventHandler(PhpPlugin::OnGetWorkspaceFiles), NULL, this);
    EventNotifier::Get()->Connect(wxEVT_CMD_GET_CURRENT_FILE_PROJECT_FILES,
                                  wxCommandEventHandler(PhpPlugin::OnGetCurrentFileProjectFiles),
                                  NULL,
                                  this);
    EventNotifier::Get()->Connect(
        wxEVT_CMD_GET_ACTIVE_PROJECT_FILES, wxCommandEventHandler(PhpPlugin::OnGetActiveProjectFiles), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_CMD_GET_FIND_IN_FILES_MASK, clCommandEventHandler(PhpPlugin::OnGetFiFMask), NULL, this);
    EventNotifier::Get()->Connect(wxEVT_FILE_SAVED, clCommandEventHandler(PhpPlugin::OnFileSaved), NULL, this);
    EventNotifier::Get()->Connect(wxEVT_PHP_LOAD_URL, PHPEventHandler(PhpPlugin::OnLoadURL), NULL, this);
    EventNotifier::Get()->Connect(
        wxEVT_ALL_EDITORS_CLOSED, wxCommandEventHandler(PhpPlugin::OnAllEditorsClosed), NULL, this);

    EventNotifier::Get()->Bind(wxEVT_XDEBUG_CONNECTED, &PhpPlugin::OnDebugSatrted, this);
    EventNotifier::Get()->Bind(wxEVT_XDEBUG_SESSION_ENDED, &PhpPlugin::OnDebugEnded, this);
    
    EventNotifier::Get()->Connect(wxEVT_GOING_DOWN, clCommandEventHandler(PhpPlugin::OnGoingDown), NULL, this);
    CallAfter(&PhpPlugin::DoCreateDebuggerPanes);

    // Extract all CC files from PHP.zip into the folder ~/.codelite/php-plugin/cc
    wxFileName phpResources(clStandardPaths::Get().GetDataDir(), "PHP.zip");
    if(phpResources.Exists()) {

        clZipReader zipReader(phpResources);
        wxFileName targetDir(clStandardPaths::Get().GetUserDataDir(), "");
        targetDir.AppendDir("php-plugin");

        // Don't extract the zip if one of the files on disk is newer or equal to the zip timestamp
        wxFileName fnSampleFile(targetDir.GetPath(), "basic.php");
        fnSampleFile.AppendDir("cc");
        if(!fnSampleFile.Exists() || // the sample file does not exists
                                     // Or the resource file (PHP.zip) is newer than the sample file
           (phpResources.GetModificationTime().GetTicks() > fnSampleFile.GetModificationTime().GetTicks())) {

            targetDir.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL);
            zipReader.Extract("*", targetDir.GetPath());

            // Make sure we add this path to the general PHP settings
            targetDir.AppendDir("cc"); // the CC files are located under an internal folder named "cc" (lowercase)
            PHPConfigurationData config;
            if(config.Load().GetCcIncludePath().Index(targetDir.GetPath()) == wxNOT_FOUND) {
                config.Load().GetCcIncludePath().Add(targetDir.GetPath());
                config.Save();
            }
        }
    } else {
        CL_WARNING("PHP: Could not locate PHP resources 'PHP.zip' => '%s'", phpResources.GetFullPath());
    }
}
void wxCodeCompletionBoxManager::OnAppActivate(wxActivateEvent& event)
{
    event.Skip();
    CallAfter(&wxCodeCompletionBox::DoDestroy);
}
Example #25
0
void MainBook::ReloadExternallyModified(bool prompt)
{
    if(m_isWorkspaceReloading) return;
    static int depth = wxNOT_FOUND;
    ++depth;

    // Protect against recursion
    if(depth == 2) {
        depth = wxNOT_FOUND;
        return;
    }

    LEditor::Vec_t editors;
    GetAllEditors(editors, MainBook::kGetAll_IncludeDetached);

    time_t workspaceModifiedTimeBefore = clCxxWorkspaceST::Get()->GetFileLastModifiedTime();

    // filter list of editors for any whose files have been modified
    std::vector<std::pair<wxFileName, bool> > files;
    size_t n = 0;
    for(size_t i = 0; i < editors.size(); i++) {
        time_t diskTime = editors[i]->GetFileLastModifiedTime();
        time_t editTime = editors[i]->GetEditorLastModifiedTime();
        if(diskTime != editTime) {
            // update editor last mod time so that we don't keep bugging the user over the same file,
            // unless it gets changed again
            editors[i]->SetEditorLastModifiedTime(diskTime);

            // A last check: see if the content of the file has actually changed. This avoids unnecessary reload offers
            // after e.g. git stash
            if(!CompareFileWithString(editors[i]->GetFileName().GetFullPath(), editors[i]->GetText())) {
                files.push_back(std::make_pair(editors[i]->GetFileName(), !editors[i]->GetModify()));
                editors[n++] = editors[i];
            }
        }
    }
    editors.resize(n);
    if(n == 0) return;

    if(prompt) {

        int res = clConfig::Get().GetAnnoyingDlgAnswer("FilesModifiedDlg", wxNOT_FOUND);
        if(res == wxID_CANCEL) {
            return; // User had previous ticked the 'Remember my answer' checkbox after he'd just chosen Ignore
        }

        if(res == wxNOT_FOUND) {
            // User hasn't previously ticked the 'Remember my answer' checkbox
            // Show the dialog
            res = GetFilesModifiedDlg()->ShowModal();

            if(GetFilesModifiedDlg()->GetRememberMyAnswer()) {
                clConfig::Get().SetAnnoyingDlgAnswer("FilesModifiedDlg", res);
            }

            if(res == FilesModifiedDlg::kID_BUTTON_IGNORE) {
                return;
            }
        }

        if(res == FilesModifiedDlg::kID_BUTTON_CHOOSE) {
            UserSelectFiles(files, _("Reload Modified Files"),
                _("Files have been modified outside the editor.\nChoose which files you would like to reload."), false);
        }
    }

    time_t workspaceModifiedTimeAfter = clCxxWorkspaceST::Get()->GetFileLastModifiedTime();
    if(workspaceModifiedTimeBefore != workspaceModifiedTimeAfter) {
        // a workspace reload occured between the "Reload Modified Files" and
        // the "Reload WOrkspace" dialog, cancel this it's not needed anymore
        return;
    }

    // See issue: https://github.com/eranif/codelite/issues/663
    LEditor::Vec_t editorsAgain;
    GetAllEditors(editorsAgain, MainBook::kGetAll_IncludeDetached);

    // Make sure that the tabs that we have opened
    // are still available in the main book
    LEditor::Vec_t realEditorsList;
    std::sort(editors.begin(), editors.end());
    std::sort(editorsAgain.begin(), editorsAgain.end());
    std::set_intersection(
        editorsAgain.begin(), editorsAgain.end(), editors.begin(), editors.end(), std::back_inserter(realEditorsList));

    // Update the "files" list
    if(editors.size() != realEditorsList.size()) {
        // something went wrong here...
        CallAfter(&MainBook::ReloadExternallyModified, prompt);
        return;
    }

    // reset the recursive protector
    depth = wxNOT_FOUND;

    std::vector<wxFileName> filesToRetag;
    for(size_t i = 0; i < files.size(); i++) {
        if(files[i].second) {
            editors[i]->ReloadFile();
            filesToRetag.push_back(files[i].first);
        }
    }
    if(filesToRetag.size() > 1) {
        TagsManagerST::Get()->RetagFiles(filesToRetag, TagsManager::Retag_Quick);
        SendCmdEvent(wxEVT_FILE_RETAGGED, (void*)&filesToRetag);

    } else if(filesToRetag.size() == 1) {
        ManagerST::Get()->RetagFile(filesToRetag.at(0).GetFullPath());
        SendCmdEvent(wxEVT_FILE_RETAGGED, (void*)&filesToRetag);
    }
}
Example #26
0
void xLightsFrame::SaveSequence()
{
    if (SeqData.NumFrames() == 0)
    {
        wxMessageBox("You must open a sequence first!", "Error");
        return;
    }

    wxCommandEvent playEvent(EVT_STOP_SEQUENCE);
    wxPostEvent(this, playEvent);

    if (xlightsFilename.IsEmpty())
    {
        int saved_text_entry_context = mTextEntryContext;
        mTextEntryContext = TEXT_ENTRY_DIALOG;
        wxString NewFilename;

        wxFileDialog fd(this,
                        "Choose filename to Save Sequence:",
                        CurrentDir,
                        CurrentSeqXmlFile->GetName(),
                        strSequenceSaveAsFileTypes,
                        wxFD_SAVE | wxFD_OVERWRITE_PROMPT);

        bool ok = false;
        do
        {
            if (fd.ShowModal() != wxID_OK)
            {
                return;
            }
            // validate inputs
            NewFilename=fd.GetPath();
            NewFilename.Trim();
            ok=true;
            if (NewFilename.IsEmpty())
            {
                ok=false;
                wxMessageBox(_("File name cannot be empty"), _("ERROR"));
            }
        }
        while (!ok);
        wxFileName oName(NewFilename);
        oName.SetExt("fseq");
        DisplayXlightsFilename(oName.GetFullPath());

        oName.SetExt("xml");
        CurrentSeqXmlFile->SetPath(oName.GetPath());
        CurrentSeqXmlFile->SetFullName(oName.GetFullName());

        mTextEntryContext = saved_text_entry_context;
    }

    EnableSequenceControls(false);
    wxStopWatch sw; // start a stopwatch timer
    StatusBar1->SetStatusText(_("Saving ")+xlightsFilename);

    CurrentSeqXmlFile->Save(mSequenceElements);
    if (mRenderOnSave) {
        RenderIseqData(true); // render ISEQ layers below the Nutcracker layer
        RenderGridToSeqData();
        RenderIseqData(false);  // render ISEQ layers above the Nutcracker layer
    }
    WriteFalconPiFile(xlightsFilename);
    DisplayXlightsFilename(xlightsFilename);
    float elapsedTime = sw.Time()/1000.0; // now stop stopwatch timer and get elapsed time. change into seconds from ms
    wxString displayBuff = wxString::Format(_("%s     Updated in %7.3f seconds"),xlightsFilename,elapsedTime);
    CallAfter(&xLightsFrame::SetStatusText, displayBuff);
    EnableSequenceControls(true);
    mSavedChangeCount = mSequenceElements.GetChangeCount();
}
Example #27
0
void cellSpursJq_init()
{
	REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeInitialize);
	REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetMaxGrab);
	REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetSubmitWithEntryLock);
	REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetDoBusyWaiting);
	REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetIsHaltOnError);
	REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetIsJobTypeMemoryCheck);
	REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetMaxSizeJobDescriptor);
	REG_FUNC(cellSpursJq, cellSpursJobQueueAttributeSetGrabParameters);
	REG_FUNC(cellSpursJq, cellSpursJobQueueSetWaitingMode);
	REG_FUNC(cellSpursJq, cellSpursShutdownJobQueue);
	REG_FUNC(cellSpursJq, _cellSpursCreateJobQueueWithJobDescriptorPool);
	REG_FUNC(cellSpursJq, _cellSpursCreateJobQueue);
	REG_FUNC(cellSpursJq, cellSpursJoinJobQueue);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePushJobListBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePushJobBody2);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePushJob2Body);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePushAndReleaseJobBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePushJobBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePushBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueueAllocateJobDescriptorBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePushSync);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePushFlush);
	REG_FUNC(cellSpursJq, cellSpursJobQueueGetSpurs);
	REG_FUNC(cellSpursJq, cellSpursJobQueueGetHandleCount);
	REG_FUNC(cellSpursJq, cellSpursJobQueueGetError);
	REG_FUNC(cellSpursJq, cellSpursJobQueueGetMaxSizeJobDescriptor);
	REG_FUNC(cellSpursJq, cellSpursGetJobQueueId);
	REG_FUNC(cellSpursJq, cellSpursJobQueueGetSuspendedJobSize);
	REG_FUNC(cellSpursJq, cellSpursJobQueueClose);
	REG_FUNC(cellSpursJq, cellSpursJobQueueOpen);
	REG_FUNC(cellSpursJq, cellSpursJobQueueSemaphoreTryAcquire);
	REG_FUNC(cellSpursJq, cellSpursJobQueueSemaphoreAcquire);
	REG_FUNC(cellSpursJq, cellSpursJobQueueSemaphoreInitialize);
	REG_FUNC(cellSpursJq, cellSpursJobQueueSendSignal);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePortGetJobQueue);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePortPushSync);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePortPushFlush);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePortPushJobListBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePortPushJobBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePortPushJobBody2);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePortPushBody);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePortTrySync);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePortSync);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePortInitialize);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePortInitializeWithDescriptorBuffer);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePortFinalize);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePortCopyPushJobBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePortCopyPushJobBody2);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePortCopyPushBody);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePort2GetJobQueue);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePort2PushSync);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePort2PushFlush);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePort2PushJobListBody);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePort2Sync);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePort2Create);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePort2Destroy);
	REG_FUNC(cellSpursJq, cellSpursJobQueuePort2AllocateJobDescriptor);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePort2PushAndReleaseJobBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePort2CopyPushJobBody);
	REG_FUNC(cellSpursJq, _cellSpursJobQueuePort2PushJobBody);
	REG_FUNC(cellSpursJq, cellSpursJobQueueSetExceptionEventHandler);
	REG_FUNC(cellSpursJq, cellSpursJobQueueUnsetExceptionEventHandler);

#ifdef PRX_DEBUG
	CallAfter([]()
	{
		libspurs_jq = (u32)Memory.PRXMem.AllocAlign(sizeof(libspurs_jq_data), 4096);
		memcpy(vm::get_ptr<void>(libspurs_jq), libspurs_jq_data, sizeof(libspurs_jq_data));
		libspurs_jq_rtoc = libspurs_jq + 0x17E80;

		extern Module* sysPrxForUser;
		extern Module* cellSpurs;
		extern Module* cellFiber;

		FIX_IMPORT(cellSpurs, cellSpursSendWorkloadSignal           , libspurs_jq + 0x6728);
		FIX_IMPORT(cellSpurs, cellSpursWorkloadAttributeSetName     , libspurs_jq + 0x6748);
		FIX_IMPORT(cellSpurs, cellSpursRemoveWorkload               , libspurs_jq + 0x6768);
		FIX_IMPORT(cellSpurs, cellSpursWaitForWorkloadShutdown      , libspurs_jq + 0x6788);
		FIX_IMPORT(cellSpurs, cellSpursWakeUp                       , libspurs_jq + 0x67A8);
		FIX_IMPORT(cellSpurs, cellSpursShutdownWorkload             , libspurs_jq + 0x67C8);
		FIX_IMPORT(cellSpurs, cellSpursAddWorkloadWithAttribute     , libspurs_jq + 0x67E8);
		FIX_IMPORT(cellSpurs, cellSpursSetExceptionEventHandler     , libspurs_jq + 0x6808);
		FIX_IMPORT(cellSpurs, _cellSpursWorkloadAttributeInitialize , libspurs_jq + 0x6828);
		FIX_IMPORT(cellFiber, cellFiberPpuSelf                      , libspurs_jq + 0x6848);
		FIX_IMPORT(cellFiber, cellFiberPpuWaitSignal                , libspurs_jq + 0x6868);
		FIX_IMPORT(sysPrxForUser, _sys_strncmp                      , libspurs_jq + 0x6888);
		FIX_IMPORT(sysPrxForUser, _sys_snprintf                     , libspurs_jq + 0x68A8);
		FIX_IMPORT(sysPrxForUser, sys_lwcond_destroy                , libspurs_jq + 0x68C8);
		FIX_IMPORT(sysPrxForUser, sys_lwmutex_create                , libspurs_jq + 0x68E8);
		FIX_IMPORT(sysPrxForUser, _sys_memset                       , libspurs_jq + 0x6908);
		FIX_IMPORT(sysPrxForUser, _sys_printf                       , libspurs_jq + 0x6928);
		fix_import(sysPrxForUser, 0x9FB6228E                        , libspurs_jq + 0x6948);
		FIX_IMPORT(sysPrxForUser, sys_lwmutex_destroy               , libspurs_jq + 0x6968);
		FIX_IMPORT(sysPrxForUser, sys_lwcond_create                 , libspurs_jq + 0x6988);
		fix_import(sysPrxForUser, 0xE75C40F2                        , libspurs_jq + 0x69A8);

		fix_relocs(cellSpursJq, libspurs_jq, 0xFF70, 0x12370, 0xED00);
	});
#endif
}
Example #28
0
s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialogCallback> callback, vm::ptr<void> userData, vm::ptr<void> extParam)
{
	cellSysutil.Warning("cellMsgDialogOpen2(type=0x%x, msgString=*0x%x, callback=*0x%x, userData=*0x%x, extParam=*0x%x)", type, msgString, callback, userData, extParam);

	if (!msgString || strlen(msgString.get_ptr()) >= 0x200 || type & -0x33f8)
	{
		return CELL_MSGDIALOG_ERROR_PARAM;
	}

	switch (type & CELL_MSGDIALOG_TYPE_BUTTON_TYPE)
	{
	case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_NONE:
	{
		if (type & CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR)
		{
			return CELL_MSGDIALOG_ERROR_PARAM;
		}
		switch (type & CELL_MSGDIALOG_TYPE_PROGRESSBAR)
		{
		case CELL_MSGDIALOG_TYPE_PROGRESSBAR_NONE: break;
		case CELL_MSGDIALOG_TYPE_PROGRESSBAR_SINGLE: break;
		case CELL_MSGDIALOG_TYPE_PROGRESSBAR_DOUBLE: break;
		default: return CELL_MSGDIALOG_ERROR_PARAM;
		}
		break;
	}

	case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO:
	{
		switch (type & CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR)
		{
		case CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_YES: break;
		case CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_NO: break;
		default: return CELL_MSGDIALOG_ERROR_PARAM;
		}
		if (type & CELL_MSGDIALOG_TYPE_PROGRESSBAR)
		{
			return CELL_MSGDIALOG_ERROR_PARAM;
		}
		break;
	}

	case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK:
	{
		if (type & CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR)
		{
			return CELL_MSGDIALOG_ERROR_PARAM;
		}
		if (type & CELL_MSGDIALOG_TYPE_PROGRESSBAR)
		{
			return CELL_MSGDIALOG_ERROR_PARAM;
		}
		break;
	}

	default: return CELL_MSGDIALOG_ERROR_PARAM;
	}

	MsgDialogState old = msgDialogNone;
	if (!g_msg_dialog->state.compare_exchange_strong(old, msgDialogInit))
	{
		return CELL_SYSUTIL_ERROR_BUSY;
	}

	g_msg_dialog->wait_until = get_system_time() + 31536000000000ull; // some big value

	switch (type & CELL_MSGDIALOG_TYPE_PROGRESSBAR)
	{
	case CELL_MSGDIALOG_TYPE_PROGRESSBAR_DOUBLE: g_msg_dialog->progress_bar_count = 2; break;
	case CELL_MSGDIALOG_TYPE_PROGRESSBAR_SINGLE: g_msg_dialog->progress_bar_count = 1; break;
	default: g_msg_dialog->progress_bar_count = 0; break;
	}

	switch (type & CELL_MSGDIALOG_TYPE_SE_MUTE) // TODO
	{
	case CELL_MSGDIALOG_TYPE_SE_MUTE_OFF: break;
	case CELL_MSGDIALOG_TYPE_SE_MUTE_ON: break;
	}

	std::string msg = msgString.get_ptr();

	switch (type & CELL_MSGDIALOG_TYPE_SE_TYPE)
	{
	case CELL_MSGDIALOG_TYPE_SE_TYPE_NORMAL: cellSysutil.Warning("%s", msg); break;
	case CELL_MSGDIALOG_TYPE_SE_TYPE_ERROR: cellSysutil.Error("%s", msg); break;
	}

	g_msg_dialog->status = CELL_MSGDIALOG_BUTTON_NONE;

	CallAfter([type, msg]()
	{
		if (Emu.IsStopped())
		{
			g_msg_dialog->state.exchange(msgDialogNone);

			return;
		}

		g_msg_dialog->Create(type, msg);

		g_msg_dialog->state.exchange(msgDialogOpen);
	});

	while (g_msg_dialog->state == msgDialogInit)
	{
		if (Emu.IsStopped())
		{
			if (g_msg_dialog->state != msgDialogNone)
			{
				break;
			}

			CHECK_EMU_STATUS;
		}

		std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
	}

	thread_t(WRAP_EXPR("MsgDialog Thread"), [=]()
	{
		while (g_msg_dialog->state == msgDialogOpen || (s64)(get_system_time() - g_msg_dialog->wait_until) < 0)
		{
			if (Emu.IsStopped())
			{
				g_msg_dialog->state = msgDialogAbort;
				break;
			}
			std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
		}

		if (callback && g_msg_dialog->state != msgDialogAbort)
		{
			const s32 status = g_msg_dialog->status;

			Emu.GetCallbackManager().Register([=](CPUThread& CPU) -> s32
			{
				callback(static_cast<PPUThread&>(CPU), status, userData);
				return CELL_OK;
			});
		}

		CallAfter([]()
		{
			g_msg_dialog->Destroy();
			g_msg_dialog->state = msgDialogNone;
		});

	}).detach();

	return CELL_OK;
}
Example #29
0
PropertiesDialog::PropertiesDialog(wxWindow *parent, bool fileExistsOnDisk, int initialPage)
    : m_validatedPlural(-1), m_validatedLang(-1)
{
    wxXmlResource::Get()->LoadDialog(this, parent, "properties");

    m_team = XRCCTRL(*this, "team_name", wxTextCtrl);
    m_teamEmail = XRCCTRL(*this, "team_email", wxTextCtrl);
    m_project = XRCCTRL(*this, "prj_name", wxTextCtrl);
    m_language = XRCCTRL(*this, "language", LanguageCtrl);
    m_charset = XRCCTRL(*this, "charset", wxComboBox);
    m_basePath = XRCCTRL(*this, "basepath", wxTextCtrl);
    m_sourceCodeCharset = XRCCTRL(*this, "source_code_charset", wxComboBox);

    m_pluralFormsDefault = XRCCTRL(*this, "plural_forms_default", wxRadioButton);
    m_pluralFormsCustom = XRCCTRL(*this, "plural_forms_custom", wxRadioButton);
    m_pluralFormsExpr = XRCCTRL(*this, "plural_forms_expr", wxTextCtrl);
#if defined(__WXMSW__) && !wxCHECK_VERSION(3,1,0)
    m_pluralFormsExpr->SetFont(m_pluralFormsExpr->GetFont().Smaller());
#else
    m_pluralFormsExpr->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
#endif

    // my custom controls:
    m_keywords = new wxEditableListBox(this, -1, _("Additional keywords"));
    m_paths = new wxEditableListBox(this, -1, _("Paths"));
    m_excludedPaths = new wxEditableListBox(this, -1, _("Excluded paths"));

    m_paths->SetMinSize(wxSize(-1, 90));
    m_excludedPaths->SetMinSize(wxSize(-1, 90));

#ifdef __WXOSX__
    for (auto l: {m_keywords, m_paths, m_excludedPaths})
    {
        for (auto c: l->GetChildren())
        {
            c->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
            for (auto c2: c->GetChildren())
                c2->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
        }
    }
#endif // __WXOSX__

    wxXmlResource::Get()->AttachUnknownControl("keywords", m_keywords);
    wxXmlResource::Get()->AttachUnknownControl("paths", m_paths);
    wxXmlResource::Get()->AttachUnknownControl("excluded_paths", m_excludedPaths);

    // Controls setup:
    m_project->SetHint(_("Name of the project the translation is for"));
    m_pluralFormsExpr->SetHint(_("e.g. nplurals=2; plural=(n > 1);"));

    Layout();
    GetSizer()->SetSizeHints(this);

    if (!fileExistsOnDisk)
        DisableSourcesControls();

    auto nb = XRCCTRL(*this, "properties_notebook", wxNotebook);
    nb->SetSelection(initialPage);

    m_language->Bind(wxEVT_TEXT, &PropertiesDialog::OnLanguageChanged, this);
    m_language->Bind(wxEVT_COMBOBOX, &PropertiesDialog::OnLanguageChanged, this);

    m_pluralFormsDefault->Bind(wxEVT_RADIOBUTTON, &PropertiesDialog::OnPluralFormsDefault, this);
    m_pluralFormsCustom->Bind(wxEVT_RADIOBUTTON, &PropertiesDialog::OnPluralFormsCustom, this);
    m_pluralFormsExpr->Bind(
        wxEVT_UPDATE_UI,
        [=](wxUpdateUIEvent& e){ e.Enable(m_pluralFormsCustom->GetValue()); });
    m_pluralFormsExpr->Bind(
        wxEVT_TEXT,
        [=](wxCommandEvent& e){ m_validatedPlural = -1; e.Skip(); });
    Bind(wxEVT_UPDATE_UI,
        [=](wxUpdateUIEvent& e){ e.Enable(Validate()); },
        wxID_OK);
    CallAfter([=]{
        m_project->SetFocus();
    });
}
Example #30
0
void QuickFindBar::DoSearch(size_t searchFlags)
{
    if(!m_sci || m_sci->GetLength() == 0 || m_findWhat->GetValue().IsEmpty()) return;

    clGetManager()->SetStatusMessage(wxEmptyString);

    // Clear all search markers if desired
    if(EditorConfigST::Get()->GetOptions()->GetClearHighlitWordsOnFind()) {
        m_sci->SetIndicatorCurrent(MARKER_WORD_HIGHLIGHT);
        m_sci->IndicatorClearRange(0, m_sci->GetLength());
    }

    wxString find = m_findWhat->GetValue();
    bool fwd = searchFlags & kSearchForward;
    int flags = DoGetSearchFlags();

    // Since scintilla uses a non POSIX way of handling the paren
    // fix them
    if(flags & wxSTC_FIND_REGEXP) {
        DoFixRegexParen(find);
    }

    int curpos = m_sci->GetCurrentPos();
    int start = wxNOT_FOUND;
    int end = wxNOT_FOUND;
    m_sci->GetSelection(&start, &end);
    if((end != wxNOT_FOUND) && fwd) {
        if(m_sci->FindText(start, end, find, flags) != wxNOT_FOUND) {
            // Incase we searching forward and the current selection matches the search string
            // Clear the selection and set the caret position to the end of the selection
            m_sci->SetCurrentPos(end);
            m_sci->SetSelectionEnd(end);
            m_sci->SetSelectionStart(end);
        }
    }

    int pos = wxNOT_FOUND;
    if(fwd) {
        m_sci->SearchAnchor();
        pos = m_sci->SearchNext(flags, find);
        if(pos == wxNOT_FOUND) {
            clGetManager()->SetStatusMessage(_("Wrapped past end of file"), 1);
            m_sci->SetCurrentPos(0);
            m_sci->SetSelectionEnd(0);
            m_sci->SetSelectionStart(0);
            m_sci->SearchAnchor();
            pos = m_sci->SearchNext(flags, find);
        }
    } else {
        m_sci->SearchAnchor();
        pos = m_sci->SearchPrev(flags, find);
        if(pos == wxNOT_FOUND) {
            clGetManager()->SetStatusMessage(_("Wrapped past end of file"), 1);
            int lastPos = m_sci->GetLastPosition();
            m_sci->SetCurrentPos(lastPos);
            m_sci->SetSelectionEnd(lastPos);
            m_sci->SetSelectionStart(lastPos);
            m_sci->SearchAnchor();
            pos = m_sci->SearchPrev(flags, find);
        }
    }

    if(pos == wxNOT_FOUND) {
        // Restore the caret position
        m_sci->SetCurrentPos(curpos);
        m_sci->ClearSelections();
        CallAfter(&QuickFindBar::DoSetCaretAtEndOfText);
        return;
    }
    DoEnsureLineIsVisible();
    CallAfter(&QuickFindBar::DoSetCaretAtEndOfText);
}