Some good news - I have partial mapping added - I’m working on a larger update but if you want better support for it right now…
Edit xcodemapper.py and add these: to the XCodeMapper base class…
##
## Returns the Character Offset from the start of the file to the beginning of the row + num chars to the chosen column
##
def GetSublimeViewTextPoint( self, _row = 0, _col = 0 ):
return self.GetMappedFileView( ).text_point( _row - 1, _col )
##
## Returns a region from the lines provided
##
def GetSublimeViewRegionByLines( self, _line_number, _line_number_2 ):
##
_file_view = self.GetMappedFileView( )
_region = sublime.Region( self.GetSublimeViewTextPoint( _line_number ), self.GetSublimeViewTextPoint( _line_number ) )
return _file_view.line( _region )
##
## Returns the region of a single entire-line
##
def GetSublimeViewLineRegion( self, _line_number ):
## Grabs the starting point of the line
_start = self.GetSublimeViewTextPoint( _line_number )
## Grabs the starting point of the line after it - then subtracts 1 char which should put us on the previous line at the end...
_end = self.GetSublimeViewTextPoint( _line_number + 1 ) - 1
return sublime.Region( _start, _end )
##
## Return the line number from a provided Region Tuple, or from the char value...
##
def GetSublimeViewLineNumberByRegion( self, _region ):
return self.GetMappedFileView( ).rowcol( _region.begin( ) )[ 0 ] + 1
These work together with the already existing Symbols mapping system ( you will need to edit Run func in the main XCodeMapper so that )
## Process symbols for the file...
if ( _file_view != None ):
self.MappingFileSymbols( _file_view, _file_view.symbols( ) )
is just above the for loop for the lines so
## Process symbols for the file...
if ( _file_view != None ):
self.MappingFileSymbols( _file_view, _file_view.symbols( ) )
## For Each Line...
for _line_number, _line in enumerate( _lines, 1 ):
which ensures the view etc… is set…
Then add
##
## Callback - these are the symbols from the file we're currently editings symbols( ) from the view - ie all extracted symbols from Sublime Text...
## In Short: If working this should give us all of the information from the Command Palette when we look at @, :, etc.. for function names and everything... A potentially almost perfect way to create a universal mapper...
##
## Task: Allow symbols to be processed through the AddSyntax processor ( Make a syntax processor function outside of Run to do this ) - Then the full-line of code can be grabbed from the symbols SublimeText provides us and we'll have a basic universal mapping system....
##
def OnMappingFileSymbols( self, _view, _symbols ):
## pass
print( ' >> Symbols: ' + str( _symbols ) )
## Symbols also don't give their function prefix...
## if ( _code.startswith( 'def' ):
## Symbols appear in a list, in a tuple with a region and the symbol...[((515, 525), 'PANEL:Init'), ((891, 910), 'PANEL:ControlValues'), ((1159, 1178), 'PANEL:PerformLayout')]
## So for each entry
for _entry in _symbols:
## Tuples and lists use numerical indices
## Grab the region object ( chars from start of file to X, and Total Chars in Region + X )
_region = _entry[ 0 ]
## Grab the partial code we're given - we can grab the full line using a helper function...
_code = _entry[ 1 ]
## Grab the line number using another helper...
_line_number = self.GetSublimeViewLineNumberByRegion( _region )
## _line_number = 1
## Grab the line code by another helper...
_line = self.GetFileDataByLine( _line_number )
_file_view = self.GetMappedFileView( )
_scope_name = _file_view.scope_name( _region.begin( ) )
## Note - Symbols use regions meaning the starting char of from the entire code blob to the end... not line numbering so this has to be calculated...
## Since other info is also lost we can really only guess at the data unless we check the file and look at other infomration...
## self.AddEntry( CATEGORY_FUNCTION, _line_number, _code, _depth, _mode, _pattern, _class_cat )
self.AddSimpleEntry( CATEGORY_DEFINITION, _line_number, _line.strip( ), 0 )
To your mapper - since the old version doesn’t have CATEGORY_SYMBOLS that other one will work… This uses Sublime Text Symbols meaning it will mean universal mapping for most languages… Or at least close to it…
The next update is pretty large - moves everything into a single folder, still adding sublime-settings support, and a ton of extra things,…
If you want - OnMappingfileSymbols exists without the latest update but the helper function won’t exist - so for _entry in _symbols: will return ( Region, String ) or Tuple with Region and String - Region.begin( ) or .a and Region.end( ) or .b for the first and second element to it… the string is what it finds from the command palette @ menu … I’m working on adding the others and getting more info…
Increased resolution will mean I can make a super light-weight universal mapper based on the back-end systems and the extension addon for those who want more control…