eterm/src/command.h

396 lines
11 KiB
C
Raw Normal View History

/*--------------------------------*-C-*---------------------------------*
* File: command.h
*
* Copyright 1992 John Bovey, University of Kent at Canterbury.
*
* You can do what you like with this source code as long as you don't try
* to make money out of it and you include an unaltered copy of this
* message (including the copyright).
*
* This module has been heavily modified by R. Nation
* <nation@rocket.sanders.lockheed.com>
* No additional restrictions are applied.
*
* Additional modifications by mj olesen <olesen@me.QueensU.CA>
* No additional restrictions are applied.
*
* As usual, the author accepts no responsibility for anything, nor does
* he guarantee anything whatsoever.
*----------------------------------------------------------------------*/
#ifndef _COMMAND_H_
# define _COMMAND_H_
# include <signal.h>
# include <limits.h>
# include <X11/X.h>
# include <X11/Xfuncproto.h>
# include <X11/Xproto.h>
# include <X11/keysym.h>
# ifdef HAVE_X11_LOCALE_H
# include <X11/Xlocale.h>
# endif
# include <locale.h>
# include "options.h"
# include "system.h" /* For RETSIGTYPE */
/************ Macros and Definitions ************/
#if !defined(SIGSYS)
# if defined(SIGUNUSED)
# define SIGSYS SIGUNUSED
# else
# define SIGSYS ((int) 0)
# endif
#endif
#ifdef OFFIX_DND
# define DndFile 2
# define DndDir 5
# define DndLink 7
#endif
# define scrollbar_esc 30
/* Motif window hints */
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_HINTS_INPUT_MODE (1L << 2)
#define MWM_HINTS_STATUS (1L << 3)
/* bit definitions for MwmHints.functions */
#define MWM_FUNC_ALL (1L << 0)
#define MWM_FUNC_RESIZE (1L << 1)
#define MWM_FUNC_MOVE (1L << 2)
#define MWM_FUNC_MINIMIZE (1L << 3)
#define MWM_FUNC_MAXIMIZE (1L << 4)
#define MWM_FUNC_CLOSE (1L << 5)
/* bit definitions for MwmHints.decorations */
#define MWM_DECOR_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1)
#define MWM_DECOR_RESIZEH (1L << 2)
#define MWM_DECOR_TITLE (1L << 3)
#define MWM_DECOR_MENU (1L << 4)
#define MWM_DECOR_MINIMIZE (1L << 5)
#define MWM_DECOR_MAXIMIZE (1L << 6)
/* bit definitions for MwmHints.inputMode */
#define MWM_INPUT_MODELESS 0
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
#define MWM_INPUT_SYSTEM_MODAL 2
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
#define PROP_MWM_HINTS_ELEMENTS 5
/* DEC private modes */
# define PrivMode_132 (1LU<<0)
# define PrivMode_132OK (1LU<<1)
# define PrivMode_rVideo (1LU<<2)
# define PrivMode_relOrigin (1LU<<3)
# define PrivMode_Screen (1LU<<4)
# define PrivMode_Autowrap (1LU<<5)
# define PrivMode_aplCUR (1LU<<6)
# define PrivMode_aplKP (1LU<<7)
# define PrivMode_BackSpace (1LU<<8)
# define PrivMode_ShiftKeys (1LU<<9)
# define PrivMode_VisibleCursor (1LU<<10)
# define PrivMode_MouseX10 (1LU<<11)
# define PrivMode_MouseX11 (1LU<<12)
/* too annoying to implement X11 highlight tracking */
/* #define PrivMode_MouseX11Track (1LU<<13) */
# define PrivMode_scrollbar (1LU<<14)
# define PrivMode_menuBar (1LU<<15)
#define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11)
#define PrivMode(test,bit) do {\
if (test) PrivateModes |= (bit); else PrivateModes &= ~(bit);} while (0)
#define PrivMode_Default (PrivMode_Autowrap|PrivMode_ShiftKeys|PrivMode_VisibleCursor)
#ifdef HAVE_TERMIOS_H
# ifdef TCSANOW /* POSIX */
# define GET_TERMIOS(fd,tios) tcgetattr(fd, tios)
# define SET_TERMIOS(fd,tios) do {cfsetospeed(tios, BAUDRATE); cfsetispeed(tios, BAUDRATE); tcsetattr(fd, TCSANOW, tios);} while (0)
# else
# ifdef TIOCSETA
# define GET_TERMIOS(fd,tios) ioctl(fd, TIOCGETA, tios)
# define SET_TERMIOS(fd,tios) do {tios->c_cflag |= BAUDRATE; ioctl(fd, TIOCSETA, tios);} while (0)
# else
# define GET_TERMIOS(fd,tios) ioctl(fd, TCGETS, tios)
# define SET_TERMIOS(fd,tios) do {tios->c_cflag |= BAUDRATE; ioctl(fd, TCSETS, tios);} while (0)
# endif
# endif
# define SET_TTYMODE(fd,tios) SET_TERMIOS(fd, tios)
#else
# define SET_TTYMODE(fd,tt) do {tt->sg.sg_ispeed = tt->sg.sg_ospeed = BAUDRATE; ioctl(fd, TIOCSETP, &(tt->sg)); ioctl(fd, TIOCSETC, &(tt->tc)); \
ioctl(fd, TIOCSLTC, &(tt->lc)); ioctl(fd, TIOCSETD, &(tt->line)); ioctl(fd, TIOCLSET, &(tt->local)); \
} while (0)
#endif /* HAVE_TERMIOS_H */
#ifdef B38400
# define BAUDRATE B38400
#else
# ifdef B19200
# define BAUDRATE B19200
# else
# define BAUDRATE B9600
# endif
#endif
/* Disable special character functions */
#ifdef _POSIX_VDISABLE
# define VDISABLE _POSIX_VDISABLE
#else
# define VDISABLE 255
#endif
/* system default characters if defined and reasonable */
#ifndef CINTR
# define CINTR '\003' /* ^C */
#endif
#ifndef CQUIT
# define CQUIT '\034' /* ^\ */
#endif
#ifndef CERASE
# ifdef linux
# define CERASE '\177' /* ^? */
# else
# define CERASE '\010' /* ^H */
# endif
#endif
#ifndef CKILL
# define CKILL '\025' /* ^U */
#endif
#ifndef CEOF
# define CEOF '\004' /* ^D */
#endif
#ifndef CSTART
# define CSTART '\021' /* ^Q */
#endif
#ifndef CSTOP
# define CSTOP '\023' /* ^S */
#endif
#ifndef CSUSP
# define CSUSP '\032' /* ^Z */
#endif
#ifndef CDSUSP
# define CDSUSP '\031' /* ^Y */
#endif
#ifndef CRPRNT
# define CRPRNT '\022' /* ^R */
#endif
#ifndef CFLUSH
# define CFLUSH '\017' /* ^O */
#endif
#ifndef CWERASE
# define CWERASE '\027' /* ^W */
#endif
#ifndef CLNEXT
# define CLNEXT '\026' /* ^V */
#endif
#ifndef CSTATUS
# define CSTATUS '\024' /* ^T */
#endif
#ifndef VDISCRD
# ifdef VDISCARD
# define VDISCRD VDISCARD
# endif
#endif
#ifndef VWERSE
# ifdef VWERASE
# define VWERSE VWERASE
# endif
#endif
#define KBUFSZ 64 /* size of keyboard mapping buffer */
#define STRING_MAX 512 /* max string size for process_xterm_seq() */
#define ESC_ARGS 32 /* max # of args for esc sequences */
/* a large REFRESH_PERIOD causes problems with `cat' */
#ifndef REFRESH_PERIOD
# define REFRESH_PERIOD 3
#endif
#ifndef MULTICLICK_TIME
# define MULTICLICK_TIME 500
#endif
#ifndef SCROLLBAR_INITIAL_DELAY
# define SCROLLBAR_INITIAL_DELAY 40
#endif
#ifndef SCROLLBAR_CONTINUOUS_DELAY
# define SCROLLBAR_CONTINUOUS_DELAY 2
#endif
/* time factor to slow down a `jumpy' mouse */
#define MOUSE_THRESHOLD 50
#define CONSOLE "/dev/console" /* console device */
/* key-strings: if only these keys were standardized <sigh> */
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org> This is the first public availability of the work thus far on Eterm 0.9.1. There's quite a bit of new stuff here. * Added scrollbar thumb support. * Completely redid the terminfo/termcap stuff. The terminfo file is now compiled (by tic) and installed by default (unless you specify --without-terminfo). The config files still say xterm, though, because some programs (like SLang and GNU mc) use the silly algorithm of "Is $TERM set to xterm?" to detect mouse reporting support in a terminal. =P But if you don't ever use xterm, you can use Eterm's termcap and just name it "xterm" instead. Thanks to Marius Gedminas <mgedmin@takas.lt> for his patch that started this whole revamp. * Added the kEsetroot script for KDE users from Dax Games <dgames@isoc.net>. * You can now configure the Home and End emulation via --with-home= and --with-end= options to configure. The --with-terminfo option is also new, and --enable-xim is now the default. * Added a new image state, disabled, for when Eterm loses focus. This is supported by all widgets (well, all those that could possibly be on screen when Eterm lost focus), even the background image. So you could actually have all your images darken on focus out and restore to normal on focus in. * Widget colors formerly dealt with as colors (menu text color, scrollbar color, etc.) are now handled by the imageclasses. Each image state can have a foreground and background color defined. The current exception is the background image; I hope to add that later. The foreground is the text color and the background is the object color (for solid color mode). So menu text color is set by the menu imageclass. And again, for unfocused colors, use the disabled state of the imageclass. * Proportionally-spaced fonts are now handled much better. They are still forced into evenly-spaced columns (it's a terminal for crying out loud!) but at least you don't end up with Eterm's wider than your screen. :-) * Home on refresh is gone, as is home on echo. It's now much simpler. There are two options: home on output, and home on input, the former being a combination of echo and refresh. Also, keypresses that don't necessarily have corresonding output can trigger a home on input, like Ctrl-End or whatever...ones that don't have special meaning. Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out this issue and the one with "m-" in font names. * I finally got around to re-merging the new parser stuff from my work on the Not Game. Closed up some old potential behavior quirks with theme parsing. * Added a new escape sequence to fork-and-exec a program. Also added a scrollback search capability to highlight all occurances of a string in your scrollback buffer. Use the new "Etsearch" utility to access it. "Etsearch string" to search for a string, then "Etsearch" by itself to reset the highlighting. * And of course, the biggie. Eterm now supports a completely- customizeable buttonbar. Not a menubar, a buttonbar. It can have an arbitrary number of buttons, and each button can perform an action, just like a menuitem. So a button could bring up a menu (like a menubar) or launch a program (like a launchbar) or perform an operation (like a toolbar). Each button can have an icon, text, or both. And you can have buttons left- or right-justified in the buttonbar. You will eventually be able to have an arbitrary number of buttonbars, but I'm still working on that. As with any change this big, things could very easily be broken. So beware. :-) I have tested this myself, and everything seems to work, but I can't test every possibility. Let me know if you find anything that's broken, and enjoy! SVN revision: 2048
2000-02-10 16:25:07 -08:00
#ifndef KS_HOME
# define KS_HOME "\033[7~" /* Home */
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org> This is the first public availability of the work thus far on Eterm 0.9.1. There's quite a bit of new stuff here. * Added scrollbar thumb support. * Completely redid the terminfo/termcap stuff. The terminfo file is now compiled (by tic) and installed by default (unless you specify --without-terminfo). The config files still say xterm, though, because some programs (like SLang and GNU mc) use the silly algorithm of "Is $TERM set to xterm?" to detect mouse reporting support in a terminal. =P But if you don't ever use xterm, you can use Eterm's termcap and just name it "xterm" instead. Thanks to Marius Gedminas <mgedmin@takas.lt> for his patch that started this whole revamp. * Added the kEsetroot script for KDE users from Dax Games <dgames@isoc.net>. * You can now configure the Home and End emulation via --with-home= and --with-end= options to configure. The --with-terminfo option is also new, and --enable-xim is now the default. * Added a new image state, disabled, for when Eterm loses focus. This is supported by all widgets (well, all those that could possibly be on screen when Eterm lost focus), even the background image. So you could actually have all your images darken on focus out and restore to normal on focus in. * Widget colors formerly dealt with as colors (menu text color, scrollbar color, etc.) are now handled by the imageclasses. Each image state can have a foreground and background color defined. The current exception is the background image; I hope to add that later. The foreground is the text color and the background is the object color (for solid color mode). So menu text color is set by the menu imageclass. And again, for unfocused colors, use the disabled state of the imageclass. * Proportionally-spaced fonts are now handled much better. They are still forced into evenly-spaced columns (it's a terminal for crying out loud!) but at least you don't end up with Eterm's wider than your screen. :-) * Home on refresh is gone, as is home on echo. It's now much simpler. There are two options: home on output, and home on input, the former being a combination of echo and refresh. Also, keypresses that don't necessarily have corresonding output can trigger a home on input, like Ctrl-End or whatever...ones that don't have special meaning. Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out this issue and the one with "m-" in font names. * I finally got around to re-merging the new parser stuff from my work on the Not Game. Closed up some old potential behavior quirks with theme parsing. * Added a new escape sequence to fork-and-exec a program. Also added a scrollback search capability to highlight all occurances of a string in your scrollback buffer. Use the new "Etsearch" utility to access it. "Etsearch string" to search for a string, then "Etsearch" by itself to reset the highlighting. * And of course, the biggie. Eterm now supports a completely- customizeable buttonbar. Not a menubar, a buttonbar. It can have an arbitrary number of buttons, and each button can perform an action, just like a menuitem. So a button could bring up a menu (like a menubar) or launch a program (like a launchbar) or perform an operation (like a toolbar). Each button can have an icon, text, or both. And you can have buttons left- or right-justified in the buttonbar. You will eventually be able to have an arbitrary number of buttonbars, but I'm still working on that. As with any change this big, things could very easily be broken. So beware. :-) I have tested this myself, and everything seems to work, but I can't test every possibility. Let me know if you find anything that's broken, and enjoy! SVN revision: 2048
2000-02-10 16:25:07 -08:00
#endif
#ifndef KS_END
# define KS_END "\033[8~" /* End */
#endif
#ifdef NO_DELETE_KEY
# undef KS_DELETE /* use X server definition */
#else
# ifndef KS_DELETE
# define KS_DELETE "\033[3~" /* Delete = Execute */
# endif
#endif
#define VT100_ANS "\033[?1;2c" /* vt100 answerback */
#define LINUX_ANS "\033[?6;5c" /* linux answerback */
#ifndef ESCZ_ANSWER
# define ESCZ_ANSWER VT100_ANS /* obsolete ANSI ESC[c */
#endif
#if defined(linux) && defined(N_TTY_BUF_SIZE)
# define CMD_BUF_SIZE N_TTY_BUF_SIZE
#else
# ifndef CMD_BUF_SIZE
# define CMD_BUF_SIZE 4096
# endif
#endif
#if !defined(EACCESS) && defined(EAGAIN)
# define EACCESS EAGAIN
#endif
#define PTYCHAR1 "pqrstuvwxyz"
#define PTYCHAR2 "0123456789abcdefghijklmnopqrstuvwxyz"
#if RETSIGTYPE != void
# define SIG_RETURN(x) return ((RETSIGTYPE) x)
#else
# define SIG_RETURN(x) return
#endif
#define CHARS_READ() (cmdbuf_ptr < cmdbuf_endp)
#define CHARS_BUFFERED() (count != CMD_BUF_SIZE)
#define RETURN_CHAR() do { \
char c = *cmdbuf_ptr++; \
refreshed = 0; \
if (c < 32) D_VT(("RETURN_CHAR(): \'%s\' (%d 0x%02x %03o)\n", get_ctrl_char_name(c), c, c, c)); \
else D_VT(("RETURN_CHAR(): \'%c\' (%d 0x%02x %03o)\n", c, c, c, c)); \
return (c); \
} while (0)
#ifdef REFRESH_DELAY
# define REFRESH_DELAY_USEC (1000000/25)
#endif
#if defined(linux)
# ifdef PTY_BUF_SIZE /* From <linux/tty.h> */
# define MAX_PTY_WRITE PTY_BUF_SIZE
# endif
#endif
/* NOTE: _POSIX_MAX_INPUT is defined _through_ <limits.h> at least for
* the following systems: HP-UX 10.20, AIX (no idea about the version),
* OSF1/alpha 4.0, Linux (probably any Linux system).
*/
#ifndef MAX_PTY_WRITE
# ifdef _POSIX_VERSION
# ifdef _POSIX_MAX_INPUT
# define MAX_PTY_WRITE _POSIX_MAX_INPUT
# else
# define MAX_PTY_WRITE 255 /* POSIX minimum MAX_INPUT */
# endif
# endif
#endif
#ifndef MAX_PTY_WRITE
# define MAX_PTY_WRITE 128 /* 1/2 POSIX minimum MAX_INPUT */
#endif
/************ Structures ************/
/* Motif window hints */
# ifdef LONG64
typedef struct _mwmhints {
CARD64 flags;
CARD64 functions;
CARD64 decorations;
INT64 input_mode;
CARD64 status;
} MWMHints;
# else
typedef struct _mwmhints {
CARD32 flags;
CARD32 functions;
CARD32 decorations;
INT32 input_mode;
CARD32 status;
} MWMHints;
# endif
# ifdef HAVE_TERMIOS_H
typedef struct termios ttymode_t;
# else
typedef struct { /* sgtty interface */
struct sgttyb sg;
struct tchars tc;
struct ltchars lc;
int line;
int local;
} ttymode_t;
# endif
/************ Variables ************/
extern int my_ruid, my_rgid, my_euid, my_egid;
extern int pipe_fd;
extern char initial_dir[PATH_MAX+1];
extern unsigned long PrivateModes;
extern int refresh_count, refresh_limit, refresh_type;
extern pid_t cmd_pid;
#ifdef USE_XIM
extern XIC xim_input_context; /* input context */
#endif
/************ Function Prototypes ************/
_XFUNCPROTOBEGIN
#ifdef HAVE_U_STACK_TRACE
extern void U_STACK_TRACE(void);
#endif
extern char *ptsname();
extern void privileges(int);
extern char *sig_to_str(int);
extern const char *event_type_to_name(int);
extern const char *request_code_to_name(int);
extern const char *get_ctrl_char_name(char);
extern void dump_stack_trace(void);
Wed Apr 12 21:18:19 PDT 2000 Michael Jennings <mej@eterm.org> This is the initial commit with Imlib2 support. READ THIS CAREFULLY. There is important information in this commit message that will keep you from getting screwed. First off, support for Imlib 1.x is GONE. It is no longer supported as of now. If you want to continue using it, do NOT install this version. I tried to support both for awhile, but the code ended up being way too ugly and hackish. Imlib2 is the future. And trust me, when you see what we do with this future, you'll be happy for the switch. The good news is that most of the basics work. Transparency still works, and the basic image stuff works. Most users won't notice any major problems, so long as your Imlib2 is 100% up-to-date. However, a few things still don't work: 1. Auto mode is a bit broken. You'll get X errors in XFree86 4.0. Don't use it if you're running XFree 4. 2. Color modifiers for images don't work. At all. 3. Transparency shading/tinting will not work in 8bpp or lower. Life blows sometimes. Sorry. Time for a real video card. :-) 4. The built-in icon is broken. 5. You WILL need to update your theme.cfg files. The borders on the horizontal and vertical bar images were incorrect when combined with the new anti-aliased scaling. The horizontal bars should have a right border of 3. Vertical bars should have a bottom border of 3. The menu images should have both right *and* bottom borders of 3. You can either make those changes by hand, or use the --with-theme-update option to autogen.sh. Your call. I think that covers everything I've run into. I will point out that I don't really take advantage of a lot of the Imlib2 features just yet. My first priority is to make all the stuff that worked before work again (or at least the important stuff). Then I'll work on new features. So there it is. If you're not ready for it, don't use it. But if you are, I hope you like it. SVN revision: 2478
2000-04-12 21:19:05 -07:00
extern void install_handlers(void);
extern void clean_exit(void);
extern int get_pty(void);
extern int get_tty(void);
extern XFontSet create_fontset(const char *, const char *);
#if defined(USE_XIM) || defined(MULTI_CHARSET)
extern void xim_set_status_position(void);
extern void xim_get_position(XPoint *pos);
extern void xim_set_fontset(void);
extern void init_locale(void);
#else
# define init_locale() ((void)0)
#endif
extern int escreen_init(char **);
extern int run_command(char **);
extern void init_command(char **);
extern void tt_winsize(int);
extern void tt_resize(void);
extern unsigned int cmd_write(const unsigned char *, unsigned int);
#ifdef BACKGROUND_CYCLING_SUPPORT
extern RETSIGTYPE check_pixmap_change(int);
#endif
extern unsigned char cmd_getc(void);
extern void cmd_ungetc(void);
extern void tt_write(const unsigned char *, unsigned int);
extern void tt_printf(const unsigned char *, ...);
extern void main_loop(void);
extern int v_doPending(void);
extern void v_writeBig(int, char *, int);
#ifdef DISPLAY_IS_IP
extern char *network_display(const char *);
#endif
_XFUNCPROTOEND
#endif /* _COMMAND_H_ */