1999-08-17 18:12:47 -07:00
|
|
|
/* main.h -- Eterm main program header file
|
1999-08-17 16:01:18 -07:00
|
|
|
*
|
1999-08-17 18:12:47 -07:00
|
|
|
* This file is original work by Michael Jennings <mej@eterm.org> and
|
|
|
|
* Tuomo Venalainen <vendu@cc.hut.fi>. This file, and any other file
|
|
|
|
* bearing this same message or a similar one, is distributed under
|
|
|
|
* the GNU Public License (GPL) as outlined in the COPYING file.
|
1999-08-17 16:01:18 -07:00
|
|
|
*
|
1999-08-17 18:12:47 -07:00
|
|
|
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
|
1999-08-17 16:01:18 -07:00
|
|
|
*
|
1999-08-17 18:12:47 -07:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*/
|
1999-08-17 16:01:18 -07:00
|
|
|
|
|
|
|
#ifndef _MAIN_H
|
|
|
|
# define _MAIN_H
|
|
|
|
# include <X11/Xfuncproto.h>
|
1999-08-17 18:12:47 -07:00
|
|
|
# include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
|
1999-08-17 16:01:18 -07:00
|
|
|
# include <ctype.h>
|
|
|
|
# include <stdio.h>
|
|
|
|
# include <stdarg.h>
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <string.h>
|
1999-08-17 18:12:47 -07:00
|
|
|
# include "misc.h"
|
1999-08-17 16:01:18 -07:00
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
/************ Macros and Definitions ************/
|
1999-08-17 16:01:18 -07:00
|
|
|
# ifndef EXIT_SUCCESS /* missing from <stdlib.h> */
|
|
|
|
# define EXIT_SUCCESS 0 /* exit function success */
|
|
|
|
# define EXIT_FAILURE 1 /* exit function failure */
|
|
|
|
# endif
|
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
# define THEME_CFG "theme.cfg"
|
|
|
|
# define USER_CFG "user.cfg"
|
1999-08-17 16:01:18 -07:00
|
|
|
|
|
|
|
# define MAX_COLS 200
|
|
|
|
# define MAX_ROWS 128
|
|
|
|
|
|
|
|
# ifndef min
|
|
|
|
# define min(a,b) (((a) < (b)) ? (a) : (b))
|
1999-09-28 17:14:05 -07:00
|
|
|
# endif
|
|
|
|
# ifndef max
|
1999-08-17 16:01:18 -07:00
|
|
|
# define max(a,b) (((a) > (b)) ? (a) : (b))
|
|
|
|
# endif
|
|
|
|
# ifndef MIN
|
|
|
|
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
|
|
|
# endif
|
|
|
|
# ifndef MAX
|
|
|
|
# define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
|
|
|
# endif
|
1999-09-28 17:14:05 -07:00
|
|
|
# define LOWER_BOUND(current, other) (((current) < (other)) ? ((current) = (other)) : (current))
|
|
|
|
# define AT_LEAST(current, other) LOWER_BOUND(current, other)
|
|
|
|
# define MAX_IT(current, other) LOWER_BOUND(current, other)
|
|
|
|
# define UPPER_BOUND(current, other) (((current) > (other)) ? ((current) = (other)) : (current))
|
|
|
|
# define AT_MOST(current, other) UPPER_BOUND(current, other)
|
|
|
|
# define MIN_IT(current, other) UPPER_BOUND(current, other)
|
|
|
|
# define SWAP_IT(one, two, tmp) do {(tmp) = (one); (one) = (two); (two) = (tmp);} while (0)
|
1999-08-17 16:01:18 -07:00
|
|
|
|
|
|
|
/* width of scrollBar, menuBar shadow ... don't change! */
|
|
|
|
# define SHADOW 2
|
|
|
|
|
|
|
|
/* convert pixel dimensions to row/column values */
|
|
|
|
# define Pixel2Width(x) ((x) / TermWin.fwidth)
|
|
|
|
# define Pixel2Height(y) ((y) / TermWin.fheight)
|
|
|
|
# define Pixel2Col(x) Pixel2Width((x) - TermWin.internalBorder)
|
|
|
|
# define Pixel2Row(y) Pixel2Height((y) - TermWin.internalBorder)
|
|
|
|
# define Width2Pixel(n) ((n) * TermWin.fwidth)
|
|
|
|
# define Height2Pixel(n) ((n) * TermWin.fheight)
|
|
|
|
# define Col2Pixel(col) (Width2Pixel(col) + TermWin.internalBorder)
|
|
|
|
# define Row2Pixel(row) (Height2Pixel(row) + TermWin.internalBorder)
|
|
|
|
|
|
|
|
# define TermWin_TotalWidth() (TermWin.width + 2 * TermWin.internalBorder)
|
|
|
|
# define TermWin_TotalHeight() (TermWin.height + 2 * TermWin.internalBorder)
|
|
|
|
|
|
|
|
# define Xscreen DefaultScreen(Xdisplay)
|
|
|
|
# define Xcmap DefaultColormap(Xdisplay,Xscreen)
|
|
|
|
# define Xdepth DefaultDepth(Xdisplay,Xscreen)
|
|
|
|
# define Xroot DefaultRootWindow(Xdisplay)
|
1999-08-17 18:12:47 -07:00
|
|
|
# define Xvisual DefaultVisual(Xdisplay, Xscreen)
|
1999-08-17 16:01:18 -07:00
|
|
|
# ifdef DEBUG_DEPTH
|
|
|
|
# undef Xdepth
|
|
|
|
# define Xdepth DEBUG_DEPTH
|
|
|
|
# endif
|
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
/************ Structures ************/
|
|
|
|
typedef struct {
|
|
|
|
int internalBorder; /* Internal border size */
|
|
|
|
short width, height; /* window size [pixels] */
|
|
|
|
short fwidth, fheight; /* font width and height [pixels] */
|
|
|
|
short fprop; /* font is proportional */
|
|
|
|
short ncol, nrow; /* window size [characters] */
|
|
|
|
short focus; /* window has focus */
|
|
|
|
short saveLines; /* number of lines that fit in scrollback */
|
|
|
|
short nscrolled; /* number of line actually scrolled */
|
|
|
|
short view_start; /* scrollback view starts here */
|
|
|
|
Window parent, vt; /* parent (main) and vt100 window */
|
|
|
|
GC gc; /* GC for drawing text */
|
|
|
|
XFontStruct * font; /* main font structure */
|
|
|
|
XFontSet fontset;
|
1999-08-17 16:01:18 -07:00
|
|
|
# ifndef NO_BOLDFONT
|
1999-08-17 18:12:47 -07:00
|
|
|
XFontStruct * boldFont; /* bold font */
|
1999-08-17 16:01:18 -07:00
|
|
|
# endif
|
1999-08-17 18:12:47 -07:00
|
|
|
# ifdef MULTI_CHARSET
|
|
|
|
XFontStruct * mfont; /* multibyte font structure */
|
1999-08-17 16:01:18 -07:00
|
|
|
# endif
|
1999-08-17 18:12:47 -07:00
|
|
|
} TermWin_t;
|
1999-08-17 16:01:18 -07:00
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
/************ Variables ************/
|
|
|
|
extern TermWin_t TermWin;
|
|
|
|
extern Window root;
|
|
|
|
extern Display *Xdisplay;
|
|
|
|
extern Colormap cmap;
|
|
|
|
extern char *orig_argv0;
|
|
|
|
#ifdef PIXMAP_SUPPORT
|
|
|
|
extern short bg_needs_update;
|
1999-08-17 16:01:18 -07:00
|
|
|
#endif
|
1999-08-17 18:12:47 -07:00
|
|
|
extern const char *display_name;
|
1999-08-17 16:01:18 -07:00
|
|
|
|
|
|
|
#endif /* whole file */
|