Пример #1
0
 def set_tabs_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id,
                                               UI_ELEMENT_TABS, flag)
Пример #2
0
 def set_menu_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id,
                                               UI_ELEMENT_MENU, flag)
Пример #3
0
 def set_minimap_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id,
                                               UI_ELEMENT_MINIMAP, flag)
Пример #4
0
 def set_status_bar_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id,
                                               UI_ELEMENT_STATUS_BAR, flag)
Пример #5
0
 def set_menu_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_MENU, flag)
Пример #6
0
 def set_sidebar_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id,
                                               UI_ELEMENT_SIDE_BAR, flag)
Пример #7
0
 def set_status_bar_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_STATUS_BAR, flag)
Пример #8
0
 def set_tabs_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_TABS, flag)
Пример #9
0
 def set_sidebar_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_SIDE_BAR, flag)
Пример #10
0
 def set_minimap_visible(self, flag):
     sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_MINIMAP, flag)
Пример #11
0
 def set_menu_visible(self, flag):        sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_MENU, flag)
 def folders(self):        return sublime_api.window_folders(self.window_id)
Пример #12
0
 def set_status_bar_visible(self, flag):        sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_STATUS_BAR, flag)
 def get_tabs_visible(self):        return sublime_api.window_is_ui_element_visible(self.window_id, UI_ELEMENT_TABS)
Пример #13
0
 def set_minimap_visible(self, flag):        sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_MINIMAP, flag)
 def is_status_bar_visible(self):        return sublime_api.window_is_ui_element_visible(self.window_id, UI_ELEMENT_STATUS_BAR)
Пример #14
0
 def set_sidebar_visible(self, flag):        sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_SIDE_BAR, flag)
 def is_minimap_visible(self):        return sublime_api.window_is_ui_element_visible(self.window_id, UI_ELEMENT_MINIMAP)
