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

Dynamically Setting Geometry #242

Open
chengpengvb opened this issue Oct 25, 2024 · 0 comments
Open

Dynamically Setting Geometry #242

chengpengvb opened this issue Oct 25, 2024 · 0 comments

Comments

@chengpengvb
Copy link

chengpengvb commented Oct 25, 2024

Hello:
I tried to dynamically set terminalWidth and terminalHeight with the following code:

sendNAWS(cols: number, rows: number): void {
        if (!this.socket || !this.socket.writable) {
            this.emit('error', new Error('Socket is not writable'));
            console.error('Socket is not writable. Cannot send NAWS.');
            return;
        }
        const nawsBuffer = Buffer.from([
            255, // IAC
            250, // SB
            31,  // NAWS
            (cols >> 8) & 0xff, // Columns high byte
            cols & 0xff,        // Columns low byte
            (rows >> 8) & 0xff, // Rows high byte
            rows & 0xff,        // Rows low byte
            255, // IAC
            240  // SE
        ]);
        console.log(`Sending NAWS command with cols=${cols}, rows=${rows}:`, nawsBuffer);
        this.socket.write(nawsBuffer, (err?: Error) => {
            if (err) {
                this.emit('error', err);
                console.error('Failed to send NAWS command:', err);
            } else {
                this.emit('geometrySet', { cols, rows });
                console.log(`NAWS command sent successfully for cols=${cols}, rows=${rows}.`);
            }
        });
    }

But it didn't work. Has anyone encountered the same requirement?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant