Index: trunk/Ohana/src/opihi/cmd.basic/opihi.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.basic/opihi.c	(revision 27614)
+++ trunk/Ohana/src/opihi/cmd.basic/opihi.c	(revision 27790)
@@ -3,8 +3,8 @@
 int opihi_setmode (int argc, char **argv) {
 
-  int value;
+  OpihiVerboseMode value;
 
   if (argc < 2) {
-    gprint (GP_ERR, "USAGE: opihi (verbose) [on/off]\n");
+    gprint (GP_ERR, "USAGE: opihi (verbose) [on/off/error]\n");
     return (FALSE);
   }
@@ -13,17 +13,30 @@
       if (argc == 2) {
 	  value = get_verbose_shell();
-	  if (value) {
-	    gprint (GP_ERR, "opihi verbose mode: on\n");
-	  } else {
-	    gprint (GP_ERR, "opihi verbose mode: off\n");
-	  }
+	  switch (value) {
+	    case OPIHI_VERBOSE_OFF:
+	      gprint (GP_ERR, "opihi verbose mode: off\n");
+	      break;
+	    case OPIHI_VERBOSE_ON:
+	      gprint (GP_ERR, "opihi verbose mode: on\n");
+	      break;
+	    case OPIHI_VERBOSE_ERROR:
+	      gprint (GP_ERR, "opihi verbose mode: error\n");
+	      break;
+	    default:
+	      fprintf (stderr, "impossible condition\n");
+	      abort();
+	  } 
 	  return (TRUE);
       }
       if (!strcasecmp(argv[2], "on")) {
-	set_verbose_shell (TRUE);
+	set_verbose_shell (OPIHI_VERBOSE_ON);
 	return (TRUE);
       }
       if (!strcasecmp(argv[2], "off")) {
-	set_verbose_shell (FALSE);
+	set_verbose_shell (OPIHI_VERBOSE_OFF);
+	return (TRUE);
+      }
+      if (!strcasecmp(argv[2], "error")) {
+	set_verbose_shell (OPIHI_VERBOSE_ERROR);
 	return (TRUE);
       }
Index: trunk/Ohana/src/opihi/cmd.data/box.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/box.c	(revision 27614)
+++ trunk/Ohana/src/opihi/cmd.data/box.c	(revision 27790)
@@ -25,5 +25,5 @@
   } 
 
-  graphmode.lweight = 1;
+  // graphmode.lweight = 1;
   if ((N = get_argument (argc, argv, "-lw"))) {
     remove_argument (N, &argc, argv);
@@ -32,5 +32,5 @@
   }
 
-  graphmode.color = KapaColorByName ("black");
+  // graphmode.color = KapaColorByName ("black");
   if ((N = get_argument (argc, argv, "-c"))) {
     remove_argument (N, &argc, argv);
@@ -40,5 +40,6 @@
   }
 
-  strcpy (graphmode.ticks, "2222");
+  // XXX need to get the current values from kapa
+  // strcpy (graphmode.ticks, "2222");
   if ((N = get_argument (argc, argv, "-ticks"))) {
     remove_argument (N, &argc, argv);
@@ -51,5 +52,5 @@
   }
   
-  strcpy (graphmode.labels, "2222");
+  // strcpy (graphmode.labels, "2222");
   if ((N = get_argument (argc, argv, "-labels"))) {
     remove_argument (N, &argc, argv);
@@ -62,5 +63,5 @@
   }
 
-  strcpy (graphmode.axis, "2222");
+  // strcpy (graphmode.axis, "2222");
   if ((N = get_argument (argc, argv, "-axis"))) {
     remove_argument (N, &argc, argv);
@@ -71,4 +72,72 @@
       if ((graphmode.axis[i] != '0') && (graphmode.axis[i] != '1') && (graphmode.axis[i] != '2')) { goto usage; }
     }
