Ejemplo n.º 1
0
	def __init__(self,  is_logging_enabled=False):

		#api not tested so no token loaded
		if not TodoistAPI.APIOK:
			TodoistAPI.APITOKEN=settings.get('token');

		super(TodoistAPI, self).__init__(
			api_url="https://api.todoist.com/API",
			api_token=TodoistAPI.APITOKEN);


		self.logging_enabled=is_logging_enabled;

		self.project="Inbox"
		
		if len(sublime.windows())>0:
			self.project=sublime.windows()[0].folders()[0];
			
		self.logfile=open(sublime.packages_path() + "\\SimpleTodo\\todoisthandler.messages", "w");

		#if true automatically adds a new project if one cannot be found
		#else it will add to the inbox
		self.auto_add_project=True;
		
		self.log("TodoistAPI handler added for:%s\ncurrent project:%s\n" %(self.api_token, self.project));
Ejemplo n.º 2
0
  def run(self):
    windows = sublime.windows()
    active_window = sublime.active_window()

    for window in sublime.windows():
      if active_window != window:
          window.run_command('close_window')
    def on_input(self, input):
        view = self.window.active_view()
        settings = view.settings()
        haxelib_path = settings.get("haxelib_path", "haxelib")
        is_module = self.mode == 'module'
        files_to_open = []

        old = to_disk_path_form(self.classpath, self.option, is_module)
        new = to_disk_path_form(self.classpath, input, is_module)

        if self.mode == 'module':
            for w in sublime.windows():
                for v in w.views():
                    if v.file_name() == old:
                        w.focus_view(v)
                        w.run_command('close')
                        files_to_open.append(new)
        elif self.mode == 'package':
            for w in sublime.windows():
                for v in w.views():
                    if old in v.file_name():
                        relpath = os.path.relpath(v.file_name(), old)
                        files_to_open.append(os.path.join(new, relpath))
                        w.focus_view(v)
                        w.run_command('close')

        res, err = runcmd([
            haxelib_path, 'run', 'refactor', '-vv', 'rename',
            self.classpath, old, new], '')
        print('\nRefactor:\n' + res)

        for f in files_to_open:
            self.window.open_file(f)
 def on_load(self, view):
     if view.file_name():
         window = view.window()
         windows = sublime.windows()
         transient = window is None
         if transient or len(windows) == 1:
             pass
         elif sublime.load_settings("Side Bar Folders.sublime-settings").get(
             "open_files_in_folder_window", False
         ):
             path = normalize(view.file_name())
             if op.exists(path):
                 folders = window.folders()
                 for item in folders:
                     if path.startswith(normalize(item)):  # already in best window
                         return
                 for _window in sublime.windows():
                     if _window.id() != window.id():
                         folders = _window.folders()
                         for item in folders:
                             if path.startswith(
                                 normalize(item)
                             ):  # moving to best window
                                 window.run_command("close")
                                 _view = _window.open_file(path)
                                 self.focus_view(_view)
                                 return
Ejemplo n.º 5
0
        def jump_to_stack_frame(idx):
            if idx>=0:
                file_path = err['stack'][idx]['path']
                lineno = err['stack'][idx]['line']
                parent_win = sublime.active_window()
                print [w for w in sublime.windows() for v in w.views() if v.id()==task_id.view]
                for win in (w for w in sublime.windows() for v in w.views() if v.id()==task_id.view):
                    match = [v for v in win.views() if v.file_name()==file_path]
                    if match:
                        view = match[0]
                        view.settings().set('shebang.goto',idx)
                        if view.id()==sublime.active_window().active_view().id():
                            self.flash_errors(view)
                        else:
                            win.open_file(file_path)
                        return
                    else:
                        parent_win = win

                view = parent_win.open_file("%s:%i"%(file_path, lineno), sublime.ENCODED_POSITION)
                stack = [ (f['path']==file_path and f['line']) for f in err['stack']]
                view.settings().set('shebang.goto', idx)
                view.settings().set('shebang.stacktrace', {"task":[task_id.path, task_id.view], 
                                                           "gen":err['gen'],
                                                           "stack":stack, 
                                                           "depth":idx})
        sublime.active_window().show_quick_panel(ui, jump_to_stack_frame)
