我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用sublime.message_dialog()。
def run(self): info = {} info['platform'] = sublime.platform() info['version'] = sublime.version() info['file_icons_version'] = __version__ info['pc_install'] = is_installed_by_package_control() info['current_theme'] = get_current_theme() info['installed_themes'] = get_installed_themes() msg = textwrap.dedent( '''\ - File Icons: %(file_icons_version)s - Sublime Text: %(version)s - Platform: %(platform)s - Package Control: %(pc_install)s - Current Theme: %(current_theme)s - Installed Themes: %(installed_themes)s ''' % info ) sublime.message_dialog( msg + '\nInfo has been copied to the clipboard.' ) sublime.set_clipboard(msg)
def run(self, edit): scope = self.view.scope_name(self.view.sel()[0].a) if "source.json" in scope or "source.sublimecompletions" in scope: print("Atomizr: JSON detected, trying to convert") self.view.run_command('subl_to_atom') elif "source.coffee" in scope: print("Atomizr: CoffeeScript detected, trying to convert") self.view.run_command('atom_to_subl') elif "text.xml" in scope: print("Atomizr: XML detected, trying to convert") self.view.run_command('subl_snippets_to_atom') elif "text.plain" in scope: sublime.message_dialog("Atomizr\n\nAutomatic conversion requires a supported CoffeeScript package to be installed") else: sublime.message_dialog("Atomizr\n\nUnsupported scope, aborting") # Convert Atom format
def run(self, edit, languageName=None, set_fallback=False, is_init=False): view = self.view global currentView currentView = view if self.downloading: sublime.message_dialog('Another progress is working for checkout ' + self.downloading + '. Please try again later.') return self.languageList, index = getLanguageList(languageName) self.set_fallback = set_fallback if languageName: self.updateLanguage(index) else: currentView.window().show_quick_panel(self.languageList, self.updateLanguage, sublime.KEEP_OPEN_ON_FOCUS_LOST)
def checkoutLanguage(self): global language languageName = self.languageName if not self.downloadLanguageGZ(languageName): if getSetting('debug'): print('download error') return False setSetting('language', languageName) language = languageName languageSettings = currentSettings.get('languages') languageSettings[languageName] = 'gz' setSetting('languages', languageSettings) if self.set_fallback: setSetting('language_fallback', languageName) loadLanguage() sublime.message_dialog('Language ' + languageName + ' is checked out')
def _finish(self): """ make and write tsconfig.json. Call finished_callback """ Debug('project+', 'Wizzard finished: Create and write tsconfig.json') content = { "compilerOptions" : {}, "files" : {}} if self.module is None: content['compilerOptions']['out'] = self.outfile content['compilerOptions']['target'] = self.target content['compilerOptions']['sourceMap'] = self.sourcemap elif self.module == "commonjs" or self.module == "amd": content['compilerOptions']['outDir'] = self.outdir content['compilerOptions']['target'] = self.target content['compilerOptions']['sourceMap'] = self.sourcemap content['compilerOptions']['module'] = self.module content['files'] = self.files self.write_json_to_tsconfigfile(content) if self.finished_callback: self.finished_callback() sublime.active_window().open_file(self.tspath) sublime.message_dialog("For more compilerOptions, see tsc --help.\n\n To configure ArcticTypescript, see README.md") self._cleanup()
def on_model_name_provided(self, name): response, code = HTTP.post(self.env.project_manager.get_build_api_key(), PL_BUILD_API_URL_V4 + "models/", '{"name" : "' + name + '" }') if not HTTP.is_response_code_valid(code) \ and sublime.ok_cancel_dialog(STR_MODEL_NAME_EXISTS): self.create_new_model(False) return elif not HTTP.is_response_code_valid(code): sublime.message_dialog(STR_MODEL_FAILED_TO_CREATE) return # Save newly created model to the project settings settings = self.load_settings() settings[EI_MODEL_ID] = response.get("model").get("id") settings[EI_MODEL_NAME] = response.get("model").get("name") self.env.project_manager.save_settings(PR_SETTINGS_FILE, settings) self.update_model_name_in_status(query_model_name=False) # Reset the logs self.env.log_manager.reset() # Check settings self.check_settings(selecting_or_creating_model=True)
def on_device_to_add_selected(self, index): # Selection was canceled, just return if index == -1: return model = self.env.tmp_model device_id = self.env.tmp_device_ids[index] response, code = HTTP.put(self.env.project_manager.get_build_api_key(), PL_BUILD_API_URL_V4 + "devices/" + device_id, '{"model_id": "' + model.get("id") + '"}') if not HTTP.is_response_code_valid(code): sublime.message_dialog(STR_MODEL_ADDING_DEVICE_FAILED) # Once the device is registered, select this device self.on_device_selected(index) sublime.message_dialog(STR_MODEL_IMP_REGISTERED) self.env.tmp_model = None self.env.tmp_device_ids = None
def add_device(self, need_to_confirm=True): model = self.load_this_model() if not model: sublime.message_dialog(STR_MODEL_NOT_ASSIGNED) return if need_to_confirm and not sublime.ok_cancel_dialog(STR_MODEL_ADD_DEVICE): return device_ids = model.get("devices") (device_ids, device_names) = self.load_devices(exclude_device_ids=device_ids) if len(device_ids) == 0: sublime.message_dialog(STR_NO_DEVICES_AVAILABLE) return self.env.tmp_model = model self.env.tmp_device_ids = device_ids self.window.show_quick_panel(device_names, self.on_device_to_add_selected)
def on_remove_device_selected(self, index): device_id = self.env.tmp_device_ids[index] active_device_id = self.load_settings().get(EI_DEVICE_ID) if device_id == active_device_id: sublime.message_dialog(STR_MODEL_CANT_REMOVE_ACTIVE_DEVICE) return response, code = HTTP.put(self.env.project_manager.get_build_api_key(), PL_BUILD_API_URL_V4 + "devices/" + device_id, '{"model_id": ""}') if not HTTP.is_response_code_valid(code): sublime.message_dialog(STR_MODEL_REMOVE_DEVICE_FAILED) return sublime.message_dialog(STR_MODEL_DEVICE_REMOVED) self.env.tmp_model = None self.env.tmp_device_ids = None
def run(self, edit): scope_name = [] settings = [] for i in range(500): t = time.time() self.view.scope_name(0) scope_name.append(time.time() - t) for i in range(500): t = time.time() self.view.settings().get('markdown_live_preview_enabled') settings.append(time.time() - t) msg = ["scope_name: {}".format(sum(scope_name) / len(scope_name))] msg += ["settings : {}".format(sum(settings) / len(settings))] msg = '\n'.join(msg) sublime.message_dialog(msg)
def run(self): self.recent_workspaces = self.get_recent_workspaces() if not self.recent_workspaces: return sublime.error_message('No project to load!') for i, recent_workspace in enumerate(self.recent_workspaces): self.recent_workspaces[i] = recent_workspace.replace('C/', 'C:/').strip('/') # only display workspaces that really exist self.recent_workspaces_that_really_exist = [] for recent_workspace in self.recent_workspaces: if os.path.isfile(recent_workspace): self.recent_workspaces_that_really_exist.append(recent_workspace) sublime.message_dialog(str(self.recent_workspaces_that_really_exist)) self.window.show_quick_panel(self.recent_workspaces_that_really_exist, self.on_done)
def _log(message, *args, status=False, dialog=False): """ A simple logic facility to ensure that all console output is prefixed with the package name so the source is clear. Can also optionally send the output to the status line and/or a message dialog. """ message = message % args print("HyperHelp:", message) if status: sublime.status_message(message) if dialog: sublime.message_dialog(message)
def display_confirmation_message(self, files_without_key, files_with_key): confirmation_message = "" for key, value in self.properties.items(): confirmation_message += "Property " + key + "=" + value + " was: " if files_without_key[key]: confirmation_message += "\nAdded in files:\n" + "\n".join(files_without_key[key]) if files_with_key[key]: confirmation_message += "\n\nEdited in files:\n" + "\n".join(files_with_key[key]) confirmation_message += "\n\n" sublime.message_dialog(confirmation_message)
def display_confirmation_message(self, files_without_key, files_with_key): confirmation_message = "Property with key " + self.key + " was: " if files_with_key: confirmation_message += "\nRemoved in files:\n" + "\n".join(files_with_key) if files_without_key: confirmation_message += "\n\nNot found in files:\n" + "\n".join(files_without_key) if files_without_key: sublime.error_message(confirmation_message) else: sublime.message_dialog(confirmation_message)
def display_confirmation_message(self, files_without_old_key, files_with_new_key, files_with_renamed_key): confirmation_message = "Key " + self.old_key + " was: " if files_with_renamed_key: confirmation_message += "\nRenamed in files:\n" + "\n".join(files_with_renamed_key) if files_without_old_key: confirmation_message += "\n\nNot found in files:\n" + "\n".join(files_without_old_key) if files_with_new_key: confirmation_message += "\n\nKey " + self.new_key + " already exists in files:\n" + "\n".join(files_with_new_key) if files_without_old_key or files_with_new_key: sublime.error_message(confirmation_message) else: sublime.message_dialog(confirmation_message)
def message(record): """ shows text in message dialog """ sublime.message_dialog(record.msg)
def run(self, edit): scope = self.view.scope_name(self.view.sel()[0].a) if "source.json" in scope: print("Atomizr: JSON detected, trying to convert to CSON") self.view.run_command('atom_json_to_cson') elif "source.coffee" in scope: print("Atomizr: CSON detected, trying to convert to JSON") self.view.run_command('atom_cson_to_json') else: sublime.message_dialog("Atomizr\n\nUnsupported scope, aborting") # Converts Atom snippets into Sublime Text completions
def run(self, edit): import cson, json # read data from view selection = self.view.substr(sublime.Region(0, self.view.size())) # interprete and validate data try: data = cson.loads(selection) except BaseException as e: sublime.message_dialog("Atomizr\n\nInvalid CSON, aborting conversion. See console for details.") print(e) sort_keys = sublime.load_settings('Atomizr.sublime-settings').get("json_sort_keys") or False indent = sublime.load_settings('Atomizr.sublime-settings').get("json_indentation") or 2 # write converted data to view selection = sublime.Region(0, self.view.size()) self.view.replace(edit, selection, json.dumps(data, sort_keys=sort_keys, indent=indent, separators=(',', ': '))) # set syntax to JSON Helpers.set_json(self) Helpers.rename_file(self, "json") # Reset selection Helpers.reset_selection(self) # Converts Atom snippets (JSON into CSON)
def run(self, edit): import cson, json # read data from view selection = self.view.substr(sublime.Region(0, self.view.size())) # interprete and validate data try: data = json.loads(selection) except BaseException as e: sublime.message_dialog("Atomizr\n\nInvalid JSON, aborting conversion. See console for details.") print(e) sort_keys = sublime.load_settings('Atomizr.sublime-settings').get("cson_sort_keys") or True indent = sublime.load_settings('Atomizr.sublime-settings').get("cson_indentation") or 2 # write converted data to view selection = sublime.Region(0, self.view.size()) self.view.replace(edit, selection, ATOM_GENERATOR + cson.dumps(data, sort_keys=sort_keys, indent=indent)) # set syntax to CSON, requires supported CoffeeScript package if Helpers.get_coffee(self) is True: Helpers.rename_file(self, "cson") # Reset selection Helpers.reset_selection(self) # Converts Atom snippets into Visual Studio Code snippets
def run(self, edit): import cson, json # read data from view input = self.view.substr(sublime.Region(0, self.view.size())) try: data = cson.loads(input) except BaseException as e: sublime.message_dialog("Atomizr\n\nInvalid CSON, aborting conversion. See console for details.") print(e) for key in data.keys(): if key[0] != ".": sublime.message_dialog("Atomizr\n\nNot an Atom snippet file") return output = data[key] sort_keys = sublime.load_settings('Atomizr.sublime-settings').get("json_sort_keys") or True indent = sublime.load_settings('Atomizr.sublime-settings').get("json_indentation") or 2 selection = sublime.Region(0, self.view.size()) self.view.replace(edit, selection, json.dumps(output, sort_keys=sort_keys, indent=indent, separators=(',', ': '))) # set syntax to JSON Helpers.set_json(self) Helpers.rename_file(self, "json") # Reset selection Helpers.reset_selection(self) # Converts Sublime Text into Atom snippets
def run(self, edit): scope = self.view.scope_name(self.view.sel()[0].a) if "source.json" in scope or "source.sublimecompletions" in scope: print("Atomizr: JSON detected, trying to convert to XML") self.view.run_command('subl_json_to_xml') elif "text.xml" in scope: print("Atomizr: XML detected, trying to convert to JSON") self.view.run_command('subl_xml_to_json') else: sublime.message_dialog("Atomizr\n\nUnsupported scope, aborting") # Converts Sublime Text snippets into Sublime Text completions
def run(self, edit): import cson, json scope = self.view.scope_name(self.view.sel()[0].a) # read data from view input = self.view.substr(sublime.Region(0, self.view.size())) if "source.json" in scope or "source.sublimecompletions" in scope: print("Atomizr: JSON detected, trying to convert") data = SublimeText.read_json(input) elif "text.xml" in scope: print("Atomizr: XML detected, trying to convert") data = SublimeText.read_xml(input) else: sublime.message_dialog("Atomizr\n\nNot a Sublime Text completions file") if data is False: return output = VsCode.write_json(data) sort_keys = sublime.load_settings('Atomizr.sublime-settings').get("json_sort_keys") or True indent = sublime.load_settings('Atomizr.sublime-settings').get("json_indentation") or 2 selection = sublime.Region(0, self.view.size()) self.view.replace(edit, selection, json.dumps(output, sort_keys=sort_keys, indent=indent, separators=(',', ': '))) # set syntax to JSON Helpers.set_json(self) Helpers.rename_file(self, "sublime-completions") # Reset selection Helpers.reset_selection(self) # Convert Visual Studio Code into Atom snippets
def get_coffee(this): import os # package locations locations = [sublime.installed_packages_path(), sublime.packages_path()] # supported packages packages = ["Better CoffeeScript", "CoffeeScript", "IcedCoffeeScript", "Mongoose CoffeeScript"] # iterate over packages locations for location in locations: # iterate over packages installed with Package Control for package in packages: # is "ignored_package"? settings = sublime.load_settings('Preferences.sublime-settings').get("ignored_packages") if package in settings: continue if os.path.isfile(location + "/" + package + ".sublime-package") is True: if package is "IcedCoffeeScript": this.view.set_syntax_file("Packages/IcedCoffeeScript/Syntaxes/IcedCoffeeScript.tmLanguage") return True elif package is "Mongoose CoffeeScript": this.view.set_syntax_file("Packages/Mongoose CoffeeScript/CoffeeScript.tmLanguage") return True else: this.view.set_syntax_file("Packages/" + package + "/CoffeeScript.tmLanguage") return True sublime.message_dialog("Atomizr\n\nAutomatic conversion requires a supported CoffeeScript package to be installed") return False
def read_json(input): """Reads Visual Studio Code snippets, returns object""" import json # interprete and validate data try: data = json.loads(input) except BaseException as e: sublime.message_dialog("Atomizr\n\nInvalid JSON, aborting conversion. See console for details.") print(e) return False completions = [] # but is it a Visual Studio snippet? try: for k in data: prefix = data[k]["prefix"] if "description" in data[k]: description = data[k]["description"] body = Helpers.remove_trailing_tabstop(data[k]["body"]) if "description" in data[k]: completions.append( {"trigger": prefix, "contents": body, "description": description} ) else: completions.append( {"trigger": prefix, "contents": body} ) except: sublime.message_dialog("Atomizr\n\nNot a Visual Studio Code snippet file") return False output = { "scope": "source", "completions": completions } return output
def md(*t, **kwargs): sublime.message_dialog(kwargs.get('sep', '\n').join([str(el) for el in t]))
def show_in_dialog(message_str): sublime.message_dialog(xstr(message_str))
def show_in_panel(message_str): # sublime.message_dialog(message_str) XyPanel.show_in_panel("xypanel", xstr(message_str))
def run(self, paths = []): sublime.message_dialog('Sidebar Enhancements: Thanks for your support ^.^') browser = s.get('default_browser', '') SideBarOpenInBrowserThread('','','').try_open("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DD4SL2AHYJGBW", browser)
def update_interpreter_build_system(self, cmd): """Updates the project and adds/modifies the build system """ view = active_view() if get_settings(view, 'auto_python_builder_enabled', True) is False: return if is_remote_session(view): return if cmd is None: sublime.message_dialog( 'Your python interpreter is not set or is invalid' ) return project = self._get_project() if project.get('build_systems', False) is not False: if type(project['build_systems']) is list: done = False current_list = project['build_systems'] for i in range(len(current_list)): build = current_list[i] if build['name'] == 'Anaconda Python Builder': current_list[i] = self._parse_tpl(cmd) done = True break if not done: project['build_systems'].append(self._parse_tpl(cmd)) else: sublime.message_dialog( 'Your project build_systems is messed up' ) else: project.update({ 'build_systems': [self._parse_tpl(cmd)] }) self._save_project(project)
def update_interpreter_settings(self, venv_path: str) -> None: """Updates the project and adds/modifies the Venv path""" project_data = self.get_project_data() # Check if have settings set in the project settings if project_data.get('settings', False): try: # Try to get the python_interpreter key project_data['settings'].get('python_interpreter', False) except AttributeError: # If this happens that mean your settings is a sting not a dict sublime.message_dialog( 'Ops your project settings is missed up' ) else: # Set the path and save the project project_data['settings']['python_interpreter'] = venv_path self.save_project_data(project_data) else: # This will excute if settings key is not in you project settings project_data.update( { 'settings': {'python_interpreter': venv_path} } ) self.save_project_data(project_data) AnacondaSetPythonBuilder().update_interpreter_build_system( venv_path )
def run(self, edit: sublime.Edit) -> None: self.data = None # type: List[str] location = self.view.rowcol(self.view.sel()[0].begin()) if not self._detected_undefined_name(location): sublime.message_dialog( 'The word under the cursor is not an undefined name.') return for name in self.data: self.insert_import(edit, name)
def _create_tsconfigjson(self): """ Location for the tsconfig.json file """ Debug('project+', 'Ask for tsconfig.json location') self.window.show_input_panel("Location for tsconfig.json (use your project folder)", os.path.dirname(self.view.file_name()), lambda folder: self._set_folder_and_go_on(folder), None, # on change lambda: [self._cleanup(), set_plugin_temporarily_disabled(folder=self.view), sublime.message_dialog( "ArcticTypescript disabled for this file's folder")] )
def _ask_output_directory(self, default="built/"): """ For multiple file output, ask for the output directory """ Debug('project+', 'Ask for output directory') self.window.show_input_panel("Relative output FOLDER for all compiled js files: %s/" % self.tsconfigfolder, default, lambda outdir: [self._set_outdir(outdir), self._ask_for_files()], None, # on change lambda: [self._cleanup(), set_plugin_temporarily_disabled(folder=self.view), sublime.message_dialog( "ArcticTypescript disabled for this file's folder")])
def _ask_for_files(self, dialog=True): """ Ask to define all files which are the roots of the reference tree """ if dialog: sublime.message_dialog("Please name all files which should be compiled, relative to %s/ \n \n You don't need to specify files which are refrenced using /// <reference> or import a = require('a');\n\n So only name the files which are on top of your reference tree.\n\n Press <Esc> or enter nothing to finish." % self.tsconfigfolder) firstfile = os.path.relpath(self.view.file_name(), self.tsconfigfolder) Debug('project+', 'Ask for files') self.window.show_input_panel("(%i) Please name all files which should be compiled, relative to %s/" % (len(self.files), self.tsconfigfolder), firstfile if dialog else "", lambda file: self._file_entered(file), None, # on change lambda: self._file_entered(""))
def run(self, edit): settings = sublime.load_settings("GoTests.sublime-settings") gopath = settings.get("GOPATH", "") if os.environ.get("GOPATH") == None: if gopath != "": # Set $GOPATH in this shell and add $GOPATH/bin to $PATH. os.environ["GOPATH"] = gopath os.environ["PATH"] += os.pathsep + os.path.join(gopath, "bin") else: sublime.message_dialog("GoTests: GOPATH is not set.") return False fn = self.view.file_name() if fn and fn.endswith('.go') and not fn.endswith('_test.go'): fs = [] for s in self.view.sel(): line = self.function_line(s.begin()) i = line.begin() while i <= s.end(): f = self.function_name(line) i = line.end() + 1 line = self.view.line(i) if not f: continue fs.append(f) try: gotests = settings.get("gotests_cmd", "gotests") cmd = [gotests, '-w', '-only=(?i)^(' + "|".join(fs) + ')$', fn] proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) print(proc.stdout.read().decode("utf-8").replace('\r\n', '\n')) except OSError as e: sublime.message_dialog("GoTests error: " + str(e) + ".") return False return True return False # Returns a function signature's line from a point in its body.
def check_settings(self, callback=None, selecting_or_creating_model=None): # Setup pending callback if callback: self.env.tmp_check_settings_callback = callback else: callback = getattr(self.env, "tmp_check_settings_callback", None) if selecting_or_creating_model is not None: self.env.tmp_selecting_or_creating_model = selecting_or_creating_model else: selecting_or_creating_model = getattr(self.env, "tmp_selecting_or_creating_model", None) key = self.env.project_manager.get_build_api_key() # Perform the checks and prompts for appropriate settings if self.is_missing_node_js_path(): self.prompt_for_node_js_path() elif self.is_missing_builder_cli_path(): self.prompt_for_builder_cli_path() elif not key or not HTTP.is_build_api_key_valid(key): self.prompt_for_build_api_key() elif not selecting_or_creating_model and self.is_missing_model(): sublime.message_dialog(STR_MODEL_NOT_ASSIGNED) else: # All the checks passed, invoke the callback now if callback: callback() self.env.tmp_check_settings_callback = None self.env.tmp_selecting_or_creating_model = None
def select_device(self, need_to_confirm=True): model = self.load_this_model() if not model: sublime.message_dialog(STR_MODEL_NOT_ASSIGNED) return device_ids = model.get("devices") if not device_ids or not len(device_ids): sublime.message_dialog(STR_MODEL_HAS_NO_DEVICES) return if need_to_confirm and not sublime.ok_cancel_dialog(STR_SELECT_DEVICE): return (Env.For(self.window).tmp_device_ids, device_names) = self.load_devices(input_device_ids=device_ids) self.window.show_quick_panel(device_names, self.on_device_selected)
def run(self): self.init_env_and_settings() def check_settings_callback(): settings = self.load_settings() if EI_DEVICE_ID in settings: device_id = settings.get(EI_DEVICE_ID) response, code = HTTP.get(self.env.project_manager.get_build_api_key(), PL_BUILD_API_URL_V4 + "devices/" + device_id) agent_id = response.get("device").get("agent_id") agent_url = PL_AGENT_URL.format(agent_id) sublime.set_clipboard(agent_url) sublime.message_dialog(STR_AGENT_URL_COPIED.format(device_id, agent_url)) self.check_settings(callback=check_settings_callback)
def select_existing_model(self, need_to_confirm=True): response, code = HTTP.get(self.env.project_manager.get_build_api_key(), PL_BUILD_API_URL_V4 + "models") if len(response["models"]) > 0: if need_to_confirm and not sublime.ok_cancel_dialog(STR_MODEL_SELECT_EXISTING_MODEL): return all_model_names = [model["name"] for model in response["models"]] self.__tmp_all_models = [(model["id"], model["name"]) for model in response["models"]] else: sublime.message_dialog(STR_MODEL_NO_MODELS_FOUND) return self.window.show_quick_panel(all_model_names, self.on_model_selected)
def prompt_model_to_remove_device(self, need_to_confirm=True): if need_to_confirm and not sublime.ok_cancel_dialog(STR_MODEL_REMOVE_DEVICE): return model = self.load_this_model() device_ids = model.get("devices") if model else None if not device_ids or len(device_ids) == 0: sublime.message_dialog(STR_MODEL_NO_DEVICES_TO_REMOVE) return (Env.For(self.window).tmp_device_ids, device_names) = self.load_devices(input_device_ids=device_ids) self.window.show_quick_panel(device_names, self.on_remove_device_selected)
def run(self, *args, **kwargs): tool = kwargs.get("tool", "atllbuild") build_last = kwargs.get("build_last", False) if not self.window.project_file_name(): return pkg = Package.fromFile(atpkgTools.findAtpkg(self.window.project_file_name())) probable_task = pkg.task_for_file(self.window.active_view().file_name()) if not build_last: tasks = [] idx = 0 for (name, task) in pkg.tasks.items(): if task.tool != tool: continue desc = "Task group" if task.tool == "atllbuild": desc = "Compile Swift " + task.output_type.replace("-", " ") elif task.tool == "shell": desc = "Run Shell script" elif task.tool == "xctestrun": desc = "Execute Tests" if task == probable_task: idx = len(tasks) tasks.append([name, desc]) if len(tasks) == 0: sublime.message_dialog("SublimeAnarchy\n\nThere are no tasks to run") return if len(tasks) == 1: self.build(pkg, tasks, 0) return self.window.show_quick_panel(tasks, lambda x: self.build(pkg, tasks, x), 0, idx) else: if self.window.id() in last_build_target: BuildWithATBuild(self.window, pkg, last_build_target[self.window.id()]).start()
def run(self, edit): s = sublime.load_settings('phpfmt.sublime-settings') php_bin = s.get("php_bin", "php") formatter_path = os.path.join(dirname(realpath(sublime.packages_path())), "Packages", "phpfmt", "fmt.phar") s = debugEnvironment(php_bin, formatter_path) sublime.message_dialog(s)
def get_code(self, type='text' ): code = '' file_name = "%s.tmpl" % type isIOError = False if IS_GTE_ST3: tmpl_dir = 'Packages/' + PACKAGE_NAME + '/' + TMLP_DIR + '/' user_tmpl_dir = 'Packages/User/' + PACKAGE_NAME + '/' + TMLP_DIR + '/' else: tmpl_dir = os.path.join(PACKAGES_PATH, PACKAGE_NAME, TMLP_DIR) user_tmpl_dir = os.path.join(PACKAGES_PATH, 'User', PACKAGE_NAME, TMLP_DIR) self.user_tmpl_path = os.path.join(user_tmpl_dir, file_name) self.tmpl_path = os.path.join(tmpl_dir, file_name) if IS_GTE_ST3: try: code = sublime.load_resource(self.user_tmpl_path) except IOError: try: code = sublime.load_resource(self.tmpl_path) except IOError: isIOError = True else: if os.path.isfile(self.user_tmpl_path): code = self.open_file(self.user_tmpl_path) elif os.path.isfile(self.tmpl_path): code = self.open_file(self.tmpl_path) else: isIOError = True if isIOError: sublime.message_dialog('[Warning] No such file: ' + self.tmpl_path + ' or ' + self.user_tmpl_path) return self.format_tag(code)
def log(message, *args, status=False, dialog=False): """ Simple logging method; writes to the console and optionally also the status message as well. """ message = message % args print("OverrideAudit:", message) if status: sublime.status_message(message) if dialog: sublime.message_dialog(message)
def md(*t): t = ' '.join([str(txt) for txt in t]) sublime.message_dialog(t)
def m(self, text): sublime.message_dialog(str(text))
def md(*t): t = ' '.join([str(el) for el in t]) sublime.message_dialog(t)
def md(*t, **kwargs): t = kwargs.get('sep', ' ').join([str(el) for el in t]) sublime.message_dialog(t)
def md(*t, **kwargs): sublime.message_dialog(kwargs.get('sep', ' ').join([str(el) for el in t]))