Skip to content

Commit

Permalink
fix: set screen cols & rows on new tab (#427)
Browse files Browse the repository at this point in the history
* fix: set terminal col rows on new tab

* fix: revert cols/width for windows

* refactor: send resize event on windows

---------

Co-authored-by: Raphael Amorim <[email protected]>
  • Loading branch information
hougesen and raphamorim authored Jan 22, 2024
1 parent 5f919de commit 5681e0f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 23 additions & 4 deletions frontends/rioterm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ impl<T: EventListener + Clone + std::marker::Send + 'static> ContextManager<T> {
size: SugarloafLayout,
config: &ContextManagerConfig,
) -> Result<Context<T>, Box<dyn Error>> {
#[cfg(target_os = "windows")]
let width = size.width_u32;

#[cfg(target_os = "windows")]
let height = size.height_u32;

let cols: u16 = size.columns.try_into().unwrap_or(MIN_COLUMNS as u16);
let rows: u16 = size.lines.try_into().unwrap_or(MIN_LINES as u16);

let mut terminal =
Crosswords::new(size, cursor_state.0.content, event_proxy.clone(), window_id);
terminal.blinking_cursor = cursor_state.1;
Expand All @@ -133,8 +142,8 @@ impl<T: EventListener + Clone + std::marker::Send + 'static> ContextManager<T> {
log::info!("rio -> teletypewriter: create_pty_with_fork");
pty = match create_pty_with_fork(
&Cow::Borrowed(&config.shell.program),
2,
1,
cols,
rows,
) {
Ok(created_pty) => created_pty,
Err(err) => {
Expand All @@ -148,8 +157,8 @@ impl<T: EventListener + Clone + std::marker::Send + 'static> ContextManager<T> {
&Cow::Borrowed(&config.shell.program),
config.shell.args.clone(),
&config.working_dir,
2,
1,
cols,
rows,
) {
Ok(created_pty) => created_pty,
Err(err) => {
Expand Down Expand Up @@ -182,8 +191,18 @@ impl<T: EventListener + Clone + std::marker::Send + 'static> ContextManager<T> {
if config.spawn_performer {
machine.spawn();
}

let messenger = Messenger::new(channel);

#[cfg(target_os = "windows")]
{
if let Err(resize_error) =
messenger.send_resize(width as u16, height as u16, cols, rows)
{
log::error!("{resize_error:?}");
}
};

Ok(Context {
#[cfg(not(target_os = "windows"))]
main_fd,
Expand Down
2 changes: 1 addition & 1 deletion teletypewriter/src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ pub fn create_pty_with_fork(shell: &str, columns: u16, rows: u16) -> Result<Pty,
};

if shell.is_empty() {
log::info!("shell configuration is empty, will retrive from env");
log::info!("shell configuration is empty, will retrieve from env");
shell_program = &user.shell;
}

Expand Down

0 comments on commit 5681e0f

Please sign in to comment.