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
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