Пример #15
0
class Window(object):
    def __init__(self, id):
        self.window_id = id
        self.settings_object = None
        self.template_settings_object = None

    def __eq__(self, other):        return isinstance(other, Window) and other.window_id == self.window_id
    def __bool__(self):             return self.window_id != 0
    def id(self):                   return self.window_id
    def is_valid(self):             return sublime_api.window_num_groups(self.window_id) != 0

    def hwnd(self):
        """ Platform specific window handle, only returns a meaningful result under Windows """
        return sublime_api.window_system_handle(self.window_id)

    def active_sheet(self):
        sheet_id = sublime_api.window_active_sheet(self.window_id)
        if sheet_id == 0:
            return None
        else:
            return Sheet(sheet_id)

    def active_view(self):
        view_id = sublime_api.window_active_view(self.window_id)
        if view_id == 0:
            return None
        else:
            return View(view_id)

    def run_command(self, cmd, args=None):
        sublime_api.window_run_command(self.window_id, cmd, args)

    def new_file(self, flags=0, syntax=""):
        """ flags must be either 0 or TRANSIENT """
        return View(sublime_api.window_new_file(self.window_id, flags, syntax))

    def open_file(self, fname, flags=0, group=-1):
        """
        valid bits for flags are:
        ENCODED_POSITION: fname name may have :row:col or :row suffix
        TRASIENT: don't add the file to the list of open buffers
        FORCE_GROUP: don't select the file if it's opened in a different group
        """
        return View(sublime_api.window_open_file(self.window_id, fname, flags, group))

    def find_open_file(self, fname):
        view_id = sublime_api.window_find_open_file(self.window_id, fname)
        if view_id == 0:
            return None
        else:
            return View(view_id)

    def num_groups(self):                   return sublime_api.window_num_groups(self.window_id)
    def active_group(self):                 return sublime_api.window_active_group(self.window_id)
    def focus_group(self, idx):                     sublime_api.window_focus_group(self.window_id, idx)

    def focus_sheet(self, sheet):
        if sheet:
            sublime_api.window_focus_sheet(self.window_id, sheet.sheet_id)

    def focus_view(self, view):
        if view:
            sublime_api.window_focus_view(self.window_id, view.view_id)

    def get_sheet_index(self, sheet):
        if sheet:
            return sublime_api.window_get_sheet_index(self.window_id, sheet.sheet_id)
        else:
            return (-1, -1)

    def get_view_index(self, view):
        if view:
            return sublime_api.window_get_view_index(self.window_id, view.view_id)
        else:
            return (-1, -1)

    def set_sheet_index(self, sheet, group, idx):
        sublime_api.window_set_sheet_index(self.window_id, sheet.sheet_id, group, idx)

    def set_view_index(self, view, group, idx):
        sublime_api.window_set_view_index(self.window_id, view.view_id, group, idx)

    def sheets(self):
        sheet_ids = sublime_api.window_sheets(self.window_id)
        return [Sheet(x) for x in sheet_ids]

    def views(self):
        view_ids = sublime_api.window_views(self.window_id)
        return [View(x) for x in view_ids]

    def active_sheet_in_group(self, group):
        sheet_id = sublime_api.window_active_sheet_in_group(self.window_id, group)
        if sheet_id == 0:
            return None
        else:
            return Sheet(sheet_id)

    def active_view_in_group(self, group):
        view_id = sublime_api.window_active_view_in_group(self.window_id, group)
        if view_id == 0:
            return None
        else:
            return View(view_id)

    def sheets_in_group(self, group):
        sheet_ids = sublime_api.window_sheets_in_group(self.window_id, group)
        return [Sheet(x) for x in sheet_ids]

    def views_in_group(self, group):
        view_ids = sublime_api.window_views_in_group(self.window_id, group)
        return [View(x) for x in view_ids]

    def transient_sheet_in_group(self, group):
        sheet_id = sublime_api.window_transient_sheet_in_group(self.window_id, group)
        if sheet_id != 0:
            return Sheet(sheet_id)
        else:
            return None

    def transient_view_in_group(self, group):
        view_id = sublime_api.window_transient_view_in_group(self.window_id, group)
        if view_id != 0:
            return View(view_id)
        else:
            return None

    def layout(self):               return sublime_api.window_get_layout(self.window_id)
    def get_layout(self):   
        """ get_layout() is deprecated, use layout() """
        return sublime_api.window_get_layout(self.window_id)

    def set_layout(self, layout):        sublime_api.window_set_layout(self.window_id, layout)
    def create_output_panel(self, name, unlisted=False):        return View(sublime_api.window_create_output_panel(self.window_id, name, unlisted))

    def find_output_panel(self, name):
        view_id = sublime_api.window_find_output_panel(self.window_id, name)
        return View(view_id) if view_id else None

    def destroy_output_panel(self, name):        sublime_api.window_destroy_output_panel(self.window_id, name)

    def active_panel(self):
        name = sublime_api.window_active_panel(self.window_id)
        return name or None

    def panels(self):        return sublime_api.window_panels(self.window_id)

    def get_output_panel(self, name):
        """ deprecated, use create_output_panel """
        return self.create_output_panel(name)

    def show_input_panel(self, caption, initial_text, on_done, on_change, on_cancel):
        """ on_done and on_change should accept a string argument, on_cancel should have no arguments """
        return View(sublime_api.window_show_input_panel(
            self.window_id, caption, initial_text, on_done, on_change, on_cancel))

    def show_quick_panel(self, items, on_select, flags=0, selected_index=-1, on_highlight=None):
        """
        on_select is called when the the quick panel is finished, and should
        accept a single integer, specifying which item was selected, or -1 for none

        on_highlight is called when the quick panel is still active, and
        indicates the current highlighted index

        flags is a bitwise OR of MONOSPACE_FONT, and KEEP_OPEN_ON_FOCUS_LOST
        """
        items_per_row = 1
        flat_items = items
        if len(items) > 0 and isinstance(items[0], list):
            items_per_row = len(items[0])
            flat_items = []

            for i in range(len(items)):
                if isinstance(items[i], str):
                    flat_items.append(items[i])
                    for j in range(1, items_per_row):
                        flat_items.append("")
                else:
                    for j in range(items_per_row):
                        flat_items.append(items[i][j])

        sublime_api.window_show_quick_panel(
            self.window_id, flat_items, items_per_row, on_select, on_highlight,
            flags, selected_index)

    def is_sidebar_visible(self):        return sublime_api.window_is_ui_element_visible(self.window_id, UI_ELEMENT_SIDE_BAR)
    def set_sidebar_visible(self, flag):        sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_SIDE_BAR, flag)
    def is_minimap_visible(self):        return sublime_api.window_is_ui_element_visible(self.window_id, UI_ELEMENT_MINIMAP)
    def set_minimap_visible(self, flag):        sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_MINIMAP, flag)
    def is_status_bar_visible(self):        return sublime_api.window_is_ui_element_visible(self.window_id, UI_ELEMENT_STATUS_BAR)
    def set_status_bar_visible(self, flag):        sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_STATUS_BAR, flag)
    def get_tabs_visible(self):        return sublime_api.window_is_ui_element_visible(self.window_id, UI_ELEMENT_TABS)
    def set_tabs_visible(self, flag)        sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_TABS, flag)
    def is_menu_visible(self):        return sublime_api.window_is_ui_element_visible(self.window_id, UI_ELEMENT_MENU)
    def set_menu_visible(self, flag):        sublime_api.window_set_ui_element_visible(self.window_id, UI_ELEMENT_MENU, flag)
    def folders(self):        return sublime_api.window_folders(self.window_id)

    def project_file_name(self):
        name = sublime_api.window_project_file_name(self.window_id)
        if len(name) == 0:
            return None
        else:
            return name

    def project_data(self):
        return sublime_api.window_get_project_data(self.window_id)

    def set_project_data(self, v):
        sublime_api.window_set_project_data(self.window_id, v)

    def settings(self):
        """ Per-window settings, the contents are persisted in the session """
        if not self.settings_object:
            self.settings_object = Settings(
                sublime_api.window_settings(self.window_id))

        return self.settings_object

    def template_settings(self):
        """ Per-window settings that are persisted in the session, and duplicated into new windows """
        if not self.template_settings_object:
            self.template_settings_object = Settings(
                sublime_api.window_template_settings(self.window_id))

        return self.template_settings_object

    def lookup_symbol_in_index(self, sym):
        """ Finds all files and locations where sym is defined, using the symbol index """
        return sublime_api.window_lookup_symbol(self.window_id, sym)

    def lookup_symbol_in_open_files(self, sym):
        """ Finds all files and locations where sym is defined, searching through open files """
        return sublime_api.window_lookup_symbol_in_open_files(self.window_id, sym)

    def lookup_references_in_index(self, sym):
        """ Finds all files and locations where sym is referenced, using the symbol index """
        return sublime_api.window_lookup_references(self.window_id, sym)

    def lookup_references_in_open_files(self, sym):
        """ Finds all files and locations where sym is referenced, searching through open files """
        return sublime_api.window_lookup_references_in_open_files(self.window_id, sym)

    def extract_variables(self):
        return sublime_api.window_extract_variables(self.window_id)

    def status_message(self, msg):
        sublime_api.window_status_message(self.window_id, msg)