Mon Oct 11 16:48:22 PDT 1999 Michael Jennings <mej@eterm.org>

More useless, hackish, and/or poorly-written code meets an untimely
	end.


SVN revision: 799
This commit is contained in:
Michael Jennings 1999-10-11 19:29:45 +00:00
parent 332269133d
commit 8e252e121d
23 changed files with 21 additions and 5271 deletions

View File

@ -2570,3 +2570,9 @@ Mon Oct 11 15:54:52 PDT 1999 Michael Jennings <mej@eterm.org>
SVR4-style pty's (/dev/pts/*) under Linux.
-------------------------------------------------------------------------------
Mon Oct 11 16:48:22 PDT 1999 Michael Jennings <mej@eterm.org>
More useless, hackish, and/or poorly-written code meets an untimely
end.
-------------------------------------------------------------------------------

View File

@ -523,7 +523,6 @@ utils/Makefile \
libmej/Makefile \
pix/Makefile \
src/Makefile \
src/graphics/Makefile \
themes/Makefile \
Eterm.spec \
)

View File

@ -1,3 +0,0 @@
Well, now that we have a new CVS server, I've kinda done a little
restructuring. There may still be things that are screwy, so please
let me know (mej@eterm.org) if you have problems.

View File

@ -2,7 +2,7 @@
lib_LTLIBRARIES = libEterm.la
libEterm_la_SOURCES = actions.c command.c e.c events.c font.c graphics.c grkelot.c menus.c misc.c netdisp.c \
libEterm_la_SOURCES = actions.c command.c e.c events.c font.c grkelot.c menus.c misc.c netdisp.c \
options.c pixmap.c screen.c scrollbar.c startup.c system.c term.c timer.c utmp.c windows.c
libEterm_la_DEPENDENCIES = $(top_builddir)/libmej/libmej.la feature.h
libEterm_la_LDFLAGS = -version-info 9:0:9
@ -15,6 +15,5 @@ Eterm_LDFLAGS = -rpath $(libdir):$(pkglibdir)
INCLUDES = -I. -I$(top_srcdir) -I$(top_srcdir)/libmej -I.. -I$(includedir) -I$(prefix)/include $(X_CFLAGS)
LDADD = libEterm.la $(top_builddir)/libmej/libmej.la -L$(libdir) -L$(prefix)/lib $(LIBS) $(GRLIBS) $(X_LIBS)
EXTRA_DIST = actions.h command.h debug.h e.h eterm_utmp.h events.h feature.h font.h graphics.h grkelot.h grx.h menus.h misc.h options.h \
pixmap.h profile.h screen.h scrollbar.h startup.h system.h term.h timer.h windows.h graphics/Makefile.am \
graphics/Makefile.in graphics/README graphics/data graphics/grxlib.c graphics/grxlib.h graphics/qplot.c Eterm.xpm
EXTRA_DIST = actions.h command.h debug.h e.h eterm_utmp.h events.h feature.h font.h grkelot.h grx.h menus.h misc.h options.h \
pixmap.h profile.h screen.h scrollbar.h startup.h system.h term.h timer.h windows.h Eterm.xpm

View File

@ -44,7 +44,6 @@ static const char cvs_ident[] = "$Id$";
#include "command.h"
#include "e.h"
#include "events.h"
#include "graphics.h"
#include "menus.h"
#include "options.h"
#include "pixmap.h"

View File

@ -122,7 +122,6 @@ static const char cvs_ident[] = "$Id$";
#include "../libmej/strings.h"
#include "events.h"
#include "font.h"
#include "graphics.h"
#include "grkelot.h"
#include "options.h"
#include "pixmap.h"

View File

