ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Quick​Search​Enhanced

by shagabutdinov ST2/ST3

Sublime's quick_search api wrapper

Details

Installs

  • Total 3K
  • Win 1K
  • OS X 742
  • Linux 578
Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5
Windows 2 7 1 1 2 2 1 7 4 3 2 2 0 0 1 3 3 2 1 0 1 1 1 1 5 4 1 1 0 1 2 2 6 2 2 4 4 6 6 0 2 1 4 2 3 1
OS X 2 4 2 1 0 2 0 0 2 1 2 1 0 1 0 1 2 1 1 1 0 1 2 0 0 3 0 0 2 1 2 1 2 0 0 2 2 0 2 0 1 0 1 3 3 0
Linux 3 1 0 1 1 0 2 0 0 1 0 1 1 0 2 0 0 0 2 0 0 0 1 1 0 0 1 0 2 0 1 2 1 0 1 1 1 0 0 2 0 0 0 1 0 1

Readme

Source
raw.​githubusercontent.​com

Sublime QuickSearchEnhanced plugin

Api for other plugins to use sublime's quick_search in bit better way.

Installation

This plugin is part of sublime-enhanced plugin set. You can install sublime-enhanced and this plugin will be installed automatically.

If you would like to install this package separately check “Installing packages separately” section of sublime-enhanced package.

Dependencies

None

API

There are two usable classes in module:

  • QuickSearches - container for opened panels; this class is preinstanciated under “panels” variable.

  • QuickSearch - quick search panel

Quick search panel are create through “create” function. Panels are stackable (new panel hides previos when showed, and shows previous when closed).

Note that inproper code that runned in callbacks can crash sublime (due to its internal bugs). So use this plugin with care.

QuickSearches.create(values = [], open = None, close = None, preview = None, text = '', callers = [], on_create = None, index = 0)

Creates a quick search panel.

Arguments:

  • values - list of values in following format:

    • [string, string, …] - list of strings.
    • [[value, line1, line2, …], [value, line1, line2, …]] - list of lists; value - any value; line1, line2, lineN - strings; note that count of lines always should be the same otherwise unexpected behavior of sublime are expected.
  • open(QuickSearch) - open callback; callback called when user hits enter in list; callback receive QuickSearch instance as argument.

  • close(QuickSearch) - close callback; callback called when user hit “escape” or “enter” (panel is closed).

  • preview(QuickSearch) - preview callback; callback called when user selects an item in list.

  • text - initial text that is entered in panel.

  • callers - list of callers to obtain panel instance when issuing commands over panel in following format: [[name, object], …] where name is name of caller and object - instance of caller; this is usefull when you need to check that search panel contains specific information or issues command on instance that has opened the panel

  • index - initial selected index

Result:

QuickSearch; created panel; note that panel have to be showed after it will be created by issuing .show() command;

Example:

from QuickSearchEnhanced import quick_search
  panel = quick_search.panels.create(
    ['a', 'b', 'c'],
    lambda panel: print(panel.get_current_value())
  )
QuickSearches.close_all()

Closes all panels.

QuickSearches.remove(panel)

Removes given panel from stack.

Arguments:

  • panel - QuickSearch; panel to remove
QuickSearches.get_current()

Returns currently opened panel (QuickSearch)

QuickSearch.show()

Shows panel. Note that it'll hide currently opened panel.

QuickSearch.get_values()

Get all values that are in search panel.

QuickSearch.set_values(values)

Set new values to panel.

QuickSearch.set_text(text)

Set new text to panel.

QuickSearch.get_callers()

Get all callers of search panel. See “callers” argument in QuickSearches.create() above for information. Returns list of callers.

QuickSearch.get_caller(name)

Returns caller that has specified name. If no caller found returns None.

QuickSearch.get_current_index()

Returns currently selected index.

QuickSearch.get_current_value()

Returns currenly selected value. If no value selected returns None.

QuickSearch.get_current_description()

Returns list currently selected desciptions (lines).

QuickSearch.get_current_text()

Returns current text.

QuickSearch.get_panel()

Returns underlying view of opened panel.

QuickSearch.get_opener()

Returns view that was focused when panel was showed.

QuickSearch.is_visible()

Tells whether panel is visible or not.

QuickSearch.close(index = -1, call = True)

Closes the panel. Panel will be removed from current panels stack.

Arguments:

index - integer; index of value; if index == -1 than last selected index will be used.

call - boolean; if True then open callback will be called.

QuickSearch.hide()

Hide the panel. Panel can be showed later using show() method. Panel will be not removed from panels stack.

QuickSearch.refresh()

Refreshes contents of panel. If one of callers responds to “refresh” method than “refresh” method of caller that earlier in stack will be called before panel will bee redrawed.