Ejemplo n.º 6
0
def update_folders():
	folders = list(set([norm_path(folder) for w in sublime.windows() for folder in w.folders() if folder and not should_exclude(norm_path(folder))]))
	_folders = []
	for folder in folders:
		_folders = deduplicate_crawl_folders(_folders, folder)
	_folders.sort()
	Pref.updated_folders = _folders
	Pref.updated_files = [norm_path(v.file_name()) for w in sublime.windows() for v in w.views() if v.file_name() and is_javascript_file(v.file_name()) and not should_exclude(norm_path(v.file_name()))]
Ejemplo n.º 7
0
    def on_close(self, view):
        # get version via api change
        sv = 2
        if hasattr(sublime.Window,"lookup_symbol_in_index"):
            sv = 3

        if len(sublime.windows()) == 1 and len(sublime.windows()[0].views()) == [43,1,1,0][sv]:
            sublime.windows()[0].new_file()
Ejemplo n.º 8
0
    def output_win(self):
        if self._frame is None or self._frame not in (w.id() for w in sublime.windows()):
            before = set([w.id() for w in sublime.windows()])
            sublime.run_command("new_window")
            after = set([w.id() for w in sublime.windows()])
            self._frame = after.difference(before).pop()

        for win in sublime.windows():
            if win.id() == self._frame:
                return win
Ejemplo n.º 9
0
def plugin_loaded():
	rm_in = open(path.join(root_dir, 'system_settings.json'))
	sys_settings = sublime.decode_value(rm_in.read())
	rm_in.close()

	if not sys_settings['is_init']:
		sys_settings['is_init'] = True
		rm_out = open(path.join(root_dir, 'system_settings.json'), 'w')
		rm_out.write(sublime.encode_value(sys_settings))
		rm_out.close()
		sublime.windows()[0].open_file(path.join(root_dir, 'Docs/Docs-EN.md'))
Ejemplo n.º 10
0
def hijack_window():
    '''Execute on loading plugin or on new window open;
    allow to open FB automatically in ST3
    '''
    settings = sublime.load_settings('dired.sublime-settings')
    command = settings.get("dired_hijack_new_window")
    if command:
        if command == "jump_list":
            sublime.set_timeout(lambda: sublime.windows()[-1].run_command("dired_jump_list"), 1)
        else:
            sublime.set_timeout(lambda: sublime.windows()[-1].run_command("dired", {"immediate": True}), 1)
 def init_(self):
     # ST BUG https://github.com/SublimeTextIssues/Core/issues/5
     # the application is not sending on_load when opening/restoring a window,
     # then there is this hack which will simulate or synthesize an on_load when you open the application
     # since this is just a hack, there is a terrible noticeable delay, which just sucks
     self.on_load(sublime.active_window().active_view())
     for window in sublime.windows():
         for view in reversed(window.views()):
             self.on_load(view)
     for window in sublime.windows():
         self.on_load(window.active_view())
         self.restore_scroll(window.active_view())
Ejemplo n.º 12
0
 def is_visible(self, source = "active_window"):
     result = False
     if (source in self.source_options):
         if (source == 'active_window'):
             result = len(self.window.views()) > 0
         elif (source == 'all_windows'):
             if (len(sublime.windows()) > 1):
                 view_count = 0
                 for w in sublime.windows():
                     view_count += len(w.views())
                     if view_count > 0:
                         break
                 result = (view_count > 0)
     return result
Ejemplo n.º 13
0
	def close_affected_buffers(self, path):
		for window in sublime.windows():
			active_view = window.active_view()
			views = []
			for view in window.views():
				if view.file_name():
					views.append(view)
			views.reverse();
			for view in views:
				if path == view.file_name():
					window.focus_view(view)
					window.run_command('revert')
					window.run_command('close')
				elif view.file_name().find(path+'\\') == 0:
					window.focus_view(view)
					window.run_command('revert')
					window.run_command('close')
				elif view.file_name().find(path+'/') == 0:
					window.focus_view(view)
					window.run_command('revert')
					window.run_command('close')

			# try to repaint
			try:
				window.focus_view(active_view)
				window.focus_view(window.active_view())
			except:
				try:
					window.focus_view(window.active_view())
				except:
					pass
