Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set screen cols & rows on new tab #427

Merged
merged 4 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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