Esempio n. 1
0
 def loc_from_view_info(self,
                        view_type,
                        window_num,
                        tabbed_view_id,
                        view,
                        pos=-1,
                        session_name=""):
     """Create a Location instance from the given view info.
     
     @param view_type {string}
     @param window_num {int} the identifier for the view's Komodo window.
     @param tabbed_view_id {int} the identifier for the multi-tabbed view
         containing `view`.
     @param view {koIView} a Komodo view.
     @param pos {int} position of view to record
         ignored for some non-editor views, conventionally -1
     @param session_name {str} the current history session. Default is the
         empty string.
     @returns {Location}
     """
     if view.koDoc.file:
         uri = view.koDoc.file.URI
     elif view_type == 'editor':
         # Internal URI scheme used for unsaved buffers
         uri = "kotemporary://" + view.uid + "/" + view.koDoc.displayPath
     else:
         uri = ""
     if view_type == 'editor':
         view = view.QueryInterface(components.interfaces.koIScintillaView)
         scimoz = view.scimoz
         if pos == -1:
             pos = scimoz.currentPos
         line = scimoz.lineFromPosition(pos)
         loc = Location(uri, line, scimoz.getColumn(pos), view_type)
         loc.marker_handle = scimoz.markerAdd(line, self.MARKNUM_HISTORYLOC)
         ciBuf = view.koDoc.ciBuf
         if ciBuf and hasattr(ciBuf, "curr_section_from_line"):
             try:
                 section = ciBuf.curr_section_from_line(line + 1)
             except COMException:
                 # See bug 82776.  Don't know why we get this when
                 # ctrl-tabbing across a tab group.
                 log.exception("can't get the section")
             else:
                 if section:
                     loc.section_title = section.title
     else:
         loc = Location(uri, -1, -1, view_type)
     loc.window_num = window_num
     loc.tabbed_view_id = tabbed_view_id
     loc.session_name = session_name
     return loc
Esempio n. 2
0
 def loc_from_view_info(self, view_type,
                        window_num, tabbed_view_id, view,
                        pos=-1, session_name=""):
     """Create a Location instance from the given view info.
     
     @param view_type {string}
     @param window_num {int} the identifier for the view's Komodo window.
     @param tabbed_view_id {int} the identifier for the multi-tabbed view
         containing `view`.
     @param view {koIView} a Komodo view.
     @param pos {int} position of view to record
         ignored for some non-editor views, conventionally -1
     @param session_name {str} the current history session. Default is the
         empty string.
     @returns {Location}
     """
     if view.koDoc.file:
         uri = view.koDoc.file.URI
     elif view_type == 'editor':
         # Internal URI scheme used for unsaved buffers
         uri = "kotemporary://" + view.uid + "/" + view.koDoc.displayPath;
     else:
         uri = ""
     if view_type == 'editor':
         view = view.QueryInterface(components.interfaces.koIScintillaView)
         scimoz = view.scimoz
         if pos == -1:
             pos = scimoz.currentPos
         line = scimoz.lineFromPosition(pos)
         loc = Location(uri, line,
                        scimoz.getColumn(pos),
                        view_type)
         loc.marker_handle = scimoz.markerAdd(line, self.MARKNUM_HISTORYLOC)
         ciBuf = view.koDoc.ciBuf
         if ciBuf and hasattr(ciBuf, "curr_section_from_line"):
             try:
                 section = ciBuf.curr_section_from_line(line + 1)
             except COMException:
                 # See bug 82776.  Don't know why we get this when
                 # ctrl-tabbing across a tab group.
                 log.exception("can't get the section")
             else:
                 if section:
                     loc.section_title = section.title
     else:
         loc = Location(uri, -1, -1, view_type)
     loc.window_num = window_num
     loc.tabbed_view_id = tabbed_view_id
     loc.session_name = session_name
     return loc