Ejemplo n.º 14
0
	def run(self, edit, args):
		for w in sublime.windows():
			for v in w.views():
				lines = v.split_by_newlines(sublime.Region(0, v.size()))
				if len(lines) > args['linenum']:
					if v.substr(lines[args['linenum']]).strip() == args['string']:
						cview= v
Ejemplo n.º 15
0
 def run(self, edit):
     print("SELF.VIEW IS: " + str(self.view))
     print("SELF.VIEW.WINDOW().VIEWS() IS: " + str(self.view.window().views()))
     print("SUBLIME.WINDOWS() IS: " + str(sublime.windows()))
     print("SUBLIME.ACTIVE_WINDOW().VIEWS() IS: " + str(sublime.active_window().views()))
     print("SUBLIME.ACTIVE_WINDOW().ACTIVE_VIEW() IS: " + str(sublime.active_window().active_view()))
     self.view.sel().clear()
Ejemplo n.º 16
0
def clear_all_regions():
    """Clear all regions."""

    for window in sublime.windows():
        for view in window.views():
            for region_key in view.settings().get("bracket_highlighter.regions", []):
                view.erase_regions(region_key)
Ejemplo n.º 17
0
def settings_changed():
    for window in sublime.windows():
        for view in window.views():
            linter = select_linter(view)

            if (linter):
                reload_settings(view)
Ejemplo n.º 18
0
    def findHttpResponseView(self):
        for window in sublime.windows():
            for view in window.views():
                if view.name() == "http response":
                    return view

        return None
Ejemplo n.º 19
0
def focus_view(view):
	# looks like view.window() is broken in ST2,
	# use another way to find parent window
	for w in sublime.windows():
		for v in w.views():
			if v.id() == view.id():
				return w.focus_view(v)
Ejemplo n.º 20
0
def get_output_view(tag, strategy, name, switch_to, fallback_window):
    """
    Retrieves an output using the given strategy, window, and views.
    """
    window_list = sublime.windows()

    # Console Strategy
    if strategy == 'console':
        show_view(fallback_window, fallback_window.active_view(), True)
        return fallback_window.get_output_panel(tag)

    # Grouped strategy
    if strategy == 'grouped':
        for window in window_list:
            view_list = window.views()
            for view in view_list:
                if view.settings().get('output_tag') == tag:
                    if switch_to:
                        show_view(window, view, False)
                    return window, view

    if (strategy == 'separate') or (strategy == 'grouped'):
        w = sublime.active_window()
        v = w.active_view()

        result = fallback_window.new_file()
        result.set_name(name)
        result.set_scratch(True)
        result.settings().set('output_tag', tag)
        if switch_to:
            show_view(fallback_window, result, False)
        else:
            show_view(w, v, False)
        return fallback_window, result
    def init(self):
        if self.inited:
            return

        sets = sublime.load_settings(settings_file)
        if get_version() < 3000:
            if sets.get("ha_style").startswith("underlined"):
                sets.set("ha_style", "outlined")
            if sets.get("icons"):
                sets.set("icons", False)
            if sets.get("icons_all"):
                sets.set("icons_all", False)
            sublime.save_settings(settings_file)

        for k in ["enabled", "style", "ha_style", "icons_all", "icons", "color_formats"]:
            self.settings[k] = sets.get(k)

        self.settings["color_fmts"] = list(map(get_format, self.settings["color_formats"]))

        sets.clear_on_change("ColorHighlighter")
        sets.add_on_change("ColorHighlighter", lambda: self.on_ch_settings_change())

        sets = sublime.load_settings("Preferences.sublime-settings")

        self.settings["color_scheme"] = sets.get("color_scheme")

        sets.clear_on_change("ColorHighlighter")
        sets.add_on_change("ColorHighlighter", lambda: self.on_g_settings_change())

        self.inited = True

        for w in sublime.windows():
            for v in w.views():
                self.init_view(v)
