def run(self): self.logEnabled = not self.logEnabled sublime.log_commands(self.logEnabled) if self.logEnabled: self.window.run_command('show_panel', {'panel': 'console', 'toggle': False} ) else: self.window.run_command('hide_panel', {'panel': 'console'} )
def run(self, edit): if self.debug: sublime.log_commands(True) self.save() self.prettify(edit) if self.debug: sublime.log_commands(False)
def plugin_loaded(): global settings settings = sublime.load_settings("deeplTranslate.sublime-settings") sublime.log_commands(False) sublime.active_window().run_command("show_panel", {"panel": "console", "toggle": True}) print('DeepL auth_key loaded:', settings.get('auth_key')) print('DeepL Translating From:', settings.get('source_language'), ' To:', settings.get('target_language')) print('DeepL Keep Moving Down the line?', settings.get('keep_moving_down'))
def run(self): self.enabled = not self.enabled sublime.log_build_systems(self.enabled) sublime.log_commands(self.enabled) # sublime.log_indexing(self.enabled) sublime.log_input(self.enabled) sublime.log_result_regex(self.enabled)
def plugin_loaded(): if _DEBUG: # pragma: no cover sublime.log_input(True) sublime.log_commands(True) _init_backwards_compat_patches() loading_exeption = None pc_event = None try: from package_control import events if events.install('NeoVintageous'): # pragma: no cover pc_event = 'install' if events.post_upgrade('NeoVintageous'): # pragma: no cover pc_event = 'post_upgrade' except ImportError: # pragma: no cover pass # Package Control isn't available (PC is not required) except Exception as e: # pragma: no cover traceback.print_exc() loading_exeption = e try: _update_ignored_packages() except Exception as e: # pragma: no cover traceback.print_exc() loading_exeption = e try: load_session() load_rc() except Exception as e: # pragma: no cover traceback.print_exc() loading_exeption = e if _startup_exception or loading_exeption: # pragma: no cover clean_views() if isinstance(_startup_exception, ImportError) or isinstance( loading_exeption, ImportError): if pc_event == 'post_upgrade': message = "Failed to load some modules trying to upgrade NeoVintageous. "\ "Please restart Sublime Text to finish the upgrade." else: message = "Failed to load some NeoVintageous modules. "\ "Please restart Sublime Text." else: if pc_event == 'post_upgrade': message = "An error occurred trying to upgrade NeoVintageous. "\ "Please restart Sublime Text to finish the upgrade." else: message = "An error occurred trying to load NeoVintageous. "\ "Please restart Sublime Text." print('NeoVintageous: ERROR', message) sublime.message_dialog(message)
def run(): global g_bVerbose global g_bCommands global g_bInput g_bVerbose = False g_bCommands = False g_bInput = False sublime.log_commands(g_bCommands) sublime.log_input(g_bInput)
def on_done(self, text): text = text.split(' ') for t in text: if t == 'cmd1': sublime.log_commands(True) elif t == 'cmd0': sublime.log_commands(False) elif t == 'ipt1': sublime.log_input(True) elif t == 'ipt0': sublime.log_input(False) else: em('Unknow abbr!')
def run(self, edit): window = self.view.window() sublime.log_commands(True) sublime.log_input(True) sublime.status_message("Press the key to describe...") print('\n'*10) window.run_command('show_panel', {'panel': 'console', 'toggle': False}) # deactivate the panel window.focus_group(window.active_group()) sublime.set_timeout(self.disable, 2000)
def run(self, edit): """Enables and disabled Sublime API log_commands. Enable/disable is controlled by robot_framework_log_commands setting. For more details, see the Sublime API document: https://www.sublimetext.com/docs/3/api_reference.html """ setting = get_setting(SettingObject.log_commands) if setting: sublime.log_commands(True) sublime.status_message("log_commands is enabled") else: sublime.log_commands(False) sublime.status_message("log_commands is disabled")
def run(self, edit): """Enables and disabled Sublime API log_commands. Enable/disable is controlled by robot_framework_log_commands setting. For more details, see the Sublime API document: https://www.sublimetext.com/docs/3/api_reference.html """ setting = get_setting(SettingObject.log_commands) if setting: sublime.log_commands(True) sublime.status_message('log_commands is enabled') else: sublime.log_commands(False) sublime.status_message('log_commands is disabled')
def _set_debug_mode(flag): log_commands(flag) log_input(flag) # Create or remove the debug indicator file. if _debug_indicator_file_exists(): if not flag: os.remove(_debug_indicator_file_name()) else: if flag: with open(_debug_indicator_file_name(), 'w+', encoding='utf8') as f: f.write('') preferences = load_settings('Preferences.sublime-settings') plugins = {} for setting in _debug_plugins_meta: if isinstance(setting, tuple): plugin_name, settings = setting plugins[plugin_name] = load_settings(plugin_name + '.sublime-settings') if isinstance(settings, str): settings = [settings] for key in settings: print('Scriptease: {} \'{}\''.format( 'enable' if flag else 'disable', setting)) if flag: plugins[plugin_name].set(key, True) else: plugins[plugin_name].erase(key) else: print('Scriptease: {} \'{}\''.format( 'enable' if flag else 'disable', setting)) if flag: preferences.set(str(setting), True) else: preferences.erase(str(setting)) for plugin in plugins.keys(): save_settings(plugin + '.sublime-settings') save_settings('Preferences.sublime-settings')
def _set_debug_mode(flag): log_commands(flag) log_input(flag) # Create or remove the debug indicator file. if _debug_indicator_file_exists(): if not flag: os.remove(_debug_indicator_file_name()) else: if flag: with open(_debug_indicator_file_name(), 'w+', encoding='utf8') as f: f.write('') preferences = load_settings('Preferences.sublime-settings') plugins = {} for setting in _debug_plugins_meta: if isinstance(setting, tuple): plugin_name, settings = setting plugins[plugin_name] = load_settings(plugin_name + '.sublime-settings') if isinstance(settings, str): settings = [settings] for key in settings: print('Scriptease: {} \'{}\''.format('enable' if flag else 'disable', setting)) if flag: plugins[plugin_name].set(key, True) else: plugins[plugin_name].erase(key) else: print('Scriptease: {} \'{}\''.format('enable' if flag else 'disable', setting)) if flag: preferences.set(str(setting), True) else: preferences.erase(str(setting)) for plugin in plugins.keys(): save_settings(plugin + '.sublime-settings') save_settings('Preferences.sublime-settings')
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.options = [ 'commands', 'input', 'commands+input', 'build systems', 'result regex', 'build systems+result regex', 'indexing', ] self.toggles = { 'commands': lambda x: sublime.log_commands(x), 'input': lambda x: sublime.log_input(x), 'build systems': lambda x: sublime.log_build_systems(x), 'result regex': lambda x: sublime.log_result_regex(x), 'indexing': lambda x: sublime.log_indexing(x), }
def run(self): self.logging = not self.logging sublime.log_commands(self.logging) print("setting logging to: ", self.logging)
import sublime sublime.log_commands(True) import sublime_plugin from sublimation import block_select from sublimation import json_plist_toggle from sublimation import update_api_docs class BlockSelectCommand(sublime_plugin.TextCommand): def run(self, edit): block_select.block_select(self, edit) class JsonPlistToggleCommand(sublime_plugin.TextCommand): def run(self, edit): json_plist_toggle.json_plist_toggle(self, edit) class UpdateApiDoc(sublime_plugin.TextCommand): def run(self, edit): print "running" update_api_docs.update_api_docs(self)
def run(self, edit): sublime.log_commands(False)
def run(self): self.flag = not self.flag sublime.log_commands(self.flag)
def plugin_loaded(): value = get_setting() sublime.log_input(value); sublime.log_commands(value); sublime.log_result_regex(value);
def disable_st_debug_mode_action(self): log_commands(False) log_input(False)
def debug(f): if zen_settings.get('debug'): sublime.log_commands(True) print 'ZenCoding:', f
def disable(self): sublime.log_commands(False) sublime.log_input(False) sublime.status_message("")
def ToggleCommands(): global g_bCommands g_bCommands = not g_bCommands sublime.log_commands(g_bCommands)
def plugin_loaded(): # Enable sublime debug information if in DEBUG mode. if bool(os.getenv('SUBLIME_NEOVINTAGEOUS_DEBUG')): sublime.log_input(True) sublime.log_commands(True) pc_event = None try: from package_control import events if events.install('NeoVintageous'): pc_event = 'install' if events.post_upgrade('NeoVintageous'): pc_event = 'post_upgrade' except ImportError: pass # Package Control isn't available (PC is not required) except Exception: import traceback traceback.print_exc() try: _update_ignored_packages() except Exception: import traceback traceback.print_exc() try: _loading_exeption = None from NeoVintageous.nv import rc rc.load() window = sublime.active_window() if window: # Hack to correctly set the current woring directory. The way # settings are handled needs to be completley overhauled. def set_window_cwd(window): settings = window.settings().get('vintage') if not isinstance(settings, dict): settings = {} variables = window.extract_variables() if 'folder' in variables: settings['_cmdline_cd'] = variables['folder'] window.settings().set('vintage', settings) set_window_cwd(window) except Exception as e: import traceback traceback.print_exc() _loading_exeption = e if _startup_exception or _loading_exeption: try: _cleanup_views() except Exception: import traceback traceback.print_exc() if isinstance(_startup_exception, ImportError) or isinstance(_loading_exeption, ImportError): if pc_event == 'post_upgrade': message = "Failed to load some modules trying to upgrade NeoVintageous. "\ "Please restart Sublime Text to finish the upgrade." else: message = "Failed to load some NeoVintageous modules. "\ "Please restart Sublime Text." else: if pc_event == 'post_upgrade': message = "An error occurred trying to upgrade NeoVintageous. "\ "Please restart Sublime Text to finish the upgrade." else: message = "An error occurred trying to load NeoVintageous. "\ "Please restart Sublime Text." print('NeoVintageous: ERROR', message) sublime.message_dialog(message)
def run(self,enable,toggle): if toggle: self.state=not self.state else: self.state=enable sublime.log_commands(self.state)
# https://github.com/zzjin/syncViewScroll # which is licensed under GNU # Copyright (C) 2012 Tito Bouzout <*****@*****.**> # TODOS: Auto Language detection + comment syntax {} # Find, Search, Replace, Save, Save as, Save all # IE Non text based shortcuts # Double click to select a line selects the new line char too, so isnt being counted as "select line" # Probably falsely. languagesCommentSymbol = [] keyHistory = [] actionLog = [] actionLineLog = [] specialkey = "cmd" if sublime.platform() == "osx" else "ctrl" sublime.log_commands(False) sublime.log_input(False) global hasWarned sublime.run_command('toggle_sync_scroll') todaysFocus = random.randrange(1,5+1) if(sublime.active_window().active_view().size() > 50000): sublime.run_command("sub_notify", {"title": "Welcome to CodeBuddy, Try "+specialkey+" + R", "msg": "This file is big, use "+specialkey+" + R to quickly navigate functions", "sound": False}) # sublime.message_dialog("Welcome to CodeBuddy. This file is sizeable, so remember to use "+specialkey+" + R to quickly navigate functions") elif(todaysFocus == 1): sublime.run_command("sub_notify", {"title": "Welcome to CodeBuddy, Try "+specialkey+" + P", "msg": specialkey+" + P to quickly navigate files", "sound": False}) # sublime.message_dialog(". Try to focus on using "+specialkey+" + P to quickly navigate files") elif(todaysFocus == 2): sublime.run_command("sub_notify", {"title": "Welcome to CodeBuddy, Try "+specialkey+" + D", "msg": "Did you know you can use "+specialkey+" + D or "+specialkey+" + click to create multiple cursors?", "sound": False}) # sublime.message_dialog("Welcome to CodeBuddy. Did you know you can use "+specialkey+" + D or "+specialkey+" + click to create multiple cursors?") elif(todaysFocus == 3):
def run(self): show_commands = toggle_show_input("show_commands") sublime.log_commands(show_commands) print("Show commands: {0}".format(show_commands)) if show_commands: self.window.run_command("show_panel", {"panel": "console"})
def run(self, edit): global settings translate = DeeplTranslate(settings) process_strings = ProcessStrings(translate.callback) v = self.view window = v.window() # Get the current cursor position in the file caret = v.sel()[0].begin() # Get the new current line number cur_line = self.line_at(caret) # Get the count of lines in the buffer so we know when to stop last_line = self.line_at(v.size()) keep_moving = True sublime.log_commands(False) sublime.active_window().run_command("show_panel", {"panel": "console", "toggle": True}) sublime.active_window().run_command("reveal_in_side_bar", {"event": {"x": 505.296875, "y": 111.76171875}}) v.run_command("show_panel", {"panel": "console", "toggle": True}) v.run_command("reveal_in_side_bar", {"event": {"x": 505.296875, "y": 111.76171875}}) # REF: # https://stackoverflow.com/questions/44578315/making-a-sublime-text-3-macro-to-evaluate-a-line-and-then-move-the-cursor-to-the # A regex that matches a line that's blank or contains a comment. # Adjust as needed _r_blank = re.compile("^\s*(#.*)?$") looping = 0 while keep_moving: print('-------SublimeText3-DeepL-----:', '------------') for region in v.sel(): whole_line = False if not region.empty(): selection = v.substr(region) coordinates = v.sel() keep_moving = False else: selection = v.substr(v.line(v.sel()[0])) coordinates = v.line(v.sel()[0]) whole_line = True if selection: largo = len(selection) print('line(' + str(cur_line + 1) + ') length(' + str(largo) + ') selection(' + selection + ')') selection = selection.encode('utf-8') if not settings.get("target_language"): v.run_command("deepl_translate_to") keep_moving = False return else: try: # looping = looping + 1 if looping > 10000: print('exiting 10001 process here. ... last line processed(' + str(cur_line + 1) + ')') v.run_command('save') sublime.active_window().run_command('save') keep_moving = False raise DeeplTranslateException(translate.error_codes[401]) result = process_strings.translate( selection, translate.target, translate.source, translate.target_type, False ) time.sleep(0.15) except: # REF: # https://github.com/Enteleform/-SCRIPTS-/blob/master/SublimeText/%5BMisc%5D/%5BProof%20Of%20Concept%5D%20Progress%20Bar/ProgressBarDemo/ProgressBarDemo.py print('') message = 'ERR: LINE:' + str(cur_line + 1) + ' translation service failed.' print(message) print('') sublime.status_message(u'' + message) self.view.window().show_quick_panel( ["Translate", "Error", message], "", 1, 2) keep_moving = False return # DEBUG print('edit') # DEBUG pprint(edit) # DEBUG print('coordinates') # DEBUG pprint(coordinates) # DEBUG print('result') # DEBUG pprint(result) if not whole_line: v.replace(edit, region, result) else: v.replace(edit, coordinates, result) window.focus_view(v) if not settings.get('source_language'): detected = 'auto' else: detected = settings.get('source_language') sublime.status_message( u'Done! (translate ' + detected + ' --> ' + settings.get("target_language") + ')') else: sublime.status_message(u'Nothing to translate!') print('Nothing to translate!') # DEBUG print('selection(' + selection + ')' ) if settings.get('keep_moving_down') == 'no': keep_moving = False looping = looping + 1 if looping > 10000: print('exiting 10000 process here.... last line processed(' + str(cur_line + 1) + ')') v.run_command('save') sublime.active_window().run_command('save') keep_moving = False if keep_moving: # Move to the next line v.run_command("move", {"by": "lines", "forward": True}) time.sleep(0.15) sublime.status_message(u'moved down.') print('moved down.') # Get the current cursor position in the file caret = v.sel()[0].begin() # Get the new current line number cur_line = self.line_at(caret) percent = (cur_line * 100) / last_line sublime.status_message('%03.2f %%' % percent) # Get the contents of the current line # content = v.substr(v.line(caret)) # selection = v.substr(v.line(v.sel()[0])) # largo = len(selection.strip()) # If the current line is the last line, or the contents of # the current line does not match the regex, break out now. if cur_line == last_line: # or largo == 0: # not _r_blank.match(selection): print('cur_line(' + str(cur_line) + ') == last_line(' + str(last_line) + ')') # print('selection.len(' + str(largo) + ')') v.run_command('save') sublime.active_window().run_command('save') print('saving and exiting translation process here.') keep_moving = False
def enable_st_debug_mode_action(self): log_commands(True) log_input(True)
def run(self, edit, **kvargs): allContentRegion = sublime.Region(0, self.view.size()) if not allContentRegion.empty(): self.stepIndex = 0 self.tokens = TokensMap() self.patternsOfTokens = CaseInsensitiveDict() try: arguments = CaseInsensitiveDict(kvargs) if arguments["SEQUENCE"] != None: self.json = arguments else: message = "Empty command args dictionary. No sequence attached to regex_sequencer command." print(message) sublime.status_message(message) return # TODO: support of using sequence opened in other view # full path path = "{}/{}".format(os.path.dirname(__file__),"sample_regex_sequence.json") sequenceView = sublime.active_window().open_file(path,0) sequenceRegion = sublime.Region(0, sequenceView.size()) jsonString = sequenceView.substr(sequenceRegion) # decode json self.json = sublime.decode_value(jsonString) self.json = CaseInsensitiveDict(self.json) # debug option shouldCommentSteps = self.json["DEBUG"] self.debug = shouldCommentSteps if shouldCommentSteps != None else False # set active window print("active window", sublime.active_window().id(), sublime.active_window().active_view().name(), sublime.active_window().active_view().file_name()) # Start logging if self.debug: sublime.log_commands(True) sublime.log_result_regex(True) sublime.log_input(False) # output string, generated only if comments for each step is enabled self.output = "" if self.debug else None # Load Master Sequence if type(self.json) is list: masterSequence = self.json else: masterSequence = self.json["SEQUENCE"] # steps global definitions self.steps = self.json["STEPS"] if self.steps == None: self.steps = CaseInsensitiveDict(); # commands global definitions self.commands = self.json["COMMANDS"] if self.commands == None: self.commands = CaseInsensitiveDict(); # find patterns global definitions self.regularExpressions = self.json["REGULAR_EXPRESSIONS"] if self.regularExpressions == None: self.regularExpressions = CaseInsensitiveDict(); # replace patterns global definitions self.replaceTemplates = self.json["REPLACE_TEMPLATES"] if self.replaceTemplates == None: self.replaceTemplates = CaseInsensitiveDict(); # content of the buffer before the the any sequence start source = self.view.substr(sublime.Region(0, self.view.size())) # run master sequence self.run_sequence(edit,masterSequence) # if output string available replace all content with it # print("self.output: ",self.output) if self.output != None: comment = str() # log available global regular expressions comment += "// GLOBAL REGEXES:\n" for key in self.regularExpressions: comment += "// \"{}\" = \"{}\"\n".format(key,self.regularExpressions[key]) # log available global replace templates comment += "// GLOBAL REPLACES:\n" for key in self.replaceTemplates: comment += "// \"{}\" = \"{}\"\n".format(key,self.replaceTemplates[key]) # put log before the output self.output = "{}\n\n{}".format(comment,self.output) # insert soruce text at the begining of the output self.output = "{}\n\n{}".format(source,self.output) # replace content with output allContentRegion = sublime.Region(0, self.view.size()) self.view.replace(edit, allContentRegion, self.output) # End logging if self.debug: sublime.log_commands(False) sublime.log_result_regex(False) sublime.log_input(False) except Exception as ex: self.show_exception() raise ex
def debug(f): if zen_settings.get("debug"): sublime.log_commands(True) print "ZenCoding:", f
def run(self, edit): self.logging_commands = not self.logging_commands sublime.log_commands(self.logging_commands)
def handleError(self, error): if (error is not None): print(error) sublime.log_commands(True) sublime.active_window().run_command("show_panel", {"panel": "console", "toggle": True})
def run(self, edit): sublime.log_commands(True)
def run(self, flag): sublime.log_commands(flag)
def plugin_loaded(): # Enable sublime debug information if in DEBUG mode. if bool(os.getenv('SUBLIME_NEOVINTAGEOUS_DEBUG')): sublime.log_input(True) sublime.log_commands(True) # Some setting defaults are changing! To avoid impacting users in a later # update, this patch sets the current value to whatever is currently used. # See Roadmap: https://github.com/NeoVintageous/NeoVintageous/issues/404. preferences = sublime.load_settings('Preferences.sublime-settings') build_version = preferences.get('neovintageous_build_version', 0) # type: int if not build_version or int(build_version) < 11000: preferences.set('neovintageous_build_version', 11000) preferences.set('vintageous_use_ctrl_keys', preferences.get('vintageous_use_ctrl_keys')) preferences.set('vintageous_use_super_keys', preferences.get('vintageous_use_super_keys')) sublime.save_settings('Preferences.sublime-settings') loading_exeption = None pc_event = None try: from package_control import events if events.install('NeoVintageous'): pc_event = 'install' if events.post_upgrade('NeoVintageous'): pc_event = 'post_upgrade' except ImportError: pass # Package Control isn't available (PC is not required) except Exception as e: import traceback traceback.print_exc() loading_exeption = e try: _update_ignored_packages() except Exception as e: import traceback traceback.print_exc() loading_exeption = e try: from NeoVintageous.nv import rc rc.load() except Exception as e: import traceback traceback.print_exc() loading_exeption = e if _startup_exception or loading_exeption: try: _cleanup_views() except Exception: import traceback traceback.print_exc() if isinstance(_startup_exception, ImportError) or isinstance( loading_exeption, ImportError): if pc_event == 'post_upgrade': message = "Failed to load some modules trying to upgrade NeoVintageous. "\ "Please restart Sublime Text to finish the upgrade." else: message = "Failed to load some NeoVintageous modules. "\ "Please restart Sublime Text." else: if pc_event == 'post_upgrade': message = "An error occurred trying to upgrade NeoVintageous. "\ "Please restart Sublime Text to finish the upgrade." else: message = "An error occurred trying to load NeoVintageous. "\ "Please restart Sublime Text." print('NeoVintageous: ERROR', message) sublime.message_dialog(message)