本文整理汇总了Python中vim.buffers方法的典型用法代码示例。如果您正苦于以下问题:Python vim.buffers方法的具体用法?Python vim.buffers怎么用?Python vim.buffers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vim
的用法示例。
在下文中一共展示了vim.buffers方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: highlight_line
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [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: update_buffers
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [as 别名]
def update_buffers(req):
b1_id = int(vim.eval("s:b1"))
b1 = vim.buffers[b1_id]
b2_id = int(vim.eval("s:b2"))
b2 = vim.buffers[b2_id]
# Set up the buffers
set_buffer_content(b1, req.full_message())
if req.response is not None:
set_buffer_content(b2, req.response.full_message())
# Save the port, ssl, host setting
vim.command("let s:dest_port=%d" % req.dest_port)
vim.command("let s:dest_host='%s'" % escape(req.dest_host))
if req.use_tls:
vim.command("let s:use_tls=1")
else:
vim.command("let s:use_tls=0")
示例3: from_client
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [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)
示例4: nvim_list_bufs
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [as 别名]
def nvim_list_bufs():
return list(vim.buffers)
示例5: submit_current_buffer
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [as 别名]
def submit_current_buffer():
curbuf = vim.current.buffer
b2_id = int(vim.eval("s:b2"))
b2 = vim.buffers[b2_id]
vim.command("let s:b1=bufnr('$')")
vim.command("only")
vim.command("rightbelow vertical new")
vim.command("b %d" % b2_id)
vim.command("wincmd h")
full_request = '\n'.join(curbuf)
req = parse_request(full_request)
dest_host, dest_port, use_tls, storage_id = dest_loc()
req.dest_host = dest_host
req.dest_port = dest_port
req.use_tls = use_tls
comm_type, comm_addr = get_conn_addr()
with ProxyConnection(kind=comm_type, addr=comm_addr) as conn:
new_req = conn.submit(req, storage=storage_id)
conn.add_tag(new_req.db_id, "repeater", storage_id)
update_buffers(new_req)
# (left, right) = set_up_windows()
# set_buffer_content(left, 'Hello\nWorld')
# set_buffer_content(right, 'Hello\nOther\nWorld')
#print "Arg is %s" % vim.eval("a:arg")
示例6: test
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [as 别名]
def test():
it.assertEquals(
vim_helpers._getBufferVars(vim.buffers[0]),
{'buffer_0_var_0' : 'buffer_0_var_value_0',
'buffer_0_var_1' : 'buffer_0_var_value_1',}
)
it.assertEquals(
vim_helpers._getBufferVars(vim.buffers[1]),
{'buffer_1_var_0' : 'buffer_1_var_value_0',
'buffer_1_var_1' : 'buffer_1_var_value_1',}
)
示例7: GetFileType
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [as 别名]
def GetFileType( bufnr ):
ft = vim.buffers[ bufnr ].options[ 'filetype' ]
return _ToUnicode( ft )
示例8: GetBufferLen
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [as 别名]
def GetBufferLen( bufnr ):
return len( vim.buffers[ bufnr ] )
示例9: GetLineLen
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [as 别名]
def GetLineLen( bufnr, line ):
# line index is 1 based, but vim python interface is 0 based
return len( vim.buffers[ bufnr ][ line - 1 ] )
示例10: getmmwindow
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [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
示例11: getmainwindow
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [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
示例12: show_response
# 需要导入模块: import vim [as 别名]
# 或者: from vim import buffers [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