Ejemplo n.º 22
0
    def run(self, url=None):
        
        # Can't remember why doing this ?
        window = sorted(sublime.windows(), key=lambda w: w.id())[0] #suself.window
        txmt   = url.startswith('txmt')
        p      = urlparse('http' + url[4:])
        query  = dict(parse_qsl(p.query))

        if txmt:
            url  = query.get('url')

            if url: f = unquote(urlparse(url).path)
            else:   f = window.active_view().file_name()

            f += ':%(line)s:%(column)s' % query
        else:
            f =  unquote(p.path)

        @on_load(f, window)
        def do(view):
            if txmt: return

            for cmd, args in loadsj(query.get('commands', '[]')):

                if window:
                    if DEBUG:
                        # Formatted like sublime.log_commands(True)
                        print 'command: %s' % encode_for_command_line(cmd, args)

                    # Bug: command can't be unicode
                    window.run_command(cmd.encode('utf8'), args)

################################################################################
Ejemplo n.º 23
0
def view_for_buffer_id(buf_id):
	for w in sublime.windows():
		for v in w.views():
			if str(v.buffer_id()) == buf_id:
				return v

	return None
Ejemplo n.º 24
0
  def get_results_window(self):
    for window in sublime.windows():
      for view in window.views():
        if view.settings().get('parent_file') == self.current_file:
          return view

    window = sublime.active_window()
    view = window.new_file()
    view.set_syntax_file(sublime.packages_path() + '/RunInScratch/run_in_scratch.tmlanguage')
    view.settings().set('parent_file', self.current_file)
    view.settings().set('word_wrap', True)
    window.run_command("set_layout",
          {
              "cols": [0.0, 0.65, 1.0],
              "rows": [0.0, 1.0],
              "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
          })



    view.set_name('Results of %s' % (self.tab_name))
    view.settings().set("RunInScratch", True)


    window.run_command("move_to_group", {"group": 1})
    window.run_command("focus_group", {"group": 0})
    view.set_scratch(True)

    return view
Ejemplo n.º 25
0
 def close_project(self, project):
     for w in sublime.windows():
         if w.project_file_name() == self.project_file_name(project):
             w.run_command("close_workspace")
             w.run_command("close_window")
             return True
     return False
Ejemplo n.º 26
0
 def on_done(self, picked):
     if picked == -1:
         return
     if picked < len(adb_views):
         view = adb_views[picked].view
         window = view.window()
         if window == None:
             # This is silly, but apparently the view is considered windowless
             # when it is not focused
             found = False
             for window in sublime.windows():
                 for view2 in window.views():
                     if view2.id() == view.id():
                         found = True
                         break
                 if found:
                     break
         window.focus_view(view)
         return
     name = self.options[picked]
     picked -= len(adb_views)
     device = self.devices[picked]
     adb = get_setting("adb_command")
     args = get_setting("adb_args")
     cmd = [adb, "-s", device] + args
     self.launch(cmd, name, device)
Ejemplo n.º 27
0
	def closeViews(self):
		path = self.path()
		closed_items = []
		for window in sublime.windows():
			active_view = window.active_view()
			views = []
			for view in window.views():
				if view.file_name():
					views.append(view)
			views.reverse();
			for view in views:
				if path == view.file_name() or view.file_name().find(path+'\\') == 0 or view.file_name().find(path+'/') == 0:
					if view.window():
						closed_items.append([view.file_name(), view.window(), view.window().get_view_index(view)])
					if len(window.views()) == 1:
						window.new_file()
					window.focus_view(view)
					window.run_command('revert')
					window.run_command('close')

			# try to repaint
			try:
				window.focus_view(active_view)
				window.focus_view(window.active_view())
			except:
				try:
					window.focus_view(window.active_view())
				except:
					pass
		return closed_items
Ejemplo n.º 28
0
def get_directories():
    '''Get Open Directories in Sublime'''
    dic = {}
    # retrieve all Sublime windows
    windows = sublime.windows()
    for w in windows:
        # and retrieve all unique directory path
        fs = w.folders()
        for f in fs:
            key = f.split(os.path.sep)[-1]
            if dic.has_key(key):
                if dic[key] is f:
                    continue
                else:
                    loop = True
                    num = 0
                    while(loop):
                        num += 1
                        k = key + " " + str(num)
                        if dic.has_key(k):
                            if dic[k] is f:
                                loop = False
                                break
                        else:
                            dic[k] = f
                            loop = False
                            break
            else:
                dic[key] = f
    return dic
