Skip to content

Commit

Permalink
api: add a mouse field to Window{Config,Opts} on nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Oct 24, 2024
1 parent b986c49 commit e01ba4e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
- a `String::to_str()` method which returns a `&str` if the string contains
valid UTF-8 data;

- a `WindowConfig::mouse` field and a `WindowOptsBuilder::mouse()` method
on nightly ([#189](https://github.com/noib3/nvim-oxi/pull/189));

### Changed

- `nvim_oxi::api::echo` is now generic over the highlight group type instead of
Expand Down
15 changes: 15 additions & 0 deletions crates/api/src/types/window_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ pub struct WindowConfig {
)]
pub hide: Option<bool>,

#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
#[cfg(feature = "neovim-nightly")] // On 0.10 and nightly.
#[serde(default)]
pub mouse: bool,

/// If `true` then no buffer-related autocommand events such as `BufEnter`
/// or `BufLeave` are fired when calling [`open_win`](crate::open_win).
pub noautocmd: Option<bool>,
Expand Down Expand Up @@ -436,6 +441,9 @@ pub struct WindowOpts {
bufpos: Array,
external: Boolean,
focusable: Boolean,
#[cfg_attr(docsrs, doc(cfg(feature = "neovim-nightly")))]
#[cfg(feature = "neovim-nightly")]
mouse: Boolean,
vertical: Boolean,
zindex: Integer,
border: Object,
Expand Down Expand Up @@ -501,6 +509,9 @@ impl From<&WindowConfig> for WindowOpts {
builder.focusable(focusable);
}

#[cfg(feature = "neovim-nightly")]
builder.mouse(config.mouse);

if let Some(vertical) = config.vertical {
builder.vertical(vertical);
}
Expand Down Expand Up @@ -567,6 +578,8 @@ impl TryFrom<WindowOpts> for WindowConfig {
footer_pos,
height,
hide,
#[cfg(feature = "neovim-nightly")]
mouse,
noautocmd,
relative,
row,
Expand Down Expand Up @@ -639,6 +652,8 @@ impl TryFrom<WindowOpts> for WindowConfig {
))?,
height: deserialize(height)?,
hide: deserialize(hide)?,
#[cfg(feature = "neovim-nightly")]
mouse,
noautocmd: deserialize(noautocmd)?,
relative,
row: deserialize(row)?,
Expand Down

0 comments on commit e01ba4e

Please sign in to comment.