aboutsummaryrefslogtreecommitdiffstats
path: root/src/terminal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c75
1 files changed, 43 insertions, 32 deletions
diff --git a/src/terminal.c b/src/terminal.c
index 301ea74..4f31372 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -11,6 +11,9 @@ static char rcsid[] =
/*
* $Log$
+ * Revision 1.25 2012/06/22 10:22:25 james
+ * *** empty log message ***
+ *
* Revision 1.24 2008/03/12 10:47:26 james
* @@
*
@@ -106,7 +109,8 @@ static char rcsid[] =
#include "project.h"
-typedef struct TERMINAL_struct {
+typedef struct TERMINAL_struct
+{
TTY_SIGNATURE;
struct termios orig_termios;
struct TERMINAL_struct *next;
@@ -149,8 +153,11 @@ terminal_close (TTY * _t)
t->xmit (_t, "\033[?25h", 6); // Show cursor
t->xmit (_t, "\033[r", 3); // No margins
t->xmit (_t, "\033[0m", 4); // Default attributes
- i = sprintf (buf, "\033[%d;%dH", t->displayed_length ? (t->displayed_length + 1) : (CRT_ROWS + 1), 1);
- // Cursor to bottom
+ i =
+ sprintf (buf, "\033[%d;%dH",
+ t->displayed_length ? (t->displayed_length + 1) : (CRT_ROWS + 1),
+ 1);
+ // Cursor to bottom
t->xmit (_t, buf, i);
t->xmit (_t, "\033[J", 3); // erase rest of screen
@@ -191,13 +198,16 @@ terminal_getsize (TTY * _t)
if (!t)
return;
- if (ioctl (t->wfd, TIOCGWINSZ, &sz)) {
- t->size.x = CRT_COLS;
- t->size.y = CRT_ROWS;
- } else {
- t->size.x = sz.ws_col;
- t->size.y = sz.ws_row;
- }
+ if (ioctl (t->wfd, TIOCGWINSZ, &sz))
+ {
+ t->size.x = CRT_COLS;
+ t->size.y = CRT_ROWS;
+ }
+ else
+ {
+ t->size.x = sz.ws_col;
+ t->size.y = sz.ws_row;
+ }
}
@@ -227,18 +237,19 @@ terminal_read (TTY * _t, void *buf, int len)
terminal_dispatch ();
set_nonblocking (t->rfd);
- do {
+ do
+ {
- red = wrap_read (t->rfd, buf, len);
- if (red < 0)
- return -1;
- if (!red)
- return done;
+ red = wrap_read (t->rfd, buf, len);
+ if (red < 0)
+ return -1;
+ if (!red)
+ return done;
- buf += red;
- len -= red;
- done += red;
- }
+ buf += red;
+ len -= red;
+ done += red;
+ }
while (len);
@@ -256,19 +267,20 @@ terminal_write (TTY * _t, void *buf, int len)
set_blocking (t->wfd);
- do {
+ do
+ {
- writ = wrap_write (t->wfd, buf, len);
- if (writ < 0)
- return -1;
+ writ = wrap_write (t->wfd, buf, len);
+ if (writ < 0)
+ return -1;
- if (!writ)
- usleep (1000);
+ if (!writ)
+ usleep (1000);
- buf += writ;
- len -= writ;
- done += writ;
- }
+ buf += writ;
+ len -= writ;
+ done += writ;
+ }
while (len);
@@ -279,7 +291,7 @@ terminal_write (TTY * _t, void *buf, int len)
void
terminal_register_handlers (void)
{
- struct sigaction sa = { 0 };
+ struct sigaction sa = { {0} };
sa.sa_handler = sigwinch;
sa.sa_flags = SA_RESTART;
@@ -295,7 +307,6 @@ TTY *
terminal_open (int rfd, int wfd)
{
TERMINAL *t;
- pid_t child;
struct termios termios;
t = (TERMINAL *) xmalloc (sizeof (TERMINAL));