Ejemplo n.º 29
0
def scalBuildListProjects():

    print("Relisting projects: ")

    ## Clean
    ScalBuild.availableProjects = []

    ## Get All Folders
    #############
    windows = sublime.windows()
    for window in windows:
        for folder in window.folders():

            ## Check if the folder may be sbt buildable
            ##############

            ## Pattern src/main/scala is present
            detectionPatterns = ['src/main/scala','src-main-scala','*.scala']
            foundScala = False
            for pattern in detectionPatterns:
                if len(glob.glob(folder+"/"+pattern))!=0 :

                    ## Found Scala Project
                    #######################
                    print("Found Scala Project @"+folder)

                    ScalBuild.availableProjects.append(ScalBuildProject(folder))

                    break
Ejemplo n.º 30
0
def plugin_loaded():
    for w in sublime.windows():
        for v in w.views():
            if v.settings().get("vintage_start_in_command_mode"):
                v.settings().set('command_mode', True)
                v.settings().set('inverse_caret_state', True)
            update_status_line(v)
Ejemplo n.º 31
0
def remove_all_highlights():
    for window in sublime.windows():
        remove_highlights(window)
Ejemplo n.º 32
0
    def disable_packages(self, packages, type='upgrade'):
        """
        Disables one or more packages before installing or upgrading to prevent
        errors where Sublime Text tries to read files that no longer exist, or
        read a half-written file.

        :param packages:
            The string package name, or an array of strings

        :param type:
            The type of operation that caused the package to be disabled:
             - "upgrade"
             - "remove"
             - "install"
             - "disable"
        """

        if not isinstance(packages, list):
            packages = [packages]

        disabled = []

        settings = sublime.load_settings(preferences_filename())
        ignored = load_list_setting(settings, 'ignored_packages')

        pc_settings = sublime.load_settings(pc_settings_filename())
        in_process = load_list_setting(pc_settings, 'in_process_packages')

        self.old_syntaxes = {}
        self.old_color_schemes = {}

        for package in packages:
            if not package in ignored:
                in_process.append(package)
                ignored.append(package)
                disabled.append(package)

                if type in ['upgrade', 'remove']:
                    version = self.get_version(package)
                    tracker_type = 'pre_upgrade' if type == 'upgrade' else type
                    events.add(tracker_type, package, version)

            for window in sublime.windows():
                for view in window.views():
                    view_settings = view.settings()
                    syntax = view_settings.get('syntax')
                    if syntax.find('Packages/' + package + '/') != -1:
                        if package not in self.old_syntaxes:
                            self.old_syntaxes[package] = []
                        self.old_syntaxes[package].append([view, syntax])
                        view_settings.set('syntax', 'Packages/Text/Plain text.tmLanguage')
                    scheme = view_settings.get('color_scheme')
                    if scheme.find('Packages/' + package + '/') != -1:
                        if package not in self.old_color_schemes:
                            self.old_color_schemes[package] = []
                        self.old_color_schemes[package].append([view, scheme])
                        view_settings.set('color_scheme', 'Packages/Color Scheme - Default/Monokai.tmTheme')

            # Change the color scheme before disabling the package containing it
            if settings.get('color_scheme').find('Packages/' + package + '/') != -1:
                self.old_color_scheme_package = package
                self.old_color_scheme = settings.get('color_scheme')
                settings.set('color_scheme', 'Packages/Color Scheme - Default/Monokai.tmTheme')

            # Change the theme before disabling the package containing it
            if package_file_exists(package, settings.get('theme')):
                self.old_theme_package = package
                self.old_theme = settings.get('theme')
                settings.set('theme', 'Default.sublime-theme')

        pc_settings.set('in_process_packages', in_process)
        sublime.save_settings(pc_settings_filename())

        settings.set('ignored_packages', ignored)
        sublime.save_settings(preferences_filename())

        return disabled
Ejemplo n.º 33
0
 def current_views(self):
     for window in sublime.windows():
         for view in window.views():
             yield view
Ejemplo n.º 34
0
 def update(self) -> None:
     for window in sublime.windows():
         if window.id() in self._managers:
             self._managers[window.id()].update(create_window_configs(window, self._configs))
Ejemplo n.º 35
0
def update_profile_status():
    profile = get_active_profile()
    for w in sublime.windows():
        for v in w.views():
            v.set_status('user_profile', profile)
