Skip to content

Commit

Permalink
nterm: set terminal winsize during initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Jan 12, 2025
1 parent dcd5e51 commit 46dc8f0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions nterm/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <termios.h>
#include <errno.h>

TerminalStatus terminal;

Expand Down Expand Up @@ -100,6 +102,22 @@ int main(int argc, char **argv) {

for(int i = 0; i < terminal.hchar; i++)
ntermRedrawLine(i);

// let the pty driver know the terminal's size
struct winsize ws;
if(tcgetwinsize(terminal.master, &ws)) {
ntermPuts("failed to request terminal window size: ");
ntermPuts(strerror(errno));
for(;;);
}

ws.ws_col = terminal.wchar;
ws.ws_row = terminal.hchar;
if(tcsetwinsize(terminal.master, &ws)) {
ntermPuts("failed to set terminal window size: ");
ntermPuts(strerror(errno));
for(;;);
}

// fork and spawn a test process
pid_t pid = fork();
Expand Down

0 comments on commit 46dc8f0

Please sign in to comment.