Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove deprecated manual input command

  • Loading branch information...
commit 9e3130545840256684cab7624fcbe194b2f1d692 1 parent c866b30
Isaac authored
Showing with 44 additions and 133 deletions.
  1. +44 −50 Default.sublime-commands
  2. +0 −83 rr_manual_sequencer.py
View
94 Default.sublime-commands
@@ -1,54 +1,48 @@
[
- // Input Sequencer command
- {
- "caption": "Reg Replace: RegEx Input Sequencer",
- "command": "reg_replace_input"
- },
+ // Clear all find highlights
+ {
+ "caption": "Reg Replace: Clear Highlights",
+ "command": "reg_replace",
+ "args": {"clear": true}
+ },
- // Clear all find highlights
- {
- "caption": "Reg Replace: Clear Highlights",
- "command": "reg_replace",
- "args": {"clear": true}
- },
+ // Example commands.
+ // {
+ // "caption": "Reg Replace: HTML5 Remove Deprecated Type Attr",
+ // "command": "reg_replace",
+ // "args": {"replacements": ["html5_remove_deprecated_type_attr"]}
+ // },
+ // {
+ // "caption": "Reg Replace: Remove Trailing Spaces",
+ // "command": "reg_replace",
+ // "args": {"replacements": ["remove_trailing_spaces"]}
+ // },
+ // // Chained replacements in one command
+ // {
+ // "caption": "Reg Replace: Remove HTML Comments and Trailing Spaces",
+ // "command": "reg_replace",
+ // "args": {"replacements": ["remove_html_comments", "remove_trailing_spaces"]}
+ // },
- // Example commands.
- // {
- // "caption": "Reg Replace: HTML5 Remove Deprecated Type Attr",
- // "command": "reg_replace",
- // "args": {"replacements": ["html5_remove_deprecated_type_attr"]}
- // },
- // {
- // "caption": "Reg Replace: Remove Trailing Spaces",
- // "command": "reg_replace",
- // "args": {"replacements": ["remove_trailing_spaces"]}
- // },
- // // Chained replacements in one command
- // {
- // "caption": "Reg Replace: Remove HTML Comments and Trailing Spaces",
- // "command": "reg_replace",
- // "args": {"replacements": ["remove_html_comments", "remove_trailing_spaces"]}
- // },
-
- // Preferences
- {
- "caption": "Preferences: Reg Replace Settings – Default",
- "command": "open_file",
- "args": { "file": "${packages}/RegReplace/reg_replace.sublime-settings" }
- },
- {
- "caption": "Preferences: Reg Replace Settings – User",
- "command": "open_file",
- "args": { "file": "${packages}/User/reg_replace.sublime-settings" }
- },
- {
- "caption": "Preferences: Reg Replace Commands – Default",
- "command": "open_file",
- "args": { "file": "${packages}/RegReplace/Default.sublime-commands" }
- },
- {
- "caption": "Preferences: Reg Replace Commands – User",
- "command": "open_file",
- "args": { "file": "${packages}/User/Default.sublime-commands" }
- }
+ // Preferences
+ {
+ "caption": "Preferences: Reg Replace Settings – Default",
+ "command": "open_file",
+ "args": { "file": "${packages}/RegReplace/reg_replace.sublime-settings" }
+ },
+ {
+ "caption": "Preferences: Reg Replace Settings – User",
+ "command": "open_file",
+ "args": { "file": "${packages}/User/reg_replace.sublime-settings" }
+ },
+ {
+ "caption": "Preferences: Reg Replace Commands – Default",
+ "command": "open_file",
+ "args": { "file": "${packages}/RegReplace/Default.sublime-commands" }
+ },
+ {
+ "caption": "Preferences: Reg Replace Commands – User",
+ "command": "open_file",
+ "args": { "file": "${packages}/User/Default.sublime-commands" }
+ }
]
View
83 rr_manual_sequencer.py
@@ -1,83 +0,0 @@
-import sublime_plugin
-import re
-
-
-class RegReplaceInputCommand(sublime_plugin.WindowCommand):
- def run_sequence(self, value):
- """
- Run the sequence
- """
-
- find_only = False
- action = None
- multi_pass = False
- options = {}
-
- # Parse Input
- matches = re.match(r"(\?)?\s*([^\+][\w\W]*|\+?)\s*:\s*([\w\W]*)\s*", value)
- if matches is not None:
- # Sequence
- value = matches.group(3)
-
- # Find Only?
- if matches.group(1) == '?':
- find_only = True
-
- # Multi-Pass?
- if matches.group(2) == '+':
- multi_pass = True
-
- # Action?
- elif matches.group(2) != '' and matches.group(2) is not None:
- # Mark or unmark: parse options?
- params = re.match(
- r"^(unmark|mark)\s*=\s*([\w\s\.\-]*)\s*(?:,\s*([\w\s\.\-]*)\s*)?(?:,\s*([\w\s\.\-]*))?\s*",
- matches.group(2)
- )
- if params is not None:
- if params.group(2) != '' and params.group(2) is not None:
- # Mark options
- if params.group(1) == 'mark':
- options['key'] = params.group(2).strip()
- if params.group(3) != '' and params.group(3) is not None:
- options['scope'] = params.group(3).strip()
- if params.group(4) != '' and params.group(4) is not None:
- options['style'] = params.group(4).strip()
- action = params.group(1)
- # Unmark options
- elif params.group(1) == 'unmark':
- options['key'] = params.group(2)
- action = params.group(1)
- else:
- # All other actions
- action = matches.group(2)
-
- # Parse returned regex sequence
- sequence = [x.strip() for x in value.split(',')]
- view = self.window.active_view()
-
- # Execute sequence
- if view is not None:
- view.run_command(
- 'reg_replace',
- {
- 'replacements': sequence,
- 'find_only': find_only,
- 'action': action,
- 'multi_pass': multi_pass,
- 'options': options
- }
- )
-
- def run(self):
- """
- Display RegReplace input panel for on the fly regex sequences
- """
-
- self.window.show_input_panel(
- 'Regex Sequence:',
- '',
- self.run_sequence,
- None,
- None
- )
Please sign in to comment.
Something went wrong with that request. Please try again.