本文整理汇总了Python中vim.windows方法的典型用法代码示例。如果您正苦于以下问题:Python vim.windows方法的具体用法?Python vim.windows怎么用?Python vim.windows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vim
的用法示例。
在下文中一共展示了vim.windows方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: highlight_line
# 需要导入模块: import vim [as 别名]
# 或者: from vim import windows [as 别名]
def highlight_line(group, buf_number, line_number):
match_id = int(vim.buffers[buf_number].vars.get('_roast_match_id', 0))
if match_id:
win = None
for win in vim.windows:
if win.buffer.number == buf_number:
break
try:
vim.eval(f'matchdelete({match_id})' if win is None else f'matchdelete({match_id}, {win.number})')
except vim.error:
# TODO: Only hide E803 error, which is thrown if this match_id has already been deleted.
pass
vim.buffers[buf_number].vars['_roast_match_id'] = vim.eval(
fr"matchadd('{group}', '\V' . escape(getbufline({buf_number}, {line_number + 1})[0], '\') . '\$')"
)
示例2: from_client
# 需要导入模块: import vim [as 别名]
# 或者: from vim import windows [as 别名]
def from_client(msg):
def handler(obj):
if type(obj) is msgpack.ExtType:
if obj.code == BUFFER_TYPE_ID:
return vim.buffers[msgpack.unpackb(obj.data)]
if obj.code == WINDOW_TYPE_ID:
return vim.windows[msgpack.unpackb(obj.data) - 1]
if sys.version_info.major != 2:
# python3 needs decode
obj = decode_if_bytes(obj)
return obj
return walk(handler, msg)
示例3: vim_ipython_is_open
# 需要导入模块: import vim [as 别名]
# 或者: from vim import windows [as 别名]
def vim_ipython_is_open():
"""
Helper function to let us know if the vim-ipython shell is currently
visible
"""
for w in vim.windows:
if w.buffer.name is not None and w.buffer.name.endswith("vim-ipython"):
return True
return False
示例4: getmmwindow
# 需要导入模块: import vim [as 别名]
# 或者: from vim import windows [as 别名]
def getmmwindow():
for b in vim.buffers:
if b.name.endswith(MINIMAP):
for w in vim.windows:
if w.buffer == b:
return w
return None
示例5: getmainwindow
# 需要导入模块: import vim [as 别名]
# 或者: from vim import windows [as 别名]
def getmainwindow():
for b in vim.buffers:
if not b.name.endswith(MINIMAP) and not "NERD_tree" in b.name:
for w in vim.windows:
if w.buffer == b:
return w
return None
示例6: closeminimap
# 需要导入模块: import vim [as 别名]
# 或者: from vim import windows [as 别名]
def closeminimap():
minimap = getmmwindow()
src = vim.current.window
if minimap:
vim.current.window = minimap
# clear the minimap autocmds
setmmautocmd(True)
vim.command(":quit!")
# try the last window, but sometimes this one was already closed
# (ex. tagbar toggle) which will lead to an exception
try:
vim.current.window = src
except:
vim.current.window = vim.windows[0]
示例7: show_response
# 需要导入模块: import vim [as 别名]
# 或者: from vim import windows [as 别名]
def show_response(response: requests.Response):
# A window holding a roast buffer, to be used as a workspace for setting up all roast buffers.
workspace_window = workspace_renderer = None
for window in vim.windows:
if '_roast_renderer' in window.buffer.vars:
workspace_window = window
workspace_renderer = window.buffer.vars['_roast_renderer']
if not isinstance(workspace_renderer, str):
workspace_renderer = workspace_renderer.decode()
break
# Switch to workspace window.
prev_window = vim.current.window
for renderer in renderers:
buf_name = f'__roast_{renderer}__'
num = bufnr(buf_name)
if num < 0:
if workspace_window is not None:
vim.current.window = workspace_window
vim.command(f'keepalt edit {buf_name} | setl bt=nofile bh=hide noswf nornu')
num = bufnr(buf_name)
else:
vim.command(f'keepalt vnew {buf_name} | setl bt=nofile bh=hide noswf nornu')
num = bufnr(buf_name)
vim.current.window = workspace_window = vim.windows[int(vim.eval(f'bufwinnr({num})')) - 1]
else:
if workspace_window is not None:
vim.current.window = workspace_window
vim.command(f'keepalt {num}buffer')
else:
vim.command(f'keepalt vertical {num}sbuffer')
vim.current.window = workspace_window = vim.windows[int(vim.eval(f'bufwinnr({num})')) - 1]
buf = vim.buffers[num]
buf[:] = None
buf.vars['_roast_renderer'] = renderer
actions = getattr(roast_api, f'render_{renderer}')(buf, response)
apply_actions(buf, actions)
workspace_window.options['statusline'] = "Roast <%{get(b:, '_roast_renderer', 'N/A')}> " + \
('' if response.ok else '%#Error#') + " HTTP:" + str(response.status_code) + " %* %{&ft}"
vim.command(f'{workspace_window.number}windo keepalt buffer __roast_{workspace_renderer or renderers[0]}__')
vim.current.window = prev_window