本文整理匯總了Python中Vintageous.state.State.enter_normal_mode方法的典型用法代碼示例。如果您正苦於以下問題:Python State.enter_normal_mode方法的具體用法?Python State.enter_normal_mode怎麽用?Python State.enter_normal_mode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Vintageous.state.State
的用法示例。
在下文中一共展示了State.enter_normal_mode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testFromNormalModeToNormalMode
# 需要導入模塊: from Vintageous.state import State [as 別名]
# 或者: from Vintageous.state.State import enter_normal_mode [as 別名]
def testFromNormalModeToNormalMode(self):
self.write('abc\nxxx\nabc\nabc')
self.clear_sel()
self.add_sel(self.R((1, 0), (1, 0)))
state = State(self.view)
state.enter_normal_mode()
self.view.run_command('vi_enter_normal_mode')
prev_mode = state.mode
self.view.run_command('ex_move', {'address': '3'})
state = State(self.view)
new_mode = state.mode
self.assertEqual(prev_mode, new_mode)
示例2: testFromNormalModeToNormalMode
# 需要導入模塊: from Vintageous.state import State [as 別名]
# 或者: from Vintageous.state.State import enter_normal_mode [as 別名]
def testFromNormalModeToNormalMode(self):
self.write('abc\nxxx\nabc\nabc')
self.clear_sel()
self.add_sel(self.R((1, 0), (1, 0)))
state = State(self.view)
state.enter_normal_mode()
self.view.run_command('vi_enter_normal_mode')
prev_mode = state.mode
self.range['left_offset'] = 2
self.range['text_range'] = '2'
self.view.run_command('ex_delete', {'line_range': self.range})
state = State(self.view)
new_mode = state.mode
self.assertEqual(prev_mode, new_mode)
示例3: run
# 需要導入模塊: from Vintageous.state import State [as 別名]
# 或者: from Vintageous.state.State import enter_normal_mode [as 別名]
#.........這裏部分代碼省略.........
forced=False,
file_name='',
plusplus_args='',
operator='',
target_redirect='',
subcmd=''):
if file_name and target_redirect:
sublime.status_message('Vintageous: Too many arguments.')
return
appending = operator == '>>'
a_range = line_range['text_range']
self.view = self.window.active_view()
content = get_region_by_range(self.view, line_range=line_range) if a_range else \
[sublime.Region(0, self.view.size())]
read_only = False
if self.view.file_name():
mode = os.stat(self.view.file_name())
read_only = (stat.S_IMODE(mode.st_mode) & stat.S_IWUSR !=
stat.S_IWUSR)
if target_redirect:
target = self.window.new_file()
target.set_name(target_redirect)
elif file_name:
def report_error(msg):
sublime.status_message('Vintageous: %s' % msg)
file_path = os.path.abspath(os.path.expanduser(file_name))
if os.path.exists(file_path) and (file_path != self.view.file_name()):
# TODO add w! flag
# TODO: Hook this up with ex error handling (ex/errors.py).
msg = "File '{0}' already exists.".format(file_path)
report_error(msg)
return
if not os.path.exists(os.path.dirname(file_path)):
msg = "Directory '{0}' does not exist.".format(os.path.dirname(file_path))
report_error(msg)
return
try:
# FIXME: We need to do some work with encodings here, don't we?
with open(file_path, 'w+') as temp_file:
for frag in reversed(content):
temp_file.write(self.view.substr(frag))
temp_file.close()
sublime.status_message("Vintageous: Saved {0}".format(file_path))
row, col = self.view.rowcol(self.view.sel()[0].b)
encoded_fn = "{0}:{1}:{2}".format(file_path, row + 1, col + 1)
self.view.set_scratch(True)
w = self.window
w.run_command('close')
w.open_file(encoded_fn, sublime.ENCODED_POSITION)
return
except IOError as e:
report_error( "Failed to create file '%s'." % file_name )
return
window = self.window
window.open_file(file_path)
return
else:
target = self.view
if (read_only or self.view.is_read_only()) and not forced:
utils.blink()
sublime.status_message("Vintageous: Can't write read-only file.")
return
start = 0 if not appending else target.size()
prefix = '\n' if appending and target.size() > 0 else ''
if appending or target_redirect:
for frag in reversed(content):
target.run_command('append', {'characters': prefix + self.view.substr(frag) + '\n'})
elif a_range:
start_deleting = 0
text = ''
for frag in content:
text += self.view.substr(frag) + '\n'
start_deleting = len(text)
self.view.run_command('ex_replace_file', {'start': 0, 'end': 0, 'with_what': text})
else:
dirname = os.path.dirname(self.view.file_name())
if not os.path.exists(dirname):
os.makedirs(dirname)
self.window.run_command('save')
# This may unluckily prevent the user from seeing ST's feedback about saving the current
# file.
state = State(self.window.active_view())
if state.mode != MODE_NORMAL:
state.enter_normal_mode()
self.window.run_command('vi_enter_normal_mode')
示例4: set_mode
# 需要導入模塊: from Vintageous.state import State [as 別名]
# 或者: from Vintageous.state.State import enter_normal_mode [as 別名]
def set_mode(self):
state = State(self.view)
state.enter_normal_mode()
self.view.run_command('vi_enter_normal_mode')