Esempio n. 3
0
    def loc_from_view_info(self,
                           view_type,
                           window_num,
                           tabbed_view_id,
                           view,
                           pos=-1,
                           session_name="",
                           callback=None):
        """Create a Location instance from the given view info.
        
        @param view_type {string}
        @param window_num {int} the identifier for the view's Komodo window.
        @param tabbed_view_id {int} the identifier for the multi-tabbed view
            containing `view`.
        @param view {koIView} a Komodo view.
        @param pos {int} position of view to record
            ignored for some non-editor views, conventionally -1
        @param session_name {str} the current history session. Default is the
            empty string.
        @param callback {callable} The callback to invoke when the location has
            been found; takes a single Location argument.
        """
        if view.koDoc.file:
            uri = view.koDoc.file.URI
        elif view_type == 'editor':
            # Internal URI scheme used for unsaved buffers
            uri = "kotemporary://" + view.uid + "/" + view.koDoc.displayPath
        else:
            uri = ""

        def on_have_location(section=None):
            if section:
                loc.section_title = section.title
            loc.window_num = window_num
            loc.tabbed_view_id = tabbed_view_id
            loc.session_name = session_name
            if hasattr(callback, "onHaveLocation"):
                callback.onHaveLocation(loc)
            elif loc:
                callback(loc)

        pending = False
        if view_type == 'editor':
            view = view.QueryInterface(components.interfaces.koIScintillaView)
            scimoz = view.scimoz
            if pos == -1:
                pos = scimoz.currentPos
            line = scimoz.lineFromPosition(pos)
            loc = Location(uri, line, scimoz.getColumn(pos), view_type)
            loc.marker_handle = scimoz.markerAdd(line, self.MARKNUM_HISTORYLOC)
            ciBuf = view.koDoc.ciBuf
            if ciBuf and hasattr(ciBuf, "section_from_line"):
                try:
                    ciBuf.section_from_line(line + 1, ciBuf.SECTION_CURRENT,
                                            False, on_have_location)
                except COMException:
                    # See bug 82776.  Don't know why we get this when
                    # ctrl-tabbing across a tab group.
                    log.exception("can't get the section")
                else:
                    pending = True
        else:
            loc = Location(uri, -1, -1, view_type)
        if not pending:
            on_have_location()
Esempio n. 4
0
    def loc_from_view_info(self, view_type,
                           window_num, tabbed_view_id, view,
                           pos=-1, session_name="",
                           callback=None):
        """Create a Location instance from the given view info.
        
        @param view_type {string}
        @param window_num {int} the identifier for the view's Komodo window.
        @param tabbed_view_id {int} the identifier for the multi-tabbed view
            containing `view`.
        @param view {koIView} a Komodo view.
        @param pos {int} position of view to record
            ignored for some non-editor views, conventionally -1
        @param session_name {str} the current history session. Default is the
            empty string.
        @param callback {callable} The callback to invoke when the location has
            been found; takes a single Location argument.
        """
        if view.koDoc.file:
            uri = view.koDoc.file.URI
        elif view_type == 'editor':
            # Internal URI scheme used for unsaved buffers
            uri = "kotemporary://" + view.uid + "/" + view.koDoc.displayPath;
        else:
            uri = ""

        def on_have_location(section=None):
            if section:
                loc.section_title = section.title
            loc.window_num = window_num
            loc.tabbed_view_id = tabbed_view_id
            loc.session_name = session_name
            if hasattr(callback, "onHaveLocation"):
                callback.onHaveLocation(loc)
            elif loc:
                callback(loc)

        pending = False
        if view_type == 'editor':
            view = view.QueryInterface(components.interfaces.koIScintillaView)
            scimoz = view.scimoz
            if pos == -1:
                pos = scimoz.currentPos
            line = scimoz.lineFromPosition(pos)
            loc = Location(uri, line,
                           scimoz.getColumn(pos),
                           view_type)
            loc.marker_handle = scimoz.markerAdd(line, self.MARKNUM_HISTORYLOC)
            ciBuf = view.koDoc.ciBuf
            if ciBuf and hasattr(ciBuf, "section_from_line"):
                try:
                    ciBuf.section_from_line(line + 1,
                                            ciBuf.SECTION_CURRENT,
                                            False,
                                            on_have_location)
                except COMException:
                    # See bug 82776.  Don't know why we get this when
                    # ctrl-tabbing across a tab group.
                    log.exception("can't get the section")
                else:
                    pending = True
        else:
            loc = Location(uri, -1, -1, view_type)
        if not pending:
            on_have_location()