aboutsummaryrefslogtreecommitdiffstats
path: root/src/terminal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c88
1 files changed, 45 insertions, 43 deletions
diff --git a/src/terminal.c b/src/terminal.c
index 65ec41c..c89ca16 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1,4 +1,4 @@
-/*
+/*
* terminal.c:
*
* Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
@@ -9,8 +9,11 @@
static char rcsid[] =
"$Id$";
-/*
+/*
* $Log$
+ * Revision 1.15 2008/03/07 12:37:04 james
+ * *** empty log message ***
+ *
* Revision 1.14 2008/03/03 06:04:42 james
* *** empty log message ***
*
@@ -113,15 +116,19 @@ terminal_close (TTY * _t)
set_nonblocking (t->wfd);
- t->xmit (_t, "\033%@", 3); //Leave UTF-8
- t->xmit (_t, "\033(B", 3); //US-ASCII in G0
- t->xmit (_t, "\033)B", 3); //US-ASCII in G1
- t->xmit (_t, "\017", 1); //Select G0
- 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
+ t->xmit (_t, "\033%@", 3); // Leave UTF-8
+ t->xmit (_t, "\033(B", 3); // US-ASCII in G0
+ t->xmit (_t, "\033)B", 3); // US-ASCII in G1
+ t->xmit (_t, "\017", 1); // Select G0
+ 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
t->xmit (_t, buf, i);
- t->xmit (_t, "\033[J", 3); //erase rest of screen
+ t->xmit (_t, "\033[J", 3); // erase rest of screen
set_blocking (t->rfd);
set_blocking (t->wfd);
@@ -160,16 +167,13 @@ 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;
+ }
}
@@ -199,19 +203,18 @@ 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);
@@ -229,20 +232,19 @@ 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);
@@ -290,7 +292,7 @@ terminal_open (int rfd, int wfd)
cfmakeraw (&termios);
- //raw_termios (&termios);
+ // raw_termios (&termios);
tcsetattr (wfd, TCSANOW, &termios);