Term-Gnuplot

 view release on metacpan or  search on metacpan

gnuterm/term/ggi.trm  view on Meta::CPAN


static void GGI_line_colors __PROTO((void));
TERM_PUBLIC void GGI_graphics __PROTO((void));
TERM_PUBLIC void GGI_set_size __PROTO((void));
TERM_PUBLIC void GGI_init __PROTO((void));
TERM_PUBLIC void GGI_linetype __PROTO((int));
TERM_PUBLIC void GGI_move __PROTO((unsigned int,unsigned int));
TERM_PUBLIC void GGI_options __PROTO((void));
TERM_PUBLIC void GGI_put_text __PROTO((unsigned int,unsigned int, const char*));
TERM_PUBLIC void GGI_suspend __PROTO((void));
TERM_PUBLIC void GGI_resume __PROTO((void));
TERM_PUBLIC void GGI_fillbox __PROTO((int style, unsigned int x, unsigned int y,
	unsigned int w, unsigned int h));
TERM_PUBLIC void GGI_close __PROTO((void));
TERM_PUBLIC void GGI_reset __PROTO((void));
TERM_PUBLIC void GGI_text __PROTO((void));
TERM_PUBLIC void GGI_vector __PROTO((unsigned int,unsigned int));

#ifdef USE_MOUSE

/* zoom box information */

typedef struct  {
    int x;
    int y;
} GGI_point_t;

typedef struct {
    int x;
    int y;
    int width;
    int height;
    char str[0xff];
} GGI_vertex_t;

TERM_PUBLIC long int GGI_SetTime(const struct timeval* current);
TERM_PUBLIC int GGI_from_keysym __PROTO((uint32 keysym));
TERM_PUBLIC int GGI_from_button __PROTO((uint32 button));
TERM_PUBLIC int GGI_y __PROTO((sint32 y));
TERM_PUBLIC int GGI_dispatch_event __PROTO((const ggi_event* event));
TERM_PUBLIC int GGI_eventually_update_modifiers __PROTO((const ggi_event* event, const int add));
TERM_PUBLIC int GGI_waitforinput __PROTO((void));
TERM_PUBLIC void GGI_draw_ruler __PROTO((void));
TERM_PUBLIC void GGI_clear_zoombox __PROTO((void));
TERM_PUBLIC void GGI_draw_zoombox __PROTO((void));
TERM_PUBLIC void GGI_set_ruler __PROTO((int, int));
TERM_PUBLIC void GGI_set_cursor __PROTO((int, int, int));
TERM_PUBLIC void GGI_save_frame_canvas __PROTO((void));
TERM_PUBLIC void GGI_save_frame_stl __PROTO((void));
TERM_PUBLIC void GGI_replot __PROTO((void));
TERM_PUBLIC void GGI_clear __PROTO((const GGI_vertex_t* v, const int tag));
TERM_PUBLIC void GGI_save_puts __PROTO((GGI_vertex_t* v, const int tag));
TERM_PUBLIC void GGI_set_vertex __PROTO((GGI_vertex_t* v, const int x, const int y, const char* str, const int tag));
TERM_PUBLIC void GGI_abort_zooming __PROTO((void));
TERM_PUBLIC void GGI_put_tmptext __PROTO((int, const char str[]));
TERM_PUBLIC void GGI_relative __PROTO((int r[2]));
TERM_PUBLIC void GGI_clear_hline __PROTO((int x1, int x2, int y));
TERM_PUBLIC void GGI_clear_vline __PROTO((int y1, int y2, int x));
TERM_PUBLIC void GGI_draw_hline __PROTO((int x1, int x2, int y));
TERM_PUBLIC void GGI_draw_vline __PROTO((int y1, int y2, int x));
TERM_PUBLIC void GGI_set_clipboard __PROTO((const char[]));
#endif /* USE_MOUSE */

#ifdef PM3D
TERM_PUBLIC int GGI_make_palette __PROTO((t_sm_palette*));
TERM_PUBLIC void GGI_previous_palette __PROTO((void));
TERM_PUBLIC void GGI_set_color __PROTO((double));
#ifdef ENABLE_XMI
TERM_PUBLIC void GGI_filled_polygon __PROTO((int, gpiPoint*));
#endif
#endif

#define GOT_GGI_PROTO
#endif

#ifndef TERM_PROTO_ONLY
#ifdef TERM_BODY

#define GGI_XMAX 800
#define GGI_YMAX 600
#define GGI_VCHAR 8
#define GGI_HCHAR 8
#define GGI_VTIC 8
#define GGI_HTIC 8


#ifdef USE_MOUSE
static GGI_vertex_t GGI_zoom[2][2];
static GGI_vertex_t GGI_stl_vertex;
static GGI_point_t GGI_ruler = {-1, -1};
static GGI_point_t GGI_zoombox[2] = {{-1, -1}, {-1, -1}};

