Subversion Repositories planix.SVN

Rev

Rev 119 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
118 7u83 1
/*
2
 * Copyright (c) 2019 The PLANIX Project,
3
 * All rights reserved.  
4
 *
5
 * The Berkeley software License Agreement specifies the terms 
6
 * and conditions for redistribution.
7
 *
8
 */
9
 
10
#include <stdlib.h>
11
#include <termios.h>
12
#include <unistd.h>
13
 
14
struct termios orig_termios;
15
 
16
void
17
disable_raw()
18
{
19
	tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
20
}
21
 
22
void
23
enable_raw()
24
{
121 7u83 25
	struct termios raw;
118 7u83 26
	tcgetattr(STDIN_FILENO, &orig_termios);
27
	atexit(disable_raw);
121 7u83 28
	raw = orig_termios;
118 7u83 29
	raw.c_iflag &= ~(IXON);
30
	raw.c_lflag &= ~(ECHO | ICANON | ISIG);
31
	tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
32
}
119 7u83 33
 
34
#include <stdio.h>
35
 
36
 
37
void 
38
get_size(short *columns, short *lines)
39
{
40
	struct winsize win;
41
	int x,y;
42
	if (ioctl(0, TIOCGWINSZ, &win) < 0) {
43
		*lines = tgetnum("li");
44
		*columns = tgetnum("co");
45
		return;
46
	} 
47
 
48
	*lines = win.ws_row;	
49
	*columns = win.ws_col;	
50
 
51
 
52
	printf("Here is the terminal size: %d x %d\n", *columns, *lines );
53
	/*	
54
 
55
 
56
	else {
57
		if ((LINES = winsz.ws_row = win.ws_row) == 0)
58
			LINES = tgetnum("li");
59
		i = LINES;
60
		if ((COLUMNS = winsz.ws_col = win.ws_col) == 0)
61
			COLUMNS = tgetnum("co");
62
	}
63
*/
64
 
65
}