<s> from . common import * <EOL> class Bookmark : <EOL> def __init__ ( self , uid , name , window , activeView ) : <EOL> self . uid = int ( uid ) <EOL> self . name = str ( name ) <EOL> self . filePath = str ( activeView . file_name ( ) ) <EOL> self . projectPath = getCurrentProjectPath ( window ) <EOL> region = getCurrentLineRegion ( activeView ) <EOL> self . regionA = int ( region . a ) <EOL> self . regionB = int ( region . b ) <EOL> self . group = getCurrentActiveGroup ( window ) <EOL> self . lineStr = activeView . substr ( region ) <EOL> cursorPos = activeView . sel ( ) [ <NUM_LIT:0> ] . begin ( ) <EOL> self . lineNumber = activeView . rowcol ( cursorPos ) [ <NUM_LIT:0> ] <EOL> self . bufferID = activeView . buffer_id ( ) <EOL> def getBufferID ( self ) : <EOL> return self . bufferID <EOL> def getName ( self ) : <EOL> return self . name <EOL> def getUid ( self ) : <EOL> return self . uid <EOL> def getRegion ( self ) : <EOL> return sublime . Region ( self . regionA , self . regionB ) <EOL> def getFilePath ( self ) : <EOL> return self . filePath <EOL> def getProjectPath ( self ) : <EOL> return self . projectPath <EOL> def getLineNumber ( self ) : <EOL> return self . lineNumber <EOL> def getLineStr ( self ) : <EOL> return self . lineStr <EOL> def getGroup ( self ) : <EOL> return self . group <EOL> def setLineStr ( self , newLineStr ) : <EOL> self . lineStr = str ( newLineStr ) <EOL> def setRegion ( self , region ) : <EOL> self . regionA = region . a <EOL> self . regionB = region . b <EOL> def setGroup ( self , group ) : <EOL> self . group = int ( group ) <EOL> def isTemporary ( self ) : <EOL> return self . filePath == "<STR_LIT:None>" <EOL> def goto ( self , window ) : <EOL> view = getBookmarkView ( window , self ) <EOL> assert ( view is not None ) <EOL> region = self . getRegion ( ) <EOL> view . show_at_center ( region ) <EOL> bookmarkRegionMid = <NUM_LIT:0.5> * ( region . begin ( ) + region . end ( ) ) <EOL> moveRegion = sublime . Region ( bookmarkRegionMid , bookmarkRegionMid ) <EOL> view . sel ( ) . clear ( ) <EOL> view . sel ( ) . add ( moveRegion ) <EOL> region = self . getRegion ( ) <EOL> line = view . substr ( region ) <EOL> return isLineEmpty ( line ) <EOL> def isMyView ( self , window , view ) : <EOL> if view is None : <EOL> return False <EOL> bufferID = view . buffer_id ( ) <EOL> filePath = view . file_name ( ) <EOL> if self . isTemporary ( ) : <EOL> return self . getBufferID ( ) == bufferID <EOL> else : <EOL> return self . getFilePath ( ) == filePath <EOL> def updateData ( self , window , myView ) : <EOL> regions = myView . get_regions ( str ( self . uid ) ) <EOL> if len ( regions ) == <NUM_LIT:0> : <EOL> return <EOL> lines = myView . split_by_newlines ( regions [ <NUM_LIT:0> ] ) <EOL> region = lines [ <NUM_LIT:0> ] <EOL> self . regionA = region . a <EOL> self . regionB = region . b <EOL> self . lineStr = myView . substr ( region ) <EOL> self . group = window . get_view_index ( myView ) [ <NUM_LIT:0> ] <EOL> def getBookmarkView ( window , bookmark ) : <EOL> view = None <EOL> if bookmark . isTemporary ( ) : <EOL> view = getViewByBufferID ( window , bookmark . getBufferID ( ) ) <EOL> window . focus_view ( view ) <EOL> else : <EOL> view = window . open_file ( bookmark . getFilePath ( ) ) <EOL> assert view is not None <EOL> return view <EOL> def shouldRemoveTempBookmark ( window , bookmark ) : <EOL> assert ( bookmark . isTemporary ( ) ) <EOL> return getViewByBufferID ( window , bookmark . getBufferID ( ) ) is None <EOL> def moveBookmarkToGroup ( window , bookmark , group ) : <EOL> def moveViewToGroup ( window , view , group ) : <EOL> ( viewGroup , viewIndex ) = window . get_view_index ( view ) <EOL> if group != viewGroup or viewGroup == - <NUM_LIT:1> or viewIndex == - <NUM_LIT:1> : <EOL> if len ( window . views_in_group ( viewGroup ) ) == <NUM_LIT:1> : <EOL> window . focus_group ( viewGroup ) <EOL> window . new_file ( ) <EOL> newIndex = len ( window . views_in_group ( group ) ) <EOL> window . set_view_index ( view , group , newIndex ) <EOL> else : <EOL> pass <EOL> view = None <EOL> if bookmark . isTemporary ( ) : <EOL> view = getViewByBufferID ( window , bookmark . getBufferID ( ) ) <EOL> assert ( view is not None ) <EOL> else : <EOL> view = window . open_file ( bookmark . getFilePath ( ) ) <EOL> assert ( view is not None ) <EOL> moveViewToGroup ( window , view , group ) </s>
