Thu Oct 7 18:48:31 PDT 1999 Michael Jennings <mej@eterm.org>

Shaved off around 100 KB of memory usage per Eterm by moving more
	code into the shared library, removing lots of unneeded variables, and
	fixing some small leaks here and there.


SVN revision: 710
eterm-0.10
Michael Jennings 24 years ago
parent fb94fcd0b6
commit dd84c6abab
  1. 7
      ChangeLog
  2. 6
      src/Makefile.am
  3. 2
      src/actions.c
  4. 2
      src/command.c
  5. 4
      src/e.c
  6. 2
      src/e.h
  7. 2
      src/eterm_utmp.h
  8. 4
      src/events.c
  9. 2
      src/events.h
  10. 2
      src/feature.h
  11. 4
      src/font.c
  12. 2
      src/font.h
  13. 2
      src/graphics.c
  14. 299
      src/main.c
  15. 8
      src/menus.c
  16. 2
      src/menus.h
  17. 4
      src/misc.c
  18. 2
      src/misc.h
  19. 2
      src/netdisp.c
  20. 214
      src/options.c
  21. 14
      src/options.h
  22. 4
      src/pixmap.c
  23. 2
      src/pixmap.h
  24. 2
      src/screen.c
  25. 2
      src/screen.h
  26. 4
      src/scrollbar.c
  27. 2
      src/scrollbar.h
  28. 327
      src/startup.c
  29. 10
      src/startup.h
  30. 4
      src/term.c
  31. 2
      src/term.h
  32. 2
      src/threads.c
  33. 2
      src/timer.c
  34. 4
      src/windows.c
  35. 2
      src/windows.h

@ -2549,3 +2549,10 @@ Thu Oct 7 16:39:48 PDT 1999 Michael Jennings <mej@eterm.org>
wasn't working. It is now. :-)
-------------------------------------------------------------------------------
Thu Oct 7 18:48:31 PDT 1999 Michael Jennings <mej@eterm.org>
Shaved off around 100 KB of memory usage per Eterm by moving more
code into the shared library, removing lots of unneeded variables, and
fixing some small leaks here and there.
-------------------------------------------------------------------------------

@ -3,7 +3,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 \
options.c pixmap.c screen.c scrollbar.c system.c term.c threads.c timer.c utmp.c windows.c
options.c pixmap.c screen.c scrollbar.c startup.c system.c term.c threads.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,6 @@ 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 main.h menus.h misc.h \
options.h pixmap.h profile.h screen.h scrollbar.h system.h term.h threads.h timer.h windows.h graphics/Makefile.am \
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 threads.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

@ -37,7 +37,7 @@ static const char cvs_ident[] = "$Id$";
#include "../libmej/debug.h"
#include "../libmej/strings.h"
#include "debug.h"
#include "main.h"
#include "startup.h"
#include "mem.h"
#include "strings.h"
#include "actions.h"

@ -115,7 +115,7 @@ static const char cvs_ident[] = "$Id$";
/* Eterm-specific Headers */
#include "command.h"
#include "main.h"
#include "startup.h"
#include "../libmej/debug.h"
#include "debug.h"
#include "../libmej/mem.h"

@ -5,7 +5,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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
@ -41,7 +41,7 @@ static const char cvs_ident[] = "$Id$";
#include "debug.h"
#include "e.h"
#include "command.h"
#include "main.h"
#include "startup.h"
#include "options.h"
#include "pixmap.h"
#include "system.h"

@ -6,7 +6,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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

@ -5,7 +5,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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

@ -6,7 +6,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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
@ -37,7 +37,7 @@ static const char cvs_ident[] = "$Id$";
#include "../libmej/debug.h"
#include "../libmej/strings.h"
#include "debug.h"
#include "main.h"
#include "startup.h"
#include "mem.h"
#include "strings.h"
#include "actions.h"

@ -6,7 +6,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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

@ -6,7 +6,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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

@ -5,7 +5,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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
@ -39,7 +39,7 @@ static const char cvs_ident[] = "$Id$";
#include "debug.h"
#include "command.h"
#include "font.h"
#include "main.h"
#include "startup.h"
#include "options.h"
#include "screen.h"
#include "term.h"

@ -5,7 +5,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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

