Beispiel #1
0
    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)
Beispiel #2
0
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)
Beispiel #3
0
 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!')
Beispiel #5
0
    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)
Beispiel #6
0
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')
Beispiel #8
0
 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):
     show_input = toggle_show_input("show_input")
     sublime.log_input(show_input)
     print("Show input: {0}".format(show_input))
     if show_input:
         self.window.run_command("show_panel", {"panel": "console"})
Beispiel #10
0
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)
Beispiel #11
0
# 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):
	sublime.run_command("sub_notify", {"title": "Welcome to CodeBuddy, Try "+specialkey+" + P then :40", "msg":  specialkey+" + P followed by :<line> to navigate by line", "sound": False})
Beispiel #12
0
 def run(self):
     self.flag = not self.flag
     sublime.log_input(self.flag)
 def run(self, flag):
     sublime.log_input(flag)
Beispiel #14
0
def plugin_loaded():
    value = get_setting()
    sublime.log_input(value);
    sublime.log_commands(value);
    sublime.log_result_regex(value);
 def enable_st_debug_mode_action(self):
     log_commands(True)
     log_input(True)
 def disable_st_debug_mode_action(self):
     log_commands(False)
     log_input(False)
Beispiel #17
0
def ToggleInput():
    global g_bInput
    g_bInput = not g_bInput
    sublime.log_input(g_bInput)
	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
Beispiel #19
0
 def disable(self):
     sublime.log_commands(False)
     sublime.log_input(False)
     sublime.status_message("")
Beispiel #20
0
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)
 def run(self, flag):
     sublime.log_input(flag)