File: tty.h

package info (click to toggle)
lsh-utils 2.1-12
  • links: PTS
  • area: main
  • in suites: buster
  • size: 12,884 kB
  • sloc: ansic: 51,017; sh: 5,683; lisp: 657; makefile: 381; perl: 63
file content (66 lines) | stat: -rw-r--r-- 2,112 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* tty.h
 *
 */

/* lsh, an implementation of the ssh protocol
 *
 * Copyright (C) 1998, 1999, Niels Mller, Balzs Scheidler
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef LSH_TTY_H_INCLUDED
#define LSH_TTY_H_INCLUDED

#include <termios.h>

#include "lsh.h"

struct terminal_dimensions
{
  uint32_t char_width;
  uint32_t char_height;
  uint32_t pixel_width;
  uint32_t pixel_height;
};

int tty_getattr(int fd, struct termios *ios);
int tty_setattr(int fd, struct termios *ios);

int tty_getwinsize(int fd, struct terminal_dimensions *dims);
int tty_setwinsize(int fd, const struct terminal_dimensions *dims);

struct lsh_string *
tty_encode_term_mode(struct termios *ios);
int
tty_decode_term_mode(struct termios *ios, uint32_t t_len, const uint8_t *t_modes);

#if HAVE_CFMAKERAW
#define CFMAKERAW cfmakeraw
#else /* !HAVE_CFMAKERAW */
/* The flags part definition is probably from the linux cfmakeraw man
 * page. We also set the MIN and TIME attributes (note that these use
 * the same fields as VEOF and VEOL). */

#define CFMAKERAW(ios) do {						   \
  (ios)->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); \
  (ios)->c_oflag &= ~OPOST;						   \
  (ios)->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);			   \
  (ios)->c_cflag &= ~(CSIZE|PARENB); (ios)->c_cflag |= CS8;		   \
  (ios)->c_cc[VMIN] = 3; (ios)->c_cc[VTIME] = 2;			   \
} while(0)
#endif /* !HAVE_CFMAKERAW */

#endif /* LSH_TTY_H_INCLUDED */