Ejemplo n.º 36
0
def unload_sessions():
    for window in sublime.windows():
        wm = windows.lookup(window)
        wm.end_sessions()
Ejemplo n.º 37
0
    def prune_projects(cls, obj):
        """Prune windows from projects that are closed."""

        dead = obj.projects - set([x.id() for x in sublime.windows()])
        for key in dead:
            obj.projects.remove(key)
Ejemplo n.º 38
0
 def update(self) -> None:
     for window in sublime.windows():
         if window.id() in self._managers:
             self._managers[window.id()].update()
Ejemplo n.º 39
0
 def erase_all_statuses(cls):
     for w in sublime.windows():
         for v in w.views():
             v.erase_status(cls._status_key)
Ejemplo n.º 40
0
    def synch_scroll(self):

        Pref.synch_scroll_running = True

        # find current view
        view = Pref.synch_scroll_current_view_object
        if view is None or view.is_loading():
            Pref.synch_scroll_running = False
            return

        # if something changed
        if Pref.synch_scroll_last_view_id != Pref.current_view:
            Pref.synch_scroll_last_view_id = Pref.current_view
            Pref.synch_scroll_last_view_position = 0
        last_view_position = [
            view.visible_region(),
            view.viewport_position(),
            view.viewport_extent()
        ]
        if Pref.synch_scroll_last_view_position == last_view_position:
            Pref.synch_scroll_running = False
            return
        Pref.synch_scroll_last_view_position = last_view_position

        # if there is clones
        clones = {}
        clones_positions = []
        for window in sublime.windows():
            for _view in window.views():
                if not _view.is_loading() and _view.file_name(
                ) == view.file_name() and view.id() != _view.id():
                    id, index = self.view_id(_view)
                    if index == '0':
                        index = str(window.id()) + '(0, 0)'
                    clones[index] = _view
                    clones_positions.append(index)
        if not clones_positions:
            Pref.synch_scroll_running = False
            return

        #print 'sync scroll'

        # current view
        id, index = self.view_id(view)
        if index == '0':
            index = str(view.window().id()) + '(0, 0)'

        # append current view to list of clones
        clones[index] = view
        clones_positions.append(index)
        clones_positions.sort()

        # find current view index
        i = [i for i, x in enumerate(clones_positions) if x == index][0]

        lenght = len(clones_positions)
        line = view.line_height()
        # synch scroll for views to the left
        b = i - 1
        previous_view = view
        while b > -1:
            current_view = clones[clones_positions[b]]
            ppl, ppt = current_view.text_to_layout(
                previous_view.line(previous_view.visible_region().a).b)
            cpw, cph = current_view.viewport_extent()
            left, old_top = current_view.viewport_position()
            top = ((ppt - cph) + line)
            if abs(old_top - top) >= line:
                current_view.set_viewport_position((left, top))
            previous_view = current_view
            b -= 1

        # synch scroll for views to the right
        i += 1
        previous_view = view
        while i < lenght:
            current_view = clones[clones_positions[i]]
            top = current_view.text_to_layout(
                previous_view.line(previous_view.visible_region().b).a)
            left, old_top = current_view.viewport_position()
            top = top[
                1] - 3  # 3 is the approximated height of the shadow of the tabbar. Removing the shadow Makes the text more readable
            if abs(old_top - top) >= line:
                current_view.set_viewport_position((left, top))
            previous_view = current_view
            i += 1

        Pref.synch_scroll_running = False
Ejemplo n.º 41
0
def all_cwds():
    cwds = set()
    for window in sublime.windows():
        for view in window.views():
            cwds.add(s_cwd(view))
    return cwds
Ejemplo n.º 42
0
 def run(self, unused_edit):
     for window in sublime.windows():
         for view in window.views():
             view.settings().erase('preview_in_marked')
     self.view.settings().set('preview_in_marked', True)
Ejemplo n.º 43
0
def plugin_unloaded():
    for wnd in sublime.windows():
        for view in wnd.views():
            dispose(view)
