def show_vsplit_set_disp_buf_size(self): """A split can specify the number of lines for the display buffer. The number of lines is specified using a negative value for the splitcols argument. :<py>: res = Struct() buf = vpe.get_display_buffer('test') win = vim.current.window res.orig_cols = win.width buf.show(splitcols=-3) win = vim.current.window res.top_cols = win.width res.bottom_cols = vim.windows[win.number].width with buf.modifiable(): buf[:] = ['One', 'Two'] res.cur_buf = vim.current.buffer.name res.lines = list(vim.current.buffer) dump(res) """ res = self.run_self() failUnlessEqual('/[[test]]', fix_path(res.cur_buf)) failUnlessEqual(['One', 'Two'], res.lines) failUnlessEqual(3, res.top_cols) failUnlessEqual(res.orig_cols, res.bottom_cols + 4)
def short_description_property(self): """The short_description property depends on the buffer's type. :<py>: res = Struct() vpe.commands.cbuffer() vim.setqflist([], 'a', {'title': 'Test title'}) vpe.commands.copen() res.qf = vim.current.buffer.short_description vpe.commands.edit('/tmp/nodir/nofile.txt') res.location = vim.current.buffer.short_description vpe.commands.bdelete('.') if vim.vvars.version >= 801: vpe.commands.terminal('echo 9') res.terminal = vim.current.buffer.short_description vpe.commands.bdelete('.') dump(res) """ res = self.run_self() failUnlessEqual('Test title', res.qf) failUnlessEqual('/tmp/nodir', fix_path(res.location)) if vim_if.VimSession.get_version() >= [8, 1]: failUnlessEqual('!echo 9', res.terminal)
def show_display_buffer_in_vsplit(self): """A display buffer can be shown in the left part of a split window. The number of columns left in the right window is specified using the splitcols argument. :<py>: res = Struct() buf = vpe.get_display_buffer('test') win = vim.current.window res.orig_cols = win.width buf.show(splitcols=3) win = vim.current.window res.top_cols = win.width res.bottom_cols = vim.windows[win.number].width with buf.modifiable(): buf[:] = ['One', 'Two'] res.cur_buf = vim.current.buffer.name res.lines = list(vim.current.buffer) dump(res) """ res = self.run_self() failUnlessEqual('/[[test]]', fix_path(res.cur_buf)) failUnlessEqual(['One', 'Two'], res.lines) failUnlessEqual(3, res.bottom_cols) failUnlessEqual(res.orig_cols, res.top_cols + 4)
def lower_window_is_made_smaller(self): """The display buffer will be given a minimum of one line. If necessary the upper window is given fewer lines than requested. :<py>: res = Struct() buf = vpe.get_display_buffer('test') win = vim.current.window res.orig_lines = win.height res.ok = buf.show(splitlines=res.orig_lines - 1) win = vim.current.window res.top_lines = win.height res.bottom_lines = vim.windows[win.number].height with buf.modifiable(): buf[:] = ['One', 'Two'] res.cur_buf = vim.current.buffer.name res.lines = list(vim.current.buffer) dump(res) """ res = self.run_self() failUnlessEqual('/[[test]]', fix_path(res.cur_buf)) failUnlessEqual(['One', 'Two'], res.lines) failUnlessEqual(res.orig_lines - 2, res.bottom_lines) failUnlessEqual(1, res.top_lines) failUnless(res.ok)
def display_buffer_ext_name(self): """A Scratch buffer's name may an extension part. The extension can be changed. :<py>: res = Struct() buf = vpe.get_display_buffer('test') res.simple_name = buf.name buf.set_ext_name('aaa') res.ext_aaa_name = buf.name buf.set_ext_name('bbb') res.ext_bbb_name = buf.name dump(res) """ res = self.run_self() failUnlessEqual('/[[test]]', fix_path(res.simple_name)) failUnlessEqual('/[[test]]/aaa', fix_path(res.ext_aaa_name)) failUnlessEqual('/[[test]]/bbb', fix_path(res.ext_bbb_name))
def buffer_name_can_change(self): """Buffer.name can be modified. :<py>: res = Struct() buffer = vim.current.buffer res.orig_name = _vim.current.buffer.name buffer.name = '/tmp/monty' res.new_name = _vim.current.buffer.name dump(res) """ res = self.run_self() failIfEqual(not res.orig_name, res.new_name) failUnlessEqual('/tmp/monty', fix_path(res.new_name))
def create_display_buffer(self): """Create a display-only buffer. The modifiable context manager is used when changes need to be made. :<py>: buf = vpe.get_display_buffer('test') buf.show() with buf.modifiable(): buf[:] = ['One', 'Two'] res = Struct() res.cur_buf = vim.current.buffer.name res.lines = list(vim.current.buffer) dump(res) """ res = self.run_self() failUnlessEqual('/[[test]]', fix_path(res.cur_buf)) failUnlessEqual(['One', 'Two'], res.lines)
def location_property(self): """The location property is the file's directory. If the buffer has no file then it is an empty string. :<py>: res = Struct() vpe.commands.edit('/tmp/nodir/nofile.txt') res.location = vim.current.buffer.location buf = vim.current.buffer buf.options.buftype = 'nofile' res.empty = buf.location vpe.commands.bdelete('.') dump(res) """ res = self.run_self() failUnlessEqual('/tmp/nodir', fix_path(res.location)) failUnlessEqual('', res.empty)
def long_display_name_property(self): """The long_display_name property depends on the buffer's type. :<py>: res = Struct() vpe.commands.cbuffer() vim.setqflist([], 'a', {'title': 'Test title'}) vpe.commands.copen() res.qf = vim.current.buffer.long_display_name vpe.commands.edit('/tmp/nodir/nofile.txt') res.full_path = vim.current.buffer.long_display_name vpe.commands.bdelete('.') vpe.commands.enew() res.empty = vim.current.buffer.long_display_name dump(res) """ res = self.run_self() failUnlessEqual('[quickfix]: Test title', res.qf) failUnlessEqual('/tmp/nodir/nofile.txt', fix_path(res.full_path)) failUnlessEqual('[No name]', res.empty)