Skip to content

Commit

Permalink
Deprecate legacy terminal size feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Mar 26, 2013
1 parent a125d2d commit 5867eec
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 37 deletions.
9 changes: 6 additions & 3 deletions userspace/core/ls.c
Expand Up @@ -15,6 +15,8 @@
#include <syscall.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/ioctl.h>
#include <termios.h>

#include "lib/list.h"

Expand Down Expand Up @@ -251,9 +253,10 @@ int main (int argc, char * argv[]) {
int term_height = DEFAULT_TERM_HEIGHT;

/* This is a hack to determine the terminal with in a toaru terminal */
printf("\033[1003z");
fflush(stdout);
scanf("%d,%d", &term_width, &term_height);
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
term_width = w.ws_col;
term_height = w.ws_row;
term_width -= 1; /* And this just helps clean up our math */

int col_ext = ent_max_len + MIN_COL_SPACING;
Expand Down
11 changes: 2 additions & 9 deletions userspace/extra/bim.c
Expand Up @@ -12,11 +12,11 @@
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <termios.h>

#ifdef __linux__
#include <stdio_ext.h>
#include <sys/ioctl.h>
#include <termios.h>
#define BACKSPACE_KEY 0x7F
#else
#include <syscall.h>
Expand Down Expand Up @@ -511,17 +511,10 @@ void initialize() {
buffers_avail = 4;
buffers = malloc(sizeof(buffer_t *) * buffers_avail);

#ifdef __linux__
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
term_width = w.ws_col;
term_height = w.ws_row;
#else
printf("\033[1003z");
fflush(stdout);
scanf("%d,%d", &term_width, &term_height);
fpurge(stdin);
#endif
set_unbuffered();

}
Expand Down
14 changes: 1 addition & 13 deletions userspace/extra/csnow.c
Expand Up @@ -2,12 +2,11 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>

#ifdef __toaru__
#include <syscall.h>
int usleep(useconds_t time) { syscall_nanosleep(0, time / 10000); }
#else
#include <sys/ioctl.h>
#endif

#define MAX_SPEED 2
Expand Down Expand Up @@ -43,21 +42,10 @@ screen_t * init_screen() {

screen_t * screen = malloc(sizeof(screen_t));

#ifdef __toaru__
if (strstr(term, "toaru")) {
printf("\033[1003z");
fflush(stdout);
scanf("%d,%d", &screen->width, &screen->height);
} else {
screen->width = 80; /* better safe than sorry */
screen->height = 24;
}
#else
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
screen->width = w.ws_col;
screen->height = w.ws_row;
#endif

screen->backingstore = malloc(sizeof(char *) * screen->width * screen->height);

Expand Down
7 changes: 0 additions & 7 deletions userspace/gui/terminal/terminal.c
Expand Up @@ -314,13 +314,6 @@ static void _ansi_put(char c) {
/* Local Echo On */
state.local_echo = 1;
break;
case 1003:
{
char out[24];
sprintf(out, "%d,%d\n", term_width, term_height);
input_buffer_stuff(out);
}
break;
case 1555:
if (argc > 1) {
scale_fonts = 1;
Expand Down
13 changes: 8 additions & 5 deletions userspace/util/term_size.c
@@ -1,9 +1,12 @@
#include <stdio.h>
#include <sys/ioctl.h>
#include <termios.h>

int main(int argc, char * argv[]) {
printf("\033[1003z");
fflush(stdout);
int width, height;
scanf("%d,%d", &width, &height);
printf("Terminal is %dx%d\n", width, height);
struct winsize w;
int width, height;
ioctl(0, TIOCGWINSZ, &w);
width = w.ws_col;
height = w.ws_row;
printf("Terminal is %dx%d\n", width, height);
}

0 comments on commit 5867eec

Please sign in to comment.