Ejemplo n.º 44
0
def new_window(
    *,
    menu_visible: Optional[bool] = None,
    sidebar_visible: Optional[bool] = None,
    tabs_visible: Optional[bool] = None,
    minimap_visible: Optional[bool] = None,
    status_bar_visible: Optional[bool] = None,
    project_data: Optional[dict] = None
) -> sublime.Window:
    """Open a new window, returning the :class:`~sublime.Window` object.

    This function takes many optional keyword arguments:

    :argument menu_visible:
        Show the menubar.
        New windows show the menubar by default.
        On the Mac OS, this argument has no effect.

    :argument sidebar_visible:
        Show the sidebar.
        The sidebar will only be shown
        if the window's project data has at least one folder.

    :argument tabs_visible:
        Show the tab bar.
        If the tab bar is hidden,
        it will not be shown even if there are multiple tabs.

    :argument minimap_visible:
        Show the minimap.

    :argument status_bar_visible:
        Show the status bar.

    :argument project_data:
        Project data for the window, such as `folders`.
        See the `.sublime_project` documentation for details.

    This function currently does not provide a way
    to associate a window with a `.sublime_project` file.

    :raise RuntimeError: if the window is not created for any reason.

    .. versionadded:: 1.2
    """
    original_ids = set(window.id() for window in sublime.windows())

    sublime.run_command('new_window')

    try:
        window = next(window for window in sublime.windows() if window.id() not in original_ids)
    except StopIteration:  # pragma: no cover
        raise RuntimeError("Window not created.") from None

    if menu_visible is not None:
        window.set_menu_visible(menu_visible)

    if sidebar_visible is not None:
        window.set_sidebar_visible(sidebar_visible)

    if tabs_visible is not None:
        window.set_tabs_visible(tabs_visible)

    if minimap_visible is not None:
        window.set_minimap_visible(minimap_visible)

    if status_bar_visible is not None:
        window.set_status_bar_visible(status_bar_visible)

    if project_data is not None:
        window.set_project_data(project_data)

    return window
Ejemplo n.º 45
0
def on_renamed_file(new_filename, **kwargs):
    # update all panels that contain this file
    for window in sublime.windows():
        if new_filename in filenames_per_window(window):
            if panel_is_active(window):
                fill_panel(window)
Ejemplo n.º 46
0
def plugin_unloaded():
    for window in sublime.windows():
        window.destroy_output_panel(PANEL_NAME)
Ejemplo n.º 47
0
def settings_changed():
    for window in sublime.windows():
        for view in window.views():
            reload_settings(view)
Ejemplo n.º 48
0
def on_updated_error_positions(filename, **kwargs):
    for window in sublime.windows():
        if panel_is_active(window) and filename in filenames_per_window(window):
            fill_panel(window)
Ejemplo n.º 49
0
 def _on_part(self, data):
     super(self.__class__, self)._on_part(data)
     region_key = 'floobits-highlight-%s' % (str(data['user_id']))
     for window in sublime.windows():
         for view in window.views():
             view.erase_regions(region_key)
Ejemplo n.º 50
0
def plugin_unloaded():
    for wnd in sublime.windows():
        for view in wnd.views():
            unmark(view)
Ejemplo n.º 51
0
def all_views_into_file(filename):
    for window in sublime.windows():
        for view in window.views():
            if util.get_filename(view) == filename:
                yield view
Ejemplo n.º 52
0
def plugin_unloaded():
    events.off(on_lint_result)
    for window in sublime.windows():
        for view in window.views():
            undraw(view)
Ejemplo n.º 53
0
 def on_autofix(self, corrs):
     self.corrections = corrs
     sublime.set_timeout(
         lambda: symbols.mark_corrections(
             [v for w in sublime.windows()
              for v in w.views()], self.corrections), 0)
Ejemplo n.º 54
0
def unload_handler():
    for w in sublime.windows():
        for v in w.views():
            v.settings().set('command_mode', False)
            v.settings().set('inverse_caret_state', False)
            v.settings().set('vintage', {})
Ejemplo n.º 55
0
def apply_to_all_views(callback):
    """Apply callback to all views in all windows."""
    for window in sublime.windows():
        for view in window.views():
            callback(view)
Ejemplo n.º 56
0
def plugin_unloaded():
    events.off(on_lint_result)
    for window in sublime.windows():
        for view in window.views():
            view.erase_status(STATUS_COUNTER_KEY)
            view.erase_status(STATUS_MSG_KEY)
