summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2002-06-08 23:33:04 +0000
committerMarcus Brinkmann <marcus@gnu.org>2002-06-08 23:33:04 +0000
commitfc2f9b7d7b5c2c25e730896024f03bf828a2d8d5 (patch)
treebedd3aa0ce31e56af275340cf5c90e7b3fe8920b
parentde70b25fcd6b7f3c523efea95863cbfeb4313aae (diff)
2002-06-09 Marcus Brinkmann <marcus@gnu.org>
* display.c (struct cursor): Change type of all members from int to u_int32_t. (screen_init): Initialize SCREEN->lines with 25 instead 200 for now. (screen_fill): Bring SCREEN->current_line into the calculation of MATRIXP. (screen_scroll_up): Likewise. (screen_scroll_down): Likewise. (screen_scroll_left): Likewise. (screen_scroll_right): Likewise. (display_output_one): Beautify code a bit. (display_read): Add metadata to beginning of file. * console.c (new_node): Increase size of display node to include metadata.
-rw-r--r--console/ChangeLog17
-rw-r--r--console/console.c2
-rw-r--r--console/display.c65
3 files changed, 67 insertions, 17 deletions
diff --git a/console/ChangeLog b/console/ChangeLog
index 5a14f195..332a70ba 100644
--- a/console/ChangeLog
+++ b/console/ChangeLog
@@ -1,3 +1,20 @@
+2002-06-09 Marcus Brinkmann <marcus@gnu.org>
+
+ * display.c (struct cursor): Change type of all members from int
+ to u_int32_t.
+ (screen_init): Initialize SCREEN->lines with 25 instead 200 for
+ now.
+ (screen_fill): Bring SCREEN->current_line into the calculation of
+ MATRIXP.
+ (screen_scroll_up): Likewise.
+ (screen_scroll_down): Likewise.
+ (screen_scroll_left): Likewise.
+ (screen_scroll_right): Likewise.
+ (display_output_one): Beautify code a bit.
+ (display_read): Add metadata to beginning of file.
+ * console.c (new_node): Increase size of display node to include
+ metadata.
+
2002-06-05 Marcus Brinkmann <marcus@gnu.org>
* input.h: New file.
diff --git a/console/console.c b/console/console.c
index 57e93de6..c0dbf4f5 100644
--- a/console/console.c
+++ b/console/console.c
@@ -288,7 +288,7 @@ new_node (struct node **np, vcons_t vcons, vcons_node_type type)
(*np)->nn_stat.st_ino = (vcons->id << 2) + 2;
(*np)->nn_stat.st_mode |= S_IFREG;
(*np)->nn_stat.st_mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH);
- (*np)->nn_stat.st_size = 2000 * sizeof (wchar_t); /* XXX */
+ (*np)->nn_stat.st_size = 2008 * sizeof (wchar_t); /* XXX */
break;
case VCONS_NODE_INPUT:
(*np)->nn_stat.st_ino = (vcons->id << 2) + 3;
diff --git a/console/display.c b/console/display.c
index d2c0b590..0fffba24 100644
--- a/console/display.c
+++ b/console/display.c
@@ -60,14 +60,14 @@ typedef struct screen *screen_t;
struct cursor
{
/* The visibility of the cursor. */
- int status;
+ u_int32_t status;
#define CURSOR_INVISIBLE 1
#define CURSOR_STANDOUT 2
- size_t x;
- size_t y;
- size_t saved_x;
- size_t saved_y;
+ u_int32_t x;
+ u_int32_t y;
+ u_int32_t saved_x;
+ u_int32_t saved_y;
};
typedef struct cursor *cursor_t;
@@ -151,7 +151,7 @@ screen_init (screen_t screen)
{
screen->width = 80;
screen->height = 25;
- screen->lines = 200; /* XXX For now. */
+ screen->lines = 25; /* XXX For now. */
screen->current_line = 0;
screen->matrix = calloc (screen->lines * screen->width, sizeof (wchar_t));
if (!screen->matrix)
@@ -172,7 +172,8 @@ static void
screen_fill (screen_t screen, size_t x, size_t y, size_t w, size_t h,
wchar_t chr, char attr)
{
- wchar_t *matrixp = screen->matrix + y * screen->width + x;
+ wchar_t *matrixp = screen->matrix
+ + ((screen->current_line + y) % screen->height) * screen->width + x;
while (h--)
{
@@ -188,7 +189,8 @@ static void
screen_scroll_up (screen_t screen, size_t x, size_t y, size_t w, size_t h,
int amt, wchar_t chr, char attr)
{
- wchar_t *matrixp = screen->matrix + y * screen->width + x;
+ wchar_t *matrixp = screen->matrix
+ + ((screen->current_line + y) % screen->height) * screen->width + x;
if (amt < 0)
return;
@@ -205,7 +207,9 @@ static void
screen_scroll_down (screen_t screen, size_t x, size_t y, size_t w, size_t h,
int amt, wchar_t chr, char attr)
{
- wchar_t *matrixp = screen->matrix + (y + h - 1) * screen->width + x;
+ wchar_t *matrixp = screen->matrix
+ + ((screen->current_line + y + h - 1) % screen->height)
+ * screen->width + x;
if (amt < 0)
return;
@@ -223,7 +227,8 @@ screen_scroll_left (screen_t screen, size_t x, size_t y, size_t w, size_t h,
int amt, wchar_t chr, char attr)
{
int i;
- wchar_t *matrixp = screen->matrix + y * screen->width + x;
+ wchar_t *matrixp = screen->matrix
+ + ((screen->current_line + y) % screen->height) * screen->width + x;
if (amt < 0)
return;
@@ -243,7 +248,8 @@ screen_scroll_right (screen_t screen, size_t x, size_t y, size_t w, size_t h,
int amt, wchar_t chr, char attr)
{
int i;
- wchar_t *matrixp = screen->matrix + y * screen->width + x;
+ wchar_t *matrixp = screen->matrix
+ + ((screen->current_line + y) % screen->height) * screen->width + x;
if (amt < 0)
return;
@@ -631,10 +637,9 @@ display_output_one (display_t display, wchar_t chr)
}
else
{
- if (display->screen.current_line == display->screen.lines - 1)
- display->screen.current_line = 0;
- else
- display->screen.current_line++;
+ display->screen.current_line++;
+ display->screen.current_line %= display->screen.lines;
+
/* XXX Set attribute flags. */
screen_fill (&display->screen, 0, display->screen.height - 1,
display->screen.width, 1, L' ', display->screen.width);
@@ -1001,12 +1006,40 @@ display_output (display_t display, int nonblock, char *data, size_t datalen)
ssize_t display_read (display_t display, int nonblock, off_t off,
char *data, size_t len)
{
+ u_int32_t metadata[8];
+ size_t metadatalen = sizeof (metadata);
+ ssize_t written = 0;
+
mutex_lock (&display->lock);
+ metadata[0] = display->screen.width;
+ metadata[1] = display->screen.height;
+ metadata[2] = display->screen.lines;
+ metadata[3] = display->screen.current_line;
+ metadata[4] = display->screen.scrolling_max;
+ metadata[5] = display->cursor.x;
+ metadata[6] = display->cursor.y;
+ metadata[7] = display->cursor.status;
+
+ if (off >= 0 && off < metadatalen)
+ {
+ int part_len = len;
+
+ if (part_len > metadatalen)
+ part_len = metadatalen;
+ memcpy (data, (char *) metadata + off, part_len);
+ data += part_len;
+ len -= part_len;
+ written += part_len;
+ }
+ off -= metadatalen;
+ if (off < 0)
+ off = 0;
+
if (off + len > 2000 * sizeof(wchar_t))
len = 2000 * sizeof(wchar_t) - off;
memcpy (data, (char *) display->screen.matrix + off, len);
mutex_unlock (&display->lock);
- return len;
+ return written + len;
}
/* Resume the output on the display DISPLAY. */