pub struct Window(/* private fields */);
Expand description
A wrapper around a Neovim window handle.
Implementations§
Source§impl Window
impl Window
Sourcepub fn get_option<Opt>(&self, name: &str) -> Result<Opt, Error>where
Opt: FromObject,
pub fn get_option<Opt>(&self, name: &str) -> Result<Opt, Error>where
Opt: FromObject,
Binding to nvim_win_get_option()
.
Gets a window option value.
Sourcepub fn set_option<Opt>(&mut self, name: &str, value: Opt) -> Result<(), Error>where
Opt: ToObject,
pub fn set_option<Opt>(&mut self, name: &str, value: Opt) -> Result<(), Error>where
Opt: ToObject,
Binding to nvim_win_set_option()
.
Sets a window option value. Passing None
as value deletes the option
(only works if there’s a global fallback).
Source§impl Window
impl Window
Sourcepub fn get_config(&self) -> Result<WindowConfig, Error>
pub fn get_config(&self) -> Result<WindowConfig, Error>
Binding to nvim_win_get_config()
.
Gets the window configuration.
Sourcepub fn set_config(&mut self, config: &WindowConfig) -> Result<(), Error>
pub fn set_config(&mut self, config: &WindowConfig) -> Result<(), Error>
Binding to nvim_win_get_config()
.
Configures the window layout. Only for floating and external windows.
Source§impl Window
impl Window
Sourcepub fn current() -> Self
pub fn current() -> Self
Shorthand for get_current_win
.
Sourcepub fn call<F, Res, Ret>(&self, fun: F) -> Result<Ret, Error>where
F: FnOnce(()) -> Res + 'static,
Res: IntoResult<Ret>,
Res::Error: StdError + 'static,
Ret: Pushable + FromObject,
pub fn call<F, Res, Ret>(&self, fun: F) -> Result<Ret, Error>where
F: FnOnce(()) -> Res + 'static,
Res: IntoResult<Ret>,
Res::Error: StdError + 'static,
Ret: Pushable + FromObject,
Binding to nvim_win_call()
.
Calls a function with this window as the temporary current window.
Sourcepub fn close(self, force: bool) -> Result<(), Error>
pub fn close(self, force: bool) -> Result<(), Error>
Binding to nvim_win_close()
.
Closes the window. Not allowed when
textlock
is active.
Sourcepub fn del_var(&mut self, name: &str) -> Result<(), Error>
pub fn del_var(&mut self, name: &str) -> Result<(), Error>
Binding to nvim_win_del_var()
.
Removes a window-scoped (w:
) variable.
Sourcepub fn get_buf(&self) -> Result<Buffer, Error>
pub fn get_buf(&self) -> Result<Buffer, Error>
Binding to nvim_win_get_buf()
.
Gets the current Buffer
in the window.
Sourcepub fn get_cursor(&self) -> Result<(usize, usize), Error>
pub fn get_cursor(&self) -> Result<(usize, usize), Error>
Binding to nvim_win_get_cursor()
.
Gets the (1,0)-indexed cursor position in the window.
Sourcepub fn get_height(&self) -> Result<u32, Error>
pub fn get_height(&self) -> Result<u32, Error>
Binding to nvim_win_get_height()
.
Gets the window height as a count of rows.
Sourcepub fn get_number(&self) -> Result<u32, Error>
pub fn get_number(&self) -> Result<u32, Error>
Binding to nvim_win_get_number()
.
Gets the window number.
Sourcepub fn get_position(&self) -> Result<(usize, usize), Error>
pub fn get_position(&self) -> Result<(usize, usize), Error>
Binding to nvim_win_get_position()
.
Gets the window position in display cells.
Sourcepub fn get_tabpage(&self) -> Result<TabPage, Error>
pub fn get_tabpage(&self) -> Result<TabPage, Error>
Binding to nvim_win_get_tabpage()
.
Gets the window’s TabPage
.
Sourcepub fn get_var<Var>(&self, name: &str) -> Result<Var, Error>where
Var: FromObject,
pub fn get_var<Var>(&self, name: &str) -> Result<Var, Error>where
Var: FromObject,
Binding to nvim_win_get_var()
.
Gets a window-scoped (w:
) variable.
Sourcepub fn get_width(&self) -> Result<u32, Error>
pub fn get_width(&self) -> Result<u32, Error>
Binding to nvim_win_get_width()
.
Gets the window width as a number of columns.
Sourcepub fn hide(self) -> Result<(), Error>
pub fn hide(self) -> Result<(), Error>
Binding to nvim_win_hide()
.
Closes the window and hides the buffer it contains.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Binding to nvim_win_is_valid()
.
Checks if the window is valid.
Sourcepub fn set_buf(&mut self, buffer: &Buffer) -> Result<(), Error>
pub fn set_buf(&mut self, buffer: &Buffer) -> Result<(), Error>
Binding to nvim_win_set_buf()
.
Sets buffer
as the current buffer in the window.
Sourcepub fn set_cursor(&mut self, line: usize, col: usize) -> Result<(), Error>
pub fn set_cursor(&mut self, line: usize, col: usize) -> Result<(), Error>
Binding to nvim_win_set_cursor()
.
Sets the (1,0)-indexed cursor in the window. This will scroll the window even if it’s not the current one.
Sourcepub fn set_height(&mut self, height: u32) -> Result<(), Error>
pub fn set_height(&mut self, height: u32) -> Result<(), Error>
Binding to nvim_win_set_height()
.
Sets the window height.
Sourcepub fn set_hl_ns(&mut self, ns_id: u32) -> Result<(), Error>
pub fn set_hl_ns(&mut self, ns_id: u32) -> Result<(), Error>
Binding to nvim_win_set_hl_ns()
.
Sets the highlight namespace for this window. This will the highlights
defined with set_hl
for the given namespace, but
fall back to global highlights (ns_id = 0
) if those are missing.
This takes precedence over the winhighlight
option.
Sourcepub fn set_var<Var>(&mut self, name: &str, value: Var) -> Result<(), Error>where
Var: ToObject,
pub fn set_var<Var>(&mut self, name: &str, value: Var) -> Result<(), Error>where
Var: ToObject,
Binding to nvim_win_set_var()
.
Sets a window-scoped (w:
) variable.
Sourcepub fn set_width(&mut self, width: u32) -> Result<(), Error>
pub fn set_width(&mut self, width: u32) -> Result<(), Error>
Binding to nvim_win_set_width()
.
Sets the window width.
Sourcepub fn text_height(
&self,
opts: &WinTextHeightOpts,
) -> Result<WinTextHeightInfos, Error>
pub fn text_height( &self, opts: &WinTextHeightOpts, ) -> Result<WinTextHeightInfos, Error>
Binding to nvim_win_text_height()
.
Computes the number of screen lines occupied by a range of text in a given window. Works for off-screen text and takes folds into account.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Window
impl<'de> Deserialize<'de> for Window
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl FromObject for Window
impl FromObject for Window
impl Eq for Window
impl StructuralPartialEq for Window
Auto Trait Implementations§
impl Freeze for Window
impl RefUnwindSafe for Window
impl Send for Window
impl Sync for Window
impl Unpin for Window
impl UnwindSafe for Window
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§type Error = Infallible
type Error = Infallible
Result
.Source§fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
Result
.