Ejemplo n.º 57
0
 def __del__(self) -> None:
     for window in sublime.windows():
         for view in window.views():
             view.erase_status(self._key)
     super().__del__()
Ejemplo n.º 58
0
    def disable_packages(self, packages, type='upgrade'):
        """
        Disables one or more packages before installing or upgrading to prevent
        errors where Sublime Text tries to read files that no longer exist, or
        read a half-written file.

        :param packages:
            The string package name, or an array of strings

        :param type:
            The type of operation that caused the package to be disabled:
             - "upgrade"
             - "remove"
             - "install"
             - "disable"
             - "loader"

        :return:
            A list of package names that were disabled
        """

        if not isinstance(threading.current_thread(), threading._MainThread):
            raise RuntimeError(
                'disable_packages called on a background thread')

        global events

        if events is None:
            from package_control import events

        if not isinstance(packages, list):
            packages = [packages]

        disabled = []

        settings = sublime.load_settings(preferences_filename())
        ignored = load_list_setting(settings, 'ignored_packages')

        pc_settings = sublime.load_settings(pc_settings_filename())
        in_process = load_list_setting(pc_settings, 'in_process_packages')

        PackageDisabler.old_color_scheme_package = None
        PackageDisabler.old_color_scheme = None

        PackageDisabler.old_theme_package = None
        PackageDisabler.old_theme = None

        PackageDisabler.old_syntaxes = {}
        PackageDisabler.old_color_schemes = {}

        for package in packages:
            if package not in ignored:
                in_process.append(package)
                ignored.append(package)
                disabled.append(package)

            if type in ['upgrade', 'remove']:
                version = self.get_version(package)
                tracker_type = 'pre_upgrade' if type == 'upgrade' else type
                events.add(tracker_type, package, version)

            global_color_scheme = settings.get('color_scheme')
            if global_color_scheme is not None and global_color_scheme.find(
                    'Packages/' + package + '/') != -1:
                PackageDisabler.old_color_scheme_package = package
                PackageDisabler.old_color_scheme = global_color_scheme
                settings.set(
                    'color_scheme',
                    'Packages/Color Scheme - Default/Monokai.tmTheme')

            for window in sublime.windows():
                for view in window.views():
                    view_settings = view.settings()
                    syntax = view_settings.get('syntax')
                    if syntax is not None and syntax.find('Packages/' +
                                                          package + '/') != -1:
                        if package not in PackageDisabler.old_syntaxes:
                            PackageDisabler.old_syntaxes[package] = []
                        PackageDisabler.old_syntaxes[package].append(
                            [view, syntax])
                        view_settings.set(
                            'syntax', 'Packages/Text/Plain text.tmLanguage')
                    # Handle view-specific color_scheme settings not already taken care
                    # of by resetting the global color_scheme above
                    scheme = view_settings.get('color_scheme')
                    if scheme is not None and scheme != global_color_scheme \
                            and scheme.find('Packages/' + package + '/') != -1:
                        if package not in PackageDisabler.old_color_schemes:
                            PackageDisabler.old_color_schemes[package] = []
                        PackageDisabler.old_color_schemes[package].append(
                            [view, scheme])
                        view_settings.set(
                            'color_scheme',
                            'Packages/Color Scheme - Default/Monokai.tmTheme')

            # Change the theme before disabling the package containing it
            if package_file_exists(package, settings.get('theme')):
                PackageDisabler.old_theme_package = package
                PackageDisabler.old_theme = settings.get('theme')
                settings.set('theme', 'Default.sublime-theme')

        # We don't mark a package as in-process when disabling it, otherwise
        # it automatically gets re-enabled the next time Sublime Text starts
        if type != 'disable':
            save_list_setting(pc_settings, pc_settings_filename(),
                              'in_process_packages', in_process)

        save_list_setting(settings, preferences_filename(), 'ignored_packages',
                          ignored)

        return disabled
Ejemplo n.º 59
0
def all_views_into_buffer(buffer_id):
    for window in sublime.windows():
        for view in window.views():
            if view.buffer_id() == buffer_id:
                yield view
Ejemplo n.º 60
0
def plugin_loaded():
    for w in sublime.windows():
        for g in range(w.num_groups()):
            listener.on_load(w.active_view_in_group(g))

    logger.debug('UvLinter loaded: v%s' % __version__)