Exemplo n.º 1
0
void EditFiles::onIdle()
    {
    idleHighlight();
    for(auto &fv : mFileViews)
        {
        if(fv->mDesiredLine != -1)
            {
#if(DBG_EDITF)
            sDbgFile.printflush("onIdle file %s line %d\n",
                    fv->getFileEditView().getFileName().c_str(),
                    fv->mDesiredLine);
#endif
            fv->mFileView.gotoLine(fv->mDesiredLine);
            gtk_widget_grab_focus(GTK_WIDGET(fv->mFileView.getTextView()));
            fv->mDesiredLine = -1;
            }
        }
    }
Exemplo n.º 2
0
extern "C" G_MODULE_EXPORT gboolean on_DebugViewVariable_activate(GtkWidget *widget,
        GdkEvent *event, gpointer user_data)
    {
    if(sEditFiles && sEditFiles->checkDebugger())
        {
        FileEditView const *view = sEditFiles->getEditView();
        if(view)
            {
            sEditFiles->showInteractNotebookTab("Data");
            sEditFiles->getDebugger().startGetVariable(
                    Gui::getSelectedText(view->getTextView()));
#if(DBG_EDITF)
    const char *str = Gui::getSelectedText(view->getTextView());
    sDbgFile.printflush("ViewVar %s\n", str);
#endif
            }
        }
    return false;
    }
Exemplo n.º 3
0
void EditFiles::viewFile(OovStringRef const fn, int lineNum)
    {
    FilePath fp;

    fp.getAbsolutePath(fn, FP_File);
    auto iter = std::find_if(mFileViews.begin(), mFileViews.end(),
        [fp](std::unique_ptr<ScrolledFileView> const &fv) -> bool
        { return fv->mFilename.comparePaths(fp) == 0; });
    if(iter == mFileViews.end())
        {
        GtkNotebook *book = nullptr;
        if(putInMainWindow(fn))
            book = mSourceBook;
        else
            book = mHeaderBook;
        if(book)
            {
            GtkWidget *scrolled = gtk_scrolled_window_new(nullptr, nullptr);
            GtkWidget *editView = gtk_text_view_new();

            /// @todo - use make_unique when supported.
            ScrolledFileView *scrolledView = new ScrolledFileView(mDebugger);
            scrolledView->mFileView.init(GTK_TEXT_VIEW(editView), this);
            OovStatus status = scrolledView->mFileView.openTextFile(fp);
            if(status.needReport())
                {
                OovString err = "Unable to open file ";
                err += fp;
                status.report(ET_Error, err);
                }
            scrolledView->mScrolled = GTK_SCROLLED_WINDOW(scrolled);
            scrolledView->mFilename = fp;

            gtk_container_add(GTK_CONTAINER(scrolled), editView);
            Gui::appendPage(book, scrolled,
                    newTabLabel(fp.getName(), scrolledView->getViewTopParent()));
            gtk_widget_show_all(scrolled);
            scrolledView->mLeftMargin.setupMargin(GTK_TEXT_VIEW(editView));

            // Set up the windows to draw the line numbers in the left margin.
            // GTK has changed, and different setups are required for different
            // versions of GTK.
            // This is not allowed for a text view
            //          gtk_widget_set_app_paintable(editView, true);
#if(USE_DRAW_LAYER)
            overrideDrawLayer(editView);
            // If the left window is not created, errors display, "Attempt to
            // convert text buffer coordinates to coordinates for a nonexistent
            // buffer or private child window of GtkTextView". So create a
            // window that is only one pixel wide, and draw the line numbers
            // on the main text view window.
            gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(editView),
                    GTK_TEXT_WINDOW_LEFT, 1);
            gtk_text_view_set_left_margin(GTK_TEXT_VIEW(editView),
                    scrolledView->mLeftMargin.getMarginWidth());
#else
            // The margin is drawn on the border window.
            gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(editView),
                    GTK_TEXT_WINDOW_LEFT, scrolledView->mLeftMargin.getMarginWidth());
            g_signal_connect(editView, "draw", G_CALLBACK(onTextViewDraw), scrolledView);
#endif

            g_signal_connect(editView, "focus_in_event",
                    G_CALLBACK(on_EditFiles_focus_in_event), NULL);
            g_signal_connect(editView, "key_press_event",
                    G_CALLBACK(on_EditFiles_key_press_event), NULL);
            g_signal_connect(editView, "button_press_event",
                    G_CALLBACK(on_EditFiles_button_press_event), NULL);
            mFileViews.push_back(std::unique_ptr<ScrolledFileView>(scrolledView));
#if(DBG_EDITF)
        sDbgFile.printflush("viewFile count %d, line %d\n", mFileViews.size(), lineNum);
#endif
            iter = mFileViews.end()-1;
            }
        }
    GtkNotebook *notebook = (*iter)->getBook();
    if(notebook)
        {
        int pageIndex = getPageNumber(notebook, (*iter)->getTextView());
        Gui::setCurrentPage(notebook, pageIndex);
        // focus is set after the screen is displayed by onIdle
//      gtk_widget_grab_focus(GTK_WIDGET((*iter).getTextView()));
#if(DBG_EDITF)
        sDbgFile.printflush("viewFile %d\n", pageIndex);
#endif
        if(lineNum > 1)
            {
            (*iter)->mDesiredLine = lineNum;
            }
        }
    }
Exemplo n.º 4
0
void logProc(char const *str, const void *ptr, int val)
    {
    sDebugQueue.printflush("%s %p %d\n", str, ptr, val);
    }