Inform remote that terminal size changed

This commit is contained in:
oupson 2023-03-04 12:57:58 +01:00
parent df40cbf7a9
commit 3df4119fa0
Signed by: oupson
GPG Key ID: 3BD88615552EFCB7
1 changed files with 17 additions and 7 deletions

View File

@ -34,6 +34,9 @@ namespace Footerm {
private Footerm.Model.Server? server; private Footerm.Model.Server? server;
private int old_terminal_width = 0;
private int old_terminal_height = 0;
construct { construct {
this.configure_terminal(); this.configure_terminal();
} }
@ -78,15 +81,22 @@ namespace Footerm {
private void configure_terminal() { private void configure_terminal() {
this.terminal.set_enable_sixel(true); this.terminal.set_enable_sixel(true);
this.terminal.char_size_changed.connect(() => { this.terminal.char_size_changed.connect(this.terminal_appearance_changed);
var pty = this.terminal.get_pty(); this.terminal.contents_changed.connect(this.terminal_appearance_changed);
if (pty != null && this.channel != null) { }
int rows = 0;
int columns = 0; private void terminal_appearance_changed() {
pty.get_size(out rows, out columns); var pty = this.terminal.get_pty();
if (pty != null && this.channel != null) {
int rows = 0;
int columns = 0;
pty.get_size(out rows, out columns);
if (rows != this.old_terminal_height || columns != this.old_terminal_width) {
this.old_terminal_height = rows;
this.old_terminal_width = columns;
this.channel.request_pty_size(columns, rows); this.channel.request_pty_size(columns, rows);
} }
}); }
} }
private void create_pty() throws GLib.IOError { private void create_pty() throws GLib.IOError {