Esempio n. 1
0
def main():
    filename = editor.get_path()
    if not filename:
        return

    if not filename.endswith('.py'):
        return

    text = editor.get_text()
    if not text:
        return

    def scroll_to_node(node, shift_enter):
        source.scroll_to_line(node.line)

    v = PickerView()
    v.name = 'Outline'
    v.datasource = OutlineDataSource(text, os.path.basename(filename))
    v.shift_enter_enabled = False
    v.help_label.text = (
        '⇅ - select • Enter - scroll to location'
        '\n'
        'Esc - close • Cmd . - close with Apple smart keyboard')
    v.textfield.placeholder = 'Start typing to filter nodes...'
    v.did_select_item_action = scroll_to_node
    v.present('sheet')
    v.wait_modal()
Esempio n. 2
0
def main():
    def run_wrench_item(item, shift_enter):
        item.action_info.run(delay=1.0)

    v = PickerView()
    v.name = 'Action Quickly...'
    v.datasource = ActionPickerDataSource()
    v.shift_enter_enabled = False
    v.help_label.text = (
        '⇅ - select • Enter - run action item'
        '\n'
        'Esc - close • Cmd . - Close with Apple smart keyboard')
    v.textfield.placeholder = 'Start typing to filter wrench items...'
    v.did_select_item_action = run_wrench_item
    v.present('sheet')
    v.wait_modal()
Esempio n. 3
0
def _select_location(definitions):
    def action(item, shift_enter):
        _show_documentation(item.definition)

    v = PickerView()
    v.name = '{} definitions'.format(definitions[0].name)
    v.datasource = LocationDataSource(definitions)

    v.shift_enter_enabled = False
    v.help_label.text = (
        '⇅ - select • Enter - show documentation'
        '\n'
        'Esc - close • Cmd . - close with Apple smart keyboard')
    v.textfield.placeholder = 'Start typing to filter location...'
    v.did_select_item_action = action
    v.present('sheet')
    v.wait_modal()
Esempio n. 4
0
def _select_location(definitions):
    def open_location(item, shift_enter):
        tab.open_file(item.path, line=item.line)

    v = PickerView()
    v.name = '{} usages'.format(definitions[0].name)
    v.datasource = LocationDataSource(definitions)

    v.shift_enter_enabled = False
    v.help_label.text = (
        '⇅ - select • Enter - open file and scroll to location'
        '\n'
        'Esc - close • Cmd . - close with Apple smart keyboard')
    v.textfield.placeholder = 'Start typing to filter usages...'
    v.did_select_item_action = open_location
    v.present('sheet')
    v.wait_modal()
Esempio n. 5
0
def main():
    def allow_file(root, name):
        return path.is_python_file(name) and not name.startswith('.')

    def run_script(item, shift_enter):
        script.run_script(item.file_path, full_path=True, delay=1.0)

    kwargs = {'ignore_folders': _ignore_folders(), 'allow_file': allow_file}

    v = PickerView()
    v.name = 'Run Quickly...'
    v.datasource = FilePickerDataSource(**kwargs)
    v.shift_enter_enabled = False
    v.help_label.text = (
        '⇅ - select • Enter - run Python script'
        '\n'
        'Esc - close • Cmd . - close with Apple smart keyboard')
    v.textfield.placeholder = 'Start typing to filter scripts...'
    v.did_select_item_action = run_script
    v.present('sheet')
    v.wait_modal()
Esempio n. 6
0
def main():
    def allow_file(root, name):
        return not name.startswith('.')

    def open_file(item, shift_enter):
        new_tab = not shift_enter
        tab.open_file(item.file_path, new_tab=new_tab)

    kwargs = {'ignore_folders': _ignore_folders(), 'allow_file': allow_file}

    v = PickerView()
    v.name = 'Open Quickly...'
    v.datasource = FilePickerDataSource(**kwargs)
    v.shift_enter_enabled = True
    v.help_label.text = (
        '⇅ - select • Enter - open file in new tab • Shift + Enter - open file in current tab'
        '\n'
        'Esc - close • Cmd . - close with Apple smart keyboard')
    v.textfield.placeholder = 'Start typing to filter files...'
    v.did_select_item_action = open_file
    v.present('sheet')
    v.wait_modal()