@ -21,7 +21,7 @@ static const char cvs_ident[] = "$Id$";
#include "command.h" /* for tt_printf() */
#include "debug.h"
#include "graphics.h"
#include "main.h"
#include "startup.h"
#include "screen.h"
/* commands:

@ -6,7 +6,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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
@ -26,303 +26,10 @@
static const char cvs_ident[] = "$Id$";
#include "config.h"
#include "feature.h"
extern int eterm_bootstrap(int argc, char *argv[]);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <ctype.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xos.h>
#include "../libmej/debug.h" /* from libmej */
#include "debug.h"
#include "../libmej/mem.h"
#include "../libmej/strings.h"
#include "main.h"
#include "actions.h"
#include "command.h"
#include "eterm_utmp.h"
#include "events.h"
#include "graphics.h"
#include "options.h"
#include "pixmap.h"
#include "screen.h"
#include "scrollbar.h"
#include "term.h"
#ifdef USE_POSIX_THREADS
# include "threads.h"
#endif
#include "windows.h"
char *orig_argv0;
#ifdef PIXMAP_SUPPORT
/* Set to one in case there is no WM, or a lousy one
that doesn't send the right events (*cough*
Window Maker *cough*) -- mej */
short bg_needs_update = 1;
#endif
#ifdef USE_POSIX_THREADS
static void **retval;
static int join_value;
static pthread_t main_loop_thr;
static pthread_attr_t main_loop_attr;
# ifdef MUTEX_SYNCH
pthread_mutex_t mutex;
# endif
#endif
TermWin_t TermWin;
Display *Xdisplay; /* display */
Colormap cmap;
unsigned int debug_level = 0; /* Level of debugging information to display */
const char *display_name = NULL;
unsigned int colorfgbg;
/* main() */
int
main(int argc, char *argv[])
{
int i;
char *val;
static char windowid_string[20], *display_string, *term_string; /* "WINDOWID=\0" = 10 chars, UINT_MAX = 10 chars */
ImlibInitParams params;
orig_argv0 = argv[0];
#ifdef USE_POSIX_THREADS
# ifdef MUTEX_SYNCH
pthread_atfork((void *) &prepare, (void *) &parent, (void *) &child);
# endif
#endif
/* Security enhancements -- mej */
putenv("IFS= \t\n");
my_ruid = getuid();
my_euid = geteuid();
my_rgid = getgid();
my_egid = getegid();
privileges(REVERT);
getcwd(initial_dir, PATH_MAX);
init_defaults();
/* Open display, get options/resources and create the window */
if ((display_name = getenv("DISPLAY")) == NULL)
display_name = ":0";
/* This MUST be called before any other Xlib functions */
#ifdef USE_POSIX_THREADS
if (XInitThreads()) {
D_THREADS(("XInitThreads() succesful\n"));
} else {
D_THREADS(("XInitThreads() failed, I'm outta here\n"));
}
#endif
get_initial_options(argc, argv);
#ifdef NEED_LINUX_HACK
privileges(INVOKE); /* xdm in new Linux versions requires ruid != root to open the display -- mej */
#endif
Xdisplay = XOpenDisplay(display_name);
#ifdef NEED_LINUX_HACK
privileges(REVERT);
#endif
if (!Xdisplay) {
print_error("can't open display %s", display_name);
exit(EXIT_FAILURE);
}
#if DEBUG >= DEBUG_X
if (debug_level >= DEBUG_X) {
XSetErrorHandler((XErrorHandler) abort);
} else {
XSetErrorHandler((XErrorHandler) xerror_handler);
}
#else
XSetErrorHandler((XErrorHandler) xerror_handler);
#endif
if (Options & Opt_install) {
cmap = XCreateColormap(Xdisplay, Xroot, Xvisual, AllocNone);
XInstallColormap(Xdisplay, cmap);
#ifdef PIXMAP_SUPPORT
params.cmap = cmap;
params.flags = PARAMS_COLORMAP;
#endif
} else {
cmap = Xcmap;
#ifdef PIXMAP_SUPPORT
params.flags = 0;
#endif
}
/* Since we always use Imlib now, let's initialize it here. */
#ifdef PIXMAP_SUPPORT
if (params.flags) {
imlib_id = Imlib_init_with_params(Xdisplay, &params);
} else {
imlib_id = Imlib_init(Xdisplay);
}
if (!imlib_id) {
fatal_error("Unable to initialize Imlib. Aborting.");
}
#endif
read_config(THEME_CFG);
read_config((rs_config_file ? rs_config_file : USER_CFG));
#if defined(PIXMAP_SUPPORT)
if (rs_path || theme_dir || user_dir) {
register unsigned long len;
register char *tmp;
len = strlen(initial_dir);
if (rs_path) {
len += strlen(rs_path) + 1; /* +1 for the colon */
}
if (theme_dir) {
len += strlen(theme_dir) + 1;
}
if (user_dir) {
len += strlen(user_dir) + 1;
}
tmp = MALLOC(len + 1); /* +1 here for the NUL */
snprintf(tmp, len + 1, "%s%s%s%s%s%s%s", (rs_path ? rs_path : ""), (rs_path ? ":" : ""), initial_dir,
(theme_dir ? ":" : ""), (theme_dir ? theme_dir : ""), (user_dir ? ":" : ""), (user_dir ? user_dir : ""));
tmp[len] = '\0';
FREE(rs_path);
rs_path = tmp;
D_OPTIONS(("New rs_path set to \"%s\"\n", rs_path));
}
#endif
get_options(argc, argv);
D_UTMP(("Saved real uid/gid = [ %d, %d ] effective uid/gid = [ %d, %d ]\n", my_ruid, my_rgid, my_euid, my_egid));
D_UTMP(("Now running with real uid/gid = [ %d, %d ] effective uid/gid = [ %d, %d ]\n", getuid(), getgid(), geteuid(),
getegid()));
post_parse();
#ifdef PREFER_24BIT
cmap = DefaultColormap(Xdisplay, Xscreen);
/*
* If depth is not 24, look for a 24bit visual.
*/
if (Xdepth != 24) {
XVisualInfo vinfo;
if (XMatchVisualInfo(Xdisplay, Xscreen, 24, TrueColor, &vinfo)) {
Xdepth = 24;
Xvisual = vinfo.visual;
cmap = XCreateColormap(Xdisplay, RootWindow(Xdisplay, Xscreen),
Xvisual, AllocNone);
}
}
#endif
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);
#if DEBUG >= DEBUG_X
if (debug_level >= DEBUG_X) {
XSynchronize(Xdisplay, True);
}
#endif
#ifdef DISPLAY_IS_IP
/* Fixup display_name for export over pty to any interested terminal
* clients via "ESC[7n" (e.g. shells). Note we use the pure IP number
* (for the first non-loopback interface) that we get from
* network_display(). This is more "name-resolution-portable", if you
* will, and probably allows for faster x-client startup if your name
* server is beyond a slow link or overloaded at client startup. Of
* course that only helps the shell's child processes, not us.
*
* Giving out the display_name also affords a potential security hole
*/
val = display_name = network_display(display_name);
if (val == NULL)
#endif /* DISPLAY_IS_IP */
val = XDisplayString(Xdisplay);
if (display_name == NULL)
display_name = val; /* use broken `:0' value */
i = strlen(val);
display_string = MALLOC((i + 9));
sprintf(display_string, "DISPLAY=%s", val);
sprintf(windowid_string, "WINDOWID=%u", (unsigned int) TermWin.parent);
/* add entries to the environment:
* DISPLAY: X display name
* WINDOWID: X windowid of the window
* COLORTERM: Terminal supports color
* COLORTERM_BCE: Terminal supports BCE
* TERM: Terminal type for termcap/terminfo
*/
putenv(display_string);
putenv(windowid_string);
if (Xdepth <= 2) {
putenv("COLORTERM=" COLORTERMENV "-mono");
putenv("COLORTERM_BCE=" COLORTERMENV "-mono");
putenv("TERM=" TERMENV);
} else {
if (rs_term_name != NULL) {
i = strlen(rs_term_name);
term_string = MALLOC((i + 6) * sizeof(char));
sprintf(term_string, "TERM=%s", rs_term_name);
putenv(term_string);
} else {
#ifdef DEFINE_XTERM_COLOR
if (Xdepth <= 2)
putenv("TERM=" TERMENV);
else
putenv("TERM=" TERMENV "-color");
#else
putenv("TERM=" TERMENV);
#endif
}
putenv("COLORTERM=" COLORTERMENV);
putenv("COLORTERM_BCE=" COLORTERMENV);
}
putenv("ETERM_VERSION=" VERSION);
D_CMD(("init_command()\n"));
init_command(rs_execArgs);
#ifndef USE_POSIX_THREADS
if (Options & Opt_borderless) {
resize_window();
}
#endif
#ifdef USE_POSIX_THREADS
D_THREADS(("main_thread:"));
pthread_attr_init(&main_loop_attr);
pthread_create(&main_loop_thr, &main_loop_attr,
(void *) &main_thread, NULL);
D_THREADS(("done? :)\n"));
while (1);
/* main_loop(); */
#else
main_loop(); /* main processing loop */
#endif
return (EXIT_SUCCESS);
return (eterm_bootstrap(argc, argv));
}
/* EOF */

