Skip to content

Commit

Permalink
Rename geometry to grid size
Browse files Browse the repository at this point in the history
  • Loading branch information
fredizzimo committed Oct 1, 2023
1 parent 9cc44b9 commit 0dd6a3c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/bridge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async fn launch() -> NeovimSession {
session
}

async fn run(session: NeovimSession, geometry: Option<Dimensions>) {
async fn run(session: NeovimSession, grid_size: Option<Dimensions>) {
let settings = SETTINGS.get::<CmdLineSettings>();
let mut options = UiAttachOptions::new();
options.set_linegrid_external(true);
Expand All @@ -107,10 +107,10 @@ async fn run(session: NeovimSession, geometry: Option<Dimensions>) {

// Triggers loading the user config

let geometry = geometry.map_or(DEFAULT_GRID_SIZE, |v| v.clamped_grid_size());
let grid_size = grid_size.map_or(DEFAULT_GRID_SIZE, |v| v.clamped_grid_size());
session
.neovim
.ui_attach(geometry.width as i64, geometry.height as i64, &options)
.ui_attach(grid_size.width as i64, grid_size.height as i64, &options)
.await
.unwrap_or_explained_panic("Could not attach ui to neovim process");

Expand Down Expand Up @@ -143,12 +143,12 @@ impl NeovimRuntime {
self.state = RuntimeState::Launched(self.runtime.block_on(launch()));
}

pub fn attach(&mut self, geometry: Option<Dimensions>) {
pub fn attach(&mut self, grid_size: Option<Dimensions>) {
assert!(matches!(self.state, RuntimeState::Launched(..)));
if let RuntimeState::Launched(session) =
std::mem::replace(&mut self.state, RuntimeState::Invalid)
{
self.state = RuntimeState::Attached(self.runtime.spawn(run(session, geometry)));
self.state = RuntimeState::Attached(self.runtime.spawn(run(session, grid_size)));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ pub struct CmdLineSettings {
#[group(required = false, multiple = false)]
pub struct GeometryArgs {
/// The initial grid size of the window [<columns>x<lines>]. Defaults to columns/lines from init.vim/lua if no value is given.
/// If --geometry is not set then it's inferred from the window size
/// If --grid is not set then it's inferred from the window size
#[arg(long)]
pub geometry: Option<Option<Dimensions>>,
pub grid: Option<Option<Dimensions>>,

/// The size of the window in pixels.
#[arg(long)]
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ fn protected_main() -> ExitCode {
runtime.launch();
let event_loop = create_event_loop();
let window = create_window(&event_loop, &window_size);
let geometry = match window_size {
WindowSize::Geometry(geometry) => Some(geometry),
let grid_size = match window_size {
WindowSize::Grid(grid_size) => Some(grid_size),
_ => None,
};
runtime.attach(geometry);
runtime.attach(grid_size);

maybe_disown();
start_editor();
Expand Down
13 changes: 6 additions & 7 deletions src/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ pub fn create_window(
pub enum WindowSize {
Size(PhysicalSize<u32>),
Maximized,
Geometry(Dimensions),
NeovimGeometry, // The geometry is read from init.vim/lua
Grid(Dimensions),
NeovimGrid, // The geometry is read from init.vim/lua
}

pub fn determine_window_size() -> WindowSize {
Expand All @@ -209,13 +209,12 @@ pub fn determine_window_size() -> WindowSize {

match cmd_line.geometry {
GeometryArgs {
geometry: Some(Some(dimensions)),
grid: Some(Some(dimensions)),
..
} => WindowSize::Geometry(dimensions.clamped_grid_size()),
} => WindowSize::Grid(dimensions.clamped_grid_size()),
GeometryArgs {
geometry: Some(None),
..
} => WindowSize::NeovimGeometry,
grid: Some(None), ..
} => WindowSize::NeovimGrid,
GeometryArgs {
size: Some(dimensions),
..
Expand Down
4 changes: 2 additions & 2 deletions src/window/window_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@ impl WinitWindowWrapper {
self.windowed_context.window().set_visible(true);
self.windowed_context.window().set_maximized(true);
}
WindowSize::Geometry(Dimensions { width, height }) => {
WindowSize::Grid(Dimensions { width, height }) => {
self.requested_columns = Some(width);
self.requested_lines = Some(height);
log::info!("Showing window {width}, {height}");
// The visibility is changed after the size is adjusted
}
WindowSize::NeovimGeometry => {
WindowSize::NeovimGrid => {
let grid_size = self.renderer.get_grid_size();
self.requested_columns = Some(grid_size.width);
self.requested_lines = Some(grid_size.height);
Expand Down
12 changes: 6 additions & 6 deletions website/docs/command-line-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Can be set to:

Sets the initial neovide window size in pixels.

Can not be used together with `--maximized`, or `--geometry`.
Can not be used together with `--maximized`, or `--grid`.

### Maximized

Expand All @@ -61,22 +61,22 @@ visible.
This is not the same as `g:neovide_fullscreen`, which runs Neovide in "exclusive fullscreen",
covering up the entire screen.

Can not be used together with `--size`, or `--geometry`.
Can not be used together with `--size`, or `--grid`.

### Geometry
**Unreleased-yet**
### Grid Size

```sh
--geometry [<columns>x<lines>]
--grid [<columns>x<lines>]

```

Check failure on line 71 in website/docs/command-line-reference.md

View workflow job for this annotation

GitHub Actions / Lint website

Fenced code blocks should be surrounded by blank lines [Context: "```"]
**Unreleased-yet**

Check failure on line 72 in website/docs/command-line-reference.md

View workflow job for this annotation

GitHub Actions / Lint website

Emphasis used instead of a heading [Context: "Unreleased-yet"]

Sets the initial grid size of the window. If no value is given, it defaults to
columns/lines from `init.vim/lua`, see
[columns](https://neovim.io/doc/user/options.html#'columns') and
[lines](https://neovim.io/doc/user/options.html#'lines').

If the `--geometry` argument is not set then the geometry is inferred from the
If the `--grid` argument is not set then the grid size is inferred from the
window size.

Note: After the initial size has been determined and `init.vim/lua` processed,
Expand Down

0 comments on commit 0dd6a3c

Please sign in to comment.