def run(self, edit, range='%', forced=False, pattern=''): try: global_pattern, subcmd = global_command.split(pattern) except ValueError: msg = "VintageEx: Bad :global pattern. (:%sglobal%s)" % (range, pattern) sublime.status_message(msg) print msg return if global_pattern: ExGlobal.most_recent_pat = global_pattern else: global_pattern = ExGlobal.most_recent_pat # Make sure we always have a subcommand to exectute. This is what # Vim does too. subcmd = subcmd or 'print' rs = get_region_by_range(self.view, range) for r in rs: try: match = re.search(global_pattern, self.view.substr(r)) except Exception, e: msg = "VintageEx (global): %s ... in pattern '%s'" % (str(e), global_pattern) sublime.status_message(msg) print msg return if (match and not forced) or (not match and forced): GLOBAL_RANGES.append(r)
def run(self, edit, **kwargs): vid = self.view.id() if vid in persist.errors and persist.errors[vid]: method(self, self.view, persist.errors[vid], persist.highlights[vid], **kwargs) else: sublime.status_message('No lint errors.')
def run(self, command, file_name=None, forced=False): window = self.window selfview = window.active_view() max_index = len(window.views()) (group, index) = window.get_view_index(selfview) if (command == "open"): if file_name is None: # TODO: file completion window.run_command("show_overlay", {"overlay": "goto", "show_files": True, }) else: cur_dir = os.path.dirname(selfview.file_name()) window.open_file(os.path.join(cur_dir, file_name)) elif command == "next": window.run_command("select_by_index", {"index": (index + 1) % max_index}, ) elif command == "prev": window.run_command("select_by_index", {"index": (index + max_index - 1) % max_index, }) elif command == "last": window.run_command("select_by_index", {"index": max_index - 1, }) elif command == "first": window.run_command("select_by_index", {"index": 0, }) elif command == "only": for view in window.views_in_group(group): if view.id() != selfview.id(): window.focus_view(view) window.run_command("ex_quit", {"forced": forced}) window.focus_view(selfview) else: sublime.status_message("Unknown TabControl Command")
def WarnUser(message): perforce_settings = sublime.load_settings('Perforce.sublime-settings') if(perforce_settings.get('perforce_warnings_enabled')): if(perforce_settings.get('perforce_log_warnings_to_status')): sublime.status_message("Perforce [warning]: {0}".format(message)) else: print("Perforce [warning]: {0}".format(message))
def run(self, dirs): if sublime.ok_cancel_dialog("Delete Folder?", "Delete"): try: for d in dirs: send2trash.send2trash(d) except: sublime.status_message("Unable to delete folder")
def on_done(self, paths, searchTerm): self.searchTerm = searchTerm.strip() self.total = 0 content = u'' for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames(): self.files = [] self.num_files = 0 self.find(item.path()) content += '\nSearching '+str(self.num_files)+' files for "'+self.searchTerm+'" in \n"'+item.path()+'"\n\n' content += (':\n'.join(self.files))+':\n\n' length = len(self.files) if length > 1: content += str(length)+' matches\n' elif length > 0: content += '1 match\n' else: content += 'No match\n' self.total = self.total + length if self.total > 0: view = sublime.active_window().new_file() view.settings().set('word_wrap', False) view.set_name('Find Results') view.set_syntax_file('Packages/Default/Find Results.hidden-tmLanguage') view.set_scratch(True) edit = view.begin_edit() view.replace(edit, sublime.Region(0, view.size()), content.lstrip()); view.sel().clear() view.sel().add(sublime.Region(0)) view.end_edit(edit) else: sublime.status_message('No files containing "'+self.searchTerm+'"')
def run_command(self, command, callback=None, show_status=True, filter_empty_args=True, no_save=False, **kwargs): if filter_empty_args: command = [arg for arg in command if arg] if "working_dir" not in kwargs: kwargs["working_dir"] = self.get_working_dir() if ( "fallback_encoding" not in kwargs and self.active_view() and self.active_view().settings().get("fallback_encoding") ): kwargs["fallback_encoding"] = ( self.active_view().settings().get("fallback_encoding").rpartition("(")[2].rpartition(")")[0] ) s = sublime.load_settings("Git.sublime-settings") if s.get("save_first") and self.active_view() and self.active_view().is_dirty() and not no_save: self.active_view().run_command("save") if command[0] == "git" and s.get("git_command"): command[0] = s.get("git_command") if command[0] == "git-flow" and s.get("git_flow_command"): command[0] = s.get("git_flow_command") if not callback: callback = self.generic_done thread = CommandThread(command, callback, **kwargs) thread.start() if show_status: message = kwargs.get("status_message", False) or " ".join(command) sublime.status_message(message)
def run_async(self): short_hash = self.get_selected_short_hash() if not short_hash: return # Cannot squash last commit. if self.interface.entries[-1].short_hash == short_hash: sublime.status_message("Unable to squash most recent commit.") return # Generate identical change templates with author/date metadata # in tact. In case of commit-to-squash, indicate that the changes # should be rolled over into the next change's commit. commit_chain = [ self.ChangeTemplate(orig_hash=entry.long_hash, do_commit=entry.short_hash != short_hash, msg=entry.raw_body, datetime=entry.datetime, author="{} <{}>".format(entry.author, entry.email)) for entry in self.interface.entries ] # Take the commit message from the commit-to-squash and append # it to the next commit's message. for idx, commit in enumerate(commit_chain): if not commit.do_commit: commit_chain[idx+1].msg += "\n\n" + commit.msg commit.msg = None self.make_changes(commit_chain)
def run_async(self): short_hash = self.get_selected_short_hash() if not short_hash: return if self.interface.entries[-1].short_hash == short_hash: sublime.status_message("Unable to move last commit down.") return commit_chain = [ self.ChangeTemplate(orig_hash=entry.long_hash, move=entry.short_hash == short_hash, do_commit=True, msg=entry.raw_body, datetime=entry.datetime, author="{} <{}>".format(entry.author, entry.email)) for entry in self.interface.entries ] # Take the change to move and swap it with the one following. for idx, commit in enumerate(commit_chain): if commit.move: commit_chain[idx], commit_chain[idx+1] = commit_chain[idx+1], commit_chain[idx] break try: self.make_changes(commit_chain) except: sublime.message_dialog("Unable to move commit, most likely due to a conflict.")
def show_in_quick_panel(self, result): self.results = list(result.rstrip().split('\n')) if len(self.results): self.quick_panel(self.results, self.do_nothing, sublime.MONOSPACE_FONT) else: sublime.status_message("Nothing to show")
def run_command(self, command, callback=None, show_status=True, filter_empty_args=True, no_save=False, **kwargs): if filter_empty_args: command = [arg for arg in command if arg] if 'working_dir' not in kwargs: kwargs['working_dir'] = self.get_working_dir() if 'fallback_encoding' not in kwargs and self.active_view() and self.active_view().settings().get('fallback_encoding'): kwargs['fallback_encoding'] = self.active_view().settings().get('fallback_encoding').rpartition('(')[2].rpartition(')')[0] s = sublime.load_settings("Git.sublime-settings") if s.get('save_first') and self.active_view() and self.active_view().is_dirty() and not no_save: self.active_view().run_command('save') if command[0] == 'git' and s.get('git_command'): command[0] = s.get('git_command') if command[0] == 'git-flow' and s.get('git_flow_command'): command[0] = s.get('git_flow_command') if not callback: callback = self.generic_done thread = CommandThread(command, callback, **kwargs) thread.start() if show_status: message = kwargs.get('status_message', False) or ' '.join(command) sublime.status_message(message)
def on_done(self, idx): if idx == -1: return gist = self.gists[idx] filename = list(gist["files"].keys())[0] filedata = gist["files"][filename] content = self.gistapi.get(filedata["raw_url"]) if self.open_in_editor: new_view = self.view.window().new_file() if expat: # not present in Linux # set syntax file if not self.syntax_file_map: self.syntax_file_map = self._generate_syntax_file_map() try: extension = os.path.splitext(filename)[1][1:].lower() syntax_file = self.syntax_file_map[extension] new_view.set_syntax_file(syntax_file) except KeyError: logger.warn("no mapping for '%s'" % extension) pass # insert the gist new_view.run_command("insert_text", {'text': content}) new_view.set_name(filename) new_view.settings().set('gist', gist) elif self.copy_gist_id: sublime.set_clipboard(gist["html_url"]) else: sublime.set_clipboard(content) sublime.status_message(self.MSG_SUCCESS % filename)
def on_done_filename(self, value): self.filename = value # get selected text, or the whole file if nothing selected if all([region.empty() for region in self.view.sel()]): text = self.view.substr(sublime.Region(0, self.view.size())) else: text = "\n".join([self.view.substr(region) for region in self.view.sel()]) try: gist = self.gistapi.create_gist(description=self.description, filename=self.filename, content=text, public=self.public) self.view.settings().set('gist', gist) sublime.set_clipboard(gist["html_url"]) sublime.status_message(self.MSG_SUCCESS) except GitHubApi.UnauthorizedException: # clear out the bad token so we can reset it self.settings.set("github_token", "") sublime.save_settings("GitHub.sublime-settings") sublime.error_message(self.ERR_UNAUTHORIZED_TOKEN) sublime.set_timeout(self.get_username, 50) except GitHubApi.UnknownException as e: sublime.error_message(e.message) except GitHubApi.ConnectionException as e: sublime.error_message(e.message)
def status_done(self, result): self.results = filter(lambda x: len(x) > 0 and not x.lstrip().startswith('>'), result.rstrip().split('\n')) if len(self.results): self.show_status_list() else: sublime.status_message("Nothing to show")
def plugin_loaded(): if DEBUG: UTC_TIME = datetime.utcnow() PYTHON = sys.version_info[:3] VERSION = sublime.version() PLATFORM = sublime.platform() ARCH = sublime.arch() PACKAGE = sublime.packages_path() INSTALL = sublime.installed_packages_path() message = ( 'Jekyll debugging mode enabled...\n' '\tUTC Time: {time}\n' '\tSystem Python: {python}\n' '\tSystem Platform: {plat}\n' '\tSystem Architecture: {arch}\n' '\tSublime Version: {ver}\n' '\tSublime Packages Path: {package}\n' '\tSublime Installed Packages Path: {install}\n' ).format(time=UTC_TIME, python=PYTHON, plat=PLATFORM, arch=ARCH, ver=VERSION, package=PACKAGE, install=INSTALL) sublime.status_message('Jekyll: Debugging enabled...') debug('Plugin successfully loaded.', prefix='\n\nJekyll', level='info') debug(message, prefix='Jekyll', level='info')
def run(self): sublime.status_message('Sending to PasteBin...') response = urlopen(url=API_URL, data=urlencode(self.call_args).encode('utf8')).read().decode('utf8') sublime.set_clipboard(response) sublime.status_message('PasteBin URL copied to clipboard: ' + response)
def run(self, edit): paths = getPaths(self) if len(paths[2]) != 0 and len(paths[3]) != 0: command = ['/Users/kyleg/bin/push', paths[2]] simpleShellExecute(command, paths[3]) sublime.status_message("Pushed %s from %s" % (paths[2], paths[3]))
def search_bare_weblink_and_open(self, start, end): # expand selection to nearest stopSymbols view_size = self.view.size() stopSymbols = ['\t', ' ', '\"', '\'', '>', '<', ','] # move the selection back to the start of the url while (start > 0 and not self.view.substr(start - 1) in stopSymbols and self.view.classify(start) & sublime.CLASS_LINE_START == 0): start -= 1 # move end of selection forward to the end of the url while (end < view_size and not self.view.substr(end) in stopSymbols and self.view.classify(end) & sublime.CLASS_LINE_END == 0): end += 1 # grab the URL url = self.view.substr(sublime.Region(start, end)) # optional select URL self.view.sel().add(sublime.Region(start, end)) exp = re.search(self.URL_REGEX, url, re.X) if exp and exp.group(0): strUrl = exp.group(0) if strUrl.find("://") == -1: strUrl = "http://" + strUrl webbrowser.open_new_tab(strUrl) else: sublime.status_message("Looks like there is nothing to open")
def run(self, edit, fn=None): point = self.view.sel()[0].begin() line = self.view.substr(self.view.line(point)) match_link = self.LINK_PATTERN.search(line) match_md = self.MD_LINK.search(line) match_wiki = self.WIKI_LINK.search(line) if match_link: fn, sym, line, col, text = match_link.group('fn', 'sym', 'line', 'col', 'text') elif match_md: fn, sym, line, col, text = match_md.group('fn', 'sym', 'line', 'col', 'text') # unescape some chars fn = (fn.replace('\\(', '(').replace('\\)', ')')) elif match_wiki: fn = match_wiki.group('fn') sym = match_wiki.group('sym') or match_wiki.group('symn') line = match_wiki.group('line') or match_wiki.group('linen') col = match_wiki.group('col') or match_wiki.group('coln') text = match_wiki.group('text') or match_wiki.group('textn') # unescape some chars fn = (fn.replace('\\[', '[').replace('\\]', ']')) if text: text = (text.replace('\\[', '[').replace('\\]', ']')) if fn: self.show_panel_or_open(fn, sym, line, col, text) if text: sublime.set_timeout(lambda: self.find_text(self.opened_file, text, line), 300) else: sublime.status_message('Line does not contain a valid link to file')
def parser_specific_convert(self, markdown_text): import subprocess binary = self.settings.get("multimarkdown_binary", "") if os.path.exists(binary): cmd = [binary] critic_mode = self.settings.get("strip_critic_marks", "accept") if critic_mode in ("accept", "reject"): cmd.append("-a" if critic_mode == "accept" else "-r") sublime.status_message("converting markdown with multimarkdown...") if sublime.platform() == "windows": startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW p = subprocess.Popen( cmd, startupinfo=startupinfo, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) else: p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) for line in markdown_text.split("\n"): p.stdin.write((line + "\n").encode("utf-8")) markdown_html = p.communicate()[0].decode("utf-8") if p.returncode: # Log info to console sublime.error_message("Could not convert file! See console for more info.") print(markdown_html) markdown_html = _CANNOT_CONVERT else: sublime.error_message("Cannot find multimarkdown binary!") markdown_html = _CANNOT_CONVERT return markdown_html
def handle_threads(self, edit, threads, selections, offset = 0, i = 0, dir = 1): next_threads = [] for thread in threads: if thread.is_alive(): next_threads.append(thread) continue if thread.result == False: continue self.handle_result(edit, thread, selections, offset) threads = next_threads if len(threads): before = i % 8 after = (7) - before dir = -1 if not after else dir dir = 1 if not before else dir i += dir self.view.set_status('minify', '[%s=%s]' % (' ' * before, ' ' * after)) sublime.set_timeout(lambda: self.handle_threads(edit, threads, selections, offset, i, dir), 100) return self.view.erase_status('minify') sublime.status_message('Successfully minified')
def run(self, *args, **kwargs): try: # The first folder needs to be the Laravel Project self.PROJECT_PATH = self.window.folders()[0] artisan_path = os.path.join(self.PROJECT_PATH, self.artisan_path) self.args = [self.php_path, artisan_path] if os.path.isfile("%s" % artisan_path): self.command = kwargs.get('command', None) if self.command == 'serveStop': plat = platform.system() if plat == 'Windows': self.command = 'taskkill /F /IM php.exe' else: self.command = 'killall php' self.args = [] else: self.args = [self.php_path, artisan_path] self.fill_in_accept = kwargs.get('fill_in', False) self.fill_in_label = kwargs.get('fill_in_lable', 'Enter the resource name') self.fields_accept = kwargs.get('fields', False) self.fields_label = kwargs.get('fields_label', 'Enter the fields') if self.command is None: self.window.show_input_panel('Command name w/o args:', '', self.on_command_custom, None, None) else: self.on_command(self.command) else: sublime.status_message("Artisan not found") except IndexError: sublime.status_message("Please open a Laravel Project")
def on_filename(filename): if filename: text = self.view.substr(sublime.Region(0, self.view.size())) changes = {filename: {'content': text}} new_gist = update_gist(gist['url'], changes) gistify_view(self.view, new_gist, filename) sublime.status_message("File added to Gist")
def on_gist_filename(filename): # We need to figure out the filenames. Right now, the following logic is used: # If there's only 1 selection, just pass whatever the user typed to Github. It'll rename empty files for us. # If there are multiple selections and user entered a filename, rename the files from foo.js to # foo (1).js, foo (2).js, etc. # If there are multiple selections and user didn't enter anything, post the files as # $SyntaxName 1, $SyntaxName 2, etc. if len(region_data) == 1: gist_data = {filename: region_data[0]} else: if filename: (namepart, extpart) = os.path.splitext(filename) make_filename = lambda num: "%s (%d)%s" % (namepart, num, extpart) else: syntax_name, _ = os.path.splitext(os.path.basename(self.view.settings().get('syntax'))) make_filename = lambda num: "%s %d" % (syntax_name, num) gist_data = dict((make_filename(idx), data) for idx, data in enumerate(region_data, 1)) gist = create_gist(self.public, description, gist_data) gist_html_url = gist['html_url'] sublime.set_clipboard(gist_html_url) sublime.status_message("%s Gist: %s" % (self.mode(), gist_html_url)) if gistify: gistify_view(self.view, gist, gist['files'].keys()[0])
def on_filename(filename): if filename and filename != old_filename: text = self.view.substr(sublime.Region(0, self.view.size())) file_changes = {old_filename: {'filename': filename, 'content': text}} new_gist = update_gist(self.gist_url(), file_changes) gistify_view(self.view, new_gist, filename) sublime.status_message('Gist file renamed')
def handle_threads(self, edit, threads, offset=0, i=0, dir=1): next_threads = [] for thread in threads: if thread.is_alive(): next_threads.append(thread) continue if thread.result == False: continue offset = self.replace(edit, thread, offset) threads = next_threads if len(threads): # This animates a little activity indicator in the status area before = i % 8 after = (7) - before if not after: dir = -1 if not before: dir = 1 i += dir self.view.set_status('bitly', 'Bitly [%s=%s]' % (' ' * before, ' ' * after)) sublime.set_timeout(lambda: self.handle_threads(edit, threads, offset, i, dir), 100) return self.view.end_edit(edit) self.view.erase_status('bitly') matches = len(self.urls) sublime.status_message('Bitly successfully run on %s selection%s' % (matches, '' if matches == 1 else 's'))
def run(self, edit, command, options=None, text=None, separator=None): try: cmd = Command.create(command, options) if cmd: items = None if text: items = text.split(separator) cmd.init(self.view, items) regions = [] sel = self.view.sel() last_region = None for region in sel: if cmd.has_next(): value = cmd.next() if value is not None: self.view.replace(edit, region, value) regions.append(region) else: break for region in regions: sel.subtract(region) else: sublime.status_message("Command not found: " + cmd) except ValueError: sublime.status_message("Error while executing Text Pastry, canceled") pass
def run(self, **args): config = getPrefs(args["cmd"]) if config != None: if (len(config) > 0): if args.get("batch", False) == True or (config.get("debug", None) != None and "all" in config["debug"] or "a" in config["debug"]): args["cmd"] = [config["compiler"], config["filedir"]] if config.get("scripts", None) != None: if config["filedir"] == config["scripts"]: if USER_SETTINGS.get("confirm_dangerous_batch_compilations", True) == True: if not sublime.ok_cancel_dialog("Are you sure you want to batch compile all script sources in \"%s\"?\n\nThis folder may contain script sources that are supplied with Creation Kit and are a part of the base game. Compiling said script sources could lead to unintended behavior if they have been modified." % config["filedir"]): return else: args["cmd"] = [config["compiler"], config["filename"]] args["cmd"].append("-f=%s" % config["flags"]) args["cmd"].append("-i=%s" % config["import"]) args["cmd"].append("-o=%s" % config["output"]) for debugarg in config["debug"]: if debugarg.startswith("-"): args["cmd"].append("%s" % debugarg) else: args["cmd"].append("-%s" % debugarg) if args.get("batch", False) == True: if config.get("debug", None) != None or ("all" not in config["debug"] and "a" not in config["debug"]): args["cmd"].append("-all") del args["batch"] args["working_dir"] = os.path.dirname(config["compiler"]) self.window.run_command("exec", args) else: sublime.status_message("No configuration for %s" % os.path.dirname(args["cmd"]))
def on_post_save(self, view): dir = view.window().folders() title = "ThinkPHP-CLI.html" title2 = "ThinkPHP-Queryer" content = view.substr(sublime.Region(0, view.size())) global seperator if dir == []: if view.file_name().find(title) != -1: sublime.status_message('Please open a folder') else: if view.file_name().find(title) != -1: query = content.split(seperator) cmd = query[0] command_text = ['php', dir[0] + os.sep + 'index.php', cmd] thread = cli(command_text,view,dir[0]) thread.start() ThreadProgress(thread, 'Is excuting', 'cli excuted') if view.file_name().find(title2) != -1: sql = content if sql == '': sublime.status_message('Pls input correct sql') else: command_text = 'php "' + packages_path + os.sep + 'command.php" "query"' cloums = os.popen(command_text) data = cloums.read() self.window = view.window() show_outpanel(self, 'ThinkPHP-Queryer', data , True)
def open_in_browser(cls, path, browser="default"): if browser == "default": if sys.platform == "darwin": # To open HTML files, Mac OS the open command uses the file # associated with .html. For many developers this is Sublime, # not the default browser. Getting the right value is # embarrassingly difficult. import shlex import subprocess env = {"VERSIONER_PERL_PREFER_32_BIT": "true"} raw = """perl -MMac::InternetConfig -le 'print +(GetICHelper "http")[1]'""" process = subprocess.Popen(shlex.split(raw), env=env, stdout=subprocess.PIPE) out, err = process.communicate() default_browser = out.strip().decode("utf-8") cmd = "open -a '%s' %s" % (default_browser, path) os.system(cmd) else: desktop.open(path) sublime.status_message("Markdown preview launched in default browser") else: cmd = '"%s" %s' % (browser, path) if sys.platform == "darwin": cmd = "open -a %s" % cmd elif sys.platform == "linux2": cmd += " &" elif sys.platform == "win32": cmd = 'start "" %s' % cmd result = os.system(cmd) if result != 0: sublime.error_message('cannot execute "%s" Please check your Markdown Preview settings' % browser) else: sublime.status_message("Markdown preview launched in %s" % browser)
def no_candidate(self): sublime.status_message("no test candidate found, requesting the user") Window().show_input_panel( "No test candidate found. Please enter the command to execute", str("s"), functools.partial(self.user_entered_command_line), None, None)
def nothing_selected(): sublime.status_message('nothing selected, fool')
def showPackageList(self): self.getPackageList() sublime.status_message("Choose a package for the new snippet.") sublime.active_window().show_quick_panel(self.packageList, self.choosePackage)
def log(arg): arg = str(arg) sublime.status_message(arg) pp.pprint(arg)
def on_done(self): sublime.set_clipboard(self.url) sublime.status_message("Remote URL copied to clipboard")
def open_file(self, picked_file): if os.path.isfile(os.path.join(self.root, picked_file)): self.window.open_file(os.path.join(self.root, picked_file)) else: sublime.status_message("File doesn't exist")
def status(msg, console=False): msg = "[%s] %s" % (PACKAGE_NAME, msg) sublime.status_message(msg) if console: print(msg)
def handle_thread(thread, timeout): if thread.is_alive(): sublime.set_timeout(lambda: handle_thread(thread, timeout), timeout) return result = api.result # Output component size size = len(result["records"]) print( message.SEPRATE.format( str(component_type) + " Size: " + str(size))) # Write Components to local components = {} for record in result["records"]: # Get Component Name of this record component_name = record['Name'] component_url = record['attributes']['url'] component_id = record["Id"] print(str(component_type) + " ==> " + str(record['Name'])) # Write mapping of component_name with component_url # into component_metadata.sublime-settings components[component_name] = { "url": component_url, "id": component_id, "type": component_type, "body": component_body, "extension": component_extension } # Judge Component is Test Class or not body = record[component_body] if component_type == "ApexClass": if "@isTest" in body or "testMethod" in body or "testmethod" in body: components[component_name]["is_test"] = True else: components[component_name]["is_test"] = False # Write body to local file fp = open(component_outputdir + "/" + component_name +\ component_extension, "wb") try: body = bytes(body, "UTF-8") except: body = body.encode("UTF-8") fp.write(body) # Set status_message sublime.status_message(component_name + " [" + component_type + "] Downloaded") # Save Refreshed Component Attributes to component_metadata.sublime-settings s = sublime.load_settings(COMPONENT_METADATA_SETTINGS) username = toolingapi_settings["username"] components_dict = s.get(username) components_dict[component_type] = components s.set(username, components_dict) sublime.save_settings(context.COMPONENT_METADATA_SETTINGS)
def on_complete(self, *args, **kwargs): sublime.set_timeout( lambda: sublime.status_message('PyV8 binary successfully loaded'), 0)
def print_with_status(self, message): sublime.status_message(message) print(message)
def run(self, edit): c = self.view.substr(self.view.sel()[0].end()) sublime.status_message("<%s> %d, Hex %s, Octal %s" % (c, ord(c), hex(ord(c))[2:], oct(ord(c))))
def get_entries(self, *bib_files): entries = [] for bibfname in bib_files: bib_cache = bibcache.BibCache("trad", bibfname) try: cached_entries = bib_cache.get() entries.extend(cached_entries) continue except: pass try: bibf = codecs.open(bibfname, 'r', 'UTF-8', 'ignore') # 'ignore' to be safe except IOError: print("Cannot open bibliography file %s !" % (bibfname, )) sublime.status_message("Cannot open bibliography file %s !" % (bibfname, )) continue else: bib_data = bibf.readlines() bib_entries = [] entry = {} for line in bib_data: line = line.strip() # Let's get rid of irrelevant lines first if line == "" or line[0] == '%': continue if line.lower()[0:8] == "@comment": continue if line.lower()[0:7] == "@string": continue if line.lower()[0:9] == "@preamble": continue if line[0] == "@": if 'keyword' in entry: bib_entries.append(entry) entry = {} kp_match = kp.search(line) if kp_match: entry['keyword'] = kp_match.group(1) else: print(u"Cannot process this @ line: " + line) print(u"Previous keyword (if any): " + entry.get('keyword', '')) continue # Now test for title, author, etc. # Note: we capture only the first line, but that's OK for our purposes multip_match = multip.search(line) if multip_match: key = multip_match.group(1).lower() value = codecs.decode(multip_match.group(2), 'latex') if key == 'title': value = value.replace('{\\textquoteright}', '').replace('{', '').replace( '}', '') entry[key] = value continue # at the end, we have a single record if 'keyword' in entry: bib_entries.append(entry) print('Loaded %d bibitems' % (len(bib_entries))) try: bib_cache.set(bib_entries) fmt_entries = bib_cache.get() entries.extend(fmt_entries) except: traceback.print_exc() print("Using bibliography without caching it") entries.extend(bib_entries) finally: try: bibf.close() except: pass print("Found %d total bib entries" % (len(entries), )) return entries
def run(self, edit): changes = {self.gist_filename(): None} update_gist(self.gist_url(), changes) ungistify_view(self.view) sublime.status_message("Gist file deleted")
def parser_specific_convert(self, markdown_text): sublime.status_message('converting markdown with Python markdown...') config_extensions = self.get_config_extensions(DEFAULT_EXT) return markdown.markdown(markdown_text, extensions=config_extensions)
def on_done(index): """ Set the selected theme """ if index != -1: self.set_theme(themes[index][1]) sublime.status_message(themes[index][0])
def run(self, edit, character): sublime.status_message("Set bookmark " + character) self.view.add_regions("bookmark_" + character, [s for s in self.view.sel()], "", "", sublime.PERSISTENT | sublime.HIDDEN)
def run(self): the_theme = Themr.instance().get_theme() favorites = Themr.instance().get_favorites() favorites.append(the_theme) Themr.instance().set_favorites(favorites) sublime.status_message(the_theme + ' added to favorites')
def run(self, edit): text = self.view.substr(sublime.Region(0, self.view.size())) changes = {self.gist_filename(): {'content': text}} update_gist(self.gist_url(), changes) sublime.status_message("Gist updated")
def on_done(select) : if not select == -1 : bm.pop(select) sublime.status_message('Remove selected bookmark.') settings.set('bookmarks', bm) sublime.save_settings('dired.sublime-settings')
def run(self): the_theme = Themr.instance().get_theme() favorites = Themr.instance().get_favorites() favorites.remove(the_theme) Themr.instance().set_favorites(favorites) sublime.status_message(the_theme + ' removed from favorites')
def run(self, enable=None): settings = sublime.load_settings(settings_filename) if enable is None: # toggle enable = not settings.get(build_enable_field) settings.set(build_enable_field, enable) sublime.status_message("AutoBuildLatex Turned %s" % ("On" if enable else "Off"))
def on_sync_done(self, thread): if thread.result: sublime.status_message("Data has been synchronized successfully") else: sublime.error_message(thread.result_message) raise thread.exception
def no_word_selected(self): sublime.status_message('No word was selected.')
def display_warning(warning): for region in PyflakesListener.warning_messages: if region['region'] == warning: sublime.status_message(region['message']) break
def sm(*t, **kwargs): t = kwargs.get('sep', ' ').join([str(el) for el in t]) sublime.status_message(t)
def save_settings(self, theme): sublime.save_settings('Preferences.sublime-settings') sublime.status_message('Theme - Cyanide: ' + theme) print('') print('[Theme - Cyanide] ' + theme) print('')
def pgpass_tip(): url = "www.postgresql.org/docs/9.2/static/libpq-pgpass.html" status_message(url) message_dialog("psql get password from pgpass") status_message(url)
def run(self): rs = [ u'기다리는 중', u'재채점을 기다리는 중', u'컴파일 하는 중', u'채점 중', None, u'출력 형식이 잘못되었습니다', u'틀렸습니다', u'시간 초과', u'메모리 초과', u'출력 초과', u'런타임 에러', u'컴파일 에러' ] for i in range(1, 60): conn = hcl.HTTPConnection('www.acmicpc.net', 80) conn.request('POST', '/cmd/status', urp.urlencode(self.o), {'Content-type': 'application/x-www-form-urlencoded'}) ru = conn.getresponse().read() r = json.loads(ru.decode('utf-8')) conn.close() if r['error']: sublime.status_message(r['error_text']) return a = r['result'] e = int(a['result']) if e == 3: if 'progress' in r: sublime.status_message(u'%s (%s%%)' % (rs[e], r['progress'])) else: sublime.status_message(u'%s' % rs[e]) elif e < 3: sublime.status_message(rs[e]) elif e == 4: sublime.status_message( u'맞았습니다!! / 메모리: %(memory)sKB, 시간: %(time)sms, 코드 길이: %(code_length)sB' % a) break elif e < 10: sublime.status_message(u'%s / 코드 길이: %sB' % (rs[e], a['code_length'])) break else: sublime.status_message(u'%s / 메시지: %s' % (rs[e], r['error_text'])) break time.sleep(1)
def showProblemStatusBar(p): if p['replacements']: msg = u"{0} ({1})".format(p['message'], p['replacements']) else: msg = p['message'] sublime.status_message(msg)
def on_done(i): if i != -1: sublime.set_clipboard(dotted_paths[i]) sublime.status_message("CFML: copied cfc dotted path")