@ -5,7 +5,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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
@ -37,7 +37,7 @@ static const char cvs_ident[] = "$Id$";
#include "e.h"
#include "events.h"
#include "font.h"
#include "main.h"
#include "startup.h"
#include "menus.h"
#include "misc.h"
#include "options.h"
@ -615,8 +615,8 @@ menuitem_create(char *text)
menuitem_t *menuitem;
menuitem = (menuitem_t *) MALLOC(sizeof(menu_t));
MEMSET(menuitem, 0, sizeof(menu_t));
menuitem = (menuitem_t *) MALLOC(sizeof(menuitem_t));
MEMSET(menuitem, 0, sizeof(menuitem_t));
if (text) {
menuitem->text = StrDup(text);

@ -5,7 +5,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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

@ -5,7 +5,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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
@ -39,7 +39,7 @@ static const char cvs_ident[] = "$Id$";
#include "../libmej/mem.h"
#include "../libmej/strings.h"
#include "command.h"
#include "main.h"
#include "startup.h"
#include "misc.h"
#include "options.h"

@ -5,7 +5,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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

@ -62,7 +62,7 @@ static const char cvs_ident[] = "$Id$";
#include <net/if.h>
#include <net/if_arp.h>
#include "main.h"
#include "startup.h"
/* return a pointer to a static buffer */
char *

@ -6,7 +6,7 @@
* bearing this same message or a similar one, is distributed under
* the GNU Public License (GPL) as outlined in the COPYING file.
*
* Copyright (C) 1997, Michael Jennings and Tuomo Venalainen
* Copyright (C) 1997-1999, Michael Jennings and Tuomo Venalainen
*
* 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
@ -50,7 +50,7 @@ static const char cvs_ident[] = "$Id$";
#include "events.h"
#include "font.h"
#include "grkelot.h"
#include "main.h"
#include "startup.h"
#include "menus.h"
#include "options.h"
#include "pixmap.h"
@ -210,24 +210,6 @@ char *rs_mfont[NFONTS];
char *rs_print_pipe = NULL;
#endif
char *rs_cutchars = NULL;
const char *rs_loginShell = NULL;
const char *rs_utmpLogging = NULL;
const char *rs_scrollBar = NULL;
const char *rs_install = NULL;
const char *rs_app_keypad = NULL;
const char *rs_app_cursor = NULL;
const char *rs_homeOnEcho = NULL;
const char *rs_homeOnInput = NULL;
const char *rs_homeOnRefresh = NULL;
const char *rs_scrollBar_right = NULL;
const char *rs_scrollBar_floating = NULL;
const char *rs_scrollbar_popup = NULL;
const char *rs_borderless = NULL;
const char *rs_pause = NULL;
const char *rs_xterm_select = NULL;
const char *rs_select_whole_line = NULL;
const char *rs_select_trailing_spaces = NULL;
const char *rs_report_as_keysyms = NULL;
unsigned short rs_min_anchor_size = 0;
char *rs_scrollbar_type = NULL;
unsigned long rs_scrollbar_width = 0;
@ -236,16 +218,6 @@ char *rs_term_name = NULL;
static char *rs_bigfont_key = NULL;
static char *rs_smallfont_key = NULL;
#endif
#ifndef NO_MAPALERT
# ifdef MAPALERT_OPTION
static const char *rs_mapAlert = NULL;
# endif
#endif
static const char *rs_visualBell = NULL;
static const char *rs_reverseVideo = NULL;
#ifdef META8_OPTION
static const char *rs_meta8 = NULL;
#endif
#ifdef MULTI_CHARSET
static char *rs_multchar_encoding = NULL;
#endif
@ -267,7 +239,6 @@ time_t rs_anim_delay = 0;
# endif
static char *rs_pixmaps[image_max];
#endif
char *rs_noCursor = NULL;
char *rs_theme = NULL;
char *rs_config_file = NULL;
unsigned int rs_line_space = 0;
@ -307,13 +278,13 @@ static const struct {
#else
OPT_ILONG("debug", "level of debugging information to show (0-5)", &debug_level),
#endif
OPT_BLONG("install", "install a private colormap", &rs_install, &Options, Opt_install),
OPT_BLONG("install", "install a private colormap", &Options, Opt_install),
OPT_BOOL('h', "help", "display usage information", NULL, NULL, 0),
OPT_BLONG("version", "display version and configuration information", NULL, NULL, 0),
OPT_BOOL('h', "help", "display usage information", NULL, 0),
OPT_BLONG("version", "display version and configuration information", NULL, 0),
/* =======[ Color options ]======= */
OPT_BOOL('r', "reverse-video", "reverse video", &rs_reverseVideo, &Options, Opt_reverseVideo),
OPT_BOOL('r', "reverse-video", "reverse video", &Options, Opt_reverseVideo),
OPT_STR('b', "background-color", "background color", &rs_color[bgColor]),
OPT_STR('f', "foreground-color", "foreground color", &rs_color[fgColor]),
OPT_LONG("color0", "color 0", &rs_color[minColor]),
@ -351,7 +322,7 @@ static const struct {
/* =======[ X11 options ]======= */
OPT_STR('g', "geometry", "WxH+X+Y = size and position", &rs_geometry),
OPT_BOOL('i', "iconic", "start iconified", NULL, &Options, Opt_iconic),
OPT_BOOL('i', "iconic", "start iconified", &Options, Opt_iconic),
OPT_STR('n', "name", "client instance, icon, and title strings", &rs_name),
OPT_STR('T', "title", "title string", &rs_title),
OPT_LONG("icon-name", "icon name", &rs_iconName),
@ -377,8 +348,8 @@ static const struct {
OPT_LONG("trough-pixmap", "scrollbar background (trough) pixmap [scaling optional]", &rs_pixmaps[image_sb]),
OPT_LONG("anchor-pixmap", "scrollbar anchor pixmap [scaling optional]", &rs_pixmaps[image_sa]),
OPT_LONG("menu-pixmap", "menu pixmap [scaling optional]", &rs_pixmaps[image_menu]),
OPT_BOOL('O', "trans", "creates a pseudo-transparent Eterm", NULL, &image_toggles, IMOPT_TRANS),
OPT_BLONG("viewport-mode", "use viewport mode for the background image", NULL, &image_toggles, IMOPT_VIEWPORT),
OPT_BOOL('O', "trans", "creates a pseudo-transparent Eterm", &image_toggles, IMOPT_TRANS),
OPT_BLONG("viewport-mode", "use viewport mode for the background image", &image_toggles, IMOPT_VIEWPORT),
OPT_LONG("cmod", "image color modifier (\"brightness contrast gamma\")", &rs_cmod_image),
OPT_LONG("cmod-red", "red-only color modifier (\"brightness contrast gamma\")", &rs_cmod_red),
OPT_LONG("cmod-green", "green-only color modifier (\"brightness contrast gamma\")", &rs_cmod_green),
@ -405,32 +376,32 @@ static const struct {
#endif
/* =======[ Toggles ]======= */
OPT_BOOL('l', "login-shell", "login shell, prepend - to shell name", &rs_loginShell, &Options, Opt_loginShell),
OPT_BOOL('s', "scrollbar", "display scrollbar", &rs_scrollBar, &Options, Opt_scrollBar),
OPT_BOOL('u', "utmp-logging", "make a utmp entry", &rs_utmpLogging, &Options, Opt_utmpLogging),
OPT_BOOL('v', "visual-bell", "visual bell", &rs_visualBell, &Options, Opt_visualBell),
OPT_BOOL('H', "home-on-echo", "jump to bottom on output", &rs_homeOnEcho, &Options, Opt_homeOnEcho),
OPT_BLONG("home-on-input", "jump to bottom on input", &rs_homeOnInput, &Options, Opt_homeOnInput),
OPT_BOOL('E', "home-on-refresh", "jump to bottom on refresh (^L)", &rs_homeOnRefresh, &Options, Opt_homeOnRefresh),
OPT_BLONG("scrollbar-right", "display the scrollbar on the right", &rs_scrollBar_right, &Options, Opt_scrollBar_right),
OPT_BLONG("scrollbar-floating", "display the scrollbar with no trough", &rs_scrollBar_floating, &Options, Opt_scrollBar_floating),
OPT_BLONG("scrollbar-popup", "popup the scrollbar only when focused", &rs_scrollbar_popup, &Options, Opt_scrollbar_popup),
OPT_BOOL('x', "borderless", "force Eterm to have no borders", &rs_borderless, &Options, Opt_borderless),
OPT_BOOL('l', "login-shell", "login shell, prepend - to shell name", &Options, Opt_loginShell),
OPT_BOOL('s', "scrollbar", "display scrollbar", &Options, Opt_scrollBar),
OPT_BOOL('u', "utmp-logging", "make a utmp entry", &Options, Opt_utmpLogging),
OPT_BOOL('v', "visual-bell", "visual bell", &Options, Opt_visualBell),
OPT_BOOL('H', "home-on-echo", "jump to bottom on output", &Options, Opt_homeOnEcho),
OPT_BLONG("home-on-input", "jump to bottom on input", &Options, Opt_homeOnInput),
OPT_BOOL('E', "home-on-refresh", "jump to bottom on refresh (^L)", &Options, Opt_homeOnRefresh),
OPT_BLONG("scrollbar-right", "display the scrollbar on the right", &Options, Opt_scrollBar_right),
OPT_BLONG("scrollbar-floating", "display the scrollbar with no trough", &Options, Opt_scrollBar_floating),
OPT_BLONG("scrollbar-popup", "popup the scrollbar only when focused", &Options, Opt_scrollbar_popup),
OPT_BOOL('x', "borderless", "force Eterm to have no borders", &Options, Opt_borderless),
#ifndef NO_MAPALERT
# ifdef MAPALERT_OPTION
OPT_BOOL('m', "map-alert", "uniconify on beep", &rs_mapAlert, &Options, Opt_mapAlert),
OPT_BOOL('m', "map-alert", "uniconify on beep", &Options, Opt_mapAlert),
# endif
#endif
#ifdef META8_OPTION
OPT_BOOL('8', "meta-8", "Meta key toggles 8-bit", &rs_meta8, &Options, Opt_meta8),
OPT_BOOL('8', "meta-8", "Meta key toggles 8-bit", &Options, Opt_meta8),
#endif
OPT_BLONG("backing-store", "use backing store", &rs_backing_store, &Options, Opt_backing_store),
OPT_BLONG("no-cursor", "disable the text cursor", &rs_noCursor, &Options, Opt_noCursor),
OPT_BLONG("pause", "pause for a keypress after the child process exits", &rs_pause, &Options, Opt_pause),
OPT_BLONG("xterm-select", "duplicate xterm's broken selection behavior", &rs_xterm_select, &Options, Opt_xterm_select),
OPT_BLONG("select-line", "triple-click selects whole line", &rs_select_whole_line, &Options, Opt_select_whole_line),
OPT_BLONG("select-trailing-spaces", "do not skip trailing spaces when selecting", &rs_select_trailing_spaces, &Options, Opt_select_trailing_spaces),
OPT_BLONG("report-as-keysyms", "report special keys as keysyms", &rs_report_as_keysyms, &Options, Opt_report_as_keysyms),
OPT_BLONG("backing-store", "use backing store", &Options, Opt_backing_store),
OPT_BLONG("no-cursor", "disable the text cursor", &Options, Opt_noCursor),
OPT_BLONG("pause", "pause for a keypress after the child process exits", &Options, Opt_pause),
OPT_BLONG("xterm-select", "duplicate xterm's broken selection behavior", &Options, Opt_xterm_select),
OPT_BLONG("select-line", "triple-click selects whole line", &Options, Opt_select_whole_line),
OPT_BLONG("select-trailing-spaces", "do not skip trailing spaces when selecting", &Options, Opt_select_trailing_spaces),
OPT_BLONG("report-as-keysyms", "report special keys as keysyms", &Options, Opt_report_as_keysyms),
/* =======[ Keyboard options ]======= */
#if defined (HOTKEY_CTRL) || defined (HOTKEY_META)
@ -440,8 +411,8 @@ static const struct {
#ifdef GREEK_SUPPORT
OPT_LONG("greek-keyboard", "greek keyboard mapping (iso or ibm)", &rs_greek_keyboard),
#endif
OPT_BLONG("app-keypad", "application keypad mode", &rs_app_keypad, &PrivateModes, PrivMode_aplKP),
OPT_BLONG("app-cursor", "application cursor key mode", &rs_app_cursor, &PrivateModes, PrivMode_aplCUR),
OPT_BLONG("app-keypad", "application keypad mode", &PrivateModes, PrivMode_aplKP),
OPT_BLONG("app-cursor", "application cursor key mode", &PrivateModes, PrivMode_aplCUR),
/* =======[ Misc options ]======= */
OPT_INT('L', "save-lines", "lines to save in scrollback buffer", &rs_saveLines),
@ -456,7 +427,7 @@ static const struct {
OPT_LONG("cut-chars", "seperators for double-click selection", &rs_cutchars),
#endif /* CUTCHAR_OPTION */
OPT_LONG("term-name", "value to use for setting $TERM", &rs_term_name),
OPT_BOOL('C', "console", "grab console messages", NULL, &Options, Opt_console),
OPT_BOOL('C', "console", "grab console messages", &Options, Opt_console),
OPT_ARGS('e', "exec", "execute a command rather than a shell", &rs_execArgs)
};
@ -1052,17 +1023,11 @@ get_options(int argc, char *argv[])
if (optList[j].maskvar) {
*(optList[j].maskvar) |= optList[j].mask;
}
if (optList[j].pval) {
*((const char **) optList[j].pval) = *true_vals;
}
} else if (BOOL_OPT_ISFALSE(val_ptr)) {
D_OPTIONS(("\"%s\" == FALSE\n", val_ptr));
if (optList[j].maskvar) {
*(optList[j].maskvar) &= ~(optList[j].mask);
}
if (optList[j].pval) {
*((const char **) optList[j].pval) = *false_vals;
}
} else {
print_error("unrecognized boolean value \"%s\" for option --%s",
val_ptr, optList[j].long_opt);
@ -1073,9 +1038,6 @@ get_options(int argc, char *argv[])
if (optList[j].maskvar) {
*(optList[j].maskvar) |= optList[j].mask;
}
if (optList[j].pval) {
*((const char **) optList[j].pval) = *true_vals;
}
}
} else if (optList[j].flag & OPT_INTEGER) { /* Integer value */
D_OPTIONS(("Integer option detected\n"));
@ -1172,9 +1134,6 @@ get_options(int argc, char *argv[])
if (optList[j].maskvar) {
*(optList[j].maskvar) |= optList[j].mask;
}
if (optList[j].pval) {
*((const char **) optList[j].pval) = *true_vals;
}
} else if (optList[j].flag & OPT_INTEGER) { /* Integer value */
D_OPTIONS(("Integer option detected\n"));
*((int *) optList[j].pval) = strtol(val_ptr, (char **) NULL, 0);
@ -1253,26 +1212,17 @@ get_initial_options(int argc, char *argv[])
if (optList[j].maskvar) {
*(optList[j].maskvar) |= optList[j].mask;
}
if (optList[j].pval) {
*((const char **) optList[j].pval) = *true_vals;
}
} else if (BOOL_OPT_ISFALSE(val_ptr)) {
D_OPTIONS(("\"%s\" == FALSE\n", val_ptr));
if (optList[j].maskvar) {
*(optList[j].maskvar) &= ~(optList[j].mask);
}
if (optList[j].pval) {
*((const char **) optList[j].pval) = *false_vals;
}
}
} else { /* No value, so force it on */
D_OPTIONS(("Forcing option --%s to TRUE\n", opt));
if (optList[j].maskvar) {
*(optList[j].maskvar) |= optList[j].mask;
}
if (optList[j].pval) {
*((const char **) optList[j].pval) = *true_vals;
}
}
} else {
D_OPTIONS(("String option detected\n"));
@ -1354,7 +1304,7 @@ builtin_version(char *param)
D_PARSE(("builtin_version(%s) called\n", param));
return (Word(1, VERSION));
return (StrDup(VERSION));
}
char *
@ -1363,7 +1313,7 @@ builtin_appname(char *param)
D_PARSE(("builtin_appname(%s) called\n", param));
return (Word(1, APL_NAME "-" VERSION));
return (StrDup(APL_NAME "-" VERSION));
}
/* chomp() removes leading and trailing whitespace/quotes from a string */
@ -1690,42 +1640,42 @@ parse_color(char *buff)
ASSERT(buff != NULL);
if (!BEG_STRCASECMP(buff, "foreground ")) {
rs_color[fgColor] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[fgColor], Word(2, buff));
} else if (!BEG_STRCASECMP(buff, "background ")) {
rs_color[bgColor] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[bgColor], Word(2, buff));
} else if (!BEG_STRCASECMP(buff, "cursor ")) {
#ifndef NO_CURSORCOLOR
rs_color[cursorColor] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[cursorColor], Word(2, buff));
#else
print_warning("Support for the cursor attribute was not compiled in, ignoring");
#endif
} else if (!BEG_STRCASECMP(buff, "cursor_text ")) {
#ifndef NO_CURSORCOLOR
rs_color[cursorColor2] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[cursorColor2], Word(2, buff));
#else
print_warning("Support for the cursor_text attribute was not compiled in, ignoring");
#endif
} else if (!BEG_STRCASECMP(buff, "menu ")) {
rs_color[menuColor] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[menuColor], Word(2, buff));
} else if (!BEG_STRCASECMP(buff, "menu_text ")) {
rs_color[menuTextColor] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[menuTextColor], Word(2, buff));
} else if (!BEG_STRCASECMP(buff, "scrollbar ")) {
rs_color[scrollColor] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[scrollColor], Word(2, buff));
} else if (!BEG_STRCASECMP(buff, "unfocusedmenu ")) {
rs_color[unfocusedMenuColor] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[unfocusedMenuColor], Word(2, buff));
} else if (!BEG_STRCASECMP(buff, "unfocusedscrollbar ")) {
rs_color[unfocusedScrollColor] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[unfocusedScrollColor], Word(2, buff));
} else if (!BEG_STRCASECMP(buff, "pointer ")) {
rs_color[pointerColor] = Word(2, buff);
RESET_AND_ASSIGN(rs_color[pointerColor], Word(2, buff));
} else if (!BEG_STRCASECMP(buff, "video ")) {
@ -1733,7 +1683,6 @@ parse_color(char *buff)
if (!BEG_STRCASECMP(tmp, "reverse")) {
Options |= Opt_reverseVideo;
rs_reverseVideo = *true_vals;
} else if (BEG_STRCASECMP(tmp, "normal")) {
print_error("Parse error in file %s, line %lu: Invalid value \"%s\" for attribute video",
file_peek_path(), file_peek_line(), tmp);
@ -1759,19 +1708,19 @@ parse_color(char *buff)
} else if (n >= 8 && n <= 15) {
index = minBright + n - 8;
}
rs_color[index] = Word(1, r1);
RESET_AND_ASSIGN(rs_color[index], Word(1, r1));
return;
} else {
if (!BEG_STRCASECMP(tmp, "bd ")) {
#ifndef NO_BOLDUNDERLINE
rs_color[colorBD] = Word(1, r1);
RESET_AND_ASSIGN(rs_color[colorBD], Word(1, r1));
#else
print_warning("Support for the color bd attribute was not compiled in, ignoring");
#endif
return;
} else if (!BEG_STRCASECMP(tmp, "ul ")) {
#ifndef NO_BOLDUNDERLINE
rs_color[colorUL] = Word(1, r1);
RESET_AND_ASSIGN(rs_color[colorUL], Word(1, r1));
#else
print_warning("Support for the color ul attribute was not compiled in, ignoring");
#endif
@ -1798,11 +1747,11 @@ parse_color(char *buff)
b = strtoul(b1, (char **) NULL, 0);
if (n <= 7) {
index = minColor + n;
rs_color[index] = MALLOC(14);
RESET_AND_ASSIGN(rs_color[index], MALLOC(14));
sprintf(rs_color[index], "#%02x%02x%02x", r, g, b);
} else if (n >= 8 && n <= 15) {
index = minBright + n - 8;
rs_color[index] = MALLOC(14);
RESET_AND_ASSIGN(rs_color[index], MALLOC(14));
sprintf(rs_color[index], "#%02x%02x%02x", r, g, b);
} else {
print_error("Parse error in file %s, line %lu: Invalid color index %lu",
@ -1811,7 +1760,7 @@ parse_color(char *buff)
} else if (!BEG_STRCASECMP(tmp, "bd ")) {
#ifndef NO_BOLDUNDERLINE
rs_color[colorBD] = MALLOC(14);
RESET_AND_ASSIGN(rs_color[colorBD], MALLOC(14));
r = strtoul(r1, (char **) NULL, 0);
g = strtoul(g1, (char **) NULL, 0);
b = strtoul(b1, (char **) NULL, 0);
@ -1822,7 +1771,7 @@ parse_color(char *buff)
} else if (!BEG_STRCASECMP(tmp, "ul ")) {
#ifndef NO_BOLDUNDERLINE
rs_color[colorUL] = MALLOC(14);
RESET_AND_ASSIGN(rs_color[colorUL], MALLOC(14));
r = strtoul(r1, (char **) NULL, 0);
g = strtoul(g1, (char **) NULL, 0);
b = strtoul(b1, (char **) NULL, 0);
@ -1883,14 +1832,14 @@ parse_attributes(char *buff)
if (isdigit(*tmp)) {
n = (unsigned char) strtoul(tmp, (char **) NULL, 0);
if (n <= 4) {
rs_font[n] = Word(2, tmp);
RESET_AND_ASSIGN(rs_font[n], Word(2, tmp));
} else {
print_error("Parse error in file %s, line %lu: Invalid font index %d",
file_peek_path(), file_peek_line(), n);
}
} else if (!BEG_STRCASECMP(tmp, "bold ")) {
#ifndef NO_BOLDFONT
rs_boldFont = Word(2, tmp);
RESET_AND_ASSIGN(rs_boldFont, Word(2, tmp));
#else
print_warning("Support for the bold font attribute was not compiled in, ignoring");
#endif
@ -1935,10 +1884,8 @@ parse_toggles(char *buff)
#if !defined(NO_MAPALERT) && defined(MAPALERT_OPTION)
if (bool_val) {
Options |= Opt_mapAlert;
rs_mapAlert = *true_vals;
} else {
Options &= ~(Opt_mapAlert);
rs_mapAlert = *false_vals;
}
#else
print_warning("Support for the map_alert attribute was not compiled in, ignoring");
@ -1947,36 +1894,28 @@ parse_toggles(char *buff)
} else if (!BEG_STRCASECMP(buff, "visual_bell ")) {
if (bool_val) {
Options |= Opt_visualBell;
rs_visualBell = *true_vals;
} else {
Options &= ~(Opt_visualBell);
rs_visualBell = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "login_shell ")) {
if (bool_val) {
Options |= Opt_loginShell;
rs_loginShell = *true_vals;
} else {
Options &= ~(Opt_loginShell);
rs_loginShell = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "scrollbar ")) {
if (bool_val) {
Options |= Opt_scrollBar;
rs_scrollBar = *true_vals;
} else {
Options &= ~(Opt_scrollBar);
rs_scrollBar = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "utmp_logging ")) {
#ifdef UTMP_SUPPORT
if (bool_val) {
Options |= Opt_utmpLogging;
rs_utmpLogging = *true_vals;
} else {
Options &= ~(Opt_utmpLogging);
rs_utmpLogging = *false_vals;
}
#else
print_warning("Support for the utmp_logging attribute was not compiled in, ignoring");
@ -1986,10 +1925,8 @@ parse_toggles(char *buff)
#ifdef META8_OPTION
if (bool_val) {
Options |= Opt_meta8;
rs_meta8 = *true_vals;
} else {
Options &= ~(Opt_meta8);
rs_meta8 = *false_vals;
}
#else
print_warning("Support for the meta8 attribute was not compiled in, ignoring");
@ -2005,124 +1942,96 @@ parse_toggles(char *buff)
} else if (!BEG_STRCASECMP(buff, "home_on_echo ")) {
if (bool_val) {
Options |= Opt_homeOnEcho;
rs_homeOnEcho = *true_vals;
} else {
Options &= ~(Opt_homeOnEcho);
rs_homeOnEcho = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "home_on_input ")) {
if (bool_val) {
Options |= Opt_homeOnInput;
rs_homeOnInput = *true_vals;
} else {
Options &= ~(Opt_homeOnInput);
rs_homeOnInput = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "home_on_refresh ")) {
if (bool_val) {
Options |= Opt_homeOnRefresh;
rs_homeOnRefresh = *true_vals;
} else {
Options &= ~(Opt_homeOnRefresh);
rs_homeOnRefresh = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "scrollbar_floating ")) {
if (bool_val) {
Options |= Opt_scrollBar_floating;
rs_scrollBar_floating = *true_vals;
} else {
Options &= ~(Opt_scrollBar_floating);
rs_scrollBar_floating = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "scrollbar_right ")) {
if (bool_val) {
Options |= Opt_scrollBar_right;
rs_scrollBar_right = *true_vals;
} else {
Options &= ~(Opt_scrollBar_right);
rs_scrollBar_right = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "scrollbar_popup ")) {
if (bool_val) {
Options |= Opt_scrollbar_popup;
rs_scrollbar_popup = *true_vals;
} else {
Options &= ~(Opt_scrollbar_popup);
rs_scrollbar_popup = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "borderless ")) {
if (bool_val) {
Options |= Opt_borderless;
rs_borderless = *true_vals;
} else {
Options &= ~(Opt_borderless);
rs_borderless = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "backing_store ")) {
if (bool_val) {
Options |= Opt_backing_store;
rs_backing_store = *true_vals;
} else {
Options &= ~(Opt_backing_store);
rs_backing_store = *false_vals;
}
} else if (!BEG_STRCASECMP(buff, "no_cursor ")) {
if (bool_val) {
Options |= Opt_noCursor;
rs_noCursor = (char *) true_vals;
} else {
Options &= ~(Opt_noCursor);
rs_noCursor = (char *) false_vals;
}
} else if (!BEG_STRCASECMP(buff, "pause ")) {
if (bool_val) {
Options |= Opt_pause;
rs_pause = (char *) true_vals;
} else {
Options &= ~(Opt_pause);
rs_pause = (char *) false_vals;
}
} else if (!BEG_STRCASECMP(buff, "xterm_select ")) {
if (bool_val) {
Options |= Opt_xterm_select;
rs_xterm_select = (char *) true_vals;
} else {
Options &= ~(Opt_xterm_select);
rs_xterm_select = (char *) false_vals;
}
} else if (!BEG_STRCASECMP(buff, "select_line ")) {
if (bool_val) {
Options |= Opt_select_whole_line;
rs_select_whole_line = (char *) true_vals;
} else {
Options &= ~(Opt_select_whole_line);
rs_select_whole_line = (char *) false_vals;
}
} else if (!BEG_STRCASECMP(buff, "select_trailing_spaces ")) {
if (bool_val) {
Options |= Opt_select_trailing_spaces;
rs_select_trailing_spaces = (char *) true_vals;
} else {