How to use match_all method in ATX

Best Python code snippet using ATX Github


Full Screen

1import sublime2from import MODE_NORMAL, MODE_NORMAL_INSERT, MODE_INSERT, ACTIONS_EXITING_TO_INSERT_MODE, MODE_VISUAL_LINE, MODE_VISUAL, MODE_SELECT3from import MODE_VISUAL_BLOCK4from import constants5from import utils6from import action_to_namespace7class KeyContext(object):8 def __get__(self, instance, owner):9 self.state = instance10 return self11 def vi_must_change_mode(self, key, operator, operand, match_all):12 is_normal_mode = self.state.settings.view['command_mode']13 is_exit_mode_insert = (self.state.action in ACTIONS_EXITING_TO_INSERT_MODE)14 if (is_normal_mode and is_exit_mode_insert):15 return self._check(True, operator, operand, match_all)16 # Close the ':' panel.17 if self.vi_is_cmdline(key, operator, operand, match_all):18 # We return False so that vi_esc will be skipped and the default Sublime Text command19 # will be triggered instead. When the input panel finally closes, the initialization20 # code in will take care of clearing the state so we are left in a consistent21 # state.22 return False23 # If we have primed counts, we have to clear the state.24 if self.state.user_provided_count or self.state.motion or self.state.action:25 return True26 # TODO: Simplify comparisons.27 if self.state.mode == MODE_NORMAL_INSERT:28 return True29 if self.state.mode == MODE_INSERT:30 return True31 # check if we are NOT in normal mode -- if NOT, we need to change modes32 # This covers, for example, SELECT_MODE.33 if self.state.mode != MODE_NORMAL:34 return True35 # Clear non-empty selections if there any.36 # For example, this will be the case when we've used select mode (gh).37 if not all(r.empty() for r in self.state.view.sel()):38 return True39 # XXX Actually, if we already are in normal mode, we still need to perform certain40 # cleanup tasks, so let the command run anyway.41 if self.state.view.get_regions('vi_search'):42 return True43 def vi_is_buffer(self, key, operator, operand, match_all):44 # !! The following check is based on an implementation detail of Sublime Text. !!45 is_console = False if (getattr(self.state.view, 'settings') is not None) else True46 is_widget = self.state.view.settings().get('is_widget')47 value = (is_console or is_widget)48 return self._check(value, operand, operand, match_all)49 def vi_must_exit_to_insert_mode(self, key, operator, operand, match_all):50 # XXX: This conext most likely not needed any more.51 is_normal_mode = self.state.settings.view['command_mode']52 is_exit_mode_insert = (self.state.action in ACTIONS_EXITING_TO_INSERT_MODE)53 value = (is_normal_mode and is_exit_mode_insert)54 return self._check(value, operator, operand, match_all)55 def vi_use_ctrl_keys(self, key, operator, operand, match_all):56 value = self.state.settings.view['vintageous_use_ctrl_keys']57 return self._check(value, operator, operand, match_all)58 def vi_is_cmdline(self, key, operator, operand, match_all):59 value = (self.state.view.score_selector(0, 'text.excmdline') != 0)60 return self._check(value, operator, operand, match_all)61 def vi_enable_cmdline_mode(self, key, operator, operand, match_all):62 value = self.state.settings.view['vintageous_enable_cmdline_mode']63 return self._check(value, operator, operand, match_all)64 def vi_has_incomplete_action(self, key, operator, operand, match_all):65 value = any(x for x in (self.state.action, self.state.motion) if66 x in constants.INCOMPLETE_ACTIONS)67 return self._check(value, operator, operand, match_all)68 def vi_has_action(self, key, operator, operand, match_all):69 value = self.state.action70 value = value and (value not in constants.INCOMPLETE_ACTIONS)71 return self._check(value, operator, operand, match_all)72 def vi_has_motion_count(self, key, operator, operand, match_all):73 value = self.state.motion_digits74 return self._check(value, operator, operand, match_all)75 def vi_mode_normal_insert(self, key, operator, operand, match_all):76 value = self.state.mode == MODE_NORMAL_INSERT77 return self._check(value, operator, operand, match_all)78 def vi_mode_visual_block(self, key, operator, operand, match_all):79 value = self.state.mode == MODE_VISUAL_BLOCK80 return self._check(value, operator, operand, match_all)81 def vi_mode_cannot_push_zero(self, key, operator, operand, match_all):82 value = False83 if operator == sublime.OP_EQUAL:84 value = not (self.state.motion_digits or85 self.state.action_digits)86 return self._check(value, operator, operand, match_all)87 def vi_mode_visual_any(self, key, operator, operand, match_all):88 value = self.state.mode in (MODE_VISUAL_LINE, MODE_VISUAL, MODE_VISUAL_BLOCK)89 return self._check(value, operator, operand, match_all)90 def vi_mode_select(self, key, operator, operand, match_all):91 value = self.state.mode == MODE_SELECT92 return self._check(value, operator, operand, match_all)93 def vi_mode_visual_line(self, key, operator, operand, match_all):94 value = self.state.mode == MODE_VISUAL_LINE95 return self._check(value, operator, operand, match_all)96 def vi_mode_insert(self, key, operator, operand, match_all):97 value = self.state.mode == MODE_INSERT98 return self._check(value, operator, operand, match_all)99 def vi_mode_visual(self, key, operator, operand, match_all):100 value = self.state.mode == MODE_VISUAL101 return self._check(value, operator, operand, match_all)102 def vi_mode_normal(self, key, operator, operand, match_all):103 value = self.state.mode == MODE_NORMAL104 return self._check(value, operator, operand, match_all)105 def vi_mode_normal_or_visual(self, key, operator, operand, match_all):106 # XXX: This context is used to disable some keys for VISUALLINE.107 # However, this is hiding some problems in visual transformers that might not be dealing108 # correctly with VISUALLINE.109 normal = self.vi_mode_normal(key, operator, operand, match_all)110 visual = self.vi_mode_visual(key, operator, operand, match_all)111 visual = visual or self.vi_mode_visual_block(key, operator, operand, match_all)112 return self._check((normal or visual), operator, operand, match_all)113 def vi_mode_normal_or_any_visual(self, key, operator, operand, match_all):114 normal_or_visual = self.vi_mode_normal_or_visual(key, operator, operand, match_all)115 visual_line = self.vi_mode_visual_line(key, operator, operand, match_all)116 return self._check((normal_or_visual or visual_line), operator, operand, match_all)117 def vi_state_next_character_is_user_input(self, key, operator, operand, match_all):118 value = (self.state.expecting_user_input or119 self.state.expecting_register)120 return self._check(value, operator, operand, match_all)121 def vi_state_expecting_user_input(self, key, operator, operand, match_all):122 value = self.state.expecting_user_input123 return self._check(value, operator, operand, match_all)124 def vi_state_expecting_register(self, key, operator, operand, match_all):125 value = self.state.expecting_register126 return self._check(value, operator, operand, match_all)127 def vi_mode_can_push_digit(self, key, operator, operand, match_all):128 motion_digits = not self.state.motion129 action_digits = self.state.motion130 value = motion_digits or action_digits131 return self._check(value, operator, operand, match_all)132 def vi_is_recording_macro(self, key, operator, operand, match_all):133 value = self.state.is_recording134 return self._check(value, operator, operand, match_all)135 def vi_in_key_namespace(self, key, operator, operand, match_all):136 has_incomplete_action = self.vi_has_incomplete_action('vi_has_incomplete_action', sublime.OP_EQUAL, True, False)137 if not has_incomplete_action:138 return False139 value = action_to_namespace(self.state.action) or action_to_namespace(self.state.motion)140 if not value:141 return False142 value = value == operand143 return value144 # return self._check(value, operator, True, match_all)145 def vi_can_enter_any_visual_mode(self, key, operator, operand, match_all):146 sels = self.state.view.sel()147 rv = True148 for sel in sels:149 # We're assuming we are in normal mode.150 if sel.b == self.state.view.size() and self.state.view.line(sel.b).empty():151 rv = False152 break153 if not rv:154 print("Vintageous: Can't enter visual mode at EOF if last line is empty.")155 utils.blink()156 return self._check(rv, operator, operand, match_all)157 def check(self, key, operator, operand, match_all):158 func = getattr(self, key, None)159 if func:160 return func(key, operator, operand, match_all)161 else:162 return None163 def _check(self, value, operator, operand, match_all):164 if operator == sublime.OP_EQUAL:165 if operand == True:166 return value167 elif operand == False:168 return not value169 elif operator == sublime.OP_NOT_EQUAL:170 if operand == True:171 return not value172 elif operand == False:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?