diff --git a/docs/changelog.md b/docs/changelog.md index 3ffe72a05..c2426ad69 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -14,6 +14,8 @@ As features stabilize some brief notes about them will accumulate here. #### New * [ActivateKeyTable](config/lua/keyassignment/ActivateKeyTable.md) now supports `until_unknown=true` to implicitly pop the table when a key not defined by that table is pressed. [#2178](https://github.com/wez/wezterm/issues/2178) * [window:copy_to_clipboard](config/lua/window/copy_to_clipboard.md) method for putting arbitrary text into the clipboard/selection. +* [window:set_inner_size](config/lua/window/set_inner_size.md) method for controlling window size. +* [window:set_position](config/lua/window/set_position.md) method for controlling window position. * [window:get_selection_escapes_for_pane](config/lua/window/get_selection_escapes_for_pane.md) method for getting the current selection including escape sequences. [#2223](https://github.com/wez/wezterm/issues/2223) * New [wezterm.gui](config/lua/wezterm.gui/index.md) module and [mux_window:gui_window](config/lua/mux-window/gui_window.md) method. diff --git a/docs/config/lua/window/set_inner_size.md b/docs/config/lua/window/set_inner_size.md new file mode 100644 index 000000000..800cc4ec5 --- /dev/null +++ b/docs/config/lua/window/set_inner_size.md @@ -0,0 +1,6 @@ +# `window:set_inner_size(width, height)` + +*Since: nightly builds only* + +Resizes the inner portion of the window (excluding any window decorations) to +the specified width and height. diff --git a/docs/config/lua/window/set_position.md b/docs/config/lua/window/set_position.md new file mode 100644 index 000000000..d2721efaa --- /dev/null +++ b/docs/config/lua/window/set_position.md @@ -0,0 +1,8 @@ +# `window:set_position(x, y)` + +*Since: nightly builds only* + +Repositions the top-left corner of the window to the specified `x`, `y` coordinates. + +Note that Wayland does not allow applications to directly control their window +placement, so this method has no effect on Wayland. diff --git a/wezterm-gui/src/scripting/guiwin.rs b/wezterm-gui/src/scripting/guiwin.rs index 759408121..9ca9b619d 100644 --- a/wezterm-gui/src/scripting/guiwin.rs +++ b/wezterm-gui/src/scripting/guiwin.rs @@ -39,6 +39,17 @@ impl UserData for GuiWin { methods.add_method("mux_window", |_, this, _: ()| { Ok(mux_lua::MuxWindow(this.mux_window_id)) }); + methods.add_method( + "set_inner_size", + |_, this, (width, height): (usize, usize)| { + this.window.set_inner_size(width, height); + Ok(()) + }, + ); + methods.add_method("set_position", |_, this, (x, y): (isize, isize)| { + this.window.set_window_position(euclid::point2(x, y)); + Ok(()) + }); methods.add_method( "toast_notification", |_, _, (title, message, url, timeout): (String, String, Option, Option)| {