static struct timeval GGI_timestamp;
static int GGI_mouse_x = 0;
static int GGI_mouse_y = 0;
static int GGI_modifiers = 0;
static int GGI_use_mouse = 1; /* mouse is on by default */
static unsigned int GGIcanvas_height = 0;
static int GGI_font_width = 0;
static int GGI_font_height = 0;
static int GGI_saved_canvas = 0;
static int GGI_saved_stl = 0;
static int GGI_needs_update = 1;
#endif

#ifdef PM3D
static t_sm_palette GGI_save_pal = {
    -1, -1, -1, -1, -1, -1, -1, -1,
    (rgb_color*) 0, -1, -1
};
#endif

/* First to some global variables
 *
 * GGIvisual is our 'piece of paper.'
 * GGIborderColor and axixColor have the obvious meanings.
 * GGIcolors are the colors for linestyles 0 and up.
 * GGImap is for initializing colors.
 * GGIx,GGIy are the current coordinates.
 * GGIwidth, GGIheight are the extensions in the visual.
 * GGIymax = term->ymax

gnuterm/term/ggi.trm  view on Meta::CPAN

	    second = (char*) strchr(str, '\r'); 
	    --i; /* transform to [0, 1] */
	    GGI_clear_zoombox();
	    if (second == NULL) {
		/* remove box and / or coordinates */
		GGI_set_vertex(&(GGI_zoom[i][0]), 0, 0, (char*)0, GGI_saved_canvas);
		GGI_set_vertex(&(GGI_zoom[i][1]), 0, 0, (char*)0, GGI_saved_canvas);
		break;
	    } else {
		*second = '\0'; /* XXX this assumes that str is writable XXX */
		second++;
		GGI_set_vertex(&(GGI_zoom[i][0]), GGI_mouse_x, GGI_mouse_y - GGI_font_height - 1, str, GGI_saved_canvas);
		GGI_set_vertex(&(GGI_zoom[i][1]), GGI_mouse_x, GGI_mouse_y + 1, second, GGI_saved_canvas);
		GGI_zoombox[i].x = GGI_mouse_x;
		GGI_zoombox[i].y = GGI_mouse_y;
	    }
	    break;
    }
    GGI_needs_update++;
}

TERM_PUBLIC void
GGI_set_ruler(x, y)
    int x, y;
{
    if (x < 0) {

	/* turn ruler off */
	GGI_clear_hline(0, GGIwidth, GGI_ruler.y);
	GGI_clear_vline(0, GGIcanvas_height, GGI_ruler.x);
	GGI_ruler.x = -1;
	GGI_ruler.y = -1;

    } else {
	GGI_ruler.x = x;
	GGI_ruler.y = GGI_y(y);
    }
    GGI_needs_update++;
}

TERM_PUBLIC void
GGI_set_cursor(c, x, y)
    int c, x, y;
{
    /* TODO */
    switch (c) {
	case 0:
	    GGI_abort_zooming();
	    break;
	case 1:
	case 2:
	case 3:
	default:
	    /* XXX not implemented */
	    break;
    }
    GGI_needs_update++;
}

TERM_PUBLIC void
GGI_set_clipboard(s)
    const char s[];
{
    /* XXX: not implemented */
}
#endif

#ifdef PM3D
TERM_PUBLIC int
GGI_make_palette(palette)
    t_sm_palette *palette;
{
    /* reallocate only, if it has changed */
    if (palette && (GGI_save_pal.colorFormulae < 0
	    || palette->colorFormulae != GGI_save_pal.colorFormulae
	    || palette->colorMode != GGI_save_pal.colorMode
	    || palette->formulaR != GGI_save_pal.formulaR
	    || palette->formulaG != GGI_save_pal.formulaG
	    || palette->formulaB != GGI_save_pal.formulaB
	    || palette->positive != GGI_save_pal.positive)) {
	int i;
	ggi_color color;
	for (i = 0; i < ggi_pm3d_colors; i++) {
	    color.r = (short)floor(palette->color[i].r * 0xffff),
	    color.g = (short)floor(palette->color[i].g * 0xffff),
	    color.b = (short)floor(palette->color[i].b * 0xffff),
	    GGI_smooth_colors[i] = ggiMapColor(GGIvisual, &color);
	}
	GGI_save_pal = *palette;
    } else {
	return ggi_pm3d_colors;
    }
    return 0;
}