@ -44,7 +44,6 @@ static const char cvs_ident[] = "$Id$";
#include "command.h"
#include "e.h"
#include "events.h"
#include "graphics.h"
#include "menus.h"
#include "options.h"
#include "pixmap.h"
@ -474,7 +473,6 @@ handle_expose(event_t * ev)
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, Expose, &unused_xevent));
while (XCheckTypedWindowEvent(Xdisplay, ev->xany.window, GraphicsExpose, &unused_xevent));
Gr_expose(ev->xany.window);
}
if (desktop_window != None) {
XSelectInput(Xdisplay, desktop_window, PropertyChangeMask);
@ -503,9 +501,7 @@ handle_button_press(event_t * ev)
button_state.report_mode = (button_state.bypass_keystate ? 0 : ((PrivateModes & PrivMode_mouse_report) ? 1 : 0));
if (ev->xany.window == TermWin.vt) {
if (ev->xbutton.subwindow != None) {
Gr_ButtonPress(ev->xbutton.x, ev->xbutton.y);
} else {
if (ev->xbutton.subwindow == None) {
if (button_state.report_mode) {
if (PrivateModes & PrivMode_MouseX10) {
/* no state info allowed */
@ -567,9 +563,7 @@ handle_button_release(event_t * ev)
button_state.report_mode = (button_state.bypass_keystate ? 0 : ((PrivateModes & PrivMode_mouse_report) ? 1 : 0));
if (ev->xany.window == TermWin.vt) {
if (ev->xbutton.subwindow != None)
Gr_ButtonRelease(ev->xbutton.x, ev->xbutton.y);
else {
if (ev->xbutton.subwindow == None) {
if (button_state.report_mode) {
switch (PrivateModes & PrivMode_mouse_report) {
case PrivMode_MouseX10:

View File

@ -108,9 +108,6 @@
* problems some people have had. See also NO_BOLDOVERSTRIKE. */
# define FORCE_CLEAR_CHARS
/* Rob Nation's graphics escape sequences */
/* #define RXVT_GRAPHICS */
/* The command through which to pipe print-screen requests */
#define PRINTPIPE "lp"

View File

@ -1,553 +0,0 @@
/*--------------------------------*-C-*---------------------------------*
* File: graphics.c
*
* This module is all new by Rob Nation
* <nation@rocket.sanders.lockheed.com>
*
* Modifications by mj olesen <olesen@me.QueensU.CA>
* and Raul Garcia Garcia <rgg@tid.es>
*----------------------------------------------------------------------*/
static const char cvs_ident[] = "$Id$";
#include "config.h"
#include "feature.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <X11/cursorfont.h>
#include "command.h" /* for tt_printf() */
#include "debug.h"
#include "graphics.h"
#include "startup.h"
#include "screen.h"
/* commands:
* 'C' = Clear
* 'F' = Fill
* 'G' = Geometry
* 'L' = Line
* 'P' = Points
* 'T' = Text
* 'W' = Window
*/
#ifndef GRX_SCALE
# define GRX_SCALE 10000
#endif
/* extern functions referenced */
/* extern variables referenced */
/* extern variables declared here */
#ifdef RXVT_GRAPHICS
/* local variables */
static int graphics_up = 0;
typedef struct grcmd_t {
char cmd;
short color;
short ncoords;
int *coords;
unsigned char *text;
struct grcmd_t *next;
} grcmd_t;
typedef struct grwin_t {
Window win;
int x, y;
unsigned int w, h;
short screen;
grcmd_t *graphics;
struct grwin_t *prev, *next;
} grwin_t;
static grwin_t *gr_root = NULL;
/*----------------------------------------------------------------------*
* local functions
*/
/* Gr_NewWindow() */
static void
Gr_NewWindow(int nargs, int args[])
{
int x, y;
unsigned int w, h;
Window win;
grwin_t *grwin;
Cursor cursor;
if (nargs != 4) {
print_error("NewWindow: 4 args needed, got %d\n", nargs);
return;
}
x = args[0] * TermWin.width / GRX_SCALE + TermWin.internalBorder;
y = args[1] * TermWin.height / GRX_SCALE + TermWin.internalBorder;
w = args[2] * TermWin.width / GRX_SCALE;
h = args[3] * TermWin.height / GRX_SCALE;
win = XCreateSimpleWindow(Xdisplay, TermWin.vt,
x, y, w, h,
0,
PixColors[fgColor],
PixColors[bgColor]);
cursor = XCreateFontCursor(Xdisplay, XC_crosshair);
XDefineCursor(Xdisplay, win, cursor);
XMapWindow(Xdisplay, win);
XSelectInput(Xdisplay, win, ExposureMask);
grwin = (grwin_t *) MALLOC(sizeof(grwin_t));
grwin->win = win;
grwin->x = x;
grwin->y = y;
grwin->w = w;
grwin->h = h;
grwin->screen = 0;
grwin->prev = NULL;
grwin->next = gr_root;
if (grwin->next)
grwin->next->prev = grwin;
gr_root = grwin;
grwin->graphics = NULL;
graphics_up++;
tt_printf("\033W%ld\n", (long) grwin->win);
}
/* Gr_ClearWindow() */
static void
Gr_ClearWindow(grwin_t * grwin)
{
grcmd_t *cmd, *next;
for (cmd = grwin->graphics; cmd != NULL; cmd = next) {
next = cmd->next;
free(cmd->coords);
if (cmd->text != NULL)
free(cmd->text);
free(cmd);
}
grwin->graphics = NULL;
XClearWindow(Xdisplay, grwin->win);
}
/* Gr_Text() */
/*
* arg [0] = x
* arg [1] = y
* arg [2] = alignment
* arg [3] = strlen (text)
*/
static void
Gr_Text(grwin_t * grwin, grcmd_t * data)
{
int x, y, align;
if (data->ncoords < 4 || data->text == NULL || *(data->text) == '\0')
return;
x = data->coords[0] * grwin->w / GRX_SCALE;
y = data->coords[1] * grwin->h / GRX_SCALE;
align = data->coords[2];
if (align & RIGHT_TEXT)
x -= XTextWidth(TermWin.font, data->text, data->coords[3]);
else if (align & HCENTER_TEXT)
x -= (XTextWidth(TermWin.font, data->text, data->coords[3]) >> 1);
if (align & TOP_TEXT)
y += TermWin.font->ascent;
else if (align & BOTTOM_TEXT)
y -= TermWin.font->descent;
if (align & VCENTER_TEXT)
y -= TermWin.font->descent + ((TermWin.font->ascent + TermWin.font->descent) >> 1);
if (align & VCAPS_CENTER_TEXT)
y += (TermWin.font->ascent >> 1);
# ifdef PIXMAP_SUPPORT
XClearArea(Xdisplay, grwin->win,
x, y,
Width2Pixel(data->coords[3]),
Height2Pixel(1),
0);
# endif
XDrawString(Xdisplay, grwin->win, TermWin.gc,
x, y,
data->text, data->coords[3]);
}
/* Gr_Geometry() */
static void
Gr_Geometry(grwin_t * grwin, grcmd_t * data)
{
if (grwin)
tt_printf("\033G%ld %d %d %u %u %d %d %ld %ld %d\n",
(long) grwin->win,
grwin->x, grwin->y, grwin->w, grwin->h,
TermWin.fwidth,
TermWin.fheight,
(long) GRX_SCALE * TermWin.fwidth / grwin->w,
(long) GRX_SCALE * TermWin.fheight / grwin->h,
Xdepth);
else /* rxvt terminal window size */
tt_printf("\033G0 0 0 %d %d %d %d %ld %ld %d\n",
TermWin.width - 2 * TermWin.internalBorder,
TermWin.height - 2 * TermWin.internalBorder,
TermWin.fwidth,
TermWin.fheight,
(long) GRX_SCALE * TermWin.fwidth / (TermWin.width - 2 * TermWin.internalBorder),
(long) GRX_SCALE * TermWin.fheight / (TermWin.height - 2 * TermWin.internalBorder),
Xdepth);
}
/* Gr_DestroyWindow() */
static void
Gr_DestroyWindow(grwin_t * grwin)
{
grcmd_t *cmd, *next;
if (grwin == NULL)
return;
for (cmd = grwin->graphics; cmd; cmd = next) {
next = cmd->next;
free(cmd->coords);
if (cmd->text != NULL)
free(cmd->text);
free(cmd);
}
XDestroyWindow(Xdisplay, grwin->win);
if (grwin->next != NULL)
grwin->next->prev = grwin->prev;
if (grwin->prev != NULL)
grwin->prev->next = grwin->next;
else
gr_root = grwin->next;
free(grwin);
graphics_up--;
}
/* Gr_Dispatch() */
static void
Gr_Dispatch(grwin_t * grwin, grcmd_t * data)
{
int i, n;
union {
XPoint pt[NGRX_PTS / 2];
XRectangle rect[NGRX_PTS / 4];
} xdata;
if (data->color != fgColor) {
XGCValues gcv;
gcv.foreground = PixColors[data->color];
XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcv);
}
if (grwin)
switch (data->cmd) {
case 'L':
if (data->ncoords > 3) {
for (n = i = 0; i < data->ncoords; i += 2, n++) {
xdata.pt[n].x = data->coords[i] * grwin->w / GRX_SCALE;
xdata.pt[n].y = data->coords[i + 1] * grwin->h / GRX_SCALE;
}
XDrawLines(Xdisplay,
grwin->win, TermWin.gc, xdata.pt, n, CoordModeOrigin);
}
break;
case 'P':
if (data->ncoords > 3) {
for (n = i = 0; i < data->ncoords; i += 2, n++) {
xdata.pt[n].x = data->coords[i] * grwin->w / GRX_SCALE;
xdata.pt[n].y = data->coords[i + 1] * grwin->h / GRX_SCALE;
}
XDrawPoints(Xdisplay,
grwin->win, TermWin.gc, xdata.pt, n, CoordModeOrigin);
}
break;
case 'F':
if (data->ncoords > 0) {
for (n = i = 0; i < data->ncoords; i += 4, n++) {
xdata.rect[n].x = data->coords[i] * grwin->w / GRX_SCALE;
xdata.rect[n].y = data->coords[i + 1] * grwin->h / GRX_SCALE;
xdata.rect[n].width = ((data->coords[i + 2]
- data->coords[i] + 1) *
grwin->w / GRX_SCALE);
xdata.rect[n].height = ((data->coords[i + 3]
- data->coords[i + 1] + 1) *
grwin->h / GRX_SCALE);
# ifdef PIXMAP_SUPPORT
XClearArea(Xdisplay, grwin->win,
xdata.rect[n].x,
xdata.rect[n].y,
xdata.rect[n].width,
xdata.rect[n].height,
0);
# endif
}
XFillRectangles(Xdisplay, grwin->win, TermWin.gc, xdata.rect, n);
}
break;
case 'T':
Gr_Text(grwin, data);
break;
case 'C':
Gr_ClearWindow(grwin);
break;
}
if (data->color != fgColor) {
XGCValues gcv;
gcv.foreground = PixColors[fgColor];
XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcv);
}
}
/* Gr_Redraw() */
static void
Gr_Redraw(grwin_t * grwin)
{
grcmd_t *cmd;
for (cmd = grwin->graphics; cmd != NULL; cmd = cmd->next)
Gr_Dispatch(grwin, cmd);
}
#endif
/*----------------------------------------------------------------------*
* end of static functions
*/
#ifdef RXVT_GRAPHICS
void
Gr_ButtonReport(int but, int x, int y)
{
grwin_t *grwin;
for (grwin = gr_root; grwin != NULL; grwin = grwin->next)
if ((x > grwin->x) &&
(y > grwin->y) &&
(x < grwin->x + grwin->w) &&
(y < grwin->y + grwin->h))
break;
if (grwin == NULL)
return;
x = GRX_SCALE * (x - grwin->x) / grwin->w;
y = GRX_SCALE * (y - grwin->y) / grwin->h;
tt_printf("\033%c%ld;%d;%d;\n", but, (long) grwin->win, x, y);
}
/* Gr_do_graphics() */
void
Gr_do_graphics(int cmd, int nargs, int args[], unsigned char *text)
{
static Window last_id = None;
long win_id;
grwin_t *grwin;
grcmd_t *newcmd, *oldcmd;
int i;
if (cmd == 'W') {
Gr_NewWindow(nargs, args);
return;
}
win_id = (nargs > 0) ? (Window) args[0] : None;
if ((cmd == 'G') && (win_id == None)) {
Gr_Geometry(NULL, NULL);
return;
}
if ((win_id == None) && (last_id != None))
win_id = last_id;
if (win_id == None)
return;
grwin = gr_root;
while ((grwin != NULL) && (grwin->win != win_id))
grwin = grwin->next;
if (grwin == NULL)
return;
if (cmd == 'G') {
Gr_Geometry(grwin, NULL);
return;
}
nargs--;
args++; /* skip over window id */
/* record this new command */
newcmd = (grcmd_t *) MALLOC(sizeof(grcmd_t));
newcmd->ncoords = nargs;
newcmd->coords = (int *) MALLOC((newcmd->ncoords * sizeof(int)));
newcmd->next = NULL;
newcmd->cmd = cmd;
newcmd->color = scr_get_fgcolor();
newcmd->text = text;
for (i = 0; i < newcmd->ncoords; i++)
newcmd->coords[i] = args[i];
/*
* If newcmd == fill, and rectangle is full window, drop all prior
* commands.
*/
if ((newcmd->cmd == 'F') && (grwin) && (grwin->graphics)) {
for (i = 0; i < newcmd->ncoords; i += 4) {
if ((newcmd->coords[i] == 0) &&
(newcmd->coords[i + 1] == 0) &&
(newcmd->coords[i + 2] == GRX_SCALE) &&
(newcmd->coords[i + 3] == GRX_SCALE)) {
/* drop previous commands */
oldcmd = grwin->graphics;
while (oldcmd->next != NULL) {
grcmd_t *tmp = oldcmd;
oldcmd = oldcmd->next;
free(tmp);
}
grwin->graphics = NULL;
}
}
}
/* insert new command into command list */
oldcmd = grwin->graphics;
if (oldcmd == NULL)
grwin->graphics = newcmd;
else {
while (oldcmd->next != NULL)
oldcmd = oldcmd->next;
oldcmd->next = newcmd;
}
Gr_Dispatch(grwin, newcmd);
}
/* Gr_scroll() */
void
Gr_scroll(int count)
{
static short prev_start = 0;
grwin_t *grwin, *next;
if ((count == 0) && (prev_start == TermWin.view_start))
return;
prev_start = TermWin.view_start;
for (grwin = gr_root; grwin != NULL; grwin = next) {
next = grwin->next;
grwin->y -= (count * TermWin.fheight);
if ((grwin->y + grwin->h) < -(TermWin.saveLines * TermWin.fheight))
Gr_DestroyWindow(grwin);
else
XMoveWindow(Xdisplay, grwin->win,
grwin->x,
grwin->y + (TermWin.view_start * TermWin.fheight));
}
}
/* Gr_ClearScreen() */
void
Gr_ClearScreen(void)
{
grwin_t *grwin, *next;
for (grwin = gr_root; grwin != NULL; grwin = next) {
next = grwin->next;
if ((grwin->screen == 0) && (grwin->y + grwin->h > 0)) {
if (grwin->y >= 0)
Gr_DestroyWindow(grwin);
else
XResizeWindow(Xdisplay, grwin->win,
grwin->w, -grwin->y);
}
}
}
/* Gr_ChangeScreen() */
void
Gr_ChangeScreen(void)
{
grwin_t *grwin, *next;
for (grwin = gr_root; grwin != NULL; grwin = next) {
next = grwin->next;
if (grwin->y + grwin->h > 0) {
if (grwin->screen == 1) {
XMapWindow(Xdisplay, grwin->win);
grwin->screen = 0;
} else {
XUnmapWindow(Xdisplay, grwin->win);
grwin->screen = 1;
}
}
}
}
/* Gr_expose() */
void
Gr_expose(Window win)
{
grwin_t *grwin;
for (grwin = gr_root; grwin != NULL; grwin = grwin->next) {
if (grwin->win == win) {
Gr_Redraw(grwin);
break;
}
}
}
/* Gr_Resize() */
void
Gr_Resize(int w, int h)
{
grwin_t *grwin;
for (grwin = gr_root; grwin != NULL; grwin = grwin->next) {
if (TermWin.height != h) {
grwin->y += (TermWin.height - h);
XMoveWindow(Xdisplay, grwin->win,
grwin->x,
grwin->y + (TermWin.view_start * TermWin.fheight));
}
Gr_Redraw(grwin);
}
}
/* Gr_reset() */
void
Gr_reset(void)
{
grwin_t *grwin, *next;
for (grwin = gr_root; grwin != NULL; grwin = next) {
next = grwin->next;
Gr_DestroyWindow(grwin);
}
graphics_up = 0;
}
/* Gr_Displayed() */
int
Gr_Displayed(void)
{
return graphics_up;
}
#endif /* RXVT_GRAPHICS */
/*----------------------- end-of-file (C source) -----------------------*/

View File

@ -1,63 +0,0 @@
/*--------------------------------*-C-*---------------------------------*
* File: graphics.h
*
*----------------------------------------------------------------------*/
#ifndef _GRAPHICS_H_
# define _GRAPHICS_H_
# include <X11/Xfuncproto.h>
# include "grx.h" /* text alignment */
/*
* number of graphics points
* divisible by 2 (num lines)
* divisible by 4 (num rect)
*/
# define NGRX_PTS 1000
_XFUNCPROTOBEGIN
extern void Gr_ButtonReport(int, int, int);
extern void Gr_do_graphics (int /* cmd */,
int /* nargs */,
int /* args */[],
unsigned char * /* text */);
extern void Gr_scroll (int /* count */);
extern void Gr_ClearScreen (void);
extern void Gr_ChangeScreen (void);
extern void Gr_expose (Window /* win */);
extern void Gr_Resize (int /* w */,
int /* h */);
extern void Gr_reset (void);
extern int Gr_Displayed (void);
_XFUNCPROTOEND
# ifdef RXVT_GRAPHICS
# define Gr_ButtonPress(x,y) Gr_ButtonReport ('P',(x),(y))
# define Gr_ButtonRelease(x,y) Gr_ButtonReport ('R',(x),(y))
# define GR_DISPLAY(x) if (Gr_Displayed()) (x)
# define GR_NO_DISPLAY(x) if (!Gr_Displayed()) (x)
# else
# define Gr_ButtonPress(x,y) ((void)0)
# define Gr_ButtonRelease(x,y) ((void)0)
# define Gr_scroll(count) ((void)0)
# define Gr_ClearScreen() ((void)0)
# define Gr_ChangeScreen() ((void)0)
# define Gr_expose(win) ((void)0)
# define Gr_Resize(w,h) ((void)0)
# define Gr_reset() ((void)0)
# define GR_DISPLAY(x)
# define GR_NO_DISPLAY(x) (x)
# endif
#endif /* whole file */
/*----------------------- end-of-file (C header) -----------------------*/

View File

@ -1,2 +0,0 @@
Makefile
Makefile.in

View File

@ -1,11 +0,0 @@
# $Id$
bin_PROGRAMS = qplot
qplot_SOURCES = grxlib.c qplot.c
INCLUDES = -I. -I.. -I$(includedir) -I$(prefix)/include
LDADD = -L. -L.. -L$(libdir) -L$(prefix)/lib
install-exec-hook:

View File

@ -1 +0,0 @@
This is an example of rxvt graphics.

File diff suppressed because it is too large Load Diff

View File

@ -1,169 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>
static const char cvs_ident[] = "$Id$";
#ifdef _AIX
# include <termio.h>
#else
# include <termios.h>
#endif
#include "grxlib.h"
/*----------------------------------------------------------------------*/
void Done (void) { putchar (':'); }
void StartLine (long id) { printf ("\033GL%ld", id); }
void StartPoint (long id) { printf ("\033GP%ld", id); }
void StartFill (long id) { printf ("\033GF%ld", id); }
void Extend (int x, int y) { printf (";%d;%d", x, y); }
void FillArea (int x1, int y1, int x2, int y2)
{
printf (";%d;%d;%d;%d", x1, y1, x2, y2);
}
void PlaceText (long id, int x, int y, int mode, char *text)
{
printf ("\033GT%ld;%d;%d;%d;%d:%s", id, x, y, mode, strlen(text), text);
fflush (stdout);
}
void ClearWindow (long id) { printf ("\033GC%ld:", id); }
void ForeColor (int col) { printf ("\033[3%dm", (col<0||col>7)?0:col); }
void DefaultRendition (void) { printf ("\033[m"); }
#define LINESZ 100
static char line [LINESZ];
static FILE *infd = NULL;
long
CreateWin (int x, int y, int w, int h)
{
long id = 0;
fflush (stdout);
printf ("\033GW%d;%d;%d;%d:", x, y, w, h);
fflush (stdout);
while (1)
{
if ((fgets (line, LINESZ, infd) != NULL) &&
(sscanf (line,"\033W%ld", &id) == 1))
break;
}
return id;
}
void
QueryWin (long id, int *nfwidth, int *nfheight)
{
int id1, x, y, width, height, fwidth, fheight;
printf ("\033GG%ld:",id);
fflush (stdout);
while (1)
{
if ((fgets (line, sizeof(line), infd) != NULL) &&
(sscanf (line,"\033G%ld %ld %ld %ld %ld %ld %ld %ld %ld",
&id1, &x, &y, &width, &height,
&fwidth, &fheight, nfwidth, nfheight) != 0))
break;
}
}
int
WaitForCarriageReturn (long *win, int *x, int *y)
{
int i, len;
fgets (line, LINESZ, infd);
line [LINESZ-1] = 0;
len = strlen (line);
for (i = 0; i < len; i++)
{
if (line [i] == '\033')
{
int ret = 1;
i++;
switch (line[i]) {
case 'R': ret++;
/* drop */
case 'P':
sscanf (&line[i+1],"%ld;%d;%d", win, x, y);
return ret;
break;
}
}
}
return 0;
}
static int fno2;
static struct termios ttmode;
int
InitializeGraphics (int scroll_text_up)
{
int fno, i;
char *screen_tty;
struct winsize winsize;
fno = fileno (stdout);
if (!isatty (fno))
{
fprintf (stderr, "stdout must be a tty\n");
return 0;
}
screen_tty = ttyname (fno);
ioctl (fno, TCGETS, (char *)&ttmode);
ttmode.c_lflag &= ~ECHO;
ioctl (fno, TCSETS, (char *)&ttmode);
infd = fopen (screen_tty, "rw");
fno2 = fileno (infd);
ioctl (fno2, TCGETS, (char *)&ttmode);
ttmode.c_lflag &= ~ECHO;
ioctl (fno2, TCSETS, (char *)&ttmode);
/* query rxvt to find if graphics are available */
fflush (stdout);
printf ("\033GQ");
fflush (stdout);
while (1)
{
if ((fgets (line, LINESZ, infd) != NULL) &&
(sscanf (line,"\033G%d", &i) == 1))
{
if (!i)
{
fprintf (stderr, "rxvt graphics not available\n");
CloseGraphics ();
return 0;
}
break;
}
}
if (scroll_text_up)
{
ioctl (fno, TIOCGWINSZ, &winsize);
fflush (stdout);
for (i = 0; i < winsize.ws_row; i++)
putchar ('\n');
fflush (stdout);
}
return i;
}
void
CloseGraphics (void)
{
DefaultRendition ();
fflush (stdout);
ttmode.c_lflag |= ECHO;
ioctl (fno2, TCSETS, (char *)&ttmode);
fclose (infd);
}
/*----------------------- end-of-file (C source) -----------------------*/

View File

@ -1,28 +0,0 @@
#include "../grx.h" /* text alignment */
/*function pointer to either StartLine or StartPoint */
typedef void (*LineFunction) (long id);
#ifdef __cplusplus
extern "C" {
#endif
extern void StartLine (long id);
extern void StartPoint (long id);
extern void Extend (int x, int y);
extern void StartFill (long id);
extern void FillArea (int x1, int y1, int x2, int y2);
extern void Done (void);
extern void PlaceText (long id, int x, int y, int mode, char *text);
extern void ClearWindow (long id);
extern long CreateWin (int x, int y, int w, int h);
extern void QueryWin (long id, int *nfwidth, int *nfheight);
extern void ForeColor (int color);
extern void DefaultRendition (void);
extern int WaitForCarriageReturn (long *win, int *x, int *y);
extern int InitializeGraphics (int scroll_text_up);
extern void CloseGraphics (void);
#ifdef __cplusplus
}
#endif
/*----------------------- end-of-file (C header) -----------------------*/

View File

@ -1,257 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <signal.h>
#include "grxlib.h"
static const char cvs_ident[] = "$Id$";
#define Real float
#ifndef GRX_SCALE
# define GRX_SCALE 10000
#endif
#define DEFAULT_DATA_FILE "data"
static void
axis_round (Real *min, Real *max, Real *grid_spacing)
{
int logspace;
logspace = (int)(log10 ((*max - *min)/10.0) + 0.5);
*grid_spacing = pow (10, (double)logspace);
*min = (Real)((int)(*min / (*grid_spacing))) * (*grid_spacing);
*max = (Real)((int)(*max / (*grid_spacing))+1) * (*grid_spacing);
}
static int
nice_end (int junk)
{
CloseGraphics ();
putchar ('\n');
exit (EXIT_SUCCESS);
return 0;
}
int
main (int argc, char **argv)
{
char line[256], *file = NULL;
long id,winclick;
int Do_Start = 1,tmp;
Real x[1000000], y[1000000];
Real nls[1000];
int m, p, i, j, n, nchars, theight, twidth, xclick, yclick;
int downx = 1000,downy = 1000,upx,upy;
Real xmax, xmin, ymax, ymin, xdiff, ydiff, xgrid_spacing, ygrid_spacing;
FILE *fd;
char axis[100];
LineFunction linetype = StartLine;
ymax = xmax = -HUGE_VAL;
ymin = xmin = HUGE_VAL;
for (i = 1; i < argc; i++)
{
if (*argv[i] == '-')
{
if (!strcmp (argv[i], "-nl"))
linetype = StartPoint;
else if (argv[i][1] == '\0') /* use stdin */
file = argv [i];
else
{
fprintf(stderr,
"Usage:\n\t %s [options] [file]\n\n", argv[0]);
fprintf(stderr,
"where options include:\n"
" -pt plot with points instead of lines\n\n");
fprintf(stderr,
"file name `-' specifies stdin\n"
"if no file name is specified, "
"the default is \"%s\"\n\n",
DEFAULT_DATA_FILE);
return EXIT_FAILURE;
}
}
else
{
file = argv [i];
}
}
if (!strcmp (file, "-"))
{
fd = stdin;
file = "stdin";
}
else
{
if (file == NULL) file = DEFAULT_DATA_FILE;
if ((fd = fopen (file, "r")) == NULL)
{
fprintf (stderr, "%s: can't open file \"%s\"\n", argv[0], file);
return EXIT_FAILURE;
}
}
m = 0;
p = 0;
while (fgets(line, sizeof(line),fd) != NULL)
{
if (sscanf(line,"%f %f",&x[m], &y[m]) == 2)
{
if (x[m] > xmax) xmax = x[m]; else if (x[m] < xmin) xmin = x[m];
if (y[m] > ymax) ymax = y[m]; else if (y[m] < ymin) ymin = y[m];
m++;
}
else
{
nls [p] = m;
p++;
}
}
nls [p++] = m;
if (m == 0)
return;
signal (SIGTERM, nice_end);
signal (SIGSTOP, nice_end);
signal (SIGTSTP, nice_end);
signal (SIGINT, nice_end);
signal (SIGQUIT, nice_end);
if (!InitializeGraphics (1))
return EXIT_FAILURE;
n = 1;
do
{
axis_round (&xmin, &xmax, &xgrid_spacing);
axis_round (&ymin, &ymax, &ygrid_spacing);
id = CreateWin (0, 0, GRX_SCALE, GRX_SCALE);
if (id == 0)
{
fprintf (stderr,"Help id = 0\n");
return EXIT_FAILURE;
}
/* Fill the window in black for real eye-catching graphics! */
ForeColor (0);
StartFill (id);
FillArea (0, 0, GRX_SCALE, GRX_SCALE);
Done ();
/* draw outline box in white */
ForeColor (7);
/* Draw outline box */
StartLine(id);
Extend (1000, 1000);
Extend (1000, 9000);
Extend (9000, 9000);
Extend (9000, 1000);
Extend (1000, 1000);
Done();
/* Draw the data - either lines or dots */
xdiff = 8000 / (xmax-xmin);
ydiff = 8000 / (ymax-ymin);
for (i = j = 0; j < p; j++)
{
int n = 0;
ForeColor (j%6+1);
while (((x[i] < xmin) || (x[i] > xmax) ||
(y[i] < ymin) || (y[i] > ymax)) && (i < nls [j]))
i++;
while (i < nls [j])
{
if (n == 0)
linetype (id);
Extend (1000+(x[i]-xmin)*xdiff,9000-(y[i]-ymin)*ydiff);
n++;
if (n > 450)
{
Done ();
n = 0;
continue;
}
i++;
while ((i < nls [j]) &&
((x [i] < xmin) || (x [i] > xmax) ||
(y [i] < ymin) || (y [i] > ymax)))
i++;
}
if (n > 0)
Done ();
}
/* Do axis labels in black */
ForeColor (7);
QueryWin (id, &twidth,&theight);
PlaceText (id, GRX_SCALE/2, 0, HCENTER_TEXT|TOP_TEXT, file);
PlaceText (id, GRX_SCALE/2, GRX_SCALE, HCENTER_TEXT|BOTTOM_TEXT, "X");
PlaceText (id, 0, GRX_SCALE/2, LEFT_TEXT|VCENTER_TEXT, "Y");
sprintf (axis, "%f", ymax);
nchars = 1000 / twidth;
axis [nchars] = 0;
PlaceText (id, GRX_SCALE/10, GRX_SCALE/10,
RIGHT_TEXT|TOP_TEXT, axis);
sprintf (axis, "%f", ymin);
axis [nchars] = 0;
PlaceText (id, GRX_SCALE/10, 9*GRX_SCALE/10,
RIGHT_TEXT|BOTTOM_TEXT,axis);
sprintf (axis, "%f",xmax);
PlaceText (id, 9*GRX_SCALE/10, 9*GRX_SCALE/10,
HCENTER_TEXT|TOP_TEXT,axis);
sprintf (axis,"%f",xmin);
PlaceText (id, GRX_SCALE/10, 9*GRX_SCALE/10,
HCENTER_TEXT|TOP_TEXT,axis);
fflush (stdout);
do
{
n = WaitForCarriageReturn (&winclick, &xclick, &yclick);
switch (n) {
case 1:
downx = xclick;
downy = yclick;
break;
case 2:
upx = xclick;
upy = yclick;
if (upx < downx)
{
tmp = downx;
downx = upx;
upx = tmp;
}
if (upy < downy)
{
tmp = downy;
downy = upy;
upy = tmp;
}
xmin = (xmax - xmin) * (downx - 1000) / (8000) + xmin;
xmax = (xmax - xmin) * (upx - 1000) / (8000) + xmin;
ymax = ymax - (ymax - ymin) * (downy - 1000) / (8000);
ymin = ymax - (ymax - ymin) * (upy - 1000) / (8000);
break;
}
}
while (n && (n != 2));
}
while (n);
nice_end (EXIT_SUCCESS);
return EXIT_SUCCESS;
}
/*----------------------- end-of-file (C source) -----------------------*/

View File

@ -1,53 +0,0 @@
/*--------------------------------*-C-*---------------------------------*
* File: grx.h
*
* Stuff for text alignment for special graphics mode
*
* alignment
* Top:
* text is placed so that the specified point is at the top of the
* capital letters
* Center:
* text is placed so that the specified point is equidistant from the
* bottom of descenders and the top of the capital letters
* Botton:
* text is placed so that the bottom of descenders is on the specified
* point
* Base:
* text is placed so that the bottom of the characters with no descenders
* is on the specified point
* Caps_Center:
* text is placed so that the specified point is equidistant from the
* bottom and tops of capital letters
*----------------------------------------------------------------------*/
#ifndef _RXVTGRX_H
# define _RXVTGRX_H
# define GRX_SCALE 10000
# define RIGHT_TEXT 0x10
# define HCENTER_TEXT 0x20
# define LEFT_TEXT 0x30
# define HORIZONTAL_ALIGNMENT 0x70
# define TOP_TEXT 0x01
# define VCENTER_TEXT 0x02
# define BOTTOM_TEXT 0x03
# define BASE_TEXT 0x04
# define VCAPS_CENTER_TEXT 0x05
# define VERTICAL_ALIGNMENT 0x0F
# if 0 /* this would be nicer */
# define TXT_RIGHT 'r'
# define TXT_CENTER 'c'
# define TXT_LEFT 'l'
# define TXT_TOP 't'
# define TXT_VCENTER 'v'
# define TXT_BOTTOM 'b'
# define TXT_BASE '_'
# define TXT_VCAPS_CENTER 'C'
# endif
#endif /* whole file */
/*----------------------- end-of-file (C header) -----------------------*/

View File

@ -635,11 +635,6 @@ version(void)
#else
printf(" -FORCE_CLEAR_CHARS");
#endif
#ifdef RXVT_GRAPHICS
printf(" +RXVT_GRAPHICS");
#else
printf(" -RXVT_GRAPHICS");
#endif
#ifdef PREFER_24BIT
printf(" +PREFER_24BIT");
#else

View File

@ -27,7 +27,6 @@ static const char cvs_ident[] = "$Id$";
#include "debug.h"
#include "startup.h"
#include "mem.h"
#include "graphics.h"
#include "screen.h"
#include "scrollbar.h"
#include "options.h"
@ -410,7 +409,6 @@ scr_poweron(void)
scr_reset();
XClearWindow(Xdisplay, TermWin.vt);
scr_refresh(SLOW_REFRESH);
Gr_reset();
}
/* ------------------------------------------------------------------------- *
@ -482,19 +480,15 @@ scr_change_screen(int scrn)
screen.flags |= Screen_VisibleCursor;
swap.flags |= Screen_VisibleCursor;
GR_DISPLAY(Gr_scroll(0));
GR_DISPLAY(Gr_ChangeScreen());
#else
# ifndef DONT_SCROLL_ME
GR_DISPLAY(Gr_ClearScreen);
if (current_screen == PRIMARY)
if (current_screen == PRIMARY) {
GR_NO_DISPLAY(scroll_text(0, (TermWin.nrow - 1), TermWin.nrow, 0));
scroll_text(0, (TermWin.nrow - 1), TermWin.nrow, 0);
for (i = TermWin.saveLines; i < TermWin.nrow + TermWin.saveLines; i++)
if (screen.text[i] == NULL) {
make_screen_mem(screen.text, screen.rend, i);
blank_line(screen.text[i], screen.rend[i], TermWin.ncol,
DEFAULT_RSTYLE);
blank_line(screen.text[i], screen.rend[i], TermWin.ncol, DEFAULT_RSTYLE);
screen.text[i][TermWin.ncol] = 0;
}
}
@ -709,7 +703,6 @@ scroll_text(int row1, int row2, int count, int spec)
}
count = -count;
}
GR_DISPLAY(Gr_scroll(count));
#ifdef PROFILE_SCREEN
P_SETTIMEVAL(cnt.stop);
total_time += P_CMPTIMEVALS_USEC(cnt.start, cnt.stop);
@ -956,7 +949,6 @@ scr_gotorc(int row, int col, int relative)
ZERO_SCROLLBACK;
RESET_CHSTAT;
GR_DISPLAY(Gr_scroll(0));
screen.col = ((relative & C_RELATIVE) ? (screen.col + col) : col);
MAX_IT(screen.col, 0);
@ -1004,7 +996,6 @@ scr_index(int direction)
ZERO_SCROLLBACK;
RESET_CHSTAT;
GR_DISPLAY(Gr_scroll(0));
if (screen.flags & Screen_WrapNext) {
screen.flags &= ~Screen_WrapNext;
@ -1042,7 +1033,6 @@ scr_erase_line(int mode)
D_SCREEN(("scr_erase_line(%d) at screen row: %d\n", mode, screen.row));
ZERO_SCROLLBACK;
RESET_CHSTAT;
GR_DISPLAY(Gr_scroll(0));
if (screen.flags & Screen_WrapNext)
screen.flags &= ~Screen_WrapNext;
@ -1102,7 +1092,6 @@ scr_erase_screen(int mode)
num = screen.row;
break;
case 2: /* erase whole screen */
Gr_ClearScreen();
row = 0;
num = TermWin.nrow;
break;
@ -1175,7 +1164,6 @@ scr_insdel_lines(int count, int insdel)
ZERO_SCROLLBACK;
RESET_CHSTAT;
GR_DISPLAY(Gr_scroll(0));
if (screen.row > screen.bscroll)
return;
@ -1217,7 +1205,6 @@ scr_insdel_chars(int count, int insdel)
ZERO_SCROLLBACK;
RESET_CHSTAT;
GR_DISPLAY(Gr_scroll(0));
if (count <= 0)
return;
@ -1516,7 +1503,6 @@ big5dummy(unsigned char *str, int len)
}
#endif
/* ------------------------------------------------------------------------- */
void
set_multichar_encoding(const char *str)
{
@ -1537,34 +1523,7 @@ set_multichar_encoding(const char *str)
#endif /* MULTI_CHARSET */
}
/* ------------------------------------------------------------------------- *
* GRAPHICS COLORS *
* ------------------------------------------------------------------------- */
#ifdef RXVT_GRAPHICS
int
scr_get_fgcolor(void)
{
return GET_FGCOLOR(rstyle);
}
#endif
/* ------------------------------------------------------------------------- */
#ifdef RXVT_GRAPHICS
int
scr_get_bgcolor(void)
{
return GET_BGCOLOR(rstyle);
}
#endif
/* ------------------------------------------------------------------------- *
* MAJOR SCREEN MANIPULATION *
* ------------------------------------------------------------------------- */
/*
* Refresh an area
*/
/* Refresh an area */
void
scr_expose(int x, int y, int width, int height)
{
@ -1654,7 +1613,6 @@ scr_move_to(int y, int len)
MAX_IT(TermWin.view_start, 0);
MIN_IT(TermWin.view_start, TermWin.nscrolled);
GR_DISPLAY(Gr_scroll(0));
return (TermWin.view_start - start);
}
/* ------------------------------------------------------------------------- */
@ -1677,7 +1635,6 @@ scr_page(int direction, int nlines)
MAX_IT(TermWin.view_start, 0);
MIN_IT(TermWin.view_start, TermWin.nscrolled);
GR_DISPLAY(Gr_scroll(0));
return (TermWin.view_start - start);
}

View File

@ -52,7 +52,6 @@ static const char cvs_ident[] = "$Id$";
#include "command.h"
#include "eterm_utmp.h"
#include "events.h"
#include "graphics.h"
#include "options.h"
#include "pixmap.h"
#include "screen.h"
@ -205,7 +204,6 @@ eterm_bootstrap(int argc, char *argv[])
Create_Windows(argc, argv);
scr_reset(); /* initialize screen */
Gr_reset(); /* reset graphics */
/* add scrollBar, do it directly to avoid resize() */
scrollbar_mapping(Options & Opt_scrollBar);

View File

@ -752,7 +752,13 @@ process_escape_seq(void)
scr_add_lines("\n\r", 1, 2);
break;
case 'G':
process_graphics();
if ((ch = cmd_getc()) == 'Q') { /* query graphics */
tt_printf("\033G0\n"); /* no graphics */
} else {
do {
ch = cmd_getc();
} while (ch != ':');
}
break;
case 'H':
scr_set_tab(1);
@ -1430,64 +1436,6 @@ process_sgr_mode(unsigned int nargs, int arg[])
}
}
/* process Rob Nation's own graphics mode sequences */
void
process_graphics(void)
{
unsigned char ch, cmd = cmd_getc();
#ifndef RXVT_GRAPHICS
if (cmd == 'Q') { /* query graphics */
tt_printf("\033G0\n"); /* no graphics */
return;
}
/* swallow other graphics sequences until terminating ':' */
do
ch = cmd_getc();
while (ch != ':');
#else
int nargs;
int args[NGRX_PTS];
unsigned char *text = NULL;
if (cmd == 'Q') { /* query graphics */
tt_printf("\033G1\n"); /* yes, graphics (color) */
return;
}
for (nargs = 0; nargs < (sizeof(args) / sizeof(args[0])) - 1; /*nil */ ) {
int neg;
ch = cmd_getc();
neg = (ch == '-');
if (neg || ch == '+')
ch = cmd_getc();
for (args[nargs] = 0; isdigit(ch); ch = cmd_getc())
args[nargs] = args[nargs] * 10 + (ch - '0');
if (neg)
args[nargs] = -args[nargs];
nargs++;
args[nargs] = 0;
if (ch != ';')
break;
}
if ((cmd == 'T') && (nargs >= 5)) {
int i, len = args[4];
text = MALLOC((len + 1) * sizeof(char));
if (text != NULL) {
for (i = 0; i < len; i++)
text[i] = cmd_getc();
text[len] = '\0';
}
}
Gr_do_graphics(cmd, nargs, args, text);
#endif
}
/* color aliases, fg/bg bright-bold */
void
color_aliases(int idx)

View File

@ -178,7 +178,6 @@ extern void process_xterm_seq(void);
extern void process_window_mode(unsigned int, int []);
extern void process_terminal_mode(int, int, unsigned int, int []);
extern void process_sgr_mode(unsigned int, int []);
extern void process_graphics(void);
extern void color_aliases(int);
#ifndef NO_BRIGHTCOLOR
extern void set_colorfgbg(void);