diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-04-02 22:11:25 +0000 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2001-04-02 22:11:25 +0000 |
commit | e4acd1c4f7deeed5d96e9eeb2284a7a2afef440c (patch) | |
tree | 8fde6cd6cedd24355d4092e35dc1634cc47e1da5 /mixgtk | |
parent | cb9e5852b9731f754335459d43826e5397b0f617 (diff) | |
download | mdk-e4acd1c4f7deeed5d96e9eeb2284a7a2afef440c.tar.gz mdk-e4acd1c4f7deeed5d96e9eeb2284a7a2afef440c.tar.bz2 |
use of opem_memstream avoided for FreeBSD portability
Diffstat (limited to 'mixgtk')
-rw-r--r-- | mixgtk/mixgtk_device.c | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/mixgtk/mixgtk_device.c b/mixgtk/mixgtk_device.c index 2e231a4..faf3c3b 100644 --- a/mixgtk/mixgtk_device.c +++ b/mixgtk/mixgtk_device.c @@ -1,7 +1,7 @@ /* -*-c-*- ---------------- mixgtk_device.c : * actual types for mixgtk devices * ------------------------------------------------------------------ - * Last change: Time-stamp: <01/03/05 01:13:40 jose> + * Last change: Time-stamp: <01/04/03 00:09:46 jose> * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -22,8 +22,6 @@ */ -#define _GNU_SOURCE 1 - #include <stdio.h> #include <mixlib/xmix_device.h> #include "mixgtk_device.h" @@ -37,8 +35,7 @@ static mix_vm_t *vm_ = NULL; struct mixgtk_device_t { mix_device_t device; - char *buffer; - size_t buffer_len; + gchar *buffer; GtkText *widget; gint pos; }; @@ -47,18 +44,37 @@ struct mixgtk_device_t static gboolean write_out_ (mix_device_t *dev, const mix_word_t *block) { - struct mixgtk_device_t *gtkdev; + struct mixgtk_device_t *gtkdev = (struct mixgtk_device_t *) dev; + guint k, j; - if (!((DEF_DEV_VTABLE_->write) (dev, block))) return FALSE; - gtkdev = (struct mixgtk_device_t *) dev; - if (gtkdev->buffer_len > 0) - { - gtk_text_insert (gtkdev->widget, NULL, NULL, NULL, - gtkdev->buffer, gtkdev->buffer_len); - rewind (mix_io_to_FILE (gtkdev->device.file)); - gtk_notebook_set_page (container_, gtkdev->pos); - gtk_widget_draw (GTK_WIDGET (container_), NULL); - } + for (k = 0; k < SIZES_[dev->type]; k++) + for (j = 1; j < 6; j++) + { + mix_char_t ch = mix_word_get_byte (block[k], j); + gtkdev->buffer[5 * k + j - 1] = mix_char_to_ascii (ch); + } + + gtk_text_insert (gtkdev->widget, NULL, NULL, NULL, gtkdev->buffer, -1); + gtk_notebook_set_page (container_, gtkdev->pos); + + return TRUE; +} + +static gboolean +read_out_ (mix_device_t *dev, mix_word_t *block) +{ + return TRUE; +} + +static gboolean +ioc_out_ (mix_device_t *dev, mix_short_t cmd) +{ + return TRUE; +} + +static gboolean +busy_out_ (const mix_device_t *dev) +{ return TRUE; } @@ -74,13 +90,13 @@ mixgtk_device_new_ (mix_device_type_t type) if (MODES_[type] == mix_dev_CHAR && FMODES_[type] == mix_io_WRITE) { - FILE *f; dev = g_new (struct mixgtk_device_t, 1); - f = open_memstream (&(dev->buffer), &(dev->buffer_len)); - g_assert (f); - dev->device.file = mix_io_new (f); + dev->device.file = NULL; dev->device.type = type; dev->device.vtable = &MIXGTK_OUT_VTABLE_; + dev->buffer = g_new (gchar, (SIZES_[type] * 5 + 2)); + dev->buffer[SIZES_[type] * 5] = '\n'; + dev->buffer[SIZES_[type] * 5 + 1] = '\0'; dev->widget = (GtkText *)gtk_text_new (NULL, NULL); g_assert (dev->widget); gtk_text_set_editable (dev->widget, FALSE); @@ -131,9 +147,9 @@ mixgtk_device_init (GtkNotebook *container, mix_vm_t *vm) /* initialise vtables */ MIXGTK_OUT_VTABLE_.write = write_out_; - MIXGTK_OUT_VTABLE_.read = DEF_DEV_VTABLE_->read; - MIXGTK_OUT_VTABLE_.ioc = DEF_DEV_VTABLE_->ioc; - MIXGTK_OUT_VTABLE_.busy = DEF_DEV_VTABLE_->busy; + MIXGTK_OUT_VTABLE_.read = read_out_; + MIXGTK_OUT_VTABLE_.ioc = ioc_out_; + MIXGTK_OUT_VTABLE_.busy = busy_out_; /* connect default devices */ while (def_types[k] != mix_dev_INVALID) |