TERM_PUBLIC void
GGI_previous_palette()
{
#if 0
#ifdef ENABLE_XMI
    fprintf(stderr, "(GGI_previous_palette) \n");
    if (GGI_miPaintedSet) {
	miPoint offset;
	offset.x = 0; offset.y = 0;
	miCopyPaintedSetToVisual(GGIvisual, GGI_miGC, GGI_miPaintedSet, offset);
	miClearPaintedSet(GGIvisual, GGI_miPaintedSet);
    }
#endif
#endif
}

TERM_PUBLIC void
GGI_set_color(gray)
    double gray;
{
    if (GGIvisual) {
	int idx = (gray <= 0) ? 0 : (int)(gray * ggi_pm3d_colors);
	if (idx >= ggi_pm3d_colors)
	    idx = ggi_pm3d_colors - 1;
	ggiSetGCForeground(GGIvisual, GGI_smooth_colors[idx]);
#ifdef ENABLE_XMI
	GGI_miGC->pixels[1] = GGI_smooth_colors[idx];
#endif
    }
}

#ifdef ENABLE_XMI
TERM_PUBLIC void
GGI_filled_polygon(points, corners)
    int points;
    gpiPoint *corners;
{
    static miPoint offset = {0, 0};
    if (GGI_miPaintedSet) {
#define MI_POINTS 4
	miPoint mi_corners[MI_POINTS];
	unsigned int i;
	if (MI_POINTS != points) {
	    fprintf(stderr, "(GGI_filled_polygon) internal error %s:%d\n", __FILE__, __LINE__);
	    return;
	}
	for (i = 0; i < MI_POINTS; i++) {
	    mi_corners[i].x = corners[i].x;
	    mi_corners[i].y = GGI_y(corners[i].y);
	}
	miFillPolygon(GGIvisual, GGI_miPaintedSet, GGI_miGC,
	    MI_SHAPE_GENERAL, MI_COORD_MODE_ORIGIN, MI_POINTS, mi_corners);
	miCopyPaintedSetToVisual(GGIvisual, GGI_miGC, GGI_miPaintedSet, offset);
	miClearPaintedSet(GGIvisual, GGI_miPaintedSet);
    }
}
#endif

#endif /* PM3D */

#endif /* TERM_BODY */

#ifdef TERM_TABLE

TERM_TABLE_START(ggi_driver)
    "ggi", "GGI target",
    GGI_XMAX, GGI_YMAX, GGI_VCHAR, GGI_HCHAR, GGI_VTIC, GGI_HTIC,
    GGI_options, GGI_init, GGI_reset, GGI_text,
    null_scale, GGI_graphics, GGI_move, GGI_vector,
    GGI_linetype, GGI_put_text,
    0, /* angle */
    0, /* justify text */
    0, /* point */
    0, /* arrow */
    0, /* set_font */
    0, /* set_pointsize */
    TERM_CAN_MULTIPLOT,
    GGI_suspend,
    GGI_resume,
    GGI_fillbox,
    0 /* linewidth */
#ifdef USE_MOUSE
    , GGI_waitforinput, GGI_put_tmptext, GGI_set_ruler, GGI_set_cursor, GGI_set_clipboard
#endif
#ifdef PM3D
    , GGI_make_palette,
    GGI_previous_palette,
    GGI_set_color,
#ifdef ENABLE_XMI
    GGI_filled_polygon
#else
    0 /* GGI_filled_polygon */
#endif
#endif
TERM_TABLE_END(ggi_driver)

#endif /* TERM_TABLE */
#endif /* TERM_PROTO_ONLY */

#ifdef TERM_HELP
START_HELP(ggi)
"1 ggi",
"?commands set terminal ggi",
"?set terminal ggi",
"?set term ggi",
"?terminal ggi",
"?term ggi",
"?ggi",
" The `ggi` driver can run on different targets as X or svgalib.",
"",
" Syntax:",
"    set terminal ggi [acceleration <integer>] [[mode] {mode}]",
"",
" In X the window cannot be resized using window manager handles, but the",
" mode can be given with the mode option, e.g.:",
"  - V1024x768",
"  - V800x600",
"  - V640x480",
"  - V320x200",
" Please refer to the ggi documentation for other modes. The 'mode' keyword",
" is optional. It is recommended to select the target by environment variables",
" as explained in the libggi manual page. To get DGA on X, you should for",
" example",
"    bash> export GGI_DISPLAY=DGA",
"    csh>  setenv GGI_DISPLAY DGA",
"",
" 'acceleration' is only used for targets which report relative pointer",
" motion events (e.g. DGA) and is a strictly positive integer multiplication",
" factor for the relative distances.  The default for acceleration is 7.",
"",
" Examples:",
"    set term ggi acc 10",
"    set term ggi acc 1 mode V1024x768",
"    set term ggi V1024x768"
END_HELP(ggi)
#endif



( run in 0.571 second using v1.01-cache-2.11-cpan-2398b32b56e )