Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
tab.open_file and new arg line
Browse files Browse the repository at this point in the history
  • Loading branch information
zrzka committed Oct 4, 2017
1 parent 7e4e676 commit e15b851
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Find usages contains symbol name in the dialog title
* Jump to definition contains symbol name in the dialog title
* Show documentation contains symbol name in the dialog title
* `tab.open_file` has new `line` argument
* Jump to definition, Find usages utilizes `tab.open_file` instead of `editor`'s one


## 1.0.2 (2017-10-01)
Expand Down
10 changes: 8 additions & 2 deletions blackmamba/ide/tab.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!python3

from objc_util import on_main_thread, ObjCClass, sel

import blackmamba.ide.source as source
import ui

_PASlidingContainerViewController = ObjCClass('PASlidingContainerViewController')
_PA2UniversalTextEditorViewController = ObjCClass('PA2UniversalTextEditorViewController')
Expand Down Expand Up @@ -177,7 +178,7 @@ def get_paths():
return [str(tab.filePath()) for tab in tabs.tabViewControllers()]


def open_file(path, new_tab=True):
def open_file(path, new_tab=True, line=None):
index = None
paths = get_paths()

Expand All @@ -192,3 +193,8 @@ def open_file(path, new_tab=True):
editor.open_file(path, new_tab=new_tab)
else:
select_tab(index)

if line is not None:
def scroll():
source.scroll_to_line(line)
ui.delay(scroll, 0.2)
12 changes: 1 addition & 11 deletions blackmamba/script/find_usages.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@
import blackmamba.ide.source as source


def _open_and_scroll(path, line):
if editor.get_path() == path:
source.scroll_to_line(line)
else:
def scroll():
source.scroll_to_line(line)
editor.open_file(path, new_tab=True)
ui.delay(scroll, 0.2)


class LocationPickerItem(PickerItem):
def __init__(self, path, line, display_folder):
super().__init__(
Expand Down Expand Up @@ -75,7 +65,7 @@ def __init__(self, definitions):

def _select_location(definitions):
def open_location(item, shift_enter):
_open_and_scroll(item.path, item.line)
tab.open_file(item.path, line=item.line)

v = PickerView()
v.name = '{} usages'.format(definitions[0].name)
Expand Down
14 changes: 2 additions & 12 deletions blackmamba/script/jump_to_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@
import blackmamba.ide.tab as tab


def _open_and_scroll(path, line):
if editor.get_path() == path:
source.scroll_to_line(line)
else:
def scroll():
source.scroll_to_line(line)
tab.open_file(path, new_tab=True)
ui.delay(scroll, 0.2)


class LocationPickerItem(PickerItem):
def __init__(self, path, line, display_folder, definition):
super().__init__(
Expand Down Expand Up @@ -77,7 +67,7 @@ def __init__(self, definitions):
def _select_location(definitions):
def open_location(item, shift_enter):
definition = item.definition
_open_and_scroll(definition.module_path, definition.line)
tab.open_file(definition.module_path, line=definition.line)

v = PickerView()
v.name = '{} definitions'.format(definitions[0].name)
Expand Down Expand Up @@ -130,7 +120,7 @@ def main():
return

if len(definitions) == 1:
_open_and_scroll(definitions[0].module_path, definitions[0].line)
tab.open_file(definitions[0].module_path, line=definitions[0].line)
else:
_select_location(definitions)

Expand Down

0 comments on commit e15b851

Please sign in to comment.