+  }
+
+  if ((N = get_argument (argc, argv, "-tickpad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.ticktextPad = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if ((N = get_argument (argc, argv, "-labelpadx"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.labelPadXm = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if ((N = get_argument (argc, argv, "-labelpady"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.labelPadYm = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if ((N = get_argument (argc, argv, "+labelpadx"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.labelPadXp = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if ((N = get_argument (argc, argv, "+labelpady"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.labelPadYp = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if ((N = get_argument (argc, argv, "-labelpad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.labelPadXm = atof(argv[N]);
+    graphmode.labelPadXp = atof(argv[N]);
+    graphmode.labelPadYm = atof(argv[N]);
+    graphmode.labelPadYp = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if ((N = get_argument (argc, argv, "-pad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.padXm = atof(argv[N]);
+    graphmode.padXp = atof(argv[N]);
+    graphmode.padYm = atof(argv[N]);
+    graphmode.padYp = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "-xpad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.padXm = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "+xpad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.padXp = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "-ypad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.padYm = atof(argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  if ((N = get_argument (argc, argv, "+ypad"))) {
+    remove_argument (N, &argc, argv);
+    graphmode.padYp = atof(argv[N]);
+    remove_argument (N, &argc, argv);
   }
 
Index: trunk/Ohana/src/opihi/cmd.data/section.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/section.c	(revision 27614)
+++ trunk/Ohana/src/opihi/cmd.data/section.c	(revision 27790)
@@ -1,9 +1,9 @@
 # include "data.h"
 
-enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL};
+enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG};
 
 int section (int argc, char **argv) {
   
-  int N, action, kapa;
+  int N, action, kapa, background;
   Graphdata graphmode;
   KapaSection section;
@@ -37,4 +37,16 @@
     location = argv[N];
     remove_argument (N, &argc, argv);
+  }
+
+  background = -1; // invisible
+  if ((N = get_argument (argc, argv, "-bg"))) {
+    remove_argument (N, &argc, argv);
+    if (!strcasecmp (argv[N], "NONE")) {
+      background = -1;
+    } else {
+      background = KapaColorByName(argv[N]);
+    }
+    remove_argument (N, &argc, argv);
+    action = BG;
   }
 
@@ -82,4 +94,8 @@
 	break;
 
+      case BG:
+	KapaSectionBG (kapa, argv[1], background);
+	break;
+
       case TOOL:
 	if (!strcmp(location, "-x")) {
@@ -121,4 +137,5 @@
     section.dx = atof (argv[4]);
     section.dy = atof (argv[5]);
+    section.bg = background;
     KapaSetSection (kapa, &section);
     return (TRUE);
Index: trunk/Ohana/src/opihi/include/shell.h
===================================================================
--- trunk/Ohana/src/opihi/include/shell.h	(revision 27614)
+++ trunk/Ohana/src/opihi/include/shell.h	(revision 27790)
@@ -15,4 +15,5 @@
 typedef enum {GP_FILE, GP_BUFF} gpMode;
 typedef enum {GP_LOG, GP_ERR} gpDest;
+typedef enum {OPIHI_VERBOSE_OFF, OPIHI_VERBOSE_ON, OPIHI_VERBOSE_ERROR} OpihiVerboseMode;
 
 typedef int CommandF (int argc, char **argv);
Index: trunk/Ohana/src/opihi/lib.data/open_graph.c
===================================================================
--- trunk/Ohana/src/opihi/lib.data/open_graph.c	(revision 27614)
+++ 	(revision )
@@ -1,176 +1,0 @@
-# include "display.h"
-# include "shell.h"
-# define DEBUG 0
-
-/* we have space for several kapa windows */
-# define NXGRAPH 5
-
-static int       Active;
-static int       Xgraph[NXGRAPH];  
-static Graphdata graphdata[NXGRAPH];
-
-void QuitGraph () {
-
-  int i;
-  
-  for (i = 0; i < NXGRAPH; i++) {
-    KiiClose (Xgraph[i]);
-  }
-}
-
-void InitGraph () {
-
-  int i;
-
-  Active = 0;
-  for (i = 0; i < NXGRAPH; i++) {
-    Xgraph[i] = -1;
-
-    graphdata[i].xmin = graphdata[i].ymin = 0.0;
-    graphdata[i].xmax = graphdata[i].ymax = 1.0;
-    graphdata[i].style = graphdata[i].ptype = 0;
-    graphdata[i].ltype = graphdata[i].color = 0;
-    graphdata[i].etype = graphdata[i].ebar = 0;
-    graphdata[i].lweight = graphdata[i].size = 1.0;
-    
-    graphdata[i].coords.pc1_1 = graphdata[i].coords.pc2_2 = 1.0;
-    graphdata[i].coords.pc1_2 = graphdata[i].coords.pc2_1 = 0.0;
-    strcpy (graphdata[i].coords.ctype, "RA---LIN");
-    graphdata[i].coords.crval1 = 0.0;
-    graphdata[i].coords.crval2 = 0.0;
-    graphdata[i].coords.crpix1 = 0.0;
-    graphdata[i].coords.crpix2 = 0.0;
-    graphdata[i].coords.cdelt1 = graphdata[i].coords.cdelt2 = 1.0;
-    graphdata[i].flipeast = TRUE;
-    graphdata[i].flipnorth = FALSE;
-    strcpy (graphdata[i].axis, "2222");
-    strcpy (graphdata[i].ticks, "2222");
-    strcpy (graphdata[i].labels, "2222");
-  }
-}
-
-/* set SIGPIPE to this function to close cleanly */ 
-void XGraphDead (int input) {
-  signal (SIGPIPE, XGraphDead);
-  gprint (GP_ERR, "kapa is dead, must restart\n");
-  Xgraph[Active] = -1;
-}
-
-/** start socketed connection */
-int open_graph (int N) {
-
-  int fd;
-  char *kapa_exec, name[16];
-  
-  kapa_exec = get_variable ("KAPA");
-  if (kapa_exec == (char *) NULL) {
-    gprint (GP_ERR, "variable KAPA not found\n");
-    return (FALSE);
-  }
-
-  snprintf (name, 16, "[%d]", N);
-  fd = KiiOpen (kapa_exec, name);
-  free (kapa_exec);
-
-  if (fd < 0) {
-    gprint (GP_ERR, "error starting kapa\n");
-    return (FALSE);
-  } 
-
-  Xgraph[N] = fd;
-  return (TRUE);
-}
-
-int close_graph (int N) {
-
-  if (N <  0) return (FALSE);
-  if (N >= NXGRAPH) return (FALSE);
-
-  KiiClose (Xgraph[N]); 
-  Xgraph[N] = -1;
-  return (TRUE);
-}
-
-/* return pointers for current Xgraph, set if desired, test, open if needed */
-int GetGraph (Graphdata *data, int *socket, int *N) {
-
-  int i, n;
-  char buffer[70];
-
-  SetImageDevice (FALSE);
-  if (N == (int *) NULL) {
-    n = Active;
-  } else {
-    if (*N >= NXGRAPH) {
-      gprint (GP_ERR, "invalid Xgraph window %d\n", *N); 
-      return (FALSE);
-    }
-    if (*N < 0) {
-      *N = n = Active;
-    } else {
-      Active = n = *N;
-    }
-  }
-  
-  /* test Xgraph[0], flush junk from pipe */
-  signal (SIGPIPE, XGraphDead);
-  fcntl (Xgraph[n], F_SETFL,  O_NONBLOCK); 
-  for (i = 0; (read (Xgraph[n], buffer, 64) > 0) && (i < 20); i++);
-  fcntl (Xgraph[n], F_SETFL, !O_NONBLOCK); 
-  
-  if (Xgraph[n] < 1) {
-    if (!open_graph(n)) {
-      return (FALSE);
-    }
-  }
-
-  if (data != (Graphdata *) NULL) *data  = graphdata[n];
-  if (socket != (int *) NULL) *socket = Xgraph[n];
-
-  return (TRUE);
-
-}
-
-/* return pointers for given Xgraph, don't set or open */
-int GetGraphData (Graphdata *data, int *sock, int *N) {
-
-  int n;
-
-  if (N == (int *) NULL) {
-    n = Active;
-  } else {
-    if (*N >= NXGRAPH) {
-      gprint (GP_ERR, "invalid Xgraph window %d\n", *N); 
-      return (FALSE);
-    }
-    if (*N < 0) {
-      n = Active;
-    } else {
-      n = *N;
-    }
-  }
-  
-  if (data != (Graphdata *) NULL) *data  = graphdata[n];
-  if (sock != (int *) NULL) *sock = Xgraph[n];
-
-  return (TRUE);
-
-}
-
-/* assign given values to current Xgraph */
-void SetGraph (Graphdata data) {
-  graphdata[Active] = data;
-}
-
-/** internal tracking of current active device type **/
-
-static int       IsImage = FALSE;
-
-int GetCurrentDevice () {
-  return (IsImage);
-}
-
-void SetImageDevice (int state) {
-  IsImage = state;
-}
-
Index: trunk/Ohana/src/opihi/lib.data/open_image.c
===================================================================
--- trunk/Ohana/src/opihi/lib.data/open_image.c	(revision 27614)
+++ 	(revision )
@@ -1,133 +1,0 @@
-# include "display.h"
-# include "shell.h"
-# define DEBUG 0
-
-/* we have space for several kii windows */
-# define NXIMAGE 5
-
-static int       Active;
-static int       Ximage[NXIMAGE];  
-static char      Ximbuffer[NXIMAGE][512];
-static double    Xzero[NXIMAGE];
-static double    Xrange[NXIMAGE];
-
-void QuitImage () {
-
-  int i;
-  
-  for (i = 0; i < NXIMAGE; i++) {
-    KiiClose (Ximage[i]);
-  }
-}
-
-void InitImage () {
-
-  int i;
-
-  Active = 0;
-  for (i = 0; i < NXIMAGE; i++) {
-    Ximage[i] = -1;
-    Xzero[i] = 0;
-    Xrange[i] = 1024;
-    strcpy (Ximbuffer[i], "none");
-  }
-}
-
-/* set SIGPIPE to this function to close cleanly */ 
-void XImageDead (int input) {
-  signal (SIGPIPE, XImageDead);
-  gprint (GP_ERR, "kii is dead, must restart\n");
-  Ximage[Active] = -1;
-}
-
-/** start socketed connection */
-int open_image (int N) {
-
-  int fd;
-  char *kii_exec, name[16];
-
-  kii_exec = get_variable ("KII");
-  if (kii_exec == (char *) NULL) {
-    gprint (GP_ERR, "variable KII not found\n");
-    return (FALSE);
-  }
-
-  snprintf (name, 16, "[%d]", N);
-  fd = KiiOpen (kii_exec, name);
-  free (kii_exec);
-
-  if (fd < 0) {
-    gprint (GP_ERR, "error starting kii\n");
-    return (FALSE);
-  } 
-
-  Ximage[N] = fd;
-  return (TRUE);
-}
-
-int close_image (int N) {
-
-  if (N <  0) return (FALSE);
-  if (N >= NXIMAGE) return (FALSE);
-
-  KiiClose (Ximage[N]); 
-  Ximage[N] = -1;
-  return (TRUE);
-}
-
-/* return pointers for current Ximage, set if desired, test, open if needed */
-int GetImage (int *socket, int *N) {
-
-  int i, n;
-  char buffer[70];
-
-  SetImageDevice (TRUE);
-  if (N == (int *) NULL) {
-    n = Active;
-  } else {
-    if (*N >= NXIMAGE) {
-      gprint (GP_ERR, "invalid Ximage window %d\n", *N); 
-      return (FALSE);
-    }
-    if (*N < 0) {
-      *N = n = Active;
-    } else {
-      Active = n = *N;
-    }
-  }
-  
-  /* test Ximage[0], flush junk from pipe */
-  signal (SIGPIPE, XImageDead);
-  fcntl (Ximage[n], F_SETFL,  O_NONBLOCK); 
-  for (i = 0; (read (Ximage[n], buffer, 64) > 0) && (i < 20); i++);
-  fcntl (Ximage[n], F_SETFL, !O_NONBLOCK); 
-  
-  if (Ximage[n] < 1) {
-    if (!open_image(n)) {
-      return (FALSE);
-    }
-  }
-
-  if (socket != (int *) NULL) *socket = Ximage[n];
-
-  return (TRUE);
-
-}
-
-void SetImageName (char *name) {
-  strcpy (Ximbuffer[Active], name);
-}
-
-char *GetImageName () {
-  return (Ximbuffer[Active]);
-}
- 
-// leave this information on kapa, request when needed? 
-void SetImageScale (double zero, double range) {
-  Xzero[Active] = zero;
-  Xrange[Active] = range;
-}
-void GetImageScale (double *zero, double *range) {
-  *zero = Xzero[Active];
-  *range = Xrange[Active];
-}
Index: trunk/Ohana/src/opihi/lib.shell/command.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/command.c	(revision 27614)
+++ trunk/Ohana/src/opihi/lib.shell/command.c	(revision 27790)
@@ -2,5 +2,5 @@
 # define DEBUG 0
 
-static int VERBOSE_SHELL = FALSE;
+static int VERBOSE_SHELL = OPIHI_VERBOSE_OFF;
 
 int command (char *line, char **outline, int VERBOSE) {
@@ -10,6 +10,6 @@
   Command *cmd;
 
-  rawline = NULL;
-  // rawline = strcreate (line);
+  // rawline = NULL;
+  rawline = strcreate (line);
 
   /* force a space between ! and first word: !ls becomes ! ls */
@@ -24,4 +24,9 @@
   /* expand anything of the form fred[N] */ 
   line = expand_vectors (line);  /* line is freed here, new one allocated */
+
+  // print the line with the variables and vectors expanded, but before evaluating 
+  // any in-line math expression
+  if (VERBOSE_SHELL == OPIHI_VERBOSE_ON) gprint (GP_ERR, "opihi: %s\n", line);
+
   /* solve math expresions, assign variable, if needed */
   line = parse (line);        /* line is freed here, new one allocated */
@@ -31,6 +36,4 @@
   *outline = line;
   
-  if (VERBOSE_SHELL) gprint (GP_ERR, "opihi: %s\n", line);
-
   argv = parse_commands (line, &argc);
   if (argc == 0) {
@@ -60,5 +63,5 @@
     msg = get_variable_ptr ("ERRORMSG");
     if (msg != (char *) NULL) gprint (GP_ERR, "%s\n", msg);
-    if (VERBOSE_SHELL) gprint (GP_ERR, "error on line: %s\n", rawline);
+    if (VERBOSE_SHELL != OPIHI_VERBOSE_OFF) gprint (GP_ERR, "error on line: %s\n", rawline);
   }
 
