]> granicus.if.org Git - graphviz/commitdiff
remove dotty, lefty, lneato
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 3 Aug 2022 02:40:15 +0000 (19:40 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 8 Aug 2022 04:07:03 +0000 (21:07 -0700)
Lefty, and its dependent tools Dotty and Lneato, have been suspected unused for
a long time. They were scheduled for removal, but we took a cautious and very
slow approach to this given how pervasive Graphviz is and the limited visibility
we have into its usage:

  1. 2021-09-25 make Lefty default to disabled in the build system¹
  2. 2022-01-16 disable Lefty in published graphviz.org packages²
  3. 2022-03-28 remove build system support³

This completes the final step of removing the code from the repository. It is
still retained in the history, should anyone need access to it or need to build
a past version of Graphviz with Lefty.

So far, we have only heard two notable reactions from the downstream world:

  1. Lefty disabling was not quite complete on the first attempt.⁴
  2. There has been an offer of assistance to maintain Lefty.⁵ No patches have
     yet emerged, but if and when they do we could feasibly reverse direction on
     this and reinstate Lefty and friends.

Gitlab: closes #219, closes #552, related to #1836, #1854

¹ 1a4ad00b59cc1e1e9302fcbd1a205495ee59cab5
² 04a78cc9ae01b2a7e5d5435146cd503c45af90b9
³ 6faa34010f947510ec129af2d998614de8a513ed
⁴ https://gitlab.com/graphviz/graphviz/-/issues/2153
⁵ https://forum.graphviz.org/t/lefty-not-a-graphviz-application/835/6

135 files changed:
.gitignore
ci/clang_format.py
cmd/dotty/dotty.1 [deleted file]
cmd/dotty/dotty.bsh [deleted file]
cmd/dotty/dotty.ksh [deleted file]
cmd/dotty/dotty.lefty [deleted file]
cmd/dotty/dotty.sh [deleted file]
cmd/dotty/dotty_draw.lefty [deleted file]
cmd/dotty/dotty_edit.lefty [deleted file]
cmd/dotty/dotty_layout.lefty [deleted file]
cmd/dotty/dotty_ui.lefty [deleted file]
cmd/dotty/mswin32/doinst [deleted file]
cmd/dotty/mswin32/dotty.c [deleted file]
cmd/dotty/mswin32/dotty.mak [deleted file]
cmd/dotty/notes [deleted file]
cmd/lefty/LOG [deleted file]
cmd/lefty/aix_mods/common.h [deleted file]
cmd/lefty/aix_mods/exec.c [deleted file]
cmd/lefty/aix_mods/tbl.c [deleted file]
cmd/lefty/code.c [deleted file]
cmd/lefty/code.h [deleted file]
cmd/lefty/colors.txt [deleted file]
cmd/lefty/common.c [deleted file]
cmd/lefty/common.h [deleted file]
cmd/lefty/cs2l/cs2l.c [deleted file]
cmd/lefty/cs2l/cs2l.h [deleted file]
cmd/lefty/display.c [deleted file]
cmd/lefty/display.h [deleted file]
cmd/lefty/dot2l/dot2l.c [deleted file]
cmd/lefty/dot2l/dot2l.h [deleted file]
cmd/lefty/dot2l/dotlex.c [deleted file]
cmd/lefty/dot2l/dotparse.y [deleted file]
cmd/lefty/dot2l/dottrie.c [deleted file]
cmd/lefty/dot2l/triefa.c [deleted file]
cmd/lefty/dot2l/triefa.h [deleted file]
cmd/lefty/examples/box.lefty [deleted file]
cmd/lefty/examples/def.lefty [deleted file]
cmd/lefty/examples/fractal.lefty [deleted file]
cmd/lefty/examples/fractal2.lefty [deleted file]
cmd/lefty/examples/slides.lefty [deleted file]
cmd/lefty/examples/tree.lefty [deleted file]
cmd/lefty/exec.c [deleted file]
cmd/lefty/exec.h [deleted file]
cmd/lefty/g.c [deleted file]
cmd/lefty/g.h [deleted file]
cmd/lefty/gfxview.c [deleted file]
cmd/lefty/gfxview.h [deleted file]
cmd/lefty/internal.c [deleted file]
cmd/lefty/internal.h [deleted file]
cmd/lefty/lefty.1 [deleted file]
cmd/lefty/lefty.c [deleted file]
cmd/lefty/lefty.psp [deleted file]
cmd/lefty/leftyio.h [deleted file]
cmd/lefty/lex.c [deleted file]
cmd/lefty/lex.h [deleted file]
cmd/lefty/mem.c [deleted file]
cmd/lefty/mem.h [deleted file]
cmd/lefty/os/mswin32/doinst [deleted file]
cmd/lefty/os/mswin32/io.c [deleted file]
cmd/lefty/os/mswin32/lefty.mak [deleted file]
cmd/lefty/os/unix/io.c [deleted file]
cmd/lefty/parse.c [deleted file]
cmd/lefty/parse.h [deleted file]
cmd/lefty/str.c [deleted file]
cmd/lefty/str.h [deleted file]
cmd/lefty/tbl.c [deleted file]
cmd/lefty/tbl.h [deleted file]
cmd/lefty/txtview.c [deleted file]
cmd/lefty/txtview.h [deleted file]
cmd/lefty/ws/gtk/garray.c [deleted file]
cmd/lefty/ws/gtk/gbutton.c [deleted file]
cmd/lefty/ws/gtk/gcanvas.c [deleted file]
cmd/lefty/ws/gtk/gcommon.c [deleted file]
cmd/lefty/ws/gtk/gcommon.h [deleted file]
cmd/lefty/ws/gtk/glabel.c [deleted file]
cmd/lefty/ws/gtk/gmenu.c [deleted file]
cmd/lefty/ws/gtk/gpcanvas.c [deleted file]
cmd/lefty/ws/gtk/gquery.c [deleted file]
cmd/lefty/ws/gtk/gscroll.c [deleted file]
cmd/lefty/ws/gtk/gtext.c [deleted file]
cmd/lefty/ws/gtk/gview.c [deleted file]
cmd/lefty/ws/mswin32/garray.c [deleted file]
cmd/lefty/ws/mswin32/gbutton.c [deleted file]
cmd/lefty/ws/mswin32/gcanvas.c [deleted file]
cmd/lefty/ws/mswin32/gcommon.c [deleted file]
cmd/lefty/ws/mswin32/gcommon.h [deleted file]
cmd/lefty/ws/mswin32/glabel.c [deleted file]
cmd/lefty/ws/mswin32/gmenu.c [deleted file]
cmd/lefty/ws/mswin32/gpcanvas.c [deleted file]
cmd/lefty/ws/mswin32/gquery.c [deleted file]
cmd/lefty/ws/mswin32/gscroll.c [deleted file]
cmd/lefty/ws/mswin32/gtext.c [deleted file]
cmd/lefty/ws/mswin32/gview.c [deleted file]
cmd/lefty/ws/mswin32/lefty.rc [deleted file]
cmd/lefty/ws/mswin32/resource.h [deleted file]
cmd/lefty/ws/none/garray.c [deleted file]
cmd/lefty/ws/none/gbutton.c [deleted file]
cmd/lefty/ws/none/gcanvas.c [deleted file]
cmd/lefty/ws/none/gcommon.c [deleted file]
cmd/lefty/ws/none/gcommon.h [deleted file]
cmd/lefty/ws/none/glabel.c [deleted file]
cmd/lefty/ws/none/gmenu.c [deleted file]
cmd/lefty/ws/none/gpcanvas.c [deleted file]
cmd/lefty/ws/none/gquery.c [deleted file]
cmd/lefty/ws/none/gscroll.c [deleted file]
cmd/lefty/ws/none/gtext.c [deleted file]
cmd/lefty/ws/none/gview.c [deleted file]
cmd/lefty/ws/x11/garray.c [deleted file]
cmd/lefty/ws/x11/gbutton.c [deleted file]
cmd/lefty/ws/x11/gcanvas.c [deleted file]
cmd/lefty/ws/x11/gcommon.c [deleted file]
cmd/lefty/ws/x11/gcommon.h [deleted file]
cmd/lefty/ws/x11/glabel.c [deleted file]
cmd/lefty/ws/x11/gmenu.c [deleted file]
cmd/lefty/ws/x11/gpcanvas.c [deleted file]
cmd/lefty/ws/x11/gquery.c [deleted file]
cmd/lefty/ws/x11/gscroll.c [deleted file]
cmd/lefty/ws/x11/gtext.c [deleted file]
cmd/lefty/ws/x11/gview.c [deleted file]
cmd/lefty/ws/x11/libfilereq/Dir.c [deleted file]
cmd/lefty/ws/x11/libfilereq/Draw.c [deleted file]
cmd/lefty/ws/x11/libfilereq/Path.c [deleted file]
cmd/lefty/ws/x11/libfilereq/README.selfile [deleted file]
cmd/lefty/ws/x11/libfilereq/SF.h [deleted file]
cmd/lefty/ws/x11/libfilereq/SFDecls.h [deleted file]
cmd/lefty/ws/x11/libfilereq/SFinternal.h [deleted file]
cmd/lefty/ws/x11/libfilereq/SelFile.c [deleted file]
cmd/lefty/ws/x11/libfilereq/xstat.h [deleted file]
cmd/lneato/lneato.1 [deleted file]
cmd/lneato/lneato.bsh [deleted file]
cmd/lneato/lneato.ksh [deleted file]
cmd/lneato/lneato.sh [deleted file]
cmd/lneato/mswin32/doinst [deleted file]
cmd/lneato/mswin32/lneato.c [deleted file]
cmd/lneato/mswin32/lneato.mak [deleted file]

index 5975623319d7a03ab20860c47102be87470c130a..a68d178e8bdb5d7e5f65448916ba2cc7d5bbb4d7 100644 (file)
@@ -130,8 +130,6 @@ tclpkg/gv/swig.mli
 
 ## Files generated by Flex, Bison and Awk
 y.*
-cmd/lefty/dot2l/dotparse.c
-cmd/lefty/dot2l/dotparse.h
 cmd/tools/gmlparse.c
 cmd/tools/gmlparse.h
 cmd/tools/gmlparse.output
@@ -153,14 +151,11 @@ plugin/xlib/vimdot
 ## Binaries
 cmd/dot/dot
 cmd/dot/dot_static
-cmd/dotty/dotty
 cmd/edgepaint/edgepaint
 cmd/gvmap/cluster
 cmd/gvmap/gvmap
 cmd/gvpr/gvpr
 cmd/gvpr/gvpr_static
-cmd/lefty/lefty
-cmd/lneato/lneato
 cmd/mingle/mingle
 cmd/smyrna/smyrna
 cmd/smyrna/smyrna_static
index d03597659fb16a3788b50227b22930ab2746db8c..0b6681771164ef91cf3343fb03304dcf18e85aa2 100644 (file)
@@ -18,7 +18,6 @@ EXCLUDE = (
   "cmd/dot/dot.c",
   "cmd/dot/dot_builtins.cpp",
   "cmd/dot/no_builtins.c",
-  "cmd/dotty/mswin32/dotty.c",
   "cmd/edgepaint/edgepaintmain.c",
   "cmd/gvedit/csettings.cpp",
   "cmd/gvedit/csettings.h",
@@ -39,105 +38,6 @@ EXCLUDE = (
   "cmd/gvmap/power.c",
   "cmd/gvmap/power.h",
   "cmd/gvpr/gvprmain.c",
-  "cmd/lefty/aix_mods/common.h",
-  "cmd/lefty/aix_mods/exec.c",
-  "cmd/lefty/aix_mods/tbl.c",
-  "cmd/lefty/code.c",
-  "cmd/lefty/code.h",
-  "cmd/lefty/common.c",
-  "cmd/lefty/common.h",
-  "cmd/lefty/cs2l/cs2l.c",
-  "cmd/lefty/cs2l/cs2l.h",
-  "cmd/lefty/display.c",
-  "cmd/lefty/display.h",
-  "cmd/lefty/dot2l/dot2l.c",
-  "cmd/lefty/dot2l/dot2l.h",
-  "cmd/lefty/dot2l/dotlex.c",
-  "cmd/lefty/dot2l/dottrie.c",
-  "cmd/lefty/dot2l/triefa.c",
-  "cmd/lefty/dot2l/triefa.h",
-  "cmd/lefty/exec.c",
-  "cmd/lefty/exec.h",
-  "cmd/lefty/g.c",
-  "cmd/lefty/g.h",
-  "cmd/lefty/gfxview.c",
-  "cmd/lefty/gfxview.h",
-  "cmd/lefty/internal.c",
-  "cmd/lefty/internal.h",
-  "cmd/lefty/lefty.c",
-  "cmd/lefty/leftyio.h",
-  "cmd/lefty/lex.c",
-  "cmd/lefty/lex.h",
-  "cmd/lefty/mem.c",
-  "cmd/lefty/mem.h",
-  "cmd/lefty/os/mswin32/io.c",
-  "cmd/lefty/os/unix/io.c",
-  "cmd/lefty/parse.c",
-  "cmd/lefty/parse.h",
-  "cmd/lefty/str.c",
-  "cmd/lefty/str.h",
-  "cmd/lefty/tbl.c",
-  "cmd/lefty/tbl.h",
-  "cmd/lefty/txtview.c",
-  "cmd/lefty/txtview.h",
-  "cmd/lefty/ws/gtk/garray.c",
-  "cmd/lefty/ws/gtk/gbutton.c",
-  "cmd/lefty/ws/gtk/gcanvas.c",
-  "cmd/lefty/ws/gtk/gcommon.c",
-  "cmd/lefty/ws/gtk/gcommon.h",
-  "cmd/lefty/ws/gtk/glabel.c",
-  "cmd/lefty/ws/gtk/gmenu.c",
-  "cmd/lefty/ws/gtk/gpcanvas.c",
-  "cmd/lefty/ws/gtk/gquery.c",
-  "cmd/lefty/ws/gtk/gscroll.c",
-  "cmd/lefty/ws/gtk/gtext.c",
-  "cmd/lefty/ws/gtk/gview.c",
-  "cmd/lefty/ws/mswin32/garray.c",
-  "cmd/lefty/ws/mswin32/gbutton.c",
-  "cmd/lefty/ws/mswin32/gcanvas.c",
-  "cmd/lefty/ws/mswin32/gcommon.c",
-  "cmd/lefty/ws/mswin32/gcommon.h",
-  "cmd/lefty/ws/mswin32/glabel.c",
-  "cmd/lefty/ws/mswin32/gmenu.c",
-  "cmd/lefty/ws/mswin32/gpcanvas.c",
-  "cmd/lefty/ws/mswin32/gquery.c",
-  "cmd/lefty/ws/mswin32/gscroll.c",
-  "cmd/lefty/ws/mswin32/gtext.c",
-  "cmd/lefty/ws/mswin32/gview.c",
-  "cmd/lefty/ws/mswin32/resource.h",
-  "cmd/lefty/ws/none/garray.c",
-  "cmd/lefty/ws/none/gbutton.c",
-  "cmd/lefty/ws/none/gcanvas.c",
-  "cmd/lefty/ws/none/gcommon.c",
-  "cmd/lefty/ws/none/gcommon.h",
-  "cmd/lefty/ws/none/glabel.c",
-  "cmd/lefty/ws/none/gmenu.c",
-  "cmd/lefty/ws/none/gpcanvas.c",
-  "cmd/lefty/ws/none/gquery.c",
-  "cmd/lefty/ws/none/gscroll.c",
-  "cmd/lefty/ws/none/gtext.c",
-  "cmd/lefty/ws/none/gview.c",
-  "cmd/lefty/ws/x11/garray.c",
-  "cmd/lefty/ws/x11/gbutton.c",
-  "cmd/lefty/ws/x11/gcanvas.c",
-  "cmd/lefty/ws/x11/gcommon.c",
-  "cmd/lefty/ws/x11/gcommon.h",
-  "cmd/lefty/ws/x11/glabel.c",
-  "cmd/lefty/ws/x11/gmenu.c",
-  "cmd/lefty/ws/x11/gpcanvas.c",
-  "cmd/lefty/ws/x11/gquery.c",
-  "cmd/lefty/ws/x11/gscroll.c",
-  "cmd/lefty/ws/x11/gtext.c",
-  "cmd/lefty/ws/x11/gview.c",
-  "cmd/lefty/ws/x11/libfilereq/Dir.c",
-  "cmd/lefty/ws/x11/libfilereq/Draw.c",
-  "cmd/lefty/ws/x11/libfilereq/Path.c",
-  "cmd/lefty/ws/x11/libfilereq/SF.h",
-  "cmd/lefty/ws/x11/libfilereq/SFDecls.h",
-  "cmd/lefty/ws/x11/libfilereq/SFinternal.h",
-  "cmd/lefty/ws/x11/libfilereq/SelFile.c",
-  "cmd/lefty/ws/x11/libfilereq/xstat.h",
-  "cmd/lneato/mswin32/lneato.c",
   "cmd/mingle/minglemain.cpp",
   "cmd/smyrna/arcball.c",
   "cmd/smyrna/arcball.h",
diff --git a/cmd/dotty/dotty.1 b/cmd/dotty/dotty.1
deleted file mode 100644 (file)
index 53c5cf0..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-.TH DOTTY 1
-.SH NAME
-dotty \- A Customizable Graph Editor
-.SH SYNOPSIS
-.B dotty
-[
-.B -V
-] [
-.BI -lm mode
-] [
-.BI -el lev
-] [
-.I file
-]
-.SH DESCRIPTION
-.B dotty
-is a graph editor for the X Window System.  It may be run as a standalone
-editor, or as a front end for applications that use graphs.  It can control
-multiple windows viewing different graphs.
-
-.B dotty
-is written on top of
-.B dot
-and
-.BR lefty .
-.B lefty
-is a general-purpose programmable editor for technical pictures.  It has an
-interpretive programming language similar to AWK and C.  The user interface and
-graph editing operations of
-.B dotty
-are written as
-.B lefty
-functions.
-Programmer-defined graph operations may be loaded as well.  Graph layouts are
-made by
-.BR dot ,
-which runs as a separate process that communicates with
-.B lefty
-through pipes.
-
-If the input graph contains xdot attributes,
-.B dotty
-will use that to display the graph. Otherwise, it runs
-.B dot
-to obtain layout information.
-.SH USAGE
-The file name is optional. If present, the graph contained in that file is
-displayed in the
-.B dotty
-window.
-.SH OPTIONS
-.TP
-.B -V
-Prints the version.
-.TP
-.BI -lm mode
-Sets the layout mode. The \fImode\fP can be \fBsync\fP or \fBasync\fP. The default is \fBasync\fP.
-.TP
-.BI -el lev
-Sets the mesage level. The \fIlev\fP can be \fB0\fP or \fB1\fP. The default is \fB0\fP.
-.SH BUGS
-The lefty parser does not accept anonymous graphs.
-.SH SEE ALSO
-dot(1), lefty(1), lneato(1), xdot(3)
-.br
-.I dotty
-user guide.
diff --git a/cmd/dotty/dotty.bsh b/cmd/dotty/dotty.bsh
deleted file mode 100755 (executable)
index 55a13f3..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/sh
-
-FILES=""
-MLEVEL="0"
-LMODE="async"
-
-usage='echo usage: dotty [-V] [-lm (sync|async)] [-el (0|1)] <filename>'
-
-if [ "x$DOTTYOPTIONS" != "x" ]; then
-    set -- $DOTTYOPTIONS $*
-fi
-
-while [ "x$1" != 'x' ]; do
-    case $1 in
-    -V)
-        echo "dotty version 96c (09-24-96)"
-        shift
-        ;;
-    -f)
-        shift
-        loadfile=$1
-        shift
-        ;;
-    -lm)
-        shift
-        LMODE=$1
-        if [ "x$LMODE" != 'xsync' -a "x$LMODE" != 'xasync' ]; then
-            $usage
-            exit 1
-        fi
-        shift
-        ;;
-    -el)
-        shift
-        MLEVEL=$1
-        if [ "x$MLEVEL" != 'x0' -a "x$MLEVEL" != 'x1' ]; then
-            $usage
-            exit 1
-        fi
-        shift
-        ;;
-    -)
-        FILES=`echo $FILES \"$1\"`
-        shift
-        ;;
-    -*)
-        $usage
-        exit 1
-        ;;
-    *)
-        FILES=`echo $FILES \"$1\"`
-        shift
-        ;;
-    esac
-done
-
-if [ "x$DOTTYPATH" != 'x' ]; then
-    LEFTYPATH="$DOTTYPATH:$LEFTYPATH"
-fi
-
-CMDS=""
-
-CMDS="dotty.protogt.layoutmode = '$LMODE';"
-
-CMDS=`echo $CMDS dotty.mlevel = $MLEVEL";"`
-
-if [ "x$loadfile" != 'x' ]; then
-    CMDS=`echo $CMDS load \("'"$loadfile"'"\)";"`
-fi
-
-if [ "x$FILES" = 'x' ]; then
-    FILES=null
-fi
-FUNC="dotty.createviewandgraph"
-for i in $FILES; do
-    CMDS=`echo $CMDS $FUNC \($i, "'"file"'", null, null\)";"`
-done
-
-leftypath=`which lefty`
-if [ ! -f "$leftypath" ]; then
-    echo "dotty: cannot locate the lefty program"
-    echo "       make sure that your path includes"
-    echo "       the directory containing dotty and lefty"
-    exit 1
-fi
-
-$leftypath -e "
-load ('dotty.lefty');
-checkpath = function () {
-    if (tablesize (dotty) > 0)
-        remove ('checkpath');
-    else {
-        echo ('dotty: cannot locate the dotty scripts');
-        echo ('       make sure that the environment variable LEFTYPATH');
-        echo ('       is set to the directory containing dotty.lefty');
-        exit ();
-    }
-};
-checkpath ();
-dotty.init ();
-monitorfile = dotty.monitorfile;
-$CMDS
-txtview ('off');
-"
diff --git a/cmd/dotty/dotty.ksh b/cmd/dotty/dotty.ksh
deleted file mode 100755 (executable)
index 3bb2b16..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-
-set -A FILES
-MLEVEL="0"
-LMODE="async"
-FLAGS=
-
-function usage {
-    print "usage: dotty [-V] [-lm (sync|async)] [-el (0|1)] <filename>"
-}
-
-function processoptions {
-    while [[ $# > 0 ]] do
-        case $1 in
-        -V)
-            print "dotty version 96c (09-24-96)"
-                       FLAGS=$FLAGS" -V"
-            shift
-            ;;
-        -f)
-            shift
-            loadfile=$1
-            shift
-            ;;
-        -lt)
-            shift
-            layouttool=$1
-            shift
-            ;;
-        -lm)
-            shift
-            LMODE=$1
-            if [[ $LMODE != 'sync' && $LMODE != 'async' ]] then
-                usage
-                exit 1
-            fi
-            shift
-            ;;
-        -el)
-            shift
-            MLEVEL=$1
-            if [[ $MLEVEL != '0' && $MLEVEL != '1' ]] then
-                usage
-                exit 1
-            fi
-            shift
-            ;;
-        -)
-            FILES[${#FILES[@]}]="'"$1"'"
-            shift
-            ;;
-        -*)
-            usage
-            exit 1
-            ;;
-        *)
-            FILES[${#FILES[@]}]="'"$1"'"
-            shift
-            ;;
-        esac
-    done
-}
-
-if [[ $DOTTYOPTIONS != '' ]] then
-    processoptions $DOTTYOPTIONS
-fi
-processoptions "$@"
-
-if [[ $DOTTYPATH != '' ]] then
-    export LEFTYPATH="$DOTTYPATH:$LEFTYPATH"
-fi
-
-CMDS=""
-
-CMDS="dotty.protogt.layoutmode = '$LMODE';"
-
-CMDS=$(print $CMDS dotty.mlevel = $MLEVEL";")
-
-if [[ $loadfile != '' ]] then
-    CMDS=$(print $CMDS load \("'"$loadfile"'"\)";")
-fi
-
-if [[ $layouttool != '' ]] then
-    CMDS=$(print $CMDS dotty.protogt.lserver = "'$layouttool';")
-fi
-
-if [[ $FILES = '' ]] then
-    FILES=null
-fi
-FUNC="dotty.createviewandgraph"
-for i in "${FILES[@]}"; do
-    CMDS=$(print $CMDS $FUNC \($i, "'"file"'", null, null\)";")
-done
-
-leftypath=$(whence -p lefty)
-if [[ $leftypath == '' ]] then
-    print -u2 "dotty: cannot locate the lefty program"
-    print -u2 "       make sure that your path includes"
-    print -u2 "       the directory containing dotty and lefty"
-    exit 1
-fi
-
-$leftypath $FLAGS -e "
-load ('dotty.lefty');
-checkpath = function () {
-    if (tablesize (dotty) > 0)
-        remove ('checkpath');
-    else {
-        echo ('dotty: cannot locate the dotty scripts');
-        echo ('       make sure that the environment variable LEFTYPATH');
-        echo ('       is set to the directory containing dotty.lefty');
-        exit ();
-    }
-};
-checkpath ();
-dotty.init ();
-monitorfile = dotty.monitorfile;
-$CMDS
-txtview ('off');
-"
diff --git a/cmd/dotty/dotty.lefty b/cmd/dotty/dotty.lefty
deleted file mode 100644 (file)
index d306f7b..0000000
+++ /dev/null
@@ -1,748 +0,0 @@
-#
-# DOTTY
-#
-dotty = [
-    'keys' = [
-        'nid'    = 'nid';
-        'eid'    = 'eid';
-        'gid'    = 'gid';
-        'name'   = 'name';
-        'attr'   = 'attr';
-        'gattr'  = 'graphattr';
-        'eattr'  = 'edgeattr';
-        'nattr'  = 'nodeattr';
-        'edges'  = 'edges';
-        'tail'   = 'tail';
-        'tport'  = 'tport';
-        'head'   = 'head';
-        'hport'  = 'hport';
-        'pos'    = 'pos';
-        'size'   = 'size';
-        'rect'   = 'rect';
-        'fname'  = 'fontname';
-        'fsize'  = 'fontsize';
-        'fcolor' = 'fontcolor';
-        'dcolor' = 'drawcolor';
-        'bcolor' = 'fillcolor';
-    ];
-    'maps' = [
-        'X11' = [
-            'fontmap' = [
-                'Times-Roman'    = '-*-times-medium-r-*--%d-*-*-*-*-*-*-1';
-                'Times-Italic'   = '-*-times-medium-i-*--%d-*-*-*-*-*-*-1';
-                'Times-Bold'     = '-*-times-bold-r-*--%d-*-*-*-*-*-*-1';
-                'Courier'        = '-*-courier-bold-r-*--%d-*-*-*-*-*-*-1';
-                'Courier-Bold'   = '-*-courier-bold-r-*--%d-*-*-*-*-*-*-1';
-                'Helvetica'      = (
-                     '-*-helvetica-medium-r-normal--%d-*-*-*-p-*-iso8859-1'
-                );
-                'Helvetica-Bold' = (
-                    '-*-helvetica-bold-r-normal--%d-*-*-*-p-*-iso8859-1'
-                );
-            ];
-            'psfontmap' = [
-                'Times-Roman'    = 'Times-Roman';
-                'Times-Italic'   = 'Times-Italic';
-                'Times-Bold'     = 'Times-Bold';
-                'Courier'        = 'Courier';
-                'Courier-Bold'   = 'Courier-Bold';
-                'Helvetica'      = 'Helvetica';
-                'Helvetica-Bold' = 'Helvetica-Bold';
-            ];
-        ];
-        'mswin' = [
-            'fontmap' = [
-                'Times-Roman'    = 'Times New Roman';
-                'Times-Italic'   = 'Times New Roman Italic';
-                'Times-Bold'     = 'Times New Roman Bold';
-                'Courier'        = 'Courier New';
-                'Courier-Bold'   = 'Courier New Bold';
-                'Helvetica'      = 'Arial';
-                'Helvetica-Bold' = 'Arial Bold';
-            ];
-            'psfontmap' = [
-                'Times-Roman'    = 'Times New Roman';
-                'Times-Italic'   = 'Times New Roman Italic';
-                'Times-Bold'     = 'Times New Roman Bold';
-                'Courier'        = 'Courier New';
-                'Courier-Bold'   = 'Courier New Bold';
-                'Helvetica'      = 'Arial';
-                'Helvetica-Bold' = 'Arial Bold';
-            ];
-        ];
-    ];
-    'protogt' = [
-        'graph' = [
-            'graphattr' = [
-                'fontsize' = '14';
-                'fontname' = 'Times-Roman';
-                'fontcolor' = 'black';
-            ];
-            'nodeattr' = [
-                'shape' = 'ellipse';
-                'fontsize' = '14';
-                'fontname' = 'Times-Roman';
-                'fontcolor' = 'black';
-                'style' = 'solid';
-            ];
-            'edgeattr' = [
-                'fontsize' = '14';
-                'fontname' = 'Times-Roman';
-                'fontcolor' = 'black';
-                'style' = 'solid';
-            ];
-            'graphdict' = [];
-            'nodedict' = [];
-            'graphs' = [];
-            'nodes' = [];
-            'edges' = [];
-            'maxgid' = 0;
-            'maxnid' = 0;
-            'maxeid' = 0;
-            'type' = 'digraph';
-        ];
-        'layoutmode' = 'sync';
-        'lserver' = 'dot';
-        'edgehandles' = 1;
-        'noundo' = 0;
-    ];
-    'lservers' = [];
-    'mlevel' = 0;
-    'graphs' = [];
-    'views' = [];
-    'protovt' = [
-        'normal' = [
-            'name' = 'DOTTY';
-            'orig' = ['x' = 1; 'y' = 1;];
-            'size' = ['x' = 420; 'y' = 520;];
-            'wrect' = [
-                0 = ['x' = 0; 'y' = 0;];
-                1 = ['x' = 400; 'y' = 500;];
-            ];
-            'vsize' = ['x' = 400; 'y' = 500;];
-            'w2v' = 1;
-        ];
-        'birdseye' = [
-            'type' = 'birdseye';
-            'name' = 'DOTTY birdseye view';
-            'orig' = ['x' = 1; 'y' = 1;];
-            'size' = ['x' = 220; 'y' = 260;];
-            'wrect' = [
-                0 = ['x' = 0; 'y' = 0;];
-                1 = ['x' = 200; 'y' = 250;];
-            ];
-            'vsize' = ['x' = 200; 'y' = 250;];
-            'w2v' = 1;
-        ];
-    ];
-    'pagesizes' = [
-        '8.5x11' = ['x' =    8; 'y' = 10.5;];
-        '11x17'  = ['x' = 10.5; 'y' = 16.5;];
-        '36x50'  = ['x' = 35.5; 'y' = 49.5;];
-    ];
-];
-load ('dotty_draw.lefty');
-load ('dotty_edit.lefty');
-load ('dotty_layout.lefty');
-load ('dotty_ui.lefty');
-#
-# initialization functions
-#
-dotty.init = function () {
-    dotty.fontmap = dotty.maps[getenv ('LEFTYWINSYS')].fontmap;
-    dotty.clipgt = dotty.protogt.creategraph (['noundo' = 1;]);
-    dotty.inited = 1;
-};
-dotty.simple = function (file) {
-    if (dotty.inited ~= 1)
-        dotty.init ();
-    dotty.createviewandgraph (file, 'file', null, null);
-    txtview ('off');
-};
-#
-# main operations
-#
-dotty.protogt.creategraph = function (protogt) {
-    local gt, id, gtid;
-
-    if (~protogt)
-        protogt = dotty.protogt;
-    for (gtid = 0; dotty.graphs[gtid]; gtid = gtid + 1)
-        ;
-    gt = (dotty.graphs[gtid] = []);
-    if (protogt.mode ~= 'replace') {
-        for (id in dotty.protogt)
-            gt[id] = copy (dotty.protogt[id]);
-    }
-    for (id in protogt)
-        gt[id] = copy (protogt[id]);
-    gt.gtid = gtid;
-    gt.views = [];
-    gt.undoarray = ['level' = 0; 'entries' = [];];
-    gt.busy = 0;
-    return gt;
-};
-dotty.protogt.copygraph = function (ogt) {
-    local gt, gtid, id;
-
-    for (gtid = 0; dotty.graphs[gtid]; gtid = gtid + 1)
-        ;
-    gt = (dotty.graphs[gtid] = []);
-    for (id in ogt)
-        gt[id] = copy (ogt[id]);
-    gt.gtid = gtid;
-    gt.views = [];
-    gt.undoarray = ['level' = 0; 'entries' = [];];
-    gt.busy = 0;
-    return gt;
-};
-dotty.protogt.destroygraph = function (gt) {
-    local vid, vlist;
-
-    if (gt.layoutpending > 0)
-        gt.cancellayout (gt);
-    for (vid in gt.views)
-        vlist[vid] = gt.views[vid];
-    for (vid in gt.views)
-        gt.destroyview (gt, vlist[vid]);
-    remove (gt.gtid, dotty.graphs);
-};
-dotty.protogt.loadgraph = function (gt, name, type, protograph, layoutflag) {
-    local fd, vid, vt, graph, nid, eid, gid;
-
-    if (gt.layoutpending > 0)
-        gt.cancellayout (gt);
-    if (~name)
-        if (~(name = ask ('file name:', 'file', '')))
-            return;
-    dotty.pushbusy (gt, gt.views);
-    dotty.message (1, 'loading');
-    if (~protograph)
-        protograph = dotty.protogt.graph;
-    if (
-        ~((fd = dotty.openio (name, type, 'r')) >= 0) |
-        ~(graph = readgraph (fd, protograph))
-    ) {
-        dotty.message (0, 'cannot load graph');
-        dotty.popbusy (gt, gt.views);
-        return;
-    }
-    for (vid in gt.views) {
-        vt = gt.views[vid];
-        vt.colors = [];
-        vt.colorn = 2;
-    }
-    gt.graph = graph;
-    gt.name = name;
-    gt.type = type;
-    gt.undoarray = ['level' = 0; 'entries' = [];];
-    if (~(type == 'file' & name == '-'))
-        closeio (fd);
-    graph.maxgid = tablesize (graph.graphs);
-    graph.maxnid = tablesize (graph.nodes);
-    graph.maxeid = tablesize (graph.edges);
-    for (nid in graph.nodes)
-        graph.nodes[nid][dotty.keys.nid] = nid;
-    for (eid in graph.edges)
-        graph.edges[eid][dotty.keys.eid] = eid;
-    for (gid in graph.graphs)
-        graph.graphs[gid][dotty.keys.gid] = gid;
-    gt.unpackattr (gt);
-    if (layoutflag) {
-        dotty.message (1, 'generating layout');
-        gt.layoutgraph (gt);
-    }
-    dotty.popbusy (gt, gt.views);
-    return gt.graph;
-};
-dotty.protogt.savegraph = function (gt, name, type) {
-    local fd;
-
-    if (~name)
-        if (~(name = ask ('file name:', 'file', '')))
-            return;
-    if (
-        ~((fd = dotty.openio (name, type, 'w')) >= 0) |
-        ~writegraph (fd, gt.graph, 0)
-    ) {
-        dotty.message (0, 'cannot save graph');
-        return;
-    }
-    if (~(type == 'file' & name == '-'))
-        closeio (fd);
-};
-dotty.protogt.setgraph = function (gt, graph) {
-    local vid, vt, nid, eid, gid;
-
-    if (gt.layoutpending > 0)
-        gt.cancellayout (gt);
-    for (vid in gt.views) {
-        vt = gt.views[vid];
-        vt.colors = [];
-        vt.colorn = 2;
-    }
-    gt.graph = copy (graph);
-    gt.undoarray = ['level' = 0; 'entries' = [];];
-    gt.unpackattr (gt);
-    gt.graph.maxgid = tablesize (graph.graphs);
-    gt.graph.maxnid = tablesize (graph.nodes);
-    gt.graph.maxeid = tablesize (graph.edges);
-    for (nid in gt.graph.nodes)
-        gt.graph.nodes[nid][dotty.keys.nid] = nid;
-    for (eid in gt.graph.edges)
-        gt.graph.edges[eid][dotty.keys.eid] = eid;
-    for (gid in gt.graph.graphs)
-        gt.graph.graphs[gid][dotty.keys.gid] = gid;
-    gt.unpackattr (gt);
-    dotty.message (1, 'generating layout');
-    gt.layoutgraph (gt);
-    return gt.graph;
-};
-dotty.protogt.erasegraph = function (gt, protogt, protovt) {
-    local vid, vt;
-
-    if (gt.layoutpending > 0)
-        gt.cancellayout (gt);
-    for (vid in gt.views) {
-        vt = gt.views[vid];
-        vt.colors = [];
-        vt.colorn = 2;
-        clear (vt.canvas);
-    }
-    if (~protogt)
-        protogt = dotty.protogt;
-    gt.graph = copy (protogt.graph);
-    gt.undoarray = ['level' = 0; 'entries' = [];];
-};
-dotty.protogt.layoutgraph = function (gt) {
-    if (gt.graph.graphattr.xdotversion) {
-        gt.unpacklayout (gt, gt.graph);
-        gt.setviewsize (gt.views, gt.graph.rect);
-        gt.redrawgraph (gt, gt.views);
-        return;
-    }
-    if (gt.layoutmode == 'async') {
-        if (~gt.haveinput) {
-            gt.startlayout (gt);
-            return;
-        }
-        if (~gt.finishlayout (gt))
-            return;
-        gt.setviewsize (gt.views, gt.graph.rect);
-        gt.redrawgraph (gt, gt.views);
-    } else {
-        if (~gt.startlayout (gt))
-            return;
-        else
-            while (~gt.finishlayout (gt))
-                ;
-        gt.setviewsize (gt.views, gt.graph.rect);
-        gt.redrawgraph (gt, gt.views);
-    }
-};
-dotty.protogt.createview = function (gt, protovt) {
-    local vt, ovt, id, t;
-
-    vt = [];
-    vt.colors = [];
-    vt.colorn = 2;
-    if (~protovt)
-        protovt = dotty.protovt.normal;
-    if (protovt.mode ~= 'replace') {
-        for (id in dotty.protovt[protovt.type])
-            vt[id] = copy (dotty.protovt[protovt.type][id]);
-    }
-    for (id in protovt)
-        vt[id] = copy (protovt[id]);
-    if (~(vt.parent >= 0)) {
-        vt.view = createwidget (-1, [
-            'type'   = 'view';
-            'name'   = vt.name;
-            'origin' = vt.orig;
-            'size'   = vt.size;
-        ]);
-        vt.scroll = createwidget (vt.view, ['type' = 'scroll';]);
-    } else {
-        vt.view = -1;
-        vt.scroll = createwidget (vt.parent, [
-            'type' = 'scroll';
-            'size' = vt.size;
-        ]);
-    }
-    vt.canvas = createwidget (vt.scroll, [
-        'type' = 'canvas';
-        'color' = [0 = protovt.bgcolor; 1 = protovt.fgcolor;];
-    ]);
-    setwidgetattr (vt.canvas, [
-        'window' = vt.wrect;
-        'viewport' = vt.vsize;
-    ]);
-    clear (vt.canvas);
-    dotty.views[vt.canvas] = vt;
-    vt.vtid = vt.canvas;
-    vt.gtid = gt.gtid;
-    gt.views[vt.vtid] = vt;
-    dotty.views[vt.scroll] = vt;
-    if (vt.view ~= -1)
-        dotty.views[vt.view] = vt;
-    if (protovt.colors & tablesize (protovt.colors) > 0) {
-        for (id in protovt.colors)
-            if (id == '_bgcolor_')
-                setwidgetattr (vt.canvas, [
-                    'color' = [0 = protovt.colors[id];];
-                ]);
-            else if (setwidgetattr (vt.canvas, ['color' = [
-                protovt.colors[id] = id;
-            ];]) ~= 1) {
-                t = split (id, ' ');
-                if (tablesize (t) ~= 3 | setwidgetattr (vt.canvas, [
-                    'color' = [protovt.colors[id] = [
-                        'h' = ston (t[0]); 's' = ston (t[1]); 'v' = ston (t[2]);
-                    ];];
-                ]) ~= 1) {
-                    dotty.message (
-                        0, concat ('unknown color ', id, ' using #1')
-                    );
-                }
-            }
-        vt.colors = copy (protovt.colors);
-        vt.colorn = protovt.colorn;
-    } else if (tablesize (gt.views) > 1) {
-        for (id in gt.views)
-            if (gt.views[id] ~= vt)
-                break;
-        ovt = gt.views[id];
-        for (id in ovt.colors)
-            if (id == '_bgcolor_')
-                setwidgetattr (vt.canvas, ['color' = [0 = ovt.colors[id];];]);
-            else if (setwidgetattr (vt.canvas, ['color' = [
-                ovt.colors[id] = id;
-            ];]) ~= 1) {
-                t = split (id, ' ');
-                if (tablesize (t) ~= 3 | setwidgetattr (vt.canvas, [
-                    'color' = [ovt.colors[id] = [
-                        'h' = ston (t[0]); 's' = ston (t[1]); 'v' = ston (t[2]);
-                    ];];
-                ]) ~= 1) {
-                    dotty.message (
-                        0, concat ('unknown color ', id, ' using #1')
-                    );
-                }
-            }
-        vt.colors = copy (ovt.colors);
-        vt.colorn = ovt.colorn;
-    }
-    if (gt.graph.rect)
-        gt.setviewsize ([vt.vtid = vt;], gt.graph.rect);
-    gt.drawgraph (gt, [vt.vtid = vt;]);
-    for (id in vt.uifuncs)
-        if (id == 'closeview')
-            widgets[vt.view][id] = vt.uifuncs[id];
-        else
-            widgets[vt.canvas][id] = vt.uifuncs[id];
-    return vt;
-};
-dotty.protogt.destroyview = function (gt, vt) {
-    destroywidget (vt.canvas);
-    destroywidget (vt.scroll);
-    if (vt.view ~= -1) {
-        destroywidget (vt.view);
-        remove (vt.view, dotty.views);
-    }
-    remove (vt.scroll, dotty.views);
-    remove (vt.canvas, dotty.views);
-    if (vt.gtid >= 0)
-        remove (vt.vtid, gt.views);
-    if (tablesize (dotty.views) == 0)
-        exit ();
-};
-dotty.protogt.zoom = function (gt, vt, factor, pos) {
-    gt.setviewscale ([vt.vtid = vt;], factor);
-    if (pos)
-        gt.setviewcenter ([vt.vtid = vt;], pos);
-    gt.redrawgraph (gt, [vt.vtid = vt;]);
-};
-dotty.protogt.findnode = function (gt, vt) {
-    local key, node, node1, nid;
-
-    if (~(key = ask ('give node name or label')))
-        return;
-    if (gt.graph.nodedict[key] >= 0)
-        node = gt.graph.nodes[gt.graph.nodedict[key]];
-    else if (gt.graph.nodedict[ston (key)] >= 0)
-        node = gt.graph.nodes[gt.graph.nodedict[ston (key)]];
-    else {
-        for (nid in gt.graph.nodes) {
-            node1 = gt.graph.nodes[nid];
-            if (node1.attr.label == key | node1.attr.label == ston (key)) {
-                node = node1;
-                break;
-            }
-        }
-    }
-    if (~node) {
-        dotty.message (0, concat ('cannot find node: ', key));
-        return;
-    }
-    gt.setviewcenter ([vt.vtid = vt;], node.pos);
-};
-dotty.protogt.setattr = function (gt, obj) {
-    local kv, t, attr, value, n, i, s;
-
-    if (~(kv = ask ('give attr/value, eg. color=blue')))
-        return;
-    t = split (kv, '=');
-    attr = t[0];
-    value = t[1];
-    if ((n = tablesize (t)) > 2)
-        for (i = 2; i < n; i = i + 1)
-            value = concat (value, '=', t[i]);
-    # Check for HTML string and convert using lefty convention
-    s = split (value, '');
-    n = tablesize (s);
-    if ((s[0] == '<') & (s[n-1] == '>')) {
-        s[0] = '>';
-        s[n-1] = '<';
-        value = s[0]; 
-        for (i = 1; i < n; i = i + 1)
-            value = concat (value, s[i]);
-    }
-    if (
-        obj.attr == gt.graph.graphattr |
-        obj.attr == gt.graph.edgeattr |
-        obj.attr == gt.graph.nodeattr
-    ) {
-        obj.attr[attr] = value;
-        return;
-    }
-    if (obj.nid >= 0) {
-        gt.undrawnode (gt, gt.views, obj);
-        obj.attr[attr] = value;
-        gt.unpacknodeattr (gt, obj);
-        gt.drawnode (gt, gt.views, obj);
-    } else if (obj.eid >= 0) {
-        gt.undrawedge (gt, gt.views, obj);
-        obj.attr[attr] = value;
-        gt.unpackedgeattr (gt, obj);
-        gt.drawedge (gt, gt.views, obj);
-    }
-};
-dotty.protogt.getattr = function (gt, node) {
-    local kv;
-
-    if (~(kv.key = ask ('give attr name')))
-        return null;
-    if ((kv.val = node.attr[kv.key]))
-        return kv;
-    return null;
-};
-#
-# utilities
-#
-dotty.createviewandgraph = function (name, type, protogt, protovt) {
-    local vt, gt;
-
-    if (~protogt)
-        protogt = dotty.protogt;
-    if (protogt.creategraph)
-        gt = protogt.creategraph (protogt);
-    else
-        gt = dotty.protogt.creategraph (protogt);
-    vt = gt.createview (gt, protovt);
-    if (~protogt.graph)
-        protogt.graph = copy (dotty.protogt.graph);
-    if (name)
-        gt.loadgraph (gt, name, type, protogt.graph, 1);
-    return ['gt' = gt; 'vt' = vt;];
-};
-dotty.openio = function (name, type, mode) {
-    local fd;
-
-    if (~name)
-        return null;
-    if (type == 'file') {
-        if (name == '-') {
-            if (mode == 'r' | mode == 'r+')
-                fd = 0;
-            else
-                fd = 1;
-        } else if (~((fd = openio ('file', name, mode)) >= 0)) {
-            dotty.message (0, concat ('cannot open file: ', name));
-            return null;
-        }
-    } else if (type == 'pipe') {
-        if (~((fd = openio (
-            'pipe', 'ksh', mode, concat ("%e ", name)
-        )) >= 0)) {
-            dotty.message (0, concat ('cannot run command: ', name));
-            return null;
-        }
-    } else
-        return null;
-    return fd;
-};
-dotty.pushbusy = function (gt, views) {
-    local vid;
-
-    if (gt.busy == 0)
-        for (vid in gt.views)
-            setwidgetattr (vid, ['cursor' = 'watch';]);
-    gt.busy = gt.busy + 1;
-};
-dotty.popbusy = function (gt, views) {
-    local vid;
-
-    gt.busy = gt.busy - 1;
-    if (gt.busy == 0)
-        for (vid in gt.views)
-            setwidgetattr (vid, ['cursor' = 'default';]);
-};
-dotty.message = function (level, text) {
-    if (level <= dotty.mlevel)
-        echo ('dotty.lefty: ', text);
-};
-#
-# printing or saving to file
-#
-dotty.protogt.printorsave = function (gt, vt, otype, name, mode, ptype) {
-    local pr, wrect, vsize, xy, psize, canvas, pscanvas, cid, cname, t;
-    local graph, edgehandles, fontmap, eid, edge, nid, node, gid, sgraph;
-    local did, draw, i;
-
-    if (~otype)
-        if (~(otype = ask ('print to', 'choice', 'file|printer')))
-            return;
-    if (otype == 'printer') {
-        if (~getenv ('TMPDIR'))
-            name = concat (getenv ('HOME'), '/.dottyout.ps');
-        else
-            name = concat (getenv ('TMPDIR'), '/.dottyout.ps', random (10000));
-        if (getenv ('LEFTYWINSYS') ~= 'mswin' & ~pr)
-            if (~(pr = ask ('printer command', 'string', 'lpr')))
-                return;
-    }
-    if (~name)
-        if (~(name = ask ('postscript file', 'file', 'out.ps')))
-            return;
-    if (~ptype)
-        if (~(ptype = ask ('page size', 'choice', '8.5x11|11x17|36x50')))
-            return;
-    if (~mode)
-        if (~(mode = ask ('mode', 'choice', 'portrait|landscape|best fit')))
-            return;
-    wrect = copy (vt.wrect);
-    wrect[0].x = wrect[0].x - 1;
-    wrect[1].x = wrect[1].x + 1;
-    wrect[0].y = wrect[0].y - 1;
-    wrect[1].y = wrect[1].y + 1;
-    vsize = copy (vt.vsize);
-    if (vsize.x == 0)
-        vsize.x = 1;
-    if (vsize.y == 0)
-        vsize.y = 1;
-    xy = vsize.x / vsize.y;
-    if (mode == 'best fit') {
-        if (xy < 1)
-            mode = 'portrait';
-        else
-            mode = 'landscape';
-    }
-    psize = dotty.pagesizes[ptype];
-    if (mode == 'portrait') {
-        if (xy < psize.x / psize.y) {
-            vsize.y = psize.y * 300;
-            vsize.x = vsize.y * xy;
-        } else {
-            vsize.x = psize.x * 300;
-            vsize.y = vsize.x / xy;
-        }
-    } else {
-        if (xy < psize.y / psize.x) {
-            vsize.y = psize.x * 300;
-            vsize.x = vsize.y * xy;
-        } else {
-            vsize.x = psize.y * 300;
-            vsize.y = vsize.x / xy;
-        }
-    }
-    if (~((pscanvas = createwidget (-1, [
-        'type'   = 'ps';
-        'origin' = ['x' = 0; 'y' = 0;];
-        'size'   = vsize;
-        'mode'   = mode;
-        'name'   = name;
-    ])) >= 0)) {
-        dotty.message (0, 'cannot open printer device');
-        return;
-    }
-    for (cname in vt.colors) {
-        cid = vt.colors[cname];
-        if (cname == '_bgcolor_')
-            setwidgetattr (pscanvas, ['color' = [0 = cid;];]);
-        else if (setwidgetattr (pscanvas, ['color' = [cid = cname;];]) ~= 1) {
-            t = split (cname, ' ');
-            if (tablesize (t) ~= 3 | setwidgetattr (pscanvas, [
-                'color' = [cid = [
-                    'h' = ston (t[0]); 's' = ston (t[1]); 'v' = ston (t[2]);
-                ];];
-            ]) ~= 1) {
-                dotty.message (
-                    0, concat ('unknown color ', cname, ' using #1')
-                );
-            }
-        }
-    }
-    setwidgetattr (pscanvas, ['window' = wrect;]);
-    graph = copy (gt.graph);
-    canvas = vt.canvas;
-    vt.canvas = pscanvas;
-    edgehandles = gt.edgehandles;
-    gt.edgehandles = 0;
-    fontmap = dotty.maps[getenv ('LEFTYWINSYS')].psfontmap;
-    for (eid in graph.edges) {
-        edge = graph.edges[eid];
-        edge.fontname = fontmap[edge.attr.fontname];
-        for (did in edge.draws) {
-            if (did == 'ep')
-                continue;
-            draw = edge.draws[did];
-            for (i = 0; draw[i]; i = i + 1)
-                if (draw[i].type == 'F')
-                    draw[i].fn = fontmap[draw[i].ofn];
-        }
-        gt.drawedge (gt, [0 = vt;], edge);
-    }
-    for (nid in graph.nodes) {
-        node = graph.nodes[nid];
-        node.fontname = fontmap[node.attr.fontname];
-        for (did in node.draws) {
-            if (did == 'ep')
-                continue;
-            draw = node.draws[did];
-            for (i = 0; draw[i]; i = i + 1)
-                if (draw[i].type == 'F')
-                    draw[i].fn = fontmap[draw[i].ofn];
-        }
-        gt.drawnode (gt, [0 = vt;], node);
-    }
-    for (gid in graph.graphs) {
-        sgraph = graph.graphs[gid];
-        sgraph.fontname = fontmap[sgraph.graphattr.fontname];
-        for (did in sgraph.draws) {
-            if (did == 'ep')
-                continue;
-            draw = sgraph.draws[did];
-            for (i = 0; draw[i]; i = i + 1)
-                if (draw[i].type == 'F')
-                    draw[i].fn = fontmap[draw[i].ofn];
-        }
-        gt.drawsgraph (gt, [0 = vt;], sgraph);
-    }
-    graph.fontname = fontmap[graph.graphattr.fontname];
-    gt.drawsgraph (gt, [0 = vt;], graph);
-    gt.edgehandles = edgehandles;
-    vt.canvas = canvas;
-    destroywidget (pscanvas);
-    if (otype == 'printer' & getenv ('LEFTYWINSYS') ~= 'mswin')
-        system (concat (pr, ' ', name, '; rm ',name));
-};
diff --git a/cmd/dotty/dotty.sh b/cmd/dotty/dotty.sh
deleted file mode 100755 (executable)
index 6e334bc..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-#!/bin/sh
-
-FILES=""
-MLEVEL="0"
-LMODE="async"
-FLAGS=
-
-usage='echo usage: dotty [-V] [-lm (sync|async)] [-el (0|1)] <filename>'
-
-if [ "x$DOTTYOPTIONS" != "x" ]; then
-    set -- $DOTTYOPTIONS $*
-fi
-
-while [ "x$1" != 'x' ]; do
-    case $1 in
-    -V)
-        echo "dotty version 96c (09-24-96)"
-               FLAGS=$FLAGS" -V"
-        shift
-        ;;
-    -f)
-        shift
-        loadfile=$1
-        shift
-        ;;
-    -lm)
-        shift
-        LMODE=$1
-        if [ "x$LMODE" != 'xsync' -a "x$LMODE" != 'xasync' ]; then
-            $usage
-            exit 1
-        fi
-        shift
-        ;;
-    -el)
-        shift
-        MLEVEL=$1
-        if [ "x$MLEVEL" != 'x0' -a "x$MLEVEL" != 'x1' ]; then
-            $usage
-            exit 1
-        fi
-        shift
-        ;;
-    -)
-        FILES=`echo $FILES \"$1\"`
-        shift
-        ;;
-    -\?)
-        $usage
-        exit 0
-        ;;
-    -*)
-        $usage
-        exit 1
-        ;;
-    *)
-        FILES=`echo $FILES \"$1\"`
-        shift
-        ;;
-    esac
-done
-
-if [ "x$DOTTYPATH" != 'x' ]; then
-    LEFTYPATH="$DOTTYPATH:$LEFTYPATH"
-fi
-
-CMDS=""
-
-CMDS="dotty.protogt.layoutmode = '$LMODE';"
-
-CMDS=`echo $CMDS dotty.mlevel = $MLEVEL";"`
-
-if [ "x$loadfile" != 'x' ]; then
-    CMDS=`echo $CMDS load \("'"$loadfile"'"\)";"`
-fi
-
-if [ "x$FILES" = 'x' ]; then
-    FILES=null
-fi
-FUNC="dotty.createviewandgraph"
-for i in $FILES; do
-    CMDS=`echo $CMDS $FUNC \($i, "'"file"'", null, null\)";"`
-done
-
-leftypath=`which lefty`
-if [ ! -f "$leftypath" ]; then
-    echo "dotty: cannot locate the lefty program"
-    echo "       make sure that your path includes"
-    echo "       the directory containing dotty and lefty"
-    exit 1
-fi
-
-exec $leftypath $FLAGS -e "
-load ('dotty.lefty');
-checkpath = function () {
-    if (tablesize (dotty) > 0)
-        remove ('checkpath');
-    else {
-        echo ('dotty: cannot locate the dotty scripts');
-        echo ('       make sure that the environment variable LEFTYPATH');
-        echo ('       is set to the directory containing dotty.lefty');
-        exit ();
-    }
-};
-checkpath ();
-dotty.init ();
-monitorfile = dotty.monitorfile;
-$CMDS
-txtview ('off');
-"
diff --git a/cmd/dotty/dotty_draw.lefty b/cmd/dotty/dotty_draw.lefty
deleted file mode 100644 (file)
index 2c10f85..0000000
+++ /dev/null
@@ -1,603 +0,0 @@
-#
-# dotty_draw: drawing functions and data structures
-#
-dotty.protogt.drawgraph = function (gt, views) {
-    local gid, eid, nid, graph;
-
-    graph = gt.graph;
-    gt.drawsgraph (gt, views, graph);
-    for (gid in graph.graphs)
-        gt.drawsgraph (gt, views, graph.graphs[gid]);
-    for (eid in graph.edges)
-        gt.drawedge (gt, views, graph.edges[eid]);
-    for (nid in graph.nodes)
-        gt.drawnode (gt, views, graph.nodes[nid]);
-};
-dotty.protogt.redrawgraph = function (gt, views) {
-    local vid;
-
-    for (vid in views)
-        clear (views[vid].canvas);
-    gt.drawgraph (gt, views);
-};
-dotty.protogt.setviewsize = function (views, r) {
-    local vid, vt, w2v, scale, attr;
-
-    for (vid in views) {
-        vt = views[vid];
-        vt.wrect = copy (r);
-        if (r[1].x == 0 | r[1].y == 0) {
-            attr = getwidgetattr (vt.scroll, [0 = 'size';]);
-            vt.wrect[1] = copy (attr.size);
-        }
-        if (vt.type == 'birdseye') {
-            attr = getwidgetattr (vt.scroll, [0 = 'size';]);
-            scale.x = (vt.wrect[1].x - vt.wrect[0].x) / attr.size.x;
-            scale.y = (vt.wrect[1].y - vt.wrect[0].y) / attr.size.y;
-            if (scale.x > 1 & scale.x > scale.y)
-                vt.w2v = scale.x;
-            else if (scale.y > 1)
-                vt.w2v = scale.y;
-            else
-                vt.w2v = 1;
-        }
-        w2v = vt.w2v;
-        vt.vsize = [
-            'x' = toint ((vt.wrect[1].x - vt.wrect[0].x) / w2v);
-            'y' = toint ((vt.wrect[1].y - vt.wrect[0].y) / w2v);
-        ];
-        setwidgetattr (vt.canvas, [
-            'window' = vt.wrect;
-            'viewport' = vt.vsize;
-        ]);
-        attr = getwidgetattr (vt.canvas, [0 = 'viewport';]);
-        vt.vsize = copy (attr.viewport);
-    }
-};
-dotty.protogt.setviewscale = function (views, factor) {
-    local vid, vt, w2v, attr;
-
-    for (vid in views) {
-        vt = views[vid];
-        if ((w2v = vt.w2v * factor) < 0.01) {
-            dotty.message (0, 'cannot zoom any closer');
-            return;
-        }
-        vt.w2v = w2v;
-        vt.vsize = [
-            'x' = (vt.wrect[1].x - vt.wrect[0].x) / w2v;
-            'y' = (vt.wrect[1].y - vt.wrect[0].y) / w2v;
-        ];
-        setwidgetattr (vt.canvas, ['viewport' = vt.vsize;]);
-        attr = getwidgetattr (vt.canvas, [0 = 'viewport';]);
-        vt.vsize = copy (attr.viewport);
-    }
-};
-dotty.protogt.setviewcenter = function (views, center) {
-    local vid, vt, pos;
-
-    for (vid in views) {
-        vt = views[vid];
-        pos = [
-            'x' = center.x * vt.vsize.x / (vt.wrect[1].x - vt.wrect[0].x);
-            'y' = (
-                (vt.wrect[1].y - center.y) * vt.vsize.y /
-                (vt.wrect[1].y - vt.wrect[0].y)
-            );
-        ];
-        setwidgetattr (vt.scroll, ['childcenter' = pos;]);
-    }
-};
-#
-# draw graph components
-#
-dotty.protogt.drawsgraph = function (gt, views, sgraph) {
-    sgraph.draw = 1;
-    if (~sgraph.draws)
-        return;
-    gt.execalldraw (gt, views, null, sgraph.draws, [
-        'fontname' = sgraph.fontname;
-        'fontsize' = sgraph.fontsize;
-        'fontcolor' = sgraph.fontcolor;
-        'drawcolor' = sgraph.drawcolor;
-        'fillcolor' = sgraph.fillcolor;
-    ]);
-};
-dotty.protogt.undrawsgraph = function (gt, views, sgraph) {
-    sgraph.drawn = 0;
-    if (~sgraph.draws)
-        return;
-    gt.execalldraw (gt, views, null, sgraph.draws, [
-        'fontname' = sgraph.fontname;
-        'fontsize' = sgraph.fontsize;
-        'fontcolor' = sgraph.fontcolor;
-        'drawcolor' = 0;
-        'fillcolor' = 0;
-    ]);
-};
-dotty.protogt.drawnode = function (gt, views, node) {
-    local vid;
-
-    node.drawn = 1;
-    if (~node.draws)
-        return;
-    gt.execalldraw (gt, views, node, node.draws, [
-        'fontname' = node.fontname;
-        'fontsize' = node.fontsize;
-        'fontcolor' = node.fontcolor;
-        'drawcolor' = node.drawcolor;
-        'fillcolor' = node.fillcolor;
-    ]);
-    for (vid in views)
-        setpick (views[vid].canvas, node, node.rect);
-};
-dotty.protogt.undrawnode = function (gt, views, node) {
-    local vid;
-
-    if (~node.drawn)
-        return;
-    node.drawn = 0;
-    if (~node.pos)
-        return;
-    gt.execalldraw (gt, views, node, node.draws, [
-        'nooverride' = 1;
-        'fontname' = node.fontname;
-        'fontsize' = node.fontsize;
-        'fontcolor' = 0;
-        'drawcolor' = 0;
-        'fillcolor' = 0;
-    ]);
-    for (vid in views)
-        clearpick (views[vid].canvas, node);
-};
-dotty.protogt.movenode = function (gt, node, pos) {
-    local dp, eid, edge;
-
-    dp.x = pos.x - node.pos.x;
-    dp.y = pos.y - node.pos.y;
-    gt.undrawnode (gt, gt.views, node);
-    node.pos.x = pos.x;
-    node.pos.y = pos.y;
-    
-    # correct the bounding box when moving
-    node.rect[0].x = node.pos.x - node.size.x/2;
-    node.rect[1].x = node.pos.x + node.size.x/2;
-    node.rect[0].y = node.pos.y - node.size.y/2;
-    node.rect[1].y = node.pos.y + node.size.y/2;
-    
-    gt.movenodedraw (node.draws, dp);
-    for (eid in node.edges) {
-        edge = node.edges[eid];
-        gt.undrawedge (gt, gt.views, edge);
-        gt.moveedgedraw (edge.draws, edge.tail.pos, edge.head.pos);
-        gt.drawedge (gt, gt.views, edge);
-    }
-    gt.drawnode (gt, gt.views, node);
-};
-dotty.protogt.drawedge = function (gt, views, edge) {
-    local vid, canvas;
-
-    edge.drawn = 1;
-    if (~edge.draws)
-        return;
-    gt.execalldraw (gt, views, edge, edge.draws, [
-        'fontname' = edge.fontname;
-        'fontsize' = edge.fontsize;
-        'fontcolor' = edge.fontcolor;
-        'drawcolor' = edge.drawcolor;
-        'fillcolor' = edge.fillcolor;
-    ]);
-    for (vid in views) {
-        canvas = views[vid].canvas;
-        if (gt.edgehandles == 0 | ~edge.draws.ep)
-            continue;
-        arc (canvas, edge, edge.draws.ep, ['x' = 5; 'y' = 5;], ['color' = 1;]);
-    }
-};
-dotty.protogt.undrawedge = function (gt, views, edge) {
-    local vid, canvas;
-
-    if (~edge.drawn)
-        return;
-    edge.drawn = 0;
-    if (~edge.draws)
-        return;
-    gt.execalldraw (gt, views, edge, edge.draws, [
-        'nooverride' = 1;
-        'fontname' = edge.fontname;
-        'fontsize' = edge.fontsize;
-        'fontcolor' = 0;
-        'drawcolor' = 0;
-        'fillcolor' = 0;
-    ]);
-    for (vid in views) {
-        canvas = views[vid].canvas;
-        if (gt.edgehandles == 0 | ~edge.draws.ep)
-            continue;
-        arc (canvas, edge, edge.draws.ep, ['x' = 5; 'y' = 5;], ['color' = 0;]);
-        clearpick (canvas, edge);
-    }
-};
-#
-# draw directives
-#
-dotty.protogt.execalldraw = function (gt, views, obj, draws, gc) {
-    local vid, vt, did, draw, i, func;
-
-    for (vid in views) {
-        vt = views[vid];
-        for (did in draws) {
-            if (did == 'ep')
-                continue;
-            draw = draws[did];
-            for (i = 0; draw[i]; i = i + 1)
-                if ((func = gt.drawfunc[draw[i].type]))
-                    func (gt, vt.canvas, obj, draw[i], gc);
-        }
-    }
-};
-dotty.protogt.drawfunc.E = function (gt, canvas, obj, data, gc) {
-    arc (canvas, obj, data.c, data.s, [
-        'color' = gc.fillcolor; 'style' = gc.style; 'width' = gc.width;
-        'fill' = 'on';
-    ]);
-    arc (canvas, obj, data.c, data.s, [
-        'color' = gc.drawcolor; 'style' = gc.style; 'width' = gc.width;
-    ]);
-};
-dotty.protogt.drawfunc.e = function (gt, canvas, obj, data, gc) {
-    arc (canvas, obj, data.c, data.s, [
-        'color' = gc.drawcolor; 'style' = gc.style; 'width' = gc.width;
-    ]);
-};
-dotty.protogt.drawfunc.P = function (gt, canvas, obj, data, gc) {
-    polygon (canvas, obj, data.ps, [
-        'color' = gc.fillcolor; 'style' = gc.style; 'width' = gc.width;
-        'fill' = 'on';
-    ]);
-    polygon (canvas, obj, data.ps, [
-        'color' = gc.drawcolor; 'style' = gc.style; 'width' = gc.width;
-    ]);
-};
-dotty.protogt.drawfunc.p = function (gt, canvas, obj, data, gc) {
-    polygon (canvas, obj, data.ps, [
-        'color' = gc.drawcolor; 'style' = gc.style; 'width' = gc.width;
-    ]);
-};
-dotty.protogt.drawfunc.L = function (gt, canvas, obj, data, gc) {
-    polygon (canvas, obj, data.ps, [
-        'color' = gc.drawcolor; 'style' = gc.style; 'width' = gc.width;
-    ]);
-};
-dotty.protogt.drawfunc.b = function (gt, canvas, obj, data, gc) {
-    splinegon (canvas, obj, data.ps, [
-        'color' = gc.fillcolor; 'style' = gc.style; 'width' = gc.width;
-        'fill' = 'on';
-    ]);
-};
-dotty.protogt.drawfunc.B = function (gt, canvas, obj, data, gc) {
-    splinegon (canvas, obj, data.ps, [
-        'color' = gc.drawcolor; 'style' = gc.style; 'width' = gc.width;
-    ]);
-};
-dotty.protogt.drawfunc.T = function (gt, canvas, obj, data, gc) {
-    text (canvas, obj, data.p, data.s, gc.fontname, gc.fontsize, data.j, [
-        'color' = gc.fontcolor; 'style' = gc.style; 'width' = gc.width;
-    ]);
-};
-dotty.protogt.drawfunc.C = function (gt, canvas, obj, data, gc) {
-    if (gc.nooverride ~= 1)
-        gc.fillcolor = data.fillcolor;
-};
-dotty.protogt.drawfunc.c = function (gt, canvas, obj, data, gc) {
-    if (gc.nooverride ~= 1) {
-        gc.drawcolor = data.drawcolor;
-        gc.fontcolor = data.drawcolor;
-    }
-};
-dotty.protogt.drawfunc.F = function (gt, canvas, obj, data, gc) {
-    gc.fontname = data.fn;
-    gc.fontsize = data.fs;
-};
-dotty.protogt.drawfunc.S = function (gt, canvas, obj, data, gc) {
-    gc.style = data.style;
-    gc.width = data.width;
-};
-dotty.protogt.movenodedraw = function (draws, dp) {
-    local did, draw, i, j;
-
-    for (did in draws) {
-        if (did == 'ep')
-            continue;
-        draw = draws[did];
-        for (i = 0; draw[i]; i = i + 1) {
-            if (draw[i].type == 'E' | draw[i].type == 'e') {
-                draw[i].c.x = draw[i].c.x + dp.x;
-                draw[i].c.y = draw[i].c.y + dp.y;
-            } else if (draw[i].type == 'P' | draw[i].type == 'p') {
-                for (j = 1; draw[i].ps[j]; j = j + 1) {
-                    draw[i].ps[j].x = draw[i].ps[j].x + dp.x;
-                    draw[i].ps[j].y = draw[i].ps[j].y + dp.y;
-                }
-            } else if (draw[i].type == 'L' | draw[i].type == 'B') {
-                for (j = 0; draw[i].ps[j]; j = j + 1) {
-                    draw[i].ps[j].x = draw[i].ps[j].x + dp.x;
-                    draw[i].ps[j].y = draw[i].ps[j].y + dp.y;
-                }
-            } else if (draw[i].type == 'T') {
-                draw[i].p.x = draw[i].p.x + dp.x;
-                draw[i].p.y = draw[i].p.y + dp.y;
-            }
-        }
-    }
-};
-dotty.protogt.moveedgedraw = function (draws, tp, hp) {
-    local draws2, did;
-
-    for (did in draws)
-        draws2[did] = draws[did];
-    for (did in draws2)
-        remove (did, draws);
-    draws[0] = [
-        0 = [
-            'type' = 'L';
-            'n' = 2;
-            'ps' = [
-                0 = copy (tp);
-                1 = copy (hp);
-            ];
-        ];
-        'ep' = ['x' = (tp.x + hp.x) / 2; 'y' = (tp.y + hp.y) / 2;];
-    ];
-};
-dotty.protogt.simplenodedraw = function (node, c, s) {
-    local draws;
-
-    if (node.attr.shape == 'ellipse')
-        draws[0] = [
-            0 = [
-                'type' = 'e';
-                'c' = copy (c);
-                's' = ['x' = s.x / 2; 'y' = s.y / 2;];
-            ];
-        ];
-    else
-        draws[0] = [
-            0 = [
-                'type' = 'p';
-                'n' = 5;
-                'ps' = [
-                    0 = ['x' = c.x - s.x / 2; 'y' = c.y - s.y / 2;];
-                    1 = ['x' = c.x + s.x / 2; 'y' = c.y - s.y / 2;];
-                    2 = ['x' = c.x + s.x / 2; 'y' = c.y + s.y / 2;];
-                    3 = ['x' = c.x - s.x / 2; 'y' = c.y + s.y / 2;];
-                    4 = ['x' = c.x - s.x / 2; 'y' = c.y - s.y / 2;];
-                ];
-            ];
-        ];
-    return draws;
-};
-dotty.protogt.simpleedgedraw = function (edge, tp, hp) {
-    local draws;
-
-    draws[0] = [
-        0 = [
-            'type' = 'L';
-            'n' = 2;
-            'ps' = [
-                0 = copy (tp);
-                1 = copy (hp);
-            ];
-        ];
-        'ep' = ['x' = (tp.x + hp.x) / 2; 'y' = (tp.y + hp.y) / 2;];
-    ];
-    return draws;
-};
-#
-# utilities
-#
-dotty.protogt.getcolor = function (views, name) {
-    local vid, vt, color, t;
-
-    for (vid in views) {
-        vt = views[vid];
-        if (~(color >= 0)) {
-            if (~(vt.colors[name] >= 0))
-                color = (vt.colors[name] = vt.colorn);
-            else {
-                color = vt.colors[name];
-                break;
-            }
-        } else if (~(vt.colors[name] >= 0))
-            vt.colors[name] = color;
-        else if (vt.colors[name] ~= color)
-            dotty.message (0, concat ('inconsistent color ids for ', name));
-        if (setwidgetattr (vt.canvas, ['color' = [color = name;];]) ~= 1) {
-            t = split (name, ' ');
-            if (tablesize (t) ~= 3 |
-                    setwidgetattr (vt.canvas, ['color' = [color = [
-                        'h' = ston (t[0]); 's' = ston (t[1]); 'v' = ston (t[2]);
-                    ];];]) ~= 1) {
-                dotty.message (0, concat ('unknown color ', name, ' using #1'));
-                return 1;
-            }
-        }
-        vt.colorn = color + 1;
-    }
-    return color;
-};
-dotty.protogt.setbgcolor = function (views, name) {
-    local vid, vt, t;
-
-    for (vid in views) {
-        vt = views[vid];
-        if (setwidgetattr (vt.canvas, ['color' = [0 = name;];]) ~= 1) {
-            t = split (name, ' ');
-            if (tablesize (t) ~= 3 |
-                    setwidgetattr (vt.canvas, ['color' = [0 = [
-                        'h' = ston (t[0]); 's' = ston (t[1]); 'v' = ston (t[2]);
-                    ];];]) ~= 1) {
-                dotty.message (0, concat ('unknown bgcolor ', name));
-                return;
-            }
-        }
-        vt.colors['_bgcolor_'] = name;
-    }
-};
-dotty.protogt.unpacksgraphattr = function (gt, sgraph) {
-    local attr;
-
-    attr = sgraph.graphattr;
-    if (dotty.fontmap[attr.fontname])
-        sgraph[dotty.keys.fname] = dotty.fontmap[attr.fontname];
-    else
-        sgraph[dotty.keys.fname] = attr.fontname;
-    sgraph[dotty.keys.fsize] = ston (attr.fontsize);
-    sgraph[dotty.keys.fcolor] = gt.getcolor (gt.views, attr.fontcolor);
-    if (attr.color)
-        sgraph[dotty.keys.dcolor] = gt.getcolor (gt.views, attr.color);
-    else
-        sgraph[dotty.keys.dcolor] = gt.getcolor (gt.views, 'black');
-    if (attr.style == 'filled') {
-        if (attr.fillcolor)
-            sgraph[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.fillcolor);
-        else if (attr.color)
-            sgraph[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.color);
-        else
-            sgraph[dotty.keys.bcolor] = gt.getcolor (gt.views, 'lightgrey');
-    }
-};
-dotty.protogt.unpacknodeattr = function (gt, node) {
-    local attr;
-
-    attr = node.attr;
-    if (dotty.fontmap[attr.fontname])
-        node[dotty.keys.fname] = dotty.fontmap[attr.fontname];
-    else
-        node[dotty.keys.fname] = attr.fontname;
-    node[dotty.keys.fsize] = ston (attr.fontsize);
-    node[dotty.keys.fcolor] = gt.getcolor (gt.views, attr.fontcolor);
-    if (attr.color)
-        node[dotty.keys.dcolor] = gt.getcolor (gt.views, attr.color);
-    else
-        node[dotty.keys.dcolor] = gt.getcolor (gt.views, 'black');
-    if (attr.style == 'filled') {
-        if (attr.fillcolor)
-            node[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.fillcolor);
-        else if (attr.color)
-            node[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.color);
-        else
-            node[dotty.keys.bcolor] = gt.getcolor (gt.views, 'lightgrey');
-    }
-};
-dotty.protogt.unpackedgeattr = function (gt, edge) {
-    local attr;
-
-    attr = edge.attr;
-    if (dotty.fontmap[attr.fontname])
-        edge[dotty.keys.fname] = dotty.fontmap[attr.fontname];
-    else
-        edge[dotty.keys.fname] = attr.fontname;
-    edge[dotty.keys.fsize] = ston (attr.fontsize);
-    edge[dotty.keys.fcolor] = gt.getcolor (gt.views, attr.fontcolor);
-    if (attr.color)
-        edge[dotty.keys.dcolor] = gt.getcolor (gt.views, attr.color);
-    else
-        edge[dotty.keys.dcolor] = gt.getcolor (gt.views, 'black');
-    if (attr.style == 'filled') {
-        if (attr.fillcolor)
-            edge[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.fillcolor);
-        else if (attr.color)
-            edge[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.color);
-        else
-            edge[dotty.keys.bcolor] = gt.getcolor (gt.views, 'lightgrey');
-    }
-};
-dotty.protogt.unpackattr = function (gt) {
-    local gid, sgraph, nid, node, eid, edge, graph, attr;
-
-    graph = gt.graph;
-    attr = graph.graphattr;
-    if (dotty.fontmap[attr.fontname])
-        graph[dotty.keys.fname] = dotty.fontmap[attr.fontname];
-    else
-        graph[dotty.keys.fname] = attr.fontname;
-    graph[dotty.keys.fsize] = ston (attr.fontsize);
-    graph[dotty.keys.fcolor] = gt.getcolor (gt.views, attr.fontcolor);
-    if (attr.color)
-        graph[dotty.keys.dcolor] = gt.getcolor (gt.views, attr.color);
-    else
-        graph[dotty.keys.dcolor] = gt.getcolor (gt.views, 'black');
-    if (attr.style == 'filled') {
-        if (attr.fillcolor)
-            graph[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.fillcolor);
-        else if (attr.color)
-            graph[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.color);
-        else
-            graph[dotty.keys.bcolor] = gt.getcolor (gt.views, 'lightgrey');
-    }
-    if (attr.bgcolor & attr.bgcolor ~= '')
-        gt.setbgcolor (gt.views, attr.bgcolor);
-    for (gid in graph.graphdict) {
-        sgraph = graph.graphs[graph.graphdict[gid]];
-        attr = sgraph.graphattr;
-        if (dotty.fontmap[attr.fontname])
-            sgraph[dotty.keys.fname] = dotty.fontmap[attr.fontname];
-        else
-            sgraph[dotty.keys.fname] = attr.fontname;
-        sgraph[dotty.keys.fsize] = ston (attr.fontsize);
-        sgraph[dotty.keys.fcolor] = gt.getcolor (gt.views, attr.fontcolor);
-        if (attr.color)
-            sgraph[dotty.keys.dcolor] = gt.getcolor (gt.views, attr.color);
-        else
-            sgraph[dotty.keys.dcolor] = gt.getcolor (gt.views, 'black');
-        if (attr.style == 'filled') {
-            if (attr.fillcolor)
-                sgraph[dotty.keys.bcolor] = gt.getcolor (
-                    gt.views, attr.fillcolor
-                );
-            else if (attr.color)
-                sgraph[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.color);
-            else
-                sgraph[dotty.keys.bcolor] = gt.getcolor (gt.views, 'lightgrey');
-        }
-    }
-    for (nid in graph.nodedict) {
-        node = graph.nodes[graph.nodedict[nid]];
-        attr = node.attr;
-        if (dotty.fontmap[attr.fontname])
-            node[dotty.keys.fname] = dotty.fontmap[attr.fontname];
-        else
-            node[dotty.keys.fname] = attr.fontname;
-        node[dotty.keys.fsize] = ston (attr.fontsize);
-        node[dotty.keys.fcolor] = gt.getcolor (gt.views, attr.fontcolor);
-        if (attr.color)
-            node[dotty.keys.dcolor] = gt.getcolor (gt.views, attr.color);
-        else
-            node[dotty.keys.dcolor] = gt.getcolor (gt.views, 'black');
-        if (attr.style == 'filled') {
-            if (attr.fillcolor)
-                node[dotty.keys.bcolor] = gt.getcolor (
-                    gt.views, attr.fillcolor
-                );
-            else if (attr.color)
-                node[dotty.keys.bcolor] = gt.getcolor (gt.views, attr.color);
-            else
-                node[dotty.keys.bcolor] = gt.getcolor (gt.views, 'lightgrey');
-        }
-    }
-    for (eid in graph.edges) {
-        edge = graph.edges[eid];
-        attr = edge.attr;
-        if (dotty.fontmap[attr.fontname])
-            edge[dotty.keys.fname] = dotty.fontmap[attr.fontname];
-        else
-            edge[dotty.keys.fname] = attr.fontname;
-        edge[dotty.keys.fsize] = ston (attr.fontsize);
-        edge[dotty.keys.fcolor] = gt.getcolor (gt.views, attr.fontcolor);
-        if (attr.color)
-            edge[dotty.keys.dcolor] = gt.getcolor (gt.views, attr.color);
-        else
-            edge[dotty.keys.dcolor] = gt.getcolor (gt.views, 'black');
-    }
-};
diff --git a/cmd/dotty/dotty_edit.lefty b/cmd/dotty/dotty_edit.lefty
deleted file mode 100644 (file)
index 41c11d8..0000000
+++ /dev/null
@@ -1,593 +0,0 @@
-#
-# dotty_edit: editing functions and data structures
-#
-dotty.protogt.getnodesbyattr = function (gt, key, val) {
-    local nid, node, nlist;
-
-    nlist = [];
-    for (nid in gt.graph.nodes) {
-        node = gt.graph.nodes[nid];
-        if (node.attr[key] == val)
-            nlist[nid] = node;
-    }
-    return nlist;
-};
-dotty.protogt.reachablenodes = function (gt, node) {
-    local nlist, stack, eid, edge, i;
-
-    stack[0] = node;
-    i = 1;
-    while (i > 0) {
-        node = stack[i - 1];
-        i = i - 1;
-        nlist[node.nid] = node;
-        for (eid in node.edges) {
-            edge = node.edges[eid];
-            if (~nlist[edge.head.nid]) {
-                nlist[edge.head.nid] = edge.head;
-                stack[i] = edge.head;
-                i = i + 1;
-            }
-        }
-    }
-    return nlist;
-};
-dotty.protogt.mergegraph = function (gt, graph, show) {
-    local nameid, onode, pos, size, eid, eid2, tnode, hnode, oedge;
-
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    for (nameid in graph.nodedict) {
-        pos = null;
-        size = null;
-        onode = graph.nodes[graph.nodedict[nameid]];
-        if (onode.pos)
-            pos = node.pos;
-        if (onode.size)
-            size = node.size;
-        if (~(gt.graph.nodedict[nameid] >= 0)) {
-            pos = null;
-            size = null;
-            if (onode.pos)
-                pos = node.pos;
-            if (onode.size)
-                size = node.size;
-            gt.insertnode (gt, pos, size, nameid, onode.attr, show);
-        }
-    }
-    for (eid in graph.edges) {
-        oedge = graph.edges[eid];
-        tnode = gt.graph.nodes[gt.graph.nodedict[oedge.tail.name]];
-        hnode = gt.graph.nodes[gt.graph.nodedict[oedge.head.name]];
-        for (eid2 in tnode.edges)
-            if (
-                tnode.edges[eid2].tail == tnode &
-                tnode.edges[eid2].head == hnode
-            ) {
-                oedge = null;
-                break;
-            }
-        if (oedge)
-            gt.insertedge (gt, tnode, null, hnode, null, oedge.attr, show);
-    }
-    if (~gt.noundo)
-        gt.endadd2undo (gt);
-};
-dotty.protogt.insertsgraph = function (gt, name, attr, show) {
-    local gid, sgraph, aid;
-
-    if (~gt)
-        return null;
-    gid = gt.graph.maxgid;
-    if (~name) {
-        while (gt.graph.graphdict[(name = concat ('g', gid))] >= 0)
-            gid = gid + 1;
-    } else if (gt.graph.graphdict[name]) {
-        dotty.message (0, concat ('graph: ', name, ' exists'));
-        return null;
-    }
-    gt.graph.graphdict[name] = gid;
-    gt.graph.maxgid = gid + 1;
-    gt.graph.graphs[gid] = [
-        dotty.keys.gid   = gid;
-        dotty.keys.name  = name;
-        dotty.keys.gattr = copy (gt.graph.graphattr);
-        dotty.keys.nattr = copy (gt.graph.nodeattr);
-        dotty.keys.eattr = copy (gt.graph.edgeattr);
-    ];
-    sgraph = gt.graph.graphs[gid];
-    if (~attr)
-        attr = [];
-    if (~attr.label)
-        attr.label = '\N';
-    for (aid in attr)
-        sgraph.graphattr[aid] = attr[aid];
-    gt.unpacksgraphattr (gt, sgraph);
-    if (show)
-        gt.drawsgraph (gt, gt.views, sgraph);
-    return sgraph;
-};
-dotty.protogt.removesgraph = function (gt, sgraph) {
-    gt.undrawsgraph (gt, gt.views, sgraph);
-    remove (sgraph.name, gt.graph.graphdict);
-    remove (sgraph.gid, gt.graph.graphs);
-};
-dotty.protogt.insertnode = function (gt, pos, size, name, attr, show) {
-    local nid, node, aid;
-
-    nid = gt.graph.maxnid;
-    if (~name) {
-        while (gt.graph.nodedict[(name = concat ('n', nid))] >= 0)
-            nid = nid + 1;
-    } else if (gt.graph.nodedict[name] >= 0) {
-        dotty.message (0, concat ('node: ', name, ' exists'));
-        return null;
-    }
-    gt.graph.nodedict[name] = nid;
-    gt.graph.maxnid = nid + 1;
-    gt.graph.nodes[nid] = [
-        dotty.keys.nid   = nid;
-        dotty.keys.name  = name;
-        dotty.keys.attr  = copy (gt.graph.nodeattr);
-        dotty.keys.edges = [];
-    ];
-    node = gt.graph.nodes[nid];
-    if (~attr)
-        attr = [];
-    if (~attr.label)
-        attr.label = '\N';
-    for (aid in attr)
-        node.attr[aid] = attr[aid];
-    gt.unpacknodeattr (gt, node);
-    if (~pos)
-        pos = ['x' = 10; 'y' = 10;];
-    node[dotty.keys.pos] = copy (pos);
-    if (~size)
-        size = ['x' = strlen (attr.label) * 30; 'y' = 30;];
-    if (size.x == 0)
-        size.x = 30;
-    node[dotty.keys.size] = copy (size);
-    node[dotty.keys.rect] = [
-        0 = ['x' = pos.x - size.x / 2; 'y' = pos.y - size.y / 2;];
-        1 = ['x' = pos.x + size.x / 2; 'y' = pos.y + size.y / 2;];
-    ];
-    node.draws = gt.simplenodedraw (node, pos, size);
-    if (show)
-        gt.drawnode (gt, gt.views, node);
-    if (~gt.noundo) {
-        gt.startadd2undo (gt);
-        gt.currundo.inserted.nodes[nid] = node;
-        gt.endadd2undo (gt);
-    }
-    return node;
-};
-dotty.protogt.removenode = function (gt, node) {
-    local eid, list, edge, gid;
-
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    for (eid in node.edges)
-        list[eid] = node.edges[eid];
-    for (eid in list)
-        gt.removeedge (gt, list[eid]);
-    gt.undrawnode (gt, gt.views, node);
-    for (gid in gt.graph.graphs)
-        remove (node.nid, gt.graph.graphs[gid].nodes);
-    remove (node.name, gt.graph.nodedict);
-    remove (node.nid, gt.graph.nodes);
-    if (~gt.noundo) {
-        gt.currundo.deleted.nodes[node.nid] = node;
-        gt.endadd2undo (gt);
-    }
-};
-dotty.protogt.insertedge = function (
-    gt, nodea, porta, nodeb, portb, attr, show
-) {
-    local eid, edge, aid, tport, hport;
-
-    if (~nodea | ~nodeb)
-        return null;
-    if (porta)
-        tport = porta;
-    if (portb)
-        hport = portb;
-    eid = gt.graph.maxeid;
-    while (gt.graph.edges[eid])
-        eid = eid + 1;
-    gt.graph.maxeid = eid + 1;
-    gt.graph.edges[eid] = [
-        dotty.keys.eid   = eid;
-        dotty.keys.tail  = nodea;
-        dotty.keys.tport = porta;
-        dotty.keys.head  = nodeb;
-        dotty.keys.hport = portb;
-        dotty.keys.attr  = copy (gt.graph.edgeattr);
-    ];
-    edge = gt.graph.edges[eid];
-    if (~attr)
-        attr = [];
-    for (aid in attr)
-        edge.attr[aid] = attr[aid];
-    nodea.edges[eid] = edge;
-    nodeb.edges[eid] = edge;
-    gt.unpackedgeattr (gt, edge);
-    edge.draws = gt.simpleedgedraw (edge, nodea.pos, nodeb.pos);
-    if (show)
-        gt.drawedge (gt, gt.views, edge);
-    if (~gt.noundo) {
-        gt.startadd2undo (gt);
-        gt.currundo.inserted.edges[eid] = edge;
-        gt.endadd2undo (gt);
-    }
-    return edge;
-};
-dotty.protogt.removeedge = function (gt, edge) {
-    local head, tail;
-
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    if (edge.head.attr.support == 1)
-        head = edge.head;
-    if (edge.tail.attr.support == 1)
-        if (head ~= edge.tail)
-            tail = edge.tail;
-    gt.undrawedge (gt, gt.views, edge);
-    remove (edge.eid, edge.head.edges);
-    remove (edge.eid, edge.tail.edges);
-    remove (edge.eid, gt.graph.edges);
-    if (head & tablesize (head.edges) == 0)
-        gt.removenode (gt, head);
-    if (tail & tablesize (tail.edges) == 0)
-        gt.removenode (gt, tail);
-    if (~gt.noundo) {
-        gt.currundo.deleted.edges[edge.eid] = edge;
-        gt.endadd2undo (gt);
-    }
-};
-dotty.protogt.swapedgeids = function (gt, edge1, edge2) {
-    local eid1, eid2;
-
-    if (edge1.eid == edge2.eid)
-        return;
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    eid1 = edge1.eid;
-    eid2 = edge2.eid;
-    gt.graph.edges[eid1] = edge2;
-    gt.graph.edges[eid2] = edge1;
-    remove (eid1, edge1.tail.edges);
-    remove (eid1, edge1.head.edges);
-    remove (eid2, edge2.tail.edges);
-    remove (eid2, edge2.head.edges);
-    edge1.tail.edges[eid2] = edge1;
-    edge1.head.edges[eid2] = edge1;
-    edge2.tail.edges[eid1] = edge2;
-    edge2.head.edges[eid1] = edge2;
-    edge1.eid = eid2;
-    edge2.eid = eid1;
-    if (~gt.noundo) {
-        gt.currundo.swapped.edges[eid1] = edge1;
-        gt.currundo.swapped.edges[eid2] = edge2;
-        gt.endadd2undo (gt);
-    }
-};
-dotty.protogt.removesubtree = function (gt, obj) {
-    local nlist, node, head, nid, edge, eid;
-
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    if (obj.nid >= 0)
-        node = obj;
-    else if (obj.eid >= 0) {
-        node = obj.head;
-        gt.removeedge (gt, obj);
-        if (~gt.graph.nodes[node.nid]) {
-            if (~gt.noundo)
-                gt.endadd2undo (gt);
-            return;
-        }
-        for (eid in node.edges) {
-            edge = node.edges[eid];
-            if (edge.head == node & edge.tail ~= node) {
-                if (~gt.noundo)
-                    gt.endadd2undo (gt);
-                return;
-            }
-        }
-    } else {
-        dotty.message (0, 'bad object type in gt.removesubtree');
-        return;
-    }
-    nlist = [node.nid = node;];
-    while (node) {
-        for (eid in node.edges) {
-            head = node.edges[eid].head;
-            if (head ~= node)
-                nlist[head.nid] = head;
-        }
-        gt.removenode (gt, node);
-        remove (node.nid, nlist);
-        node = null;
-        for (nid in nlist) {
-            node = nlist[nid];
-            for (eid in node.edges) {
-                edge = node.edges[eid];
-                if (edge.head == node & edge.tail ~= node) {
-                    node = null;
-                    break;
-                }
-            }
-            if (node)
-                break;
-        }
-    }
-    if (~gt.noundo)
-        gt.endadd2undo (gt);
-};
-dotty.protogt.removenodesbyattr = function (gt, key, val) {
-    local nlist, nid;
-
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    nlist = gt.getnodesbyattr (gt, key, val);
-    for (nid in nlist)
-        gt.removenode (gt, nlist[nid]);
-    if (~gt.noundo)
-        gt.endadd2undo (gt);
-};
-dotty.protogt.removesubtreesbyattr = function (gt, key, val) {
-    local nlist, nid;
-
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    nlist = gt.getnodesbyattr (gt, key, val);
-    for (nid in nlist)
-        if (gt.graph.nodes[nid])
-            gt.removesubtree (gt, nlist[nid]);
-    if (~gt.noundo)
-        gt.endadd2undo (gt);
-};
-dotty.protogt.groupnodes = function (
-    gt, nlist, gnode, pos, size, attr, keepmulti, show
-) {
-    local nid, node, elist, eid, edge, nodea, nodeb, inlist, outlist;
-
-    if (~nlist | tablesize (nlist) == 0)
-        return;
-    if (gnode.attr.support) {
-        dotty.message (0, 'cannot group nodes in a support node');
-        return;
-    }
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    if (~gnode)
-        gnode = gt.insertnode (gt, pos, size, null, attr, show);
-    inlist = [];
-    outlist = [];
-    for (nid in nlist) {
-        if ((node = nlist[nid]) == gnode)
-            continue;
-        elist = [];
-        for (eid in node.edges)
-            elist[eid] = node.edges[eid];
-        for (eid in elist) {
-            edge = elist[eid];
-            if (edge.head == node) {
-                nodea = edge.tail;
-                nodeb = gnode;
-                if (~keepmulti) {
-                    if (inlist[nodea.nid])
-                        continue;
-                    inlist[nodea.nid] = nodea;
-                    if (nodea == gnode)
-                        outlist[nodea.nid] = nodea;
-                }
-            } else {
-                nodea = gnode;
-                nodeb = edge.head;
-                if (~keepmulti) {
-                    if (outlist[nodeb.nid])
-                        continue;
-                    outlist[nodeb.nid] = nodeb;
-                    if (nodeb == gnode)
-                        inlist[nodeb.nid] = nodeb;
-                }
-            }
-            gt.insertedge (gt, nodea, null, nodeb, null, edge.attr, show);
-        }
-        gt.removenode (gt, node);
-    }
-    if (~gt.noundo)
-        gt.endadd2undo (gt);
-    return gnode;
-};
-dotty.protogt.groupnodesbyattr = function (
-    gt, key, val, attr, keepmulti, show
-) {
-    local nlist, nid, pos, size;
-
-    pos = null;
-    size = null;
-    nlist = gt.getnodesbyattr (gt, key, val);
-    if (show)
-        for (nid in nlist) {
-            pos = nlist[nid].pos;
-            size = nlist[nid].size;
-            break;
-        }
-    return gt.groupnodes (gt, nlist, null, pos, size, attr, keepmulti, show);
-};
-dotty.protogt.cut = function (gt, obj, set, mode, op) {
-    local clipgt, list, node, nid, edge, eid, clipnode;
-
-    clipgt = dotty.clipgt;
-    clipgt.graph = copy (dotty.protogt.graph);
-    if (obj.eid >= 0) { # it's an edge
-        list.edges[obj.eid] = obj;
-        node = obj.head;
-    } else if (obj.nid >= 0) {
-        list.nodes[obj.nid] = obj;
-        node = obj;
-        for (eid in node.edges)
-            list.edges[eid] = node.edges[eid];
-    } else {
-        dotty.message (0, 'unknown object type in gt.cut');
-        return;
-    }
-    if (set == 'reachable') {
-        list.nodes = gt.reachablenodes (gt, node);
-        for (nid in list.nodes) {
-            node = list.nodes[nid];
-            for (eid in node.edges) {
-                edge = node.edges[eid];
-                list.edges[edge.eid] = edge;
-            }
-        }
-    }
-    if (mode == 'support') {
-        for (eid in list.edges) {
-            edge = list.edges[eid];
-            if (~list.nodes[edge.tail.nid]) {
-                list.support[edge.tail.nid] = edge.tail;
-                list.nodes[edge.tail.nid] = edge.tail;
-            }
-            if (~list.nodes[edge.head.nid]) {
-                list.support[edge.head.nid] = edge.head;
-                list.nodes[edge.head.nid] = edge.head;
-            }
-        }
-    }
-    for (nid = 0; nid < gt.graph.maxnid; nid = nid + 1) {
-        if (~list.nodes[nid])
-            continue;
-        node = list.nodes[nid];
-        clipnode = gt.insertnode (clipgt, null, null, node.name, node.attr, 0);
-        if (list.support[nid])
-            clipnode.support = 1;
-        list.clipnodes[nid] = clipnode;
-    }
-    for (eid = 0; eid < gt.graph.maxeid; eid = eid + 1) {
-        if (~list.edges[eid])
-            continue;
-        edge = list.edges[eid];
-        if (~list.nodes[edge.tail.nid] | ~list.nodes[edge.head.nid])
-            continue;
-        gt.insertedge (
-            clipgt, list.clipnodes[edge.tail.nid], null,
-            list.clipnodes[edge.head.nid], null, edge.attr, 0
-        );
-    }
-    if (op ~= 'cut')
-        return;
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    for (eid in list.edges)
-        gt.removeedge (gt, list.edges[eid]);
-    for (nid in list.nodes)
-        if (~list.support[nid] & gt.graph.nodes[nid])
-            gt.removenode (gt, list.nodes[nid]);
-    if (~gt.noundo)
-        gt.endadd2undo (gt);
-};
-dotty.protogt.paste = function (gt, pos, show) {
-    local clipgt, offset, center, nid, node, eid, edge, nodes;
-
-    if (~gt.noundo)
-        gt.startadd2undo (gt);
-    clipgt = dotty.clipgt;
-    if (clipgt.graph.rect)
-        center = [
-            'x' = (clipgt.graph.rect[1].x + clipgt.graph.rect[0].x) / 2;
-            'y' = (clipgt.graph.rect[1].y + clipgt.graph.rect[0].y) / 2;
-        ];
-    else
-        center = pos;
-    offset = [
-        'x' = center.x - pos.x;
-        'y' = center.y - pos.y;
-    ];
-    for (nid = 0; clipgt.graph.nodes[nid]; nid = nid + 1) {
-        node = clipgt.graph.nodes[nid];
-        if (node.attr.label == '\N' | ~node.attr.label)
-            node.attr.label = node.name;
-        if (node.support == 1)
-            nodes[nid] = gt.insertnode (gt, [
-                'x' = node.pos.x - offset.x;
-                'y' = node.pos.y - offset.y;
-            ], null, null, [
-                'support' = 1; 'shape' = 'circle';
-                'label' = ''; 'width' = 0.2;
-            ], show);
-        else
-            nodes[nid] = gt.insertnode (gt, [
-                'x' = node.pos.x - offset.x;
-                'y' = node.pos.y - offset.y;
-            ], node.size, null, node.attr, show);
-    }
-    for (eid = 0; clipgt.graph.edges[eid]; eid = eid + 1) {
-        edge = clipgt.graph.edges[eid];
-        gt.insertedge (
-            gt, nodes[edge.tail.nid], null,
-            nodes[edge.head.nid], null, edge.attr, show
-        );
-    }
-    if (~gt.noundo)
-        gt.endadd2undo (gt);
-};
-dotty.protogt.startadd2undo = function (gt) {
-    if (~gt.undoarray.level)
-        gt.currundo = (
-            gt.undoarray.entries[tablesize (gt.undoarray.entries)] = []
-        );
-    gt.undoarray.level = gt.undoarray.level + 1;
-};
-dotty.protogt.endadd2undo = function (gt) {
-    gt.undoarray.level = gt.undoarray.level - 1;
-};
-dotty.protogt.undo = function (gt, show) {
-    local entry, n, eid, edge, nid, node, edges;
-
-    if ((n = tablesize (gt.undoarray.entries)) < 1)
-        return;
-    entry = gt.undoarray.entries[n - 1];
-    remove (n - 1, gt.undoarray.entries);
-    remove ('currundo', gt);
-    gt.noundo = 1;
-    # hardwire nodes and edges back with the same id's as the originals
-    for (nid in entry.deleted.nodes) {
-        node = entry.deleted.nodes[nid];
-        gt.graph.nodedict[node.name] = node.nid;
-        gt.graph.nodes[node.nid] = node;
-        node.edges = [];
-        if (show)
-            gt.drawnode (gt, gt.views, node);
-    }
-    for (eid in entry.deleted.edges) {
-        edge = entry.deleted.edges[eid];
-        gt.graph.edges[edge.eid] = edge;
-        edge.head.edges[edge.eid] = edge;
-        edge.tail.edges[edge.eid] = edge;
-        if (show)
-            gt.drawedge (gt, gt.views, edge);
-    }
-    if (entry.swapped.edges) {
-        if (tablesize (entry.swapped.edges) == 2) {
-            n = 0;
-            for (eid in entry.swapped.edges) {
-                edges[n] = entry.swapped.edges[eid];
-                n = n + 1;
-            }
-            gt.swapedgeids (gt, edges[0], edges[1]);
-        } else
-            dotty.message (0, 'cannot handle undoing swap of > 2 edges');
-    }
-    for (eid in entry.inserted.edges) {
-        edge = entry.inserted.edges[eid];
-        gt.removeedge (gt, edge);
-    }
-    for (nid in entry.inserted.nodes) {
-        node = entry.inserted.nodes[nid];
-        gt.removenode (gt, node);
-    }
-    gt.noundo = 0;
-};
diff --git a/cmd/dotty/dotty_layout.lefty b/cmd/dotty/dotty_layout.lefty
deleted file mode 100644 (file)
index 1bd27be..0000000
+++ /dev/null
@@ -1,453 +0,0 @@
-#
-# dotty_layout: layout functions and data structures
-#
-dotty.grablserver = function (lserver) {
-    local fd;
-
-    if (~dotty.lservers[lserver] | tablesize (dotty.lservers[lserver]) == 0) {
-        if (~((fd = openio ('pipe', lserver, 'r+', '%e -Txdot1.2')) >= 0)) {
-            dotty.message (0, concat ('cannot start ', lserver));
-            return null;
-        }
-        dotty.lservers[lserver][fd] = [
-            'fd' = fd;
-            'count' = 0;
-        ];
-    }
-    for (fd in dotty.lservers[lserver]) {
-        dotty.lservers[lserver][fd].count = dotty.lservers[
-            lserver
-        ][fd].count + 1;
-        dotty.lservers.inuse[fd] = dotty.lservers[lserver][fd];
-        remove (fd, dotty.lservers[lserver]);
-        return fd;
-    }
-};
-dotty.releaselserver = function (lserver, fd, state) {
-    if (state == 'bad' | dotty.lservers.inuse[fd].count > 40) {
-        closeio (fd, 'kill');
-        remove (fd, dotty.lservers.inuse);
-        return;
-    }
-    dotty.lservers[lserver][fd] = dotty.lservers.inuse[fd];
-    remove (fd, dotty.lservers.inuse);
-};
-dotty.protogt.startlayout = function (gt) {
-    local lpt, fd;
-
-    if (gt.layoutpending >= 1) {
-        lpt = dotty.layoutpending[gt.gtid];
-        if (gt.layoutmode == 'async')
-            monitor ('off', lpt.fd);
-        dotty.releaselserver (gt.lserver, lpt.fd, 'bad');
-        remove (gt.gtid, dotty.layoutpending);
-        gt.layoutpending = 0;
-        gt.haveinput = 0;
-        dotty.popbusy (gt, gt.views);
-    }
-    if (~((fd = dotty.grablserver (gt.lserver)) >= 0))
-        return null;
-    dotty.pushbusy (gt, gt.views);
-    writegraph (fd, gt.graph, 1);
-    gt.layoutpending = 1;
-    dotty.layoutpending[gt.gtid] = [
-        'fd' = fd;
-        'gtid' = gt.gtid;
-    ];
-    if (gt.layoutmode == 'async')
-        monitor ('on', fd);
-    return 1;
-};
-dotty.protogt.finishlayout = function (gt) {
-    local graph, lpt, fd;
-
-    if (~(gt.layoutpending >= 1)) {
-        dotty.message (0, concat ('no layout pending for graph ', gt.gtid));
-        return null;
-    }
-    lpt = dotty.layoutpending[gt.gtid];
-    if (~(graph = readgraph (lpt.fd))) {
-        if (gt.layoutmode == 'async')
-            monitor ('off', lpt.fd);
-        dotty.releaselserver (gt.lserver, lpt.fd, 'bad');
-        if (gt.layoutpending == 2) {
-            dotty.message (0, concat ('giving up on ', gt.lserver));
-            if ((fd = openio ('file', 'dottybug.gv', 'w+')) >= 0) {
-                writegraph (fd, gt.graph, 0);
-                closeio (fd);
-                dotty.message (
-                    0, concat ('graph that causes ', gt.lserver)
-                );
-                dotty.message (
-                    0, 'to fail has been saved in file dottybug.gv'
-                );
-                dotty.message (
-                    0, 'please fill out a bug report at'
-                );
-                dotty.message (
-                    0, 'http://www.graphviz.org/bugs/bugform.html'
-                );
-            }
-            dotty.popbusy (gt, gt.views);
-            gt.layoutpending = 0;
-            gt.haveinput = 0;
-            return 1;
-        }
-        dotty.message (
-            1, concat ('lost connection to ', gt.lserver, ', restarting...')
-        );
-        lpt.fd = dotty.grablserver (gt.lserver);
-        writegraph (lpt.fd, gt.graph, 1);
-        if (gt.layoutmode == 'async')
-            monitor ('on', lpt.fd);
-        gt.layoutpending = 2;
-        gt.haveinput = 0;
-        return null;
-    }
-    if (gt.layoutmode == 'async')
-        monitor ('off', lpt.fd);
-    dotty.releaselserver (gt.lserver, lpt.fd, null);
-    remove (gt.gtid, dotty.layoutpending);
-    gt.layoutpending = 0;
-    gt.haveinput = 0;
-    gt.unpacklayout (gt, graph);
-    dotty.popbusy (gt, gt.views);
-    return 1;
-};
-dotty.protogt.cancellayout = function (gt) {
-    local lpt, vid;
-
-    if (gt.layoutpending >= 1) {
-        lpt = dotty.layoutpending[gt.gtid];
-        if (gt.layoutmode == 'async')
-            monitor ('off', lpt.fd);
-        dotty.releaselserver (gt.lserver, lpt.fd, 'bad');
-        remove (gt.gtid, dotty.layoutpending);
-        gt.layoutpending = 0;
-        gt.haveinput = 0;
-        dotty.popbusy (gt, gt.views);
-    }
-};
-dotty.protogt.unpacklayout = function (gt, graph2) {
-    local graph, gid, sgraph1, sgraph2, nid, node1, node2, eid, edge1, edge2;
-    local t1, pos, size;
-
-    graph = gt.graph;
-    for (gid in graph2.graphdict) {
-        if (~(sgraph1 = graph.graphs[graph.graphdict[gid]]))
-            continue;
-        sgraph2 = graph2.graphs[graph2.graphdict[gid]];
-        sgraph1.draws = gt.unpackalldraw (gt, sgraph2.graphattr);
-    }
-    for (nid in graph2.nodedict) {
-        if (~(node1 = graph.nodes[graph.nodedict[nid]]))
-            continue;
-        node2 = graph2.nodes[graph2.nodedict[nid]];
-        node1.draws = gt.unpackalldraw (gt, node2.attr);
-        t1 = split (node2.attr.pos, ',');
-        pos = ['x' = ston (t1[0]); 'y' = ston (t1[1]);];
-        size = [
-            'x' = ston (node2.attr.width) * 72;
-            'y' = ston (node2.attr.height) * 72;
-        ];
-        node1.pos = pos;
-        node1.size = size;
-        node1.rect = [
-            0 = ['x' = pos.x - size.x / 2; 'y' = pos.y - size.y / 2;];
-            1 = ['x' = pos.x + size.x / 2; 'y' = pos.y + size.y / 2;];
-        ];
-    }
-    for (eid in graph2.edges) {
-        edge2 = graph2.edges[eid];
-        if (edge2.attr.id) {
-            if (~(edge1 = graph.edges[ston (edge2.attr.id)]))
-                continue;
-        } else if (graph == graph2)
-            edge1 = edge2;
-        edge1.draws = gt.unpackalldraw (gt, edge2.attr);
-    }
-    graph.draws = gt.unpackalldraw (gt, graph2.graphattr);
-    t1 = split (graph2.graphattr.bb, ',');
-    graph.rect[0].x = ston (t1[0]);
-    graph.rect[0].y = ston (t1[1]);
-    graph.rect[1].x = ston (t1[2]);
-    graph.rect[1].y = ston (t1[3]);
-    if (gt.graph ~= graph2)
-        return;
-    # strip position and size info from the attributes
-    for (gid in graph2.graphdict) {
-        sgraph2 = graph2.graphs[graph2.graphdict[gid]];
-        gt.removealldraw (gt, sgraph2.graphattr);
-        if (sgraph2.graphattr.bb)
-            remove ('bb', sgraph2.graphattr);
-    }
-    for (nid in graph2.nodedict) {
-        node2 = graph2.nodes[graph2.nodedict[nid]];
-        gt.removealldraw (gt, node2.attr);
-        if (node2.attr.rects)
-            remove ('rects', node2.attr);
-        remove ('pos', node2.attr);
-        remove ('width', node2.attr);
-        remove ('height', node2.attr);
-    }
-    for (eid in graph2.edges) {
-        edge2 = graph2.edges[eid];
-        gt.removealldraw (gt, edge2.attr);
-        if (edge2.attr.pos)
-            remove ('pos', edge2.attr);
-        if (edge2.attr.lp)
-            remove ('lp', edge2.attr);
-    }
-    gt.removealldraw (gt, graph2.graphattr);
-    remove ('bb', graph2.graphattr);
-    if (graph2.graphattr.lp)
-        remove ('lp', graph2.graphattr);
-};
-#
-# draw directive parsing
-#
-dotty.protogt.unpackalldraw = function (gt, attr) {
-    local o, did;
-
-    o = [];
-    if (attr._draw_)
-        o._draw_ = gt.unpackdraw (gt, attr._draw_);
-    if (attr._background)
-        o._background = gt.unpackdraw (gt, attr._background);
-    if (attr._ldraw_)
-        o._ldraw_ = gt.unpackdraw (gt, attr._ldraw_);
-    if (attr._hdraw_)
-        o._hdraw_ = gt.unpackdraw (gt, attr._hdraw_);
-    if (attr._tdraw_)
-        o._tdraw_ = gt.unpackdraw (gt, attr._tdraw_);
-    if (attr._hldraw_)
-        o._hldraw_ = gt.unpackdraw (gt, attr._hldraw_);
-    if (attr._tldraw_)
-        o._tldraw_ = gt.unpackdraw (gt, attr._tldraw_);
-    for (did in o)
-        if (o[did].ep) {
-            o.ep = o[did].ep;
-            break;
-        }
-    return o;
-};
-dotty.protogt.removealldraw = function (gt, attr) {
-    if (attr._draw_)
-        remove ('_draw_', attr);
-    if (attr._ldraw_)
-        remove ('_ldraw_', attr);
-    if (attr._hdraw_)
-        remove ('_hdraw_', attr);
-    if (attr._tdraw_)
-        remove ('_tdraw_', attr);
-    if (attr._hldraw_)
-        remove ('_hldraw_', attr);
-    if (attr._tldraw_)
-        remove ('_tldraw_', attr);
-};
-dotty.protogt.unpackdraw = function (gt, attr) {
-    local oo, o, tt, t, n, i, j, s, l, ep;
-
-    oo = [];
-    t = split (attr, ' ', 0);
-    n = tablesize (t);
-    if (t[n - 1] == '') {
-        remove (n - 1, t);
-        n = n - 1;
-    }
-    i = 0;
-    while (i < n) {
-        o = [];
-        if (t[i] == 'E') {
-            o.type = t[i];
-            o.c.x = ston (t[i + 1]);
-            o.c.y = ston (t[i + 2]);
-            o.s.x = ston (t[i + 3]);
-            o.s.y = ston (t[i + 4]);
-            i = i + 5;
-        } else if (t[i] == 'e') {
-            o.type = t[i];
-            o.c.x = ston (t[i + 1]);
-            o.c.y = ston (t[i + 2]);
-            o.s.x = ston (t[i + 3]);
-            o.s.y = ston (t[i + 4]);
-            i = i + 5;
-        } else if (t[i] == 'P') {
-            o.type = t[i];
-            o.n = ston (t[i + 1]);
-            for (j = 0; j < o.n; j = j + 1) {
-                o.ps[j].x = ston (t[i + 2 + j * 2]);
-                o.ps[j].y = ston (t[i + 2 + j * 2 + 1]);
-            }
-            i = i + 2 + o.n * 2;
-            o.ps[o.n] = o.ps[0];
-            o.n = o.n + 1;
-        } else if (t[i] == 'p') {
-            o.type = t[i];
-            o.n = ston (t[i + 1]);
-            for (j = 0; j < o.n; j = j + 1) {
-                o.ps[j].x = ston (t[i + 2 + j * 2]);
-                o.ps[j].y = ston (t[i + 2 + j * 2 + 1]);
-            }
-            i = i + 2 + o.n * 2;
-            o.ps[o.n] = o.ps[0];
-            o.n = o.n + 1;
-        } else if (t[i] == 'L') {
-            o.type = t[i];
-            o.n = ston (t[i + 1]);
-            for (j = 0; j < o.n; j = j + 1) {
-                o.ps[j].x = ston (t[i + 2 + j * 2]);
-                o.ps[j].y = ston (t[i + 2 + j * 2 + 1]);
-            }
-            i = i + 2 + o.n * 2;
-            if (~ep)
-                ep = copy (o.ps[1]);
-        } else if (t[i] == 'B') {
-            o.type = t[i];
-            o.n = ston (t[i + 1]);
-            for (j = 0; j < o.n; j = j + 1) {
-                o.ps[j].x = ston (t[i + 2 + j * 2]);
-                o.ps[j].y = ston (t[i + 2 + j * 2 + 1]);
-            }
-            i = i + 2 + o.n * 2;
-            if (~ep)
-                ep = copy (o.ps[1]);
-        } else if (t[i] == 'b') {
-            o.type = t[i];
-            o.n = ston (t[i + 1]);
-            for (j = 0; j < o.n; j = j + 1) {
-                o.ps[j].x = ston (t[i + 2 + j * 2]);
-                o.ps[j].y = ston (t[i + 2 + j * 2 + 1]);
-            }
-            i = i + 2 + o.n * 2;
-            if (~ep)
-                ep = copy (o.ps[1]);
-        } else if (t[i] == 'T') {
-            o.type = t[i];
-            o.p.x = ston (t[i + 1]);
-            o.p.y = ston (t[i + 2]);
-            o.j = ston (t[i + 3]);
-            if (o.j == -1)
-                o.j = 'lb';
-            else if (o.j == 1)
-                o.j = 'rb';
-            else if (o.j == 0)
-                o.j = 'cb';
-            o.w = ston (t[i + 4]);
-            o.n = ston (t[i + 5]);
-            i = i + 6;
-            s = t[i];
-            i = i + 1;
-            l = strlen (s) - 1;
-            while (l < o.n) {
-                s = concat (s, ' ', t[i]);
-                l = l + 1 + strlen (t[i]);
-                i = i + 1;
-            }
-            tt = split (s, '');
-            l = tablesize (tt);
-            s = '';
-            for (j = 1; j < l; j = j + 1)
-                s = concat (s, tt[j]);
-            o.s = s;
-        } else if (t[i] == 'C') {
-            o.type = t[i];
-            o.n = ston (t[i + 1]);
-            i = i + 2;
-            s = t[i];
-            i = i + 1;
-            l = strlen (s) - 1;
-            while (l < o.n) {
-                s = concat (s, ' ', t[i]);
-                l = l + 1 + strlen (t[i]);
-                i = i + 1;
-            }
-            tt = split (s, '');
-            l = tablesize (tt);
-            s = '';
-            for (j = 1; j < l; j = j + 1)
-                s = concat (s, tt[j]);
-            o.fillcolor = gt.getcolor (gt.views, s);
-        } else if (t[i] == 'c') {
-            o.type = t[i];
-            o.n = ston (t[i + 1]);
-            i = i + 2;
-            s = t[i];
-            i = i + 1;
-            l = strlen (s) - 1;
-            while (l < o.n) {
-                s = concat (s, ' ', t[i]);
-                l = l + 1 + strlen (t[i]);
-                i = i + 1;
-            }
-            tt = split (s, '');
-            l = tablesize (tt);
-            s = '';
-            for (j = 1; j < l; j = j + 1)
-                s = concat (s, tt[j]);
-            o.drawcolor = gt.getcolor (gt.views, s);
-        } else if (t[i] == 'F') {
-            o.type = t[i];
-            o.fs = ston (t[i + 1]);
-            o.n = ston (t[i + 2]);
-            i = i + 3;
-            s = t[i];
-            i = i + 1;
-            l = strlen (s) - 1;
-            while (l < o.n) {
-                s = concat (s, ' ', t[i]);
-                l = l + 1 + strlen (t[i]);
-                i = i + 1;
-            }
-            tt = split (s, '');
-            l = tablesize (tt);
-            s = '';
-            for (j = 1; j < l; j = j + 1)
-                s = concat (s, tt[j]);
-            o.ofn = s;
-            o.fn = dotty.fontmap[s];
-        } else if (t[i] == 'S') {
-            o.type = t[i];
-            o.n = ston (t[i + 1]);
-            i = i + 2;
-            s = t[i];
-            i = i + 1;
-            l = strlen (s) - 1;
-            while (l < o.n) {
-                s = concat (s, ' ', t[i]);
-                l = l + 1 + strlen (t[i]);
-                i = i + 1;
-            }
-            tt = split (s, '');
-            l = tablesize (tt);
-            s = '';
-            for (j = 1; j < l; j = j + 1)
-                s = concat (s, tt[j]);
-            if (
-                s == 'solid' | s == 'dashed' | s == 'dotted' |
-                s == 'longdashed' | s == 'shortdashed'
-            )
-                o.style = s;
-            else if (s == 'bold')
-                o.width = 3;
-            else {
-                tt = split (s, '(');
-                if (tt[0] == 'setlinewidth') {
-                    tt = split (tt[1], ')');
-                    o.width = ston (tt[0]);
-                } else
-                    continue;
-            }
-        } else if (t[i] == 'I') {
-            i = i + 7;
-        } else if (t[i] == 't') {
-            i = i + 2;
-        } else {
-            dotty.message (0, concat ('draw language parser error: ', t[i]));
-            return null;
-        }
-        oo[tablesize (oo)] = o;
-    }
-    oo.ep = ep;
-    return oo;
-};
diff --git a/cmd/dotty/dotty_ui.lefty b/cmd/dotty/dotty_ui.lefty
deleted file mode 100644 (file)
index 270c0c8..0000000
+++ /dev/null
@@ -1,477 +0,0 @@
-#
-# dotty_ui: user interface functions and data structures
-#
-dotty.protogt.doaction = function (data, s) {
-    local vt, gt;
-
-    vt = dotty.views[data.widget];
-    gt = dotty.graphs[vt.gtid];
-    data.menuitem = s;
-    if (data.obj.nid >= 0) {
-        if (gt.actions.node[s]) {
-            gt.actions.node[s] (gt, vt, data.obj, data);
-            return;
-        }
-    } else if (data.obj.eid >= 0) {
-        if (gt.actions.edge[s]) {
-            gt.actions.edge[s] (gt, vt, data.obj, data);
-            return;
-        }
-    }
-    if (gt.actions.general[s])
-        gt.actions.general[s] (gt, vt, data);
-};
-dotty.protogt.actions.general = [
-    "undo" = function (gt, vt, data) {
-        gt.undo (gt, 1);
-    };
-    "paste" = function (gt, vt, data) {
-        gt.paste (gt, data.pos, 1);
-    };
-    "do layout" = function (gt, vt, data) {
-        gt.layoutgraph (gt);
-    };
-    "cancel layout" = function (gt, vt, data) {
-        gt.cancellayout (gt);
-    };
-    "redraw" = function (gt, vt, data) {
-        gt.redrawgraph (gt, [vt.vtid = vt;]);
-    };
-    "new graph" = function (gt, vt, data) {
-        gt.erasegraph (gt, null, null);
-    };
-    "load graph" = function (gt, vt, data) {
-        gt.loadgraph (gt, null, 'file', dotty.protogt.graph, 1);
-    };
-    "reload graph" = function (gt, vt, data) {
-        gt.loadgraph (gt, gt.name, gt.type, gt.graph, 1);
-    };
-    "save graph" = function (gt, vt, data) {
-        gt.savegraph (gt, gt.name, gt.type);
-    };
-    "save graph as" = function (gt, vt, data) {
-        gt.savegraph (gt, null, 'file');
-    };
-    "open view" = function (gt, vt, data) {
-        gt = dotty.protogt.creategraph (null);
-        gt.createview (gt, null);
-    };
-    "copy view" = function (gt, vt, data) {
-        gt = gt.copygraph (gt);
-        gt.createview (gt, vt);
-    };
-    "birdseye view" = function (gt, vt, data) {
-        gt.createview (gt, dotty.protovt.birdseye);
-    };
-    "clone view" = function (gt, vt, data) {
-        gt.createview (gt, vt);
-    };
-    "close view" = function (gt, vt, data) {
-        gt.destroyview (gt, vt);
-        if (tablesize (gt.views) == 0)
-            gt.destroygraph (gt);
-    };
-    "set graph attr" = function (gt, vt, data) {
-        gt.setattr (gt, ['attr' = gt.graph.graphattr;]);
-    };
-    "set node attr" = function (gt, vt, data) {
-        gt.setattr (gt, ['attr' = gt.graph.nodeattr;]);
-    };
-    "set edge attr" = function (gt, vt, data) {
-        gt.setattr (gt, ['attr' = gt.graph.edgeattr;]);
-    };
-    "zoom in" = function (gt, vt, data) {
-        gt.zoom (gt, vt, 0.5, data.pos);
-    };
-    "zoom out" = function (gt, vt, data) {
-        gt.zoom (gt, vt, 2, data.pos);
-    };
-    "zoom in slowly" = function (gt, vt, data) {
-        gt.zoom (gt, vt, 0.9, data.pos);
-    };
-    "zoom out slowly" = function (gt, vt, data) {
-        gt.zoom (gt, vt, 1.1, data.pos);
-    };
-    "scroll horizontally" = function (gt, vt, data) {
-        vt.scrollmode = 'h';
-    };
-    "scroll vertically" = function (gt, vt, data) {
-        vt.scrollmode = 'v';
-    };
-    "find node" = function (gt, vt, data) {
-        gt.findnode (gt, vt);
-    };
-    "print graph" = function (gt, vt, data) {
-        gt.printorsave (gt, vt, null, null, null, null);
-    };
-    "text view" = function (gt, vt, data) {
-        if (dotty.txtview == 'on')
-            dotty.txtview = 'off';
-        else
-            dotty.txtview = 'on';
-        txtview (dotty.txtview);
-    };
-    "quit" = function (gt, vt, data) {
-        exit ();
-    };
-];
-dotty.protogt.actions.node = [
-    "cut" = function (gt, vt, obj, data) {
-        gt.cut (gt, obj, 'one', 'support', 'cut');
-        dotty.clipgt.layoutgraph (dotty.clipgt);
-    };
-    "Cut" = function (gt, vt, obj, data) {
-        gt.cut (gt, obj, 'reachable', 'support', 'cut');
-        dotty.clipgt.layoutgraph (dotty.clipgt);
-    };
-    "copy" = function (gt, vt, obj, data) {
-        gt.cut (gt, obj, 'one', 'support', 'copy');
-        dotty.clipgt.layoutgraph (dotty.clipgt);
-    };
-    "Copy" = function (gt, vt, obj, data) {
-        gt.cut (gt, obj, 'reachable', 'support', 'copy');
-        dotty.clipgt.layoutgraph (dotty.clipgt);
-    };
-    "group" = function (gt, vt, obj, data) {
-        local kv;
-
-        if ((kv = gt.getattr (gt, obj)))
-            gt.groupnodesbyattr (gt, kv.key, kv.val, [
-                'label' = kv.val; kv.key = kv.val;
-            ], 1, 1);
-    };
-    "Group" = function (gt, vt, obj, data) {
-        local kv;
-
-        if ((kv = gt.getattr (gt, obj)))
-            gt.groupnodesbyattr (gt, kv.key, kv.val, [
-                'label' = kv.val; kv.key = kv.val;
-            ], 0, 1);
-    };
-    "delete" = function (gt, vt, obj, data) {
-        if (obj.eid >= 0)
-            gt.removeedge (gt, obj);
-        else
-            gt.removenode (gt, obj);
-    };
-    "Delete" = function (gt, vt, obj, data) {
-        gt.removesubtree (gt, obj);
-    };
-    "remove" = function (gt, vt, obj, data) {
-        if (obj.nid >= 0)
-            if ((kv = gt.getattr (gt, obj)))
-                gt.removenodesbyattr (gt, kv.key, kv.val);
-    };
-    "Remove" = function (gt, vt, obj, data) {
-        if (obj.nid >= 0)
-            if ((kv = gt.getattr (gt, obj)))
-                gt.removesubtreesbyattr (gt, kv.key, kv.val);
-    };
-    "set attr" = function (gt, vt, obj, data) {
-        gt.setattr (gt, obj);
-    };
-    "print attr" = function (gt, vt, obj, data) {
-        if (obj.nid >= 0)
-            echo ('node: ', obj.name);
-        dump (obj.attr);
-    };
-];
-dotty.protogt.actions.edge = dotty.protogt.actions.node;
-dotty.protovt.normal.menus = [
-    'general' = [
-        0 = "undo";
-        1 = "paste";
-        2 = "do layout";
-        3 = "cancel layout";
-        4 = "redraw";
-        5 = "new graph";
-        6 = "load graph";
-        7 = "reload graph";
-        8 = "save graph";
-        9 = "save graph as";
-        10 = "open view";
-        11 = "copy view";
-        12 = "clone view";
-        13 = "birdseye view";
-        14 = "close view";
-        15 = "set graph attr";
-        16 = "set node attr";
-        17 = "set edge attr";
-        18 = "zoom in";
-        19 = "zoom out";
-        20 = "find node";
-        21 = "print graph";
-        22 = "text view";
-        23 = "quit";
-    ];
-    'node' = [
-        0 = "cut";
-        1 = "Cut";
-        2 = "copy";
-        3 = "Copy";
-        4 = "group";
-        5 = "Group";
-        6 = "delete";
-        7 = "Delete";
-        8 = "remove";
-        9 = "Remove";
-        10 = "set attr";
-        11 = "print attr";
-    ];
-    'edge' = [
-        0 = "cut";
-        1 = "Cut";
-        2 = "copy";
-        3 = "Copy";
-        4 = "delete";
-        5 = "Delete";
-        6 = "set attr";
-        7 = "print attr";
-    ];
-];
-dotty.protovt.normal.keys = [
-    'general' = [
-        'u' = "undo";
-        'p' = "paste";
-        'l' = "do layout";
-        'k' = "cancel layout";
-        ' ' = "redraw";
-        'L' = "reload graph";
-        's' = "save graph";
-        'Z' = "zoom in slowly";
-        'z' = "zoom out slowly";
-        'h' = "scroll horizontally";
-        'v' = "scroll vertically";
-    ];
-    'node' = [
-        'c' = "copy";
-        'C' = "Copy";
-        'g' = "group";
-        'G' = "Group";
-        'd' = "delete";
-        'D' = "Delete";
-        'r' = "remove";
-        'R' = "Remove";
-        'a' = "set attr";
-    ];
-    'edge' = [
-        'c' = "copy";
-        'C' = "Copy";
-        'd' = "delete";
-        'D' = "Delete";
-        'a' = "set attr";
-    ];
-];
-dotty.protovt.birdseye.menus = dotty.protovt.normal.menus;
-dotty.protovt.birdseye.keys = dotty.protovt.normal.keys;
-dotty.protovt.normal.uifuncs = [
-    'leftdown' = function (data) {
-        local gt;
-
-        gt = dotty.graphs[dotty.views[data.widget].gtid];
-        if (data.obj.nid >= 0) {
-            dotty.node2move = data.obj;
-            dotty.movewidget = data.widget;
-            dotty.rp2 = data.pos;
-            # save the previous object pos
-            dotty.node_ppos = data.obj.pos;
-        }
-    };
-    'leftmove' = function (data) {
-        local gt, offset_pos;
-
-        gt = dotty.graphs[dotty.views[data.widget].gtid];
-        if (dotty.node2move & (
-            dotty.rp2.x ~= data.pos.x | dotty.rp2.y ~= data.pos.y
-        )) {
-            # use an offset from the cursor to the node's pre-move position
-            offset_pos.x = data.pos.x - (dotty.rp2.x - dotty.node_ppos.x);
-            offset_pos.y = data.pos.y - (dotty.rp2.y - dotty.node_ppos.y);
-            gt.movenode (gt, dotty.node2move, offset_pos);
-            dotty.rp2 = data.pos;
-        }
-    };
-    'leftup' = function (data) {
-        local gt, offset_pos;
-
-        gt = dotty.graphs[dotty.views[data.widget].gtid];
-        if (dotty.node2move) {
-            if (dotty.movewidget == data.widget) {
-                offset_pos.x = data.pos.x - (dotty.rp2.x - dotty.node_ppos.x);
-                offset_pos.y = data.pos.y - (dotty.rp2.y - dotty.node_ppos.y);
-                gt.movenode (gt, dotty.node2move, offset_pos);
-            }
-            dotty.node2move = 0;
-        } else if (~data.obj)
-            gt.insertnode (gt, data.pos, null, null, null, 1);
-        gt.redrawgraph(gt, gt.views);
-    };
-    'middledown' = function (data) {
-        if (~(data.obj.nid >= 0))
-            return;
-        dotty.rubberband = 1;
-        dotty.movewidget = data.widget;
-        setgfxattr (data.widget, ['mode' = 'xor';]);
-        dotty.rp1 = data.pos;
-        dotty.rp2 = data.pos;
-        line (data.widget, null, dotty.rp1, dotty.rp2, ['color' = 1;]);
-    };
-    'middlemove' = function (data) {
-        if (dotty.rubberband ~= 1 | (
-            dotty.rp2.x == data.pos.x & dotty.rp2.y == data.pos.y
-        ))
-            return;
-        line (data.widget, null, dotty.rp1, dotty.rp2, ['color' = 1;]);
-        dotty.rp2 = data.pos;
-        line (data.widget, null, dotty.rp1, dotty.rp2, ['color' = 1;]);
-    };
-    'middleup' = function (data) {
-        local gt;
-
-        gt = dotty.graphs[dotty.views[data.widget].gtid];
-        if (dotty.rubberband ~= 1)
-            return;
-        dotty.rubberband = 0;
-        line (dotty.movewidget, null, dotty.rp1, dotty.rp2, ['color' = 1;]);
-        setgfxattr (dotty.movewidget, ['mode' = 'src';]);
-        if (dotty.movewidget ~= data.widget | ~(
-            data.pobj.nid >= 0) | ~(data.obj.nid >= 0
-        ))
-            return;
-        if (data.pobj.attr.support)
-            gt.groupnodes (gt, [
-                data.obj.nid = data.obj;
-                data.pobj.nid = data.pobj;
-            ], data.obj, null, null, null, 1, 1);
-        else if (data.obj.attr.support)
-            gt.groupnodes (gt, [
-                data.obj.nid = data.obj;
-                data.pobj.nid = data.pobj;
-            ], data.pobj, null, null, null, 1, 1);
-        else
-            gt.insertedge (gt, data.pobj, null, data.obj, null, null, 1);
-    };
-    'rightup' = function (data) {
-        local vt, gt, menu, i;
-
-        vt = dotty.views[data.widget];
-        gt = dotty.graphs[vt.gtid];
-        if (~data.obj)
-            menu = vt.menus.general;
-        else if (data.obj.nid >= 0)
-            menu = vt.menus.node;
-        else if (data.obj.eid >= 0)
-            menu = vt.menus.edge;
-        if ((i = displaymenu (data.widget, menu)) >= 0)
-            gt.doaction (data, menu[i]);
-    };
-    'button3up' = function (data) {
-        local vt, attr;
-
-        vt = dotty.views[data.widget];
-        attr = getwidgetattr (vt.scroll, [0 = 'childcenter';]);
-        if (vt.scrollmode == 'h')
-            attr.childcenter.x = attr.childcenter.x - 40;
-        else
-            attr.childcenter.y = attr.childcenter.y - 40;
-        setwidgetattr (vt.scroll, ['childcenter' = attr.childcenter;]);
-    };
-    'button4up' = function (data) {
-        local vt, attr;
-
-        vt = dotty.views[data.widget];
-        attr = getwidgetattr (vt.scroll, [0 = 'childcenter';]);
-        if (vt.scrollmode == 'h')
-            attr.childcenter.x = attr.childcenter.x + 40;
-        else
-            attr.childcenter.y = attr.childcenter.y + 40;
-        setwidgetattr (vt.scroll, ['childcenter' = attr.childcenter;]);
-    };
-    'keyup' = function (data) {
-        local vt, gt, action;
-
-        vt = dotty.views[data.widget];
-        gt = dotty.graphs[vt.gtid];
-        if (data.obj.nid >= 0) {
-            if (vt.keys.node[data.key])
-                action = vt.keys.node[data.key];
-        } else if (data.obj.eid >= 0) {
-            if (vt.keys.edge[data.key])
-                action = vt.keys.edge[data.key];
-        }
-        if (~action)
-            if (vt.keys.general[data.key])
-                action = vt.keys.general[data.key];
-        if (action)
-            gt.doaction (data, action);
-    };
-    'redraw' = function (data) {
-        local vt, gt;
-
-        vt = dotty.views[data.widget];
-        gt = dotty.graphs[vt.gtid];
-        gt.drawgraph (gt, [vt.vtid = vt;]);
-    };
-    'closeview' = function (data) {
-        local vt, gt;
-
-        vt = dotty.views[data.widget];
-        gt = dotty.graphs[vt.gtid];
-        gt.destroyview (gt, vt);
-        if (tablesize (gt.views) == 0)
-            gt.destroygraph (gt);
-    };
-];
-dotty.protovt.birdseye.uifuncs = [
-    'leftdown' = function (data) {
-        local gt, vid;
-
-        gt = dotty.graphs[dotty.views[data.widget].gtid];
-        for (vid in gt.views) {
-            vt = gt.views[vid];
-            if (vt.type ~= 'birdseye')
-                gt.setviewcenter ([vid = vt;], data.pos);
-        }
-    };
-    'leftmove' = function (data) {
-        local gt, vid;
-
-        gt = dotty.graphs[dotty.views[data.widget].gtid];
-        for (vid in gt.views) {
-            vt = gt.views[vid];
-            if (vt.type ~= 'birdseye')
-                gt.setviewcenter ([vid = vt;], data.pos);
-        }
-    };
-    'leftup' = function (data) {
-        local gt, vid;
-
-        gt = dotty.graphs[dotty.views[data.widget].gtid];
-        for (vid in gt.views) {
-            vt = gt.views[vid];
-            if (vt.type ~= 'birdseye')
-                gt.setviewcenter ([vid = vt;], data.pos);
-        }
-    };
-    'middledown' = dotty.protovt.normal.uifuncs.middledown;
-    'middlemove' = dotty.protovt.normal.uifuncs.middlemove;
-    'middleup' = dotty.protovt.normal.uifuncs.middleup;
-    'rightup' = dotty.protovt.normal.uifuncs.rightup;
-    'keyup' = dotty.protovt.normal.uifuncs.keyup;
-    'redraw' = dotty.protovt.normal.uifuncs.redraw;
-    'closeview' = dotty.protovt.normal.uifuncs.closeview;
-];
-dotty.monitorfile = function (data) {
-    local gtid, gt, lpt;
-
-    for (gtid in dotty.layoutpending) {
-        lpt = dotty.layoutpending[gtid];
-        if (lpt.fd == data.fd) {
-            gt = dotty.graphs[lpt.gtid];
-            gt.haveinput = 1;
-            gt.layoutgraph (gt);
-            return 1;
-        }
-    }
-    return 0;
-};
diff --git a/cmd/dotty/mswin32/doinst b/cmd/dotty/mswin32/doinst
deleted file mode 100755 (executable)
index 7ceb57c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-set -x
-
-if [[ $1 == '' || $1 == '-d' ]] then
-    cp -p debug/dotty.exe ../bin
-elif [[ $1 == '-a' ]] then
-    cp -p release/dotty.exe ../bin
-fi
-cp -p *.lefty ../lib/lefty
diff --git a/cmd/dotty/mswin32/dotty.c b/cmd/dotty/mswin32/dotty.c
deleted file mode 100644 (file)
index 0366885..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
-
-#include <windows.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <shellapi.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <cgraph/exit.h>
-
-static char *shellpath;
-
-static char *buildpath (char *);
-static void panic (char *, int, char *, char *, ...);
-
-static char* lneato =
-#ifdef LNEATO
-  "dotty.protogt.lserver='neato';";
-#else
-  "";
-#endif
-
-int APIENTRY WinMain (
-    HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow
-) {
-    STARTUPINFO si;
-    PROCESS_INFORMATION pi;
-    char cmd[256];
-    char *path;
-    char *s;
-    int argc;
-    LPWSTR *argv;
-
-    ZeroMemory (&si, sizeof(si));
-    si.cb = sizeof(si);
-    ZeroMemory (&pi, sizeof(pi));
-
-    shellpath = getenv ("PATH");
-    if (!shellpath || !(path = buildpath ("lefty"))) {
-        if (!GetModuleFileName (hInstance, cmd, 256) ||
-                !(s = strrchr (cmd, '\\')))
-            graphviz_exit(1);
-        *s = 0;
-        shellpath = &cmd[0];
-        if (!(path = buildpath ("lefty")))
-            graphviz_exit(1);
-    }
-    argv = CommandLineToArgvW(lpCmdLine, &argc);
-    if (argc == 1 && strcmp(argv[0], "-?") == 0) {
-        fprintf(stderr, "usage: dotty [-V] [-lm (sync|async)] [-el (0|1)] <filename>\n");
-        graphviz_exit(0);
-    }
-    if (lpCmdLine[0] == 0)
-        snprintf(cmd, sizeof(cmd), "%s -e \"load('dotty.lefty');%sdotty.init();"
-                 "dotty.createviewandgraph(null,'file',null,null);"
-                 "txtview('off');\"", path, lneato);
-    else
-        snprintf(cmd, sizeof(cmd), "%s -e \"load('dotty.lefty');%sdotty.init();"
-                 "dotty.createviewandgraph('%Ns','file',null,null);"
-                 "txtview('off');\"", path, lneato, lpCmdLine);
-
-    CreateProcess (
-        NULL,   // No module name (use command line). 
-        cmd, // Command line. 
-        NULL,             // Process handle not inheritable. 
-        NULL,             // Thread handle not inheritable. 
-        FALSE,            // Set handle inheritance to FALSE. 
-        0,                // No creation flags. 
-        NULL,             // Use parent's environment block. 
-        NULL,             // Use parent's starting directory. 
-        &si,              // Pointer to STARTUPINFO structure.
-        &pi             // Pointer to PROCESS_INFORMATION structure.
-    );
-    graphviz_exit(0);
-}
-
-#define PATHDEL '\\'
-#define PATHSEP ';'
-
-static char pathbuf[1024];
-static char commandbuf[1024];
-
-static char *buildpath (char *file) {
-    struct stat statbuf;
-    char *s1, *s2;
-    int mode, pathi;
-
-    if (file && file[0] && (file[0] == '.' || file[0] == PATHDEL))
-        return file;
-    mode = ~0;
-    s1 = shellpath;
-    while (*s1) {
-        pathi = 0;
-        while (*s1 && *s1 != PATHSEP)
-            pathbuf[pathi++] = *s1++;
-        if (*s1)
-            s1++;
-        pathbuf[pathi++] = PATHDEL;
-        for (s2 = file; *s2; s2++)
-            pathbuf[pathi++] = *s2;
-        pathbuf[pathi++] = '.';
-        pathbuf[pathi++] = 'e';
-        pathbuf[pathi++] = 'x';
-        pathbuf[pathi++] = 'e';
-        pathbuf[pathi] = '\000';
-        if (stat (pathbuf, &statbuf) == 0 && (statbuf.st_mode & mode))
-            return pathbuf;
-    }
-    return NULL;
-}
-
-static void panic (char *file, int line, char *func, char *fmt, ...) {
-    va_list args;
-
-    va_start(args, fmt);
-    {
-        char buf[256];
-        vsprintf (buf, fmt, args);
-        MessageBox ((HWND) NULL, buf, "dotty PANIC", MB_APPLMODAL);
-    }
-    abort ();
-}
diff --git a/cmd/dotty/mswin32/dotty.mak b/cmd/dotty/mswin32/dotty.mak
deleted file mode 100644 (file)
index 41a97e3..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-!IF "$(CFG)" == ""
-CFG=dotty - Win32 Debug
-!MESSAGE No configuration specified.  Defaulting to dotty - Win32 Debug.
-!ENDIF 
-
-!IF "$(CFG)" != "dotty - Win32 Release" && "$(CFG)" != "dotty - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE on this makefile
-!MESSAGE by defining the macro CFG on the command line.  For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "dotty.mak" CFG="dotty - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "dotty - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "dotty - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE 
-!ERROR An invalid configuration is specified.
-!ENDIF 
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE 
-NULL=nul
-!ENDIF 
-################################################################################
-# Begin Project
-# PROP Target_Last_Scanned "dotty - Win32 Debug"
-CPP=cl.exe
-RSC=rc.exe
-MTL=mktyplib.exe
-
-!IF  "$(CFG)" == "dotty - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-OUTDIR=.\Release
-INTDIR=.\Release
-
-ALL : "$(OUTDIR)\dotty.exe"
-
-CLEAN : 
-       -@erase "$(INTDIR)\DOTTY.OBJ"
-       -@erase "$(OUTDIR)\dotty.exe"
-
-"$(OUTDIR)" :
-    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "MSWIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /W3 /GX /O2 /D "MSWIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "MSWIN32" /D "NDEBUG" /D "_WINDOWS"\
- /Fp"$(INTDIR)/dotty.pch" /YX /Fo"$(INTDIR)/" /c 
-CPP_OBJS=.\Release/
-CPP_SBRS=.\.
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /win32
-MTL_PROJ=/nologo /D "NDEBUG" /win32 
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/dotty.bsc" 
-BSC32_SBRS= \
-       
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
- advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
- odbccp32.lib /nologo /subsystem:windows /incremental:no\
- /pdb:"$(OUTDIR)/dotty.pdb" /machine:I386 /out:"$(OUTDIR)/dotty.exe" 
-LINK32_OBJS= \
-       "$(INTDIR)\DOTTY.OBJ"
-
-"$(OUTDIR)\dotty.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-    $(LINK32) @<<
-  $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF  "$(CFG)" == "dotty - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-OUTDIR=.\Debug
-INTDIR=.\Debug
-
-ALL : "$(OUTDIR)\dotty.exe"
-
-CLEAN : 
-       -@erase "$(INTDIR)\DOTTY.OBJ"
-       -@erase "$(INTDIR)\vc40.idb"
-       -@erase "$(INTDIR)\vc40.pdb"
-       -@erase "$(OUTDIR)\dotty.exe"
-       -@erase "$(OUTDIR)\dotty.ilk"
-       -@erase "$(OUTDIR)\dotty.pdb"
-
-"$(OUTDIR)" :
-    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "MSWIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "MSWIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "MSWIN32" /D "_DEBUG" /D\
- "_WINDOWS" /Fp"$(INTDIR)/dotty.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c 
-CPP_OBJS=.\Debug/
-CPP_SBRS=.\.
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /win32
-MTL_PROJ=/nologo /D "_DEBUG" /win32 
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/dotty.bsc" 
-BSC32_SBRS= \
-       
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
- advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
- odbccp32.lib /nologo /subsystem:windows /incremental:yes\
- /pdb:"$(OUTDIR)/dotty.pdb" /debug /machine:I386 /out:"$(OUTDIR)/dotty.exe" 
-LINK32_OBJS= \
-       "$(INTDIR)\DOTTY.OBJ"
-
-"$(OUTDIR)\dotty.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-    $(LINK32) @<<
-  $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF 
-
-.c{$(CPP_OBJS)}.obj:
-   $(CPP) $(CPP_PROJ) $<  
-
-.cpp{$(CPP_OBJS)}.obj:
-   $(CPP) $(CPP_PROJ) $<  
-
-.cxx{$(CPP_OBJS)}.obj:
-   $(CPP) $(CPP_PROJ) $<  
-
-.c{$(CPP_SBRS)}.sbr:
-   $(CPP) $(CPP_PROJ) $<  
-
-.cpp{$(CPP_SBRS)}.sbr:
-   $(CPP) $(CPP_PROJ) $<  
-
-.cxx{$(CPP_SBRS)}.sbr:
-   $(CPP) $(CPP_PROJ) $<  
-
-################################################################################
-# Begin Target
-
-# Name "dotty - Win32 Release"
-# Name "dotty - Win32 Debug"
-
-!IF  "$(CFG)" == "dotty - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "dotty - Win32 Debug"
-
-!ENDIF 
-
-################################################################################
-# Begin Source File
-
-SOURCE=.\DOTTY.C
-DEP_CPP_DOTTY=\
-       {$(INCLUDE)}"\sys\stat.h"\
-       {$(INCLUDE)}"\sys\types.h"\
-       
-
-"$(INTDIR)\DOTTY.OBJ" : $(SOURCE) $(DEP_CPP_DOTTY) "$(INTDIR)"
-
-
-# End Source File
-# End Target
-# End Project
-################################################################################
diff --git a/cmd/dotty/notes b/cmd/dotty/notes
deleted file mode 100644 (file)
index aeefefa..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-fisheye view
-set graph attr
-set proto attr
diff --git a/cmd/lefty/LOG b/cmd/lefty/LOG
deleted file mode 100644 (file)
index 1a60226..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-901214 merged cheyenne.a with devices/x11 and made libgfx.a
-901220 changed the interface to dag to do a straight copy
-910201 changed parse.c and exec.c to make code a scalar object
-       (it used to be a table)
-910214 changed the way function declarations within function
-       declarations are handled.
-910418 added Xt support
-       changed gc to incremental
-910422 removed the mark field from mem.c objects
-       removed the time field from scalar objects
-910425 improved performance of spline drawing
-       added the ability to read files
-910501 added menus
-910503 optimized getva[rl] to not do unnecessary eeval's
-910506 optimized earithmetic to not eeval unless necessary
-       changed stack from being a gc table to being an array.
-910508 changed gg:findfont to keep a cache of fonts
-910521 fixed a color bug in gps.c
-910720 fixed bug in g.c where the buttonsdown wasn't updated
-       fixed gfxview.c to check if down objects have been gc'ed
-       added a recursive copy builtin
-910724 saved one word per gc object by making an array of offsets
-910726 changed the hashtables to variable size hash tables
-910809 combined type and size words into one
-       upgraded to SUNOS 4.1.1
-910826 changed lefty to use a path when searching for cmds of libs.
-       cleaned up code
-910905 cleaned up code to work with cc
-920308 cleaned up widget code
-       added support for Xaw widgets from LEFTY's language
-920813 changed the meaning of null objects for 'not equal'
-       changed text rendering options
-       changed gfxview to look in widgets and in root for functions
-       fixed arrows to always have the same size
-       split recognises \n
-       added node deletion in dot.lefty
-921107 new memory allocation scheme
-       cleanup
-930407 fixed file I/O events to not interfere with plain X events
-       message built-in is gone
-       fixed bug where text with non-existant font was slow
-       split handles ' ' like the shell (multiple spaces are treated as one)
-930614 fix ``return from outside a func'' bug
-       made openio use LEFTYPATH for plain files too
-931208 added cursor setting support for canvases
-940620 re-arranged the graphics library
-950126 added getenv putenv, fixed bugs in libgfx
-950906 added bitmap functions
-951207 added win32 support
diff --git a/cmd/lefty/aix_mods/common.h b/cmd/lefty/aix_mods/common.h
deleted file mode 100644 (file)
index 35fd599..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
-
-#ifndef _COMMON_H
-#define _COMMON_H
-#ifdef HAVECS
-#include <ast.h>
-#else
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif
-
-#include <stdbool.h>
-#include <sys/select.h>
-#include <math.h>
-#include <stdio.h>
-#include <setjmp.h>
-#include <ctype.h>
-
-#ifdef _WIN32
-#include <windows.h>
-#include <commdlg.h>
-#endif
-
-#define POS __FILE__, __LINE__
-
-#ifndef TRUE
-#define TRUE  1
-#define FALSE 0
-#endif
-
-#ifndef L_SUCCESS
-#define L_SUCCESS 1
-#define L_FAILURE 0
-#endif
-
-#define CHARSRC 0
-#define FILESRC 1
-
-    extern int warnflag;
-    extern char *leftypath, *leftyoptions, *shellpath;
-    extern jmp_buf exitljbuf;
-    extern int idlerunmode;
-    extern fd_set inputfds;
-
-    int init(char *);
-    void term(void);
-    char *buildpath(char *, bool);
-    char *buildcommand(char *, char *, int, int, char *);
-    void warning(char *, int, char *, char *, ...);
-
-#ifdef __GNUC__
-  // FIXME: use _Noreturn for all compilers when we move to C11
-  #define NORETURN __attribute__((noreturn))
-#else
-  #define NORETURN /* nothing */
-#endif
-    NORETURN void panic1(char *, int, char *, char *, ...);
-    NORETURN void panic2(char *, int, char *, char *, ...);
-#undef NORETURN
-
-#endif                         /* _COMMON_H */
diff --git a/cmd/lefty/aix_mods/exec.c b/cmd/lefty/aix_mods/exec.c
deleted file mode 100644 (file)
index 677a742..0000000
+++ /dev/null
@@ -1,994 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
-
-#include "common.h"
-#include "mem.h"
-#include "code.h"
-#include "tbl.h"
-#include "str.h"
-#include "exec.h"
-#include "internal.h"
-#include <string.h>
-#include <stdbool.h>
-
-static lvar_t *lvarp;
-static int lvarn, llvari, flvari;
-#define LVARINCR 1000
-#define LVARSIZE sizeof (lvar_t)
-
-Tobj root, null;
-Tobj rtno;
-bool Erun;
-int Eerrlevel, Estackdepth, Eshowbody;
-
-#define PUSHJMP(op, np, b) op = (volatile jmp_buf *) np, np = (jmp_buf *) &b
-#define POPJMP(op, np) np = (jmp_buf *) op
-
-/* longjmps for normal program execution */
-typedef enum {
-    PLJ_BREAK, PLJ_CONTINUE, PLJ_RETURN, PLJ_SIZE
-} PLJtype_t;
-static jmp_buf *pljbufp1, *pljbufp2;
-static PLJtype_t pljtype;
-
-/* longjmp for error handling */
-static jmp_buf *eljbufp;
-
-/* error levels and types */
-typedef enum {
-    ERR0, ERR1, ERR2, ERR3, ERR4, ERR5
-} errlevel_t;
-typedef enum {
-    ERRNOLHS, ERRNORHS, ERRNOSUCHFUNC, ERRBADARG, ERRARGMIS, ERRNOTATABLE,
-    ERRIFUNCERR, ERRRECRUN, ERRTABLECHANGED
-} errnum_t;
-static char *errnam[] = {
-    "no variable",
-    "no value",
-    "no such function",
-    "bad argument",
-    "argument number mismatch",
-    "not a table",
-    "internal function call error",
-    "recursive run attempt",
-    "table changed during a forin loop",
-};
-
-static bool errdo;
-
-/* stack information */
-typedef struct sinfo_t {
-    Tobj co, fco;
-    int ci, fci;
-    int flvari, llvari;
-} sinfo_t;
-#define SINFOSIZE sizeof (sinfo_t)
-#define SINFOINCR 100
-static sinfo_t *sinfop;
-static int sinfoi, sinfon;
-
-typedef enum {
-    TNK_LI, TNK_O, TNK_S
-} tnktype_t;
-typedef struct tnk_t {
-    tnktype_t type;
-    union {
-       int li;
-       struct {
-           Tobj to, ko;
-       } tnko;
-       struct {
-           Ctype_t kt;
-           Tobj to, co;
-           int vi;
-       } tnks;
-    } u;
-} tnk_t;
-
-typedef struct num_tt {
-    Ctype_t type;
-    union {
-       long i;
-       double d;
-       Tobj no;
-    } u;
-} num_tt;
-
-static long rootm;
-static int running;
-
-static Tobj eeval(Tobj, int);
-static Tobj efcall(Tobj, int);
-static void ewhilest(Tobj, int);
-static void eforst(Tobj, int);
-static void eforinst(Tobj, int);
-
-static Tobj getval(Tobj, int);
-static int getvar(Tobj, int, tnk_t *);
-static void setvar(tnk_t, Tobj);
-static bool boolop(Tobj);
-static int orderop(Tobj, Ctype_t, Tobj);
-static Tobj arithop(num_tt *, Ctype_t, num_tt *);
-static void err(int, int, Tobj, int);
-static void printbody(char *, int);
-
-void Einit(void)
-{
-    root = Ttable(100);
-    rootm = Mpushmark(root);
-    Tinss(root, "null", (null = Ttable(2)));
-    rtno = NULL;
-    pljbufp1 = pljbufp2 = NULL, pljtype = 0;
-    eljbufp = NULL;
-    lvarp = Marrayalloc((long) LVARINCR * LVARSIZE);
-    lvarn = LVARINCR;
-    llvari = 0;
-    flvari = 0;
-    sinfop = Marrayalloc((long) SINFOINCR * SINFOSIZE);
-    sinfon = SINFOINCR;
-    sinfoi = 0;
-    Erun = false;
-    running = 0;
-}
-
-void Eterm(void)
-{
-    Marrayfree(sinfop), sinfop = NULL, sinfon = 0, sinfoi = 0;
-    Marrayfree(lvarp), lvarp = NULL, lvarn = 0, llvari = 0, flvari = 0;
-    rtno = NULL;
-    null = NULL;
-    Mpopmark(rootm);
-}
-
-Tobj Eunit(Tobj co)
-{
-    volatile jmp_buf *oeljbufp;
-    volatile int ownsinfoi;
-    volatile long m;
-    volatile Tobj lrtno;
-
-    jmp_buf eljbuf;
-
-    if (!co)
-       return NULL;
-
-    if (Tgettype(co) != T_CODE)
-       panic1(POS, "Eunit", "argument type is not T_CODE");
-
-    m = Mpushmark(co);
-    PUSHJMP(oeljbufp, eljbufp, eljbuf);
-    ownsinfoi = sinfoi++;
-    if (sinfoi == sinfon) {
-       sinfop =
-           Marraygrow(sinfop, (long) (sinfon + SINFOINCR) * SINFOSIZE);
-       sinfon += SINFOINCR;
-    }
-    sinfop[ownsinfoi].co = co;
-    sinfop[ownsinfoi].ci = TCgetfp(co, 0);
-    sinfop[ownsinfoi].fco = NULL;
-    sinfop[ownsinfoi].flvari = flvari;
-    sinfop[ownsinfoi].llvari = llvari;
-    running++;
-    if (setjmp(*eljbufp))
-       lrtno = NULL;
-    else
-       lrtno = eeval(co, TCgetfp(co, 0));
-    running--;
-    rtno = NULL;
-    flvari = sinfop[ownsinfoi].flvari;
-    llvari = sinfop[ownsinfoi].llvari;
-    sinfoi = ownsinfoi;
-    POPJMP(oeljbufp, eljbufp);
-    Mpopmark(m);
-    Erun = true;
-    return lrtno;
-}
-
-/* shortcut: this function executes a piece of code that corresponds to
-   <internal func name> = function () internal "<internal func name>";
-*/
-Tobj Efunction(Tobj co, char *ifnam)
-{
-    Tobj v1o;
-    int fi;
-
-    fi = TCgetnext(co, TCgetfp(co, TCgetfp(co, 0)));
-    v1o = Tcode(TCgetaddr(co, fi), fi,
-               (int) TCgetinteger(co, TCgetfp(co, fi)));
-    Tinss(root, ifnam, v1o);
-    return v1o;
-}
-
-static Tobj eeval(Tobj co, int ci)
-{
-    Tobj v1o, v2o, v3o;
-    Ttype_t ttype;
-    Ctype_t ctype;
-    tnk_t tnk;
-    num_tt lnum, rnum;
-    long m1, m2;
-    int i1, i2, res;
-
-  tailrec:
-    errdo = true;
-    v1o = NULL;
-    ctype = TCgettype(co, ci);
-    switch (ctype) {
-    case C_ASSIGN:
-       i1 = TCgetfp(co, ci);
-       if ((v1o = eeval(co, TCgetnext(co, i1))) == NULL) {
-           err(ERRNORHS, ERR4, co, TCgetnext(co, i1));
-           return NULL;
-       }
-       m1 = Mpushmark(v1o);
-       res = getvar(co, i1, &tnk);
-       Mpopmark(m1);
-       if (res == -1) {
-           err(ERRNOLHS, ERR3, co, i1);
-           return NULL;
-       }
-       setvar(tnk, v1o);
-       return v1o;
-    case C_OR:
-    case C_AND:
-    case C_NOT:
-       i1 = TCgetfp(co, ci);
-       if ((v1o = eeval(co, i1)) == NULL)
-           err(ERRNORHS, ERR4, co, i1);
-       switch (ctype) {
-       case C_OR:
-           if (boolop(v1o))
-               return Ttrue;
-           if ((v1o = eeval(co, TCgetnext(co, i1))) == NULL)
-               err(ERRNORHS, ERR4, co, TCgetnext(co, i1));
-           return boolop(v1o) ? Ttrue : Tfalse;
-       case C_AND:
-           if (!boolop(v1o))
-               return Tfalse;
-           if ((v1o = eeval(co, TCgetnext(co, i1))) == NULL)
-               err(ERRNORHS, ERR4, co, TCgetnext(co, i1));
-           return !boolop(v1o) ? Tfalse : Ttrue;
-       case C_NOT:
-           return boolop(v1o) ? Tfalse : Ttrue;
-       }
-       /* NOT REACHED */
-       return Tfalse;
-    case C_EQ:
-    case C_NE:
-    case C_LT:
-    case C_LE:
-    case C_GT:
-    case C_GE:
-       i1 = TCgetfp(co, ci);
-       if ((v1o = eeval(co, i1)) == NULL)
-           err(ERRNORHS, ERR4, co, i1);
-       else
-           m1 = Mpushmark(v1o);
-       if ((v2o = eeval(co, TCgetnext(co, i1))) == NULL)
-           err(ERRNORHS, ERR4, co, TCgetnext(co, i1));
-       if (v1o)
-           Mpopmark(m1);
-       return orderop(v1o, ctype, v2o) ? Ttrue : Tfalse;
-    case C_PLUS:
-    case C_MINUS:
-    case C_MUL:
-    case C_DIV:
-    case C_MOD:
-    case C_UMINUS:
-       i1 = TCgetfp(co, ci);
-       if ((lnum.type = TCgettype(co, i1)) == C_INTEGER)
-           lnum.u.i = TCgetinteger(co, i1);
-       else if (lnum.type == C_REAL)
-           lnum.u.d = TCgetreal(co, i1);
-       else if ((lnum.u.no = eeval(co, i1)) == NULL) {
-           err(ERRNORHS, ERR4, co, i1);
-           return NULL;
-       }
-       if (ctype == C_UMINUS) {
-           if (!(v1o = arithop(&lnum, ctype, NULL)))
-               err(ERRNORHS, ERR4, co, ci);
-           return v1o;
-       }
-       if (lnum.type != C_INTEGER && lnum.type != C_REAL)
-           m1 = Mpushmark(lnum.u.no);
-       i1 = TCgetnext(co, i1);
-       if ((rnum.type = TCgettype(co, i1)) == C_INTEGER)
-           rnum.u.i = TCgetinteger(co, i1);
-       else if (rnum.type == C_REAL)
-           rnum.u.d = TCgetreal(co, i1);
-       else if ((rnum.u.no = eeval(co, i1)) == NULL)
-           err(ERRNORHS, ERR4, co, i1);
-       if (lnum.type != C_INTEGER && lnum.type != C_REAL)
-           Mpopmark(m1);
-       if (!(v1o = arithop(&lnum, ctype, &rnum)))
-           err(ERRNORHS, ERR4, co, ci);
-       return v1o;
-    case C_PEXPR:
-       ci = TCgetfp(co, ci);
-       goto tailrec;
-    case C_FCALL:
-       return efcall(co, ci);
-    case C_INTEGER:
-       return Tinteger(TCgetinteger(co, ci));
-    case C_REAL:
-       return Treal(TCgetreal(co, ci));
-    case C_STRING:
-       return Tstring(TCgetstring(co, ci));
-    case C_GVAR:
-    case C_LVAR:
-    case C_PVAR:
-       return getval(co, ci);
-    case C_FUNCTION:
-       return Tcode(TCgetaddr(co, ci), ci,
-                    (int) TCgetinteger(co, TCgetfp(co, ci)));
-    case C_TCONS:
-       v1o = Ttable(0);
-       m1 = Mpushmark(v1o);
-       for (i1 = TCgetfp(co, ci); i1 != C_NULL;
-            i1 = TCgetnext(co, TCgetnext(co, i1))) {
-           if (!(v3o = eeval(co, TCgetnext(co, i1)))) {
-               err(ERRNORHS, ERR4, co, TCgetnext(co, i1));
-               continue;
-           }
-           m2 = Mpushmark(v3o);
-           if (!(v2o = eeval(co, i1))) {
-               err(ERRNOLHS, ERR3, co, i1);
-               Mpopmark(m2);
-               continue;
-           }
-           ttype = Tgettype(v2o);
-           if (ttype == T_INTEGER || ttype == T_REAL || ttype == T_STRING)
-               Tinso(v1o, v2o, v3o);
-           else
-               err(ERRNOLHS, ERR1, co, i1);
-       }
-       Mpopmark(m1);
-       return v1o;
-    case C_STMT:
-       for (i1 = TCgetfp(co, ci); i1 != C_NULL;)
-           if ((i2 = TCgetnext(co, i1)) != C_NULL) {
-               eeval(co, i1);
-               i1 = i2;
-           } else {
-               ci = i1;
-               goto tailrec;
-           }
-       /* NOT REACHED */
-       break;
-    case C_IF:
-       i1 = TCgetfp(co, ci);
-       if (!(v1o = eeval(co, i1)))
-           err(ERRNORHS, ERR5, co, i1);
-       if (boolop(v1o)) {
-           ci = TCgetnext(co, i1);
-           goto tailrec;
-       } else if ((ci = TCgetnext(co, TCgetnext(co, i1))) != C_NULL)
-           goto tailrec;
-       break;
-    case C_WHILE:
-       ewhilest(co, ci);
-       break;
-    case C_FOR:
-       eforst(co, ci);
-       break;
-    case C_FORIN:
-       eforinst(co, ci);
-       break;
-    case C_BREAK:
-       pljtype = PLJ_BREAK;
-       longjmp(*pljbufp1, 1);
-       /* NOT REACHED */
-       break;
-    case C_CONTINUE:
-       pljtype = PLJ_CONTINUE;
-       longjmp(*pljbufp1, 1);
-       /* NOT REACHED */
-       break;
-    case C_RETURN:
-       if ((i1 = TCgetfp(co, ci)) != C_NULL)
-           rtno = eeval(co, i1);
-       pljtype = PLJ_RETURN;
-       longjmp(*pljbufp2, 1);
-       /* NOT REACHED */
-       break;
-    default:
-       panic1(POS, "eeval", "unknown program token type %d", ctype);
-    }
-    return v1o;
-}
-
-static Tobj efcall(Tobj co, int ci)
-{
-    volatile jmp_buf *opljbufp1, *opljbufp2;
-    volatile long m;
-    volatile int bi, ownsinfoi, li, ln;
-
-    jmp_buf pljbuf;
-    Tobj fdo, vo, lrtno;
-    int i, fci, ai, di, di1, fid;
-
-    ownsinfoi = sinfoi++;
-    if (sinfoi == sinfon) {
-       sinfop =
-           Marraygrow(sinfop, (long) (sinfon + SINFOINCR) * SINFOSIZE);
-       sinfon += SINFOINCR;
-    }
-    sinfop[ownsinfoi].co = co;
-    sinfop[ownsinfoi].ci = ci;
-    sinfop[ownsinfoi].fco = NULL;
-    sinfop[ownsinfoi].flvari = flvari;
-    sinfop[ownsinfoi].llvari = llvari;
-    fci = TCgetfp(co, ci);
-    if (!(fdo = getval(co, fci)) || Tgettype(fdo) != T_CODE) {
-       err(ERRNOSUCHFUNC, ERR2, co, fci);
-       sinfoi = ownsinfoi;
-       return NULL;
-    }
-
-    m = Mpushmark((Tobj) fdo);
-    ai = TCgetfp(co, TCgetnext(co, fci));
-    ln = (int) TCgetinteger(fdo, (li = TCgetnext(fdo, TCgetfp(fdo, 0))));
-    di = TCgetnext(fdo, li);
-    bi = TCgetnext(fdo, di);
-    if (bi != C_NULL && TCgettype(fdo, bi) == C_INTERNAL) {
-       for (i = 0; ai != C_NULL; ai = TCgetnext(co, ai), i++) {
-           if (!(vo = eeval(co, ai))) {
-               err(ERRBADARG, ERR2, co, ai);
-               Mpopmark(m);
-               llvari = sinfop[ownsinfoi].llvari;
-               sinfoi = ownsinfoi;
-               return NULL;
-           }
-           if (llvari + 1 > lvarn) {
-               lvarp = Marraygrow(lvarp, (long) (llvari + 1) * LVARSIZE);
-               lvarn = llvari + 1;
-           }
-           lvarp[llvari].m = Mpushmark((lvarp[llvari].o = vo));
-           llvari++;
-       }
-       fid = (int) TCgetinteger(fdo, TCgetfp(fdo, bi));
-       if (Ifuncs[fid].min > i || Ifuncs[fid].max < i) {
-           err(ERRARGMIS, ERR2, co, ci);
-           Mpopmark(m);
-           llvari = sinfop[ownsinfoi].llvari;
-           sinfoi = ownsinfoi;
-           return NULL;
-       }
-       flvari = sinfop[ownsinfoi].llvari;
-       sinfop[ownsinfoi].fco = fdo;
-       sinfop[ownsinfoi].fci = bi;
-       if (fid < 0 || fid >= Ifuncn)
-           panic1(POS, "efcall", "no such internal function: %d", fid);
-       rtno = Ttrue;
-       if ((*Ifuncs[fid].func) (i, &lvarp[flvari]) == L_FAILURE) {
-           rtno = NULL;
-           err(ERRIFUNCERR, ERR2, co, ci);
-       }
-    } else {
-       if (llvari + ln > lvarn) {
-           lvarp = Marraygrow(lvarp, (long) (llvari + ln) * LVARSIZE);
-           lvarn = llvari + ln;
-       }
-       di1 = TCgetfp(fdo, di);
-       for (i = 0; i < ln && di1 != C_NULL && ai != C_NULL;
-            i++, ai = TCgetnext(co, ai)) {
-           if (!(vo = eeval(co, ai))) {
-               err(ERRBADARG, ERR2, co, ai);
-               Mpopmark(m);
-               llvari = sinfop[ownsinfoi].llvari;
-               sinfoi = ownsinfoi;
-               return NULL;
-           }
-           lvarp[llvari].m = Mpushmark((lvarp[llvari].o = vo));
-           llvari++;
-           di1 = TCgetnext(fdo, di1);
-       }
-       if (di1 != C_NULL || ai != C_NULL) {
-           err(ERRARGMIS, ERR2, co, ci);
-           Mpopmark(m);
-           llvari = sinfop[ownsinfoi].llvari;
-           sinfoi = ownsinfoi;
-           return NULL;
-       }
-       for (; i < ln; i++, llvari++)
-           lvarp[llvari].m = Mpushmark((lvarp[llvari].o = NULL));
-       flvari = sinfop[ownsinfoi].llvari;
-       PUSHJMP(opljbufp2, pljbufp2, pljbuf);
-       opljbufp1 = (volatile jmp_buf *) pljbufp1;
-       if (setjmp(*pljbufp2)) {
-           ;
-       } else {
-           sinfop[ownsinfoi].fco = fdo;
-           for (; bi != C_NULL; bi = TCgetnext(fdo, bi)) {
-               sinfop[ownsinfoi].fci = bi;
-               if (TCgettype(fdo, bi) != C_DECL)
-                   eeval((Tobj) fdo, bi);
-           }
-       }
-       POPJMP(opljbufp2, pljbufp2);
-       pljbufp1 = (jmp_buf *) opljbufp1;
-    }
-    flvari = sinfop[ownsinfoi].flvari;
-    llvari = sinfop[ownsinfoi].llvari;
-    sinfoi = ownsinfoi;
-    Mpopmark(m);
-    lrtno = rtno, rtno = NULL;
-    errdo = true;
-    return lrtno;
-}
-
-static void ewhilest(Tobj co, int ci)
-{
-    volatile jmp_buf *opljbufp;
-    volatile jmp_buf pljbuf;
-    volatile Tobj c1o;
-    volatile int ei, si;
-
-    Tobj v1o;
-
-    c1o = (volatile Tobj) co;  /* protect argument from longjmp */
-    ei = TCgetfp(c1o, ci);
-    si = TCgetnext(c1o, ei);
-    PUSHJMP(opljbufp, pljbufp1, pljbuf);
-    for (;;) {
-       if (!(v1o = eeval((Tobj) c1o, ei)))
-           err(ERRNORHS, ERR5, c1o, ei);
-       if (!boolop(v1o))
-           break;
-       if (setjmp(*pljbufp1)) {
-           if (pljtype == PLJ_CONTINUE)
-               continue;
-           else if (pljtype == PLJ_BREAK)
-               break;
-       }
-       eeval((Tobj) c1o, si);
-    }
-    POPJMP(opljbufp, pljbufp1);
-}
-
-static void eforst(Tobj co, int ci)
-{
-    volatile jmp_buf *opljbufp;
-    volatile jmp_buf pljbuf;
-    volatile Tobj c1o;
-    volatile int ei1, ei2, ei3, si, eisnop1, eisnop2, eisnop3;
-
-    Tobj v1o;
-
-    c1o = (volatile Tobj) co;  /* protect argument from longjmp */
-    ei1 = TCgetfp(c1o, ci);
-    ei2 = TCgetnext(c1o, ei1);
-    ei3 = TCgetnext(c1o, ei2);
-    si = TCgetnext(c1o, ei3);
-    eisnop1 = (TCgettype(c1o, ei1) == C_NOP);
-    eisnop2 = (TCgettype(c1o, ei2) == C_NOP);
-    eisnop3 = (TCgettype(c1o, ei3) == C_NOP);
-    PUSHJMP(opljbufp, pljbufp1, pljbuf);
-    if (!eisnop1)
-       eeval((Tobj) c1o, ei1);
-    for (;;) {
-       if (!eisnop2) {
-           if (!(v1o = eeval((Tobj) c1o, ei2)))
-               err(ERRNORHS, ERR5, c1o, ei2);
-           if (!boolop(v1o))
-               break;
-       }
-       if (setjmp(*pljbufp1) != 0) {
-           if (pljtype == PLJ_CONTINUE);
-           else if (pljtype == PLJ_BREAK)
-               break;
-       } else {
-           eeval((Tobj) c1o, si);
-       }
-       if (!eisnop3)
-           eeval((Tobj) c1o, ei3);
-    }
-    POPJMP(opljbufp, pljbufp1);
-}
-
-static void eforinst(Tobj co, int ci)
-{
-    volatile jmp_buf *opljbufp;
-    volatile jmp_buf pljbuf;
-    volatile Tobj tblo, c1o;
-    volatile Tkvindex_t tkvi;
-    volatile tnk_t tnk;
-    volatile long km, t;
-    volatile int ei1, ei2, si;
-
-    c1o = (volatile Tobj) co;  /* protect argument from longjmp */
-    ei1 = TCgetfp(c1o, ci);
-    ei2 = TCgetnext(c1o, ei1);
-    si = TCgetnext(c1o, ei2);
-    if (getvar((Tobj) c1o, ei1, (tnk_t *) & tnk) == -1) {
-       err(ERRNOLHS, ERR3, c1o, ei1);
-       return;
-    }
-    if (tnk.type == TNK_O)
-       km = Mpushmark(tnk.u.tnko.ko);
-    if (!(tblo = (volatile Tobj) eeval((Tobj) c1o, ei2))) {
-       if (tnk.type == TNK_O)
-           Mpopmark(km);
-       err(ERRNORHS, ERR4, c1o, ei2);
-       return;
-    }
-    if (Tgettype(tblo) != T_TABLE) {
-       err(ERRNOTATABLE, ERR1, c1o, ei2);
-       return;
-    }
-    PUSHJMP(opljbufp, pljbufp1, pljbuf);
-    t = Tgettime(tblo);
-    for (Tgetfirst((Tobj) tblo, (Tkvindex_t *) & tkvi); tkvi.kvp;
-        Tgetnext((Tkvindex_t *) & tkvi)) {
-       setvar(tnk, tkvi.kvp->ko);
-       if (setjmp(*pljbufp1) != 0) {
-           if (pljtype == PLJ_CONTINUE)
-               continue;
-           else if (pljtype == PLJ_BREAK)
-               break;
-       }
-       eeval((Tobj) c1o, si);
-       if (t != Tgettime(tblo)) {
-           err(ERRTABLECHANGED, ERR1, c1o, ei2);
-           break;
-       }
-    }
-    POPJMP(opljbufp, pljbufp1);
-    if (tnk.type == TNK_O)
-       Mpopmark(km);
-}
-
-static Tobj getval(Tobj co, int ci)
-{
-    Tobj cvo, cko, cto;
-    Ctype_t ct, vt;
-    int vi, ni, nn;
-
-    if ((ct = TCgettype(co, ci)) == C_LVAR) {
-       nn = (int) TCgetinteger(co, (ni = TCgetnext(co, TCgetfp(co, ci))));
-       cto = cvo = lvarp[flvari + nn].o;
-       if (!cto)
-           return NULL;
-       vi = TCgetnext(co, ni);
-    } else if (ct == C_GVAR) {
-       cto = root;
-       vi = TCgetfp(co, ci);
-    } else if (ct == C_PVAR)
-       return TCgetobject(co, ci);
-    else
-       return NULL;
-
-    while (vi != C_NULL) {
-       if (Tgettype(cto) != T_TABLE)
-           return NULL;
-       if ((vt = TCgettype(co, vi)) == C_STRING) {
-           if (!(cvo = Tfinds(cto, TCgetstring(co, vi))))
-               return NULL;
-       } else if (vt == C_INTEGER) {
-           if (!(cvo = Tfindi(cto, TCgetinteger(co, vi))))
-               return NULL;
-       } else if (vt == C_REAL) {
-           if (!(cvo = Tfindr(cto, TCgetreal(co, vi))))
-               return NULL;
-       } else {
-           if (!(cko = eeval(co, vi)) || !(cvo = Tfindo(cto, cko)))
-               return NULL;
-       }
-       cto = cvo;
-       vi = TCgetnext(co, vi);
-    }
-    return cvo;
-}
-
-static int getvar(Tobj co, int ci, tnk_t * tnkp)
-{
-    Tobj cvo, cko, cto;
-    Ctype_t ct, vt;
-    long m;
-    int vi, ovi, nn, ni;
-
-    if ((ct = TCgettype(co, ci)) == C_LVAR) {
-       nn = (int) TCgetinteger(co, (ni = TCgetnext(co, TCgetfp(co, ci))));
-       cvo = cto = lvarp[flvari + nn].o;
-       vi = TCgetnext(co, ni);
-       if (vi != C_NULL && (!cvo || Tgettype(cvo) != T_TABLE))
-           Mresetmark(lvarp[flvari + nn].m,
-                      (lvarp[flvari + nn].o = cvo = cto = Ttable(0)));
-    } else if (ct == C_GVAR) { /* else it's a global variable */
-       cvo = root;
-       vi = TCgetfp(co, ci);
-    } else {
-       return -1;
-    }
-
-    ovi = -1;
-    while (vi != C_NULL) {
-       cto = cvo;
-       if ((vt = TCgettype(co, vi)) == C_STRING) {
-           cvo = Tfinds(cto, TCgetstring(co, vi));
-       } else if (vt == C_INTEGER) {
-           cvo = Tfindi(cto, TCgetinteger(co, vi));
-       } else if (vt == C_REAL) {
-           cvo = Tfindr(cto, TCgetreal(co, vi));
-       } else {
-           if (!(cko = eeval(co, vi)) || !(T_ISSTRING(cko) ||
-                                           T_ISNUMBER(cko)))
-               return -1;
-           cvo = Tfindo(cto, cko);
-       }
-       ovi = vi, vi = TCgetnext(co, vi);
-       if (vi != C_NULL && (!cvo || Tgettype(cvo) != T_TABLE)) {
-           if (vt == C_STRING)
-               Tinss(cto, TCgetstring(co, ovi), (cvo = Ttable(0)));
-           else if (vt == C_INTEGER)
-               Tinsi(cto, TCgetinteger(co, ovi), (cvo = Ttable(0)));
-           else if (vt == C_REAL)
-               Tinsr(cto, TCgetreal(co, ovi), (cvo = Ttable(0)));
-           else
-               m = Mpushmark(cko), Tinso(cto, cko, (cvo = Ttable(0))),
-                   Mpopmark(m);
-       }
-    }
-    if (ct == C_LVAR && ovi == -1) {
-       tnkp->type = TNK_LI;
-       tnkp->u.li = nn;
-    } else {
-       switch (vt) {
-       case C_STRING:
-       case C_INTEGER:
-       case C_REAL:
-           tnkp->type = TNK_S;
-           tnkp->u.tnks.kt = vt;
-           tnkp->u.tnks.to = cto;
-           tnkp->u.tnks.co = co;
-           tnkp->u.tnks.vi = ovi;
-           break;
-       default:
-           tnkp->type = TNK_O;
-           tnkp->u.tnko.to = cto;
-           tnkp->u.tnko.ko = cko;
-           break;
-       }
-    }
-    return 0;
-}
-
-static void setvar(tnk_t tnk, Tobj vo)
-{
-    switch (tnk.type) {
-    case TNK_LI:
-       Mresetmark(lvarp[flvari + tnk.u.li].m,
-                  (lvarp[flvari + tnk.u.li].o = vo));
-       break;
-    case TNK_O:
-       Tinso(tnk.u.tnko.to, tnk.u.tnko.ko, vo);
-       break;
-    default:
-       switch (tnk.u.tnks.kt) {
-       case C_STRING:
-           Tinss(tnk.u.tnks.to,
-                 TCgetstring(tnk.u.tnks.co, tnk.u.tnks.vi), vo);
-           break;
-       case C_INTEGER:
-           Tinsi(tnk.u.tnks.to,
-                 TCgetinteger(tnk.u.tnks.co, tnk.u.tnks.vi), vo);
-           break;
-       case C_REAL:
-           Tinsr(tnk.u.tnks.to, TCgetreal(tnk.u.tnks.co, tnk.u.tnks.vi),
-                 vo);
-           break;
-       }
-       break;
-    }
-}
-
-static bool boolop(Tobj vo)
-{
-    long i;
-    double d;
-
-    if (!vo)
-       return false;
-
-    switch (Tgettype(vo)) {
-    case T_INTEGER:
-       i = Tgetinteger(vo);
-       return i != 0;
-    case T_REAL:
-       d = Tgetreal(vo);
-       return !(d == 0.0);
-    case T_TABLE:
-       if (vo == null)
-           return false;
-       return true;
-    default:
-       return true;
-    }
-}
-
-static int orderop(Tobj v1o, Ctype_t op, Tobj v2o)
-{
-    Ctype_t t1, t2;
-    long i1, i2;
-    int r;
-    double d1, d2;
-
-    if (!v1o || !v2o) {
-       return (v1o || v2o) && op == C_NE;
-    }
-    t1 = Tgettype(v1o), t2 = Tgettype(v2o);
-    if (t1 == T_STRING && t2 == T_STRING) {
-       r = strcmp(Tgetstring(v1o), Tgetstring(v2o));
-    } else if (t1 == T_INTEGER && t2 == T_INTEGER) {
-       i1 = Tgetinteger(v1o), i2 = Tgetinteger(v2o);
-       r = (i1 == i2) ? 0 : ((i1 < i2) ? -1 : 1);
-    } else if (t1 == T_INTEGER && t2 == T_REAL) {
-       i1 = Tgetinteger(v1o), d2 = Tgetreal(v2o);
-       r = (i1 == d2) ? 0 : ((i1 < d2) ? -1 : 1);
-    } else if (t1 == T_REAL && t2 == T_INTEGER) {
-       d1 = Tgetreal(v1o), i2 = Tgetinteger(v2o);
-       r = (d1 == i2) ? 0 : ((d1 < i2) ? -1 : 1);
-    } else if (t1 == T_REAL && t2 == T_REAL) {
-       d1 = Tgetreal(v1o), d2 = Tgetreal(v2o);
-       r = (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1);
-    } else if (t1 == t2) {
-       if (op != C_EQ && op != C_NE)
-           return FALSE;
-       r = (v1o == v2o) ? 0 : 1;
-    } else {
-       return FALSE;
-    }
-    switch (op) {
-    case C_EQ:
-       return r == 0;
-    case C_NE:
-       return r != 0;
-    case C_LT:
-       return r < 0;
-    case C_LE:
-       return r <= 0;
-    case C_GT:
-       return r > 0;
-    case C_GE:
-       return r >= 0;
-    }
-    panic1(POS, "orderop", "bad op code");
-    return FALSE;              /* NOT REACHED */
-}
-
-static Tobj arithop(num_tt * lnum, Ctype_t op, num_tt * rnum)
-{
-    double d1, d2, d3;
-
-    if (!rnum && op != C_UMINUS)
-       return NULL;
-    if (lnum->type == C_INTEGER)
-       d1 = lnum->u.i;
-    else if (lnum->type == C_REAL)
-       d1 = lnum->u.d;
-    else if (!lnum->u.no)
-       return NULL;
-    else if (Tgettype(lnum->u.no) == T_INTEGER)
-       d1 = Tgetinteger(lnum->u.no);
-    else if (Tgettype(lnum->u.no) == T_REAL)
-       d1 = Tgetreal(lnum->u.no);
-    else
-       return NULL;
-    if (op == C_UMINUS) {
-       d3 = -d1;
-       goto result;
-    }
-    if (rnum->type == C_INTEGER)
-       d2 = rnum->u.i;
-    else if (rnum->type == C_REAL)
-       d2 = rnum->u.d;
-    else if (!rnum->u.no)
-       return NULL;
-    else if (Tgettype(rnum->u.no) == T_INTEGER)
-       d2 = Tgetinteger(rnum->u.no);
-    else if (Tgettype(rnum->u.no) == T_REAL)
-       d2 = Tgetreal(rnum->u.no);
-    else
-       return NULL;
-    switch (op) {
-    case C_PLUS:
-       d3 = d1 + d2;
-       break;
-    case C_MINUS:
-       d3 = d1 - d2;
-       break;
-    case C_MUL:
-       d3 = d1 * d2;
-       break;
-    case C_DIV:
-       d3 = d1 / d2;
-       break;
-    case C_MOD:
-       d3 = (long) d1 % (long) d2;
-       break;
-    }
-  result:
-    if (d3 == (double) (long) d3)
-       return Tinteger((long) d3);
-    return Treal(d3);
-}
-
-static void err(int errnum, int level, Tobj co, int ci)
-{
-    char *s;
-    int si, i;
-
-    if (level > Eerrlevel || !errdo)
-       return;
-    fprintf(stderr, "runtime error: %s\n", errnam[errnum]);
-    if (!co)
-       return;
-    if (Estackdepth < 1)
-       return;
-    if (!sinfop[(si = sinfoi - 1)].fco && si > 0)
-       si--;
-    if (Eshowbody > 0) {
-       if (co == sinfop[si].fco) {
-           s = Scfull(co, 0, ci);
-           printbody(s, Eshowbody);
-           free(s);
-       } else if (co == sinfop[si].co) {
-           s = Scfull(co, TCgetfp(co, 0), ci);
-           printbody(s, Eshowbody);
-           free(s);
-       } else {
-           printbody("", Eshowbody);
-       }
-       if (Estackdepth == 1) {
-           fprintf(stderr, "\n");
-           errdo = false;
-       }
-       for (i = si; i >= 0; i--) {
-           if (sinfop[i].fco) {
-               s = Scfull(sinfop[i].fco, 0, sinfop[i].fci);
-               printbody(s, Eshowbody), free(s);
-           }
-       }
-       s = Scfull(sinfop[0].co, TCgetfp(sinfop[0].co, 0), sinfop[0].ci);
-       printbody(s, Eshowbody), free(s);
-    }
-    fprintf(stderr, "\n");
-    errdo = false;
-}
-
-static void printbody(char *s, int mode)
-{
-    char *s1, *s2;
-    char c;
-
-    if (mode == 2) {
-       fprintf(stderr, "%s\n", s);
-       return;
-    }
-    c = '\000';
-    for (s1 = s; *s1; s1++)
-       if (strncmp(s1, ">>", 2) == 0)
-           break;
-    if (!*s1)
-       return;
-    for (; s1 != s; s1--)
-       if (*(s1 - 1) == '\n')
-           break;
-    for (s2 = s1; *s2; s2++)
-       if (*s2 == '\n')
-           break;
-    if (*s2)
-       c = *s2, *s2 = '\000';
-    fprintf(stderr, "%s\n", s1);
-    if (c)
-       *s2 = c;
-}
diff --git a/cmd/lefty/aix_mods/tbl.c b/cmd/lefty/aix_mods/tbl.c
deleted file mode 100644 (file)
index a51f35c..0000000
+++ /dev/null
@@ -1,716 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
-
-#include <stdbool.h>
-#include "common.h"
-#include "mem.h"
-#include "code.h"
-#include "tbl.h"
-
-long Ttime = 0;
-int Tstringoffset, Tcodeoffset, Tkvoffset;
-Tobj Ttrue, Tfalse;
-
-#define ISEQIK(ik, ko) \
-    (T_ISNUMBER (ko) && Tgetnumber (ko) == (ik))
-#define ISEQRK(rk, ko) \
-    (T_ISNUMBER (ko) && Tgetnumber (ko) == (rk))
-#define ISEQSK(sk, ko) \
-    (T_ISSTRING (ko)  && strcmp (((Tstring_t *) (ko))->s, (sk)) == 0)
-
-#define GETIKINDEX(tp, ik) (unsigned long) ik  % tp->ln
-#define GETRKINDEX(tp, rk) (unsigned long) rk  % tp->ln
-#define GETSKINDEX(tp, sk) (unsigned long) *sk % tp->ln
-
-typedef struct mapentry_t {
-    struct mapentry_t *next;
-    Tobj fmo, too;
-} mapentry_t;
-#define MAPENTRYSIZE sizeof (mapentry_t)
-#define MAPLISTN 100
-typedef struct map_tt {
-    struct mapentry_t *list[MAPLISTN];
-} map_tt;
-static map_tt map;
-static long mapentrybyte2size;
-
-static long truem, falsem;
-
-static Tinteger_t keyi;
-static Treal_t keyr;
-static Tstring_t keys;
-
-static void insert(Ttable_t *, Tobj, char *, Tobj);
-static Tobj find(Ttable_t *, Tobj, char *);
-static void delete(Ttable_t *, Tobj, char *);
-static void copytable(Ttable_t *, long);
-static void reccopytable(Ttable_t *, Ttable_t *);
-static void mapinit(void);
-static void mapterm(void);
-static void mapinsert(Tobj, Tobj);
-static Tobj mapfind(Tobj);
-
-void Tinit(void)
-{
-    Tstring_t s;
-    Tcode_t c;
-    Tkvlist_t kvl;
-
-    Mhaspointers[T_INTEGER] = false;
-    Mhaspointers[T_REAL] = false;
-    Mhaspointers[T_STRING] = false;
-    Mhaspointers[T_CODE] = false;
-    Mhaspointers[T_TABLE] = true;
-    Ttrue = Tinteger(1);
-    truem = Mpushmark(Ttrue);
-    Tfalse = Tinteger(0);
-    falsem = Mpushmark(Tfalse);
-    Tstringoffset = (char *) &s.s[0] - (char *) &s + 1;
-    /* the + 1 above accounts for the null character */
-    Tcodeoffset = (char *) &c.c[0] - (char *) &c;
-    Tkvoffset = (char *) &kvl.kv[0] - (char *) &kvl;
-    keyi.head.type = T_INTEGER;
-    keyr.head.type = T_REAL;
-    keys.head.type = T_STRING;
-    mapentrybyte2size = M_BYTE2SIZE(MAPENTRYSIZE);
-}
-
-void Tterm(void)
-{
-    Mpopmark(falsem);
-    Tfalse = NULL;
-    Mpopmark(truem);
-    Ttrue = NULL;
-    Mdogc(M_GCFULL);
-    Mdogc(M_GCFULL);
-}
-
-void Tgchelper(void *p)
-{
-    Ttable_t *tp;
-    Tkvlist_t *kvlp;
-    long i, j;
-
-    /* must be a table */
-    tp = (Ttable_t *) p;
-    for (i = 0; i < tp->ln; i++)
-       if ((kvlp = tp->lp[i]))
-           for (j = 0; j < kvlp->i; j++)
-               Mmkcurr(kvlp->kv[j].ko), Mmkcurr(kvlp->kv[j].vo);
-}
-
-void Tfreehelper(void *p)
-{
-    Ttable_t *tp;
-    Tkvlist_t *kvlp;
-    long i;
-
-    /* must be a table */
-    tp = (Ttable_t *) p;
-    for (i = 0; i < tp->ln; i++)
-       if ((kvlp = tp->lp[i]))
-           Mfree(kvlp, M_BYTE2SIZE(T_KVLISTSIZE(kvlp->n)));
-    Mfree(tp->lp, M_BYTE2SIZE(tp->ln * T_KVLISTPTRSIZE));
-}
-
-Tobj Tinteger(long i)
-{
-    Tinteger_t *ip;
-
-    ip = Mnew(T_INTEGERSIZE, T_INTEGER);
-    ip->i = i;
-    return ip;
-}
-
-Tobj Treal(double d)
-{
-    Treal_t *rp;
-
-    if (d == (double) (long) d)
-       return Tinteger((long) d);
-    rp = Mnew(T_REALSIZE, T_REAL);
-    rp->d = d;
-    return rp;
-}
-
-Tobj Tstring(char *s)
-{
-    Tstring_t *sp;
-
-    sp = Mnew((long) T_STRINGSIZE(strlen(s)), T_STRING);
-    strcpy(&sp->s[0], s);
-    return sp;
-}
-
-Tobj Tcode(Code_t * cp, int ci, int cl)
-{
-    Tcode_t *codep;
-    Code_t *cp2;
-    char *s;
-    int i, j, cn;
-
-    codep = Mnew((long) T_CODESIZE(cl), T_CODE);
-    cp2 = codep->c;
-    for (i = 0; i < cl; i++) {
-       switch (cp[i].ctype) {
-       case C_INTEGER:
-           cp2[i] = cp[i];
-           if (cp2[i].next != C_NULL)
-               cp2[i].next -= ci;
-           break;
-       case C_REAL:
-           cp2[i] = cp[i];
-           if (cp2[i].next != C_NULL)
-               cp2[i].next -= ci;
-           break;
-       case C_STRING:
-           cp2[i] = cp[i];
-           if (cp2[i].next != C_NULL)
-               cp2[i].next -= ci;
-           s = &cp[i].u.s;
-           while (*s)
-               s++;
-           cn = (long) (s - (char *) &cp[i]) / sizeof(Code_t);
-           for (j = 0; j < cn; j++)
-               i++, cp2[i] = cp[i];
-           break;
-       default:
-           cp2[i] = cp[i];
-           if (cp2[i].next != C_NULL)
-               cp2[i].next -= ci;
-           if (cp2[i].u.fp != C_NULL)
-               cp2[i].u.fp -= ci;
-           break;
-       }
-    }
-    return codep;
-}
-
-Tobj Ttable(long sizehint)
-{
-    Ttable_t *tp;
-    Tkvlist_t **lp;
-    long i;
-
-    sizehint = (sizehint < 2) ? 2 : sizehint;
-    tp = Mnew(T_TABLESIZE, T_TABLE);
-    lp = Mallocate((long) (sizehint * T_KVLISTPTRSIZE));
-    tp->lp = lp;
-    tp->ln = sizehint;
-    tp->n = 0;
-    tp->time = Ttime;
-    for (i = 0; i < sizehint; i++)
-       lp[i] = NULL;
-    return tp;
-}
-
-
-void Tinsi(Tobj to, long ik, Tobj vo)
-{
-    long tm;
-
-    if (!to || !T_ISTABLE(to))
-       panic1(POS, "Tinsi", "insert attempted on non-table");
-    tm = Mpushmark(to);
-    if (vo)
-       Mpushmark(vo);
-    keyi.i = ik;
-    insert(to, &keyi, NULL, vo);
-    Mpopmark(tm);
-}
-
-void Tinsr(Tobj to, double rk, Tobj vo)
-{
-    long tm;
-
-    if (!to || !T_ISTABLE(to))
-       panic1(POS, "Tinsr", "insert attempted on non-table");
-    tm = Mpushmark(to);
-    if (vo)
-       Mpushmark(vo);
-    keyr.d = rk;
-    insert(to, &keyr, NULL, vo);
-    Mpopmark(tm);
-}
-
-void Tinss(Tobj to, char *sk, Tobj vo)
-{
-    long tm;
-
-    if (!to || !T_ISTABLE(to))
-       panic1(POS, "Tinss", "insert attempted on non-table");
-    tm = Mpushmark(to);
-    if (vo)
-       Mpushmark(vo);
-    insert(to, &keys, sk, vo);
-    Mpopmark(tm);
-}
-
-void Tinso(Tobj to, Tobj ko, Tobj vo)
-{
-    long tm;
-
-    if (!to || !T_ISTABLE(to))
-       panic1(POS, "Tinso", "insert attempted on non-table");
-    if (!ko || !(T_ISINTEGER(ko) || T_ISREAL(ko) || T_ISSTRING(ko)))
-       panic1(POS, "Tinso", "bad key");
-    tm = Mpushmark(to);
-    Mpushmark(ko);
-    if (vo)
-       Mpushmark(vo);
-    insert(to, ko, NULL, vo);
-    Mpopmark(tm);
-}
-
-Tobj Tfindi(Tobj to, long ik)
-{
-    if (!to)
-       return NULL;
-    if (!T_ISTABLE(to))
-       panic1(POS, "Tfindi", "find attempted on non-table");
-    keyi.i = ik;
-    return find(to, &keyi, NULL);
-}
-
-Tobj Tfindr(Tobj to, double rk)
-{
-    if (!to)
-       return NULL;
-    if (!T_ISTABLE(to))
-       panic1(POS, "Tfindr", "find attempted on non-table");
-    keyr.d = rk;
-    return find(to, &keyr, NULL);
-}
-
-Tobj Tfinds(Tobj to, char *sk)
-{
-    if (!to)
-       return NULL;
-    if (!T_ISTABLE(to))
-       panic1(POS, "Tfinds", "find attempted on non-table");
-    return find(to, &keys, sk);
-}
-
-Tobj Tfindo(Tobj to, Tobj ko)
-{
-    if (!to || !ko)
-       return NULL;
-    if (!T_ISTABLE(to))
-       panic1(POS, "Tfindo", "find attempted on non-table");
-    if (!(T_ISINTEGER(ko) || T_ISREAL(ko) || T_ISSTRING(ko)))
-       panic1(POS, "Tfindo", "bad key");
-    return find(to, ko, NULL);
-}
-
-void Tdeli(Tobj to, long ik)
-{
-    if (!to)
-       return;
-    if (!T_ISTABLE(to))
-       panic1(POS, "Tdeli", "delete attempted on non-table");
-    keyi.i = ik;
-    delete(to, &keyi, NULL);
-}
-
-void Tdelr(Tobj to, double rk)
-{
-    if (!to)
-       return;
-    if (!T_ISTABLE(to))
-       panic1(POS, "Tdelr", "delete attempted on non-table");
-    keyr.d = rk;
-    delete(to, &keyr, NULL);
-}
-
-void Tdels(Tobj to, char *sk)
-{
-    if (!to)
-       return;
-    if (!T_ISTABLE(to))
-       panic1(POS, "Tdels", "delete attempted on non-table");
-    delete(to, &keys, sk);
-}
-
-void Tdelo(Tobj to, Tobj ko)
-{
-    if (!to || !ko)
-       return;
-    if (!T_ISTABLE(to))
-       panic1(POS, "Tdelo", "delete attempted on non-table");
-    if (!(T_ISINTEGER(ko) || T_ISREAL(ko) || T_ISSTRING(ko)))
-       panic1(POS, "Tdelo", "bad key");
-    delete(to, ko, NULL);
-}
-
-Tobj Tcopy(Tobj fmvo)
-{
-    Tobj tovo;
-    long m;
-
-    switch (M_TYPEOF(fmvo)) {
-    case T_INTEGER:
-    case T_REAL:
-    case T_STRING:
-    case T_CODE:
-       tovo = fmvo;
-       break;
-    case T_TABLE:
-       mapinit();
-       m = Mpushmark(fmvo);
-       tovo = Mnew(T_TABLESIZE, T_TABLE);
-       mapinsert(fmvo, tovo);
-       reccopytable(fmvo, tovo);
-       Mpopmark(m);
-       mapterm();
-       break;
-    }
-    return tovo;
-}
-
-void Tgetfirst(Tobj to, Tkvindex_t * p)
-{
-    if (!to || !T_ISTABLE(to))
-       return;
-    p->tp = to, p->kvp = NULL, p->i = 0, p->j = 0;
-    for (; p->i < p->tp->ln; p->i++) {
-       if (!p->tp->lp[p->i])
-           continue;
-       for (; p->j < p->tp->lp[p->i]->i; p->j++) {
-           if ((p->kvp = &p->tp->lp[p->i]->kv[p->j]))
-               return;
-       }
-       p->j = 0;
-    }
-}
-
-void Tgetnext(Tkvindex_t * p)
-{
-    p->kvp = NULL;
-    p->j++;
-    for (; p->i < p->tp->ln; p->i++) {
-       if (!p->tp->lp[p->i])
-           continue;
-       for (; p->j < p->tp->lp[p->i]->i; p->j++) {
-           if ((p->kvp = &p->tp->lp[p->i]->kv[p->j]))
-               return;
-       }
-       p->j = 0;
-    }
-}
-
-static void insert(Ttable_t * tp, Tobj ko, char *sk, Tobj vo)
-{
-    Tkvlist_t *kvlp, *nkvlp;
-    Tkv_t *kvp;
-    Ttype_t kt;
-    long ik, i, ind, nln;
-    double rk;
-
-    switch ((kt = M_TYPEOF(ko))) {
-    case T_INTEGER:
-       ik = ((Tinteger_t *) ko)->i;
-       if ((kvlp = tp->lp[(ind = GETIKINDEX(tp, ik))]))
-           for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-               if (ISEQIK(ik, kvp[i].ko))
-                   goto found;
-       break;
-    case T_REAL:
-       rk = ((Treal_t *) ko)->d;
-       if ((kvlp = tp->lp[(ind = GETRKINDEX(tp, rk))]))
-           for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-               if (ISEQRK(rk, kvp[i].ko))
-                   goto found;
-       break;
-    case T_STRING:
-       if (M_AREAOF(ko) != 0)
-           sk = ((Tstring_t *) ko)->s;
-       if ((kvlp = tp->lp[(ind = GETSKINDEX(tp, sk))]))
-           for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-               if (ISEQSK(sk, kvp[i].ko))
-                   goto found;
-       break;
-    }
-    if ((nln = tp->n + 1) > 4 * tp->ln && nln < SHRT_MAX) {
-       copytable(tp, nln);
-       switch (kt) {
-       case T_INTEGER:
-           ind = GETIKINDEX(tp, ik);
-           break;
-       case T_REAL:
-           ind = GETRKINDEX(tp, rk);
-           break;
-       case T_STRING:
-           ind = GETSKINDEX(tp, sk);
-           break;
-       }
-       kvlp = tp->lp[ind];
-    }
-    if (!kvlp) {
-       tp->lp[ind] = kvlp = Mallocate((long) T_KVLISTSIZE(1));
-       kvlp->i = 0, kvlp->n = 1;
-    } else if (kvlp->i == kvlp->n) {
-       tp->lp[ind] = nkvlp = Mallocate((long) T_KVLISTSIZE(kvlp->n * 2));
-       nkvlp->n = kvlp->n * 2;
-       for (i = 0; i < kvlp->n; i++)
-           nkvlp->kv[i] = kvlp->kv[i];
-       nkvlp->i = kvlp->i;
-       Mfree(kvlp, M_BYTE2SIZE(T_KVLISTSIZE(kvlp->n))), kvlp = nkvlp;
-    }
-    if (M_AREAOF(ko) == 0) {   /* ko must be allocated */
-       switch (kt) {
-       case T_INTEGER:
-           ko = Tinteger(ik);
-           break;
-       case T_REAL:
-           ko = Treal(rk);
-           break;
-       case T_STRING:
-           ko = Tstring(sk);
-           break;
-       }
-    }
-
-    kvlp->kv[kvlp->i].ko = ko, kvlp->kv[kvlp->i++].vo = vo;
-    tp->n++;
-    tp->time = Ttime;
-    return;
-
-  found:
-    kvp[i].vo = vo;
-    tp->time = Ttime;
-}
-
-static Tobj find(Ttable_t * tp, Tobj ko, char *sk)
-{
-    Tkvlist_t *kvlp;
-    Tkv_t *kvp;
-    long ik, i;
-    double rk;
-
-    switch (M_TYPEOF(ko)) {
-    case T_INTEGER:
-       ik = ((Tinteger_t *) ko)->i;
-       if ((kvlp = tp->lp[GETIKINDEX(tp, ik)]))
-           for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-               if (ISEQIK(ik, kvp[i].ko))
-                   goto found;
-       break;
-    case T_REAL:
-       rk = ((Treal_t *) ko)->d;
-       if ((kvlp = tp->lp[GETRKINDEX(tp, rk)]))
-           for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-               if (ISEQRK(rk, kvp[i].ko))
-                   goto found;
-       break;
-    case T_STRING:
-       if (M_AREAOF(ko) != 0)
-           sk = ((Tstring_t *) ko)->s;
-       if ((kvlp = tp->lp[GETSKINDEX(tp, sk)]))
-           for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-               if (ISEQSK(sk, kvp[i].ko))
-                   goto found;
-       break;
-    }
-    return NULL;
-
-  found:
-    return kvp[i].vo;
-}
-
-static void delete(Ttable_t * tp, Tobj ko, char *sk)
-{
-    Tkvlist_t *kvlp;
-    Tkv_t *kvp;
-    long ik, i, j;
-    double rk;
-
-    switch (M_TYPEOF(ko)) {
-    case T_INTEGER:
-       ik = ((Tinteger_t *) ko)->i;
-       if ((kvlp = tp->lp[GETIKINDEX(tp, ik)]))
-           for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-               if (ISEQIK(ik, kvp[i].ko))
-                   goto found;
-       break;
-    case T_REAL:
-       rk = ((Treal_t *) ko)->d;
-       if ((kvlp = tp->lp[GETRKINDEX(tp, rk)]))
-           for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-               if (ISEQRK(rk, kvp[i].ko))
-                   goto found;
-       break;
-    case T_STRING:
-       if (M_AREAOF(ko) != 0)
-           sk = ((Tstring_t *) ko)->s;
-       if ((kvlp = tp->lp[GETSKINDEX(tp, sk)]))
-           for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-               if (ISEQSK(sk, kvp[i].ko))
-                   goto found;
-       break;
-    }
-    return;
-
-  found:
-    for (j = i, kvp = &kvlp->kv[0]; j < kvlp->i - 1; j++)
-       kvp[j] = kvp[j + 1];
-    kvlp->i--;
-    tp->n--;
-    tp->time = Ttime;
-}
-
-static void copytable(Ttable_t * tp, long ln)
-{
-    Tkvlist_t **olp, **lp;
-    Tkvlist_t *okvlp, *kvlp, *nkvlp;
-    Tkv_t *kvp;
-    long ik, oln, i, j, k, ind;
-    double rk;
-    char *sk;
-
-    lp = Mallocate((long) (ln * T_KVLISTPTRSIZE));
-    oln = tp->ln, tp->ln = ln;
-    olp = tp->lp, tp->lp = lp;
-    for (i = 0; i < ln; i++)
-       lp[i] = NULL;
-    for (i = 0; i < oln; i++) {
-       if (!(okvlp = olp[i]))
-           continue;
-       for (j = 0; j < okvlp->i; j++) {
-           kvp = &okvlp->kv[j];
-           switch (M_TYPEOF(kvp->ko)) {
-           case T_INTEGER:
-               ik = ((Tinteger_t *) kvp->ko)->i;
-               kvlp = lp[(ind = GETIKINDEX(tp, ik))];
-               break;
-           case T_REAL:
-               rk = ((Treal_t *) kvp->ko)->d;
-               kvlp = lp[(ind = GETRKINDEX(tp, rk))];
-               break;
-           case T_STRING:
-               sk = ((Tstring_t *) kvp->ko)->s;
-               kvlp = lp[(ind = GETSKINDEX(tp, sk))];
-               break;
-           }
-           if (!kvlp) {
-               lp[ind] = kvlp = Mallocate((long) T_KVLISTSIZE(1));
-               kvlp->i = 0, kvlp->n = 1;
-           } else if (kvlp->i == kvlp->n) {
-               lp[ind] = nkvlp =
-                   Mallocate((long) T_KVLISTSIZE(kvlp->n * 2));
-               nkvlp->n = kvlp->n * 2;
-               for (k = 0; k < kvlp->i; k++)
-                   nkvlp->kv[k] = kvlp->kv[k];
-               nkvlp->i = kvlp->i;
-               Mfree(kvlp, M_BYTE2SIZE(T_KVLISTSIZE(kvlp->n)));
-               kvlp = nkvlp;
-           }
-           kvlp->kv[kvlp->i].ko = kvp->ko, kvlp->kv[kvlp->i++].vo =
-               kvp->vo;
-       }
-       Mfree(okvlp, M_BYTE2SIZE(T_KVLISTSIZE(okvlp->n)));
-    }
-    Mfree(olp, M_BYTE2SIZE(oln * T_KVLISTPTRSIZE));
-}
-
-static void reccopytable(Ttable_t * fmtp, Ttable_t * totp)
-{
-    Tkv_t *fmkvp, *tokvp;
-    long i, j, m;
-
-    totp->lp = Mallocate((long) (fmtp->ln * T_KVLISTPTRSIZE));
-    totp->ln = fmtp->ln;
-    totp->n = fmtp->n;
-    totp->time = Ttime;
-    for (i = 0; i < totp->ln; i++) {
-       if (!fmtp->lp[i]) {
-           totp->lp[i] = NULL;
-           continue;
-       }
-       totp->lp[i] = Mallocate((long) T_KVLISTSIZE(fmtp->lp[i]->n));
-       totp->lp[i]->n = fmtp->lp[i]->n;
-       totp->lp[i]->i = 0;
-    }
-    m = Mpushmark(totp);
-    for (i = 0; i < totp->ln; i++) {
-       if (!totp->lp[i])
-           continue;
-       for (j = 0; j < fmtp->lp[i]->i; j++) {
-           fmkvp = &fmtp->lp[i]->kv[j], tokvp = &totp->lp[i]->kv[j];
-           tokvp->ko = fmkvp->ko;
-           switch (M_TYPEOF(fmkvp->vo)) {
-           case T_INTEGER:
-           case T_REAL:
-           case T_STRING:
-           case T_CODE:
-               tokvp->vo = fmkvp->vo;
-               break;
-           case T_TABLE:
-               if (!(tokvp->vo = mapfind(fmkvp->vo))) {
-                   tokvp->vo = Mnew(T_TABLESIZE, T_TABLE);
-                   mapinsert(fmkvp->vo, tokvp->vo);
-                   reccopytable(fmkvp->vo, tokvp->vo);
-               }
-               break;
-           }
-           totp->lp[i]->i++;
-       }
-    }
-    Mpopmark(m);
-}
-
-static void mapinit(void)
-{
-    long li;
-
-    for (li = 0; li < MAPLISTN; li++)
-       map.list[li] = NULL;
-}
-
-static void mapterm(void)
-{
-    mapentry_t **lp;
-    mapentry_t *cep, *nep;
-    long li;
-
-    for (li = 0; li < MAPLISTN; li++) {
-       lp = &map.list[li];
-       for (cep = *lp; cep; cep = nep) {
-           nep = cep->next;
-           Mfree(cep, mapentrybyte2size);
-       }
-       *lp = NULL;
-    }
-}
-
-static void mapinsert(Tobj fmo, Tobj too)
-{
-    mapentry_t **lp;
-    mapentry_t *cep;
-
-    lp = &map.list[(unsigned long) fmo % MAPLISTN];
-    if (!(cep = Mallocate(MAPENTRYSIZE)))
-       panic1(POS, "mapinsert", "cannot allocate mapentry");
-    cep->fmo = fmo, cep->too = too;
-    cep->next = *lp, *lp = cep;
-}
-
-static Tobj mapfind(Tobj fmo)
-{
-    mapentry_t **lp;
-    mapentry_t *cep;
-
-    lp = &map.list[(unsigned long) fmo % MAPLISTN];
-    for (cep = *lp; cep; cep = cep->next)
-       if (cep->fmo == fmo)
-           return cep->too;
-    return NULL;
-}
diff --git a/cmd/lefty/code.c b/cmd/lefty/code.c
deleted file mode 100644 (file)
index 234b2f1..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "code.h"
-#include "mem.h"
-
-Code_t *cbufp;
-int cbufn, cbufi;
-#define CBUFINCR 1000l
-#define CBUFSIZE sizeof (Code_t)
-
-static int Cstringoffset;
-
-void Cinit (void) {
-    Code_t c;
-
-    cbufp = Marrayalloc(CBUFINCR * CBUFSIZE);
-    cbufn = CBUFINCR;
-    cbufi = 0;
-    Cstringoffset = &c.u.s[0] - (char *)&c + 1;
-    /* the + 1 above accounts for the null character */
-}
-
-void Cterm (void) {
-    Marrayfree (cbufp);
-    cbufp = NULL;
-    cbufn = cbufi = 0;
-}
-
-void Creset (void) {
-    cbufi = 0;
-}
-
-int Cnew (int ctype) {
-    int i;
-
-    if (cbufi >= cbufn) {
-        cbufp = Marraygrow(cbufp, (cbufn + CBUFINCR) * CBUFSIZE);
-        cbufn += CBUFINCR;
-    }
-    i = cbufi++;
-    cbufp[i].ctype = ctype;
-    cbufp[i].next = C_NULL;
-    return i;
-}
-
-int Cinteger (long i) {
-    int j;
-
-    if (cbufi >= cbufn) {
-        cbufp = Marraygrow(cbufp, (cbufn + CBUFINCR) * CBUFSIZE);
-        cbufn += CBUFINCR;
-    }
-    j = cbufi++;
-    cbufp[j].ctype = C_INTEGER;
-    cbufp[j].u.i = i;
-    cbufp[j].next = C_NULL;
-    return j;
-}
-
-int Creal (double d) {
-    int i;
-
-    if (cbufi >= cbufn) {
-        cbufp = Marraygrow(cbufp, (cbufn + CBUFINCR) * CBUFSIZE);
-        cbufn += CBUFINCR;
-    }
-    i = cbufi++;
-    cbufp[i].ctype = C_REAL;
-    cbufp[i].u.d = d;
-    cbufp[i].next = C_NULL;
-    return i;
-}
-
-int Cstring (char *s) {
-    int i, size, incr;
-
-    size = (strlen (s) + Cstringoffset + CBUFSIZE - 1) / CBUFSIZE;
-    if (cbufi + size > cbufn) {
-        incr = size > CBUFINCR ? size : CBUFINCR;
-        cbufp = Marraygrow(cbufp, (cbufn + incr) * CBUFSIZE);
-        cbufn += incr;
-    }
-    i = cbufi, cbufi += size;
-    cbufp[i].ctype = C_STRING;
-    strcpy(&cbufp[i].u.s[0], s);
-    cbufp[i].next = C_NULL;
-    return i;
-}
diff --git a/cmd/lefty/code.h b/cmd/lefty/code.h
deleted file mode 100644 (file)
index 0ea6fe6..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#define C_NULL -1
-
-#define C_ISSTMT(ct) (ct >= C_STMT && ct <= C_RETURN)
-
-#define C_CODE      0
-#define C_ASSIGN    1
-#define C_INTEGER   2
-#define C_REAL      3
-#define C_STRING    4
-#define C_OR        5
-#define C_AND       6
-#define C_EQ        7
-#define C_NE        8
-#define C_LT        9
-#define C_LE       10
-#define C_GT       11
-#define C_GE       12
-#define C_PLUS     13
-#define C_MINUS    14
-#define C_MUL      15
-#define C_DIV      16
-#define C_MOD      17
-#define C_UMINUS   18
-#define C_NOT      19
-#define C_PEXPR    20
-#define C_FCALL    21
-#define C_GVAR     22
-#define C_LVAR     23
-#define C_PVAR     24
-#define C_FUNCTION 25
-#define C_TCONS    26
-#define C_DECL     27
-#define C_STMT     28
-#define C_IF       29
-#define C_WHILE    30
-#define C_FOR      31
-#define C_FORIN    32
-#define C_BREAK    33
-#define C_CONTINUE 34
-#define C_RETURN   35
-#define C_INTERNAL 36
-#define C_ARGS     37
-#define C_NOP      38
-#define C_SIZE     39
-
-typedef struct Code_t {
-    int ctype;
-    int next;
-    union {
-        char s[1];
-        double d;
-        long i;
-        int fp;
-        void *o;
-    } u;
-} Code_t;
-#define C_CODESIZE sizeof (Code_t)
-
-#define Cgetstring(i) &cbufp[i].u.s[0]
-#define Cgetindex() cbufi
-
-#define Csettype(a, b) cbufp[a].ctype = b
-#define Csetfp(a, b) cbufp[a].u.fp = b
-#define Csetnext(a, b) cbufp[a].next = b
-#define Csetinteger(a, b) cbufp[a].u.i = b
-#define Csetobject(a, b) cbufp[a].u.o = b
-#define Csetreal(a, b) cbufp[a].u.d = b
-
-extern Code_t *cbufp;
-extern int cbufn, cbufi;
-
-void Cinit (void);
-void Cterm (void);
-void Creset (void);
-int Cnew (int);
-int Cinteger (long);
-int Creal (double);
-int Cstring (char *);
diff --git a/cmd/lefty/colors.txt b/cmd/lefty/colors.txt
deleted file mode 100644 (file)
index 61f98ee..0000000
+++ /dev/null
@@ -1,655 +0,0 @@
-colorname_t colornames[] = {
-{"aliceblue",240,248,255},
-{"antiquewhite",250,235,215},
-{"antiquewhite1",255,239,219},
-{"antiquewhite2",238,223,204},
-{"antiquewhite3",205,192,176},
-{"antiquewhite4",139,131,120},
-{"aquamarine",127,255,212},
-{"aquamarine1",127,255,212},
-{"aquamarine2",118,238,198},
-{"aquamarine3",102,205,170},
-{"aquamarine4",69,139,116},
-{"azure",240,255,255},
-{"azure1",240,255,255},
-{"azure2",224,238,238},
-{"azure3",193,205,205},
-{"azure4",131,139,139},
-{"beige",245,245,220},
-{"bisque",255,228,196},
-{"bisque1",255,228,196},
-{"bisque2",238,213,183},
-{"bisque3",205,183,158},
-{"bisque4",139,125,107},
-{"black",0,0,0},
-{"blanchedalmond",255,235,205},
-{"blue",0,0,255},
-{"blue1",0,0,255},
-{"blue2",0,0,238},
-{"blue3",0,0,205},
-{"blue4",0,0,139},
-{"blueviolet",138,43,226},
-{"brown",165,42,42},
-{"brown1",255,64,64},
-{"brown2",238,59,59},
-{"brown3",205,51,51},
-{"brown4",139,35,35},
-{"burlywood",222,184,135},
-{"burlywood1",255,211,155},
-{"burlywood2",238,197,145},
-{"burlywood3",205,170,125},
-{"burlywood4",139,115,85},
-{"cadetblue",95,158,160},
-{"cadetblue1",152,245,255},
-{"cadetblue2",142,229,238},
-{"cadetblue3",122,197,205},
-{"cadetblue4",83,134,139},
-{"chartreuse",127,255,0},
-{"chartreuse1",127,255,0},
-{"chartreuse2",118,238,0},
-{"chartreuse3",102,205,0},
-{"chartreuse4",69,139,0},
-{"chocolate",210,105,30},
-{"chocolate1",255,127,36},
-{"chocolate2",238,118,33},
-{"chocolate3",205,102,29},
-{"chocolate4",139,69,19},
-{"coral",255,127,80},
-{"coral1",255,114,86},
-{"coral2",238,106,80},
-{"coral3",205,91,69},
-{"coral4",139,62,47},
-{"cornflowerblue",100,149,237},
-{"cornsilk",255,248,220},
-{"cornsilk1",255,248,220},
-{"cornsilk2",238,232,205},
-{"cornsilk3",205,200,177},
-{"cornsilk4",139,136,120},
-{"crimson",220,20,60},
-{"cyan",0,255,255},
-{"cyan1",0,255,255},
-{"cyan2",0,238,238},
-{"cyan3",0,205,205},
-{"cyan4",0,139,139},
-{"darkgoldenrod",184,134,11},
-{"darkgoldenrod1",255,185,15},
-{"darkgoldenrod2",238,173,14},
-{"darkgoldenrod3",205,149,12},
-{"darkgoldenrod4",139,101,8},
-{"darkgreen",0,100,0},
-{"darkkhaki",189,183,107},
-{"darkolivegreen",85,107,47},
-{"darkolivegreen1",202,255,112},
-{"darkolivegreen2",188,238,104},
-{"darkolivegreen3",162,205,90},
-{"darkolivegreen4",110,139,61},
-{"darkorange",255,140,0},
-{"darkorange1",255,127,0},
-{"darkorange2",238,118,0},
-{"darkorange3",205,102,0},
-{"darkorange4",139,69,0},
-{"darkorchid",153,50,204},
-{"darkorchid1",191,62,255},
-{"darkorchid2",178,58,238},
-{"darkorchid3",154,50,205},
-{"darkorchid4",104,34,139},
-{"darksalmon",233,150,122},
-{"darkseagreen",143,188,143},
-{"darkseagreen1",193,255,193},
-{"darkseagreen2",180,238,180},
-{"darkseagreen3",155,205,155},
-{"darkseagreen4",105,139,105},
-{"darkslateblue",72,61,139},
-{"darkslategray",47,79,79},
-{"darkslategray1",151,255,255},
-{"darkslategray2",141,238,238},
-{"darkslategray3",121,205,205},
-{"darkslategray4",82,139,139},
-{"darkslategrey",47,79,79},
-{"darkturquoise",0,206,209},
-{"darkviolet",148,0,211},
-{"deeppink",255,20,147},
-{"deeppink1",255,20,147},
-{"deeppink2",238,18,137},
-{"deeppink3",205,16,118},
-{"deeppink4",139,10,80},
-{"deepskyblue",0,191,255},
-{"deepskyblue1",0,191,255},
-{"deepskyblue2",0,178,238},
-{"deepskyblue3",0,154,205},
-{"deepskyblue4",0,104,139},
-{"dimgray",105,105,105},
-{"dimgrey",105,105,105},
-{"dodgerblue",30,144,255},
-{"dodgerblue1",30,144,255},
-{"dodgerblue2",28,134,238},
-{"dodgerblue3",24,116,205},
-{"dodgerblue4",16,78,139},
-{"firebrick",178,34,34},
-{"firebrick1",255,48,48},
-{"firebrick2",238,44,44},
-{"firebrick3",205,38,38},
-{"firebrick4",139,26,26},
-{"floralwhite",255,250,240},
-{"forestgreen",34,139,34},
-{"gainsboro",220,220,220},
-{"ghostwhite",248,248,255},
-{"gold",255,215,0},
-{"gold1",255,215,0},
-{"gold2",238,201,0},
-{"gold3",205,173,0},
-{"gold4",139,117,0},
-{"goldenrod",218,165,32},
-{"goldenrod1",255,193,37},
-{"goldenrod2",238,180,34},
-{"goldenrod3",205,155,29},
-{"goldenrod4",139,105,20},
-{"gray",192,192,192},
-{"gray0",0,0,0},
-{"gray1",3,3,3},
-{"gray10",26,26,26},
-{"gray100",255,255,255},
-{"gray11",28,28,28},
-{"gray12",31,31,31},
-{"gray13",33,33,33},
-{"gray14",36,36,36},
-{"gray15",38,38,38},
-{"gray16",41,41,41},
-{"gray17",43,43,43},
-{"gray18",46,46,46},
-{"gray19",48,48,48},
-{"gray2",5,5,5},
-{"gray20",51,51,51},
-{"gray21",54,54,54},
-{"gray22",56,56,56},
-{"gray23",59,59,59},
-{"gray24",61,61,61},
-{"gray25",64,64,64},
-{"gray26",66,66,66},
-{"gray27",69,69,69},
-{"gray28",71,71,71},
-{"gray29",74,74,74},
-{"gray3",8,8,8},
-{"gray30",77,77,77},
-{"gray31",79,79,79},
-{"gray32",82,82,82},
-{"gray33",84,84,84},
-{"gray34",87,87,87},
-{"gray35",89,89,89},
-{"gray36",92,92,92},
-{"gray37",94,94,94},
-{"gray38",97,97,97},
-{"gray39",99,99,99},
-{"gray4",10,10,10},
-{"gray40",102,102,102},
-{"gray41",105,105,105},
-{"gray42",107,107,107},
-{"gray43",110,110,110},
-{"gray44",112,112,112},
-{"gray45",115,115,115},
-{"gray46",117,117,117},
-{"gray47",120,120,120},
-{"gray48",122,122,122},
-{"gray49",125,125,125},
-{"gray5",13,13,13},
-{"gray50",127,127,127},
-{"gray51",130,130,130},
-{"gray52",133,133,133},
-{"gray53",135,135,135},
-{"gray54",138,138,138},
-{"gray55",140,140,140},
-{"gray56",143,143,143},
-{"gray57",145,145,145},
-{"gray58",148,148,148},
-{"gray59",150,150,150},
-{"gray6",15,15,15},
-{"gray60",153,153,153},
-{"gray61",156,156,156},
-{"gray62",158,158,158},
-{"gray63",161,161,161},
-{"gray64",163,163,163},
-{"gray65",166,166,166},
-{"gray66",168,168,168},
-{"gray67",171,171,171},
-{"gray68",173,173,173},
-{"gray69",176,176,176},
-{"gray7",18,18,18},
-{"gray70",179,179,179},
-{"gray71",181,181,181},
-{"gray72",184,184,184},
-{"gray73",186,186,186},
-{"gray74",189,189,189},
-{"gray75",191,191,191},
-{"gray76",194,194,194},
-{"gray77",196,196,196},
-{"gray78",199,199,199},
-{"gray79",201,201,201},
-{"gray8",20,20,20},
-{"gray80",204,204,204},
-{"gray81",207,207,207},
-{"gray82",209,209,209},
-{"gray83",212,212,212},
-{"gray84",214,214,214},
-{"gray85",217,217,217},
-{"gray86",219,219,219},
-{"gray87",222,222,222},
-{"gray88",224,224,224},
-{"gray89",227,227,227},
-{"gray9",23,23,23},
-{"gray90",229,229,229},
-{"gray91",232,232,232},
-{"gray92",235,235,235},
-{"gray93",237,237,237},
-{"gray94",240,240,240},
-{"gray95",242,242,242},
-{"gray96",245,245,245},
-{"gray97",247,247,247},
-{"gray98",250,250,250},
-{"gray99",252,252,252},
-{"green",0,255,0},
-{"green1",0,255,0},
-{"green2",0,238,0},
-{"green3",0,205,0},
-{"green4",0,139,0},
-{"greenyellow",173,255,47},
-{"grey",192,192,192},
-{"grey0",0,0,0},
-{"grey1",3,3,3},
-{"grey10",26,26,26},
-{"grey100",255,255,255},
-{"grey11",28,28,28},
-{"grey12",31,31,31},
-{"grey13",33,33,33},
-{"grey14",36,36,36},
-{"grey15",38,38,38},
-{"grey16",41,41,41},
-{"grey17",43,43,43},
-{"grey18",46,46,46},
-{"grey19",48,48,48},
-{"grey2",5,5,5},
-{"grey20",51,51,51},
-{"grey21",54,54,54},
-{"grey22",56,56,56},
-{"grey23",59,59,59},
-{"grey24",61,61,61},
-{"grey25",64,64,64},
-{"grey26",66,66,66},
-{"grey27",69,69,69},
-{"grey28",71,71,71},
-{"grey29",74,74,74},
-{"grey3",8,8,8},
-{"grey30",77,77,77},
-{"grey31",79,79,79},
-{"grey32",82,82,82},
-{"grey33",84,84,84},
-{"grey34",87,87,87},
-{"grey35",89,89,89},
-{"grey36",92,92,92},
-{"grey37",94,94,94},
-{"grey38",97,97,97},
-{"grey39",99,99,99},
-{"grey4",10,10,10},
-{"grey40",102,102,102},
-{"grey41",105,105,105},
-{"grey42",107,107,107},
-{"grey43",110,110,110},
-{"grey44",112,112,112},
-{"grey45",115,115,115},
-{"grey46",117,117,117},
-{"grey47",120,120,120},
-{"grey48",122,122,122},
-{"grey49",125,125,125},
-{"grey5",13,13,13},
-{"grey50",127,127,127},
-{"grey51",130,130,130},
-{"grey52",133,133,133},
-{"grey53",135,135,135},
-{"grey54",138,138,138},
-{"grey55",140,140,140},
-{"grey56",143,143,143},
-{"grey57",145,145,145},
-{"grey58",148,148,148},
-{"grey59",150,150,150},
-{"grey6",15,15,15},
-{"grey60",153,153,153},
-{"grey61",156,156,156},
-{"grey62",158,158,158},
-{"grey63",161,161,161},
-{"grey64",163,163,163},
-{"grey65",166,166,166},
-{"grey66",168,168,168},
-{"grey67",171,171,171},
-{"grey68",173,173,173},
-{"grey69",176,176,176},
-{"grey7",18,18,18},
-{"grey70",179,179,179},
-{"grey71",181,181,181},
-{"grey72",184,184,184},
-{"grey73",186,186,186},
-{"grey74",189,189,189},
-{"grey75",191,191,191},
-{"grey76",194,194,194},
-{"grey77",196,196,196},
-{"grey78",199,199,199},
-{"grey79",201,201,201},
-{"grey8",20,20,20},
-{"grey80",204,204,204},
-{"grey81",207,207,207},
-{"grey82",209,209,209},
-{"grey83",212,212,212},
-{"grey84",214,214,214},
-{"grey85",217,217,217},
-{"grey86",219,219,219},
-{"grey87",222,222,222},
-{"grey88",224,224,224},
-{"grey89",227,227,227},
-{"grey9",23,23,23},
-{"grey90",229,229,229},
-{"grey91",232,232,232},
-{"grey92",235,235,235},
-{"grey93",237,237,237},
-{"grey94",240,240,240},
-{"grey95",242,242,242},
-{"grey96",245,245,245},
-{"grey97",247,247,247},
-{"grey98",250,250,250},
-{"grey99",252,252,252},
-{"honeydew",240,255,240},
-{"honeydew1",240,255,240},
-{"honeydew2",224,238,224},
-{"honeydew3",193,205,193},
-{"honeydew4",131,139,131},
-{"hotpink",255,105,180},
-{"hotpink1",255,110,180},
-{"hotpink2",238,106,167},
-{"hotpink3",205,96,144},
-{"hotpink4",139,58,98},
-{"indianred",205,92,92},
-{"indianred1",255,106,106},
-{"indianred2",238,99,99},
-{"indianred3",205,85,85},
-{"indianred4",139,58,58},
-{"indigo",75,0,130},
-{"ivory",255,255,240},
-{"ivory1",255,255,240},
-{"ivory2",238,238,224},
-{"ivory3",205,205,193},
-{"ivory4",139,139,131},
-{"khaki",240,230,140},
-{"khaki1",255,246,143},
-{"khaki2",238,230,133},
-{"khaki3",205,198,115},
-{"khaki4",139,134,78},
-{"lavender",230,230,250},
-{"lavenderblush",255,240,245},
-{"lavenderblush1",255,240,245},
-{"lavenderblush2",238,224,229},
-{"lavenderblush3",205,193,197},
-{"lavenderblush4",139,131,134},
-{"lawngreen",124,252,0},
-{"lemonchiffon",255,250,205},
-{"lemonchiffon1",255,250,205},
-{"lemonchiffon2",238,233,191},
-{"lemonchiffon3",205,201,165},
-{"lemonchiffon4",139,137,112},
-{"lightblue",173,216,230},
-{"lightblue1",191,239,255},
-{"lightblue2",178,223,238},
-{"lightblue3",154,192,205},
-{"lightblue4",104,131,139},
-{"lightcoral",240,128,128},
-{"lightcyan",224,255,255},
-{"lightcyan1",224,255,255},
-{"lightcyan2",209,238,238},
-{"lightcyan3",180,205,205},
-{"lightcyan4",122,139,139},
-{"lightgoldenrod",238,221,130},
-{"lightgoldenrod1",255,236,139},
-{"lightgoldenrod2",238,220,130},
-{"lightgoldenrod3",205,190,112},
-{"lightgoldenrod4",139,129,76},
-{"lightgoldenrodyellow",250,250,210},
-{"lightgray",211,211,211},
-{"lightgrey",211,211,211},
-{"lightpink",255,182,193},
-{"lightpink1",255,174,185},
-{"lightpink2",238,162,173},
-{"lightpink3",205,140,149},
-{"lightpink4",139,95,101},
-{"lightsalmon",255,160,122},
-{"lightsalmon1",255,160,122},
-{"lightsalmon2",238,149,114},
-{"lightsalmon3",205,129,98},
-{"lightsalmon4",139,87,66},
-{"lightseagreen",32,178,170},
-{"lightskyblue",135,206,250},
-{"lightskyblue1",176,226,255},
-{"lightskyblue2",164,211,238},
-{"lightskyblue3",141,182,205},
-{"lightskyblue4",96,123,139},
-{"lightslateblue",132,112,255},
-{"lightslategray",119,136,153},
-{"lightslategrey",119,136,153},
-{"lightsteelblue",176,196,222},
-{"lightsteelblue1",202,225,255},
-{"lightsteelblue2",188,210,238},
-{"lightsteelblue3",162,181,205},
-{"lightsteelblue4",110,123,139},
-{"lightyellow",255,255,224},
-{"lightyellow1",255,255,224},
-{"lightyellow2",238,238,209},
-{"lightyellow3",205,205,180},
-{"lightyellow4",139,139,122},
-{"limegreen",50,205,50},
-{"linen",250,240,230},
-{"magenta",255,0,255},
-{"magenta1",255,0,255},
-{"magenta2",238,0,238},
-{"magenta3",205,0,205},
-{"magenta4",139,0,139},
-{"maroon",176,48,96},
-{"maroon1",255,52,179},
-{"maroon2",238,48,167},
-{"maroon3",205,41,144},
-{"maroon4",139,28,98},
-{"mediumaquamarine",102,205,170},
-{"mediumblue",0,0,205},
-{"mediumorchid",186,85,211},
-{"mediumorchid1",224,102,255},
-{"mediumorchid2",209,95,238},
-{"mediumorchid3",180,82,205},
-{"mediumorchid4",122,55,139},
-{"mediumpurple",147,112,219},
-{"mediumpurple1",171,130,255},
-{"mediumpurple2",159,121,238},
-{"mediumpurple3",137,104,205},
-{"mediumpurple4",93,71,139},
-{"mediumseagreen",60,179,113},
-{"mediumslateblue",123,104,238},
-{"mediumspringgreen",0,250,154},
-{"mediumturquoise",72,209,204},
-{"mediumvioletred",199,21,133},
-{"midnightblue",25,25,112},
-{"mintcream",245,255,250},
-{"mistyrose",255,228,225},
-{"mistyrose1",255,228,225},
-{"mistyrose2",238,213,210},
-{"mistyrose3",205,183,181},
-{"mistyrose4",139,125,123},
-{"moccasin",255,228,181},
-{"navajowhite",255,222,173},
-{"navajowhite1",255,222,173},
-{"navajowhite2",238,207,161},
-{"navajowhite3",205,179,139},
-{"navajowhite4",139,121,94},
-{"navy",0,0,128},
-{"navyblue",0,0,128},
-{"oldlace",253,245,230},
-{"olivedrab",107,142,35},
-{"olivedrab1",192,255,62},
-{"olivedrab2",179,238,58},
-{"olivedrab3",154,205,50},
-{"olivedrab4",105,139,34},
-{"orange",255,165,0},
-{"orange1",255,165,0},
-{"orange2",238,154,0},
-{"orange3",205,133,0},
-{"orange4",139,90,0},
-{"orangered",255,69,0},
-{"orangered1",255,69,0},
-{"orangered2",238,64,0},
-{"orangered3",205,55,0},
-{"orangered4",139,37,0},
-{"orchid",218,112,214},
-{"orchid1",255,131,250},
-{"orchid2",238,122,233},
-{"orchid3",205,105,201},
-{"orchid4",139,71,137},
-{"palegoldenrod",238,232,170},
-{"palegreen",152,251,152},
-{"palegreen1",154,255,154},
-{"palegreen2",144,238,144},
-{"palegreen3",124,205,124},
-{"palegreen4",84,139,84},
-{"paleturquoise",175,238,238},
-{"paleturquoise1",187,255,255},
-{"paleturquoise2",174,238,238},
-{"paleturquoise3",150,205,205},
-{"paleturquoise4",102,139,139},
-{"palevioletred",219,112,147},
-{"palevioletred1",255,130,171},
-{"palevioletred2",238,121,159},
-{"palevioletred3",205,104,137},
-{"palevioletred4",139,71,93},
-{"papayawhip",255,239,213},
-{"peachpuff",255,218,185},
-{"peachpuff1",255,218,185},
-{"peachpuff2",238,203,173},
-{"peachpuff3",205,175,149},
-{"peachpuff4",139,119,101},
-{"peru",205,133,63},
-{"pink",255,192,203},
-{"pink1",255,181,197},
-{"pink2",238,169,184},
-{"pink3",205,145,158},
-{"pink4",139,99,108},
-{"plum",221,160,221},
-{"plum1",255,187,255},
-{"plum2",238,174,238},
-{"plum3",205,150,205},
-{"plum4",139,102,139},
-{"powderblue",176,224,230},
-{"purple",160,32,240},
-{"purple1",155,48,255},
-{"purple2",145,44,238},
-{"purple3",125,38,205},
-{"purple4",85,26,139},
-{"red",255,0,0},
-{"red1",255,0,0},
-{"red2",238,0,0},
-{"red3",205,0,0},
-{"red4",139,0,0},
-{"rosybrown",188,143,143},
-{"rosybrown1",255,193,193},
-{"rosybrown2",238,180,180},
-{"rosybrown3",205,155,155},
-{"rosybrown4",139,105,105},
-{"royalblue",65,105,225},
-{"royalblue1",72,118,255},
-{"royalblue2",67,110,238},
-{"royalblue3",58,95,205},
-{"royalblue4",39,64,139},
-{"saddlebrown",139,69,19},
-{"salmon",250,128,114},
-{"salmon1",255,140,105},
-{"salmon2",238,130,98},
-{"salmon3",205,112,84},
-{"salmon4",139,76,57},
-{"sandybrown",244,164,96},
-{"seagreen",46,139,87},
-{"seagreen1",84,255,159},
-{"seagreen2",78,238,148},
-{"seagreen3",67,205,128},
-{"seagreen4",46,139,87},
-{"seashell",255,245,238},
-{"seashell1",255,245,238},
-{"seashell2",238,229,222},
-{"seashell3",205,197,191},
-{"seashell4",139,134,130},
-{"sienna",160,82,45},
-{"sienna1",255,130,71},
-{"sienna2",238,121,66},
-{"sienna3",205,104,57},
-{"sienna4",139,71,38},
-{"skyblue",135,206,235},
-{"skyblue1",135,206,255},
-{"skyblue2",126,192,238},
-{"skyblue3",108,166,205},
-{"skyblue4",74,112,139},
-{"slateblue",106,90,205},
-{"slateblue1",131,111,255},
-{"slateblue2",122,103,238},
-{"slateblue3",105,89,205},
-{"slateblue4",71,60,139},
-{"slategray",112,128,144},
-{"slategray1",198,226,255},
-{"slategray2",185,211,238},
-{"slategray3",159,182,205},
-{"slategray4",108,123,139},
-{"slategrey",112,128,144},
-{"snow",255,250,250},
-{"snow1",255,250,250},
-{"snow2",238,233,233},
-{"snow3",205,201,201},
-{"snow4",139,137,137},
-{"springgreen",0,255,127},
-{"springgreen1",0,255,127},
-{"springgreen2",0,238,118},
-{"springgreen3",0,205,102},
-{"springgreen4",0,139,69},
-{"steelblue",70,130,180},
-{"steelblue1",99,184,255},
-{"steelblue2",92,172,238},
-{"steelblue3",79,148,205},
-{"steelblue4",54,100,139},
-{"tan",210,180,140},
-{"tan1",255,165,79},
-{"tan2",238,154,73},
-{"tan3",205,133,63},
-{"tan4",139,90,43},
-{"thistle",216,191,216},
-{"thistle1",255,225,255},
-{"thistle2",238,210,238},
-{"thistle3",205,181,205},
-{"thistle4",139,123,139},
-{"tomato",255,99,71},
-{"tomato1",255,99,71},
-{"tomato2",238,92,66},
-{"tomato3",205,79,57},
-{"tomato4",139,54,38},
-{"turquoise",64,224,208},
-{"turquoise1",0,245,255},
-{"turquoise2",0,229,238},
-{"turquoise3",0,197,205},
-{"turquoise4",0,134,139},
-{"violet",238,130,238},
-{"violetred",208,32,144},
-{"violetred1",255,62,150},
-{"violetred2",238,58,140},
-{"violetred3",205,50,120},
-{"violetred4",139,34,82},
-{"wheat",245,222,179},
-{"wheat1",255,231,186},
-{"wheat2",238,216,174},
-{"wheat3",205,186,150},
-{"wheat4",139,126,102},
-{"white",255,255,255},
-{"whitesmoke",245,245,245},
-{"yellow",255,255,0},
-{"yellow1",255,255,0},
-{"yellow2",238,238,0},
-{"yellow3",205,205,0},
-{"yellow4",139,139,0},
-{"yellowgreen",154,205,50},
-{"pastelblue",153,153,255},
-};
diff --git a/cmd/lefty/common.c b/cmd/lefty/common.c
deleted file mode 100644 (file)
index da03f2b..0000000
+++ /dev/null
@@ -1,452 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include <stdbool.h>
-#include <stddef.h>
-#include "common.h"
-
-int warnflag;
-char *leftypath, *leftyoptions, *shellpath;
-static size_t leftypathsz;
-static size_t leftypathlen;
-jmp_buf exitljbuf;
-int idlerunmode;
-fd_set inputfds;
-static bool innetscape;
-static char *nswin;
-
-#ifndef FEATURE_MS
-#define PATHDEL '/'
-#define PATHSEP ':'
-#define PATHSEPSTR ":"
-#define PATHLEFTY "/../lib/lefty"
-#else
-#define PATHDEL '\\'
-#define PATHSEP ';'
-#define PATHSEPSTR ";"
-#define PATHLEFTY "\\..\\lib\\lefty"
-#endif
-#ifdef FEATURE_X11
-#define WINSYS "LEFTYWINSYS=X11"
-#else
-#define WINSYS "LEFTYWINSYS=mswin"
-#endif
-#include "g.h"
-#include "gcommon.h"
-
-#ifdef FEATURE_MS
-extern int Gnocallbacks;
-#else
-static int Gnocallbacks;
-#endif
-
-static char *pathp;
-#define PATHINCR 10240
-#define PATHSIZE sizeof (char)
-static char *cmdp;
-#define CMDINCR 4096
-#define CMDSIZE sizeof (char)
-
-static char *lpathp;
-
-static void pathAppend(char* s, bool addSep)
-{
-    size_t newlen = leftypathlen + strlen(s) + (addSep ? 1 : 0);
-
-    if (newlen >= leftypathsz) {
-       leftypathsz = newlen + 1024;
-       if (!(leftypath = realloc (leftypath, leftypathsz)))
-            panic1 (POS, "init", "pathp realloc failed");
-    }
-    if (*s) strcat (leftypath, s);
-    if (addSep) strcat (leftypath, PATHSEPSTR);
-    leftypathlen = newlen;
-}
-
-int init (char *aout) {
-    char *s1, *s2, c;
-    int k;
-#ifdef FEATURE_WIN32
-        extern HANDLE hinstance;
-        char buf[260];
-#endif
-#ifdef LEFTYDATADIR
-    char *leftdatadir = LEFTYDATADIR;
-#else
-    char *leftdatadir = NULL;
-#endif
-
-    c = 0;
-    if (getenv ("INNETSCAPE"))
-        innetscape = true, nswin = getenv ("NSWIN");
-    if (!(pathp = malloc (PATHINCR * PATHSIZE)))
-        panic1 (POS, "init", "pathp malloc failed");
-    if (!(cmdp = malloc (CMDINCR * CMDSIZE)))
-        panic1 (POS, "init", "cmdp malloc failed");
-    shellpath = getenv ("PATH");
-#ifdef FEATURE_WIN32
-    GetModuleFileName (hinstance, buf, 260);
-    aout = buf;
-#else
-    if (!strchr (aout, PATHDEL)) {
-        leftypath = "";
-        if ((s1 = buildpath (aout, true)))
-            aout = strdup (s1);
-    } else
-        aout = strdup (aout);
-#endif
-    if (!(s1 = strrchr (aout, PATHDEL)))
-        s1 = aout;
-    *s1 = 0;
-    leftypathsz = PATHINCR * PATHSIZE;
-    if (!(leftypath = malloc (leftypathsz)))
-        panic1 (POS, "init", "leftypath malloc failed");
-    leftypath[0] = 0;
-    if ((s1 = getenv ("LEFTYPATH"))) {
-       pathAppend (s1, true);
-    }
-    if (*aout) {
-       pathAppend (aout, true);
-    }
-    for (k = 0; k < 2; k++) {
-        if (k == 0)
-            s1 = aout;
-        else
-            s1 = shellpath;
-        while (s1) {
-            if ((s2 = strchr (s1, PATHSEP)))
-                c = *s2, *s2 = 0;
-            pathAppend (s1, false);
-            pathAppend (PATHLEFTY, false);
-            if (s2) {
-                *s2 = c, s1 = s2 + 1;
-                pathAppend ("", true);
-            } else
-                s1 = NULL;
-        }
-        if (leftypath[0])
-            pathAppend ("", true);
-    }
-    if (leftdatadir) {    /* support a compile-time path as last resort */
-       pathAppend (leftdatadir, true);
-    }
-    if (!(leftyoptions = getenv ("LEFTYOPTIONS")))
-        leftyoptions = "";
-    putenv (WINSYS);
-    return 0;
-}
-
-void term (void) {
-    free (lpathp);
-    free (pathp);
-    free (cmdp);
-}
-
-/*  given a file name, it looks for this file in LEFTYPATH
-    (and if flag == TRUE in PATH)
-
-    returns the first occurance of that file or NULL
-*/
-char *buildpath (char *file, bool flag) {
-    struct stat statbuf;
-    char *s1, *s2;
-    int mode, pathi, i;
-
-#ifdef FEATURE_NETSCAPE
-    if (!flag && innetscape) {
-#ifdef FEATURE_WIN32
-        HWND hwnd;
-        char *s;
-
-        if (!nswin) {
-            MessageBox (
-                (HWND) NULL, "error: no peer window",
-                "Lefty Warning", MB_APPLMODAL
-            );
-            return NULL;
-        }
-        hwnd = atol (nswin);
-        fprintf (stdout, "file %s\n", file);
-        if (fflush (stdout) == -1) {
-            MessageBox (
-                (HWND) NULL, "Lost Connection to Netscape",
-                "Lefty Warning", MB_APPLMODAL
-            );
-            return NULL;
-        }
-        SendMessage (hwnd, WM_USER, 12, 34);
-        fgets (pathp, PATHINCR - 1, stdin);
-        pathp[strlen (pathp) - 1] = 0;
-        if (pathp[0] == 0)
-            return NULL;
-        return pathp;
-#else
-        Window window;
-        static XButtonEvent ev;
-
-        if (!nswin) {
-            fprintf (stderr, "error: no peer window\n");
-            return NULL;
-        }
-        window = strtol (nswin, NULL, 16);
-        fprintf (stdout, "file %s\n", file);
-        if (fflush (stdout) == -1) {
-            fprintf (stderr, "Lost Connection to Netscape\n");
-            return NULL;
-        }
-        ev.type = ButtonPress;
-        ev.window = window;
-        ev.x = -123, ev.y = -123;
-        XSendEvent (Gdisplay, window, False, 0, (XEvent *) &ev);
-        XFlush (Gdisplay);
-        fgets (pathp, PATHINCR - 1, stdin);
-        pathp[strlen (pathp) - 1] = 0;
-        if (pathp[0] == 0)
-            return NULL;
-        return pathp;
-#endif
-    }
-#endif
-
-#ifndef FEATURE_MS
-    if (file && file[0] && strchr (file, PATHDEL))
-        return file;
-    mode = S_IRUSR | (flag ? S_IXUSR : 0);
-    for (i = 0; i < 2; i++) {
-        if (i == 0)
-            s1 = leftypath;
-        else
-            s1 = shellpath;
-        while (*s1) {
-            pathi = 0;
-            while (*s1 && *s1 != PATHSEP)
-                if (pathi < PATHINCR)
-                    pathp[pathi++] = *s1++;
-            if (*s1)
-                s1++;
-            if (pathi + 3 + strlen (file) >= PATHINCR)
-                continue;
-            pathp[pathi++] = PATHDEL;
-            for (s2 = file; *s2; s2++)
-                pathp[pathi++] = *s2;
-            pathp[pathi] = '\000';
-            if (stat (pathp, &statbuf) == 0 && (statbuf.st_mode & mode))
-                return pathp;
-        }
-    }
-#else
-    if (file && file[0] && strchr (file, PATHDEL))
-        return file;
-    mode = ~0;
-    for (i = 0; i < 2; i++) {
-        if (i == 0)
-            s1 = leftypath;
-        else
-            s1 = shellpath;
-        while (*s1) {
-            pathi = 0;
-            while (*s1 && *s1 != PATHSEP)
-                if (pathi < PATHINCR)
-                    pathp[pathi++] = *s1++;
-            if (*s1)
-                s1++;
-            if (pathi + 7 + strlen (file) >= PATHINCR)
-                continue;
-            pathp[pathi++] = PATHDEL;
-            for (s2 = file; *s2; s2++)
-                pathp[pathi++] = *s2;
-            if (flag) {
-                pathp[pathi++] = '.';
-                pathp[pathi++] = 'e';
-                pathp[pathi++] = 'x';
-                pathp[pathi++] = 'e';
-            }
-            pathp[pathi] = '\000';
-            if (stat (pathp, &statbuf) == 0 && (statbuf.st_mode & mode))
-                return pathp;
-        }
-    }
-#endif
-    return NULL;
-}
-
-/*  given a file name (path) and an optional format (fmt)
-    it builds a shell command.
-
-    %e is replaced by the command path
-    %i      ...       the input channel descriptor
-    %o      ...       the output channel descriptor
-    %h      ...       the hostname
-
-    returns the complete command string or NULL
-*/
-char *buildcommand (char *path, char *host, int infd, int outfd, char *fmt) {
-    char buf[10];
-    char *s1, *s2;
-    int bufi;
-
-    cmdp[0] = '\000';
-    for (bufi = 0, s1 = fmt; *s1; s1++) {
-        if (*s1 == '%') {
-            if (*(s1 + 1) == 'e') {
-                s1++;
-                if (bufi + strlen (path) >= CMDINCR)
-                    return NULL;
-                for (s2 = path; *s2; s2++)
-                    cmdp[bufi++] = *s2;
-                continue;
-            } else if (*(s1 + 1) == 'i') {
-                if (infd == -1)
-                    buf[0] = '%', buf[1] = 'd', buf[2] = '\000';
-                else
-                    snprintf(buf, sizeof(buf), "%d", infd);
-                s1++;
-                if (bufi + strlen (buf) >= CMDINCR)
-                    return NULL;
-                for (s2 = buf; *s2; s2++)
-                    cmdp[bufi++] = *s2;
-                continue;
-            } else if (*(s1 + 1) == 'o') {
-                if (outfd == -1)
-                    buf[0] = '%', buf[1] = 'd', buf[2] = '\000';
-                else
-                    snprintf(buf, sizeof(buf), "%d", outfd);
-                s1++;
-                if (bufi + strlen (buf) >= CMDINCR)
-                    return NULL;
-                for (s2 = buf; *s2; s2++)
-                    cmdp[bufi++] = *s2;
-                continue;
-            } else if (*(s1 + 1) == 'h') {
-                s1++;
-                if (bufi + strlen (host) >= CMDINCR)
-                    return NULL;
-                for (s2 = host; *s2; s2++)
-                    cmdp[bufi++] = *s2;
-                continue;
-            }
-        }
-        if (bufi + 1 >= CMDINCR)
-            return NULL;
-        cmdp[bufi++] = *s1;
-    }
-    if (bufi + 1 >= CMDINCR)
-        return NULL;
-    cmdp[bufi] = '\000';
-    return &cmdp[0];
-}
-
-/* varargs function for printing a warning */
-void warning (char *file, int line, char *func, char *fmt, ...) {
-    va_list args;
-
-#ifndef FEATURE_MS
-    if (!warnflag)
-        return;
-
-    va_start(args, fmt);
-    Gnocallbacks = true;
-    fprintf (stderr, "warning: (file %s, line %d, func %s) ", file, line, func);
-    vfprintf (stderr, fmt, args);
-    fprintf (stderr, "\n");
-    Gnocallbacks = false;
-    va_end(args);
-#else
-    char buf[256];
-
-    if (!warnflag)
-        return;
-
-    va_start(args, fmt);
-    vsprintf (buf, fmt, args);
-    Gnocallbacks = true;
-    MessageBox ((HWND) NULL, buf, "Lefty Warning", MB_APPLMODAL);
-    Gnocallbacks = false;
-    va_end(args);
-#endif
-}
-
-/* varargs function for printing an error message and aborting */
-void panic1 (char *file, int line, char *func, char *fmt, ...) {
-    va_list args;
-
-#ifndef FEATURE_MS
-    va_start(args, fmt);
-    Gnocallbacks = true;
-    fprintf (stderr, "panic: (file %s, line %d, func %s) ", file, line, func);
-    vfprintf (stderr, fmt, args);
-    fprintf (stderr, "\n");
-    fflush (stdout);
-    Gnocallbacks = false;
-    va_end(args);
-#else
-    char buf[256];
-
-    va_start(args, fmt);
-    vsprintf (buf, fmt, args);
-    Gnocallbacks = true;
-    MessageBox ((HWND) NULL, buf, "Lefty PANIC", MB_APPLMODAL);
-    Gnocallbacks = false;
-    va_end(args);
-#endif
-    abort ();
-}
-
-/*  varargs function for printing an error message, and the
-    error message corresponding to errno and aborting
-*/
-void panic2 (char *file, int line, char *func, char *fmt, ...) {
-    va_list args;
-
-#ifndef FEATURE_MS
-    va_start(args, fmt);
-    Gnocallbacks = true;
-    fprintf (stderr, "panic: (file %s, line %d, func %s) ", file, line, func);
-    vfprintf (stderr, fmt, args);
-    fprintf (stderr, "\n");
-    perror ("");
-    fflush (stdout);
-    Gnocallbacks = false;
-    va_end(args);
-#else
-    char buf[256];
-
-    va_start(args, fmt);
-    vsprintf (buf, fmt, args);
-    Gnocallbacks = true;
-    MessageBox ((HWND) NULL, buf, "Lefty PANIC", MB_APPLMODAL);
-    Gnocallbacks = false;
-    va_end(args);
-#endif
-    abort ();
-}
-
-#ifdef FEATURE_MS
-int gprintf (const char *fmt, ...) {
-    va_list args;
-    char buf[10240];
-    size_t l;
-
-    va_start(args, fmt);
-    vsprintf (buf, fmt, args);
-    l = strlen (buf);
-    if (buf[l - 1] == '\n')
-        buf[l - 1] = 0;
-    if (buf[0]) {
-        Gnocallbacks = true;
-        MessageBox ((HWND) NULL, buf, "Lefty printf", MB_APPLMODAL);
-        Gnocallbacks = false;
-    }
-    va_end(args);
-}
-#endif
-
diff --git a/cmd/lefty/common.h b/cmd/lefty/common.h
deleted file mode 100644 (file)
index c15e957..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#ifndef _COMMON_H
-#define _COMMON_H
-
-/* some config and conversion definitions from graphviz distribution */
-#include "config.h"
-/* we set some parameters which graphviz assumes.
- * At some point, we could consider allowing these to be set in configure
- * See Makefile.old for others.
- */
-#define FEATURE_MINTSIZE 1
-#define FEATURE_DOT 1
-#if defined(_WIN32)
-#ifndef FEATURE_WIN32
-#define FEATURE_WIN32 1
-#endif
-#ifndef FEATURE_MS
-#define FEATURE_MS 1
-#endif
-#else
-#define FEATURE_X11 1
-#endif
-
-#include <stdbool.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifndef _WIN32
-#include <sys/time.h>
-#endif
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-
-#include <inttypes.h>
-#include <math.h>
-#include <stdio.h>
-#include <setjmp.h>
-#include <ctype.h>
-
-#ifdef FEATURE_WIN32
-#include <windows.h>
-#include <commdlg.h>
-#endif
-
-#ifdef FEATURE_MS
-#define printf gprintf
-#endif
-
-#define POS __FILE__, __LINE__
-
-#ifndef TRUE
-#define TRUE  1
-#define FALSE 0
-#endif
-
-#ifndef L_SUCCESS
-#define L_SUCCESS 1
-#define L_FAILURE 0
-#endif
-
-#define CHARSRC 0
-#define FILESRC 1
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-extern int warnflag;
-extern char *leftypath, *leftyoptions, *shellpath;
-extern jmp_buf exitljbuf;
-extern int idlerunmode;
-extern fd_set inputfds;
-
-int init (char *);
-void term (void);
-char *buildpath (char *, bool);
-char *buildcommand (char *, char *, int, int, char *);
-void warning (char *, int, char *, char *, ...);
-
-#ifdef __GNUC__
-  // FIXME: use _Noreturn for all compilers when we move to C11
-  #define NORETURN __attribute__((noreturn))
-#else
-  #define NORETURN /* nothing */
-#endif
-NORETURN void panic1 (char *, int, char *, char *, ...);
-NORETURN void panic2 (char *, int, char *, char *, ...);
-#undef NORETURN
-
-#endif /* _COMMON_H */
diff --git a/cmd/lefty/cs2l/cs2l.c b/cmd/lefty/cs2l/cs2l.c
deleted file mode 100644 (file)
index 824dc1e..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include <ast.h>
-#include <cs.h>
-#include <msg.h>
-#include "common.h"
-#include "code.h"
-#include "mem.h"
-#include "tbl.h"
-#include "exec.h"
-#include "cs2l.h"
-
-int C2Lopen (char *name, char *mode, FILE **ifp, FILE **ofp) {
-    int fd;
-
-    if ((fd = csopen (name, CS_OPEN_READ)) == -1)
-        return -1;
-    fcntl (fd, F_SETFD, FD_CLOEXEC);
-    *ifp = fdopen (fd, "r"), *ofp = fdopen (fd, "a+");
-    return 0;
-}
-
-/* LEFTY builtin */
-int C2Lreadcsmessage (int argc, lvar_t *argv) {
-    return L_SUCCESS;
-}
diff --git a/cmd/lefty/cs2l/cs2l.h b/cmd/lefty/cs2l/cs2l.h
deleted file mode 100644 (file)
index 804f6c9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-    int C2Lopen(char *, char *, FILE **, FILE **);
diff --git a/cmd/lefty/display.c b/cmd/lefty/display.c
deleted file mode 100644 (file)
index fb16d49..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "mem.h"
-#include "code.h"
-#include "tbl.h"
-#include "str.h"
-#include "display.h"
-
-typedef struct dnode_t {
-    int ttype;
-    Tobj ko, vo;
-    char *path;
-} dnode_t;
-
-typedef struct seennode_t {
-    Tobj vo;
-    char *path;
-} seennode_t;
-static seennode_t *seenp;
-static int seeni, seenn;
-#define SEENINCR 100
-#define SEENSIZE sizeof (seennode_t)
-
-static int indent, afternl;
-
-static void update (dnode_t *);
-static int cmp (const void *, const void *);
-static seennode_t *findseen (dnode_t *);
-static void add2seen (dnode_t *);
-static void pr (char *);
-
-void Dinit (void) {
-    seenp = Marrayalloc ((long) SEENINCR * SEENSIZE);
-    seeni = 0;
-    seenn = SEENINCR;
-}
-
-void Dterm (void) {
-    Marrayfree (seenp);
-    seeni = seenn = 0;
-}
-
-void Dtrace (Tobj to, int offset) {
-    dnode_t dnode;
-    char *s;
-    int i;
-
-    indent = offset - 2;
-    afternl = TRUE;
-    if (Tgettype (to) != T_TABLE) {
-        pr ((s = Ssfull (NULL, to))), free (s);
-        return;
-    }
-
-    seeni = 0;
-    dnode.vo = to;
-    dnode.path = "";
-    update (&dnode);
-    for (i = 0; i < seeni; i++)
-        free (seenp[i].path), seenp[i].path = NULL;
-}
-
-static void update (dnode_t *pnode) {
-    Tkvindex_t tkvi;
-    dnode_t *list, *cnode;
-    seennode_t *seennode;
-    char *s;
-    long i, n;
-
-    indent += 2;
-    n = ((Ttable_t *) pnode->vo)->n;
-    if (!(list = malloc (n * sizeof (dnode_t))))
-        panic1 (POS, "update", "list malloc failed");
-    for (
-        cnode = &list[0], Tgetfirst (pnode->vo, &tkvi); tkvi.kvp;
-        cnode++, Tgetnext (&tkvi)
-    ) {
-        cnode->ko = tkvi.kvp->ko;
-        cnode->vo = tkvi.kvp->vo;
-        cnode->ttype = Tgettype (cnode->vo);
-    }
-    qsort ((char *) list, n, sizeof (dnode_t), cmp);
-    for (i = 0, cnode = &list[0]; i < n; i++, cnode++) {
-        cnode->path = Spath (pnode->path, cnode->ko);
-        seennode = findseen (cnode);
-        if (seennode) {
-            pr ((s = Sseen (cnode->ko, seennode->path))), free (s);
-        } else {
-            add2seen (cnode);
-            if (cnode->ttype == T_TABLE) {
-                pr ((s = Stfull (cnode->ko))), free (s);
-                update (cnode);
-                pr ("];");
-            } else {
-                pr ((s = Ssfull (cnode->ko, cnode->vo))), free (s);
-            }
-        }
-    }
-    free (list);
-    indent -= 2;
-}
-
-static int cmp (const void *a, const void *b) {
-    int atype, btype;
-    dnode_t *anode, *bnode;
-    double d1, d2;
-
-    d1 = 0.0, d2 = 0.0;
-    anode = (dnode_t *) a, bnode = (dnode_t *) b;
-    atype = Tgettype (anode->ko), btype = Tgettype (bnode->ko);
-    if (atype != btype)
-        return (atype - btype);
-    if (atype == T_STRING)
-        return strcmp (Tgetstring (anode->ko), Tgetstring (bnode->ko));
-    if (atype == T_INTEGER)
-        d1 = Tgetinteger (anode->ko), d2 = Tgetinteger (bnode->ko);
-    else if (atype == T_REAL)
-        d1 = Tgetreal (anode->ko), d2 = Tgetreal (bnode->ko);
-    if (d1 < d2)
-        return -1;
-    else if (d1 > d2)
-        return 1;
-    else
-        return 0; /* but this should never happen since keys are unique */
-}
-
-static seennode_t *findseen (dnode_t *cnode) {
-    int i;
-
-    for (i = 0; i < seeni; i++)
-        if (seenp[i].vo == cnode->vo)
-            return &seenp[i];
-    return NULL;
-}
-
-static void add2seen (dnode_t *cnode) {
-    if (seeni >= seenn) {
-        seenp = Marraygrow (seenp, (long) (seenn + SEENINCR) * SEENSIZE);
-        seenn += SEENINCR;
-    }
-    seenp[seeni].vo = cnode->vo;
-    seenp[seeni++].path = cnode->path;
-}
-
-static void pr (char *s) {
-    char *s1;
-    int i;
-
-    for (s1 = s; *s1; s1++) {
-        if (afternl) {
-            for (i = 0; i < indent; i++)
-                putchar (' ');
-            afternl = FALSE;
-        }
-        if (*s1 == '\n')
-            afternl = TRUE;
-        putchar ((*s1)); /* HACK: to keep proto happy */
-    }
-    putchar ('\n');
-    afternl = TRUE;
-}
diff --git a/cmd/lefty/display.h b/cmd/lefty/display.h
deleted file mode 100644 (file)
index 56527a3..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-void Dinit (void);
-void Dterm (void);
-void Dtrace (Tobj, int);
diff --git a/cmd/lefty/dot2l/dot2l.c b/cmd/lefty/dot2l/dot2l.c
deleted file mode 100644 (file)
index e6a4108..0000000
+++ /dev/null
@@ -1,766 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#include "common.h"
-#include "mem.h"
-#include "leftyio.h"
-#include "code.h"
-#include "tbl.h"
-#include "dot2l.h"
-#include <stdbool.h>
-
-extern void lex_begin (int);
-
-char *gtype, *etype;
-int yaccdone;
-int attrclass;
-int inattrstmt;
-
-static graphframe_t *gstack, *topgframe;
-static Tobj allgraphs, alledges, allnodes;
-static Tobj gdict, edict, ndict, N;
-static long newgid, neweid, newnid, gmark = -1, errflag;
-
-static int filllabeltable (Tobj, int);
-static int filllabelrect (Tobj);
-
-static char *lsp, *rsp;
-
-static void writesgraph (int, Tobj, int, int, char *);
-static void writeattr (int, Tobj, char *);
-static void quotestring (char *, Tobj);
-
-Tobj D2Lparsegraphlabel (Tobj lo, Tobj ro) {
-    long lm;
-    Tobj to;
-
-    lm = Mpushmark (lo);
-    Mpushmark (ro);
-    to = Ttable (4);
-    Mpushmark (to);
-    lsp = Tgetstring (lo);
-    if (ro && T_ISSTRING (ro))
-        rsp = Tgetstring (ro);
-    else
-        rsp = NULL;
-
-    if (filllabeltable (to, TRUE) != 0) {
-        to = NULL;
-        fprintf (stderr, "error in label >>%s<<\n", lsp);
-    }
-    Mpopmark (lm);
-    return to;
-}
-
-#define HASTEXT 1
-#define HASPORT 2
-#define HASTABLE 4
-#define INTEXT 8
-#define INPORT 16
-
-#define ISCTRL(c) ( \
-    (c) == '{' || (c) == '}' || (c) == '|' || (c) == '<' || (c) == '>' \
-)
-
-static int filllabeltable (Tobj to, int flag) {
-    Tobj cto, fo;
-    char *tsp, *psp, *hstsp, *hspsp;
-    char text[10240], port[256];
-    long cti;
-    int mode, wflag, ishardspace;
-
-    mode = 0;
-    cti = 0;
-    Tinsi (to, cti++, (cto = Ttable (2)));
-    hstsp = tsp = &text[0], hspsp = psp = &port[0];
-    wflag = TRUE;
-    ishardspace = FALSE;
-    while (wflag) {
-        switch (*lsp) {
-        case '<':
-            if (mode & (HASTABLE | HASPORT))
-                return -1;
-            mode &= ~INTEXT;
-            mode |= (HASPORT | INPORT);
-            lsp++;
-            break;
-        case '>':
-            if (!(mode & INPORT))
-                return -1;
-            mode &= ~INPORT;
-            lsp++;
-            break;
-        case '{':
-            lsp++;
-            if (mode != 0 || !*lsp)
-                return -1;
-            Tinss (cto, "fields", (fo = Ttable (2)));
-            mode = HASTABLE;
-            if (filllabeltable (fo, FALSE) != 0)
-                return -1;
-            break;
-        case '}':
-        case '|':
-        case '\000':
-            if ((!*lsp && !flag) || (mode & INPORT))
-                return -1;
-            if (mode & HASPORT) {
-                if (psp > &port[0] + 1 && psp - 1 != hspsp && *(psp - 1) == ' ')
-                    psp--;
-                *psp = '\000';
-                Tinss (cto, "port", Tstring (&port[0]));
-                hspsp = psp = &port[0];
-            }
-            if (!(mode & (HASTEXT | HASTABLE)))
-                mode |= HASTEXT, *tsp++ = ' ';
-            if (mode & HASTEXT) {
-                if (tsp > &text[0] + 1 && tsp - 1 != hstsp && *(tsp - 1) == ' ')
-                    tsp--;
-                *tsp = '\000';
-                Tinss (cto, "text", Tstring (&text[0]));
-                hstsp = tsp = &text[0];
-            }
-            if (mode & (HASTEXT | HASPORT))
-                if (filllabelrect (cto) != 0)
-                    return -1;
-            if (*lsp) {
-                if (*lsp == '}') {
-                    lsp++;
-                    return 0;
-                }
-                Tinsi (to, cti++, (cto = Ttable (2)));
-                mode = 0;
-                lsp++;
-            } else
-                wflag = FALSE;
-            break;
-        case '\\':
-            if (*(lsp + 1)) {
-                if (ISCTRL (*(lsp + 1)))
-                    lsp++;
-                else if (*(lsp + 1) == ' ')
-                    ishardspace = TRUE, lsp++;
-           }
-            /* fall through */
-        default:
-            if ((mode & HASTABLE) && *lsp != ' ')
-                return -1;
-            if (!(mode & (INTEXT | INPORT)) && (ishardspace || *lsp != ' '))
-                mode |= (INTEXT | HASTEXT);
-            if (mode & INTEXT) {
-                if (!(*lsp == ' ' && !ishardspace && *(tsp - 1) == ' '))
-                    *tsp++ = *lsp;
-                if (ishardspace)
-                    hstsp = tsp - 1;
-            } else if (mode & INPORT) {
-                if (
-                    !(*lsp == ' ' && !ishardspace && (psp == &port[0] ||
-                    *(psp - 1) == ' '))
-                )
-                    *psp++ = *lsp;
-                if (ishardspace)
-                    hspsp = psp - 1;
-            }
-            ishardspace = FALSE;
-            lsp++;
-            break;
-        }
-    }
-    return 0;
-}
-
-static int filllabelrect (Tobj to) {
-    Tobj ro, p0o, p1o;
-    char *s2, *s3;
-    char c, c2;
-    int i;
-
-    if (!rsp)
-        return 0;
-    for (s2 = rsp; *s2 && *s2 != ' '; s2++)
-        ;
-    c = *s2, *s2 = 0;
-    Tinss (to, "rect", (ro = Ttable (2)));
-    Tinsi (ro, 0, (p0o = Ttable (2)));
-    Tinsi (ro, 1, (p1o = Ttable (2)));
-    for (i = 0; i < 4; i++) {
-        for (s3 = rsp; *s3 && *s3 != ','; s3++)
-            ;
-        c2 = *s3, *s3 = 0;
-        if (s3 == rsp)
-            return -1;
-        switch (i) {
-        case 0: Tinss (p0o, "x", Tinteger ((long) atoi (rsp))); break;
-        case 1: Tinss (p0o, "y", Tinteger ((long) atoi (rsp))); break;
-        case 2: Tinss (p1o, "x", Tinteger ((long) atoi (rsp))); break;
-        case 3: Tinss (p1o, "y", Tinteger ((long) atoi (rsp))); break;
-        }
-        *s3 = c2;
-        rsp = s3;
-        if (*rsp == ',')
-            rsp++;
-    }
-    *s2 = c;
-    rsp = s2 + 1;
-    return 0;
-}
-
-static Tobj nameo, attro, edgeso, hporto, tporto, heado, tailo, protogo;
-
-Tobj D2Lreadgraph (int ioi, Tobj protograph) {
-    graphframe_t *gframe, *tgframe;
-    edgeframe_t *eframe, *teframe;
-    Tobj graph;
-    long m;
-
-    protogo = protograph;
-    nameo = Tstring ("name");
-    m = Mpushmark (nameo);
-    attro = Tstring ("attr");
-    Mpushmark (attro);
-    edgeso = Tstring ("edges");
-    Mpushmark (edgeso);
-    hporto = Tstring ("hport");
-    Mpushmark (hporto);
-    tporto = Tstring ("tport");
-    Mpushmark (tporto);
-    heado = Tstring ("head");
-    Mpushmark (heado);
-    tailo = Tstring ("tail");
-    Mpushmark (tailo);
-    yaccdone = FALSE;
-    gstack = topgframe = NULL;
-    errflag = FALSE;
-    lex_begin (ioi);
-    yyparse ();
-    graph = NULL;
-    if (topgframe) {
-        graph = (errflag) ? NULL : topgframe->g;
-        for (gframe = gstack; gframe; gframe = tgframe) {
-            for (eframe = gframe->estack; eframe; eframe = teframe) {
-                teframe = eframe->next;
-                Mfree (eframe, M_BYTE2SIZE (sizeof (edgeframe_t)));
-            }
-            tgframe = gframe->next;
-            Mfree (gframe, M_BYTE2SIZE (sizeof (graphframe_t)));
-        }
-        goto done;
-    }
-done:
-    Mpopmark (m);
-    return graph;
-}
-
-void D2Lwritegraph (int ioi, Tobj graph, int flag) {
-    Tobj nodes, node, sgraphs, sgraph, edges, edge, tail, head, tport, hport;
-    Tobj so, no, eo, to;
-    char buf[10240];
-    char *s;
-    int isdag, n, nn, i;
-
-    if (!(so = Tfinds (graph, "type")) || !T_ISSTRING (so))
-        s = "digraph";
-    else {
-        s = Tgetstring (so);
-        if (!*s)
-            s = "digraph";
-    }
-    strcpy (buf, s);
-    if (strcmp (s, "digraph") == 0 || strcmp (s, "strict digraph") == 0)
-        isdag = 1;
-    else
-        isdag = 0;
-    if (!(so = Tfinds (graph, "name")) || !T_ISSTRING (so))
-        s = "g";
-    else {
-        s = Tgetstring (so);
-        if (!*s)
-            s = "g";
-    }
-    strcat (buf, " ");
-    quotestring (buf, Tstring (s));
-    strcat (buf, " {");
-    IOwriteline (ioi, buf);
-    buf[0] = '\t', buf[1] = '\t', buf[2] = 0;
-    if ((to = Tfinds (graph, "graphattr")) && T_ISTABLE (to)) {
-        IOwriteline (ioi, "\tgraph [");
-        writeattr (ioi, to, buf);
-        IOwriteline (ioi, "\t]");
-    }
-    if ((to = Tfinds (graph, "nodeattr")) && T_ISTABLE (to)) {
-        IOwriteline (ioi, "\tnode [");
-        writeattr (ioi, to, buf);
-        IOwriteline (ioi, "\t]");
-    }
-    if ((to = Tfinds (graph, "edgeattr")) && T_ISTABLE (to)) {
-        IOwriteline (ioi, "\tedge [");
-        writeattr (ioi, to, buf);
-        IOwriteline (ioi, "\t]");
-    }
-
-    n = 0;
-    if ((nodes = Tfinds (graph, "nodes"))) {
-        if (!(no = Tfinds (graph, "maxnid")) || !T_ISNUMBER (no))
-            n = 100 * Tgettablen (nodes);
-        else
-            n = Tgetnumber (no);
-        for (i = 0; i < n; i++) {
-            if (!(node = Tfindi (nodes, i)))
-                continue;
-            buf[0] = '\t', buf[1] = 0;
-            quotestring (buf, Tfinds (node, "name"));
-            strcat (buf, " [");
-            IOwriteline (ioi, buf);
-            buf[0] = '\t', buf[1] = '\t', buf[2] = 0;
-            if ((to = Tfinds (node, "attr")))
-                writeattr (ioi, to, buf);
-            IOwriteline (ioi, "\t]");
-        }
-    }
-    nn = n;
-    if ((sgraphs = Tfinds (graph, "graphs"))) {
-        if (!(no = Tfinds (graph, "maxgid")) || !T_ISNUMBER (no))
-            n = 100 * Tgettablen (sgraphs);
-        else
-            n = Tgetnumber (no);
-        for (i = 0; i < n; i++) {
-            if (!(sgraph = Tfindi (sgraphs, i)) || Tfinds (sgraph, "wmark"))
-                continue;
-            buf[0] = '\t', buf[1] = 0;
-            writesgraph (ioi, sgraph, n, nn, buf);
-        }
-        for (i = 0; i < n; i++) {
-            if (!(sgraph = Tfindi (sgraphs, i)))
-                continue;
-            Tdels (sgraph, "wmark");
-        }
-    }
-    if ((edges = Tfinds (graph, "edges"))) {
-        if (!(eo = Tfinds (graph, "maxeid")) || !T_ISNUMBER (eo))
-            n = 100 * Tgettablen (edges);
-        else
-            n = Tgetnumber (eo);
-        for (i = 0; i < n; i++) {
-            if (!(edge = Tfindi (edges, i)))
-                continue;
-            if (!(tail = Tfinds (edge, "tail")))
-                continue;
-            if (!(head = Tfinds (edge, "head")))
-                continue;
-            tport = Tfinds (edge, "tport");
-            hport = Tfinds (edge, "hport");
-            buf[0] = '\t', buf[1] = 0;
-            quotestring (buf, Tfinds (tail, "name"));
-            if (tport && T_ISSTRING (tport)) {
-                strcat (buf, ":");
-                quotestring (buf, tport);
-            }
-            strcat (buf, isdag ? " -> " : " -- ");
-            quotestring (buf, Tfinds (head, "name"));
-            if (hport && T_ISSTRING (hport)) {
-                strcat (buf, ":");
-                quotestring (buf, hport);
-            }
-            strcat (buf, " [");
-            IOwriteline (ioi, buf);
-            buf[0] = '\t', buf[1] = '\t', buf[2] = 0;
-            if ((to = Tfinds (edge, "attr")))
-                writeattr (ioi, to, buf);
-            if (flag) {
-                snprintf(buf, sizeof(buf), "\t\tid = %d", i);
-                IOwriteline (ioi, buf);
-            }
-            IOwriteline (ioi, "\t]");
-        }
-    }
-    IOwriteline (ioi, "}");
-}
-
-static void writesgraph (int ioi, Tobj graph, int gn, int nn, char *buf) {
-    Tobj nodes, node, sgraphs, sgraph, so, to;
-    char *s1, *s2, *s3;
-    int i;
-
-    Tinss (graph, "wmark", Tinteger (1));
-    s1 = buf + strlen (buf);
-    if (!(so = Tfinds (graph, "name")) || !T_ISSTRING (so))
-        sprintf (s1, "{");
-    else {
-        strcat (s1, "subgraph ");
-        quotestring (s1, so);
-        strcat (s1, " {");
-    }
-    IOwriteline (ioi, buf);
-    s2 = s1 + 1;
-    s3 = s2 + 1;
-    *s1 = '\t', *s2 = 0;
-    if ((to = Tfinds (graph, "graphattr")) && T_ISTABLE (to)) {
-        strcat (s1, "graph [");
-        IOwriteline (ioi, buf);
-        *s2 = '\t', *s3 = 0;
-        writeattr (ioi, to, buf);
-        *s2 = 0;
-        strcat (s1, "]");
-        IOwriteline (ioi, buf);
-        *s2 = 0;
-    }
-    if ((to = Tfinds (graph, "nodeattr")) && T_ISTABLE (to)) {
-        strcat (s1, "node [");
-        IOwriteline (ioi, buf);
-        *s2 = '\t', *s3 = 0;
-        writeattr (ioi, to, buf);
-        *s2 = 0;
-        strcat (s1, "]");
-        IOwriteline (ioi, buf);
-        *s2 = 0;
-    }
-    if ((to = Tfinds (graph, "edgeattr")) && T_ISTABLE (to)) {
-        strcat (s1, "edge [");
-        IOwriteline (ioi, buf);
-        *s2 = '\t', *s3 = 0;
-        writeattr (ioi, to, buf);
-        *s2 = 0;
-        strcat (s1, "]");
-        IOwriteline (ioi, buf);
-        *s2 = 0;
-    }
-    if ((nodes = Tfinds (graph, "nodes"))) {
-        for (i = 0; i < nn; i++) {
-            *s2 = 0;
-            if (!(node = Tfindi (nodes, i)))
-                continue;
-            quotestring (buf, Tfinds (node, "name"));
-            IOwriteline (ioi, buf);
-        }
-    }
-    if ((sgraphs = Tfinds (graph, "graphs"))) {
-        for (i = 0; i < gn; i++) {
-            if (!(sgraph = Tfindi (sgraphs, i)) || Tfinds (sgraph, "wmark"))
-                continue;
-            *s2 = 0;
-            writesgraph (ioi, sgraph, gn, nn, buf);
-        }
-    }
-    *s1 = '}', *s2 = 0;
-    IOwriteline (ioi, buf);
-    *s1 = 0;
-}
-
-static void writeattr (int ioi, Tobj to, char *buf) {
-    Tkvindex_t tkvi;
-    char *s1, *s2, *s3;
-    bool htmlflag;
-
-    s1 = buf + strlen (buf);
-    for (Tgetfirst (to, &tkvi); tkvi.kvp; Tgetnext (&tkvi)) {
-        switch (Tgettype (tkvi.kvp->ko)) {
-        case T_INTEGER:
-            sprintf (s1, "%ld = ", Tgetinteger (tkvi.kvp->ko));
-            break;
-        case T_REAL:
-            sprintf (s1, "%lf = ", Tgetreal (tkvi.kvp->ko));
-            break;
-        case T_STRING:
-            sprintf (s1, "%s = ", Tgetstring (tkvi.kvp->ko));
-            break;
-        }
-        s2 = buf + strlen (buf);
-        switch (Tgettype (tkvi.kvp->vo)) {
-        case T_INTEGER:
-            sprintf (s2, "\"%ld\"", Tgetinteger (tkvi.kvp->vo));
-            break;
-        case T_REAL:
-            sprintf (s2, "\"%lf\"", Tgetreal (tkvi.kvp->vo));
-            break;
-        case T_STRING:
-            *s2++ = '"', htmlflag = false;
-            if (
-                *(s3 = Tgetstring (tkvi.kvp->vo)) == '>' &&
-                s3[strlen (s3) - 1] == '<'
-            )
-                *(s2 - 1) = '<', s3++, htmlflag = true;
-            for ( ; *s3; s3++)
-                if (!htmlflag && *s3 == '"')
-                    *s2++ = '\\', *s2++ = *s3;
-                else
-                    *s2++ = *s3;
-            if (!htmlflag)
-                *s2++ = '"', *s2 = 0;
-            else
-                *(s2 - 1) = '>', *s2 = 0;
-            break;
-        default:
-            sprintf (s2, "\"\"");
-            break;
-        }
-        IOwriteline (ioi, buf);
-    }
-    *s1 = 0;
-}
-
-static void quotestring (char *buf, Tobj so) {
-    char *s1, *s2;
-
-    s1 = buf + strlen (buf);
-    *s1++ = '"';
-    if (so && T_ISSTRING (so))
-        for (s2 = Tgetstring (so); *s2; s2++) {
-            if (*s2 == '"')
-                *s1++ = '\\', *s1++ = *s2;
-            else
-                *s1++ = *s2;
-       }
-    *s1++ = '"', *s1 = 0;
-}
-
-static void anonname(char* buf)
-{
-    static int              anon_id = 0;
-
-    sprintf(buf,"_anonymous_%d",anon_id++);
-}
-
-void D2Lbegin (char *name) {
-
-    char buf[BUFSIZ];
-    newgid = neweid = newnid = 0;
-    attrclass = GRAPH;
-
-    if (!(gstack = Mallocate (sizeof (graphframe_t))))
-        panic1 (POS, "D2Lbegingraph", "cannot allocate graph stack");
-    gstack->next = NULL;
-    gstack->estack = NULL;
-    topgframe = gstack;
-
-    gmark = Mpushmark ((gstack->g = Ttable (12)));
-    Tinss (gstack->g, "type", Tstring (gtype));
-    if (!name) {
-        anonname(buf);
-        name = buf;
-    }
-    Tinss (gstack->g, "name", Tstring (name));
-
-    /* the dictionaries */
-    Tinss (gstack->g, "graphdict", (gdict = Ttable (10)));
-    Tinss (gstack->g, "nodedict", (ndict = Ttable (10)));
-    Tinss (gstack->g, "edgedict", (edict = Ttable (10)));
-
-    /* this graph's nodes, edges, subgraphs */
-    Tinss (gstack->g, "nodes", (allnodes = gstack->nodes = Ttable (10)));
-    Tinss (gstack->g, "graphs", (allgraphs = gstack->graphs = Ttable (10)));
-    Tinss (gstack->g, "edges", (alledges = gstack->edges = Ttable (10)));
-
-    /* attributes */
-    gstack->gattr = gstack->nattr = gstack->eattr = NULL;
-    if (protogo) {
-        gstack->gattr = Tfinds (protogo, "graphattr");
-        gstack->nattr = Tfinds (protogo, "nodeattr");
-        gstack->eattr = Tfinds (protogo, "edgeattr");
-    }
-    gstack->gattr = (gstack->gattr ? Tcopy (gstack->gattr) : Ttable (10));
-    Tinss (gstack->g, "graphattr", gstack->gattr);
-    gstack->nattr = (gstack->nattr ? Tcopy (gstack->nattr) : Ttable (10));
-    Tinss (gstack->g, "nodeattr", gstack->nattr);
-    gstack->eattr = (gstack->eattr ? Tcopy (gstack->eattr) : Ttable (10));
-    Tinss (gstack->g, "edgeattr", gstack->eattr);
-    gstack->ecopy = gstack->eattr;
-}
-
-void D2Lend (void) {
-    if (gmark != -1)
-        Mpopmark (gmark);
-    gmark = -1;
-    yaccdone = TRUE;
-}
-
-void D2Labort (void) {
-    if (gmark != -1)
-        Mpopmark (gmark);
-    errflag = TRUE;
-    yaccdone = TRUE;
-}
-
-void D2Lpushgraph (char *name) {
-    graphframe_t *gframe;
-    Tobj g, idobj, nameobj;
-    long gid;
-
-    if (!(gframe = Mallocate (sizeof (graphframe_t))))
-        panic1 (POS, "D2Lpushgraph", "cannot allocate graph stack");
-    gframe->next = gstack, gstack = gframe;
-    gstack->estack = NULL;
-
-    if (name && (idobj = Tfinds (gdict, name))) {
-        gid = Tgetnumber (idobj), gstack->g = g = Tfindi (allgraphs, gid);
-        gstack->nodes = Tfinds (g, "nodes");
-        gstack->graphs = Tfinds (g, "graphs");
-        gstack->edges = Tfinds (g, "edges");
-        gstack->gattr = Tfinds (g, "graphattr");
-        gstack->nattr = Tfinds (g, "nodeattr");
-        gstack->ecopy = gstack->eattr = Tfinds (g, "edgeattr");
-        return;
-    }
-    if (!name) {
-        gid = newgid++;
-        nameobj = Tinteger (gid);
-        Tinso (gdict, nameobj, nameobj);
-    } else
-        Tinso (gdict, (nameobj = Tstring (name)), Tinteger ((gid = newgid++)));
-    Tinsi (allgraphs, gid, (gstack->g = g = Ttable (10)));
-    Tinss (g, "name", nameobj);
-    Tinss (g, "nodes", (gstack->nodes = Ttable (10)));
-    Tinss (g, "graphs", (gstack->graphs = Ttable (10)));
-    Tinss (g, "edges", (gstack->edges = Ttable (10)));
-    Tinss (g, "graphattr", (gstack->gattr = Tcopy (gstack->next->gattr)));
-    Tinss (g, "nodeattr", (gstack->nattr = Tcopy (gstack->next->nattr)));
-    Tinss (
-        g, "edgeattr",
-        (gstack->ecopy = gstack->eattr = Tcopy (gstack->next->eattr))
-    );
-    for (
-        gframe = gstack->next; gframe->graphs != allgraphs;
-        gframe = gframe->next
-    ) {
-        if (Tfindi (gframe->graphs, gid))
-            break;
-        Tinsi (gframe->graphs, gid, g);
-    }
-    return;
-}
-
-Tobj D2Lpopgraph (void) {
-    graphframe_t *gframe;
-    Tobj g;
-
-    gframe = gstack, gstack = gstack->next;
-    g = gframe->g;
-    Mfree (gframe, M_BYTE2SIZE (sizeof (graphframe_t)));
-    return g;
-}
-
-Tobj D2Linsertnode (char *name) {
-    graphframe_t *gframe;
-    Tobj n, idobj, nameobj;
-    long nid, m;
-
-    if ((idobj = Tfinds (ndict, name))) {
-        nid = Tgetnumber (idobj), n = Tfindi (allnodes, nid);
-    } else {
-        m = Mpushmark ((nameobj = Tstring (name)));
-        Tinso (ndict, nameobj, Tinteger ((nid = newnid++)));
-        Mpopmark (m);
-        Tinsi (allnodes, nid, (n = Ttable (3)));
-        Tinso (n, nameo, nameobj);
-        Tinso (n, attro, Tcopy (gstack->nattr));
-        Tinso (n, edgeso, Ttable (2));
-    }
-    for (gframe = gstack; gframe->nodes != allnodes; gframe = gframe->next) {
-        if (Tfindi (gframe->nodes, nid))
-            break;
-        Tinsi (gframe->nodes, nid, n);
-    }
-    N = n;
-    return n;
-}
-
-void D2Linsertedge (Tobj tail, char *tport, Tobj head, char *hport) {
-    graphframe_t *gframe;
-    Tobj e;
-    long eid;
-
-    Tinsi (
-        alledges, (eid = neweid++),
-        (e = Ttable ((long) (3 + (tport ? 1 : 0) + (hport ? 1 : 0))))
-    );
-    Tinso (e, tailo, tail);
-    if (tport && tport[0])
-        Tinso (e, tporto, Tstring (tport));
-    Tinso (e, heado, head);
-    if (hport && hport[0])
-        Tinso (e, hporto, Tstring (hport));
-    Tinso (e, attro, Tcopy (gstack->ecopy));
-    Tinsi (Tfinds (head, "edges"), eid, e);
-    Tinsi (Tfinds (tail, "edges"), eid, e);
-    for (gframe = gstack; gframe->edges != alledges; gframe = gframe->next)
-        Tinsi (gframe->edges, eid, e);
-}
-
-void D2Lbeginedge (int type, Tobj obj, char *port) {
-    if (!(gstack->estack = Mallocate (sizeof (edgeframe_t))))
-        panic1 (POS, "D2Lbeginedge", "cannot allocate edge stack");
-    gstack->estack->next = NULL;
-    gstack->estack->type = type;
-    gstack->estack->obj = obj;
-    gstack->estack->port = strdup (port);
-    gstack->emark = Mpushmark ((gstack->ecopy = Tcopy (gstack->eattr)));
-}
-
-void D2Lmidedge (int type, Tobj obj, char *port) {
-    edgeframe_t *eframe;
-
-    if (!(eframe = Mallocate (sizeof (edgeframe_t))))
-        panic1 (POS, "D2Lmidedge", "cannot allocate edge stack");
-    eframe->next = gstack->estack, gstack->estack = eframe;
-    gstack->estack->type = type;
-    gstack->estack->obj = obj;
-    gstack->estack->port = strdup (port);
-}
-
-void D2Lendedge (void) {
-    edgeframe_t *eframe, *hframe, *tframe;
-    Tobj tnodes, hnodes;
-    Tkvindex_t tkvi, hkvi;
-
-    for (eframe = gstack->estack; eframe->next; eframe = tframe) {
-        hframe = eframe, tframe = eframe->next;
-        if (hframe->type == NODE && tframe->type == NODE) {
-            D2Linsertedge (
-                tframe->obj, tframe->port, hframe->obj, hframe->port
-            );
-        } else if (hframe->type == NODE && tframe->type == GRAPH) {
-            tnodes = Tfinds (tframe->obj, "nodes");
-            for (Tgetfirst (tnodes, &tkvi); tkvi.kvp; Tgetnext (&tkvi))
-                D2Linsertedge (tkvi.kvp->vo, NULL, hframe->obj, hframe->port);
-        } else if (eframe->type == GRAPH && eframe->next->type == NODE) {
-            hnodes = Tfinds (hframe->obj, "nodes");
-            for (Tgetfirst (hnodes, &hkvi); hkvi.kvp; Tgetnext (&hkvi))
-                D2Linsertedge (tframe->obj, tframe->port, hkvi.kvp->vo, NULL);
-        } else {
-            tnodes = Tfinds (tframe->obj, "nodes");
-            hnodes = Tfinds (hframe->obj, "nodes");
-            for (Tgetfirst (tnodes, &tkvi); tkvi.kvp; Tgetnext (&tkvi))
-                for (Tgetfirst (hnodes, &hkvi); hkvi.kvp; Tgetnext (&hkvi))
-                    D2Linsertedge (tkvi.kvp->vo, NULL, hkvi.kvp->vo, NULL);
-        }
-        free (eframe->port);
-        Mfree (eframe, M_BYTE2SIZE (sizeof (edgeframe_t)));
-    }
-    free (eframe->port);
-    Mfree (eframe, M_BYTE2SIZE (sizeof (edgeframe_t)));
-    Mpopmark (gstack->emark);
-    gstack->estack = NULL;
-}
-
-void D2Lsetattr (char *name, char *value) {
-    if (inattrstmt) {
-        switch (attrclass) {
-        case NODE: Tinss (gstack->nattr, name, Tstring (value)); break;
-        case EDGE: Tinss (gstack->eattr, name, Tstring (value)); break;
-        case GRAPH: Tinss (gstack->gattr, name, Tstring (value)); break;
-        }
-        return;
-    }
-    switch (attrclass) {
-    case NODE: Tinss (Tfinds (N, "attr"), name, Tstring (value)); break;
-    case EDGE: Tinss (gstack->ecopy, name, Tstring (value)); break;
-    /* a subgraph cannot have optional attrs? */
-    case GRAPH: Tinss (gstack->gattr, name, Tstring (value)); break;
-    }
-}
diff --git a/cmd/lefty/dot2l/dot2l.h b/cmd/lefty/dot2l/dot2l.h
deleted file mode 100644 (file)
index 37645bc..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-#define SMALLBUF 128
-
-int yyparse(void);
-int yylex(void);
-
-typedef struct edgeframe_t {
-    struct edgeframe_t *next;
-    int type;
-    void *obj;
-    char *port;
-} edgeframe_t;
-
-typedef struct graphframe_t {
-    struct graphframe_t *next;
-    Tobj g, graphs, nodes, edges;
-    Tobj gattr, nattr, eattr, ecopy;
-    long emark;
-    struct edgeframe_t *estack;
-} graphframe_t;
-
-typedef enum {
-    NODE, EDGE, GRAPH
-} objtype_t;
-
-extern char *gtype, *etype;
-extern int yaccdone;
-extern int attrclass;
-extern int inattrstmt;
-
-#ifndef TRUE
-#define FALSE 0
-#define TRUE 1
-#endif
-
-Tobj D2Lparsegraphlabel (Tobj, Tobj);
-Tobj D2Lreadgraph (int, Tobj);
-void D2Lwritegraph (int, Tobj, int);
-void D2Lbegin (char *);
-void D2Lend (void);
-void D2Labort (void);
-void D2Lpushgraph (char *);
-Tobj D2Lpopgraph (void);
-Tobj D2Linsertnode (char *);
-void D2Linsertedge (Tobj, char *, Tobj, char *);
-void D2Lbeginedge (int, Tobj, char *);
-void D2Lmidedge (int, Tobj, char *);
-void D2Lendedge (void);
-void D2Lsetattr (char *, char *);
diff --git a/cmd/lefty/dot2l/dotlex.c b/cmd/lefty/dot2l/dotlex.c
deleted file mode 100644 (file)
index ceddbd7..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* the graph lexer */
-
-typedef void *Tobj;
-#include "common.h"
-#include "dotparse.h"
-#include "dot2l.h"
-#include "leftyio.h"
-#include "triefa.c"
-#include <stdbool.h>
-#include <string.h>
-
-static int syntax_errors;
-static int lexer_fd;
-#define LEXBUFSIZ 10240
-static char *lexbuf, *lexptr;
-static int lexsiz;
-static int in_comment;
-static int comment_start;
-int line_number;
-
-static char *lex_gets (int);
-static int lex_token (char *);
-static void error_context (void);
-static char *skip_wscomments (char *);
-static char *scan_token (char *);
-static char *scan_num (char *);
-static char *quoted_string (char *);
-static char *html_string (char *);
-
-int lex_begin (int ioi) {
-    lexer_fd = ioi;
-    lexptr = NULL;
-    if (!(lexbuf = malloc (LEXBUFSIZ))) {
-        fprintf (stderr, "cannot allocate buffer\n");
-        return -1;
-    }
-    lexsiz = LEXBUFSIZ;
-    return 0;
-}
-
-int yylex (void) {
-    int token;
-    char *p;
-
-    /* if the parser has accepted a graph, reset and return EOF */
-    if (yaccdone) {
-        yaccdone = FALSE;
-        return EOF;
-    }
-
-    /* get a nonempty lex buffer */
-    do {
-        if ((lexptr == NULL) || strcmp(lexptr, "") == 0)
-            if ((lexptr = lex_gets (0)) == NULL) {
-                if (in_comment)
-                    fprintf (
-                        stderr,
-                        "warning, nonterminated comment in line %d\n",
-                        comment_start
-                    );
-                return EOF;
-            }
-        lexptr = skip_wscomments (lexptr);
-    } while (strcmp(lexptr, "") == 0);
-
-    /* scan quoted strings */
-    if (lexptr[0] == '\"') {
-        lexptr = quoted_string (lexptr);
-        yylval.s = strdup (lexbuf);
-        return T_id;
-    }
-
-    /* scan html strings */
-    if (lexptr[0] == '<') {
-        lexptr = html_string (lexptr);
-        yylval.s = strdup (lexbuf);
-        return T_id;
-    }
-
-    /* scan edge operator */
-    if (etype && (strncmp (lexptr, etype, strlen (etype)) == 0)) {
-        lexptr += strlen (etype);
-        return T_edgeop;
-    }
-
-    /* scan numbers */
-    if ((p = scan_num (lexptr))) {
-        lexptr = p;
-        yylval.s =  strdup (lexbuf);
-        return T_id;
-    }
-    else {
-        if (ispunct (lexptr[0]) && (lexptr[0] != '_'))
-            return *lexptr++;
-        else
-            lexptr = scan_token (lexptr);
-    }
-
-    /* scan other tokens */
-    token = lex_token (lexbuf);
-    if (token == -1) {
-        yylval.s = strdup (lexbuf);
-        token = T_id;
-    }
-    return token;
-}
-
-static void yyerror_text(const char *fmt, const char *s) {
-    if (syntax_errors++)
-        return;
-    fprintf (stderr, "graph parser: ");
-    fprintf (stderr, fmt, s);
-    fprintf (stderr, " near line %d\n", line_number);
-    error_context ();
-}
-
-void yyerror(const char *message) {
-  yyerror_text(message, "");
-}
-
-static char *lex_gets (int curlen) {
-    char *clp;
-    int len;
-
-    do {
-        /* off by one so we can back up in LineBuf */
-        if (IOreadline (
-            lexer_fd, lexbuf + curlen + 1, lexsiz - curlen - 1
-        ) == -1)
-            break;
-        clp = lexbuf + curlen + 1;
-        len = strlen (clp);
-        clp[len++] = '\n';
-        clp[len] = 0;
-
-        if (clp == lexbuf + 1 && clp[0] == '#') {
-            /* comment line or cpp line sync */
-            if (sscanf (clp+1, "%d", &line_number) == 0)
-                line_number++;
-            len = 0;
-            clp[len] = 0;
-            continue;
-        }
-
-        line_number++;
-        if ((len = strlen (clp)) > 1) {
-            if (clp[len - 2] == '\\') {
-                len = len - 2;
-                clp[len] = '\0';
-            }
-        }
-        curlen += len;
-        if (lexsiz - curlen - 1 < 1024) {
-            if (!(lexbuf = realloc (lexbuf, lexsiz * 2))) {
-                fprintf (stderr, "cannot grow buffer\n");
-                return NULL;
-            }
-            lexsiz *= 2;
-        }
-    } while (clp[len - 1] != '\n');
-
-    if (curlen > 0)
-        return lexbuf + 1;
-    else
-        return NULL;
-}
-
-static int lex_token (char *p) {
-    TFA_Init ();
-    while (*p)
-        TFA_Advance (*p++);
-    return
-        TFA_Definition ();
-}
-
-static void error_context (void) {
-    char *p, *q;
-
-    if (lexptr == NULL)
-        return;
-    fprintf (stderr, "context: ");
-    for (p = lexptr - 1; (p > lexbuf) && !isspace(*p); p--)
-        ;
-    for (q = lexbuf; q < p; q++)
-        fputc (*q, stderr);
-    fputs (" >>> ", stderr);
-    for (; q < lexptr; q++)
-        fputc (*q, stderr);
-    fputs (" <<< ", stderr);
-    fputs (lexptr, stderr);
-}
-
-/* i wrote this and it still frightens me */
-/* skip white space and comments in p */
-static char *skip_wscomments (char *p) {
-    do {
-        while (isspace (*p))
-            p++;
-        while (in_comment && p[0]) {
-            while (p[0] && (p[0] != '*'))
-                p++;
-            if (p[0]) {
-                if (p[1] == '/') {
-                    in_comment = FALSE;
-                    p += 2;
-                    break;
-                } else
-                    p++;
-            }
-        }
-        if (p[0] == '/') {
-            if (p[1] == '/')
-                while (*p)
-                    p++;    /* skip to end of line */
-            else {
-                if (p[1] == '*') {
-                    in_comment = TRUE;
-                    comment_start = line_number;
-                    p += 2;
-                    continue;
-                }
-                else
-                    break;    /* return a slash */
-            }
-        } else {
-            if (!isspace (*p))
-                break;
-        }
-    } while (p[0]);
-    return p;
-}
-
-/* scan an unquoted token and return the position after its terminator */
-static char *scan_token (char *p) {
-    char *q;
-
-    q = lexbuf;
-    if (!p || strcmp(p, "") == 0)
-        return NULL;
-    while (isalnum (*p) || (*p == '_') || (!isascii (*p)))
-        *q++ = *p++;
-    *q = '\0';
-    return p;
-}
-
-static char *scan_num (char *p) {
-    char *q, *z;
-    bool saw_rp = false;
-    bool saw_digit = false;
-
-    z = p;
-    q = lexbuf;
-    if (*z == '-')
-        *q++ = *z++;
-    if (*z == '.') {
-        saw_rp = true;
-        *q++ = *z++;
-    }
-    while (isdigit (*z)) {
-        saw_digit = true;
-        *q++ = *z++;
-    }
-    if (*z == '.' && !saw_rp) {
-        *q++ = *z++;
-        while (isdigit (*z)) {
-            saw_digit = true;
-            *q++ = *z++;
-        }
-    }
-    *q = '\0';
-    if (saw_digit && *z && (isalpha (*z)))
-        yyerror_text("badly formed number %s", lexbuf);
-
-    if (!saw_digit)
-        z = NULL;
-    return z;
-}
-
-/* scan a quoted string and return the position after its terminator */
-static char *quoted_string (char *p) {
-    char quote, *q;
-
-    quote = *p++;
-    q = lexbuf;
-    while ((*p) && (*p != quote)) {
-        if (*p == '\\') {
-            if (*(p+1) == quote)
-                p++;
-            else {
-                if (*(p+1) == '\\')
-                    *q++ = *p++;
-            }
-        }
-        *q++ = *p++;
-    }
-    if (strcmp(p, "") == 0)
-        yyerror("string ran past end of line");
-    else
-        p++;
-    *q = 0;
-    return p;
-}
-
-/* scan a html string and return the position after its terminator */
-static char *html_string (char *p) {
-    char *q, *pbuf;
-    int bal;
-
-    p++;
-    bal = 1;
-    q = lexbuf;
-    *q++ = '>';
-    while (*p && *p != '<' && *p != '>')
-        p++;
-    for (;;) {
-        while (*p) {
-            if (*p == '<')
-                bal++;
-            else if (*p == '>') {
-                bal--;
-                if (bal == 0) {
-                    *q++ = '<';
-                    *q = 0;
-                    return p + 1;
-                }
-            }
-            *q++ = *p++;
-        }
-        pbuf = lexbuf;
-        if ((lexptr = lex_gets (p - lexbuf - 1)) == NULL) {
-            fprintf (
-                stderr,
-                "warning, unterminated html label in line %d\n",
-                line_number
-            );
-            return NULL;
-        }
-        q += (lexbuf - pbuf);
-        p += (lexbuf - pbuf);
-    }
-    return NULL;
-}
diff --git a/cmd/lefty/dot2l/dotparse.y b/cmd/lefty/dot2l/dotparse.y
deleted file mode 100644 (file)
index cd2ad74..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-%{
-#include <stdio.h>
-
-typedef void *Tobj;
-
-#include "config.h"
-#include "dot2l.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-static char portstr[SMALLBUF];
-
-extern void yyerror(const char *message);
-%}
-
-%union {
-    long i;
-    char *s;
-    void *o;
-}
-
-%token <i> T_graph T_digraph T_strict
-%token <i> T_node T_edge T_edgeop
-%token <s> T_id
-%type <o> node_name node_id subg_stmt
-%type <s> optgraphname
-%left <i> T_subgraph /* to eliminate subgraph hdr shift/reduce conflict */
-%left '{'
-%%
-
-file: graph_type optgraphname
-    { D2Lbegin ($2); free ($2); }
-  '{' stmt_list '}'
-    { D2Lend (); }
-| error
-    { D2Labort (); }
-| /* empty*/
-    { D2Labort (); }
-;
-
-optgraphname:   T_id {$$=$1;} | /* empty */ {$$=0;} ;
-
-graph_type: T_graph /* safe to change graph type/name before contents appear */
-    { gtype = "graph"; etype = "--"; }
-| T_strict T_graph
-    { gtype = "strict graph"; etype = "--"; }
-| T_digraph
-    { gtype = "digraph"; etype = "->"; }
-| T_strict T_digraph
-    { gtype = "strict digraph"; etype = "->"; }
-;
-
-stmt_list: stmt_list1
-| /* empty */
-;
-
-stmt_list1: stmt
-| stmt_list1 stmt
-;
-
-stmt: stmt1
-| stmt1 ';'
-;
-
-stmt1: node_stmt /* create nodes and set attributes */
-| edge_stmt /* create edges and set attributes */
-| attr_stmt /* reset value of attributes */
-| subg_stmt {}
-;
-
-node_stmt: node_id { attrclass = NODE; portstr[0] = '\000'; }
-    opt_attr_list { attrclass = GRAPH; }
-;
-
-node_id: node_name node_port
-    { $$ = $1; }
-;
-
-node_name: T_id
-    { $$ = D2Linsertnode ($1); free ($1); }
-;
-
-edge_stmt: node_id
-    { D2Lbeginedge (NODE, $1, portstr); portstr[0] = '\000'; }
-  edgeRHS
-    { attrclass = EDGE; }
-  opt_attr_list
-    { D2Lendedge (); attrclass = GRAPH; }
-| subg_stmt
-    { D2Lbeginedge (GRAPH, $1, ""); }
-  edgeRHS
-    { attrclass = EDGE; }
-  opt_attr_list
-    { D2Lendedge (); attrclass = GRAPH; }
-;
-
-edgeRHS: T_edgeop node_id
-    { D2Lmidedge (NODE, $2, portstr); portstr[0] = '\000'; }
-| T_edgeop node_id
-    { D2Lmidedge (NODE, $2, portstr); portstr[0] = '\000'; } edgeRHS
-| T_edgeop subg_stmt
-    { D2Lmidedge (GRAPH, $2, ""); portstr[0] = '\000'; }
-| T_edgeop subg_stmt
-    { D2Lmidedge (GRAPH, $2, ""); portstr[0] = '\000'; } edgeRHS
-;
-
-node_port: /* empty */
-| port_location
-| port_angle
-| port_angle port_location
-| port_location port_angle
-;
-
-port_location: ':' T_id
-    {
-        strcat (portstr, $2); free ($2);
-    }
-| ':' T_id ':' T_id 
-    {
-        strcat (portstr, $2);
-        strcat (portstr, ":"); strcat (portstr, $4);
-        free ($2), free ($4);
-    }
-;
-
-port_angle: '@' T_id
-    {
-        strcat (portstr, "@"); strcat (portstr, $2); free ($2);
-    }
-;
-
-attr_stmt: attr_class
-    { inattrstmt = TRUE; }
-  attr_list
-    { attrclass = GRAPH; inattrstmt = FALSE; }
-| attr_set
-    { attrclass = GRAPH; }
-;
-
-attr_class: T_graph
-    { attrclass = GRAPH; }
-| T_node
-    { attrclass = NODE; }
-| T_edge
-    { attrclass = EDGE; }
-;
-
-opt_attr_list: rec_attr_list
-;
-
-rec_attr_list: rec_attr_list attr_list
-| /* empty */
-;
-
-attr_list: '[' inside_attr_list ']'
-;
-
-inside_attr_list: attr_set optcomma inside_attr_list
-| /* empty */
-;
-
-attr_set: T_id '=' T_id
-    { D2Lsetattr ($1, $3); free ($1); free ($3); }
-;
-
-optcomma: /* empty */
-| ','
-;
-
-subg_stmt: subg_hdr '{' stmt_list '}' %prec '{'
-    { $$ = D2Lpopgraph (); }
-| '{' { D2Lpushgraph (NULL); } stmt_list '}'
-    { $$ = D2Lpopgraph (); }
-| subg_hdr %prec T_subgraph
-    { $$ = D2Lpopgraph (); }
-;
-
-subg_hdr: T_subgraph T_id
-    { D2Lpushgraph ($2); free ($2); }
-;
diff --git a/cmd/lefty/dot2l/dottrie.c b/cmd/lefty/dot2l/dottrie.c
deleted file mode 100644 (file)
index 0005ad5..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#include "common.h"
-#include "dotparse.h"
-#include "triefa.h"
-
-TrieState TrieStateTbl[34] = {
-    { -1,          0,  0x42058 },
-    { -1,          5,    0x100 },
-    { -1,          6,     0x40 },
-    { -1,          7,  0x20000 },
-    { -1,          8,      0x1 },
-    { -1,          9,   0x8000 },
-    { -1,         10,     0x80 },
-    { T_digraph,  11,      0x0 },
-    { -1,         11,      0x8 },
-    { -1,         12,     0x40 },
-    { -1,         13,     0x10 },
-    { T_edge,     14,      0x0 },
-    { -1,         14,  0x20000 },
-    { -1,         15,      0x1 },
-    { -1,         16,   0x8000 },
-    { -1,         17,     0x80 },
-    { T_graph,    18,      0x0 },
-    { -1,         18,   0x4000 },
-    { -1,         19,      0x8 },
-    { -1,         20,     0x10 },
-    { T_node,     21,      0x0 },
-    { -1,         21, 0x180000 },
-    { -1,         23,  0x20000 },
-    { -1,         24,    0x100 },
-    { -1,         25,      0x4 },
-    { -1,         26,  0x80000 },
-    { T_strict,   27,      0x0 },
-    { -1,         27,      0x2 },
-    { -1,         28,     0x40 },
-    { -1,         29,  0x20000 },
-    { -1,         30,      0x1 },
-    { -1,         31,   0x8000 },
-    { -1,         32,     0x80 },
-    { T_subgraph, 33,      0x0 },
-};
-TrieTrans TrieTransTbl[33] = {
-    /* State   0 */  { 's',  21 }, { 'e',   8 }, { 'g',  12 },
-                     { 'n',  17 }, { 'd',   1 },
-    /* State   1 */  { 'i',   2 },
-    /* State   2 */  { 'g',   3 },
-    /* State   3 */  { 'r',   4 },
-    /* State   4 */  { 'a',   5 },
-    /* State   5 */  { 'p',   6 },
-    /* State   6 */  { 'h',   7 },
-    /* State   8 */  { 'd',   9 },
-    /* State   9 */  { 'g',  10 },
-    /* State  10 */  { 'e',  11 },
-    /* State  12 */  { 'r',  13 },
-    /* State  13 */  { 'a',  14 },
-    /* State  14 */  { 'p',  15 },
-    /* State  15 */  { 'h',  16 },
-    /* State  17 */  { 'o',  18 },
-    /* State  18 */  { 'd',  19 },
-    /* State  19 */  { 'e',  20 },
-    /* State  21 */  { 't',  22 }, { 'u',  27 },
-    /* State  22 */  { 'r',  23 },
-    /* State  23 */  { 'i',  24 },
-    /* State  24 */  { 'c',  25 },
-    /* State  25 */  { 't',  26 },
-    /* State  27 */  { 'b',  28 },
-    /* State  28 */  { 'g',  29 },
-    /* State  29 */  { 'r',  30 },
-    /* State  30 */  { 'a',  31 },
-    /* State  31 */  { 'p',  32 },
-    /* State  32 */  { 'h',  33 },
-};
diff --git a/cmd/lefty/dot2l/triefa.c b/cmd/lefty/dot2l/triefa.c
deleted file mode 100644 (file)
index cd57216..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/*  File - TrieFA.ins.c
-    This file contains code to be included in the scanner file using a
-    generated trie-based FA.
-*/
-
-#include "triefa.h"
-
-#ifdef UNDERLINE
-static long CharMask[28] = {
-    0x0000001, 0x0000000, 0x0000004, 0x0000008,
-    0x0000010, 0x0000020, 0x0000040, 0x0000080,
-    0x0000100, 0x0000200, 0x0000400, 0x0000800,
-    0x0001000, 0x0002000, 0x0004000, 0x0008000,
-    0x0010000, 0x0020000, 0x0040000, 0x0080000,
-    0x0100000, 0x0200000, 0x0400000, 0x0800000,
-    0x1000000, 0x2000000, 0x4000000, 0x8000000,
-};
-
-#define IN_MASK_RANGE(C) (islower (C) || ((C) == '_'))
-#define MASK_INDEX(C)    ((C) - '_')
-
-#else
-static long CharMask[26] = {
-    0x0000001, 0x0000002, 0x0000004, 0x0000008,
-    0x0000010, 0x0000020, 0x0000040, 0x0000080,
-    0x0000100, 0x0000200, 0x0000400, 0x0000800,
-    0x0001000, 0x0002000, 0x0004000, 0x0008000,
-    0x0010000, 0x0020000, 0x0040000, 0x0080000,
-    0x0100000, 0x0200000, 0x0400000, 0x0800000,
-    0x1000000, 0x2000000
-};
-
-#define IN_MASK_RANGE(C) islower (C)
-#define MASK_INDEX(C)    ((C) - 'a')
-
-#endif
-
-static short TFA_State;
-
-/*  TFA_Init:
-    Initialize the trie FA.
-*/
-#define TFA_Init() TFA_State = 0
-
-/*  TFA_Advance:
-    Advance to the next state (or -1) on the lowercase letter c.
-    This should be an inline routine, but the C++ implementation
-    isn't advanced enough so we use a macro.
-*/
-#define TFA_Advance(C) { \
-    char c = C; \
-    if (TFA_State >= 0) { \
-        if (isupper (c)) \
-            c = tolower (c); \
-        else if (! IN_MASK_RANGE (c)) { \
-            TFA_State = -1; \
-            goto TFA_done; \
-        } \
-        if (TrieStateTbl[TFA_State].mask & CharMask[MASK_INDEX (c)]) { \
-            short i = TrieStateTbl[TFA_State].trans_base; \
-            while (TrieTransTbl[i].c != c) \
-                i++; \
-            TFA_State = TrieTransTbl[i].next_state; \
-        } \
-        else \
-            TFA_State = -1; \
-    } \
-TFA_done:; \
-} /* end of TFA_Advance. */
-
-/*  TFA_Definition:
-    Return the definition (if any) associated with the current state.
-*/
-#define TFA_Definition() \
-    ((TFA_State < 0) ? -1 : TrieStateTbl[TFA_State].def)
diff --git a/cmd/lefty/dot2l/triefa.h b/cmd/lefty/dot2l/triefa.h
deleted file mode 100644 (file)
index 5c5b775..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/*  File - TrieFA.h
-    The data types for the generated trie-baseed finite automata.
-*/
-
-struct TrieState {  /* An entry in the FA state table */
-    short def;         /* If this state is an accepting state then */
-                       /* this is the definition, otherwise -1.    */
-    short trans_base;  /* The base index into the transition table.*/
-    long  mask;        /* The transition mask.                     */
-};
-
-struct TrieTrans {  /* An entry in the FA transition table. */
-    short c;           /* The transition character (lowercase). */
-    short next_state;  /* The next state.                       */
-};
-
-typedef struct TrieState TrieState;
-typedef struct TrieTrans TrieTrans;
-
-extern TrieState TrieStateTbl[];
-extern TrieTrans TrieTransTbl[];
diff --git a/cmd/lefty/examples/box.lefty b/cmd/lefty/examples/box.lefty
deleted file mode 100644 (file)
index 5c13ac9..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-load ('def.lefty');
-definit ();
-#
-# initialize window data
-#
-canvas = defcanvas;
-wrect = [0 = ['x' = 0; 'y' = 0;]; 1 = ['x' = 400; 'y' = 500;];];
-setwidgetattr (canvas, ['window' = wrect;]);
-#
-# data structures
-#
-objarray = [];
-objnum = 0;
-#
-# misc functions
-#
-min = function (a, b) {
-    if (a <= b)
-        return a;
-    return b;
-};
-max = function (a, b) {
-    if (b <= a)
-        return a;
-    return b;
-};
-rectof = function (p1, p2) {
-    return [
-        0 = ['x' = min (p1.x, p2.x); 'y' = min (p1.y, p2.y);];
-        1 = ['x' = max (p1.x, p2.x); 'y' = max (p1.y, p2.y);];
-    ];
-};
-pointadd = function (p1, p2) {
-    return ['x' = p2.x + p1.x; 'y' = p2.y + p1.y;];
-};
-pointsub = function (p1, p2) {
-    return ['x' = p2.x - p1.x; 'y' = p2.y - p1.y;];
-};
-#
-# rendering functions
-#
-drawbox = function (obj, color) {
-    box (canvas, obj, obj.rect, ['color' = color;]);
-};
-redrawboxes = function () {
-    local i;
-    clear (canvas);
-    for (i = 0; i < objnum; i = i + 1)
-        drawbox (objarray[i], 1);
-};
-redraw = function (canvas) {
-    redrawboxes ();
-};
-#
-# editing functions
-#
-new = function (rect) {
-    objarray[objnum] = [
-        'rect' = rect;
-        'id' = objnum;
-    ];
-    objnum = objnum + 1;
-    return objarray[objnum - 1];
-};
-reshape = function (obj, rect) {
-    obj.rect = rect;
-    return obj;
-};
-move = function (obj, p) {
-    obj.rect[0] = pointadd (obj.rect[0], p);
-    obj.rect[1] = pointadd (obj.rect[1], p);
-    return obj;
-};
-delete = function (obj) {
-    if (obj.id ~= objnum - 1) {
-        objarray[obj.id] = objarray[objnum - 1];
-        objarray[obj.id].id = obj.id;
-    }
-    remove (objnum - 1, objarray);
-    objnum = objnum - 1;
-};
-#
-# user interface functions
-#
-# left mouse button creates new box
-# middle button moves a box
-# right button deletes a box
-#
-leftdown = function (data) {
-    if (data.obj ~= null)
-        return;
-    leftbox = new (rectof (data.pos, data.pos));
-    drawbox (leftbox, 1);
-    setgfxattr (canvas, ['mode' = 'xor';]);
-};
-leftmove = function (data) {
-    if (~leftbox)
-        return;
-    drawbox (leftbox, 1);
-    clearpick (canvas, leftbox);
-    reshape (leftbox, rectof (data.ppos, data.pos));
-    drawbox (leftbox, 1);
-};
-leftup = function (data) {
-    if (~leftbox)
-        return;
-    drawbox (leftbox, 1);
-    clearpick (canvas, leftbox);
-    reshape (leftbox, rectof (data.ppos, data.pos));
-    setgfxattr (canvas, ['mode' = 'src';]);
-    drawbox (leftbox, 1);
-    remove ('leftbox');
-};
-middledown = function (data) {
-    if (data.obj == null)
-        return;
-    middlebox = data.obj;
-    middlepos = data.pos;
-    setgfxattr (canvas, ['mode' = 'xor';]);
-};
-middlemove = function (data) {
-    if (~middlebox)
-        return;
-    drawbox (middlebox, 1);
-    clearpick (canvas, middlebox);
-    move (middlebox, pointsub (middlepos, data.pos));
-    middlepos = data.pos;
-    drawbox (middlebox, 1);
-};
-middleup = function (data) {
-    if (~middlebox)
-        return;
-    drawbox (middlebox, 1);
-    clearpick (canvas, middlebox);
-    move (middlebox, pointsub (middlepos, data.pos));
-    setgfxattr (canvas, ['mode' = 'src';]);
-    drawbox (middlebox, 1);
-    remove ('middlepos');
-    remove ('middlebox');
-};
-rightup = function (data) {
-    if (data.pobj == null)
-        return;
-    drawbox (data.obj, 0);
-    clearpick (canvas, data.obj);
-    delete (data.obj);
-};
-dops = function () {
-    local s;
-
-    s = ['x' = 8 * 300; 'y' = 10.5 * 300;];
-    canvas = createwidget (-1, ['type' = 'ps'; 'size' = s;]);
-    setwidgetattr (canvas, ['window' = wrect;]);
-    redraw (canvas);
-    destroywidget (canvas);
-    canvas=defcanvas;
-};
diff --git a/cmd/lefty/examples/def.lefty b/cmd/lefty/examples/def.lefty
deleted file mode 100644 (file)
index 41cee96..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-definit = function () {
-    defview = createwidget (-1, [
-        'type' = 'view';
-        'name' = 'graphics view';
-        'origin' = ['x' = 1; 'y' = 1;];
-        'size' = ['x' = 400; 'y' = 500;];
-    ]);
-    defscroll = createwidget (defview, ['type' = 'scroll';]);
-    defcanvas = createwidget (defscroll, [
-        'type' = 'canvas';
-        'origin' = ['x' = 1; 'y' = 1;];
-        'size' = ['x' = 400; 'y' = 500;];
-        'borderwidth' = 1;
-    ]);
-};
diff --git a/cmd/lefty/examples/fractal.lefty b/cmd/lefty/examples/fractal.lefty
deleted file mode 100644 (file)
index 75de5d9..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-load ('def.lefty');
-definit ();
-#
-# initialize window data
-#
-canvas = defcanvas;
-wrect = [0 = ['x' = 0; 'y' = 0;]; 1 = ['x' = 400; 'y' = 500;];];
-setwidgetattr (canvas, ['window' = wrect;]);
-
-sq = function (x) {
-    return x * x;
-};
-
-# data structures
-#
-length = 300;
-center = ['x' = 200; 'y' = 250;];
-radius = 2 * length / sqrt (12);
-fractalangle = 0;
-maxlevel = 2;
-
-# drawing functions
-#
-# draw a Koch curve (a ``snowflake'' fractal)
-#
-# start with a triangle and keep replacing edges
-# with the construct: _/\_
-# until the recursion level reaches 'maxlevel'
-#
-fractal = function (level, length, angle) {
-    local nlength, newpenpos;
-
-    if (level >= maxlevel) {
-        newpenpos.x = penpos.x + length * cos (angle);
-        newpenpos.y = penpos.y + length * sin (angle);
-        line (canvas, null, penpos, newpenpos, ['color' = 1;]);
-        penpos = newpenpos;
-        return;
-    }
-    nlength = length / 3;
-    fractal (level + 1, nlength, angle);
-    fractal (level + 1, nlength, angle + 60);
-    fractal (level + 1, nlength, angle - 60);
-    fractal (level + 1, nlength, angle);
-};
-drawfractal = function () {
-    clear (canvas);
-    setpick (canvas, center, wrect);
-    penpos = [
-        'x' = center.x + cos (fractalangle + 210) * radius;
-        'y' = center.y + sin (fractalangle + 210) * radius;
-    ];
-    fractal (0, length, fractalangle +  60);
-    fractal (0, length, fractalangle -  60);
-    fractal (0, length, fractalangle - 180);
-    remove ('penpos');
-};
-
-# editing functions
-#
-# transform the fractal.
-#
-# map point 'prevpoint' to point 'currpoint'
-# with respect to the center of the fractal.
-#
-transformfractal = function (prevpoint, currpoint) {
-    local prevtan, currtan, prevradius, currradius;
-
-    prevtan = atan (prevpoint.y - center.y, prevpoint.x - center.x);
-    currtan = atan (currpoint.y - center.y, currpoint.x - center.x);
-    fractalangle = fractalangle + (currtan - prevtan);
-    prevradius = sqrt (
-        sq (prevpoint.y - center.y) + sq (prevpoint.x - center.x)
-    );
-    currradius = sqrt (
-        sq (currpoint.y - center.y) + sq (currpoint.x - center.x)
-    );
-    radius = radius / prevradius * currradius;
-    length = radius / 2 * sqrt (12);
-};
-
-# user interface functions
-#
-# bind changes to the fractal to user actions
-#
-leftup = function (data) {
-    transformfractal (data.ppos, data.pos);
-    drawfractal ();
-};
-dops = function () {
-    local s;
-
-    s = ['x' = 8 * 300; 'y' = 10.5 * 300;];
-    canvas = createwidget (-1, ['type' = 'ps'; 'size' = s;]);
-    setwidgetattr (canvas, ['window' = wrect;]);
-    drawfractal ();
-    destroywidget (canvas);
-    canvas=defcanvas;
-};
-transformfractal (['x' = 0; 'y' = 0;], ['x' = 0; 'y' = 0;]);
-drawfractal ();
diff --git a/cmd/lefty/examples/fractal2.lefty b/cmd/lefty/examples/fractal2.lefty
deleted file mode 100644 (file)
index 420da94..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-#
-# data structures
-#
-length = 300;
-center = ['x' = 200; 'y' = 250;];
-radius = 2 * length / sqrt (12);
-fractalangle = 0;
-maxlevel = 2;
-sizes = [
-    'button' = [ 'x' = 100; 'y' = 40;  ];
-    'canvas' = [ 'x' = 400; 'y' = 500; ];
-    'view'   = [ 'x' = 400; 'y' = 600; ];
-];
-sq = function (x) {
-    return x * x;
-};
-#
-# create view and other widgets
-#
-init = function () {
-    view = createwidget (-1, [
-        'type' = 'view'; 'name' = 'fractal'; 'size' = sizes.view;
-    ]);
-
-    array1 = createwidget (view, [
-        'type' = 'array'; 'borderwidth' = 1; 'mode' = 'vertical';
-    ]);
-    widgets[array1].resize = resize;
-
-    array2 = createwidget (array1, [
-        'type' = 'array'; 'borderwidth' = 1; 'mode' = 'horizontal';
-    ]);
-    widgets[array2].resize = resize;
-
-    array3 = createwidget (array2, [
-        'type' = 'array'; 'borderwidth' = 1; 'mode' = 'vertical';
-    ]);
-    widgets[array3].resize = resize;
-
-    morebutton = createwidget (array3, [
-        'type' = 'button'; 'text' = 'more';
-    ]);
-    widgets[morebutton].pressed = pressed;
-    lessbutton = createwidget (array3, [
-        'type' = 'button'; 'text' = 'less';
-    ]);
-    widgets[lessbutton].pressed = pressed;
-    setwidgetattr (morebutton, ['size' = sizes.button;]);
-    setwidgetattr (lessbutton, ['size' = sizes.button;]);
-
-    atext = createwidget (array2, [
-        'type' = 'text'; 'mode' = 'oneline';
-    ]);
-    widgets[atext].oneline = oneline;
-    setwidgetattr (atext, [
-        'size' = ['x' = sizes.button.x; 'y' = sizes.button.y * 2;];
-    ]);
-
-    scroll = createwidget (array1, ['type' = 'scroll';]);
-    canvas = createwidget (scroll, ['type' = 'canvas';]);
-    wrect = [0 = ['x' = 0; 'y' = 0;]; 1 = sizes.canvas;];
-    setwidgetattr (canvas, ['window' = wrect; 'viewport' = wrect[1];]);
-};
-#
-# drawing functions
-#
-# draw a Koch curve (a ``snowflake'' fractal)
-#
-# start with a triangle and keep replacing edges
-# with the construct: _/\_
-# until the recursion level reaches 'maxlevel'
-#
-fractal = function (level, length, angle) {
-    local nlength, newpenpos;
-
-    if (level >= maxlevel) {
-        newpenpos.x = penpos.x + length * cos (angle);
-        newpenpos.y = penpos.y + length * sin (angle);
-        line (canvas, null, penpos, newpenpos, ['color' = 1;]);
-        penpos = newpenpos;
-        return;
-    }
-    nlength = length / 3;
-    fractal (level + 1, nlength, angle);
-    fractal (level + 1, nlength, angle + 60);
-    fractal (level + 1, nlength, angle - 60);
-    fractal (level + 1, nlength, angle);
-};
-redrawfractal = function () {
-    clear (canvas);
-    setpick (canvas, center, wrect);
-    penpos = [
-        'x' = center.x + cos (fractalangle + 210) * radius;
-        'y' = center.y + sin (fractalangle + 210) * radius;
-    ];
-    fractal (0, length, fractalangle +  60);
-    fractal (0, length, fractalangle -  60);
-    fractal (0, length, fractalangle - 180);
-    remove ('penpos');
-};
-#
-# editing functions
-#
-# transform the fractal.
-#
-# map point 'prevpoint' to point 'currpoint'
-# with respect to the center of the fractal.
-#
-transformfractal = function (prevpoint, currpoint) {
-    local prevtan, currtan, prevradius, currradius;
-
-    prevtan = atan (prevpoint.y - center.y, prevpoint.x - center.x);
-    currtan = atan (currpoint.y - center.y, currpoint.x - center.x);
-    fractalangle = fractalangle + (currtan - prevtan);
-    prevradius = sqrt (
-        sq (prevpoint.y - center.y) + sq (prevpoint.x - center.x)
-    );
-    currradius = sqrt (
-        sq (currpoint.y - center.y) + sq (currpoint.x - center.x)
-    );
-    radius = radius / prevradius * currradius;
-    length = radius / 2 * sqrt (12);
-};
-#
-# main actions
-#
-redraw = function (data) {
-    redrawfractal ();
-};
-changemaxlevel = function (dn) {
-    maxlevel = maxlevel + dn;
-    if (maxlevel < 0)
-        maxlevel = 0;
-    redrawfractal ();
-};
-resize = function (data) {
-    local ret;
-    if (data.widget == array1) {
-        ret = [
-            array2 = [
-                'x' = data.size.x;
-                'y' = sizes.button.y * 2;
-            ];
-            scroll = [
-                'x' = data.size.x;
-                'y' = data.size.y - sizes.button.y * 2;
-            ];
-        ];
-    } else if (data.widget == array2) {
-        ret = [
-            array3 = [
-                'x' = sizes.button.x;
-                'y' = 2 * sizes.button.y;
-            ];
-            atext = [
-                'x' = data.size.x - sizes.button.x;
-                'y' = 2 * sizes.button.y;
-            ];
-        ];
-    } else if (data.widget == array3) {
-        ret = [
-            morebutton = sizes.button;
-            lessbutton = sizes.button;
-        ];
-    }
-    return ret;
-};
-#
-# user interface functions
-#
-# bind changes to the fractal to user actions
-#
-leftup = function (data) {
-    transformfractal (data.ppos, data.pos);
-    redrawfractal ();
-};
-menu = [
-    0 = 'more';
-    1 = 'less';
-];
-domenu = function (i) {
-    local s;
-    s = menu[i];
-    if (s == 'more')
-        changemaxlevel (1);
-    else if (s == 'less')
-        changemaxlevel (-1);
-};
-rightdown = function (data) {
-    domenu (displaymenu (canvas, menu));
-};
-pressed = function (data) {
-    if (data.widget == morebutton)
-        changemaxlevel (1);
-    else if (data.widget == lessbutton)
-        changemaxlevel (-1);
-};
-oneline = function (data) {
-    local dn;
-    dn = ston (data.text);
-    if (dn > 0 | dn < 0)
-        changemaxlevel (dn - maxlevel);
-};
-#
-# postscript generation
-#
-dops = function () {
-    local r;
-
-    r = [0 = ['x' = 0; 'y' = 0;]; 1 = ['x' = 8 * 300; 'y' = 10.5 * 300;];];
-    canvas = opencanvas ('pscanvas', '', r);
-    setwidgetattr (canvas, ['window' = wrect;]);
-    redraw ();
-    closecanvas (canvas);
-    canvas=defcanvas;
-};
-init ();
-#txtview ('off');
diff --git a/cmd/lefty/examples/slides.lefty b/cmd/lefty/examples/slides.lefty
deleted file mode 100644 (file)
index 1c9b2fe..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-load ('def.lefty');
-definit ();
-#
-# initialize window data
-#
-canvas = defcanvas;
-wrect = [0 = ['x' = 0; 'y' = 0;]; 1 = ['x' = 800; 'y' = 1000;];];
-lmargin = 100;
-width = 800;
-height = 1000;
-setwidgetattr (canvas, ['window' = wrect;]);
-fonts = [
-    'timr' = [
-        14 = 'timr14';
-        18 = 'timr18';
-        24 = 'timr24';
-    ];
-    'courr' = [
-        14 = 'courr14';
-        18 = 'courr18';
-        24 = 'courr24';
-    ];
-];
-x2ps = [
-    'timr24' = 'Times-Roman';
-    'timr18' = 'Times-Roman';
-    'timr14' = 'Times-Roman';
-    'courr24' = 'Courier';
-    'courr18' = 'Courier';
-    'courr14' = 'Courier';
-];
-
-calc = function () {
-    local i, j, cpos, tsiz, dist, slidep;
-    tsiz = ['x' = 0; 'y' = 0;];
-    for (i = 0; slides[i]; i = i + 1) {
-        slidep = slides[i];
-        if (slidep.skip) {
-            tsiz.y = tsiz.y + slidep.skip;
-        } else {
-            for (j = 0; slidep.text[j]; j = j + 1) {
-                if (j > 0)
-                    tsiz.y = tsiz.y + 5;
-                if (~slidep.font)
-                    slidep.font = slides.font;
-                if (~slidep.size)
-                    slidep.size = slides.size;
-                if (~slidep.just)
-                    slidep.just = slides.just;
-                slidep.tsiz[j] = textsize (canvas, slidep.text[j],
-                        fonts[slidep.font][slidep.size], 0);
-                tsiz.y = tsiz.y + slidep.tsiz[j].y;
-            }
-        }
-    }
-    dist = (height - tsiz.y) / (i + 1);
-    cpos = ['x' = lmargin; 'y' = height - dist;];
-    for (i = 0; slides[i]; i = i + 1) {
-        slidep = slides[i];
-        if (slidep.skip) {
-            cpos.y = cpos.y - slidep.skip - dist;
-        } else {
-            for (j = 0; slidep.text[j]; j = j + 1) {
-                if (j > 0)
-                    cpos.y = cpos.y - 5;
-                if (slidep.just == 0)
-                    slidep.tpos[j].x = cpos.x;
-                else
-                    slidep.tpos[j].x = width / 2;
-                cpos.y = cpos.y - slidep.tsiz[j].y;
-                slidep.tpos[j].y = cpos.y;
-            }
-            cpos.y = cpos.y - dist;
-        }
-    }
-};
-redraw = function () {
-    local i, j, slidep;
-    for (i = 0; slides[i]; i = i + 1) {
-        slidep = slides[i];
-        if (~slidep.skip)
-            for (j = 0; slidep.text[j]; j = j + 1)
-                text (canvas, slidep, slidep.tpos[j], slidep.text[j],
-                        fonts[slidep.font][slidep.size], 0, slidep.just);
-    }
-};
-dops = function () {
-    local i, j, slidep, r;
-
-    r = [0 = ['x' = 0; 'y' = 0;]; 1 = ['x' = 8 * 300; 'y' = 10.5 * 300;];];
-    canvas = createwidget (-1, ['type' = 'ps'; 'origin' = r[0]; 'size' = r[1]
-;]);
-    setwidgetattr (canvas, ['window' = wrect;]);
-    for (i = 0; slides[i]; i = i + 1) {
-        slidep = slides[i];
-        if (~slidep.skip)
-            for (j = 0; slidep.text[j]; j = j + 1)
-                text (canvas, slidep, slidep.tpos[j], slidep.text[j],
-                        x2ps[fonts[slidep.font][slidep.size]],
-                        slidep.tsiz[j].y, slidep.just, 1);
-    }
-    destroywidget (canvas);
-    canvas=defcanvas;
-};
-doit = function () {
-    calc ();
-    redraw ();
-    dops ();
-};
diff --git a/cmd/lefty/examples/tree.lefty b/cmd/lefty/examples/tree.lefty
deleted file mode 100644 (file)
index 0af3f8c..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-load ('def.lefty');
-definit ();
-#
-# initialize window data
-#
-canvas = defcanvas;
-wrect = [0 = ['x' = -5; 'y' = 0;]; 1 = ['x' = 410; 'y' = 500;];];
-setwidgetattr (canvas, ['window' = wrect;]);
-#
-# data structures
-#
-nodearray = [];
-nodenum = 0;
-dist = ['x' = 40; 'y' = 40;];
-defsize = ['x' = 10; 'y' = 10;];
-fontname = 'fixed';
-fontsize = 18;
-tree = null;
-
-# drawing functions
-#
-boxnode = function (node) {
-    local center;
-    box (canvas, node, node.rect, ['color' = 0; 'fill' = 'on';]);
-    box (canvas, node, node.rect);
-    center = [
-        'x' = (node.rect[0].x + node.rect[1].x) / 2;
-        'y' = (node.rect[0].y + node.rect[1].y) / 2;
-    ];
-    if (node.name)
-        text (canvas, node, center, node.name, fontname, fontsize, 'cc');
-};
-circlenode = function (node) {
-    local center, radius;
-    center = [
-        'x' = (node.rect[0].x + node.rect[1].x) / 2;
-        'y' = (node.rect[0].y + node.rect[1].y) / 2;
-    ];
-    radius = [
-        'x' = center.x - node.rect[0].x;
-        'y' = center.y - node.rect[0].y;
-    ];
-    arc (canvas, node, center, radius, ['color' = 0; 'fill' = 'on';]);
-    arc (canvas, node, center, radius);
-    if (node.name)
-        text (canvas, node, center, node.name, fontname, fontsize, 'cc');
-};
-drawnode = boxnode;
-drawedge = function (node1, node2) {
-    line (canvas, null,
-            [
-                'x' = (node1.rect[1].x + node1.rect[0].x) / 2;
-                'y' = node1.rect[0].y;
-            ], [
-                'x' = (node2.rect[1].x + node2.rect[0].x) / 2;
-                'y' = node2.rect[1].y;
-            ]);
-};
-drawtree = function (node) {
-    local i;
-    for (i in nodearray)
-        drawnode (nodearray[i]);
-    drawtreerec (node);
-};
-drawtreerec = function (node) {
-    local i, n;
-    if ((n = tablesize (node.ch)) > 0) {
-        for (i = 0; i < n; i = i + 1) {
-            drawedge (node, node.ch[i]);
-            drawtreerec (node.ch[i]);
-        }
-    }
-};
-redraw = function (c) {
-    if (tree)
-        drawtree (tree);
-};
-
-# layout functions
-#
-complayout = function () {
-    leafx = 0;
-    leafrank = 0;
-    dolayout (tree, wrect[1].y - 10);
-    remove ('leafx');
-    remove ('leafrank');
-};
-dolayout = function (node, pary) {
-    local r, n, i, size, lchp, rchp;
-    size = nodesize (node);
-    if (node.chn > 0) {
-        for (i = 0; i < node.chn; i = i + 1)
-            dolayout (node.ch[i], pary - size.y - dist.y);
-        node.rank = (node.ch[0].rank + node.ch[node.chn - 1].rank) / 2;
-        lchp = node.ch[0].rect;
-        rchp = node.ch[node.chn - 1].rect;
-        r[0].x = lchp[0].x + ((rchp[1].x - lchp[0].x) - size.x) / 2;
-        r[0].y = pary - size.y;
-        r[1].x = r[0].x + size.x;
-        r[1].y = pary;
-        node.rect = r;
-    } else {
-        node.rank = leafrank;
-        r[0].x = leafx;
-        r[0].y = pary - size.y;
-        r[1].x = r[0].x + size.x;
-        r[1].y = pary;
-        leafrank = leafrank + 1;
-        leafx = r[1].x + dist.x;
-        node.rect = r;
-    }
-};
-
-# editing functions
-#
-inode = function (point, name) {
-    local i, nnum, size;
-    nnum = nodenum;
-    if (~name)
-        name = ask ('give name of node:');
-    nodearray[nnum].ch = [];
-    nodearray[nnum].chn = 0;
-    nodearray[nnum].name = name;
-    size = nodesize (nodearray[nnum]);
-    nodearray[nnum].rect[0] = point;
-    nodearray[nnum].rect[1] = ['x' = point.x + size.x; 'y' = point.y + size.y;];
-    nodenum = nodenum + 1;
-    if (~tree) {
-        tree = nodearray[nnum];
-        tree.depth = 0;
-        complayout ();
-        drawtree (tree);
-    } else
-        drawtree (nodearray[nnum]);
-    return nodearray[nnum];
-};
-iedge = function (node1, node2) {
-    node1.ch[node1.chn] = node2;
-    node1.chn = node1.chn + 1;
-    node2.depth = node1.depth + 1;
-    complayout ();
-    clear (canvas);
-    drawtree (tree);
-};
-fix = function (node, op, np) {
-    if (node.depth ~= 0)
-        dist.y = dist.y + (op.y - np.y) / node.depth;
-    if (node.rank ~= 0)
-        dist.x = dist.x + (np.x - op.x) / node.rank;
-    complayout ();
-    clear (canvas);
-    drawtree (tree);
-};
-nodesize = function (node) {
-    local siz;
-    if (~(siz = textsize (canvas, node.name, fontname, fontsize)))
-        siz = defsize;
-    else {
-        siz.x = siz.x + 8;
-        siz.y = siz.y + 8;
-    }
-    return siz;
-};
-changenode = function (nodestyle) {
-    drawnode = nodestyle;
-    clear (canvas);
-    drawtree (tree);
-};
-
-# user interface functions
-#
-leftdown = function (data) {
-    if (~data.obj)
-        inode (data.pos, null);
-};
-leftup = function (data) {
-    if (data.pobj)
-        fix (data.pobj, data.ppos, data.pos);
-};
-middleup = function (data) {
-    if (data.pobj & data.obj)
-        iedge (data.pobj, data.obj);
-};
-dops = function () {
-    local s;
-
-    s = ['x' = 8 * 300; 'y' = 10.5 * 300;];
-    fontname = 'Times-Roman';
-    canvas = createwidget (-1, ['type' = 'ps'; 'size' = s;]);
-    setwidgetattr (canvas, ['window' = wrect;]);
-    drawtree (tree);
-    destroywidget (canvas);
-    canvas=defcanvas;
-    fontname = 'fixed';
-};
diff --git a/cmd/lefty/exec.c b/cmd/lefty/exec.c
deleted file mode 100644 (file)
index 9485c27..0000000
+++ /dev/null
@@ -1,1000 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "mem.h"
-#include "code.h"
-#include "tbl.h"
-#include "str.h"
-#include "exec.h"
-#include "internal.h"
-#include <stdbool.h>
-#include <string.h>
-
-static lvar_t *lvarp;
-static int lvarn, llvari, flvari;
-#define LVARINCR 1000
-#define LVARSIZE sizeof (lvar_t)
-
-Tobj root, null;
-Tobj rtno;
-bool Erun;
-int Eerrlevel, Estackdepth, Eshowbody;
-
-#define PUSHJMP(op, np, b) op = (volatile jmp_buf *) np, np = (jmp_buf *) &b
-#define POPJMP(op, np) np = (jmp_buf *) op
-
-/* longjmps for normal program execution */
-#define PLJ_BREAK    0
-#define PLJ_CONTINUE 1
-#define PLJ_RETURN   2
-#define PLJ_SIZE     3
-
-static jmp_buf *pljbufp1, *pljbufp2;
-static int pljtype;
-
-/* longjmp for error handling */
-static jmp_buf *eljbufp;
-
-/* error levels and types */
-#define ERR0 0
-#define ERR1 1
-#define ERR2 2
-#define ERR3 3
-#define ERR4 4
-#define ERR5 5
-
-#define ERRNOLHS        0
-#define ERRNORHS        1
-#define ERRNOSUCHFUNC   2
-#define ERRBADARG       3
-#define ERRARGMIS       4
-#define ERRNOTATABLE    5
-#define ERRIFUNCERR     6
-#define ERRRECRUN       7
-#define ERRTABLECHANGED 8
-
-static char *errnam[] = {
-    "no variable",
-    "no value",
-    "no such function",
-    "bad argument",
-    "argument number mismatch",
-    "not a table",
-    "internal function call error",
-    "recursive run attempt",
-    "table changed during a forin loop",
-};
-
-static bool errdo;
-
-/* stack information */
-typedef struct sinfo_t {
-    Tobj co, fco;
-    int ci, fci;
-    int flvari, llvari;
-} sinfo_t;
-#define SINFOSIZE sizeof (sinfo_t)
-#define SINFOINCR 100
-static sinfo_t *sinfop;
-static int sinfoi, sinfon;
-
-#define TNK_LI 0
-#define TNK_O  1
-#define TNK_S  2
-
-typedef struct tnk_t {
-    int type;
-    union {
-        int li;
-        struct {
-            Tobj to, ko;
-        } tnko;
-        struct {
-            int kt;
-            Tobj to, co;
-            int vi;
-        } tnks;
-    } u;
-} tnk_t;
-
-typedef struct Num_t {
-    int type;
-    union {
-        long i;
-        double d;
-        Tobj no;
-    } u;
-} Num_t;
-
-static long rootm;
-static int running;
-
-static Tobj eeval (Tobj, int);
-static Tobj efcall (Tobj, int);
-static void ewhilest (Tobj, int);
-static void eforst (Tobj, int);
-static void eforinst (Tobj, int);
-
-static Tobj getval (Tobj, int);
-static int getvar (Tobj, int, tnk_t *);
-static void setvar (tnk_t, Tobj);
-static bool boolop (Tobj);
-static bool orderop (Tobj, int, Tobj);
-static Tobj arithop (Num_t *, int, Num_t *);
-static void err (int, int, Tobj, int);
-static void printbody (char *, int);
-
-void Einit (void) {
-    root = Ttable (100);
-    rootm = Mpushmark (root);
-    Tinss (root, "null", (null = Ttable (2)));
-    rtno = NULL;
-    pljbufp1 = pljbufp2 = NULL, pljtype = 0;
-    eljbufp = NULL;
-    lvarp = Marrayalloc ((long) LVARINCR * LVARSIZE);
-    lvarn = LVARINCR;
-    llvari = 0;
-    flvari = 0;
-    sinfop = Marrayalloc ((long) SINFOINCR * SINFOSIZE);
-    sinfon = SINFOINCR;
-    sinfoi = 0;
-    Erun = false;
-    running = 0;
-}
-
-void Eterm (void) {
-    Marrayfree (sinfop), sinfop = NULL, sinfon = 0, sinfoi = 0;
-    Marrayfree (lvarp), lvarp = NULL, lvarn = 0, llvari = 0, flvari = 0;
-    rtno = NULL;
-    null = NULL;
-    Mpopmark (rootm);
-}
-
-Tobj Eunit (Tobj co) {
-    volatile jmp_buf *oeljbufp;
-    volatile int ownsinfoi;
-    volatile long m;
-    volatile Tobj lrtno;
-
-    jmp_buf eljbuf;
-
-    if (!co)
-        return NULL;
-
-    if (Tgettype (co) != T_CODE)
-        panic1 (POS, "Eunit", "argument type is not T_CODE");
-
-    m = Mpushmark (co);
-    PUSHJMP (oeljbufp, eljbufp, eljbuf);
-    ownsinfoi = sinfoi++;
-    if (sinfoi == sinfon) {
-        sinfop = Marraygrow (sinfop, (long) (sinfon + SINFOINCR) * SINFOSIZE);
-        sinfon += SINFOINCR;
-    }
-    sinfop[ownsinfoi].co = co;
-    sinfop[ownsinfoi].ci = TCgetfp (co, 0);
-    sinfop[ownsinfoi].fco = NULL;
-    sinfop[ownsinfoi].flvari = flvari;
-    sinfop[ownsinfoi].llvari = llvari;
-    running++;
-    if (setjmp (*eljbufp))
-        lrtno = NULL;
-    else
-        lrtno = eeval (co, TCgetfp (co, 0));
-    running--;
-    rtno = NULL;
-    flvari = sinfop[ownsinfoi].flvari;
-    llvari = sinfop[ownsinfoi].llvari;
-    sinfoi = ownsinfoi;
-    POPJMP (oeljbufp, eljbufp);
-    Mpopmark (m);
-    Erun = true;
-    return lrtno;
-}
-
-/*  shortcut: this function executes a piece of code that corresponds to
-    <internal func name> = function () internal "<internal func name>";
-*/
-Tobj Efunction (Tobj co, char *ifnam) {
-    Tobj v1o;
-    int fi;
-
-    fi = TCgetnext (co, TCgetfp (co, TCgetfp (co, 0)));
-    v1o = Tcode (
-        TCgetaddr (co, fi), fi, (int) TCgetinteger (co, TCgetfp (co, fi))
-    );
-    Tinss (root, ifnam, v1o);
-    return v1o;
-}
-
-static Tobj eeval (Tobj co, int ci) {
-    Tobj v1o, v2o, v3o;
-    int ttype;
-    int ctype;
-    tnk_t tnk;
-    Num_t lnum, rnum;
-    long m1, m2;
-    int i1, i2, res;
-
-tailrec:
-    m1 = 0;
-    errdo = true;
-    v1o = NULL;
-    ctype = TCgettype (co, ci);
-    switch (ctype) {
-    case C_ASSIGN:
-        i1 = TCgetfp (co, ci);
-        if ((v1o = eeval (co, TCgetnext (co, i1))) == NULL) {
-            err (ERRNORHS, ERR4, co, TCgetnext (co, i1));
-            return NULL;
-        }
-        m1 = Mpushmark (v1o);
-        res = getvar (co, i1, &tnk);
-        Mpopmark (m1);
-        if (res == -1) {
-            err (ERRNOLHS, ERR3, co, i1);
-            return NULL;
-        }
-        setvar (tnk, v1o);
-        return v1o;
-    case C_OR:
-    case C_AND:
-    case C_NOT:
-        i1 = TCgetfp (co, ci);
-        if ((v1o = eeval (co, i1)) == NULL)
-            err (ERRNORHS, ERR4, co, i1);
-        switch (ctype) {
-        case C_OR:
-            if (boolop (v1o))
-                return Ttrue;
-            if ((v1o = eeval (co, TCgetnext (co, i1))) == NULL)
-                err (ERRNORHS, ERR4, co, TCgetnext (co, i1));
-            return boolop(v1o) ? Ttrue: Tfalse;
-        case C_AND:
-            if (!boolop(v1o))
-                return Tfalse;
-            if ((v1o = eeval (co, TCgetnext (co, i1))) == NULL)
-                err (ERRNORHS, ERR4, co, TCgetnext (co, i1));
-            return !boolop(v1o) ? Tfalse: Ttrue;
-        case C_NOT:
-            return !boolop(v1o) ? Tfalse: Ttrue;
-        }
-        /* NOT REACHED */
-        return Tfalse;
-    case C_EQ:
-    case C_NE:
-    case C_LT:
-    case C_LE:
-    case C_GT:
-    case C_GE:
-        i1 = TCgetfp (co, ci);
-        if ((v1o = eeval (co, i1)) == NULL)
-            err (ERRNORHS, ERR4, co, i1);
-        else
-            m1 = Mpushmark (v1o);
-        if ((v2o = eeval (co, TCgetnext (co, i1))) == NULL)
-            err (ERRNORHS, ERR4, co, TCgetnext (co, i1));
-        if (v1o)
-            Mpopmark (m1);
-        return orderop (v1o, ctype, v2o) ? Ttrue: Tfalse;
-    case C_PLUS:
-    case C_MINUS:
-    case C_MUL:
-    case C_DIV:
-    case C_MOD:
-    case C_UMINUS:
-        i1 = TCgetfp (co, ci);
-        if ((lnum.type = TCgettype (co, i1)) == C_INTEGER)
-            lnum.u.i = TCgetinteger (co, i1);
-        else if (lnum.type == C_REAL)
-            lnum.u.d = TCgetreal (co, i1);
-        else if ((lnum.u.no = eeval (co, i1)) == NULL) {
-            err (ERRNORHS, ERR4, co, i1);
-            return NULL;
-        }
-        if (ctype == C_UMINUS) {
-            if (!(v1o = arithop (&lnum, ctype, NULL)))
-                err (ERRNORHS, ERR4, co, ci);
-            return v1o;
-        }
-        if (lnum.type != C_INTEGER && lnum.type != C_REAL)
-            m1 = Mpushmark (lnum.u.no);
-        i1 = TCgetnext (co, i1);
-        if ((rnum.type = TCgettype (co, i1)) == C_INTEGER)
-            rnum.u.i = TCgetinteger (co, i1);
-        else if (rnum.type == C_REAL)
-            rnum.u.d = TCgetreal (co, i1);
-        else if ((rnum.u.no = eeval (co, i1)) == NULL)
-            err (ERRNORHS, ERR4, co, i1);
-        if (lnum.type != C_INTEGER && lnum.type != C_REAL)
-            Mpopmark (m1);
-        if (!(v1o = arithop (&lnum, ctype, &rnum)))
-            err (ERRNORHS, ERR4, co, ci);
-        return v1o;
-    case C_PEXPR:
-        ci = TCgetfp (co, ci);
-        goto tailrec;
-    case C_FCALL:
-        return efcall (co, ci);
-    case C_INTEGER:
-        return Tinteger (TCgetinteger (co, ci));
-    case C_REAL:
-        return Treal (TCgetreal (co, ci));
-    case C_STRING:
-        return Tstring (TCgetstring (co, ci));
-    case C_GVAR:
-    case C_LVAR:
-    case C_PVAR:
-        return getval (co, ci);
-    case C_FUNCTION:
-        return Tcode (
-            TCgetaddr (co, ci), ci, (int) TCgetinteger (co, TCgetfp (co, ci))
-        );
-    case C_TCONS:
-        v1o = Ttable (0);
-        m1 = Mpushmark (v1o);
-        for (
-            i1 = TCgetfp (co, ci); i1 != C_NULL;
-            i1 = TCgetnext (co, TCgetnext (co, i1))
-        ) {
-            if (!(v3o = eeval (co, TCgetnext (co, i1)))) {
-                err (ERRNORHS, ERR4, co, TCgetnext (co, i1));
-                continue;
-            }
-            m2 = Mpushmark (v3o);
-            if (!(v2o = eeval (co, i1))) {
-                err (ERRNOLHS, ERR3, co, i1);
-                Mpopmark (m2);
-                continue;
-            }
-            ttype = Tgettype (v2o);
-            if (ttype == T_INTEGER || ttype == T_REAL || ttype == T_STRING)
-                Tinso (v1o, v2o, v3o);
-            else
-                err (ERRNOLHS, ERR1, co, i1);
-        }
-        Mpopmark (m1);
-        return v1o;
-    case C_STMT:
-        for (i1 = TCgetfp (co, ci); i1 != C_NULL; )
-            if ((i2 = TCgetnext (co, i1)) != C_NULL) {
-                eeval (co, i1);
-                i1 = i2;
-            } else {
-                ci = i1;
-                goto tailrec;
-            }
-        /* NOT REACHED */
-        break;
-    case C_IF:
-        i1 = TCgetfp (co, ci);
-        if (!(v1o = eeval (co, i1)))
-            err (ERRNORHS, ERR5, co, i1);
-        if (boolop(v1o)) {
-            ci = TCgetnext (co, i1);
-            goto tailrec;
-        } else if ((ci = TCgetnext (co, TCgetnext (co, i1))) != C_NULL)
-            goto tailrec;
-        break;
-    case C_WHILE:
-        ewhilest (co, ci);
-        break;
-    case C_FOR:
-        eforst (co, ci);
-        break;
-    case C_FORIN:
-        eforinst (co, ci);
-        break;
-    case C_BREAK:
-        pljtype = PLJ_BREAK;
-        longjmp (*pljbufp1, 1);
-        /* NOT REACHED */
-        break;
-    case C_CONTINUE:
-        pljtype = PLJ_CONTINUE;
-        longjmp (*pljbufp1, 1);
-        /* NOT REACHED */
-        break;
-    case C_RETURN:
-        if ((i1 = TCgetfp (co, ci)) != C_NULL)
-            rtno = eeval (co, i1);
-        pljtype = PLJ_RETURN;
-        longjmp (*pljbufp2, 1);
-        /* NOT REACHED */
-        break;
-    default:
-        panic1 (POS, "eeval", "unknown program token type %d", ctype);
-    }
-    return v1o;
-}
-
-static Tobj efcall (Tobj co, int ci) {
-    volatile jmp_buf *opljbufp1, *opljbufp2;
-    volatile long m;
-    volatile int bi, ownsinfoi, li, ln;
-
-    jmp_buf pljbuf;
-    Tobj fdo, vo, lrtno;
-    int i, fci, ai, di, di1, fid;
-
-    ownsinfoi = sinfoi++;
-    if (sinfoi == sinfon) {
-        sinfop = Marraygrow (sinfop, (long) (sinfon + SINFOINCR) * SINFOSIZE);
-        sinfon += SINFOINCR;
-    }
-    sinfop[ownsinfoi].co = co;
-    sinfop[ownsinfoi].ci = ci;
-    sinfop[ownsinfoi].fco = NULL;
-    sinfop[ownsinfoi].flvari = flvari;
-    sinfop[ownsinfoi].llvari = llvari;
-    fci = TCgetfp (co, ci);
-    if (!(fdo = getval (co, fci)) || Tgettype (fdo) != T_CODE) {
-        err (ERRNOSUCHFUNC, ERR2, co, fci);
-        sinfoi = ownsinfoi;
-        return NULL;
-    }
-
-    m = Mpushmark ((Tobj) fdo);
-    ai = TCgetfp (co, TCgetnext (co, fci));
-    ln = (int) TCgetinteger (fdo, (li = TCgetnext (fdo, TCgetfp (fdo, 0))));
-    di = TCgetnext (fdo, li);
-    bi = TCgetnext (fdo, di);
-    if (bi != C_NULL && TCgettype (fdo, bi) == C_INTERNAL) {
-        for (i = 0; ai != C_NULL; ai = TCgetnext (co, ai), i++) {
-            if (!(vo = eeval (co, ai))) {
-                err (ERRBADARG, ERR2, co, ai);
-                Mpopmark (m);
-                llvari = sinfop[ownsinfoi].llvari;
-                sinfoi = ownsinfoi;
-                return NULL;
-            }
-            if (llvari + 1 > lvarn) {
-                lvarp = Marraygrow (lvarp, (long) (llvari + 1) * LVARSIZE);
-                lvarn = llvari + 1;
-            }
-            lvarp[llvari].m = Mpushmark ((lvarp[llvari].o = vo));
-            llvari++;
-        }
-        fid = (int) TCgetinteger (fdo, TCgetfp (fdo, bi));
-        if (Ifuncs[fid].min > i || Ifuncs[fid].max < i) {
-            err (ERRARGMIS, ERR2, co, ci);
-            Mpopmark (m);
-            llvari = sinfop[ownsinfoi].llvari;
-            sinfoi = ownsinfoi;
-            return NULL;
-        }
-        flvari = sinfop[ownsinfoi].llvari;
-        sinfop[ownsinfoi].fco = fdo;
-        sinfop[ownsinfoi].fci = bi;
-        if (fid < 0 || fid >= Ifuncn)
-            panic1 (POS, "efcall", "no such internal function: %d", fid);
-        rtno = Ttrue;
-        if ((*Ifuncs[fid].func) (i, &lvarp[flvari]) == L_FAILURE) {
-            rtno = NULL;
-            err (ERRIFUNCERR, ERR2, co, ci);
-        }
-    } else {
-        if (llvari + ln > lvarn) {
-            lvarp = Marraygrow (lvarp, (long) (llvari + ln) * LVARSIZE);
-            lvarn = llvari + ln;
-        }
-        di1 = TCgetfp (fdo, di);
-        for (
-            i = 0; i < ln && di1 != C_NULL && ai != C_NULL;
-            i++, ai = TCgetnext (co, ai)
-        ) {
-            if (!(vo = eeval (co, ai))) {
-                err (ERRBADARG, ERR2, co, ai);
-                Mpopmark (m);
-                llvari = sinfop[ownsinfoi].llvari;
-                sinfoi = ownsinfoi;
-                return NULL;
-            }
-            lvarp[llvari].m = Mpushmark ((lvarp[llvari].o = vo));
-            llvari++;
-            di1 = TCgetnext (fdo, di1);
-        }
-        if (di1 != C_NULL || ai != C_NULL) {
-            err (ERRARGMIS, ERR2, co, ci);
-            Mpopmark (m);
-            llvari = sinfop[ownsinfoi].llvari;
-            sinfoi = ownsinfoi;
-            return NULL;
-        }
-        for (; i < ln; i++, llvari++)
-            lvarp[llvari].m = Mpushmark ((lvarp[llvari].o = NULL));
-        flvari = sinfop[ownsinfoi].llvari;
-        PUSHJMP (opljbufp2, pljbufp2, pljbuf);
-        opljbufp1 = (volatile jmp_buf *) pljbufp1;
-        if (setjmp (*pljbufp2)) {
-            ;
-        } else {
-            sinfop[ownsinfoi].fco = fdo;
-            for (; bi != C_NULL; bi = TCgetnext (fdo, bi)) {
-                sinfop[ownsinfoi].fci = bi;
-                if (TCgettype (fdo, bi) != C_DECL)
-                    eeval ((Tobj) fdo, bi);
-            }
-        }
-        POPJMP (opljbufp2, pljbufp2);
-        pljbufp1 = (jmp_buf *) opljbufp1;
-    }
-    flvari = sinfop[ownsinfoi].flvari;
-    llvari = sinfop[ownsinfoi].llvari;
-    sinfoi = ownsinfoi;
-    Mpopmark (m);
-    lrtno = rtno, rtno = NULL;
-    errdo = true;
-    return lrtno;
-}
-
-static void ewhilest (Tobj co, int ci) {
-    volatile jmp_buf *opljbufp;
-    volatile jmp_buf pljbuf;
-    volatile Tobj c1o;
-    volatile int ei, si;
-
-    Tobj v1o;
-
-    c1o = (Tobj) co; /* protect argument from longjmp */
-    ei = TCgetfp (c1o, ci);
-    si = TCgetnext (c1o, ei);
-    PUSHJMP (opljbufp, pljbufp1, pljbuf);
-    for (;;) {
-        if (!(v1o = eeval ((Tobj) c1o, ei)))
-            err (ERRNORHS, ERR5, c1o, ei);
-        if (!boolop(v1o))
-            break;
-        if (setjmp (*pljbufp1)) {
-            if (pljtype == PLJ_CONTINUE)
-                continue;
-            else if (pljtype == PLJ_BREAK)
-                break;
-        }
-        eeval ((Tobj) c1o, si);
-    }
-    POPJMP (opljbufp, pljbufp1);
-}
-
-static void eforst (Tobj co, int ci) {
-    volatile jmp_buf *opljbufp;
-    volatile jmp_buf pljbuf;
-    volatile Tobj c1o;
-    volatile int ei1, ei2, ei3, si, eisnop1, eisnop2, eisnop3;
-
-    Tobj v1o;
-
-    c1o = (Tobj) co; /* protect argument from longjmp */
-    ei1 = TCgetfp (c1o, ci);
-    ei2 = TCgetnext (c1o, ei1);
-    ei3 = TCgetnext (c1o, ei2);
-    si = TCgetnext (c1o, ei3);
-    eisnop1 = (TCgettype (c1o, ei1) == C_NOP);
-    eisnop2 = (TCgettype (c1o, ei2) == C_NOP);
-    eisnop3 = (TCgettype (c1o, ei3) == C_NOP);
-    PUSHJMP (opljbufp, pljbufp1, pljbuf);
-    if (!eisnop1)
-        eeval ((Tobj) c1o, ei1);
-    for (;;) {
-        if (!eisnop2) {
-            if (!(v1o = eeval ((Tobj) c1o, ei2)))
-                err (ERRNORHS, ERR5, c1o, ei2);
-            if (!boolop(v1o))
-                break;
-        }
-        if (setjmp (*pljbufp1) != 0) {
-            if (pljtype == PLJ_CONTINUE)
-                ;
-            else if (pljtype == PLJ_BREAK)
-                break;
-        } else {
-            eeval ((Tobj) c1o, si);
-        }
-        if (!eisnop3)
-            eeval ((Tobj) c1o, ei3);
-    }
-    POPJMP (opljbufp, pljbufp1);
-}
-
-static void eforinst (Tobj co, int ci) {
-    volatile jmp_buf *opljbufp;
-    volatile jmp_buf pljbuf;
-    volatile Tobj tblo, c1o;
-    volatile Tkvindex_t tkvi;
-    volatile tnk_t tnk;
-    volatile long tm, km, t;
-    volatile int ei1, ei2, si;
-
-    c1o = (Tobj) co; /* protect argument from longjmp */
-    ei1 = TCgetfp (c1o, ci);
-    ei2 = TCgetnext (c1o, ei1);
-    si = TCgetnext (c1o, ei2);
-    if (getvar ((Tobj) c1o, ei1, (tnk_t *) &tnk) == -1) {
-        err (ERRNOLHS, ERR3, c1o, ei1);
-        return;
-    }
-    if (tnk.type == TNK_O)
-        km = Mpushmark (tnk.u.tnko.ko);
-    if (!(tblo = (Tobj) eeval ((Tobj) c1o, ei2))) {
-        if (tnk.type == TNK_O)
-            Mpopmark (km);
-        err (ERRNORHS, ERR4, c1o, ei2);
-        return;
-    }
-    if (Tgettype (tblo) != T_TABLE) {
-        err (ERRNOTATABLE, ERR1, c1o, ei2);
-        return;
-    }
-    tm = Mpushmark (tblo);
-    PUSHJMP (opljbufp, pljbufp1, pljbuf);
-    t = Tgettime (tblo);
-    Ttime++;
-    for (
-        Tgetfirst ((Tobj) tblo, (Tkvindex_t *) &tkvi); tkvi.kvp;
-        Tgetnext ((Tkvindex_t *) &tkvi)
-    ) {
-        setvar (tnk, tkvi.kvp->ko);
-        if (setjmp (*pljbufp1) != 0) {
-            if (pljtype == PLJ_CONTINUE)
-                continue;
-            else if (pljtype == PLJ_BREAK)
-                break;
-        }
-        eeval ((Tobj) c1o, si);
-        if (t != Tgettime (tblo)) {
-            err (ERRTABLECHANGED, ERR1, c1o, ei2);
-            break;
-        }
-    }
-    POPJMP (opljbufp, pljbufp1);
-    Mpopmark (tm);
-    if (tnk.type == TNK_O)
-        Mpopmark (km);
-}
-
-static Tobj getval (Tobj co, int ci) {
-    Tobj cvo, cko, cto;
-    int ct, vt;
-    int vi, ni, nn;
-
-    cvo = NULL;
-    if ((ct = TCgettype (co, ci)) == C_LVAR) {
-        nn = (int) TCgetinteger (co, (ni = TCgetnext (co, TCgetfp (co, ci))));
-        cto = cvo = lvarp[flvari + nn].o;
-        if (!cto)
-            return NULL;
-        vi = TCgetnext (co, ni);
-    } else if (ct == C_GVAR) {
-        cto = root;
-        vi = TCgetfp (co, ci);
-    } else if (ct == C_PVAR)
-        return TCgetobject (co, ci);
-    else
-        return NULL;
-
-    while (vi != C_NULL) {
-        if (Tgettype (cto) != T_TABLE)
-            return NULL;
-        if ((vt = TCgettype (co, vi)) == C_STRING) {
-            if (!(cvo = Tfinds (cto, TCgetstring (co, vi))))
-                return NULL;
-        } else if (vt == C_INTEGER) {
-            if (!(cvo = Tfindi (cto, TCgetinteger (co, vi))))
-                return NULL;
-        } else if (vt == C_REAL) {
-            if (!(cvo = Tfindr (cto, TCgetreal (co, vi))))
-                return NULL;
-        } else {
-            if (!(cko = eeval (co, vi)) || !(cvo = Tfindo (cto, cko)))
-                return NULL;
-        }
-        cto = cvo;
-        vi = TCgetnext (co, vi);
-    }
-    return cvo;
-}
-
-static int getvar (Tobj co, int ci, tnk_t *tnkp) {
-    Tobj cvo, cko, cto;
-    int ct, vt;
-    long m;
-    int vi, ovi, nn, ni;
-
-    nn = 0;
-    vt = 0;
-    cko = cto = NULL;
-    if ((ct = TCgettype (co, ci)) == C_LVAR) {
-        nn = (int) TCgetinteger (co, (ni = TCgetnext (co, TCgetfp (co, ci))));
-        cvo = cto = lvarp[flvari + nn].o;
-        vi = TCgetnext (co, ni);
-        if (vi != C_NULL && (!cvo || Tgettype (cvo) != T_TABLE))
-            Mresetmark (
-                lvarp[flvari + nn].m,
-                (lvarp[flvari + nn].o = cvo = cto = Ttable (0))
-            );
-    } else if (ct == C_GVAR) { /* else it's a global variable */
-        cvo = root;
-        vi = TCgetfp (co, ci);
-    } else {
-        return -1;
-    }
-
-    ovi = -1;
-    while (vi != C_NULL) {
-        cto = cvo;
-        if ((vt = TCgettype (co, vi)) == C_STRING) {
-            cvo = Tfinds (cto, TCgetstring (co, vi));
-        } else if (vt == C_INTEGER) {
-            cvo = Tfindi (cto, TCgetinteger (co, vi));
-        } else if (vt == C_REAL) {
-            cvo = Tfindr (cto, TCgetreal (co, vi));
-        } else {
-            if (
-                !(cko = eeval (co, vi)) || !(T_ISSTRING (cko) ||
-                T_ISNUMBER (cko))
-            )
-                return -1;
-            cvo = Tfindo (cto, cko);
-        }
-        ovi = vi, vi = TCgetnext (co, vi);
-        if (vi != C_NULL && (!cvo || Tgettype (cvo) != T_TABLE)) {
-            if (vt == C_STRING)
-                Tinss (cto, TCgetstring (co, ovi), (cvo = Ttable (0)));
-            else if (vt == C_INTEGER)
-                Tinsi (cto, TCgetinteger (co, ovi), (cvo = Ttable (0)));
-            else if (vt == C_REAL)
-                Tinsr (cto, TCgetreal (co, ovi), (cvo = Ttable (0)));
-            else {
-                m = Mpushmark (cko);
-                Tinso (cto, cko, (cvo = Ttable (0))),
-                Mpopmark (m);
-            }
-        }
-    }
-    if (ct == C_LVAR && ovi == -1) {
-        tnkp->type = TNK_LI;
-        tnkp->u.li = nn;
-    } else {
-        switch (vt) {
-        case C_STRING:
-        case C_INTEGER:
-        case C_REAL:
-            tnkp->type = TNK_S;
-            tnkp->u.tnks.kt = vt;
-            tnkp->u.tnks.to = cto;
-            tnkp->u.tnks.co = co;
-            tnkp->u.tnks.vi = ovi;
-            break;
-        default:
-            tnkp->type = TNK_O;
-            tnkp->u.tnko.to = cto;
-            tnkp->u.tnko.ko = cko;
-            break;
-        }
-    }
-    return 0;
-}
-
-static void setvar (tnk_t tnk, Tobj vo) {
-    switch (tnk.type) {
-    case TNK_LI:
-        Mresetmark (
-            lvarp[flvari + tnk.u.li].m, (lvarp[flvari + tnk.u.li].o = vo)
-        );
-        break;
-    case TNK_O:
-        Tinso (tnk.u.tnko.to, tnk.u.tnko.ko, vo);
-        break;
-    default:
-        switch (tnk.u.tnks.kt) {
-        case C_STRING:
-            Tinss (
-                tnk.u.tnks.to, TCgetstring (tnk.u.tnks.co, tnk.u.tnks.vi), vo
-            );
-            break;
-        case C_INTEGER:
-            Tinsi (
-                tnk.u.tnks.to, TCgetinteger (tnk.u.tnks.co, tnk.u.tnks.vi), vo
-            );
-            break;
-        case C_REAL:
-            Tinsr (tnk.u.tnks.to, TCgetreal (tnk.u.tnks.co, tnk.u.tnks.vi), vo);
-            break;
-        }
-        break;
-    }
-}
-
-static bool boolop (Tobj vo) {
-    long i;
-    double d;
-
-    if (!vo)
-        return false;
-
-    switch (Tgettype (vo)) {
-    case T_INTEGER:
-        i = Tgetinteger (vo);
-        return i != 0;
-    case T_REAL:
-        d = Tgetreal (vo);
-        return !(d == 0.0);
-    case T_TABLE:
-        if (vo == null)
-            return false;
-        return true;
-    default:
-        return true;
-    }
-}
-
-static bool orderop (Tobj v1o, int op, Tobj v2o) {
-    int t1, t2;
-    long i1, i2;
-    int r;
-    double d1, d2;
-
-    if (!v1o || !v2o) {
-        if ((v1o || v2o) && op == C_NE)
-            return true;
-        return false;
-    }
-    t1 = Tgettype (v1o), t2 = Tgettype (v2o);
-    if (t1 == T_STRING && t2 == T_STRING) {
-        r = strcmp (Tgetstring (v1o), Tgetstring (v2o));
-    } else if (t1 == T_INTEGER && t2 == T_INTEGER) {
-        i1 = Tgetinteger (v1o), i2 = Tgetinteger (v2o);
-        r = (i1 == i2) ? 0 : ((i1 < i2) ? -1 : 1);
-    } else if (t1 == T_INTEGER && t2 == T_REAL) {
-        i1 = Tgetinteger (v1o), d2 = Tgetreal (v2o);
-        r = (i1 == d2) ? 0 : ((i1 < d2) ? -1 : 1);
-    } else if (t1 == T_REAL && t2 == T_INTEGER) {
-        d1 = Tgetreal (v1o), i2 = Tgetinteger (v2o);
-        r = (d1 == i2) ? 0 : ((d1 < i2) ? -1 : 1);
-    } else if (t1 == T_REAL && t2 == T_REAL) {
-        d1 = Tgetreal (v1o), d2 = Tgetreal (v2o);
-        r = (d1 == d2) ? 0 : ((d1 < d2) ? -1 : 1);
-    } else if (t1 == t2) {
-        if (op != C_EQ && op != C_NE)
-            return false;
-        r = (v1o == v2o) ? 0 : 1;
-    } else {
-        return false;
-    }
-    switch (op) {
-    case C_EQ: return r == 0;
-    case C_NE: return r != 0;
-    case C_LT: return r <  0;
-    case C_LE: return r <= 0;
-    case C_GT: return r >  0;
-    case C_GE: return r >= 0;
-    }
-    panic1 (POS, "orderop", "bad op code");
-    return false; /* NOT REACHED */
-}
-
-static Tobj arithop (Num_t *lnum, int op, Num_t *rnum) {
-    double d1, d2, d3;
-
-    d3 = 0.0;
-    if (!rnum && op != C_UMINUS)
-        return NULL;
-    if (lnum->type == C_INTEGER)
-        d1 = lnum->u.i;
-    else if (lnum->type == C_REAL)
-        d1 = lnum->u.d;
-    else if (!lnum->u.no)
-        return NULL;
-    else if (Tgettype (lnum->u.no) == T_INTEGER)
-        d1 = Tgetinteger (lnum->u.no);
-    else if (Tgettype (lnum->u.no) == T_REAL)
-        d1 = Tgetreal (lnum->u.no);
-    else
-        return NULL;
-    if (op == C_UMINUS) {
-        d3 = -d1;
-        goto result;
-    }
-    if (rnum->type == C_INTEGER)
-        d2 = rnum->u.i;
-    else if (rnum->type == C_REAL)
-        d2 = rnum->u.d;
-    else if (!rnum->u.no)
-        return NULL;
-    else if (Tgettype (rnum->u.no) == T_INTEGER)
-        d2 = Tgetinteger (rnum->u.no);
-    else if (Tgettype (rnum->u.no) == T_REAL)
-        d2 = Tgetreal (rnum->u.no);
-    else
-        return NULL;
-    switch (op) {
-    case C_PLUS:  d3 = d1 + d2;               break;
-    case C_MINUS: d3 = d1 - d2;               break;
-    case C_MUL:   d3 = d1 * d2;               break;
-    case C_DIV:   d3 = d1 / d2;               break;
-    case C_MOD:   d3 = (long) d1 % (long) d2; break;
-    }
-result:
-    if (d3 == (double) (long) d3)
-        return Tinteger ((long) d3);
-    return Treal (d3);
-}
-
-static void err (int errnum, int level, Tobj co, int ci) {
-    char *s;
-    int si, i;
-
-    if (level > Eerrlevel || !errdo)
-        return;
-    fprintf (stderr, "runtime error: %s\n", errnam[errnum]);
-    if (!co)
-        return;
-    if (Estackdepth < 1)
-        return;
-    if (!sinfop[(si = sinfoi - 1)].fco && si > 0)
-        si--;
-    if (Eshowbody > 0) {
-        if (co == sinfop[si].fco) {
-            s = Scfull (co, 0, ci);
-            printbody (s, Eshowbody);
-            free (s);
-        } else if (co == sinfop[si].co) {
-            s = Scfull (co, TCgetfp (co, 0), ci);
-            printbody (s, Eshowbody);
-            free (s);
-        } else {
-            printbody ("", Eshowbody);
-        }
-        if (Estackdepth == 1) {
-            fprintf (stderr, "\n");
-            errdo = false;
-        }
-        for (i = si; i >= 0; i--) {
-            if (sinfop[i].fco) {
-                s = Scfull (sinfop[i].fco, 0, sinfop[i].fci);
-                printbody (s, Eshowbody), free (s);
-            }
-        }
-        s = Scfull (sinfop[0].co, TCgetfp (sinfop[0].co, 0), sinfop[0].ci);
-        printbody (s, Eshowbody), free (s);
-    }
-    fprintf (stderr, "\n");
-    errdo = false;
-}
-
-static void printbody (char *s, int mode) {
-    char *s1, *s2;
-    char c;
-
-    if (mode == 2) {
-        fprintf (stderr, "%s\n", s);
-        return;
-    }
-    c = '\000';
-    for (s1 = s; *s1; s1++)
-        if (strncmp(s1, ">>", 2) == 0)
-            break;
-    if (!*s1)
-        return;
-    for (; s1 != s; s1--)
-        if (*(s1 - 1) == '\n')
-            break;
-    for (s2 = s1; *s2; s2++)
-        if (*s2 == '\n')
-            break;
-    if (*s2)
-        c = *s2, *s2 = '\000';
-    fprintf (stderr, "%s\n", s1);
-    if (c)
-        *s2 = c;
-}
diff --git a/cmd/lefty/exec.h b/cmd/lefty/exec.h
deleted file mode 100644 (file)
index 4c0b1db..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-#include <stdbool.h>
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-typedef struct Tonm_t lvar_t;
-
-extern Tobj root, null;
-extern Tobj rtno;
-extern bool Erun;
-extern int Eerrlevel, Estackdepth, Eshowbody;
-
-void Einit (void);
-void Eterm (void);
-Tobj Eunit (Tobj);
-Tobj Efunction (Tobj, char *);
diff --git a/cmd/lefty/g.c b/cmd/lefty/g.c
deleted file mode 100644 (file)
index d029dd0..0000000
+++ /dev/null
@@ -1,887 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-#include <stdbool.h>
-#include <string.h>
-
-Gwidget_t *Gwidgets;
-int Gwidgetn;
-
-Gbitmap_t *Gbitmaps;
-int Gbitmapn;
-#define BITMAPINCR 10
-#define BITMAPSIZE sizeof (Gbitmap_t)
-
-char *Gdefaultfont;
-int Gneedredraw;
-int Gbuttonsdown;
-int Gerrflag;
-
-char *texts;
-int textn;
-
-static long wsizes[G_WTYPESIZE];
-static Gtextline_t tlarray[1000];
-
-Gwattrmap_t Gwattrmap[] = {
-    { G_ATTRORIGIN,      G_ATTRTYPEPOINT, "origin",      },
-    { G_ATTRSIZE,        G_ATTRTYPESIZE,  "size",        },
-    { G_ATTRBORDERWIDTH, G_ATTRTYPEINT,   "borderwidth", },
-    { G_ATTRNAME,        G_ATTRTYPETEXT,  "name",        },
-    { G_ATTRTEXT,        G_ATTRTYPETEXT,  "text",        },
-    { G_ATTRAPPENDTEXT,  G_ATTRTYPETEXT,  "appendtext",  },
-    { G_ATTRSELECTION,   G_ATTRTYPETEXT,  "selection",   },
-    { G_ATTRCURSOR,      G_ATTRTYPETEXT,  "cursor",      },
-    { G_ATTRMODE,        G_ATTRTYPETEXT,  "mode",        },
-    { G_ATTRLAYOUT,      G_ATTRTYPETEXT,  "layout",      },
-    { G_ATTRZORDER,      G_ATTRTYPETEXT,  "zorder",      },
-    { G_ATTRCOLOR,       G_ATTRTYPECOLOR, "color",       },
-    { G_ATTRVIEWPORT,    G_ATTRTYPESIZE,  "viewport",    },
-    { G_ATTRWINDOW,      G_ATTRTYPERECT,  "window",      },
-    { G_ATTRWINDOWID,    G_ATTRTYPETEXT,  "windowid",    },
-    { G_ATTRCHILDCENTER, G_ATTRTYPEPOINT, "childcenter", },
-    { G_ATTRNEWLINECB,   G_ATTRTYPEFUNC,  "newlinecb",   },
-    { G_ATTRRESIZECB,    G_ATTRTYPEFUNC,  "resizecb",    },
-    { G_ATTRBUTTONCB,    G_ATTRTYPEFUNC,  "buttoncb",    },
-    { G_ATTREVENTCB,     G_ATTRTYPEFUNC,  "eventcb",     },
-    { G_ATTRUSERDATA,    G_ATTRTYPEFUNC,  "userdata",    },
-    { -1,                -1,              NULL,          },
-};
-
-static int arrayattr[] = {
-    G_ATTRSIZE,
-    G_ATTRBORDERWIDTH,
-    G_ATTRMODE,
-    G_ATTRLAYOUT,
-    G_ATTRCOLOR,
-    G_ATTRWINDOWID,
-    G_ATTRRESIZECB,
-    G_ATTRUSERDATA,
-    -1
-};
-
-static int buttonattr[] = {
-    G_ATTRSIZE,
-    G_ATTRBORDERWIDTH,
-    G_ATTRTEXT,
-    G_ATTRCOLOR,
-    G_ATTRWINDOWID,
-    G_ATTRBUTTONCB,
-    G_ATTRUSERDATA,
-    -1
-};
-
-static int canvasattr[] = {
-    G_ATTRSIZE,
-    G_ATTRBORDERWIDTH,
-#ifdef FEATURE_GMAP
-    G_ATTRMODE,
-#endif
-    G_ATTRCURSOR,
-    G_ATTRCOLOR,
-    G_ATTRVIEWPORT,
-    G_ATTRWINDOW,
-    G_ATTRWINDOWID,
-    G_ATTREVENTCB,
-    G_ATTRUSERDATA,
-    -1
-};
-
-static int labelattr[] = {
-    G_ATTRSIZE,
-    G_ATTRBORDERWIDTH,
-    G_ATTRTEXT,
-    G_ATTRCOLOR,
-    G_ATTRWINDOWID,
-    G_ATTREVENTCB,
-    G_ATTRUSERDATA,
-    -1
-};
-
-static int menuattr[] = {
-    G_ATTRUSERDATA,
-    -1
-};
-
-static int pcanvasattr[] = {
-    G_ATTRORIGIN,
-    G_ATTRSIZE,
-    G_ATTRNAME,
-    G_ATTRMODE,
-    G_ATTRCOLOR,
-    G_ATTRWINDOW,
-    G_ATTRWINDOWID,
-    G_ATTREVENTCB,
-    G_ATTRUSERDATA,
-    -1
-};
-
-static int queryattr[] = {
-    G_ATTRMODE,
-    G_ATTRUSERDATA,
-    -1
-};
-
-static int scrollattr[] = {
-    G_ATTRSIZE,
-    G_ATTRBORDERWIDTH,
-    G_ATTRCHILDCENTER,
-    G_ATTRMODE,
-    G_ATTRCOLOR,
-    G_ATTRWINDOWID,
-    G_ATTRUSERDATA,
-    -1,
-};
-
-static int textattr[] = {
-    G_ATTRSIZE,
-    G_ATTRBORDERWIDTH,
-    G_ATTRTEXT,
-    G_ATTRAPPENDTEXT,
-    G_ATTRSELECTION,
-    G_ATTRMODE,
-    G_ATTRCOLOR,
-    G_ATTRWINDOWID,
-    G_ATTRNEWLINECB,
-    G_ATTRUSERDATA,
-    -1
-};
-
-static int viewattr[] = {
-    G_ATTRORIGIN,
-    G_ATTRSIZE,
-    G_ATTRNAME,
-    G_ATTRCOLOR,
-    G_ATTRZORDER,
-    G_ATTRWINDOWID,
-    G_ATTREVENTCB,
-    G_ATTRUSERDATA,
-    -1
-};
-
-Gwlist_t Gwlist[] = {
-    { G_ARRAYWIDGET,   "array",  &arrayattr[0],   },
-    { G_BUTTONWIDGET,  "button", &buttonattr[0],  },
-    { G_CANVASWIDGET,  "canvas", &canvasattr[0],  },
-    { G_LABELWIDGET,   "label",  &labelattr[0],   },
-    { G_MENUWIDGET,    "menu",   &menuattr[0],    },
-    { G_PCANVASWIDGET, "ps",     &pcanvasattr[0], },
-    { G_QUERYWIDGET,   "query",  &queryattr[0],   },
-    { G_SCROLLWIDGET,  "scroll", &scrollattr[0],  },
-    { G_TEXTWIDGET,    "text",   &textattr[0],    },
-    { G_VIEWWIDGET,    "view",   &viewattr[0],    },
-    { -1,               NULL,    NULL,            },
-};
-
-static char *errmsg[] = {
-    /* Gerrno starts at 1      */ "no error",
-    /* G_ERRBADATTRID          */ "bad attribute id %d",
-    /* G_ERRBADATTRVALUE       */ "bad attribute value %s",
-    /* G_ERRBADCOLORINDEX      */ "bad color index %d",
-    /* G_ERRBADPARENTWIDGETID  */ "bad parent widget id %d",
-    /* G_ERRBADWIDGETID        */ "bad widget id %d",
-    /* G_ERRBADWIDGETTYPE      */ "bad widget type %d",
-    /* G_ERRCANNOTCREATEWIDGET */ "cannot create widget",
-    /* G_ERRCANNOTGETATTR      */ "cannot get attribute %s",
-    /* G_ERRCANNOTOPENFILE     */ "cannot open file %s",
-    /* G_ERRCANNOTSETATTR1     */ "cannot set attribute %s in createwidget",
-    /* G_ERRCANNOTSETATTR2     */ "cannot set attribute %s in setwidgetattr",
-    /* G_ERRINITFAILED         */ "initialization failed",
-    /* G_ERRNOCHILDWIDGET      */ "no child widget",
-    /* G_ERRNOPARENTWIDGET     */ "no parent widget",
-    /* G_ERRNOSUCHCURSOR       */ "no such cursor %s",
-    /* G_ERRNOTACANVAS         */ "widget %d is not a canvas",
-    /* G_ERRNOTIMPLEMENTED     */ "not implemented",
-    /* G_ERRNOTSUPPORTED       */ "not supported",
-    /* G_ERRBADBITMAPID        */ "bad bitmap id %d",
-    /* G_ERRCANNOTCREATEBITMAP */ "cannot create bitmap",
-    /* G_ERRNOBITMAP           */ "no bitmap",
-    /* G_ERRCANNOTREADBITMAP   */ "cannot read bitmap",
-};
-
-static int unpackstring (char *);
-
-int Ginit (void) {
-    int wi, bi;
-
-    wsizes[G_ARRAYWIDGET]   = AWSIZE;
-    wsizes[G_BUTTONWIDGET]  = BWSIZE;
-    wsizes[G_CANVASWIDGET]  = CWSIZE;
-    wsizes[G_LABELWIDGET]   = LWSIZE;
-    wsizes[G_MENUWIDGET]    = MWSIZE;
-    wsizes[G_PCANVASWIDGET] = PWSIZE;
-    wsizes[G_QUERYWIDGET]   = QWSIZE;
-    wsizes[G_SCROLLWIDGET]  = SWSIZE;
-    wsizes[G_TEXTWIDGET]    = TWSIZE;
-    wsizes[G_VIEWWIDGET]    = VWSIZE;
-    Gwidgets = Marrayalloc ((long) WIDGETINCR * WIDGETSIZE);
-    Gwidgetn = WIDGETINCR;
-    for (wi = 0; wi < Gwidgetn; wi++)
-        Gwidgets[wi].inuse = FALSE;
-    Gbitmapn = BITMAPINCR;
-    Gbitmaps = Marrayalloc ((long) Gbitmapn * BITMAPSIZE);
-    for (bi = 0; bi < Gbitmapn; bi++)
-        Gbitmaps[bi].inuse = FALSE;
-    Gneedredraw = FALSE;
-    Gbuttonsdown = 0;
-    Gdefaultfont = "";
-    Gerrflag = FALSE;
-    textn = 100;
-    texts = Marrayalloc ((long) textn);
-    texts[0] = '\0';
-    Ginitgraphics ();
-    return 0;
-}
-
-int Gterm (void) {
-    int wi;
-
-    for (wi = 0; wi < Gwidgetn; wi++)
-        if (Gwidgets[wi].inuse)
-            Gdestroywidget (wi);
-    Gtermgraphics ();
-    Marrayfree (texts), texts = NULL, textn = 0;
-    Marrayfree (Gwidgets), Gwidgets = NULL, Gwidgetn = 0;
-    Marrayfree (Gbitmaps), Gbitmaps = NULL, Gbitmapn = 0;
-    return 0;
-}
-
-int Gcreatewidget (int pwi, int type, int attrn, Gwattr_t *attrp) {
-    Gwidget_t *parent, *widget;
-    int rtn;
-
-    if ((pwi != -1) && (pwi < 0 || pwi > Gwidgetn || !Gwidgets[pwi].inuse)) {
-        Gerr (POS, G_ERRBADPARENTWIDGETID, pwi);
-        return -1;
-    }
-    if (type < 0 || type >= G_WTYPESIZE) {
-        Gerr (POS, G_ERRBADWIDGETTYPE, type);
-        return -1;
-    }
-    widget = newwidget (type);
-    widget->inuse = TRUE;
-    widget->pwi = pwi;
-    parent = (pwi == -1) ? NULL : &Gwidgets[pwi];
-    rtn = -1;
-    switch (type) {
-    case G_ARRAYWIDGET:
-        rtn = GAcreatewidget (parent, widget, attrn, attrp);
-        break;
-    case G_BUTTONWIDGET:
-        rtn = GBcreatewidget (parent, widget, attrn, attrp);
-        break;
-    case G_CANVASWIDGET:
-        rtn = GCcreatewidget (parent, widget, attrn, attrp);
-        break;
-    case G_LABELWIDGET:
-        rtn = GLcreatewidget (parent, widget, attrn, attrp);
-        break;
-    case G_MENUWIDGET:
-        rtn = GMcreatewidget (parent, widget, attrn, attrp);
-        break;
-    case G_PCANVASWIDGET:
-        rtn = GPcreatewidget (parent, widget, attrn, attrp);
-        break;
-    case G_QUERYWIDGET:
-        rtn = GQcreatewidget (parent, widget, attrn, attrp);
-        break;
-    case G_SCROLLWIDGET:
-        rtn = GScreatewidget (parent, widget, attrn, attrp);
-        break;
-    case G_TEXTWIDGET:
-        rtn = GTcreatewidget (parent, widget, attrn, attrp);
-        break;
-    case G_VIEWWIDGET:
-        rtn = GVcreatewidget (parent, widget, attrn, attrp);
-        break;
-    }
-    if (rtn == -1) {
-        widget->inuse = FALSE;
-        return -1;
-    }
-    return widget - &Gwidgets[0];
-}
-
-int Gsetwidgetattr (int wi, int attrn, Gwattr_t *attrp) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_ARRAYWIDGET:   return GAsetwidgetattr (widget, attrn, attrp);
-    case G_BUTTONWIDGET:  return GBsetwidgetattr (widget, attrn, attrp);
-    case G_CANVASWIDGET:  return GCsetwidgetattr (widget, attrn, attrp);
-    case G_LABELWIDGET:   return GLsetwidgetattr (widget, attrn, attrp);
-    case G_MENUWIDGET:    return GMsetwidgetattr (widget, attrn, attrp);
-    case G_PCANVASWIDGET: return GPsetwidgetattr (widget, attrn, attrp);
-    case G_QUERYWIDGET:   return GQsetwidgetattr (widget, attrn, attrp);
-    case G_SCROLLWIDGET:  return GSsetwidgetattr (widget, attrn, attrp);
-    case G_TEXTWIDGET:    return GTsetwidgetattr (widget, attrn, attrp);
-    case G_VIEWWIDGET:    return GVsetwidgetattr (widget, attrn, attrp);
-    }
-    return -1;
-}
-
-int Ggetwidgetattr (int wi, int attrn, Gwattr_t *attrp) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_ARRAYWIDGET:   return GAgetwidgetattr (widget, attrn, attrp);
-    case G_BUTTONWIDGET:  return GBgetwidgetattr (widget, attrn, attrp);
-    case G_CANVASWIDGET:  return GCgetwidgetattr (widget, attrn, attrp);
-    case G_LABELWIDGET:   return GLgetwidgetattr (widget, attrn, attrp);
-    case G_MENUWIDGET:    return GMgetwidgetattr (widget, attrn, attrp);
-    case G_PCANVASWIDGET: return GPgetwidgetattr (widget, attrn, attrp);
-    case G_QUERYWIDGET:   return GQgetwidgetattr (widget, attrn, attrp);
-    case G_SCROLLWIDGET:  return GSgetwidgetattr (widget, attrn, attrp);
-    case G_TEXTWIDGET:    return GTgetwidgetattr (widget, attrn, attrp);
-    case G_VIEWWIDGET:    return GVgetwidgetattr (widget, attrn, attrp);
-    }
-    return -1;
-}
-
-int Gdestroywidget (int wi) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_ARRAYWIDGET:   GAdestroywidget (widget); break;
-    case G_BUTTONWIDGET:  GBdestroywidget (widget); break;
-    case G_CANVASWIDGET:  GCdestroywidget (widget); break;
-    case G_LABELWIDGET:   GLdestroywidget (widget); break;
-    case G_MENUWIDGET:    GMdestroywidget (widget); break;
-    case G_PCANVASWIDGET: GPdestroywidget (widget); break;
-    case G_QUERYWIDGET:   GQdestroywidget (widget); break;
-    case G_SCROLLWIDGET:  GSdestroywidget (widget); break;
-    case G_TEXTWIDGET:    GTdestroywidget (widget); break;
-    case G_VIEWWIDGET:    GVdestroywidget (widget); break;
-    }
-    /* HACK: should do switch on type ... */
-    free (widget->u.c);
-    widget->inuse = FALSE;
-    return 0;
-}
-
-int Gqueryask (
-    int wi, char *prompt, char *args, char *responsep, int responsen
-) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    return GQqueryask (widget, prompt, args, responsep, responsen);
-}
-
-int Gmenuaddentries (int wi, int en, char **ep) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    return GMmenuaddentries (widget, en, ep);
-}
-
-int Gmenudisplay (int pwi, int wi) {
-    Gwidget_t *parent, *widget;
-
-    if (pwi < 0 || pwi > Gwidgetn || !Gwidgets[pwi].inuse) {
-        Gerr (POS, G_ERRBADPARENTWIDGETID, wi);
-        return -1;
-    }
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    parent = &Gwidgets[pwi];
-    widget = &Gwidgets[wi];
-    return GMmenudisplay (parent, widget);
-}
-
-/* functions for drawing on canvas and pcanvas widgets */
-
-int Gcanvasclear (int wi) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCcanvasclear (widget);
-    case G_PCANVASWIDGET: return GPcanvasclear (widget);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Gsetgfxattr (int wi, Ggattr_t *ap) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCsetgfxattr (widget, ap);
-    case G_PCANVASWIDGET: return GPsetgfxattr (widget, ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Ggetgfxattr (int wi, Ggattr_t *ap) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCgetgfxattr (widget, ap);
-    case G_PCANVASWIDGET: return GPgetgfxattr (widget, ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Garrow (int wi, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCarrow (widget, gp1, gp2, ap);
-    case G_PCANVASWIDGET: return GParrow (widget, gp1, gp2, ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Gline (int wi, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCline (widget, gp1, gp2, ap);
-    case G_PCANVASWIDGET: return GPline (widget, gp1, gp2, ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Gbox (int wi, Grect_t gr, Ggattr_t *ap) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCbox (widget, gr, ap);
-    case G_PCANVASWIDGET: return GPbox (widget, gr, ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Gpolygon (int wi, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCpolygon (widget, gpn, gpp, ap);
-    case G_PCANVASWIDGET: return GPpolygon (widget, gpn, gpp, ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Gsplinegon (int wi, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCsplinegon (widget, gpn, gpp, ap);
-    case G_PCANVASWIDGET: return GPsplinegon (widget, gpn, gpp, ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Garc (
-    int wi, Gpoint_t gc, Gsize_t gs, double ang1, double ang2, Ggattr_t *ap
-) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCarc (widget, gc, gs, ang1, ang2, ap);
-    case G_PCANVASWIDGET: return GParc (widget, gc, gs, ang1, ang2, ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Gtext (
-    int wi, char *string, Gpoint_t go, char *fn, double fs,
-    char *justs, Ggattr_t *ap
-) {
-    Gwidget_t *widget;
-    char js[2];
-    int n;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    if (strcmp(string, "") == 0)
-        return 0;
-    n = unpackstring (string);
-    if (!justs[0] || !justs[1])
-        js[0] = 'c', js[1] = 'c';
-    else {
-        js[0] = justs[0], js[1] = justs[1];
-        if (js[0] != 'l' && js[0] != 'c' && js[0] != 'r')
-            js[0] = 'c';
-        if (js[1] != 'd' && js[1] != 'b' && js[1] != 'c' && js[1] != 'u')
-            js[1] = 'c';
-    }
-    switch (widget->type) {
-    case G_CANVASWIDGET:
-        return GCtext (widget, &tlarray[0], n, go, fn, fs, &js[0], ap);
-    case G_PCANVASWIDGET:
-        return GPtext (widget, &tlarray[0], n, go, fn, fs, &js[0], ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Ggettextsize (int wi, char *string, char *fn, double fs, Gsize_t *gsp) {
-    Gwidget_t *widget;
-    int n;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    if (widget->type != G_CANVASWIDGET) {
-        Gerr (POS, G_ERRNOTACANVAS, wi);
-        return -1;
-    }
-    if (strcmp(string, "") == 0) {
-        gsp->x = gsp->y = 0.0;
-        return 0;
-    }
-    n = unpackstring (string);
-    return GCgettextsize (widget, &tlarray[0], n, fn, fs, gsp);
-}
-
-int Gcreatebitmap (int wi, Gsize_t s) {
-    Gwidget_t *widget;
-    Gbitmap_t *bitmap;
-    int rtn;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADPARENTWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    if (widget->type != G_CANVASWIDGET && widget->type != G_PCANVASWIDGET) {
-        Gerr (POS, G_ERRNOTACANVAS, wi);
-        return -1;
-    }
-    bitmap = newbitmap ();
-    bitmap->inuse = TRUE;
-    bitmap->canvas = wi;
-    rtn = -1;
-    switch (widget->type) {
-    case G_CANVASWIDGET:  rtn = GCcreatebitmap (widget, bitmap, s); break;
-    case G_PCANVASWIDGET: rtn = GPcreatebitmap (widget, bitmap, s); break;
-    }
-    if (rtn == -1) {
-        bitmap->inuse = FALSE;
-        return -1;
-    }
-    return bitmap - &Gbitmaps[0];
-}
-
-int Gdestroybitmap (int bi) {
-    Gbitmap_t *bitmap;
-
-    if (bi < 0 || bi > Gbitmapn || !Gbitmaps[bi].inuse) {
-        Gerr (POS, G_ERRBADBITMAPID, bi);
-        return -1;
-    }
-    bitmap = &Gbitmaps[bi];
-    switch (bitmap->ctype) {
-    case G_CANVASWIDGET:  GCdestroybitmap (bitmap); break;
-    case G_PCANVASWIDGET: GPdestroybitmap (bitmap); break;
-    }
-    bitmap->inuse = FALSE;
-    return 0;
-}
-
-int Greadbitmap (int wi, FILE *fp) {
-    Gwidget_t *widget;
-    Gbitmap_t *bitmap;
-    int rtn;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADPARENTWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    if (widget->type != G_CANVASWIDGET && widget->type != G_PCANVASWIDGET) {
-        Gerr (POS, G_ERRNOTACANVAS, wi);
-        return -1;
-    }
-    bitmap = newbitmap ();
-    bitmap->inuse = TRUE;
-    bitmap->canvas = wi;
-    rtn = -1;
-    switch (widget->type) {
-    case G_CANVASWIDGET:  rtn = GCreadbitmap (widget, bitmap, fp); break;
-    case G_PCANVASWIDGET: rtn = GPreadbitmap (widget, bitmap, fp); break;
-    }
-    if (rtn == -1) {
-        bitmap->inuse = FALSE;
-        return -1;
-    }
-    return bitmap - &Gbitmaps[0];
-}
-
-int Gwritebitmap (FILE *fp, int bi) {
-    Gbitmap_t *bitmap;
-    int rtn;
-
-    if (bi < 0 || bi > Gbitmapn || !Gbitmaps[bi].inuse) {
-        Gerr (POS, G_ERRBADBITMAPID, bi);
-        return -1;
-    }
-    bitmap = &Gbitmaps[bi];
-    rtn = -1;
-    switch (bitmap->ctype) {
-    case G_CANVASWIDGET:  rtn = GCwritebitmap (bitmap, fp); break;
-    case G_PCANVASWIDGET: rtn = GPwritebitmap (bitmap, fp); break;
-    }
-    if (rtn == -1)
-        return -1;
-    return 0;
-}
-
-int Gbitblt (
-    int wi, Gpoint_t gp, Grect_t gr, int bi, char *mode, Ggattr_t *ap
-) {
-    Gwidget_t *widget;
-    Gbitmap_t *bitmap;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    if (bi < 0 || bi > Gbitmapn || !Gbitmaps[bi].inuse) {
-        Gerr (POS, G_ERRBADBITMAPID, bi);
-        return -1;
-    }
-    bitmap = &Gbitmaps[bi];
-    switch (widget->type) {
-    case G_CANVASWIDGET:  return GCbitblt (widget, gp, gr, bitmap, mode, ap);
-    case G_PCANVASWIDGET: return GPbitblt (widget, gp, gr, bitmap, mode, ap);
-    }
-    Gerr (POS, G_ERRNOTACANVAS, wi);
-    return -1;
-}
-
-int Ggetmousecoords (int wi, Gpoint_t *gsp, int *count) {
-    Gwidget_t *widget;
-
-    if (wi < 0 || wi > Gwidgetn || !Gwidgets[wi].inuse) {
-        Gerr (POS, G_ERRBADWIDGETID, wi);
-        return -1;
-    }
-    widget = &Gwidgets[wi];
-    if (widget->type != G_CANVASWIDGET) {
-        Gerr (POS, G_ERRNOTACANVAS, wi);
-        return -1;
-    }
-    return GCgetmousecoords (widget, gsp, count);
-}
-
-Gwidget_t *newwidget (int type) {
-    Gwidget_t *new;
-    int wi;
-
-    for (wi = 0; wi < Gwidgetn; wi++)
-        if (!Gwidgets[wi].inuse)
-            goto found;
-
-    Gwidgets = Marraygrow (
-        Gwidgets, (long) (Gwidgetn + WIDGETINCR) * WIDGETSIZE
-    );
-    for (wi = Gwidgetn; wi < Gwidgetn + WIDGETINCR; wi++)
-        Gwidgets[wi].inuse = FALSE;
-    wi = Gwidgetn, Gwidgetn += WIDGETINCR;
-
-found:
-    new = &Gwidgets[wi];
-    new->type = type;
-    new->w = 0;
-    new->udata = 0;
-    /* HACK: should do a switch on type, but ... */
-    if (!(new->u.c = malloc (wsizes[type])))
-        panic1 (POS, "newwidget", "cannot allocate data");
-    return new;
-}
-
-Gwidget_t *findwidget (uint64_t w, int type) {
-    int wi;
-
-    if (type == G_WTYPESIZE) {
-        for (wi = 0; wi < Gwidgetn; wi++)
-            if (Gwidgets[wi].inuse && (uint64_t) Gwidgets[wi].w == w)
-                return &Gwidgets[wi];
-    } else {
-        for (wi = 0; wi < Gwidgetn; wi++)
-            if (
-                Gwidgets[wi].inuse && Gwidgets[wi].type == type &&
-                (uint64_t) Gwidgets[wi].w == w
-            )
-                return &Gwidgets[wi];
-    }
-    return NULL;
-}
-
-Gbitmap_t *newbitmap (void) {
-    Gbitmap_t *new;
-    int bi;
-
-    for (bi = 0; bi < Gbitmapn; bi++)
-        if (!Gbitmaps[bi].inuse)
-            goto found;
-
-    Gbitmaps = Marraygrow (
-        Gbitmaps, (long) (Gbitmapn + BITMAPINCR) * BITMAPSIZE
-    );
-    for (bi = Gbitmapn; bi < Gbitmapn + BITMAPINCR; bi++)
-        Gbitmaps[bi].inuse = FALSE;
-    bi = Gbitmapn, Gbitmapn += BITMAPINCR;
-
-found:
-    new = &Gbitmaps[bi];
-    return new;
-}
-
-void Gerr (char *file, int line, int errnum, ...) {
-    va_list args;
-
-#ifdef FEATURE_X11
-    if (!Gerrflag)
-        return;
-
-    va_start(args, errnum);
-    fprintf (stderr, "warning: (file %s, line %d) ", file, line);
-    vfprintf (stderr, errmsg[errnum], args);
-    fprintf (stderr, "\n");
-    va_end(args);
-#else
-#ifdef FEATURE_WIN32
-    char buf[256];
-
-    if (!warnflag)
-        return;
-
-    va_start(args, errnum);
-    vsprintf (buf, errmsg[errnum], args);
-    Gnocallbacks = true;
-    MessageBox ((HWND) NULL, buf, "Lefty Warning", MB_APPLMODAL);
-    Gnocallbacks = false;
-    va_end(args);
-#endif
-#endif
-}
-
-static int unpackstring (char *s) {
-    char *p1, *p2;
-    int n;
-
-    if ((n = strlen (s) + 1) > textn)
-        textn = n, texts = Marraygrow (texts, (long) textn);
-    strcpy (texts, s);
-    n = 0;
-    p1 = p2 = texts;
-    tlarray[0].p = p1;
-    while (*p1) {
-        if (p1[0] == '\\') {
-            if (p1[1] == 'n' || p1[1] == 'l' || p1[1] == 'r') {
-                tlarray[n].n = p1 - tlarray[n].p;
-                tlarray[n].j = p1[1];
-                tlarray[++n].p = (p1 += 2);
-            } else {
-                for (p2 = p1 + 1; *p2; p2++)
-                    p2[-1] = p2[0];
-                p2[-1] = 0;
-                p1++;
-            }
-        } else
-            p1++;
-    }
-    if ((tlarray[n].n = p1 - tlarray[n].p) > 0)
-        tlarray[n++].j = 'n';
-    return n;
-}
diff --git a/cmd/lefty/g.h b/cmd/lefty/g.h
deleted file mode 100644 (file)
index f61ac67..0000000
+++ /dev/null
@@ -1,544 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#ifdef FEATURE_X11
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-#include <X11/Shell.h>
-#include <X11/cursorfont.h>
-#include <X11/Xaw/Viewport.h>
-#include <X11/Xaw/Text.h>
-#include <X11/Xaw/AsciiText.h>
-#include <X11/Xaw/Command.h>
-#include <X11/Xaw/Dialog.h>
-#include <X11/Xaw/SimpleMenu.h>
-#include <X11/Xaw/SmeBSB.h>
-#include <X11/Xmu/CurUtil.h>
-#ifdef FEATURE_GMAP
-#ifdef FEATURE_MESAGL
-#include <GL/GLwDrawA.h>
-#else
-#include <X11/GLw/GLwDrawA.h>
-#endif
-#include <Performer/pf.h>
-#endif
-#endif
-
-/* general coordinate structures */
-
-typedef struct Gxy_t {
-    double x, y;
-} Gxy_t;
-typedef Gxy_t Gpoint_t;
-typedef Gxy_t Gsize_t;
-typedef struct Grect_t {
-    Gxy_t o, c;
-} Grect_t;
-
-/* textline structure */
-typedef struct Gtextline_t {
-    char *p;
-    int n, j;
-    int w, h;
-} Gtextline_t;
-
-/* Color structure */
-
-typedef struct Gcolor_t {
-    int index;
-    int r, g, b;
-} Gcolor_t;
-#define G_MAXCOLORS 256
-
-/* event structures */
-
-/* event consumption modes */
-#define G_ONEEVENT   0
-#define G_MANYEVENTS 1
-
-/* event types and main structure */
-#define G_MOUSE 0
-#define G_KEYBD 1
-
-#define G_DOWN 0
-#define G_UP   1
-#define G_MOVE 2
-#define G_LEFT    0
-#define G_MIDDLE  1
-#define G_RIGHT   2
-#define G_BUTTON3 3
-#define G_BUTTON4 4
-typedef struct Gevent_t {
-    int type;
-    int wi;
-    int code;
-    int data;
-    Gpoint_t p;
-} Gevent_t;
-
-/* Widgets */
-
-/* minimum widget sizes */
-#define MINVWSIZE 100
-#define MINTWSIZE 40
-#define MINBWSIZE 40
-#define MINLWSIZE 25
-#define MINAWSIZE 25
-#define MINSWSIZE 40
-#define MINCWSIZE 100
-#define MINPWSIZE 100
-
-/* gfx attributes for the [p]canvas widget */
-
-/* drawing styles */
-#define G_SOLID       0
-#define G_DASHED      1
-#define G_DOTTED      2
-#define G_LONGDASHED  3
-#define G_SHORTDASHED 4
-
-/* drawing modes */
-#ifdef FEATURE_X11
-#define G_SRC GXcopy
-#define G_XOR GXxor
-#else
-#ifdef FEATURE_WIN32
-#define G_SRC R2_COPYPEN
-#define G_XOR R2_NOT
-#else
-#define G_SRC 0
-#define G_XOR 1
-#endif
-#endif
-
-/* gfx attributes and the attribute structure */
-#define G_GATTRCOLOR  1
-#define G_GATTRWIDTH  2
-#define G_GATTRMODE   4
-#define G_GATTRFILL   8
-#define G_GATTRSTYLE 16
-
-typedef struct Ggattr_t {
-    int flags;
-    int color;
-    int width;
-    int mode;
-    int fill;
-    int style;
-} Ggattr_t;
-
-/* widget attributes structures */
-
-#define G_ATTRTYPEINT     0
-#define G_ATTRTYPELONG    1
-#define G_ATTRTYPEFLOAT   2
-#define G_ATTRTYPEDOUBLE  3
-#define G_ATTRTYPETEXT    4
-#define G_ATTRTYPEPOINT   5
-#define G_ATTRTYPESIZE    6
-#define G_ATTRTYPERECT    7
-#define G_ATTRTYPECOLOR   8
-#define G_ATTRTYPEFUNC    9
-#define G_ATTRTYPEULONG  10
-
-typedef struct Gwattrmap_t {
-    int id;
-    int type;
-    char *name;
-} Gwattrmap_t;
-typedef struct Gwattr_t {
-    int id;
-    union {
-        int i;
-        long l;
-        float f;
-        double d;
-        char *t;
-        Gpoint_t p;
-        Gsize_t s;
-        Grect_t r;
-        Gcolor_t c;
-        void *func;
-        uint64_t u;
-    } u;
-} Gwattr_t;
-typedef struct Gwlist_t {
-    int wid;
-    char *wname;
-    int *attrid;
-} Gwlist_t;
-
-/* attribute ids */
-#define G_ATTRORIGIN       0
-#define G_ATTRSIZE         1
-#define G_ATTRBORDERWIDTH  2
-#define G_ATTRNAME         3
-#define G_ATTRTEXT         4
-#define G_ATTRAPPENDTEXT   5
-#define G_ATTRSELECTION    6
-#define G_ATTRCURSOR       7
-#define G_ATTRMODE         8
-#define G_ATTRLAYOUT       9
-#define G_ATTRZORDER      10
-#define G_ATTRCOLOR       11
-#define G_ATTRVIEWPORT    12
-#define G_ATTRWINDOW      13
-#define G_ATTRWINDOWID    14
-#define G_ATTRCHILDCENTER 15
-#define G_ATTRNEWLINECB   16
-#define G_ATTRRESIZECB    17
-#define G_ATTRBUTTONCB    18
-#define G_ATTREVENTCB     19
-#define G_ATTRUSERDATA    20
-
-/* array widget structs */
-typedef struct Gawcarray_t {
-#ifdef FEATURE_X11
-    Widget w;
-#else
-#ifdef FEATURE_WIN32
-    HWND w;
-#else
-    int w;
-#endif
-#endif
-    int flag;
-    int ox, oy, sx, sy, bs;
-} Gawcarray_t;
-#define AWCARRAYINCR 10
-#define AWCARRAYSIZE sizeof (Gawcarray_t)
-
-#define G_AWHARRAY 1
-#define G_AWVARRAY 2
-typedef struct Gawdata_t {
-    int type;
-    int sx, sy;
-    Gawcarray_t *carray;
-    int cj, cn;
-#ifdef FEATURE_WIN32
-    int batchmode, working;
-#endif
-} Gawdata_t;
-
-/* query widget macros */
-#define G_QWSTRING 1 /* string query */
-#define G_QWFILE   2 /* file query */
-#define G_QWCHOICE 3 /* choose 1 query */
-#define G_QWMODES 3 /* total number of modes */
-
-/* widget callbacks */
-typedef void (*Gtwnewlinecb) (int, char *);
-typedef void (*Gbuttoncb) (int, void *);
-typedef void (*Glabelcb) (Gevent_t *);
-typedef void (*Gcanvascb) (Gevent_t *);
-typedef void (*Gawordercb) (void *, Gawdata_t *);
-typedef void (*Gawcoordscb) (int, Gawdata_t *);
-typedef void (*Gviewcb) (Gevent_t *);
-
-#define G_ARRAYWIDGET    0
-#define G_BUTTONWIDGET   1
-#define G_CANVASWIDGET   2
-#define G_LABELWIDGET    3
-#define G_MENUWIDGET     4
-#define G_PCANVASWIDGET  5
-#define G_QUERYWIDGET    6
-#define G_SCROLLWIDGET   7
-#define G_TEXTWIDGET     8
-#define G_VIEWWIDGET     9
-#define G_WTYPESIZE     10
-
-/* predefined widgets */
-
-/* --- array --- */
-typedef struct Gaw_t {
-    Gawcoordscb func;
-    int mode;
-#ifdef FEATURE_WIN32
-    Gawdata_t data;
-#endif
-} Gaw_t;
-#define AWSIZE sizeof (Gaw_t)
-
-/* --- button --- */
-typedef struct Gbw_t {
-    Gbuttoncb func;
-} Gbw_t;
-#define BWSIZE sizeof (Gbw_t)
-
-/* --- canvas --- */
-typedef struct Gcw_t {
-    int needredraw;
-    int buttonsdown;
-    char bstate[5];
-    struct Gcwcolor_t {
-        int inuse;
-#ifdef FEATURE_X11
-        XColor color;
-#else
-#ifdef FEATURE_WIN32
-        PALETTEENTRY color;
-#endif
-#endif
-    } colors[G_MAXCOLORS];
-    char allocedcolor[2];
-    Ggattr_t gattr, defgattr;
-    Grect_t wrect;
-    Gsize_t vsize;
-    Grect_t clip;
-    Gcanvascb func;
-#ifdef FEATURE_X11
-    Window window;
-    Colormap cmap;
-    GC gc;
-    Pixmap grays[17];
-    XFontStruct *font;
-#else
-#ifdef FEATURE_WIN32
-    HPALETTE cmap;
-    HDC gc;
-    HBRUSH grays[17];
-    HFONT font;
-    int ncolor;
-#endif
-#endif
-#ifdef FEATURE_GMAP
-    int gmapmode;
-#endif
-} Gcw_t;
-#define CWSIZE sizeof (Gcw_t)
-
-/* --- label --- */
-typedef struct Glw_t {
-    Glabelcb func;
-} Glw_t;
-#define LWSIZE sizeof (Glw_t)
-
-/* --- menu --- */
-typedef struct Gmw_t {
-    long count;
-} Gmw_t;
-#define MWSIZE sizeof (Gmw_t)
-
-/* --- postscript --- */
-typedef struct Gpw_t {
-#ifdef FEATURE_X11
-    FILE *fp;
-    struct Gpwcolor_t {
-        int inuse;
-        int r, g, b;
-        double nr, ng, nb;
-    } colors[G_MAXCOLORS];
-    Ggattr_t gattr, defgattr;
-    Grect_t wrect;
-    Gsize_t vsize;
-#else
-#ifdef FEATURE_WIN32
-    struct Gpwcolor_t {
-        int inuse;
-        PALETTEENTRY color;
-    } colors[G_MAXCOLORS];
-    Ggattr_t gattr, defgattr;
-    Grect_t wrect;
-    Gsize_t vsize;
-    HPALETTE cmap;
-    HDC gc;
-    HBRUSH grays[17];
-    HFONT font;
-    int ncolor, mode;
-#else
-    int dummy;
-#endif
-#endif
-} Gpw_t;
-#define PWSIZE sizeof (Gpw_t)
-
-/* --- query --- */
-typedef struct Gqw_t {
-#ifdef FEATURE_X11
-    Widget w;
-#else
-#ifdef FEATURE_WIN32
-    HWND w;
-#endif
-#endif
-    int mode;
-    int state, button;
-} Gqw_t;
-#define QWSIZE sizeof (Gqw_t)
-
-/* --- scroll --- */
-typedef struct Gsw_t {
-    int dummy;
-} Gsw_t;
-#define SWSIZE sizeof (Gsw_t)
-
-/* --- text --- */
-typedef struct Gtw_t {
-    Gtwnewlinecb func;
-} Gtw_t;
-#define TWSIZE sizeof (Gtw_t)
-
-/* --- view --- */
-typedef struct Gvw_t {
-    Gviewcb func;
-    int closing;
-} Gvw_t;
-#define VWSIZE sizeof (Gvw_t)
-
-/* the main widget structure */
-typedef struct Gwidget_t {
-    int type;
-    int inuse;
-    int pwi;
-#ifdef FEATURE_X11
-    Widget w;
-#else
-#ifdef FEATURE_WIN32
-    HWND w;
-#else
-    int w;
-#endif
-#endif
-    union {
-        Gaw_t *a;
-        Gbw_t *b;
-        Gcw_t *c;
-        Glw_t *l;
-        Gmw_t *m;
-        Gpw_t *p;
-        Gqw_t *q;
-        Gsw_t *s;
-        Gtw_t *t;
-        Gvw_t *v;
-    } u;
-    uint64_t udata;
-} Gwidget_t;
-#define WIDGETINCR 20
-#define WIDGETSIZE sizeof (Gwidget_t)
-
-/* bitmap data structure */
-typedef struct Gbitmap_t {
-    int inuse;
-    int canvas;
-    int ctype; /* type of canvas, eg. G_CANVASWIDGET */
-    Gsize_t size;
-    Gsize_t scale;
-    union {
-        struct {
-#ifdef FEATURE_X11
-            Pixmap orig, scaled;
-#else
-#ifdef FEATURE_WIN32
-            HBITMAP orig, scaled;
-#else
-            int dummy;
-#endif
-#endif
-        } bmap;
-        unsigned char *bits;
-    } u;
-} Gbitmap_t;
-
-extern Gbitmap_t *Gbitmaps;
-extern int Gbitmapn;
-
-/* global array of widgets */
-extern Gwidget_t *Gwidgets;
-extern int Gwidgetn;
-
-extern Gwlist_t Gwlist[];
-extern Gwattrmap_t Gwattrmap[];
-
-extern char *Gdefaultfont;
-extern int Gneedredraw;
-extern int Gbuttonsdown;
-extern int Gerrflag;
-extern char *Gpscanvasname;
-
-extern int Gxfd;
-
-#ifdef FEATURE_WIN32
-extern int Gnocallbacks;
-#endif
-
-/* functions returning an int
-    return -1 if there's an error
-
-    the rendering functions may return +1
-    if the graphical object is completely hidden
-*/
-int Ginit (void);
-int Gterm (void);
-int Gcreatewidget (int, int, int, Gwattr_t *);
-int Gsetwidgetattr (int, int, Gwattr_t *);
-int Ggetwidgetattr (int, int, Gwattr_t *);
-int Gdestroywidget (int);
-int Gqueryask (int, char *, char *, char *, int);
-int Gmenuaddentries (int, int, char **);
-int Gmenudisplay (int, int);
-int Gsync (void);
-int Gresetbstate (int);
-int Gcanvasclear (int);
-int Gsetgfxattr (int, Ggattr_t *);
-int Ggetgfxattr (int, Ggattr_t *);
-int Garrow (int, Gpoint_t, Gpoint_t, Ggattr_t *);
-int Gline (int, Gpoint_t, Gpoint_t, Ggattr_t *);
-int Gbox (int, Grect_t, Ggattr_t *);
-int Gpolygon (int, int, Gpoint_t *, Ggattr_t *);
-int Gsplinegon (int, int, Gpoint_t *, Ggattr_t *);
-int Garc (int, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
-int Gtext (int, char *, Gpoint_t, char *, double, char *, Ggattr_t *);
-int Ggettextsize (int, char *, char *, double, Gsize_t *);
-int Gcreatebitmap (int, Gsize_t);
-int Gdestroybitmap (int);
-int Greadbitmap (int, FILE *);
-int Gwritebitmap (FILE *, int);
-int Gbitblt (int, Gpoint_t, Grect_t, int, char *, Ggattr_t *);
-int Ggetmousecoords (int, Gpoint_t *, int *);
-
-int Gprocessevents (int, int);
-
-int Gaworder (Gwidget_t *, void *, Gawordercb);
-int Gawsetmode (Gwidget_t *, int);
-int Gawgetmode (Gwidget_t *);
-void Gawdefcoordscb (int, Gawdata_t *);
-
-Gwidget_t *newwidget (int);
-Gwidget_t *findwidget (uint64_t, int);
-Gbitmap_t *newbitmap (void);
-void Gerr (char *, int, int, ...);
-
-/* error messages */
-#define G_ERRBADATTRID           1
-#define G_ERRBADATTRVALUE        2
-#define G_ERRBADCOLORINDEX       3
-#define G_ERRBADPARENTWIDGETID   4
-#define G_ERRBADWIDGETID         5
-#define G_ERRBADWIDGETTYPE       6
-#define G_ERRCANNOTCREATEWIDGET  7
-#define G_ERRCANNOTGETATTR       8
-#define G_ERRCANNOTOPENFILE      9
-#define G_ERRCANNOTSETATTR1     10
-#define G_ERRCANNOTSETATTR2     11
-#define G_ERRINITFAILED         12
-#define G_ERRNOCHILDWIDGET      13
-#define G_ERRNOPARENTWIDGET     14
-#define G_ERRNOSUCHCURSOR       15
-#define G_ERRNOTACANVAS         16
-#define G_ERRNOTIMPLEMENTED     17
-#define G_ERRNOTSUPPORTED       18
-#define G_ERRBADBITMAPID        19
-#define G_ERRCANNOTCREATEBITMAP 20
-#define G_ERRNOBITMAP           21
-#define G_ERRCANNOTREADBITMAP   22
diff --git a/cmd/lefty/gfxview.c b/cmd/lefty/gfxview.c
deleted file mode 100644 (file)
index eaef130..0000000
+++ /dev/null
@@ -1,1787 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include <cgraph/exit.h>
-#include "common.h"
-#include "g.h"
-#include "mem.h"
-#include "leftyio.h"
-#include "code.h"
-#include "tbl.h"
-#include "parse.h"
-#include "exec.h"
-#include "gfxview.h"
-#include <math.h>
-
-#define max(a, b) (((a) >= (b)) ? (a) : (b))
-#define min(a, b) (((a) >= (b)) ? (b) : (a))
-
-#define getwintnset(to) \
-    if (getint (to, &wattrp[wattri].u.i) != -1) wattri++;
-#define getwpointnset(to) \
-    if (getxy (to, &wattrp[wattri].u.p) != -1) wattri++;
-#define getwsizenset(to) \
-    if (getxy (to, &wattrp[wattri].u.s) != -1) wattri++;
-#define getwrectnset(to) \
-    if (getrect (to, &wattrp[wattri].u.r) != -1) wattri++;
-#define getwstrnset(to) \
-    if (getstr (to, &wattrp[wattri].u.t) != -1) wattri++;
-#define getwcolornset(ko, vo) \
-    if (getcolor (ko, vo, &wattrp[wattri].u.c) != -1) wattri++;
-
-#define getaintnset(to, n, flag) \
-    if (to) { \
-        getint (to, &n), dp->flags |= flag; \
-    }
-#define getastrnset(to, s, flag) \
-    if (to) \
-        getstr (to, &s), dp->flags |= flag;
-
-typedef struct colorname_t {
-    char *name;
-    unsigned char r, g, b;
-} colorname_t;
-
-#include "colors.txt"
-
-typedef struct gfxrect_t {
-    struct gfxrect_t *next;
-    Tobj ko;
-    Grect_t r;
-} gfxrect_t;
-typedef struct gfxmenu_t {
-    struct gfxmenu_t *next;
-    Tobj ko;
-    long time;
-    int mi;
-} gfxmenu_t;
-#define LISTSIZE 100
-typedef struct gfxnode_t {
-    int inuse;
-    int wi;
-    Tobj plvo, pmvo, prvo, pb3vo, pb4vo, pkvo[256];
-    Gpoint_t plp, pmp, prp, pb3p, pb4p, pkp[256];
-    char ls, ms, rs, b3s, b4s, ks[256];
-    struct gfxrect_t *rect[LISTSIZE];
-    struct gfxmenu_t *menu[LISTSIZE];
-} gfxnode_t;
-#define GFXNODEINCR 20
-#define GFXNODESIZE sizeof (gfxnode_t)
-static gfxnode_t *gfxnodes;
-static int gfxnoden;
-
-#define ISAWIDGET(wi) (wi >= 0 && wi < Gwidgetn && Gwidgets[wi].inuse)
-#define ISALABEL(wi) (Gwidgets[wi].type == G_LABELWIDGET)
-#define ISACANVAS(wi) (Gwidgets[wi].type == G_CANVASWIDGET)
-#define ISACANVAS2(wi) ( \
-    Gwidgets[wi].type == G_CANVASWIDGET || \
-    Gwidgets[wi].type == G_PCANVASWIDGET \
-)
-#define NODEID(wi) Gwidgets[wi].udata
-#define ISABITMAP(bi) (bi >= 0 && bi < Gbitmapn && Gbitmaps[bi].inuse)
-
-static Gpoint_t *gpp = NULL;
-static long gpn = 0;
-#define GPINCR 100
-#define GPSIZE sizeof (Gpoint_t)
-
-static Gwattr_t *wattrp = NULL;
-static int wattrn = 0;
-static int wattri = 0;
-#define WATTRINCR 10
-#define WATTRSIZE sizeof (Gwattr_t)
-
-static Tobj rootwo, rootbo;
-
-static void nodeinit (int);
-static void nodeterm (int);
-static void rectinit (int);
-static void rectterm (int);
-static void rectinsert (int, Tobj, Grect_t);
-static void rectmerge (int, Tobj, Grect_t);
-static Tobj rectfind (int, Gpoint_t);
-static void rectdelete (int, Tobj);
-static void rectprune (int);
-static void menuinsert (int, Tobj, long, int);
-static int menufind (int, Tobj, long);
-static void menuprune (int);
-static int scanhsv (char *, float *, float *, float *);
-static void hsv2rgb (float, float, float, Gcolor_t *);
-
-static int getwattr (Tobj, int *);
-static int getgattr (Tobj, Ggattr_t *);
-static int getrect (Tobj, Grect_t *);
-static int getxy (Tobj, Gxy_t *);
-static int getint (Tobj, int *);
-static int getdouble (Tobj, double *);
-static int getstr (Tobj, char **);
-static int getcolor (Tobj, Tobj, Gcolor_t *);
-
-void GFXinit (void) {
-    int ni;
-
-    Tinss (root, "widgets", (rootwo = Ttable (100)));
-    Tinss (root, "bitmaps", (rootbo = Ttable (100)));
-    gfxnodes = Marrayalloc ((long) GFXNODEINCR * GFXNODESIZE);
-    gfxnoden = GFXNODEINCR;
-    for (ni = 0; ni < gfxnoden; ni++)
-        gfxnodes[ni].inuse = FALSE;
-    gpp = Marrayalloc ((long) GPINCR * GPSIZE);
-    gpn = GPINCR;
-    wattrp = Marrayalloc ((long) WATTRINCR * WATTRSIZE);
-    wattrn = WATTRINCR, wattri = 0;
-}
-
-void GFXterm (void) {
-    int ni;
-
-    Marrayfree (wattrp), wattrp = NULL, wattrn = 0;
-    Marrayfree (gpp), gpp = NULL, gpn = 0;
-    for (ni = 0; ni < gfxnoden; ni++) {
-        if (gfxnodes[ni].inuse) {
-            Gdestroywidget (gfxnodes[ni].wi);
-            nodeterm (ni);
-            gfxnodes[ni].inuse = FALSE;
-        }
-    }
-    Marrayfree (gfxnodes), gfxnodes = NULL, gfxnoden = 0;
-    Tdels (root, "bitmaps");
-    Tdels (root, "widgets");
-}
-
-/* callback for mem.c module - removes dead objects from gfxnodes */
-void GFXprune (void) {
-    gfxnode_t *np;
-    int ni, ki;
-
-    for (ni = 0; ni < gfxnoden; ni++) {
-        np = &gfxnodes[ni];
-        if (np->inuse) {
-            rectprune (ni), menuprune (ni);
-            if (np->plvo && !M_AREAOF (np->plvo))
-                np->plvo = 0;
-            if (np->pmvo && !M_AREAOF (np->pmvo))
-                np->pmvo = 0;
-            if (np->prvo && !M_AREAOF (np->prvo))
-                np->prvo = 0;
-            if (np->pb3vo && !M_AREAOF (np->pb3vo))
-                np->pb3vo = 0;
-            if (np->pb4vo && !M_AREAOF (np->pb4vo))
-                np->pb4vo = 0;
-            for (ki = 0; ki < 256; ki++)
-                if (np->pkvo[ki] && !M_AREAOF (np->pkvo[ki]))
-                    np->pkvo[ki] = 0;
-        }
-    }
-}
-
-/* callback for g.c module - calls the appropriate lefty function */
-void GFXlabelcb (Gevent_t *evp) {
-    Tobj fo, to, co, wo;
-    char *fn;
-    char s[2];
-    long fm;
-
-    fn = NULL;
-    wo = Tfindi (rootwo, evp->wi);
-    switch (evp->type) {
-    case G_MOUSE:
-        switch (evp->data) {
-        case G_LEFT:
-            fn = (evp->code == G_UP) ? "leftup" : "leftdown";
-            break;
-        case G_MIDDLE:
-            fn = (evp->code == G_UP) ? "middleup" : "middledown";
-            break;
-        case G_RIGHT:
-            fn = (evp->code == G_UP) ? "rightup" : "rightdown";
-            break;
-        }
-        break;
-    case G_KEYBD:
-        fn = (evp->code == G_UP) ? "keyup" : "keydown";
-        break;
-    }
-    if (!wo || !(fo = Tfinds (wo, fn)) || Tgettype (fo) != T_CODE)
-        if (!(fo = Tfinds (root, fn)) || Tgettype (fo) != T_CODE)
-            return;
-    fm = Mpushmark (fo);
-    to = Ttable (4);
-    Mpushmark (to);
-    Tinss (to, "widget", Tinteger (evp->wi));
-    if (evp->type == G_KEYBD)
-        s[0] = evp->data, s[1] = '\000', Tinss (to, "key", Tstring (s));
-    if ((co = Pfcall (fo, to)))
-        Eunit (co);
-    Mpopmark (fm);
-}
-
-/* callback for g.c module - calls the appropriate lefty function */
-void GFXviewcb (Gevent_t *evp) {
-    Tobj fo, to, co, wo;
-    char *fn;
-    long fm;
-
-    wo = Tfindi (rootwo, evp->wi);
-    fn = "closeview";
-    if (!wo || !(fo = Tfinds (wo, fn)) || Tgettype (fo) != T_CODE)
-        if (!(fo = Tfinds (root, fn)) || Tgettype (fo) != T_CODE)
-            graphviz_exit(0);
-    fm = Mpushmark (fo);
-    to = Ttable (2);
-    Mpushmark (to);
-    Tinss (to, "widget", Tinteger (evp->wi));
-    if ((co = Pfcall (fo, to)))
-        Eunit (co);
-    Mpopmark (fm);
-}
-
-/* callback for g.c module - calls the appropriate lefty function */
-void GFXevent (Gevent_t *evp) {
-    Tobj vo, pvo, fo, to, po, co, wo;
-    gfxnode_t *np;
-    Gpoint_t pp;
-    char *fn;
-    char s[2];
-    long fm;
-    int ni;
-
-    pp.x = pp.y = 0;
-    pvo = NULL;
-    fn = NULL;
-    ni = Gwidgets[evp->wi].udata;
-    np = &gfxnodes[ni];
-    wo = Tfindi (rootwo, evp->wi);
-    if (!(vo = rectfind (ni, evp->p)))
-        vo = null;
-    switch (evp->type) {
-    case G_MOUSE:
-        switch (evp->data) {
-        case G_LEFT:
-            if (evp->code == G_UP)
-                fn = "leftup", pvo = np->plvo, pp = np->plp, np->ls = 0;
-            else
-                fn = "leftdown", np->plvo = vo, np->plp = evp->p, np->ls = 1;
-            break;
-        case G_MIDDLE:
-            if (evp->code == G_UP)
-                fn = "middleup", pvo = np->pmvo, pp = np->pmp, np->ms = 0;
-            else
-                fn = "middledown", np->pmvo = vo, np->pmp = evp->p, np->ms = 1;
-            break;
-        case G_RIGHT:
-            if (evp->code == G_UP)
-                fn = "rightup", pvo = np->prvo, pp = np->prp, np->rs = 0;
-            else
-                fn = "rightdown", np->prvo = vo, np->prp = evp->p, np->rs = 1;
-            break;
-        case G_BUTTON3:
-            if (evp->code == G_UP) {
-                fn = "button3up";
-                pvo = np->pb3vo, pp = np->pb3p, np->b3s = 0;
-            } else {
-                fn = "button4down";
-                np->pb3vo = vo, np->pb3p = evp->p, np->b3s = 1;
-            }
-            break;
-        case G_BUTTON4:
-            if (evp->code == G_UP) {
-                fn = "button4up";
-                pvo = np->pb4vo, pp = np->pb4p, np->b4s = 0;
-            } else {
-                fn = "button4down";
-                np->pb4vo = vo, np->pb4p = evp->p, np->b4s = 1;
-            }
-            break;
-        }
-        break;
-    case G_KEYBD:
-        if (evp->code == G_UP) {
-            fn = "keyup";
-            pvo = np->pkvo[evp->data];
-            pp = np->pkp[evp->data];
-            np->ks[evp->data] = 0;
-        } else {
-            fn = "keydown";
-            np->pkvo[evp->data] = vo;
-            np->pkp[evp->data] = evp->p;
-            np->ks[evp->data] = 1;
-        }
-        break;
-    }
-    if (!wo || !(fo = Tfinds (wo, fn)) || Tgettype (fo) != T_CODE)
-        if (!(fo = Tfinds (root, fn)) || Tgettype (fo) != T_CODE)
-            return;
-
-    fm = Mpushmark (fo);
-    to = Ttable (4);
-    Mpushmark (to);
-    Tinss (to, "widget", Tinteger (evp->wi));
-    Tinss (to, "obj", vo);
-    Tinss (to, "pos", (po = Ttable (2)));
-    Tinss (po, "x", Treal (evp->p.x));
-    Tinss (po, "y", Treal (evp->p.y));
-    if (evp->code == G_UP) {
-        Tinss (to, "pobj", pvo);
-        Tinss (to, "ppos", (po = Ttable (2)));
-        Tinss (po, "x", Treal (pp.x));
-        Tinss (po, "y", Treal (pp.y));
-    }
-    if (evp->type == G_KEYBD)
-        s[0] = evp->data, s[1] = '\000', Tinss (to, "key", Tstring (s));
-    if ((co = Pfcall (fo, to)))
-        Eunit (co);
-    Mpopmark (fm);
-}
-
-/* called directly from lefty.c, when any button is held down */
-void GFXmove (void) {
-    gfxnode_t *np;
-    char *fn[5];
-    Tobj vo[5], fo, to, po, co, wo;
-    Gpoint_t cp, pp[5];
-    long fm;
-    int count, i, ni;
-
-    for (ni = 0; ni < gfxnoden; ni++) {
-        np = &gfxnodes[ni];
-        if (
-            !np->inuse || !ISACANVAS (np->wi) ||
-            !Gwidgets[np->wi].u.c->buttonsdown
-        )
-            continue;
-        wo = Tfindi (rootwo, np->wi);
-        Ggetmousecoords (np->wi, &cp, &count);
-        if (!count) {
-            Gresetbstate (np->wi);
-            continue;
-        }
-        if (np->ls)
-            fn[0] = "leftmove",   pp[0] = np->plp, vo[0] = np->plvo;
-        else
-            fn[0] = NULL;
-        if (np->ms)
-            fn[1] = "middlemove", pp[1] = np->pmp, vo[1] = np->pmvo;
-        else
-            fn[1] = NULL;
-        if (np->rs)
-            fn[2] = "rightmove",  pp[2] = np->prp, vo[2] = np->prvo;
-        else
-            fn[2] = NULL;
-        if (np->b3s)
-            fn[3] = "button3move",  pp[3] = np->pb3p, vo[3] = np->pb3vo;
-        else
-            fn[3] = NULL;
-        if (np->b4s)
-            fn[4] = "button4move",  pp[4] = np->pb4p, vo[4] = np->pb4vo;
-        else
-            fn[4] = NULL;
-        for (i = 0; i < 5; i++) {
-            if (!fn[i])
-                continue;
-            if (!wo || !(fo = Tfinds (wo, fn[i])) || Tgettype (fo) != T_CODE)
-                fo = Tfinds (root, fn[i]);
-            if (fo && Tgettype (fo) == T_CODE) {
-                fm = Mpushmark (fo);
-                to = Ttable (4);
-                Mpushmark (to);
-                Tinss (to, "widget", Tinteger (np->wi));
-                Tinss (to, "obj", vo[i]);
-                Tinss (to, "pos", (po = Ttable (2)));
-                Tinss (po, "x", Treal (cp.x));
-                Tinss (po, "y", Treal (cp.y));
-                Tinss (to, "ppos", (po = Ttable (2)));
-                Tinss (po, "x", Treal (pp[i].x));
-                Tinss (po, "y", Treal (pp[i].y));
-                if ((co = Pfcall (fo, to)))
-                    Eunit (co);
-                Mpopmark (fm);
-            }
-        }
-    }
-}
-
-/* called directly from lefty.c, when any canvas needs to be redrawn */
-void GFXredraw (void) {
-    gfxnode_t *np;
-    Tobj wo, fo, co, to;
-    long fm;
-    int ni;
-
-    for (ni = 0; ni < gfxnoden; ni++) {
-        np = &gfxnodes[ni];
-        if (
-            !np->inuse || !ISACANVAS (np->wi) ||
-            !Gwidgets[np->wi].u.c->needredraw
-        )
-            continue;
-        Gwidgets[np->wi].u.c->needredraw = FALSE;
-        wo = Tfindi (rootwo, np->wi);
-        if (!wo || !(fo = Tfinds (wo, "redraw")) || Tgettype (fo) != T_CODE)
-            if (!(fo = Tfinds (root, "redraw")) || Tgettype (fo) != T_CODE)
-                return;
-
-        fm = Mpushmark (fo);
-        to = Ttable (4);
-        Mpushmark (to);
-        Tinss (to, "widget", Tinteger (np->wi));
-        if ((co = Pfcall (fo, to)))
-            Eunit (co);
-        Mpopmark (fm);
-    }
-}
-
-static void GFXtextcb (int wi, char *s) {
-    Tobj wo, fo, co, to;
-    long fm;
-
-    if (!(wo = Tfindi (rootwo, wi)))
-        return;
-
-    if (!(fo = Tfinds (wo, "oneline")) || Tgettype (fo) != T_CODE)
-        return;
-
-    fm = Mpushmark (fo);
-    to = Ttable (4);
-    Mpushmark (to);
-    Tinss (to, "widget", Tinteger (wi));
-    Tinss (to, "text", Tstring (s));
-    if ((co = Pfcall (fo, to)))
-        Eunit (co);
-    Mpopmark (fm);
-}
-
-static void GFXbuttoncb (int wi, void *data) {
-    Tobj wo, fo, co, to;
-    long fm;
-
-    if (!(wo = Tfindi (rootwo, wi)))
-        return;
-
-    if (!(fo = Tfinds (wo, "pressed")) || Tgettype (fo) != T_CODE)
-        return;
-
-    fm = Mpushmark (fo);
-    to = Ttable (4);
-    Mpushmark (to);
-    Tinss (to, "widget", Tinteger (wi));
-    if ((co = Pfcall (fo, to)))
-        Eunit (co);
-    Mpopmark (fm);
-}
-
-static void GFXarrayresizecb (int wi, Gawdata_t *dp) {
-    Tobj wo, fo, co, so, to, lrtno, sxo, syo;
-    Tkvindex_t tkvi;
-    Gawcarray_t *cp;
-    int sx, sy, csx, csy, ci;
-    long fm;
-
-    if (!(wo = Tfindi (rootwo, wi)))
-        return;
-
-    if (!(fo = Tfinds (wo, "resize")) || Tgettype (fo) != T_CODE) {
-        Gawdefcoordscb (wi, dp);
-        return;
-    }
-
-    fm = Mpushmark (fo);
-    to = Ttable (4);
-    Mpushmark (to);
-    Tinss (to, "widget", Tinteger (wi));
-    Tinss (to, "size", (so = Ttable (2)));
-    Tinss (so, "x", Treal ((double) dp->sx));
-    Tinss (so, "y", Treal ((double) dp->sy));
-
-    lrtno = NULL;
-    if ((co = Pfcall (fo, to)))
-        lrtno = Eunit (co);
-    Mpopmark (fm);
-    if (!lrtno) {
-        Gawdefcoordscb (wi, dp);
-        return;
-    }
-    for (Tgetfirst (lrtno, &tkvi); tkvi.kvp; Tgetnext (&tkvi)) {
-        if (!T_ISNUMBER (tkvi.kvp->ko) || !T_ISTABLE ((so = tkvi.kvp->vo)))
-            continue;
-        wi = Tgetnumber (tkvi.kvp->ko);
-        if (!ISAWIDGET (wi))
-            continue;
-        for (ci = 0; ci < dp->cj; ci++) {
-            cp = &dp->carray[ci];
-            if (!cp->flag || cp->w != Gwidgets[wi].w)
-                continue;
-            if ((sxo = Tfinds (so, "x")) && T_ISNUMBER (sxo))
-                cp->sx = Tgetnumber (sxo);
-            if ((syo = Tfinds (so, "y")) && T_ISNUMBER (syo))
-                cp->sy = Tgetnumber (syo);
-            break;
-        }
-    }
-    sx = dp->sx, sy = dp->sy;
-    csx = csy = 0;
-    for (ci = 0; ci < dp->cj; ci++) {
-        cp = &dp->carray[ci];
-        if (!cp->flag)
-            continue;
-        cp->ox = csx, cp->oy = csy;
-        if (dp->type == G_AWVARRAY)
-            cp->sx = sx - 2 * cp->bs, csy += cp->sy + 2 * cp->bs;
-        else
-            cp->sy = sy - 2 * cp->bs, csx += cp->sx + 2 * cp->bs;
-    }
-    if (dp->type == G_AWVARRAY)
-        dp->sy = csy;
-    else
-        dp->sx = csx;
-}
-
-/* callback for when there is input on some file descriptor */
-void GFXmonitorfile (int fd) {
-    Tobj fo, to, co;
-    long fm, tm;
-
-    if (!(fo = Tfinds (root, "monitorfile")) || Tgettype (fo) != T_CODE)
-        return;
-
-    fm = Mpushmark (fo);
-    to = Ttable (4);
-    tm = Mpushmark (to);
-    Tinss (to, "fd", Tinteger (fd));
-    if ((co = Pfcall (fo, to)))
-        Eunit (co);
-    Mpopmark (tm);
-    Mpopmark (fm);
-}
-
-/* callback for when there is no X event and no file input */
-void GFXidle (void) {
-    Tobj fo, to, co;
-    long fm, tm;
-
-    if (!(fo = Tfinds (root, "idle")) || Tgettype (fo) != T_CODE)
-        return;
-
-    fm = Mpushmark (fo);
-    to = Ttable (4);
-    tm = Mpushmark (to);
-    if ((co = Pfcall (fo, to)))
-        Eunit (co);
-    Mpopmark (tm);
-    Mpopmark (fm);
-}
-
-/* LEFTY builtin */
-int GFXcreatewidget (int argc, lvar_t *argv) {
-    Tobj pwo, cwo, cho;
-    long rtnm;
-    int type, pwi, wi, ni;
-
-    type = -1;
-    if (getint (argv[0].o, &pwi) == -1 || getwattr (argv[1].o, &type) == -1)
-        return L_FAILURE;
-    if (type != G_VIEWWIDGET && type != G_PCANVASWIDGET && !ISAWIDGET (pwi))
-        return L_FAILURE;
-    if (type == G_CANVASWIDGET || type == G_LABELWIDGET) {
-        for (ni = 0; ni < gfxnoden; ni++)
-            if (!gfxnodes[ni].inuse)
-                break;
-        if (ni == gfxnoden) {
-            gfxnodes = Marraygrow (
-                gfxnodes, (long) (ni + GFXNODEINCR) * GFXNODESIZE
-            );
-            for (ni = gfxnoden; ni < gfxnoden + GFXNODEINCR; ni++)
-                gfxnodes[ni].inuse = FALSE;
-            ni = gfxnoden, gfxnoden += GFXNODEINCR;
-        }
-        nodeinit (ni);
-        if (wattri >= wattrn) {
-            wattrp = Marraygrow (
-                wattrp, (long) (wattrn + WATTRINCR) * WATTRSIZE
-            );
-            wattrn += WATTRINCR;
-        }
-        switch (type) {
-        case G_CANVASWIDGET:
-            wattrp[wattri].id = G_ATTRUSERDATA;
-            wattrp[wattri].u.u = ni, wattri++;
-            break;
-        case G_LABELWIDGET:
-            wattrp[wattri].id = G_ATTRUSERDATA;
-            wattrp[wattri].u.u = ni, wattri++;
-            break;
-        }
-        wi = gfxnodes[ni].wi = Gcreatewidget (pwi, type, wattri, wattrp);
-        gfxnodes[ni].inuse = TRUE;
-        goto done;
-    }
-    wi = Gcreatewidget (pwi, type, wattri, wattrp);
-
-done:
-    Tinsi (rootwo, wi, (cwo = Ttable (4)));
-    rtno = Tinteger (wi);
-    rtnm = Mpushmark (rtno);
-    if (pwi != -1) {
-        Tinss (cwo, "parent", Tinteger (pwi));
-        if ((pwo = Tfindi (rootwo, pwi))) {
-            if (!(cho = Tfinds (pwo, "children")))
-                Tinss (pwo, "children", (cho = Ttable (2)));
-            Tinsi (cho, wi, Tinteger (pwi));
-        }
-    }
-    Mpopmark (rtnm);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXsetwidgetattr (int argc, lvar_t *argv) {
-    int wi, type, rtn;
-
-    if (getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi))
-        return L_FAILURE;
-    type = Gwidgets[wi].type;
-    if ((rtn = getwattr (argv[1].o, &type)) == -1)
-        return L_FAILURE;
-    Gsetwidgetattr (wi, wattri, wattrp);
-    rtno = Tinteger (rtn);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXgetwidgetattr (int argc, lvar_t *argv) {
-    Tkvindex_t tkvi;
-    Tobj po, so, ro, co, co2;
-    Gwattrmap_t *mapp;
-    int *ap;
-    int li, ai, type, color, wattri2, wi;
-    long rtnm;
-
-    wattri = 0;
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) ||
-        !T_ISTABLE (argv[1].o)
-    )
-        return L_FAILURE;
-    type = Gwidgets[wi].type;
-    for (ap = NULL, li = 0; Gwlist[li].wname; li++) {
-        if (type == Gwlist[li].wid) {
-            ap = Gwlist[li].attrid;
-            break;
-        }
-    }
-    if (!ap)
-        return L_FAILURE;
-    for (Tgetfirst (argv[1].o, &tkvi); tkvi.kvp; Tgetnext (&tkvi)) {
-        if (!T_ISSTRING (tkvi.kvp->vo))
-            continue;
-        for (ai = 0; ap[ai] != -1; ai++) {
-            if (
-                strcmp (Gwattrmap[ap[ai]].name,
-                Tgetstring (tkvi.kvp->vo)) == 0
-            ) {
-                if (wattri >= wattrn) {
-                    wattrp = Marraygrow (
-                        wattrp, (long) (wattrn + WATTRINCR) * WATTRSIZE
-                    );
-                    wattrn += WATTRINCR;
-                }
-                if (ap[ai] == G_ATTRCOLOR) {
-                    for (color = 0; color < G_MAXCOLORS; color++) {
-                        if (wattri >= wattrn) {
-                            wattrp = Marraygrow (
-                                wattrp, (long) (wattrn + WATTRINCR) * WATTRSIZE
-                            );
-                            wattrn += WATTRINCR;
-                        }
-                        wattrp[wattri].u.c.index = color;
-                        wattrp[wattri++].id = ap[ai];
-                    }
-                } else
-                    wattrp[wattri++].id = ap[ai];
-                break;
-            }
-        }
-    }
-    if (Ggetwidgetattr (wi, wattri, wattrp) == -1)
-        return L_FAILURE;
-    rtno = Ttable (wattri);
-    rtnm = Mpushmark (rtno);
-    for (wattri2 = 0; wattri2 < wattri; wattri2++) {
-        mapp = &Gwattrmap[wattrp[wattri2].id];
-        switch (mapp->type) {
-        case G_ATTRTYPEPOINT:
-            Tinss (rtno, mapp->name, (po = Ttable (2)));
-            Tinss (po, "x", Treal (wattrp[wattri2].u.p.x));
-            Tinss (po, "y", Treal (wattrp[wattri2].u.p.y));
-            break;
-        case G_ATTRTYPESIZE:
-            Tinss (rtno, mapp->name, (so = Ttable (2)));
-            Tinss (so, "x", Treal (wattrp[wattri2].u.s.x));
-            Tinss (so, "y", Treal (wattrp[wattri2].u.s.y));
-            break;
-        case G_ATTRTYPERECT:
-            Tinss (rtno, mapp->name, (ro = Ttable (2)));
-            Tinsi (ro, 0, (po = Ttable (2)));
-            Tinss (po, "x", Treal (wattrp[wattri2].u.r.o.x));
-            Tinss (po, "y", Treal (wattrp[wattri2].u.r.o.y));
-            Tinsi (ro, 1, (po = Ttable (2)));
-            Tinss (po, "x", Treal (wattrp[wattri2].u.r.c.x));
-            Tinss (po, "y", Treal (wattrp[wattri2].u.r.c.y));
-            break;
-        case G_ATTRTYPETEXT:
-            Tinss (rtno, mapp->name, Tstring (wattrp[wattri2].u.t));
-            break;
-        case G_ATTRTYPEINT:
-            Tinss (rtno, mapp->name, Tinteger (wattrp[wattri2].u.i));
-            break;
-        case G_ATTRTYPECOLOR:
-            Tinss (rtno, mapp->name, (co = Ttable (G_MAXCOLORS)));
-            for (color = 0; color < G_MAXCOLORS; color++) {
-                Tinsi (co, color, (co2 = Ttable (3)));
-                Tinss (co2, "r", Treal (wattrp[wattri2 + color].u.c.r));
-                Tinss (co2, "g", Treal (wattrp[wattri2 + color].u.c.g));
-                Tinss (co2, "b", Treal (wattrp[wattri2 + color].u.c.g));
-            }
-            wattri2 += (G_MAXCOLORS - 1);
-            break;
-        }
-    }
-    Mpopmark (rtnm);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXdestroywidget (int argc, lvar_t *argv) {
-    Tkvindex_t tkvi;
-    Tobj wo, cho, pwio, pwo;
-    lvar_t argv2[1];
-    int wi;
-
-    if (getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi))
-        return L_FAILURE;
-
-    wo = Tfindi (rootwo, wi);
-    if ((cho = Tfinds (wo, "children"))) {
-        while (Tgettablen (cho) > 0) {
-            Tgetfirst (cho, &tkvi);
-            argv2[0].o = tkvi.kvp->ko;
-            GFXdestroywidget (1, argv2);
-        }
-    }
-    if ((pwio = Tfinds (wo, "parent"))) {
-        pwo = Tfindi (rootwo, Tgetinteger (pwio));
-        cho = Tfinds (pwo, "children");
-        Tdeli (cho, wi);
-    }
-    if (ISACANVAS (wi) || ISALABEL (wi)) {
-        nodeterm (NODEID (wi));
-        gfxnodes[NODEID (wi)].inuse = FALSE;
-    }
-    Gdestroywidget (wi);
-    Tdeli (rootwo, wi);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXclear (int argc, lvar_t *argv) {
-    int wi;
-
-    if (getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi))
-        return L_FAILURE;
-    Gcanvasclear (wi);
-    if (ISACANVAS (wi))
-        rectterm (NODEID (wi)), rectinit (NODEID (wi));
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXsetgfxattr (int argc, lvar_t *argv) {
-    Ggattr_t gattr;
-    int wi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) ||
-        getgattr (argv[1].o, &gattr) == -1
-    )
-        return L_FAILURE;
-    Gsetgfxattr (wi, &gattr);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXgetgfxattr (int argc, lvar_t *argv) {
-    Tkvindex_t tkvi;
-    Ggattr_t gattr;
-    long rtnm;
-    int wi;
-    char *s;
-
-    gattr.flags = 0;
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) ||
-        !T_ISTABLE (argv[1].o)
-    )
-        return L_FAILURE;
-
-    s = NULL;
-    for (Tgetfirst (argv[1].o, &tkvi); tkvi.kvp; Tgetnext (&tkvi)) {
-        if (!T_ISSTRING (tkvi.kvp->vo))
-            continue;
-        s = Tgetstring (tkvi.kvp->vo);
-        if (strcmp (s, "color") == 0)
-            gattr.flags |= G_GATTRCOLOR;
-        else if (strcmp (s, "width") == 0)
-            gattr.flags |= G_GATTRWIDTH;
-        else if (strcmp (s, "mode") == 0)
-            gattr.flags |= G_GATTRMODE;
-        else if (strcmp (s, "fill") == 0)
-            gattr.flags |= G_GATTRFILL;
-        else if (strcmp (s, "style") == 0)
-            gattr.flags |= G_GATTRSTYLE;
-    }
-    if (Ggetgfxattr (wi, &gattr) == -1)
-        return L_FAILURE;
-    rtno = Ttable (wattri);
-    rtnm = Mpushmark (rtno);
-    if (gattr.flags & G_GATTRCOLOR) {
-        Tinss (rtno, "color", Tinteger (gattr.color));
-    } else if (gattr.flags & G_GATTRWIDTH) {
-        Tinss (rtno, "width", Tinteger (gattr.width));
-    } else if (gattr.flags & G_GATTRMODE) {
-        s = (gattr.mode == G_SRC) ? "src" : "xor";
-        Tinss (rtno, "mode", Tstring (s));
-    } else if (gattr.flags & G_GATTRFILL) {
-        s = (gattr.fill) ? "on" : "off";
-        Tinss (rtno, "fill", Tstring (s));
-    } else if (gattr.flags & G_GATTRSTYLE) {
-        switch (gattr.style) {
-        case G_SOLID:       s = "solid";       break;
-        case G_DASHED:      s = "dashed";      break;
-        case G_DOTTED:      s = "dotted";      break;
-        case G_LONGDASHED:  s = "longdashed";  break;
-        case G_SHORTDASHED: s = "shortdashed"; break;
-        }
-        Tinss (rtno, "style", Tstring (s));
-    }
-    Mpopmark (rtnm);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXarrow (int argc, lvar_t *argv) {
-    Ggattr_t gattr;
-    Gpoint_t p0, p1;
-    int wi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getxy (argv[2].o, &p0) == -1 || getxy (argv[3].o, &p1) == -1 ||
-        getgattr ((argc == 5) ? argv[4].o : NULL, &gattr) == -1
-    )
-        return L_FAILURE;
-    Garrow (wi, p0, p1, &gattr);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXline (int argc, lvar_t *argv) {
-    Ggattr_t gattr;
-    Gpoint_t p0, p1;
-    int wi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getxy (argv[2].o, &p0) == -1 || getxy (argv[3].o, &p1) == -1 ||
-        getgattr ((argc == 5) ? argv[4].o : NULL, &gattr) == -1
-    )
-        return L_FAILURE;
-    Gline (wi, p0, p1, &gattr);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXbox (int argc, lvar_t *argv) {
-    Ggattr_t gattr;
-    Grect_t r;
-    int wi, rtn;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getrect (argv[2].o, &r) == -1 ||
-        getgattr ((argc == 4) ? argv[3].o : NULL, &gattr) == -1
-    )
-        return L_FAILURE;
-    rtn = Gbox (wi, r, &gattr);
-    if (rtn == 0 && argv[1].o != null && ISACANVAS (wi))
-        rectmerge (NODEID (wi), argv[1].o, r);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXpolygon (int argc, lvar_t *argv) {
-    Tobj po;
-    Ggattr_t gattr;
-    long i, pn;
-    int wi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getgattr ((argc == 4) ? argv[3].o : NULL, &gattr) == -1
-    )
-        return L_FAILURE;
-    po = argv[2].o;
-    if ((pn = Tgettablen (po)) > gpn) {
-        gpp = Marraygrow (gpp, (long) pn * GPSIZE);
-        gpn = pn;
-    }
-    for (i = 0; i < pn; i++)
-        if (getxy (Tfindi (po, i), &gpp[i]) == -1)
-            return L_FAILURE;
-    Gpolygon (wi, pn, gpp, &gattr);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXsplinegon (int argc, lvar_t *argv) {
-    Tobj po;
-    Ggattr_t gattr;
-    long i, pn;
-    int wi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getgattr ((argc == 4) ? argv[3].o : NULL, &gattr) == -1
-    )
-        return L_FAILURE;
-    po = argv[2].o;
-    if ((pn = Tgettablen (po)) > gpn) {
-        gpp = Marraygrow (gpp, (long) pn * GPSIZE);
-        gpn = pn;
-    }
-    for (i = 0; i < pn; i++)
-        if (getxy (Tfindi (po, i), &gpp[i]) == -1)
-            return L_FAILURE;
-    Gsplinegon (wi, pn, gpp, &gattr);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXarc (int argc, lvar_t *argv) {
-    Ggattr_t gattr;
-    Grect_t r;
-    Gpoint_t op;
-    Gsize_t sp;
-    int wi, rtn;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getxy (argv[2].o, &op) == -1 || getxy (argv[3].o, &sp) == -1 ||
-        getgattr ((argc == 5) ? argv[4].o : NULL, &gattr) == -1
-    )
-        return L_FAILURE;
-    rtn = Garc (wi, op, sp, (double) 0, (double) 360, &gattr);
-    if (rtn == 0 && argv[1].o != null && ISACANVAS (wi)) {
-        r.o.x = op.x - sp.x, r.o.y = op.y - sp.y;
-        r.c.x = op.x + sp.x, r.c.y = op.y + sp.y;
-        rectmerge (NODEID (wi), argv[1].o, r);
-    }
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXtext (int argc, lvar_t *argv) {
-    Ggattr_t gattr;
-    Gpoint_t p;
-    char *s, *fn, *justs;
-    double fs;
-    int wi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getxy (argv[2].o, &p) == -1 || getstr (argv[3].o, &s) == -1 ||
-        getstr (argv[4].o, &fn) == -1 || getdouble (argv[5].o, &fs) == -1 ||
-        getstr (argv[6].o, &justs) == -1 ||
-        getgattr ((argc == 8) ? argv[7].o : NULL, &gattr) == -1
-    )
-        return L_FAILURE;
-    Gtext (wi, s, p, fn, fs, justs, &gattr);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXtextsize (int argc, lvar_t *argv) {
-    Gsize_t sp;
-    double fs;
-    char *s, *fn;
-    long m;
-    int wi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS (wi) ||
-        getstr (argv[1].o, &s) == -1 || getstr (argv[2].o, &fn) == -1 ||
-        getdouble (argv[3].o, &fs) == -1
-    )
-        return L_FAILURE;
-    if (Ggettextsize (wi, s, fn, fs, &sp) == -1)
-        return L_FAILURE;
-    m = Mpushmark ((rtno = Ttable (2)));
-    Tinss (rtno, "x", Treal (sp.x)), Tinss (rtno, "y", Treal (sp.y));
-    Mpopmark (m);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXcreatebitmap (int argc, lvar_t *argv) {
-    Tobj bo, so;
-    Gsize_t s;
-    long rtnm;
-    int wi, bi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getxy (argv[1].o, &s) == -1
-    )
-        return L_FAILURE;
-    if ((bi = Gcreatebitmap (wi, s)) == -1)
-        return L_FAILURE;
-    Tinsi (rootbo, bi, (bo = Ttable (4)));
-    rtno = Tinteger (bi);
-    rtnm = Mpushmark (rtno);
-    Tinss (bo, "canvas", Tinteger (bi));
-    Tinss (bo, "size", (so = Ttable (2)));
-    Tinss (so, "x", Tinteger ((long) Gbitmaps[bi].size.x));
-    Tinss (so, "y", Tinteger ((long) Gbitmaps[bi].size.y));
-    Mpopmark (rtnm);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXdestroybitmap (int argc, lvar_t *argv) {
-    int bi;
-
-    if (getint (argv[0].o, &bi) == -1 || !ISABITMAP (bi))
-        return L_FAILURE;
-    Gdestroybitmap (bi);
-    Tdeli (rootbo, bi);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXreadbitmap (int argc, lvar_t *argv) {
-    Tobj bo, so;
-    long rtnm;
-    int wi, bi, ioi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getint (argv[1].o, &ioi) == -1 || ioi < 0 || ioi > ion ||
-        !iop[ioi].inuse
-    )
-        return L_FAILURE;
-    if ((bi = Greadbitmap (wi, iop[ioi].ifp)) == -1)
-        return L_FAILURE;
-    Tinsi (rootbo, bi, (bo = Ttable (4)));
-    rtno = Tinteger (bi);
-    rtnm = Mpushmark (rtno);
-    Tinss (bo, "canvas", Tinteger (bi));
-    Tinss (bo, "size", (so = Ttable (2)));
-    Tinss (so, "x", Tinteger ((long) Gbitmaps[bi].size.x));
-    Tinss (so, "y", Tinteger ((long) Gbitmaps[bi].size.y));
-    Mpopmark (rtnm);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXwritebitmap (int argc, lvar_t *argv) {
-    int bi, ioi;
-
-    if (
-        getint (argv[0].o, &ioi) == -1 || ioi < 0 || ioi > ion ||
-        !iop[ioi].inuse || getint (argv[1].o, &bi) == -1 || !ISABITMAP (bi)
-    )
-        return L_FAILURE;
-    Gwritebitmap (iop[ioi].ofp, bi);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXbitblt (int argc, lvar_t *argv) {
-    Ggattr_t gattr;
-    Grect_t r;
-    Gpoint_t p;
-    char *mode;
-    int wi, bi, rtn;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS2 (wi) ||
-        getxy (argv[2].o, &p) == -1 || getrect (argv[3].o, &r) == -1 ||
-        getint (argv[4].o, &bi) == -1 || getstr (argv[5].o, &mode) == -1 ||
-        getgattr ((argc == 7) ? argv[6].o : NULL, &gattr) == -1
-    )
-        return L_FAILURE;
-    rtn = Gbitblt (wi, p, r, bi, mode, &gattr);
-    if (
-        rtn == 0 && argv[1].o != null && ISACANVAS (wi) &&
-        strcmp (mode, "b2c") == 0
-    )
-        rectmerge (NODEID (wi), argv[1].o, r);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXclearpick (int argc, lvar_t *argv) {
-    int wi;
-
-    if (getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS (wi))
-        return L_FAILURE;
-    if (argv[1].o != null)
-        rectdelete (NODEID (wi), argv[1].o);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXsetpick (int argc, lvar_t *argv) {
-    Grect_t r;
-    int wi;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) || !ISACANVAS (wi) ||
-        getrect (argv[2].o, &r) == -1
-    )
-        return L_FAILURE;
-    if (argv[1].o != null)
-        rectinsert (NODEID (wi), argv[1].o, r);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXdisplaymenu (int argc, lvar_t *argv) {
-    Tobj mo, meo;
-    char buf[50];
-    char *entries[1];
-    int wi, mi, mei;
-    int rtn;
-
-    if (
-        getint (argv[0].o, &wi) == -1 || !ISAWIDGET (wi) ||
-        !(ISACANVAS (wi) || ISALABEL (wi))
-    )
-        return L_FAILURE;
-    mo = argv[1].o;
-    if ((mi = menufind (NODEID (wi), mo, Tgettime (mo))) != -1) {
-        if ((rtn = Gmenudisplay (wi, mi)) == -1)
-            rtno = NULL;
-        else
-            rtno = Tinteger (rtn);
-        return L_SUCCESS;
-    }
-    wattri = 0;
-    mi = Gcreatewidget (wi, G_MENUWIDGET, wattri, wattrp);
-    mei = 0;
-    while ((meo = Tfindi (mo, mei))) {
-        switch (Tgettype (meo)) {
-        case T_STRING:
-            entries[0] = Tgetstring (meo);
-            break;
-        case T_INTEGER:
-            snprintf(buf, sizeof(buf), "%d", (int) Tgetnumber (meo));
-            entries[0] = &buf[0];
-            break;
-        case T_REAL:
-            snprintf(buf, sizeof(buf), "%f", Tgetnumber (meo));
-            entries[0] = &buf[0];
-            break;
-        }
-        Gmenuaddentries (mi, 1, &entries[0]);
-        mei++;
-    }
-    menuinsert (NODEID (wi), mo, Tgettime (mo), mi);
-    Ttime++;
-    if ((rtn = Gmenudisplay (wi, mi)) == -1)
-        rtno = NULL;
-    else
-        rtno = Tinteger (rtn);
-    return L_SUCCESS;
-}
-
-/* LEFTY builtin */
-int GFXcolormap (int argc, lvar_t *argv) {
-    char *cs;
-    int cni;
-    long rtnm;
-
-    if (getstr (argv[0].o, &cs) == -1)
-        return L_FAILURE;
-    rtno = NULL;
-    for (cni = 0; cni < sizeof (colornames) / sizeof (colorname_t); cni++) {
-        if (strcmp (colornames[cni].name, cs) != 0)
-            continue;
-        rtno = Ttable (4);
-        rtnm = Mpushmark (rtno);
-        Tinss (rtno, "r", Tinteger (colornames[cni].r));
-        Tinss (rtno, "g", Tinteger (colornames[cni].g));
-        Tinss (rtno, "b", Tinteger (colornames[cni].b));
-        Mpopmark (rtnm);
-        break;
-    }
-    return L_SUCCESS;
-}
-
-static int getwattr (Tobj ao, int *type) {
-    Tkvindex_t tkvi;
-    Tobj co;
-    int *ap;
-    char *ts;
-    int li, ai;
-
-    wattri = 0;
-    if (!ao && Tgettype (ao) != T_TABLE)
-        return -1;
-    if (*type == -1) {
-        if (getstr (Tfinds (ao, "type"), &ts) == -1)
-            return -1;
-        for (ap = NULL, li = 0; Gwlist[li].wname; li++) {
-            if (strcmp (ts, Gwlist[li].wname) == 0) {
-                *type = Gwlist[li].wid;
-                ap = Gwlist[li].attrid;
-                break;
-            }
-        }
-        if (*type == -1)
-            return -1;
-        if (wattri >= wattrn) {
-            wattrp = Marraygrow (
-                wattrp, (long) (wattrn + WATTRINCR) * WATTRSIZE
-            );
-            wattrn += WATTRINCR;
-        }
-        switch (*type) {
-        case G_TEXTWIDGET:
-            wattrp[wattri].id = G_ATTRNEWLINECB;
-            wattrp[wattri].u.func = GFXtextcb, wattri++;
-            break;
-        case G_ARRAYWIDGET:
-            wattrp[wattri].id = G_ATTRRESIZECB;
-            wattrp[wattri].u.func = GFXarrayresizecb, wattri++;
-            break;
-        case G_BUTTONWIDGET:
-            wattrp[wattri].id = G_ATTRBUTTONCB;
-            wattrp[wattri].u.func = GFXbuttoncb, wattri++;
-            break;
-        case G_LABELWIDGET:
-            wattrp[wattri].id = G_ATTREVENTCB;
-            wattrp[wattri].u.func = GFXlabelcb, wattri++;
-            break;
-        case G_CANVASWIDGET:
-            wattrp[wattri].id = G_ATTREVENTCB;
-            wattrp[wattri].u.func = GFXevent, wattri++;
-            break;
-        case G_VIEWWIDGET:
-            wattrp[wattri].id = G_ATTREVENTCB;
-            wattrp[wattri].u.func = GFXviewcb, wattri++;
-            break;
-        }
-    } else {
-        for (ap = NULL, li = 0; Gwlist[li].wname; li++) {
-            if (*type == Gwlist[li].wid) {
-                ap = Gwlist[li].attrid;
-                break;
-            }
-        }
-    }
-    for (ai = 0; ap[ai] != -1; ai++) {
-        if (wattri >= wattrn) {
-            wattrp = Marraygrow (
-                wattrp, (long) (wattrn + WATTRINCR) * WATTRSIZE
-            );
-            wattrn += WATTRINCR;
-        }
-        wattrp[wattri].id = ap[ai];
-        switch (Gwattrmap[ap[ai]].type) {
-        case G_ATTRTYPEPOINT:
-            getwpointnset (Tfinds (ao, Gwattrmap[ap[ai]].name));
-            break;
-        case G_ATTRTYPESIZE:
-            getwsizenset (Tfinds (ao, Gwattrmap[ap[ai]].name));
-            break;
-        case G_ATTRTYPERECT:
-            getwrectnset (Tfinds (ao, Gwattrmap[ap[ai]].name));
-            break;
-        case G_ATTRTYPETEXT:
-            getwstrnset (Tfinds (ao, Gwattrmap[ap[ai]].name));
-            break;
-        case G_ATTRTYPEINT:
-            getwintnset (Tfinds (ao, Gwattrmap[ap[ai]].name));
-            break;
-        case G_ATTRTYPECOLOR:
-            if ((co = Tfinds (
-                ao, Gwattrmap[ap[ai]].name
-            )) && Tgettype (co) == T_TABLE) {
-                for (Tgetfirst (co, &tkvi); tkvi.kvp; Tgetnext (&tkvi)) {
-                    if (wattri >= wattrn) {
-                        wattrp = Marraygrow (
-                            wattrp, (long) (wattrn + WATTRINCR) * WATTRSIZE
-                        );
-                        wattrn += WATTRINCR;
-                    }
-                    wattrp[wattri].id = ap[ai];
-                    getwcolornset (tkvi.kvp->ko, tkvi.kvp->vo);
-                }
-            }
-            break;
-        }
-    }
-    return wattri;
-}
-
-static int getgattr (Tobj ao, Ggattr_t *dp) {
-    Tkvindex_t tkvi;
-    char *s, *s2;
-
-    dp->flags = 0;
-    if (!ao)
-        return 0;
-    if (Tgettype (ao) != T_TABLE)
-        return -1;
-    for (Tgetfirst (ao, &tkvi); tkvi.kvp; Tgetnext (&tkvi)) {
-        if (Tgettype (tkvi.kvp->ko) != T_STRING)
-            continue;
-        s = Tgetstring (tkvi.kvp->ko);
-        if (strcmp (s, "color") == 0) {
-            getaintnset (tkvi.kvp->vo, dp->color, G_GATTRCOLOR);
-        } else if (strcmp (s, "width") == 0) {
-            getaintnset (tkvi.kvp->vo, dp->width, G_GATTRWIDTH);
-        } else if (strcmp (s, "mode") == 0) {
-            getastrnset (tkvi.kvp->vo, s2, G_GATTRMODE);
-            if (dp->flags & G_GATTRMODE) {
-                if (strcmp (s2, "src") == 0)
-                    dp->mode = G_SRC;
-                else if (strcmp (s2, "xor") == 0)
-                    dp->mode = G_XOR;
-                else
-                    dp->flags &= ~G_GATTRMODE;
-            }
-        } else if (strcmp (s, "fill") == 0) {
-            getastrnset (tkvi.kvp->vo, s2, G_GATTRFILL);
-            if (dp->flags & G_GATTRFILL) {
-                if (strcmp (s2, "on") == 0)
-                    dp->fill = 1;
-                else if (strcmp (s2, "off") == 0)
-                    dp->fill = 0;
-                else
-                    dp->flags &= ~G_GATTRFILL;
-            }
-        } else if (strcmp (s, "style") == 0) {
-            getastrnset (tkvi.kvp->vo, s2, G_GATTRSTYLE);
-            if (dp->flags & G_GATTRSTYLE) {
-                if (strcmp (s2, "solid") == 0)
-                    dp->style = G_SOLID;
-                else if (strcmp (s2, "dashed") == 0)
-                    dp->style = G_DASHED;
-                else if (strcmp (s2, "dotted") == 0)
-                    dp->style = G_DOTTED;
-                else if (strcmp (s2, "longdashed") == 0)
-                    dp->style = G_LONGDASHED;
-                else if (strcmp (s2, "shortdashed") == 0)
-                    dp->style = G_SHORTDASHED;
-                else
-                    dp->flags &= ~G_GATTRSTYLE;
-            }
-        }
-    }
-    return 0;
-}
-
-static int getrect (Tobj ro, Grect_t *rp) {
-    if (ro && Tgettype (ro) == T_TABLE)
-        if (
-            getxy (Tfindi (ro, 0), &rp->o) != -1 &&
-            getxy (Tfindi (ro, 1), &rp->c) != -1
-        )
-            return 0;
-    return -1;
-}
-
-static int getxy (Tobj po, Gxy_t *xyp) {
-    Tobj xo, yo;
-
-    if (po && Tgettype (po) == T_TABLE) {
-        xo = Tfinds (po, "x"), yo = Tfinds (po, "y");
-        if (xo && T_ISNUMBER (xo) && yo && T_ISNUMBER (yo)) {
-            xyp->x = Tgetnumber (xo), xyp->y = Tgetnumber (yo);
-            return 0;
-        }
-    }
-    return -1;
-}
-
-static int getint (Tobj to, int *ip) {
-    if (to && T_ISNUMBER (to)) {
-        *ip = Tgetnumber (to);
-        return 0;
-    }
-    return -1;
-}
-
-static int getdouble (Tobj to, double *dp) {
-    if (to && T_ISNUMBER (to)) {
-        *dp = Tgetnumber (to);
-        return 0;
-    }
-    return -1;
-}
-
-static int getstr (Tobj so, char **s) {
-    if (so && T_ISSTRING (so)) {
-        *s = Tgetstring (so);
-        return 0;
-    }
-    return -1;
-}
-
-static int getcolor (Tobj ko, Tobj co, Gcolor_t *cp) {
-    Tobj ro, go, bo, ho, so, vo;
-    char *s, *s1, *s2;
-    float hc, sc, vc;
-    int cni;
-    int r, g, b, a;
-
-    if (ko && T_ISNUMBER (ko))
-        cp->index = Tgetnumber (ko);
-    else
-        return -1;
-    if (!co || !(T_ISSTRING (co) || T_ISTABLE (co)))
-        return -1;
-    if (T_ISSTRING (co)) {
-        s = Tgetstring (co);
-        while (*s == ' ')
-            s++; /* skip over any leading spaces */
-        if (*s == '#' && sscanf (s, "#%2x%2x%2x%2x", &r, &g, &b, &a) >= 3) {
-            cp->r = r;
-            cp->g = g;
-            cp->b = b;
-            return 0;
-        }
-        if ((isdigit (*s) || *s == '.') && scanhsv (s, &hc, &sc, &vc)) {
-            hsv2rgb (hc, sc, vc, cp);
-            return 0;
-        }
-        for (cni = 0; cni < sizeof (colornames) / sizeof (colorname_t); cni++) {
-            for (s1 = colornames[cni].name, s2 = s; *s1 && *s2; s1++, s2++) {
-                if (*s2 == ' ' || *s2 == '_')
-                    s2++;
-                else if (*s1 != *s2)
-                    break;
-            }
-            if (*s1 != *s2)
-                continue;
-            cp->r = colornames[cni].r;
-            cp->g = colornames[cni].g;
-            cp->b = colornames[cni].b;
-            return 0;
-        }
-        return -1;
-    } else {
-        ro = Tfinds (co, "r");
-        go = Tfinds (co, "g");
-        bo = Tfinds (co, "b");
-        if (
-            ro && T_ISNUMBER (ro) && go && T_ISNUMBER (go) &&
-            bo && T_ISNUMBER (bo)
-        ) {
-            cp->r = Tgetnumber (ro);
-            cp->g = Tgetnumber (go);
-            cp->b = Tgetnumber (bo);
-            return 0;
-        } else {
-            ho = Tfinds (co, "h");
-            so = Tfinds (co, "s");
-            vo = Tfinds (co, "v");
-            if (
-                ho && T_ISNUMBER (ho) && so && T_ISNUMBER (so) &&
-                vo && T_ISNUMBER (vo)
-            ) {
-                hc = Tgetnumber (ho);
-                sc = Tgetnumber (so);
-                vc = Tgetnumber (vo);
-                hsv2rgb (hc, sc, vc, cp);
-                return 0;
-            } else
-                return -1;
-        }
-    }
-    return -1;
-}
-
-static void nodeinit (int ni) {
-    int li, ki;
-
-    for (li = 0; li < LISTSIZE; li++)
-        gfxnodes[ni].rect[li] = NULL, gfxnodes[ni].menu[li] = NULL;
-    gfxnodes[ni].ls = gfxnodes[ni].ms = gfxnodes[ni].rs = 0;
-    for (ki = 0; ki < 256; ki++)
-        gfxnodes[ni].ks[ki] = 0;
-    gfxnodes[ni].plvo = gfxnodes[ni].pmvo = gfxnodes[ni].prvo = 0;
-    gfxnodes[ni].pb3vo = gfxnodes[ni].pb4vo = 0;
-    for (ki = 0; ki < 256; ki++)
-        gfxnodes[ni].pkvo[ki] = 0;
-}
-
-static void nodeterm (int ni) {
-    gfxrect_t **rp;
-    gfxrect_t *crp, *nrp;
-    gfxmenu_t **mp;
-    gfxmenu_t *cmp, *nmp;
-    int li;
-
-    for (li = 0; li < LISTSIZE; li++) {
-        rp = &gfxnodes[ni].rect[li];
-        for (crp = *rp; crp; crp = nrp)
-            nrp = crp->next, free (crp);
-        *rp = NULL;
-        mp = &gfxnodes[ni].menu[li];
-        for (cmp = *mp; cmp; cmp = nmp)
-            nmp = cmp->next, free (cmp);
-        *mp = NULL;
-    }
-}
-
-static void rectinit (int ni) {
-    int li;
-
-    for (li = 0; li < LISTSIZE; li++)
-        gfxnodes[ni].rect[li] = NULL;
-}
-
-static void rectterm (int ni) {
-    gfxrect_t **rp;
-    gfxrect_t *crp, *nrp;
-    int li;
-
-    for (li = 0; li < LISTSIZE; li++) {
-        rp = &gfxnodes[ni].rect[li];
-        for (crp = *rp; crp; crp = nrp)
-            nrp = crp->next, free (crp);
-        *rp = NULL;
-    }
-}
-
-static void rectinsert (int ni, Tobj ko, Grect_t r) {
-    gfxrect_t **rp;
-    gfxrect_t *crp;
-
-    rp = &gfxnodes[ni].rect[(uint64_t) ko % LISTSIZE];
-    for (crp = *rp; crp; crp = crp->next)
-        if (crp->ko == ko) {
-            crp->r.o.x = min (r.o.x, r.c.x);
-            crp->r.o.y = min (r.o.y, r.c.y);
-            crp->r.c.x = max (r.o.x, r.c.x);
-            crp->r.c.y = max (r.o.y, r.c.y);
-            return;
-        }
-    if (!(crp = malloc (sizeof (gfxrect_t))))
-        panic1 (POS, "rectinsert", "rect malloc failed");
-
-    crp->ko = ko;
-    crp->r.o.x = min (r.o.x, r.c.x);
-    crp->r.o.y = min (r.o.y, r.c.y);
-    crp->r.c.x = max (r.o.x, r.c.x);
-    crp->r.c.y = max (r.o.y, r.c.y);
-    crp->next = *rp;
-    *rp = crp;
-}
-
-static void rectmerge (int ni, Tobj ko, Grect_t r) {
-    gfxrect_t **rp;
-    gfxrect_t *crp;
-
-    rp = &gfxnodes[ni].rect[(uint64_t) ko % LISTSIZE];
-    for (crp = *rp; crp; crp = crp->next)
-        if (crp->ko == ko) {
-            crp->r.o.x = min (crp->r.o.x, min (r.o.x, r.c.x));
-            crp->r.o.y = min (crp->r.o.y, min (r.o.y, r.c.y));
-            crp->r.c.x = max (crp->r.c.x, max (r.o.x, r.c.x));
-            crp->r.c.y = max (crp->r.c.y, max (r.o.y, r.c.y));
-            return;
-        }
-    if (!(crp = malloc (sizeof (gfxrect_t))))
-        panic1 (POS, "rectmerge", "rect malloc failed");
-
-    crp->ko = ko;
-    crp->r.o.x = min (r.o.x, r.c.x);
-    crp->r.o.y = min (r.o.y, r.c.y);
-    crp->r.c.x = max (r.o.x, r.c.x);
-    crp->r.c.y = max (r.o.y, r.c.y);
-    crp->next = *rp;
-    *rp = crp;
-}
-
-static Tobj rectfind (int ni, Gpoint_t p) {
-    gfxrect_t **rp;
-    gfxrect_t *crp;
-    int li;
-
-    for (li = 0; li < LISTSIZE; li++) {
-        rp = &gfxnodes[ni].rect[li];
-        for (crp = *rp; crp; crp = crp->next)
-            if (
-                crp->r.o.x <= p.x && crp->r.c.x >= p.x &&
-                crp->r.o.y <= p.y && crp->r.c.y >= p.y
-            )
-                return crp->ko;
-    }
-    return NULL;
-}
-
-static void rectdelete (int ni, Tobj ko) {
-    gfxrect_t **rp;
-    gfxrect_t *crp, *prp;
-
-    rp = &gfxnodes[ni].rect[(uint64_t) ko % LISTSIZE];
-    for (crp = *rp, prp = NULL; crp; prp = crp, crp = crp->next)
-        if (crp->ko == ko) {
-            if (crp == *rp)
-                *rp = crp->next;
-            else
-                prp->next = crp->next;
-            free (crp);
-            return;
-        }
-}
-
-static void rectprune (int ni) {
-    gfxrect_t **rp;
-    gfxrect_t *crp, *prp;
-    int li;
-
-    for (li = 0; li < LISTSIZE; li++) {
-        rp = &gfxnodes[ni].rect[li];
-        for (crp = *rp, prp = NULL; crp; ) {
-            if (!M_AREAOF (crp->ko)) {
-                if (crp == *rp)
-                    *rp = crp->next, free (crp), crp = *rp;
-                else
-                    prp->next = crp->next, free (crp), crp = prp->next;
-            } else
-                prp = crp, crp = crp->next;
-        }
-    }
-}
-
-static void menuinsert (int ni, Tobj ko, long time, int mi) {
-    gfxmenu_t **mp;
-    gfxmenu_t *cmp;
-
-    mp = &gfxnodes[ni].menu[(uint64_t) ko % LISTSIZE];
-    for (cmp = *mp; cmp; cmp = cmp->next)
-        if (cmp->ko == ko) {
-            cmp->time = time, cmp->mi = mi;
-            return;
-        }
-    if (!(cmp = malloc (sizeof (gfxmenu_t))))
-        panic1 (POS, "menuinsert", "menu malloc failed");
-
-    cmp->ko = ko;
-    cmp->time = time;
-    cmp->mi = mi;
-    cmp->next = *mp;
-    *mp = cmp;
-}
-
-static int menufind (int ni, Tobj ko, long time) {
-    gfxmenu_t **mp;
-    gfxmenu_t *cmp;
-
-    mp = &gfxnodes[ni].menu[(uint64_t) ko % LISTSIZE];
-    for (cmp = *mp; cmp; cmp = cmp->next)
-        if (cmp->ko == ko && cmp->time == time)
-            return cmp->mi;
-    return -1;
-}
-
-static void menuprune (int ni) {
-    gfxmenu_t **mp;
-    gfxmenu_t *cmp, *pmp;
-    int li;
-
-    for (li = 0; li < LISTSIZE; li++) {
-        mp = &gfxnodes[ni].menu[li];
-        for (cmp = *mp, pmp = NULL; cmp; ) {
-            if (!M_AREAOF (cmp->ko)) {
-                if (cmp == *mp)
-                    *mp = cmp->next, free (cmp), cmp = *mp;
-                else
-                    pmp->next = cmp->next, free (cmp), cmp = pmp->next;
-            } else
-                pmp = cmp, cmp = cmp->next;
-        }
-    }
-}
-
-/*  scan a string for 3 floating point numbers separated by
-    white-space or commas.
-*/
-static int scanhsv (char *strp, float *h, float *s, float *v) {
-    char *endp;
-
-    *h = strtod (strp, &endp);
-    if (endp == strp)
-        return 0;
-    strp = endp;
-    while (*strp == ',' || isspace (*strp))
-        strp++;
-    *s = strtod (strp, &endp);
-    if (endp == strp)
-        return 0;
-    strp = endp;
-    while (*strp == ',' || isspace (*strp))
-        strp++;
-    *v = strtod (strp, &endp);
-    if (endp == strp)
-        return 0;
-    return 1;
-}
-
-static void hsv2rgb (float h, float s, float v, Gcolor_t *cp) {
-    float r, g, b, f, p, q, t;
-    int i;
-
-    /* clip to reasonable values */
-    h = fmaxf (fminf (h, 1.0f), 0.0f);
-    s = fmaxf (fminf (s, 1.0f), 0.0f);
-    v = fmaxf (fminf (v, 1.0f), 0.0f);
-    r = g = b = 0.0f;
-
-    if (s == 0.0f)
-        r = g = b = v;
-    else {
-        if (h == 1.0f)
-            h = 0.0f;
-        h = h * 6.0f;
-        i = (int) h;
-        f = h - (float) i;
-        p = v * (1.0f - s);
-        q = v * (1.0f - (s * f));
-        t = v * (1.0f - (s * (1.0f - f)));
-        switch (i) {
-            case 0: r = v; g = t; b = p; break;
-            case 1: r = q; g = v; b = p; break;
-            case 2: r = p; g = v; b = t; break;
-            case 3: r = p; g = q; b = v; break;
-            case 4: r = t; g = p; b = v; break;
-            case 5: r = v; g = p; b = q; break;
-        }
-    }
-    cp->r = (int) (255.0f * r);
-    cp->g = (int) (255.0f * g);
-    cp->b = (int) (255.0f * b);
-}
diff --git a/cmd/lefty/gfxview.h b/cmd/lefty/gfxview.h
deleted file mode 100644 (file)
index 245bbd5..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-void GFXinit (void);
-void GFXterm (void);
-void GFXprune (void);
-void GFXlabelcb (Gevent_t *);
-void GFXviewcb (Gevent_t *);
-void GFXevent (Gevent_t *);
-void GFXmove (void);
-void GFXredraw (void);
-void GFXmonitorfile (int);
-void GFXidle (void);
-
-int GFXcreatewidget (int, lvar_t *);
-int GFXsetwidgetattr (int, lvar_t *);
-int GFXgetwidgetattr (int, lvar_t *);
-int GFXdestroywidget (int, lvar_t *);
-int GFXclear (int, lvar_t *);
-int GFXsetgfxattr (int, lvar_t *);
-int GFXgetgfxattr (int, lvar_t *);
-int GFXarrow (int, lvar_t *);
-int GFXline (int, lvar_t *);
-int GFXbox (int, lvar_t *);
-int GFXpolygon (int, lvar_t *);
-int GFXsplinegon (int, lvar_t *);
-int GFXarc (int, lvar_t *);
-int GFXtext (int, lvar_t *);
-int GFXtextsize (int, lvar_t *);
-int GFXcreatebitmap (int, lvar_t *);
-int GFXdestroybitmap (int, lvar_t *);
-int GFXreadbitmap (int, lvar_t *);
-int GFXwritebitmap (int, lvar_t *);
-int GFXbitblt (int, lvar_t *);
-int GFXclearpick (int, lvar_t *);
-int GFXsetpick (int, lvar_t *);
-int GFXdisplaymenu (int, lvar_t *);
-int GFXcolormap (int, lvar_t *);
diff --git a/cmd/lefty/internal.c b/cmd/lefty/internal.c
deleted file mode 100644 (file)
index 91410aa..0000000
+++ /dev/null
@@ -1,829 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "mem.h"
-#include "leftyio.h"
-#include "code.h"
-#include "tbl.h"
-#include "parse.h"
-#include "exec.h"
-#include "display.h"
-#include "txtview.h"
-#include "gfxview.h"
-#ifdef FEATURE_DOT
-#include "dot2l.h"
-#endif
-#ifdef FEATURE_GMAP
-#include "gmap2l.h"
-#endif
-#include "internal.h"
-#include <stdbool.h>
-#include <string.h>
-#ifndef FEATURE_MS
-#include <sys/time.h>
-#endif
-
-int Idump (int, Tonm_t *);
-int Itypeof (int, Tonm_t *);
-int Icopy (int, Tonm_t *);
-int Iremove (int, Tonm_t *);
-int Itablesize (int, Tonm_t *);
-int Iopenio (int, Tonm_t *);
-int Icloseio (int, Tonm_t *);
-int Ireadline (int, Tonm_t *);
-int Iread (int, Tonm_t *);
-int Iwriteline (int, Tonm_t *);
-int Iatan (int, Tonm_t *);
-int Itan (int, Tonm_t *);
-int Icos (int, Tonm_t *);
-int Isin (int, Tonm_t *);
-int Isqrt (int, Tonm_t *);
-int Irandom (int, Tonm_t *);
-int Intos (int, Tonm_t *);
-int Iston (int, Tonm_t *);
-int Isplit (int, Tonm_t *);
-int Iconcat (int, Tonm_t *);
-int Iquote (int, Tonm_t *);
-int Ihtmlquote (int, Tonm_t *);
-int Itoint (int, Tonm_t *);
-int Istrlen (int, Tonm_t *);
-int Iload (int, Tonm_t *);
-int Irun (int, Tonm_t *);
-int Imonitor (int, Tonm_t *);
-int Iidlerun (int, Tonm_t *);
-int Itime (int, Tonm_t *);
-int Isleep (int, Tonm_t *);
-int Iecho (int, Tonm_t *);
-int Igetenv (int, Tonm_t *);
-int Iputenv (int, Tonm_t *);
-int Isystem (int, Tonm_t *);
-int Iexit (int, Tonm_t *);
-#ifdef FEATURE_DOT
-int Iparsegraphlabel (int, Tonm_t *);
-int Ireadgraph (int, Tonm_t *);
-int Iwritegraph (int, Tonm_t *);
-#endif
-#ifdef FEATURE_CS
-int C2Lreadcsmessage (int, Tonm_t *);
-#endif
-
-#define MAXN 10000
-
-Ifunc_t Ifuncs[] = {
-    { "createwidget",  GFXcreatewidget,  2,    2 },
-    { "setwidgetattr", GFXsetwidgetattr, 2,    2 },
-    { "getwidgetattr", GFXgetwidgetattr, 2,    2 },
-    { "destroywidget", GFXdestroywidget, 1,    1 },
-    { "clear",         GFXclear,         1,    1 },
-    { "setgfxattr",    GFXsetgfxattr,    2,    2 },
-    { "getgfxattr",    GFXgetgfxattr,    2,    2 },
-    { "arrow",         GFXarrow,         4,    5 },
-    { "line",          GFXline,          4,    5 },
-    { "box",           GFXbox,           3,    4 },
-    { "polygon",       GFXpolygon,       3,    4 },
-    { "splinegon",     GFXsplinegon,     3,    4 },
-    { "arc",           GFXarc,           4,    5 },
-    { "text",          GFXtext,          7,    8 },
-    { "textsize",      GFXtextsize,      4,    4 },
-    { "createbitmap",  GFXcreatebitmap,  2,    2 },
-    { "destroybitmap", GFXdestroybitmap, 1,    1 },
-    { "readbitmap",    GFXreadbitmap,    2,    2 },
-    { "writebitmap",   GFXwritebitmap,   2,    2 },
-    { "bitblt",        GFXbitblt,        6,    7 },
-    { "clearpick",     GFXclearpick,     2,    2 },
-    { "setpick",       GFXsetpick,       3,    3 },
-    { "displaymenu",   GFXdisplaymenu,   2,    2 },
-    { "colormap",      GFXcolormap,      1,    1 },
-    { "txtview",       TXTmode,          1,    1 },
-    { "ask",           TXTask,           1,    3 },
-    { "dump",          Idump,            0, MAXN },
-    { "typeof",        Itypeof,          1,    1 },
-    { "copy",          Icopy,            1,    1 },
-    { "remove",        Iremove,          1,    2 },
-    { "tablesize",     Itablesize,       1,    1 },
-    { "openio",        Iopenio,          3,    4 },
-    { "closeio",       Icloseio,         1,    2 },
-    { "readline",      Ireadline,        1,    1 },
-    { "read",          Iread,            1,    1 },
-    { "writeline",     Iwriteline,       2,    2 },
-    { "atan",          Iatan,            2,    2 },
-    { "tan",           Itan,             1,    1 },
-    { "cos",           Icos,             1,    1 },
-    { "sin",           Isin,             1,    1 },
-    { "sqrt",          Isqrt,            1,    1 },
-    { "random",        Irandom,          1,    1 },
-    { "ntos",          Intos,            1,    1 },
-    { "ston",          Iston,            1,    1 },
-    { "split",         Isplit,           2,    3 },
-    { "concat",        Iconcat,          1, MAXN },
-    { "quote",         Iquote,           1,    3 },
-    { "htmlquote",     Ihtmlquote,       1,    1 },
-    { "toint",         Itoint,           1,    1 },
-    { "strlen",        Istrlen,          1,    1 },
-    { "load",          Iload,            1,    1 },
-    { "run",           Irun,             1,    1 },
-    { "monitor",       Imonitor,         2,    2 },
-    { "idlerun",       Iidlerun,         1,    1 },
-    { "time",          Itime,            0,    0 },
-    { "sleep",         Isleep,           1,    1 },
-    { "echo",          Iecho,            1, MAXN },
-    { "getenv",        Igetenv,          1,    1 },
-    { "putenv",        Iputenv,          2,    2 },
-    { "system",        Isystem,          1, MAXN },
-    { "exit",          Iexit,            0,    0 },
-#ifdef FEATURE_DOT
-    { "parsegraphlabel", Iparsegraphlabel, 2, 2 },
-    { "readgraph",       Ireadgraph,       1, 2 },
-    { "writegraph",      Iwritegraph,      3, 3 },
-#endif
-#ifdef FEATURE_CS
-    { "readcsmessage", C2Lreadcsmessage, 1, 1 },
-#endif
-#ifdef FEATURE_GMAP
-    { "createwindow",     G2Lcreatewindow,     2, 2 },
-    { "destroywindow",    G2Ldestroywindow,    1, 1 },
-    { "setwindowattr",    G2Lsetwindowattr,    2, 2 },
-    { "getwindowattr",    G2Lgetwindowattr,    2, 2 },
-    { "createchannel",    G2Lcreatechannel,    2, 2 },
-    { "destroychannel",   G2Ldestroychannel,   1, 1 },
-    { "setchannelattr",   G2Lsetchannelattr,   2, 2 },
-    { "getchannelattr",   G2Lgetchannelattr,   2, 2 },
-    { "getchannelcoord",  G2Lgetchannelcoord,  2, 3 },
-    { "loadgeometry",     G2Lloadgeometry,     1, 1 },
-    { "unloadgeometry",   G2Lunloadgeometry,   1, 1 },
-    { "setgeometryattr",  G2Lsetgeometryattr,  2, 2 },
-    { "getgeometryattr",  G2Lgetgeometryattr,  2, 2 },
-    { "getgeometryitems", G2Lgetgeometryitems, 3, 3 },
-    { "insertgeom2chan",  G2Linsertgeom2chan,  2, 2 },
-    { "removegeom2chan",  G2Lremovegeom2chan,  1, 1 },
-    { "loadvalue",        G2Lloadvalue,        1, 1 },
-    { "unloadvalue",      G2Lunloadvalue,      1, 1 },
-    { "setvalueattr",     G2Lsetvalueattr,     2, 2 },
-    { "getvalueattr",     G2Lgetvalueattr,     2, 2 },
-    { "getvalueitems",    G2Lgetvalueitems,    2, 2 },
-    { "insertval2geom",   G2Linsertval2geom,   3, 3 },
-    { "removeval2geom",   G2Lremoveval2geom,   1, 1 },
-    { "setval2geomattr",  G2Lsetval2geomattr,  2, 2 },
-    { "getval2geomattr",  G2Lgetval2geomattr,  2, 2 },
-    { "updatewindows",    G2Lupdatewindows,    0, 0 },
-#endif
-    { 0, 0, 0, 0 }
-};
-int Ifuncn;
-
-static char *bufp;
-static int bufn;
-#define BUFINCR 10240
-#define BUFSIZE sizeof (char)
-static void growbufp (int);
-
-void Iinit (void) {
-    int i;
-
-    if (!(bufp = malloc (BUFINCR * BUFSIZE)))
-        panic1 (POS, "Iinit", "buf malloc failed");
-    bufn = BUFINCR;
-    for (i = 0; Ifuncs[i].name; i++)
-        Efunction (Pfunction (Ifuncs[i].name, i), Ifuncs[i].name);
-    Ifuncn = sizeof (Ifuncs) / sizeof (Ifunc_t) - 1;
-}
-
-void Iterm (void) {
-    int i;
-
-    for (i = 0; i < Ifuncn; i++)
-        Tdels (root, Ifuncs[i].name);
-    Ifuncn = 0;
-    free (bufp), bufp = NULL, bufn = 0;
-}
-
-int Igetfunc (char *name) {
-    int i = 0;
-
-    while (Ifuncs[i].name && strcmp (Ifuncs[i].name, name) != 0)
-        i++;
-    return (Ifuncs[i].name) ? i : -1;
-}
-
-/* display.c functions */
-
-int Idump (int argc, lvar_t *argv) {
-    int i;
-
-    if (argc == 0)
-        Dtrace (root, 0);
-    else
-        for (i = 0; i < argc; i++)
-            Dtrace (argv[i].o, 0);
-    return L_SUCCESS;
-}
-
-/* tbl.c functions */
-
-int Itypeof (int argc, lvar_t *argv) {
-    if (T_ISTABLE (argv[0].o))
-        rtno = Tstring ("table");
-    else if (T_ISSTRING (argv[0].o))
-        rtno = Tstring ("string");
-    else if (T_ISNUMBER (argv[0].o))
-        rtno = Tstring ("number");
-    return L_SUCCESS;
-}
-
-int Icopy (int argc, lvar_t *argv) {
-    rtno = Tcopy (argv[0].o);
-    return L_SUCCESS;
-}
-
-int Iremove (int argc, lvar_t *argv) {
-    Tobj tblo, keyo;
-
-    if (argc == 2)
-        tblo = argv[1].o, keyo = argv[0].o;
-    else
-        tblo = root, keyo = argv[0].o;
-    if (T_ISTABLE (tblo) && (T_ISNUMBER (keyo) || T_ISSTRING (keyo)))
-        Tdelo (tblo, keyo);
-    return L_SUCCESS;
-}
-
-int Itablesize (int argc, lvar_t *argv) {
-    Tobj vo;
-
-    if (Tgettype ((vo = argv[0].o)) != T_TABLE)
-        return L_FAILURE;
-    rtno = Tinteger (((Ttable_t *) vo)->n);
-    return L_SUCCESS;
-}
-
-/* file.c functions */
-
-int Iopenio (int argc, lvar_t *argv) {
-    int rtn;
-
-    if (argc == 3)
-        rtn = IOopen (
-            Tgetstring (argv[0].o),
-            Tgetstring (argv[1].o), Tgetstring (argv[2].o), NULL
-        );
-    else
-        rtn = IOopen (
-            Tgetstring (argv[0].o),
-            Tgetstring (argv[1].o), Tgetstring (argv[2].o),
-            Tgetstring (argv[3].o)
-        );
-    rtno = NULL;
-    if (rtn == -1)
-        return L_SUCCESS;
-    rtno = Tinteger (rtn);
-    return L_SUCCESS;
-}
-
-int Icloseio (int argc, lvar_t *argv) {
-    if (argc == 1)
-        IOclose ((int) Tgetnumber (argv[0].o), NULL);
-    else
-        IOclose ((int) Tgetnumber (argv[0].o), Tgetstring (argv[1].o));
-    return L_SUCCESS;
-}
-
-int Ireadline (int argc, lvar_t *argv) {
-    char *s;
-    int m, n;
-
-    s = bufp, n = bufn;
-    while ((m = IOreadline ((int) Tgetnumber (argv[0].o), s, n)) != -1) {
-        if (m < n - 1)
-            break;
-        m += (s - bufp);
-        growbufp (bufn + BUFINCR);
-        s = bufp + m, n = bufn - m;
-    }
-    if (m != -1)
-        rtno = Tstring (bufp);
-    else
-        rtno = NULL;
-    return L_SUCCESS;
-}
-
-int Iread (int argc, lvar_t *argv) {
-    if (IOread ((int) Tgetnumber (argv[0].o), bufp, bufn) > 0)
-        rtno = Tstring (bufp);
-    else
-        rtno = NULL;
-    return L_SUCCESS;
-}
-
-int Iwriteline (int argc, lvar_t *argv) {
-    IOwriteline ((int) Tgetnumber (argv[0].o), Tgetstring (argv[1].o));
-    return L_SUCCESS;
-}
-
-/* math functions */
-
-int Iatan (int argc, lvar_t *argv) {
-    double x, y;
-
-    y = Tgetnumber (argv[0].o), x = Tgetnumber (argv[1].o);
-    rtno = Treal (180 * atan2 (y, x) / M_PI);
-    return L_SUCCESS;
-}
-
-int Itan (int argc, lvar_t *argv) {
-    rtno = Treal (tan (M_PI * Tgetnumber (argv[0].o) / 180.0));
-    return L_SUCCESS;
-}
-
-int Icos (int argc, lvar_t *argv) {
-    rtno = Treal (cos (M_PI * Tgetnumber (argv[0].o) / 180.0));
-    return L_SUCCESS;
-}
-
-int Isin (int argc, lvar_t *argv) {
-    rtno = Treal (sin (M_PI * Tgetnumber (argv[0].o) / 180.0));
-    return L_SUCCESS;
-}
-
-int Isqrt (int argc, lvar_t *argv) {
-    rtno = Treal (sqrt (Tgetnumber (argv[0].o)));
-    return L_SUCCESS;
-}
-
-#if !defined(HAVE_LRAND48) || defined(FEATURE_MS)
-#define lrand48 rand
-#endif
-
-int Irandom (int argc, lvar_t *argv) {
-    rtno = Treal (
-        (Tgetnumber (argv[0].o) *
-        (lrand48 () & 0xffff)) / (double) (0xffff)
-    );
-    return L_SUCCESS;
-}
-
-/* conversion functions */
-
-int Intos (int argc, lvar_t *argv) {
-    double d;
-
-    d = Tgetnumber (argv[0].o);
-    if ((long) d == d)
-        sprintf (bufp, "%ld", (long) d);
-    else
-        sprintf (bufp, "%f", d);
-    rtno = Tstring (bufp);
-    return L_SUCCESS;
-}
-
-int Iston (int argc, lvar_t *argv) {
-    rtno = Treal ((double) atof (Tgetstring (argv[0].o)));
-    return L_SUCCESS;
-}
-
-int Isplit (int argc, lvar_t *argv) {
-    Tobj so, fo;
-    char *sp, *sp2, *s;
-    char fc, tc, qmode;
-    long rtnm, rtni;
-    int bufi, qflag;
-
-    if (
-        Tgettype ((so = argv[0].o)) != T_STRING ||
-        Tgettype ((fo = argv[1].o)) != T_STRING
-    )
-        return L_FAILURE;
-    qflag = (argc == 3) ? FALSE : TRUE;
-    sp = Tgetstring (so);
-    s = Tgetstring (fo);
-    if (strncmp(s, "\\n", 2) == 0)
-        fc = '\n';
-    else
-        fc = s[0];
-    rtno = Ttable (4);
-    rtnm = Mpushmark (rtno);
-    rtni = 0;
-    if (s[0] == 0) {
-        for (sp2 = sp; *sp2; sp2++) {
-            tc = *(sp2 + 1), *(sp2 + 1) = '\000';
-            Tinsi (rtno, rtni++, Tstring (sp2));
-            *(sp2 + 1) = tc;
-        }
-    } else if (qflag && (fc == ' ' || fc == '\t')) {
-        while (*sp == fc)
-            sp++;
-        while (*sp) {
-            bufi = 0;
-            qmode = 0;
-            for (sp2 = sp; *sp2; sp2++) {
-                if (bufi == bufn)
-                    growbufp (bufn + BUFINCR);
-                if (*sp2 == '"' || *sp2 == '\'') {
-                    if (qmode) {
-                        if (qmode == *sp2)
-                            qmode = 0;
-                        else
-                            bufp[bufi++] = *sp2;
-                    } else
-                        qmode = *sp2;
-                } else if (*sp2 == fc && !qmode)
-                    break;
-                else
-                    bufp[bufi++] = *sp2;
-            }
-            if (bufi == bufn)
-                growbufp (bufn + BUFINCR);
-            bufp[bufi] = 0;
-            Tinsi (rtno, rtni++, Tstring (bufp));
-            while (*sp2 == fc)
-                sp2++;
-            sp = sp2;
-        }
-    } else {
-        while (*sp) {
-            for (sp2 = sp; *sp2 && *sp2 != fc; sp2++)
-                ;
-            tc = *sp2, *sp2 = '\000';
-            Tinsi (rtno, rtni++, Tstring (sp));
-            *sp2 = tc;
-            if (*sp2) {
-                sp2++;
-                if (!*sp2)
-                    Tinsi (rtno, rtni++, Tstring (""));
-            }
-            sp = sp2;
-        }
-    }
-    Mpopmark (rtnm);
-    return L_SUCCESS;
-}
-
-int Iconcat (int argc, lvar_t *argv) {
-    Tobj ao;
-    char buf2[50];
-    char *s;
-    int i, n, bufi;
-
-    for (bufi = 0, i = 0; i < argc; i++) {
-        ao = argv[i].o;
-        switch (Tgettype (argv[i].o)) {
-        case T_STRING:
-            if (bufi + (n = strlen (Tgetstring (ao)) + 1) > bufn)
-                growbufp (bufi + n);
-            for (s = Tgetstring (ao); *s; s++)
-                bufp[bufi++] = *s;
-            break;
-        case T_INTEGER:
-            if (bufi + 50 > bufn)
-                growbufp (bufi + 50);
-            snprintf(buf2, sizeof(buf2), "%ld", Tgetinteger (ao));
-            for (s = buf2; *s; s++)
-                bufp[bufi++] = *s;
-            break;
-        case T_REAL:
-            if (bufi + 50 > bufn)
-                growbufp (bufi + 50);
-            snprintf(buf2, sizeof(buf2), "%f", Tgetreal (ao));
-            for (s = buf2; *s; s++)
-                bufp[bufi++] = *s;
-            break;
-        }
-    }
-    bufp[bufi] = '\000';
-    rtno = Tstring (bufp);
-    return L_SUCCESS;
-}
-
-int Iquote (int argc, lvar_t *argv) {
-    Tobj so, ao=NULL, qo=NULL;
-    char *s=NULL, *s1, *s2, *qs, *as;
-    char buf2[50];
-    int n, bufi;
-
-    if (
-        (Tgettype ((so = argv[0].o)) != T_STRING && !T_ISNUMBER (so)) ||
-        (argc > 1 && Tgettype ((qo = argv[1].o)) != T_STRING) ||
-        (argc > 2 && Tgettype ((ao = argv[2].o)) != T_STRING)
-    )
-        return L_FAILURE;
-    switch (Tgettype (so)) {
-    case T_STRING:
-        s = Tgetstring (so);
-        break;
-    case T_INTEGER:
-        snprintf(buf2, sizeof(buf2), "%ld", Tgetinteger (so));
-        s = &buf2[0];
-        break;
-    case T_REAL:
-        snprintf(buf2, sizeof(buf2), "%f", Tgetreal (so));
-        s = &buf2[0];
-        break;
-    }
-    if (argc > 1)
-        qs = Tgetstring (qo);
-    else
-        qs = "'\"";
-    if (argc > 2)
-        as = Tgetstring (ao);
-    else
-        as = NULL;
-    bufi = 0;
-    if ((n = strlen (s) + 3) * 2 > bufn)
-        growbufp (n * 2); /* the *2 is max for chars to quote */
-    if (as)
-        bufp[bufi++] = *as;
-    for (s1 = s; *s1; s1++) {
-        for (s2 = qs; *s2; s2++)
-            if (*s1 == *s2) {
-                bufp[bufi++] = '\\', bufp[bufi++] = *s1;
-                break;
-            }
-        if (!*s2) {
-            switch (*s1) {
-            case '\n': bufp[bufi++] = '\\', bufp[bufi++] = 'n'; break;
-            case '\r': bufp[bufi++] = '\\', bufp[bufi++] = 'r'; break;
-            default: bufp[bufi++] = *s1; break;
-            }
-        }
-    }
-    if (as)
-        bufp[bufi++] = *as;
-    bufp[bufi] = '\000';
-    rtno = Tstring (bufp);
-    return L_SUCCESS;
-}
-
-int Ihtmlquote (int argc, lvar_t *argv) {
-    Tobj so;
-    char *s, *s1;
-    int n, bufi;
-
-    if (Tgettype ((so = argv[0].o)) != T_STRING)
-        return L_FAILURE;
-    s = Tgetstring (so);
-    bufi = 0;
-    if ((n = strlen (s) + 1) * 4 > bufn)
-        growbufp (n * 4); /* the *4 is max for chars to quote */
-    for (s1 = s; *s1; s1++) {
-        switch (*s1) {
-        case '/':
-            bufp[bufi++] = '%';
-            bufp[bufi++] = '2';
-            bufp[bufi++] = 'F';
-            break;
-        case '%':
-            bufp[bufi++] = '%';
-            bufp[bufi++] = '2';
-            bufp[bufi++] = '5';
-            break;
-        case ' ':
-            bufp[bufi++] = '+';
-            break;
-        default:
-            bufp[bufi++] = *s1;
-            break;
-        }
-    }
-    bufp[bufi] = '\000';
-    rtno = Tstring (bufp);
-    return L_SUCCESS;
-}
-
-int Itoint (int argc, lvar_t *argv) {
-    rtno = Tinteger ((long) Tgetnumber (argv[0].o));
-    return L_SUCCESS;
-}
-
-int Istrlen (int argc, lvar_t *argv) {
-    rtno = Tinteger (strlen (Tgetstring (argv[0].o)));
-    return L_SUCCESS;
-}
-
-/* script loading functions */
-
-int Iload (int argc, lvar_t *argv) {
-    Psrc_t src;
-    char *fn;
-    FILE *fp;
-    Tobj co;
-
-    if ((fn = Tgetstring (argv[0].o))) {
-        if (strcmp(fn, "-") == 0)
-            fp = stdin;
-        else {
-            fp = NULL;
-            if ((fn = buildpath (fn, false)))
-                fp = fopen (fn, "r");
-        }
-        if (fp) {
-            src.flag = FILESRC, src.s = NULL, src.fp = fp;
-            src.tok = -1, src.lnum = 1;
-            while ((co = Punit (&src)))
-                Eunit(co);
-            if (fp != stdin)
-                fclose (fp);
-        } else
-            return L_FAILURE;
-    }
-    return L_SUCCESS;
-}
-
-int Irun (int argc, lvar_t *argv) {
-    Psrc_t src;
-    char *s;
-    Tobj co;
-
-    if ((s = Tgetstring (argv[0].o))) {
-        src.flag = CHARSRC, src.s = s, src.fp = NULL;
-        src.tok = -1, src.lnum = 1;
-        while ((co = Punit (&src)))
-            Eunit(co);
-    }
-    return L_SUCCESS;
-}
-
-/* mode setting functions */
-
-int Imonitor (int argc, lvar_t *argv) {
-    Tobj mo, io;
-    char *ms;
-    int ioi;
-
-    if (
-        Tgettype ((mo = argv[0].o)) != T_STRING ||
-        (Tgettype ((io = argv[1].o)) != T_INTEGER && Tgettype (io) != T_REAL)
-    )
-        return L_FAILURE;
-    ms = Tgetstring (mo), ioi = Tgetnumber (io);
-    if (ioi < 0 || ioi >= ion)
-        return L_FAILURE;
-    if (strcmp (ms, "on") == 0)
-        IOmonitor (ioi, inputfds);
-    else if (strcmp (ms, "off") == 0)
-        IOunmonitor (ioi, inputfds);
-    else
-        return L_FAILURE;
-    return L_SUCCESS;
-}
-
-int Iidlerun (int argc, lvar_t *argv) {
-    Tobj mo;
-    char *ms;
-    int mode;
-
-    if (Tgettype ((mo = argv[0].o)) != T_STRING)
-        return L_SUCCESS;
-    ms = Tgetstring (mo);
-    if (strcmp (ms, "on") == 0)
-        mode = 1;
-    else if (strcmp (ms, "off") == 0)
-        mode = 0;
-    else
-        return L_FAILURE;
-    idlerunmode = mode;
-    return L_SUCCESS;
-}
-
-/* system functions */
-
-int Itime (int argc, lvar_t *argv) {
-#ifndef FEATURE_MS
-    struct timeval tz;
-
-    gettimeofday (&tz, NULL);
-    rtno = Treal (tz.tv_sec + tz.tv_usec / 1000000.0);
-#else
-    rtno = Treal (0);
-#endif
-    return L_SUCCESS;
-}
-
-int Isleep (int argc, lvar_t *argv) {
-#ifndef FEATURE_MS
-    struct timeval tz;
-    float f;
-
-    Gsync ();
-    f = Tgetnumber (argv[0].o);
-    tz.tv_sec = f;
-    tz.tv_usec = (f - tz.tv_sec) * 1000000;
-    if (select (0, NULL, NULL, NULL, &tz) == -1)
-        return L_FAILURE;
-#endif
-    return L_SUCCESS;
-}
-
-int Iecho (int argc, lvar_t *argv) {
-    int i;
-
-    rtno = NULL;
-    for (i = 0; i < argc; i++) {
-        switch (Tgettype (argv[i].o)) {
-        case T_STRING:  printf ("%s", Tgetstring (argv[i].o));   break;
-        case T_INTEGER: printf ("%ld", Tgetinteger (argv[i].o)); break;
-        case T_REAL:    printf ("%f", Tgetreal (argv[i].o));     break;
-        case T_TABLE:   printf ("[\n"), Dtrace (argv[i].o, 4);   break;
-        }
-    }
-    printf ("\n");
-    return L_SUCCESS;
-}
-
-int Igetenv (int argc, lvar_t *argv) {
-    char *s;
-
-    if (!T_ISSTRING (argv[0].o))
-        return L_FAILURE;
-    rtno = NULL;
-    if (!(s = getenv (Tgetstring (argv[0].o))) || !*s)
-        return L_SUCCESS;
-    rtno = Tstring (s);
-    return L_SUCCESS;
-}
-
-int Iputenv (int argc, lvar_t *argv) {
-    if (!T_ISSTRING (argv[0].o) || !T_ISSTRING (argv[1].o))
-        return L_FAILURE;
-    bufp[0] = 0;
-    strcat (bufp, Tgetstring (argv[0].o));
-    strcat (bufp, "=");
-    strcat (bufp, Tgetstring (argv[1].o));
-    putenv (bufp);
-    return L_SUCCESS;
-}
-
-int Isystem (int argc, lvar_t *argv) {
-    int i;
-
-    bufp[0] = 0;
-    strcat (bufp, Tgetstring (argv[0].o));
-    for (i = 1; i < argc; i++)
-        strcat (bufp, " "), strcat (bufp, Tgetstring (argv[i].o));
-#ifndef FEATURE_MS
-    system (bufp);
-#else
-    {
-        UINT handle;
-        handle = WinExec (bufp, SW_SHOW);
-    }
-#endif
-    return L_SUCCESS;
-}
-
-int Iexit (int argc, lvar_t *argv) {
-    longjmp (exitljbuf, 1);
-    return L_SUCCESS; /* NOT REACHED */
-}
-
-#ifdef FEATURE_DOT
-/* dot related functions */
-
-int Iparsegraphlabel (int argc, lvar_t *argv) {
-    rtno = D2Lparsegraphlabel (argv[0].o, argv[1].o);
-    return L_SUCCESS;
-}
-
-int Ireadgraph (int argc, lvar_t *argv) {
-    int ioi;
-
-    if ((ioi = Tgetnumber (argv[0].o)) < 0 || ioi >= ion)
-        return L_FAILURE;
-    if (argc == 2 && !T_ISTABLE (argv[1].o))
-        return L_FAILURE;
-    if (!(rtno = D2Lreadgraph (ioi, (argc == 2 ? argv[1].o : NULL))))
-        return L_FAILURE;
-    return L_SUCCESS;
-}
-
-int Iwritegraph (int argc, lvar_t *argv) {
-    int ioi;
-
-    if (
-        !T_ISNUMBER (argv[0].o) || !T_ISTABLE (argv[1].o) ||
-        !T_ISINTEGER (argv[2].o)
-    )
-        return L_FAILURE;
-    if ((ioi = Tgetnumber (argv[0].o)) < 0 || ioi >= ion)
-        return L_FAILURE;
-    D2Lwritegraph (ioi, argv[1].o, Tgetinteger (argv[2].o));
-    return L_SUCCESS;
-}
-#endif
-
-static void growbufp (int newsize) {
-    if (!(bufp = realloc (
-        bufp, ((newsize + BUFINCR - 1) / BUFINCR) * BUFINCR * BUFSIZE
-    )))
-        panic1 (POS, "growbufp", "buf realloc failed");
-    bufn = ((newsize + BUFINCR - 1) / BUFINCR) * BUFINCR;
-}
diff --git a/cmd/lefty/internal.h b/cmd/lefty/internal.h
deleted file mode 100644 (file)
index bab850e..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-typedef struct Ifunc_t {
-    char *name;
-    int (*func) (int, Tonm_t *);
-    int min, max;
-} Ifunc_t;
-
-void Iinit (void);
-void Iterm (void);
-int Igetfunc (char *);
-
-extern Ifunc_t Ifuncs[];
-extern int Ifuncn;
diff --git a/cmd/lefty/lefty.1 b/cmd/lefty/lefty.1
deleted file mode 100644 (file)
index e4079f7..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-.TH LEFTY 1
-.SH NAME
-lefty \- A Programmable Graphics Editor
-.SH SYNOPSIS
-.B lefty
-[
-.I options
-] [
-.I file
-]
-.SH DESCRIPTION
-.B lefty
-is a two-view graphics editor for technical pictures. This editor has
-no hardwired knowledge about specific picture layouts or editing operations.
-Each picture is described by a program that contains functions to draw the
-picture and functions to perform editing operations that are appropriate for
-the specific picture. Primitive user actions, like mouse and keyboard events,
-are also bound to functions in this program. Besides the graphical view of the
-picture itself, the editor presents a textual view of the program that
-describes the picture. Programmability and the two-view interface allow the
-editor to handle a variety of pictures, but are particularly useful for
-pictures used in technical contexts, e.g., graphs and trees. Also,
-.B lefty
-can communicate with other processes. This feature allows it to use existing
-tools to compute specific picture layouts and allows external processes to use
-the editor as a front end to display their data structures graphically.
-.SH USAGE
-The file name is optional. It may be
-.BR - ,
-for reading from standard input.
-.B lefty
-uses two environment variables,
-.B LEFTYPATH
-and
-.BR LEFTYOPTIONS .
-.B LEFTYPATH
-is a colon separated list of directories. When
-.B lefty
-tries to open a file, it searches that path for the file. When
-.B lefty
-tries to start up another process, it searches
-.B LEFTYPATH
-first, then the standard
-.B PATH
-variable.
-.B LEFTYOPTIONS
-can be used to set specific options. Options specified on the command line
-override options set through this variable.
-.SH OPTIONS
-.TP
-.B -x
-Instructs the editor to exit after processing
-.BR file .
-.TP
-.B "-e <expression>"
-.B <expression>
-is parsed and executed.
-.TP
-.B -el <num>
-Set error reporting level. The default value is
-.BR 0 .
-.B 0
-never prints any messages.
-.B 1
-prints severe errors, such as trying to return from a non function.
-.B 2
-is the most useful: it reports function calls that cannot be executed, either
-because there is no function, or because of argument mismatches.
-.B 3
-also warns about bad variable names.
-.B 4,5
-warn about expressions that do not return a value. Only level
-.B 1
-messages are real errors. The rest arise from legal
-.B lefty
-statements, but may be caused by some logic errors.
-.TP
-.B "-sd <num>"
-Specifies how much of the stack to show, when an error message is to be
-printed. The default value is
-.BR 2 .
-With
-.BR 0 ,
-no part of the stack is shown. With
-.BR 1 ,
-only the top stack frame is printed. With
-.BR 2 ,
-the full stack is printed.
-.TP
-.B "-sb <num>"
-Specifies how much of each function in the stack to show, when an error message
-is to be printed. The default value is
-.BR 2 .
-With
-.BR 0 ,
-no part of the function is shown. With
-.BR 1 ,
-only the line around the error is printed. With
-.BR 2 ,
-the full function body is printed.
-.TP
-.B "-df <string>"
-Sets the default font. This font is used whenever a requested font cannot be
-found. The string must be a legal X font. If string is
-.BR "''" ,
-.B lefty
-will draw small boxes instead of text.
-.TP
-.B "-ps <file>"
-Specifies a default file name for postscript files. This name is used when no
-name is specified in the
-.B createwidget
-call. The default file name is
-.BR out.ps .
-.TP
-.B -V
-Prints the version.
-.TP
-.B -?
-Prints the usage and exits.
-.SH SEE ALSO
-.I lefty
-user guide.
diff --git a/cmd/lefty/lefty.c b/cmd/lefty/lefty.c
deleted file mode 100644 (file)
index 4c504be..0000000
+++ /dev/null
@@ -1,540 +0,0 @@
-/**
- * @file
- * @brief main of lefty
- */
-
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "config.h"
-
-#define LEFTYVERSION "10 Mar 2005"
-
-#include "builddate.h"
-#include <cgraph/exit.h>
-#include "common.h"
-#include "g.h"
-#include "code.h"
-#include "leftyio.h"
-#include "mem.h"
-#include "tbl.h"
-#include "parse.h"
-#include "exec.h"
-#include "str.h"
-#include "display.h"
-#include "internal.h"
-#include "txtview.h"
-#include "gfxview.h"
-
-#ifdef FEATURE_GMAP
-#include "gmap.h"
-#include "gmap2l.h"
-#endif
-
-#include <stdbool.h>
-#ifndef FEATURE_MS
-#include <sys/time.h>
-#  ifdef STATS
-#  include <sys/resource.h>
-#  endif
-#endif
-
-#if defined(HAVE_FILE_CNT) && HAVE_FILE_CNT
-#define canread(f) ((f)->_cnt>0)
-#else
-#  if defined(HAVE_FILE_NEXT) && HAVE_FILE_NEXT
-#  define canread(f) ((f)->_next<(f)->_endb)
-#  else
-#    if defined(HAVE_FILE_IO_READ_END) && HAVE_FILE_IO_READ_END
-#    define canread(f) ((f)->_IO_read_end>(f)->_IO_read_ptr)
-#    else
-#      if defined(HAVE_FILE_R) && HAVE_FILE_R
-#      define canread(f) ((f)->_r>0)
-#      else
-#      define canread(f) (1)
-#      endif
-#    endif
-#  endif
-#endif
-
-#ifdef FEATURE_GMAP
-static bool gmapon;
-#endif
-
-static Grect_t txtcoords = {
-    { 1,  1 }, { 449, 599 },
-};
-
-#ifdef STATS
-static time_t stime;
-#endif
-
-static int endflag = FALSE;
-
-static char *exprstr;
-static FILE *fp;
-
-static int processinput (int);
-static void processargs (int, char **);
-static void processstr (char *);
-static void printusage (void);
-
-#if defined(FEATURE_X11) || defined(FEATURE_NONE)
-
-int main (int argc, char **argv) {
-    Tobj co;
-    Psrc_t src;
-
-#ifdef MTRACE
-    extern int Mt_certify;
-    Mt_certify = 1;
-#endif
-#ifdef STATS
-    stime = time (NULL);
-#endif
-
-    idlerunmode = 0;
-    exprstr = NULL;
-    fp = NULL;
-    init (argv[0]);
-
-    processstr (leftyoptions);
-    argv++, argc--;
-    processargs (argc, argv);
-
-    Minit (GFXprune);
-    Ginit ();
-    FD_SET (Gxfd, &inputfds);
-
-    Eerrlevel = 1;
-    Estackdepth = 2;
-    Eshowbody = 1;
-
-    if (setjmp (exitljbuf))
-        goto eop;
-
-    Cinit ();
-    IOinit ();
-    Tinit ();
-    Pinit ();
-    Einit ();
-    Sinit ();
-    Dinit ();
-    Iinit ();
-    TXTinit (txtcoords);
-    GFXinit ();
-#ifdef FEATURE_GMAP
-    gmapon = true, G2Linit ();
-#endif
-
-    if (exprstr) {
-        src.flag = CHARSRC, src.s = exprstr, src.fp = NULL;
-        src.tok = -1, src.lnum = 1;
-        while ((co = Punit (&src)))
-            Eunit (co);
-    }
-    if (fp) {
-        src.flag = FILESRC, src.s = NULL, src.fp = fp;
-        src.tok = -1, src.lnum = 1;
-        while ((co = Punit (&src)))
-            Eunit (co);
-    }
-    if (endflag)
-        goto eop;
-
-    TXTupdate ();
-
-    Gneedredraw = FALSE;
-    for (;;) {
-        if (Gneedredraw)
-            GFXredraw (), Gneedredraw = FALSE;
-        if (Gbuttonsdown > 0) {
-            GFXmove (), Gprocessevents (FALSE, G_ONEEVENT);
-            processinput (FALSE);
-        } else {
-            if (Mcouldgc) {
-                if (!processinput (FALSE))
-                    Mdogc (M_GCINCR);
-            }
-            if (idlerunmode) {
-                if (!processinput (FALSE))
-                    GFXidle ();
-#ifdef FEATURE_GMAP
-            } else if (GMAPneedupdate) {
-                processinput (FALSE);
-#endif
-            } else
-                processinput (TRUE);
-        }
-#ifdef FEATURE_GMAP
-        if (gmapon)
-            GMAPupdate ();
-#endif
-        if (Erun)
-            TXTupdate (), Erun = false;
-    }
-eop:
-#ifdef PARANOID
-#ifdef FEATURE_GMAP
-    if (gmapon)
-        G2Lterm ();
-#endif
-    GFXterm ();
-    TXTterm ();
-    Iterm ();
-    Dterm ();
-    Sterm ();
-    Eterm ();
-    Pterm ();
-    Tterm ();
-    IOterm ();
-    Cterm ();
-    Gterm ();
-    Mterm ();
-    FD_CLR (Gxfd, &inputfds);
-    term ();
-#endif
-    printusage ();
-    graphviz_exit(0);
-}
-
-#else
-
-HINSTANCE hinstance, hprevinstance;
-
-int APIENTRY WinMain (
-    HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow
-) {
-    Tobj co;
-    Psrc_t src;
-    int argc;
-    LPWSTR *argv;
-
-    hinstance = hInstance;
-    hprevinstance = hPrevInstance;
-    idlerunmode = 0;
-    exprstr = NULL;
-    fp = NULL;
-    init (NULL);
-    Ginit ();
-#ifndef FEATURE_MS
-    FD_SET (Gxfd, &inputfds);
-#endif
-
-    Eerrlevel = 1;
-    Estackdepth = 2;
-    Eshowbody = 1;
-
-    processstr (leftyoptions);
-    argv = CommandLineToArgvW(lpCmdLine, &argc);
-    if (argv == NULL)
-      graphviz_exit(EXIT_FAILURE);
-    processargs(argc, argv);
-    LocalFree(argv);
-
-    if (setjmp (exitljbuf))
-        goto eop;
-
-    Cinit ();
-    IOinit ();
-    Minit (GFXprune);
-    Tinit ();
-    Pinit ();
-    Einit ();
-    Sinit ();
-    Dinit ();
-    Iinit ();
-    TXTinit (txtcoords);
-    GFXinit ();
-
-    if (exprstr) {
-        src.flag = CHARSRC, src.s = exprstr, src.fp = NULL;
-        src.tok = -1, src.lnum = 1;
-        while ((co = Punit (&src)))
-            Eunit (co);
-    }
-    if (fp) {
-        src.flag = FILESRC, src.s = NULL, src.fp = fp;
-        src.tok = -1, src.lnum = 1;
-        while ((co = Punit (&src)))
-            Eunit (co);
-    }
-    if (endflag)
-        goto eop;
-
-    TXTupdate ();
-
-    Gneedredraw = FALSE;
-    for (;;) {
-        if (Gneedredraw)
-            GFXredraw (), Gneedredraw = FALSE;
-        if (Gbuttonsdown > 0)
-            GFXmove (), Gprocessevents (FALSE, G_ONEEVENT);
-        else {
-            if (Mcouldgc) {
-                if (!processinput (FALSE))
-                    Mdogc (M_GCINCR);
-            } else if (idlerunmode) {
-                if (!processinput (FALSE))
-                    GFXidle ();
-            } else
-                processinput (TRUE);
-        }
-        if (Erun)
-            TXTupdate (), Erun = false;
-    }
-
-eop:
-#ifdef PARANOID
-    GFXterm ();
-    TXTterm ();
-    Iterm ();
-    Dterm ();
-    Sterm ();
-    Eterm ();
-    Pterm ();
-    Tterm ();
-    Mterm ();
-    IOterm ();
-    Cterm ();
-    Gterm ();
-    term ();
-#endif
-    printusage ();
-    graphviz_exit(0);
-}
-
-#endif
-
-#ifndef FEATURE_MS
-static struct timeval longwait = { 1000, 0 };
-static struct timeval zerowait = { 0, 0 };
-#endif
-
-static int processinput (int waitflag) {
-    fd_set fdset;
-#ifndef FEATURE_MS
-    struct timeval tz, *tzp;
-#else
-    HANDLE evs[MAXIMUM_WAIT_OBJECTS];
-    int evn;
-#endif
-    int n, rtn;
-    int ioi;
-
-    rtn = 0;
-    while (Gprocessevents (FALSE, G_MANYEVENTS))
-        rtn = 1;
-#ifndef FEATURE_MS
-    for (ioi = 0, n = 0; ioi < ion; ioi++)
-        if (
-            iop[ioi].inuse && iop[ioi].ismonitored &&
-            FD_ISSET (fileno (iop[ioi].ifp), &inputfds) &&
-            canread (iop[ioi].ifp)
-        )
-            GFXmonitorfile (ioi), n++;
-    if (n || rtn)
-        return 1;
-    if (Gneedredraw)
-        return 0;
-    tz = (waitflag && !rtn) ? longwait : zerowait;
-    tzp = &tz;
-    fdset = inputfds;
-    if ((n = select (FD_SETSIZE, &fdset, NULL, NULL, tzp)) <= 0)
-        return rtn;
-    rtn = 1;
-    if (FD_ISSET (Gxfd, &fdset))
-        Gprocessevents (TRUE, G_MANYEVENTS), n--;
-    if (!n)
-        return rtn;
-    Gsync ();
-    for (ioi = 0; n > 0 && ioi < ion; ioi++)
-        if (
-            iop[ioi].inuse && iop[ioi].ismonitored &&
-            FD_ISSET (fileno (iop[ioi].ifp), &fdset)
-        )
-            GFXmonitorfile (ioi), n--;
-#else
-    for (ioi = 0, n = 0, evn = 0; ioi < ion; ioi++) {
-        if (!iop[ioi].inuse || !IOismonitored (ioi))
-            continue;
-        if (
-            (iop[ioi].type == IO_FILE && canread (iop[ioi].ifp)) ||
-            (iop[ioi].type == IO_PIPE && iop[ioi].buf[0])
-        )
-            GFXmonitorfile (ioi), n++;
-        if (iop[ioi].type != IO_PIPE)
-            continue;
-        evs[evn++] = iop[ioi].ifp;
-    }
-    if (n)
-        return 1;
-    if (Gneedredraw)
-        return 0;
-    n = MsgWaitForMultipleObjects (
-        evn, evs, FALSE, (waitflag && !rtn) ? 1 : 0, QS_ALLINPUT
-    );
-    if (n == WAIT_TIMEOUT || n < WAIT_OBJECT_0 || n > WAIT_OBJECT_0 + evn)
-        return rtn;
-    if (n == WAIT_OBJECT_0 + evn)
-        Gprocessevents (TRUE, G_MANYEVENTS);
-    Gsync ();
-    for (ioi = 0; ioi < ion; ioi++)
-        if (
-            iop[ioi].inuse && IOismonitored (ioi) &&
-            (iop[ioi].type == IO_FILE || (iop[ioi].type == IO_PIPE &&
-            evs[n - WAIT_OBJECT_0] == iop[ioi].ifp))
-        )
-            GFXmonitorfile (ioi);
-#endif
-    return rtn;
-}
-
-static char* usestr =
-"    -x    - exit after processing the input file.\n\
-    -e E  - parse and execute expression E.\n\
-    -el N - set error reporting level. (0)\n\
-    -sd N - how much of the stack to show if error is printed. (2)\n\
-    -sb N - how much of each function in the stack show if error is printed. (2)\n\
-    -df S - set default font.\n\
-    -ps F - specify a default file name for postscript files.\n\
-    -     - read input from stdin.\n\
-    -?    - show help.\n\
-    -V    - print version.\n";
-
-static void usage(int eval)
-{
-    fprintf (stderr, "Usage: lefty [options] [file]\n");
-    fputs (usestr, stderr);
-    graphviz_exit(eval);
-}
-
-static void processstr (char *buf) {
-    char *words[100];
-    char *s, *s1;
-    int i;
-
-    if (!(s = buf) || *s == 0)
-        return;
-    s = strdup (s);
-    for (i = 0, s1 = s; *s1; ) {
-        for (; *s1 == ' '; s1++)
-            ;
-        if (!*s1)
-            break;
-        words[i++] = s1;
-        for (; *s1 && *s1 != ' '; s1++)
-            ;
-        if (*s1)
-            *s1 = '\000', s1++;
-    }
-    words[i] = NULL;
-    processargs (i, words);
-    free (s);
-}
-
-static void processargs (int argc, char *argv[]) {
-    while (argc) {
-        if (strcmp (argv[0], "-x") == 0)
-            endflag = TRUE;
-        else if (strcmp (argv[0], "-e") == 0)
-            exprstr = argv[1], argv++, argc--;
-        else if (strcmp (argv[0], "-el") == 0)
-            Eerrlevel = atoi (argv[1]), argv++, argc--;
-        else if (strcmp (argv[0], "-sd") == 0)
-            Estackdepth = atoi (argv[1]), argv++, argc--;
-        else if (strcmp (argv[0], "-sb") == 0)
-            Eshowbody = atoi (argv[1]), argv++, argc--;
-        else if (strcmp (argv[0], "-sc") == 0)
-            argv++, argc--;
-        else if (strcmp (argv[0], "-df") == 0)
-            Gdefaultfont = argv[1], argv++, argc--;
-        else if (strcmp (argv[0], "-w") == 0)
-            warnflag = TRUE;
-        else if (strcmp (argv[0], "-ps") == 0)
-            Gpscanvasname = argv[1], argv++, argc--;
-        else if (strcmp (argv[0], "-V") == 0) {
-            fprintf (stderr, "lefty version %s\n", LEFTYVERSION);
-            fprintf (stderr, "graphviz version %s (%s)\n", PACKAGE_VERSION, BUILDDATE);
-       }
-        else if (strcmp (argv[0], "-?") == 0)
-            usage(0);
-        else if (strcmp (argv[0], "-") == 0) {
-            if (fp != NULL && fp != stdin)
-                fclose(fp);
-            fp = stdin;
-        } else if (argv[0][0] == '-') {
-            fprintf (stderr, "option %s unrecognized\n", argv[0]);
-            usage(1);
-        }
-        else {
-            if (fp != NULL && fp != stdin)
-                fclose(fp);
-            if ((fp = fopen (argv[0], "r")) == NULL) {
-                fprintf (stderr, "cannot open input file: %s\n", argv[0]);
-                graphviz_exit(2);
-            }
-        }
-        argv++, argc--;
-    }
-    if (Eerrlevel > 1)
-        Gerrflag = TRUE;
-}
-
-static void printusage (void) {
-#ifdef STATS
-    struct rusage ru;
-
-    getrusage (RUSAGE_SELF, &ru);
-    Mreport ();
-#ifdef FEATURE_RUSAGE
-    printf (
-        "user   time %13.3lf\n",
-        ru.ru_utime.tv_sec + ru.ru_utime.tv_nsec / 1000000000.0
-    );
-    printf (
-        "system time %13.3lf\n",
-        ru.ru_stime.tv_sec + ru.ru_stime.tv_nsec / 1000000000.0
-    );
-#else
-    printf (
-        "user   time %13.3lf\n",
-        ru.ru_utime.tv_sec + ru.ru_utime.tv_usec / 1000000.0
-    );
-    printf (
-        "system time %13.3lf\n",
-        ru.ru_stime.tv_sec + ru.ru_stime.tv_usec / 1000000.0
-    );
-#endif
-    printf ("resident size  %10d\n", ru.ru_maxrss * getpagesize ());
-    printf ("input            %8d\n", ru.ru_inblock);
-    printf ("output           %8d\n", ru.ru_oublock);
-    printf ("socket msgs sent %8d\n", ru.ru_msgsnd);
-    printf ("socket msgs rcvd %8d\n", ru.ru_msgrcv);
-    printf ("real time        %8d\n", time (NULL) - stime);
-    fflush (stdout);
-#endif
-}
-
-/**
- * @dir .
- * @brief a programmable graphics editor
- *
- * @dir ../lneato
- * @brief lefty + neato
- *
- * @dir ../dotty
- * @brief dot + lefty
- *
- * @dir ../../cmd
- * @brief Graph programs
- */
diff --git a/cmd/lefty/lefty.psp b/cmd/lefty/lefty.psp
deleted file mode 100644 (file)
index c2684f4..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/BOX {
-    /boxy1 exch def /boxx1 exch def /boxy0 exch def /boxx0 exch def
-    boxx0 boxy0 moveto boxx1 boxy0 lineto
-    boxx1 boxy1 lineto boxx0 boxy1 lineto
-    closepath
-} def
-/SCP { stroke initclip newpath BOX clip newpath } def
-/CL { stroke setrgbcolor } def
-/DO { stroke } def
-/NP { newpath } def
-/FI { fill } def
-/LI { moveto lineto } def
-/CT { curveto } def
-/AR {
-    /ang2 exch def /ang1 exch def
-    /radius exch def /y2x exch def /cy exch def /cx exch def
-    gsave
-        cx cy translate 1 y2x scale 0 0 radius ang1 ang2 arc stroke
-    grestore
-} def
-/ARF {
-    /ang2 exch def /ang1 exch def
-    /radius exch def /y2x exch def /cy exch def /cx exch def
-    gsave
-        cx cy translate 1 y2x scale 0 0 radius ang1 ang2 arc fill
-    grestore
-} def
-/TXT {
-    /texth exch def
-    /textf exch def
-    /textn exch def
-    /texts exch def
-    /textyj exch def /texty exch def
-    /textxj exch def /textx exch def
-    textf findfont texth scalefont dup setfont
-    /FontBBox get 1 get 1000 div texth mul /textbl exch def
-    /textth texth textn mul def /texttw 0 def
-    0 1 textn 1 sub {
-        texts exch get 0 get stringwidth pop
-        dup texttw gt { /texttw exch def } { pop } ifelse
-    } for
-    textyj (b) eq { /ty texty textth add textbl add def } if
-    textyj (d) eq { /ty texty textth add def } if
-    textyj (c) eq { /ty texty textth 2 div add def } if
-    textyj (u) eq { /ty texty def } if
-    /ty ty textbl sub def
-    textxj (l) eq { /tx textx def } if
-    textxj (c) eq { /tx textx texttw 2 div sub def } if
-    textxj (r) eq { /tx textx texttw sub def } if
-    0 1 textn 1 sub {
-        /ty ty texth sub def
-        texts exch get dup 0 get /ts exch def 1 get /tj exch def
-        tj (l) eq { tx ty moveto ts show } if
-        tj (n) eq {
-            tx texttw ts stringwidth pop sub 2 div add ty moveto ts show
-        } if
-        tj (r) eq {
-            tx texttw ts stringwidth pop sub add ty moveto ts show
-        } if
-    } for
-} def
-
-/colorimage where {
-    pop
-} {
-    /bwproc {
-        rgbproc dup length 3 idiv string 0 3 0 5 -1 roll {
-            add 2 1 roll 1 sub dup 0 eq {
-                pop 3 idiv 3 -1 roll dup 4 -1 roll
-                dup 3 1 roll 5 -1 roll put 1 add 3 0
-            } {
-                2 1 roll
-            } ifelse
-        } forall
-        pop pop pop
-    } def
-    /colorimage {
-        pop pop /rgbproc exch def {bwproc} image
-    } bind def
-} ifelse
diff --git a/cmd/lefty/leftyio.h b/cmd/lefty/leftyio.h
deleted file mode 100644 (file)
index 2849fb0..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#define IO_FILE   0
-#define IO_PTY    1
-#define IO_PIPE   2
-#define IO_SOCKET 3
-#ifdef FEATURE_CS
-#define IO_CS     4
-#define IO_SIZE   5
-#else
-#define IO_SIZE   4
-#endif
-
-typedef struct io_t {
-    int inuse, ismonitored;
-    int type;
-    FILE *ifp, *ofp;
-    int pid;
-    char *buf;
-} io_t;
-
-#ifdef FEATURE_MS
-#define IOmonitor(ioi, set) do { \
-    iop[ioi].ismonitored = TRUE; \
-} while (0)
-#define IOunmonitor(ioi, set) do { \
-    iop[ioi].ismonitored = FALSE; \
-} while (0)
-#else
-#define IOmonitor(ioi, set) do { \
-    iop[ioi].ismonitored = TRUE; \
-    FD_SET (fileno (iop[ioi].ifp), &set); \
-} while (0)
-#define IOunmonitor(ioi, set) do { \
-    iop[ioi].ismonitored = FALSE; \
-    FD_CLR (fileno (iop[ioi].ifp), &set); \
-} while (0)
-#endif
-
-#define IOismonitored(ioi) iop[ioi].ismonitored
-#define IOINCR 5
-#define IOSIZE sizeof (io_t)
-#define IOBUFSIZE 2048
-
-extern io_t *iop;
-extern int ion;
-
-void IOinit (void);
-void IOterm (void);
-int IOopen (char *, char *, char *, char *);
-int IOclose (int, char *);
-int IOreadline (int, char *, int);
-int IOread (int, char *, int);
-int IOwriteline (int, char *);
diff --git a/cmd/lefty/lex.c b/cmd/lefty/lex.c
deleted file mode 100644 (file)
index 793a49d..0000000
+++ /dev/null
@@ -1,273 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "lex.h"
-#include <string.h>
-
-int Ltok;
-char Lstrtok[MAXTOKEN];
-
-Lname_t Lnames[] = {
-    /* L_SEMI     */ ";",
-    /* L_ASSIGN   */ "=",
-    /* L_OR       */ "|",
-    /* L_AND      */ "&",
-    /* L_EQ       */ "==",
-    /* L_NE       */ "~=",
-    /* L_LT       */ "<",
-    /* L_LE       */ "<=",
-    /* L_GT       */ ">",
-    /* L_GE       */ ">=",
-    /* L_PLUS     */ "+",
-    /* L_MINUS    */ "-",
-    /* L_MUL      */ "*",
-    /* L_DIV      */ "/",
-    /* L_MOD      */ "%",
-    /* L_NOT      */ "~",
-    /* L_STRING   */ "STRING",
-    /* L_NUMBER   */ "NUMBER",
-    /* L_ID       */ "IDENTIFIER",
-    /* L_DOT      */ "DOT",
-    /* L_LB       */ "LEFT BRACKET",
-    /* L_RB       */ "RIGHT BRACKET",
-    /* L_FUNCTION */ "FUNCTION",
-    /* L_LP       */ "LEFT PARENTHESIS",
-    /* L_RP       */ "RIGHT PARENTHESIS",
-    /* L_LCB      */ "LEFT CURLY BRACE",
-    /* L_RCB      */ "RIGHT CURLY BRACE",
-    /* L_LOCAL    */ "LOCAL",
-    /* L_COLON    */ ":",
-    /* L_COMMA    */ ",",
-    /* L_IF       */ "IF",
-    /* L_ELSE     */ "ELSE",
-    /* L_WHILE    */ "WHILE",
-    /* L_FOR      */ "FOR",
-    /* L_IN       */ "IN",
-    /* L_BREAK    */ "BREAK",
-    /* L_CONTINUE */ "CONTINUE",
-    /* L_RETURN   */ "RETURN",
-    /* L_INTERNAL */ "INTERNAL",
-    /* L_EOF      */ "EOF"
-};
-
-static char *unitp, *ucp;
-static FILE *lfp;
-static int lsrc, seeneof, linenum;
-
-#define MAXBUF 10000
-static char unitbuf[MAXBUF];
-
-/* keyword mapping */
-static struct keyword {
-    char *str;
-    int tok;
-} keywords[] = {
-    { "function", L_FUNCTION, },
-    { "local",    L_LOCAL,    },
-    { "if",       L_IF,       },
-    { "else",     L_ELSE,     },
-    { "while",    L_WHILE,    },
-    { "for",      L_FOR,      },
-    { "in",       L_IN,       },
-    { "break",    L_BREAK,    },
-    { "continue", L_CONTINUE, },
-    { "return",   L_RETURN,   },
-    { "internal", L_INTERNAL, },
-    { NULL,       0,          },
-};
-
-/* single character token mapping */
-static struct keychar {
-    int chr, tok;
-} keychars[] = {
-    { ';',    L_SEMI  },
-    { '|',    L_OR    },
-    { '&',    L_AND   },
-    { '+',    L_PLUS  },
-    { '-',    L_MINUS },
-    { '*',    L_MUL   },
-    { '/',    L_DIV   },
-    { '%',    L_MOD   },
-    { '.',    L_DOT   },
-    { '[',    L_LB    },
-    { ']',    L_RB    },
-    { '(',    L_LP    },
-    { ')',    L_RP    },
-    { '{',    L_LCB   },
-    { '}',    L_RCB   },
-    { ':',    L_COLON },
-    { ',',    L_COMMA },
-    { '\000', 0       }
-};
-
-static int gtok (void);
-static int sgetc (void);
-static void sungetc (void);
-
-void Lsetsrc (int src, char *s, FILE *fp, int tok, int lnum) {
-    if (src == CHARSRC)
-        unitp = ucp = s;
-    else if (src == FILESRC)
-        unitp = ucp = unitbuf, unitbuf[0] = '\000', lfp = fp;
-    lsrc = src;
-    linenum = lnum;
-    seeneof = FALSE;
-    if (tok == -1 || tok == L_EOF)
-        Ltok = gtok ();
-    else
-        Ltok = tok;
-}
-
-void Lgetsrc (int *srcp, char **sp, FILE **fpp, int *tokp, int *lnump) {
-    *srcp = lsrc;
-    *sp = ucp;
-    *fpp = lfp;
-    *tokp = Ltok;
-    if (*ucp && *ucp == '\n')
-        linenum++;
-    *lnump = linenum;
-}
-
-void Lprintpos (void) {
-    char *s1, *s2;
-    char c;
-
-    printf ("at line %d: ", linenum);
-    for (s1 = ucp; s1 > unitp && *s1 != '\n'; s1--)
-        ;
-    for (s2 = ucp; *s2 && *s2 != '\n'; s2++)
-        ;
-    c = *s2, *s2 = '\000';
-    printf ("%s\n", s1);
-    *s2 = c;
-}
-
-void Lgtok (void) {
-    Ltok = gtok ();
-}
-
-static int gtok (void) {
-    struct keyword *kwp;
-    struct keychar *kcp;
-    int c, qc, nc;
-    char *p;
-
-    while ((c = sgetc ()) != EOF) {
-        if (c == '#')
-            while ((c = sgetc ()) != '\n')
-                ;
-        if (c != ' ' && c != '\t' && c != '\n')
-            break;
-    }
-    if (c == EOF)
-        return L_EOF;
-    /* check for keywords and identifiers */
-    if (isalpha (c) || c == '_') {
-        p = &Lstrtok[0], *p++ = c;
-        while (isalpha ((c = sgetc ())) || isdigit (c) || c == '_')
-            *p++ = c;
-        sungetc ();
-        *p = '\000';
-        for (kwp = &keywords[0]; kwp->str; kwp++)
-            if (strcmp (kwp->str, Lstrtok) == 0)
-                return kwp->tok;
-        return L_ID;
-    }
-    /* check for number constant */
-    if (isdigit (c)) {
-        p = &Lstrtok[0], *p++ = c;
-        while (isdigit ((c = sgetc ())))
-            *p++ = c;
-        if (c == '.') {
-            *p++ = c;
-            while (isdigit ((c = sgetc ())))
-                *p++ = c;
-        }
-        sungetc ();
-        *p = '\000';
-        return L_NUMBER;
-    }
-    /* check for string constants */
-    if (c == '"' || c == '\'') {
-        p = &Lstrtok[0];
-        qc = c;
-        while ((c = sgetc ()) != EOF && c != qc)
-            *p++ = c; /* FIXME: deal with \'s */
-        if (c == EOF)
-            return L_EOF;
-        *p = '\000';
-        return L_STRING;
-    }
-    /* check for single letter keywords */
-    for (kcp = &keychars[0]; kcp->chr; kcp++)
-        if (kcp->chr == c)
-            return kcp->tok;
-    /* check for 2/1 letter keywords */
-    if (c == '=' || c == '~' || c == '<' || c == '>') {
-        nc = sgetc ();
-        if (nc == '=') {
-            switch (c) {
-            case '=': return L_EQ;
-            case '~': return L_NE;
-            case '<': return L_LE;
-            case '>': return L_GE;
-            }
-        } else {
-            sungetc ();
-            switch (c) {
-            case '=': return L_ASSIGN;
-            case '~': return L_NOT;
-            case '<': return L_LT;
-            case '>': return L_GT;
-            }
-        }
-    }
-    return L_EOF;
-}
-
-static int sgetc (void) {
-    if (seeneof)
-        return EOF;
-    if (strcmp(ucp, "") == 0) {
-        if (lsrc == CHARSRC) {
-            seeneof = TRUE;
-            linenum++;
-            return EOF;
-        } else if (lsrc == FILESRC) {
-            if (ucp != unitp)
-                *unitp = *(ucp - 1), ucp = unitp + 1;
-            else
-                ucp = unitp;
-            *ucp = '\000';
-            if (!fgets (ucp, MAXBUF - (ucp - unitp), lfp)) {
-                seeneof = TRUE;
-                return EOF;
-            }
-        }
-    }
-    if (*ucp == '\n')
-        linenum++;
-    return *ucp++;
-}
-
-static void sungetc (void) {
-    if (seeneof) {
-        seeneof = FALSE;
-        return;
-    }
-    if (ucp == unitp)
-        panic1 (POS, "sungetc", "unget before start of string");
-    ucp--;
-    if (*ucp == '\n')
-        linenum--;
-}
diff --git a/cmd/lefty/lex.h b/cmd/lefty/lex.h
deleted file mode 100644 (file)
index cbeeea6..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#define L_SEMI      0
-#define L_ASSIGN    1
-#define L_OR        2
-#define L_AND       3
-#define L_EQ        4
-#define L_NE        5
-#define L_LT        6
-#define L_LE        7
-#define L_GT        8
-#define L_GE        9
-#define L_PLUS     10
-#define L_MINUS    11
-#define L_MUL      12
-#define L_DIV      13
-#define L_MOD      14
-#define L_NOT      15
-#define L_STRING   16
-#define L_NUMBER   17
-#define L_ID       18
-#define L_DOT      19
-#define L_LB       20
-#define L_RB       21
-#define L_FUNCTION 22
-#define L_LP       23
-#define L_RP       24
-#define L_LCB      25
-#define L_RCB      26
-#define L_LOCAL    27
-#define L_COLON    28
-#define L_COMMA    29
-#define L_IF       30
-#define L_ELSE     31
-#define L_WHILE    32
-#define L_FOR      33
-#define L_IN       34
-#define L_BREAK    35
-#define L_CONTINUE 36
-#define L_RETURN   37
-#define L_INTERNAL 38
-#define L_EOF      39
-#define L_SIZE     40
-
-#define MAXTOKEN 1000
-typedef char *Lname_t;
-
-extern int Ltok;
-extern char Lstrtok[];
-extern Lname_t Lnames[];
-
-void Lsetsrc (int, char *, FILE *, int, int);
-void Lgetsrc (int *, char **, FILE **, int *, int *);
-void Lprintpos (void);
-void Lgtok (void);
diff --git a/cmd/lefty/mem.c b/cmd/lefty/mem.c
deleted file mode 100644 (file)
index b19e48d..0000000
+++ /dev/null
@@ -1,400 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "mem.h"
-#include <stdbool.h>
-
-/* SHORTCUT: the following are imported from tbl.c */
-extern void Tgchelper (void *), Tfreehelper (void *);
-
-#define M_MAXTYPES 6
-
-bool Mhaspointers[M_MAXTYPES];
-int Mgcstate;
-int Mcouldgc;
-
-typedef struct buffer_t {
-    void *data;
-    struct buffer_t *next;
-} buffer_t;
-#define BUFLEN sizeof (buffer_t)
-static buffer_t *bufferlist;
-
-typedef struct freeobj_t {
-    Mheader_t head;
-    void *next;
-} freeobj_t;
-#define FREEOBJSIZE sizeof (freeobj_t)
-#define FREESIZE sizeof (void *)
-static void **freearray;
-static long freen;
-
-#define MARKSIZE sizeof (void *)
-#define MARKINCR 100l
-static void **markarray;
-static long markn, marki;
-
-#define OTSIZE sizeof (void *)
-#define OTINCR 1000l
-static void **otarray[2];
-static long otn, oti, otj;
-static char otarea[2];
-
-static void (*cbfunc) (void);
-
-#define GCINCRSTEPS 4
-static int gcsteps = GCINCRSTEPS;
-
-#define NUMOFALLOCS 1024
-static int numofallocs = 0;
-
-#define CALCNUM(size) ((size < 20) ? 1000 : ((size < 200) ? 100 : 1))
-
-#ifdef STATS
-static caddr_t origsbrk, finsbrk;
-static long objnum, objsiz;
-static long typenum[M_MAXTYPES], typesiz[M_MAXTYPES];
-#endif
-
-static void allocbuffer (long);
-
-void Minit (void (*func) (void)) {
-
-#ifdef STATS
-    int i;
-
-    origsbrk = (caddr_t) sbrk (0);
-    for (i = 0; i < M_MAXTYPES; i++)
-        typenum[i] = typesiz[i] = 0;
-#endif
-
-    freearray = Marrayalloc ((long) FREESIZE);
-    freen = 1;
-    freearray[0] = NULL;
-    markarray = Marrayalloc(MARKINCR * MARKSIZE);
-    markn = MARKINCR;
-    marki = 0;
-    otarray[0] = Marrayalloc(OTINCR * OTSIZE);
-    otarray[1] = Marrayalloc(OTINCR * OTSIZE);
-    otn = OTINCR;
-    oti = otj = 0;
-    otarea[0] = 1, otarea[1] = 2;
-    cbfunc = func;
-    Mcouldgc = FALSE;
-}
-
-void Mterm (void) {
-    buffer_t *bp;
-
-#ifdef STATS
-    finsbrk = (caddr_t) sbrk (0);
-    printf ("memory used by data: %ld\n", (long) (finsbrk - origsbrk));
-#endif
-
-    Marrayfree (otarray[0]), Marrayfree (otarray[1]);
-    otarray[0] = otarray[1] = NULL;
-    otn = otj = oti = 0;
-    Marrayfree (freearray), freearray = NULL, freen = 0;
-    Marrayfree (markarray), markarray = NULL, markn = marki = 0;
-    for (bp = bufferlist; bp; ) {
-        free (bp->data);
-        bufferlist = bp, bp = bp->next, free (bufferlist);
-    }
-    bufferlist = NULL;
-}
-
-void *Mnew (long size, int type) {
-    freeobj_t *fp;
-
-    size = (
-        size < FREEOBJSIZE
-    ) ? M_BYTE2SIZE (FREEOBJSIZE) : M_BYTE2SIZE (size);
-    if (size >= freen || !freearray[size]) {
-        allocbuffer (size), numofallocs++;
-        if (numofallocs == NUMOFALLOCS)
-            Mdogc (M_GCFULL), gcsteps <<= 1, numofallocs = 0;
-        else
-            Mdogc (M_GCINCR);
-    } else if (Mgcstate == M_GCON)
-        Mdogc (M_GCINCR);
-    fp = freearray[size], freearray[size] = fp->next;
-    fp->head.type = type;
-    Mmkcurr (fp);
-    Mcouldgc = TRUE;
-
-#ifdef STATS
-    objnum++, objsiz += size;
-    typenum[type]++, typesiz[type] += size;
-#endif
-
-    return fp;
-}
-
-void *Mallocate (long size) {
-    freeobj_t *fp;
-
-    size = (
-        size < FREEOBJSIZE
-    ) ? M_BYTE2SIZE (FREEOBJSIZE) : M_BYTE2SIZE (size);
-    if (size >= freen || !freearray[size])
-        allocbuffer (size);
-    fp = freearray[size], freearray[size] = fp->next;
-    return fp;
-}
-
-void Mfree (void *p, long size) {
-    freeobj_t *fp;
-
-    fp = p;
-    fp->head.size = size;
-    fp->head.area = 0;
-    fp->head.type = 0;
-    fp->next = freearray[fp->head.size], freearray[fp->head.size] = fp;
-}
-
-#ifndef FEATURE_MS
-
-void *Marrayalloc (long size) {
-    void *p;
-
-    if (!(p = malloc (size)))
-        panic1 (POS, "Marrayallocate", "cannot allocate array");
-    return p;
-}
-
-void *Marraygrow (void *p, long size) {
-    if (!(p = realloc (p, size)))
-        panic1 (POS, "Marrayreallocate", "cannot re-allocate array");
-    return p;
-}
-
-void Marrayfree (void *p) {
-    free (p);
-}
-
-#else
-
-static struct arraymap_t {
-    HGLOBAL k;
-    void *v;
-} arraymap[100];
-
-void *Marrayalloc (long size) {
-    int i;
-
-    for (i = 0; i < 100; i++)
-        if (!arraymap[i].k)
-            break;
-    if (i == 100)
-        panic1 (POS, "Marrayalloc", "out of space in arraymap");
-    if (!(arraymap[i].k = GlobalAlloc (GPTR, size)))
-        panic1 (POS, "Marrayallocate", "cannot allocate array");
-    arraymap[i].v = GlobalLock (arraymap[i].k);
-    return arraymap[i].v;
-}
-
-void *Marraygrow (void *p, long size) {
-    int i;
-
-    for (i = 0; i < 100; i++)
-        if (arraymap[i].v == p)
-            break;
-    if (i == 100)
-        panic1 (POS, "Marraygrow", "cannot locate pointer");
-    if (!(arraymap[i].k = GlobalReAlloc (arraymap[i].k, size, GMEM_MOVEABLE)))
-        panic1 (POS, "Marraygrow", "cannot re-allocate array");
-    arraymap[i].v = GlobalLock (arraymap[i].k);
-    return arraymap[i].v;
-}
-
-void Marrayfree (void *p) {
-    int i;
-
-    for (i = 0; i < 100; i++)
-        if (arraymap[i].v == p)
-            break;
-    if (i == 100)
-        panic1 (POS, "Marrayfree", "cannot locate pointer");
-    GlobalUnlock (arraymap[i].k);
-    GlobalFree (arraymap[i].k);
-    arraymap[i].k = 0;
-}
-
-#endif
-
-long Mpushmark (void *p) {
-    if (marki == markn) {
-        markarray = Marraygrow(markarray, (markn + MARKINCR) * MARKSIZE);
-        markn += MARKINCR;
-    }
-    markarray[marki++] = p;
-    if (Mgcstate == M_GCON)
-        Mmkcurr (p);
-    return marki - 1;
-}
-
-void Mpopmark (long m) {
-    if (m >= 0 && m < marki)
-        marki = m;
-    else
-        warning (POS, "Mpopmark", "mark out of range");
-}
-
-void Mresetmark (long m, void *p) {
-    markarray[m] = p;
-    if (Mgcstate == M_GCON)
-        Mmkcurr (p);
-}
-
-void Mmkcurr (void *p) {
-    if (!p || M_AREAOF (p) == otarea[0])
-        return;
-    if (oti >= otn) {
-        otarray[0] = Marraygrow(otarray[0], (otn + OTINCR) * OTSIZE);
-        otarray[1] = Marraygrow(otarray[1], (otn + OTINCR) * OTSIZE);
-        otn += OTINCR;
-    }
-    otarray[0][oti++] = p;
-    ((Mheader_t *) p)->area = otarea[0];
-}
-
-void Mdogc (int gctype) {
-    void *p;
-    long i;
-    char n;
-    static long prevoti;
-
-    if (Mgcstate == M_GCOFF) {
-        Mgcstate = M_GCON;
-        p = otarray[0], otarray[0] = otarray[1], otarray[1] = p;
-        n = otarea[0], otarea[0] = otarea[1], otarea[1] = n;
-        prevoti = oti, oti = otj = 0;
-        for (i = 0; i < marki; i++)
-            Mmkcurr (markarray[i]);
-    }
-    if (gctype == M_GCFULL) {
-        while (otj != oti) {
-            p = otarray[0][otj];
-            if (Mhaspointers[M_TYPEOF (p)])
-                Tgchelper (p);
-            otj++;
-        }
-    } else {
-        for (i = 0; i < gcsteps && otj != oti; i++) {
-            p = otarray[0][otj];
-            if (Mhaspointers[M_TYPEOF (p)])
-                Tgchelper (p);
-            otj++;
-        }
-        if (otj < oti)
-            return;
-    }
-    for (i = 0; i < prevoti; i++) {
-        p = otarray[1][i];
-        if (p && M_AREAOF (p) == otarea[1]) {
-            if (Mhaspointers[M_TYPEOF (p)])
-                Tfreehelper (p);
-            Mfree (p, (long) ((Mheader_t *) p)->size);
-        }
-    }
-    if (gctype == M_GCINCR) {
-        if (numofallocs < NUMOFALLOCS / 2) {
-            int t = (gcsteps > GCINCRSTEPS) ? gcsteps >>= 1 : GCINCRSTEPS;
-           t = gcsteps;
-            numofallocs = 0;
-        }
-    }
-    if (cbfunc)
-        (*cbfunc) ();
-    Mgcstate = M_GCOFF;
-    Mcouldgc = FALSE;
-}
-
-void Mreport (void) {
-    Mheader_t *p;
-    long num[M_MAXTYPES], siz[M_MAXTYPES];
-    long i, n;
-    freeobj_t *fp;
-
-    Mdogc (M_GCFULL);
-    Mdogc (M_GCFULL);
-    for (i = 0; i < M_MAXTYPES; i++)
-        num[i] = siz[i] = 0;
-    for (i = 0; i < oti; i++) {
-        p = otarray[0][i];
-        siz[0] += p->size;
-        siz[M_TYPEOF (p)] += p->size;
-        num[M_TYPEOF (p)]++;
-        num[0]++;
-    }
-    fprintf (stderr, "live objects:      %8ld (", num[0]);
-    for (i = 1; i < M_MAXTYPES; i++)
-        fprintf (stderr, "%8ld%s", num[i], (i == M_MAXTYPES - 1) ? "" : ",");
-    fprintf (stderr, ")\n       sizes:      %8ld (", siz[0]);
-    for (i = 1; i < M_MAXTYPES; i++)
-        fprintf (stderr, "%8ld%s", siz[i], (i == M_MAXTYPES - 1) ? "" : ",");
-    fprintf (stderr, ")\n");
-    fprintf (stderr, "free lists: %ld\n", freen);
-    for (i = 0; i < freen; i++) {
-        for (n = 0, fp = freearray[i]; fp; fp = fp->next)
-            n++;
-        if (n > 0)
-            fprintf (stderr, "free list: %ld - %ld\n", i, n);
-    }
-#ifdef STATS
-    printf ("objects allocated: %8d (", objnum);
-    for (i = 1; i < M_MAXTYPES; i++)
-        printf ("%8d%s", typenum[i], (i == M_MAXTYPES - 1) ? "" : ",");
-    printf (")\n            sizes: %8d (", objsiz);
-    for (i = 1; i < M_MAXTYPES; i++)
-        printf ("%8d%s", typesiz[i], (i == M_MAXTYPES - 1) ? "" : ",");
-    printf (")\n");
-    finsbrk = (caddr_t) sbrk (0);
-    printf ("memory used by data: %ld\n", (long) (finsbrk - origsbrk));
-#endif
-}
-
-static void allocbuffer (long size) {
-    buffer_t *bp;
-    char *p;
-    long i, bytes, n;
-
-    if (size >= freen) {
-        if (size > M_SIZEMAX)
-            panic1 (POS, "allocbuffer", "size %d > max size %d: try rebuilding using -DMINTSIZE", size, M_SIZEMAX);
-        freearray = Marraygrow (freearray, (long) (size + 1) * FREESIZE);
-        for (i = freen; i < size + 1; i++)
-            freearray[i] = NULL;
-        freen = size + 1;
-    }
-    n = CALCNUM (size);
-    if (!freearray[size]) {
-        if (!(bp = malloc (BUFLEN)))
-            panic1 (POS, "allocbuffer", "cannot allocate buffer struct");
-        if (!(bp->data = malloc (size * M_UNITSIZE * n)))
-            panic1 (POS, "allocbuffer", "cannot allocate buffer");
-        bp->next = bufferlist, bufferlist = bp;
-        bytes = size * M_UNITSIZE;
-        for (i = 0, p = bp->data; i < n - 1; i++, p += bytes) {
-            ((freeobj_t *) p)->next = p + bytes;
-            ((freeobj_t *) p)->head.size = (Msize_t) size;
-            ((freeobj_t *) p)->head.area = 0;
-            ((freeobj_t *) p)->head.type = 0;
-        }
-        ((freeobj_t *) p)->next = NULL;
-        ((freeobj_t *) p)->head.size = (Msize_t) size;
-        ((freeobj_t *) p)->head.area = 0;
-        ((freeobj_t *) p)->head.type = 0;
-        freearray[size] = bp->data;
-    }
-}
diff --git a/cmd/lefty/mem.h b/cmd/lefty/mem.h
deleted file mode 100644 (file)
index df17c17..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-#include <stdbool.h>
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#ifdef FEATURE_MINTSIZE
-typedef int Msize_t;
-#define M_SIZEMAX INT_MAX
-#else
-typedef short Msize_t;
-#define M_SIZEMAX SHRT_MAX
-#endif
-typedef struct Mheader_t {
-    char type;
-    char area;
-    Msize_t size;
-} Mheader_t;
-#define M_HEADERSIZE sizeof (Mheader_t)
-
-#define M_GCOFF 0
-#define M_GCON  1
-
-#define M_GCFULL 0
-#define M_GCINCR 1
-
-#define M_UNITSIZE sizeof (long)
-#define M_BYTE2SIZE(l) ((long) (((l + M_UNITSIZE - 1) / M_UNITSIZE)))
-#define M_AREAOF(p) ((int) (((Mheader_t *) p)->area))
-#define M_TYPEOF(p) ((int) (((Mheader_t *) p)->type))
-
-extern bool Mhaspointers[];
-extern int Mgcstate;
-extern int Mcouldgc;
-
-void Minit (void (*) (void));
-void Mterm (void);
-void *Mnew (long, int);
-void *Mallocate (long);
-void Mfree (void *, long);
-void *Marrayalloc (long);
-void *Marraygrow (void *, long);
-void Marrayfree (void *);
-long Mpushmark (void *);
-void Mpopmark (long);
-void Mresetmark (long, void *);
-void Mmkcurr (void *);
-void Mdogc (int);
-void Mreport (void);
diff --git a/cmd/lefty/os/mswin32/doinst b/cmd/lefty/os/mswin32/doinst
deleted file mode 100755 (executable)
index 4374379..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-set -x
-
-if [[ $1 == '' || $1 == '-d' ]] then
-    cp -p debug/lefty.exe ../bin
-elif [[ $1 == '-a' ]] then
-    cp -p release/lefty.exe ../bin
-fi
diff --git a/cmd/lefty/os/mswin32/io.c b/cmd/lefty/os/mswin32/io.c
deleted file mode 100644 (file)
index b839115..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "leftyio.h"
-#include "mem.h"
-#include <stdbool.h>
-
-io_t *iop;
-int ion;
-
-static void pipeopen (char *, FILE **, FILE **, int *);
-
-void IOinit (void) {
-    struct stat statbuf;
-    int ioi;
-
-    iop = Marrayalloc ((long) IOINCR * IOSIZE);
-    ion = IOINCR;
-    for (ioi = 0; ioi < ion; ioi++)
-        iop[ioi].inuse = FALSE;
-    for (ioi = 0; ioi < 3; ioi++)
-        if (fstat (ioi, &statbuf) == 0) {
-            iop[ioi].inuse = TRUE;
-            iop[ioi].type = IO_FILE;
-            iop[ioi].ifp = iop[ioi].ofp = fdopen (ioi, "r+");
-            if (!(iop[ioi].buf = malloc (IOBUFSIZE)))
-                panic1 (POS, "IOinit", "malloc failed");
-            iop[ioi].buf[0] = 0;
-        }
-}
-
-void IOterm (void) {
-    int ioi;
-
-    for (ioi = 0; ioi < ion; ioi++)
-        if (iop[ioi].inuse)
-            IOclose (ioi, NULL);
-    Marrayfree (iop), iop = NULL, ion = 0;
-}
-
-int IOopen (char *kind, char *name, char *mode, char *fmt) {
-    io_t *p;
-    int type;
-    char *path, *command;
-    int i;
-    int count = 0;
-
-    if (strcmp (kind, "file") == 0)
-        type = IO_FILE;
-    else if (strcmp (kind, "pipe") == 0)
-        type = IO_PIPE;
-    else
-        return -1;
-
-    for (i = 0; i < ion; i++)
-        if (!iop[i].inuse)
-            break;
-    if (i == ion) {
-        iop = Marraygrow (iop, (long) (ion + IOINCR) * IOSIZE);
-        for (i = ion + IOINCR - 1; i >= ion; i--)
-            iop[i].inuse = FALSE;
-        i++, ion += IOINCR;
-    }
-    p = &iop[i];
-    p->type = type;
-    if (!(p->buf = malloc (IOBUFSIZE)))
-        panic1 (POS, "IOopen", "malloc failed");
-    p->buf[0] = 0;
-    switch (type) {
-    case IO_FILE:
-        if (!(p->ifp = p->ofp = fopen (name, mode))) {
-            path = buildpath (name, false);
-            if (!path || !(p->ifp = p->ofp = fopen (path, mode)))
-                return -1;
-        }
-        break;
-    case IO_PIPE:
-        if (!fmt)
-            fmt = "%e";
-        if (
-            !(path = buildpath (name, true)) ||
-            !(command = buildcommand (path, NULL, -1, -1, fmt))
-        )
-            return -1;
-        pipeopen (command, &p->ifp, &p->ofp, &p->pid);
-        if (!p->ifp || !p->ofp)
-            return -1;
-        break;
-    }
-    p->inuse = TRUE;
-    return i;
-}
-
-int IOclose (int ioi, char *action) {
-    io_t *p;
-
-    if (ioi < 0 || ioi >= ion || !iop[ioi].inuse)
-        return -1;
-
-    p = &iop[ioi];
-    free (p->buf);
-    switch (p->type) {
-    case IO_FILE:
-        fclose (p->ifp);
-        fclose (p->ofp);
-        break;
-    case IO_PIPE:
-        CloseHandle (p->ifp);
-        CloseHandle (p->ofp);
-        break;
-    }
-    p->inuse = FALSE;
-    return 0;
-}
-
-int IOreadline (int ioi, char *bufp, int bufn) {
-    io_t *p;
-    DWORD n;
-    int l, i, m;
-
-    if (ioi < 0 || ioi >= ion || !iop[ioi].inuse)
-        return -1;
-
-    p = &iop[ioi];
-    switch (p->type) {
-    case IO_FILE:
-        if (fgets (bufp, bufn, p->ifp) == NULL)
-            return -1;
-        break;
-    case IO_PIPE:
-        l = 0;
-        if (p->buf[0]) {
-            for (l = 0; l < bufn - 1 && p->buf[l]; l++)
-                if ((bufp[l] = p->buf[l]) == '\n') {
-                    l++;
-                    break;
-                }
-            for (i = l; p->buf[i]; i++)
-                p->buf[i - l] = p->buf[i];
-            p->buf[i - l] = 0;
-            bufp[l] = 0;
-            if (bufp[l - 1] == '\n')
-                break; /* exit switch */
-        }
-        while (l < bufn - 1) {
-            m = bufn - l - 1;
-            if (m > IOBUFSIZE - 1)
-                m = IOBUFSIZE - 1;
-            if (!ReadFile (p->ifp, bufp + l, m, &n, NULL))
-                return -1;
-            for (m = l; m < l + n; m++)
-                if (bufp[m] == '\n') {
-                    m++;
-                    break;
-                }
-            for (i = m; i < l + n; i++)
-                p->buf[i - m] = bufp[i];
-            bufp[m] = 0;
-            p->buf[i - m] = 0;
-            if (bufp[m - 1] == '\n')
-                break;
-            l += n;
-        }
-        break;
-    }
-    l = strlen (bufp) - 1;
-    while (bufp[l] == '\n' || bufp[l] == '\r')
-        bufp[l--] = '\000';
-    return 0;
-}
-
-int IOread (int ioi, char *bufp, int bufn) {
-    io_t *p;
-    DWORD l;
-
-    if (ioi < 0 || ioi >= ion || !iop[ioi].inuse)
-        return -1;
-
-    p = &iop[ioi];
-    switch (p->type) {
-    case IO_FILE:
-        if ((l = read (fileno (p->ifp), bufp, bufn - 1)) == -1)
-            return -1;
-        else if (l == 0)
-            return 0;
-        break;
-    case IO_PIPE:
-        if (!ReadFile (p->ifp, bufp, bufn - 1, &l, NULL))
-            return -1;
-        if (l == 0)
-            return 0;
-        break;
-    }
-    bufp[l] = '\000';
-    return l;
-}
-
-int IOwriteline (int ioi, char *bufp) {
-    io_t *p;
-    DWORD l;
-
-    if (ioi < 0 || ioi >= ion || !iop[ioi].inuse)
-        return -1;
-
-    p = &iop[ioi];
-    switch (p->type) {
-    case IO_FILE:
-        if (fputs (bufp, p->ofp) == EOF || fputs ("\n", p->ofp) == EOF)
-            return -1;
-        fflush (p->ofp);
-        break;
-    case IO_PIPE:
-        if (
-            !WriteFile (p->ofp, bufp, strlen (bufp), &l, NULL) ||
-            !WriteFile (p->ofp, "\n", 1, &l, NULL)
-        )
-            return -1;
-        break;
-    }
-    return 0;
-}
-
-static void pipeopen (char *cmd, FILE **ifp, FILE **ofp, int *pidp) {
-    PROCESS_INFORMATION pinfo;
-    STARTUPINFO sinfo;
-    SECURITY_ATTRIBUTES sattr;
-    HANDLE h, p1[2], p2[2], save[2];
-
-    sattr.nLength = sizeof (SECURITY_ATTRIBUTES);
-    sattr.bInheritHandle = TRUE;
-    sattr.lpSecurityDescriptor = NULL;
-
-    if (
-        !CreatePipe (&p1[0], &p1[1], &sattr, 0) ||
-        !CreatePipe (&p2[0], &p2[1], &sattr, 0)
-    ) {
-        *ifp = NULL;
-        return;
-    }
-    save[0] = GetStdHandle (STD_INPUT_HANDLE);
-    save[1] = GetStdHandle (STD_OUTPUT_HANDLE);
-    if (!SetStdHandle (STD_OUTPUT_HANDLE, p1[1]))
-        panic1 (POS, "pipeopen", "cannot set stdout handle");
-    if (!SetStdHandle (STD_INPUT_HANDLE, p2[0]))
-        panic1 (POS, "pipeopen", "cannot set stdin handle");
-    h = p1[0];
-    if (!DuplicateHandle (
-        GetCurrentProcess (), h, GetCurrentProcess (), &p1[0], 0, FALSE,
-        DUPLICATE_SAME_ACCESS
-    ))
-        panic1 (POS, "pipeopen", "cannot dup input handle");
-    CloseHandle (h);
-    h = p2[1];
-    if (!DuplicateHandle (
-        GetCurrentProcess(), h, GetCurrentProcess(), &p2[1], 0, FALSE,
-        DUPLICATE_SAME_ACCESS
-    ))
-        panic1 (POS, "pipeopen", "cannot dup output handle");
-    CloseHandle (h);
-    sinfo.cb = sizeof (STARTUPINFO);
-    sinfo.lpReserved = NULL;
-    sinfo.lpDesktop = NULL;
-    sinfo.lpTitle = NULL;
-    sinfo.cbReserved2 = 0;
-    sinfo.lpReserved2 = NULL;
-    sinfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
-    sinfo.hStdInput = p2[0];
-    sinfo.hStdOutput = p1[1];
-    sinfo.wShowWindow = SW_HIDE;
-    if (!CreateProcess (
-        NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &sinfo, &pinfo
-    ))
-        panic1 (POS, "pipeopen", "cannot create child process");
-    *pidp = pinfo.hProcess;
-    if (!SetStdHandle (STD_INPUT_HANDLE, save[0]))
-        panic1 (POS, "pipeopen", "cannot restore stdin");
-    if (!SetStdHandle (STD_OUTPUT_HANDLE, save[1]))
-        panic1 (POS, "pipeopen", "cannot restore stdout");
-    CloseHandle (p1[1]);
-    CloseHandle (p2[0]);
-    *ifp = p1[0], *ofp = p2[1];
-    return;
-}
diff --git a/cmd/lefty/os/mswin32/lefty.mak b/cmd/lefty/os/mswin32/lefty.mak
deleted file mode 100644 (file)
index ae95d3f..0000000
+++ /dev/null
@@ -1,901 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-!IF "$(CFG)" == ""
-CFG=lefty - Win32 Debug
-!MESSAGE No configuration specified.  Defaulting to lefty - Win32 Debug.
-!ENDIF 
-
-!IF "$(CFG)" != "lefty - Win32 Release" && "$(CFG)" != "lefty - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE on this makefile
-!MESSAGE by defining the macro CFG on the command line.  For example:
-!MESSAGE 
-!MESSAGE NMAKE /f "lefty.mak" CFG="lefty - Win32 Debug"
-!MESSAGE 
-!MESSAGE Possible choices for configuration are:
-!MESSAGE 
-!MESSAGE "lefty - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "lefty - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE 
-!ERROR An invalid configuration is specified.
-!ENDIF 
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE 
-NULL=nul
-!ENDIF 
-################################################################################
-# Begin Project
-# PROP Target_Last_Scanned "lefty - Win32 Debug"
-CPP=cl.exe
-RSC=rc.exe
-MTL=mktyplib.exe
-
-!IF  "$(CFG)" == "lefty - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-OUTDIR=.\Release
-INTDIR=.\Release
-
-ALL : "$(OUTDIR)\lefty.exe"
-
-CLEAN : 
-       -@erase "$(INTDIR)\code.obj"
-       -@erase "$(INTDIR)\common.obj"
-       -@erase "$(INTDIR)\display.obj"
-       -@erase "$(INTDIR)\dot2l.obj"
-       -@erase "$(INTDIR)\dotlex.obj"
-       -@erase "$(INTDIR)\dotparse.obj"
-       -@erase "$(INTDIR)\dottrie.obj"
-       -@erase "$(INTDIR)\exec.obj"
-       -@erase "$(INTDIR)\g.obj"
-       -@erase "$(INTDIR)\garray.obj"
-       -@erase "$(INTDIR)\gbutton.obj"
-       -@erase "$(INTDIR)\gcanvas.obj"
-       -@erase "$(INTDIR)\gcommon.obj"
-       -@erase "$(INTDIR)\gfxview.obj"
-       -@erase "$(INTDIR)\glabel.obj"
-       -@erase "$(INTDIR)\gmenu.obj"
-       -@erase "$(INTDIR)\gpcanvas.obj"
-       -@erase "$(INTDIR)\gquery.obj"
-       -@erase "$(INTDIR)\gscroll.obj"
-       -@erase "$(INTDIR)\gtext.obj"
-       -@erase "$(INTDIR)\gview.obj"
-       -@erase "$(INTDIR)\internal.obj"
-       -@erase "$(INTDIR)\io.obj"
-       -@erase "$(INTDIR)\lefty.obj"
-       -@erase "$(INTDIR)\lefty.res"
-       -@erase "$(INTDIR)\lex.obj"
-       -@erase "$(INTDIR)\mem.obj"
-       -@erase "$(INTDIR)\parse.obj"
-       -@erase "$(INTDIR)\str.obj"
-       -@erase "$(INTDIR)\tbl.obj"
-       -@erase "$(INTDIR)\txtview.obj"
-       -@erase "$(OUTDIR)\lefty.exe"
-
-"$(OUTDIR)" :
-    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "MSWIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /W3 /GX /O2 /I "." /I "./dot2l" /I ".\ws\mswin32" /D "NDEBUG" /D "HAVENETSCAPE" /D "MSWIN32" /D "_WINDOWS" /D "HAVEDOT" /D "HAVEMSWIN" /D "HAVEMSWIN32" /D LEFTYPATH=\"\\home\\ek\\work\\lib\\lefty\" /YX /c
-# SUBTRACT CPP /Fr
-CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "." /I "./dot2l" /I ".\ws\mswin32" /D\
- "NDEBUG" /D "HAVENETSCAPE" /D "MSWIN32" /D "_WINDOWS" /D "HAVEDOT" /D\
- "HAVEMSWIN" /D "HAVEMSWIN32" /D LEFTYPATH=\"\\home\\ek\\work\\lib\\lefty\"\
- /Fp"$(INTDIR)/lefty.pch" /YX /Fo"$(INTDIR)/" /c 
-CPP_OBJS=.\Release/
-CPP_SBRS=.\.
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /win32
-MTL_PROJ=/nologo /D "NDEBUG" /win32 
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-RSC_PROJ=/l 0x409 /fo"$(INTDIR)/lefty.res" /d "NDEBUG" 
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/lefty.bsc" 
-BSC32_SBRS= \
-       
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
- advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:no\
- /pdb:"$(OUTDIR)/lefty.pdb" /machine:I386 /out:"$(OUTDIR)/lefty.exe" 
-LINK32_OBJS= \
-       "$(INTDIR)\code.obj" \
-       "$(INTDIR)\common.obj" \
-       "$(INTDIR)\display.obj" \
-       "$(INTDIR)\dot2l.obj" \
-       "$(INTDIR)\dotlex.obj" \
-       "$(INTDIR)\dotparse.obj" \
-       "$(INTDIR)\dottrie.obj" \
-       "$(INTDIR)\exec.obj" \
-       "$(INTDIR)\g.obj" \
-       "$(INTDIR)\garray.obj" \
-       "$(INTDIR)\gbutton.obj" \
-       "$(INTDIR)\gcanvas.obj" \
-       "$(INTDIR)\gcommon.obj" \
-       "$(INTDIR)\gfxview.obj" \
-       "$(INTDIR)\glabel.obj" \
-       "$(INTDIR)\gmenu.obj" \
-       "$(INTDIR)\gpcanvas.obj" \
-       "$(INTDIR)\gquery.obj" \
-       "$(INTDIR)\gscroll.obj" \
-       "$(INTDIR)\gtext.obj" \
-       "$(INTDIR)\gview.obj" \
-       "$(INTDIR)\internal.obj" \
-       "$(INTDIR)\io.obj" \
-       "$(INTDIR)\lefty.obj" \
-       "$(INTDIR)\lefty.res" \
-       "$(INTDIR)\lex.obj" \
-       "$(INTDIR)\mem.obj" \
-       "$(INTDIR)\parse.obj" \
-       "$(INTDIR)\str.obj" \
-       "$(INTDIR)\tbl.obj" \
-       "$(INTDIR)\txtview.obj"
-
-"$(OUTDIR)\lefty.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-    $(LINK32) @<<
-  $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF  "$(CFG)" == "lefty - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-OUTDIR=.\Debug
-INTDIR=.\Debug
-
-ALL : "$(OUTDIR)\lefty.exe"
-
-CLEAN : 
-       -@erase "$(INTDIR)\code.obj"
-       -@erase "$(INTDIR)\common.obj"
-       -@erase "$(INTDIR)\display.obj"
-       -@erase "$(INTDIR)\dot2l.obj"
-       -@erase "$(INTDIR)\dotlex.obj"
-       -@erase "$(INTDIR)\dotparse.obj"
-       -@erase "$(INTDIR)\dottrie.obj"
-       -@erase "$(INTDIR)\exec.obj"
-       -@erase "$(INTDIR)\g.obj"
-       -@erase "$(INTDIR)\garray.obj"
-       -@erase "$(INTDIR)\gbutton.obj"
-       -@erase "$(INTDIR)\gcanvas.obj"
-       -@erase "$(INTDIR)\gcommon.obj"
-       -@erase "$(INTDIR)\gfxview.obj"
-       -@erase "$(INTDIR)\glabel.obj"
-       -@erase "$(INTDIR)\gmenu.obj"
-       -@erase "$(INTDIR)\gpcanvas.obj"
-       -@erase "$(INTDIR)\gquery.obj"
-       -@erase "$(INTDIR)\gscroll.obj"
-       -@erase "$(INTDIR)\gtext.obj"
-       -@erase "$(INTDIR)\gview.obj"
-       -@erase "$(INTDIR)\internal.obj"
-       -@erase "$(INTDIR)\io.obj"
-       -@erase "$(INTDIR)\lefty.obj"
-       -@erase "$(INTDIR)\lefty.res"
-       -@erase "$(INTDIR)\lex.obj"
-       -@erase "$(INTDIR)\mem.obj"
-       -@erase "$(INTDIR)\parse.obj"
-       -@erase "$(INTDIR)\str.obj"
-       -@erase "$(INTDIR)\tbl.obj"
-       -@erase "$(INTDIR)\txtview.obj"
-       -@erase "$(INTDIR)\vc40.idb"
-       -@erase "$(INTDIR)\vc40.pdb"
-       -@erase "$(OUTDIR)\lefty.exe"
-       -@erase "$(OUTDIR)\lefty.ilk"
-       -@erase "$(OUTDIR)\lefty.pdb"
-
-"$(OUTDIR)" :
-    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "MSWIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "." /I "./dot2l" /I ".\ws\mswin32" /D "_DEBUG" /D "HAVENETSCAPE" /D "MSWIN32" /D "_WINDOWS" /D "HAVEDOT" /D "HAVEMSWIN" /D "HAVEMSWIN32" /D LEFTYPATH=\"\\home\\ek\\work\\lib\\lefty\" /YX /c
-# SUBTRACT CPP /Fr
-CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "." /I "./dot2l" /I ".\ws\mswin32"\
- /D "_DEBUG" /D "HAVENETSCAPE" /D "MSWIN32" /D "_WINDOWS" /D "HAVEDOT" /D\
- "HAVEMSWIN" /D "HAVEMSWIN32" /D LEFTYPATH=\"\\home\\ek\\work\\lib\\lefty\"\
- /Fp"$(INTDIR)/lefty.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c 
-CPP_OBJS=.\Debug/
-CPP_SBRS=.\.
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /win32
-MTL_PROJ=/nologo /D "_DEBUG" /win32 
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-RSC_PROJ=/l 0x409 /fo"$(INTDIR)/lefty.res" /d "_DEBUG" 
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/lefty.bsc" 
-BSC32_SBRS= \
-       
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
- advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:yes\
- /pdb:"$(OUTDIR)/lefty.pdb" /debug /machine:I386 /out:"$(OUTDIR)/lefty.exe" 
-LINK32_OBJS= \
-       "$(INTDIR)\code.obj" \
-       "$(INTDIR)\common.obj" \
-       "$(INTDIR)\display.obj" \
-       "$(INTDIR)\dot2l.obj" \
-       "$(INTDIR)\dotlex.obj" \
-       "$(INTDIR)\dotparse.obj" \
-       "$(INTDIR)\dottrie.obj" \
-       "$(INTDIR)\exec.obj" \
-       "$(INTDIR)\g.obj" \
-       "$(INTDIR)\garray.obj" \
-       "$(INTDIR)\gbutton.obj" \
-       "$(INTDIR)\gcanvas.obj" \
-       "$(INTDIR)\gcommon.obj" \
-       "$(INTDIR)\gfxview.obj" \
-       "$(INTDIR)\glabel.obj" \
-       "$(INTDIR)\gmenu.obj" \
-       "$(INTDIR)\gpcanvas.obj" \
-       "$(INTDIR)\gquery.obj" \
-       "$(INTDIR)\gscroll.obj" \
-       "$(INTDIR)\gtext.obj" \
-       "$(INTDIR)\gview.obj" \
-       "$(INTDIR)\internal.obj" \
-       "$(INTDIR)\io.obj" \
-       "$(INTDIR)\lefty.obj" \
-       "$(INTDIR)\lefty.res" \
-       "$(INTDIR)\lex.obj" \
-       "$(INTDIR)\mem.obj" \
-       "$(INTDIR)\parse.obj" \
-       "$(INTDIR)\str.obj" \
-       "$(INTDIR)\tbl.obj" \
-       "$(INTDIR)\txtview.obj"
-
-"$(OUTDIR)\lefty.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-    $(LINK32) @<<
-  $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF 
-
-.c{$(CPP_OBJS)}.obj:
-   $(CPP) $(CPP_PROJ) $<  
-
-.cpp{$(CPP_OBJS)}.obj:
-   $(CPP) $(CPP_PROJ) $<  
-
-.cxx{$(CPP_OBJS)}.obj:
-   $(CPP) $(CPP_PROJ) $<  
-
-.c{$(CPP_SBRS)}.sbr:
-   $(CPP) $(CPP_PROJ) $<  
-
-.cpp{$(CPP_SBRS)}.sbr:
-   $(CPP) $(CPP_PROJ) $<  
-
-.cxx{$(CPP_SBRS)}.sbr:
-   $(CPP) $(CPP_PROJ) $<  
-
-################################################################################
-# Begin Target
-
-# Name "lefty - Win32 Release"
-# Name "lefty - Win32 Debug"
-
-!IF  "$(CFG)" == "lefty - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "lefty - Win32 Debug"
-
-!ENDIF 
-
-################################################################################
-# Begin Source File
-
-SOURCE=.\txtview.c
-DEP_CPP_TXTVI=\
-       ".\code.h"\
-       ".\common.h"\
-       ".\exec.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\parse.h"\
-       ".\str.h"\
-       ".\tbl.h"\
-       ".\txtview.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\txtview.obj" : $(SOURCE) $(DEP_CPP_TXTVI) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\tbl.c
-DEP_CPP_TBL_C=\
-       ".\code.h"\
-       ".\common.h"\
-       ".\mem.h"\
-       ".\tbl.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\tbl.obj" : $(SOURCE) $(DEP_CPP_TBL_C) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\str.c
-DEP_CPP_STR_C=\
-       ".\code.h"\
-       ".\common.h"\
-       ".\internal.h"\
-       ".\mem.h"\
-       ".\str.h"\
-       ".\tbl.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\str.obj" : $(SOURCE) $(DEP_CPP_STR_C) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\parse.c
-DEP_CPP_PARSE=\
-       ".\code.h"\
-       ".\common.h"\
-       ".\internal.h"\
-       ".\lex.h"\
-       ".\mem.h"\
-       ".\parse.h"\
-       ".\tbl.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\parse.obj" : $(SOURCE) $(DEP_CPP_PARSE) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\mem.c
-DEP_CPP_MEM_C=\
-       ".\common.h"\
-       ".\mem.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\mem.obj" : $(SOURCE) $(DEP_CPP_MEM_C) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\lex.c
-DEP_CPP_LEX_C=\
-       ".\common.h"\
-       ".\lex.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\lex.obj" : $(SOURCE) $(DEP_CPP_LEX_C) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\lefty.c
-DEP_CPP_LEFTY=\
-       ".\code.h"\
-       ".\common.h"\
-       ".\display.h"\
-       ".\exec.h"\
-       ".\g.h"\
-       ".\gfxview.h"\
-       ".\internal.h"\
-       ".\leftyio.h"\
-       ".\mem.h"\
-       ".\parse.h"\
-       ".\str.h"\
-       ".\tbl.h"\
-       ".\txtview.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-NODEP_CPP_LEFTY=\
-       ".\gmap.h"\
-       ".\gmap2l.h"\
-       
-
-"$(INTDIR)\lefty.obj" : $(SOURCE) $(DEP_CPP_LEFTY) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\internal.c
-DEP_CPP_INTER=\
-       ".\./dot2l\dot2l.h"\
-       ".\code.h"\
-       ".\common.h"\
-       ".\display.h"\
-       ".\exec.h"\
-       ".\g.h"\
-       ".\gfxview.h"\
-       ".\internal.h"\
-       ".\leftyio.h"\
-       ".\mem.h"\
-       ".\parse.h"\
-       ".\tbl.h"\
-       ".\txtview.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-NODEP_CPP_INTER=\
-       ".\gmap2l.h"\
-       
-
-"$(INTDIR)\internal.obj" : $(SOURCE) $(DEP_CPP_INTER) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\gfxview.c
-DEP_CPP_GFXVI=\
-       ".\code.h"\
-       ".\colors.txt"\
-       ".\common.h"\
-       ".\exec.h"\
-       ".\g.h"\
-       ".\gfxview.h"\
-       ".\leftyio.h"\
-       ".\mem.h"\
-       ".\parse.h"\
-       ".\tbl.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gfxview.obj" : $(SOURCE) $(DEP_CPP_GFXVI) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\g.c
-DEP_CPP_G_C12=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\g.obj" : $(SOURCE) $(DEP_CPP_G_C12) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\exec.c
-DEP_CPP_EXEC_=\
-       ".\code.h"\
-       ".\common.h"\
-       ".\exec.h"\
-       ".\internal.h"\
-       ".\mem.h"\
-       ".\str.h"\
-       ".\tbl.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\exec.obj" : $(SOURCE) $(DEP_CPP_EXEC_) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\display.c
-DEP_CPP_DISPL=\
-       ".\code.h"\
-       ".\common.h"\
-       ".\display.h"\
-       ".\mem.h"\
-       ".\str.h"\
-       ".\tbl.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\display.obj" : $(SOURCE) $(DEP_CPP_DISPL) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\common.c
-DEP_CPP_COMMO=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\common.obj" : $(SOURCE) $(DEP_CPP_COMMO) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\code.c
-DEP_CPP_CODE_=\
-       ".\code.h"\
-       ".\common.h"\
-       ".\mem.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\code.obj" : $(SOURCE) $(DEP_CPP_CODE_) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\dot2l\dottrie.c
-DEP_CPP_DOTTR=\
-       ".\common.h"\
-       ".\dot2l\triefa.h"\
-       ".\dotparse.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\dottrie.obj" : $(SOURCE) $(DEP_CPP_DOTTR) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\dot2l\dotlex.c
-DEP_CPP_DOTLE=\
-       ".\./dot2l\dot2l.h"\
-       ".\common.h"\
-       ".\dot2l\triefa.c"\
-       ".\dot2l\triefa.h"\
-       ".\dotparse.h"\
-       ".\leftyio.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\dotlex.obj" : $(SOURCE) $(DEP_CPP_DOTLE) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\dot2l\dot2l.c
-DEP_CPP_DOT2L=\
-       ".\./dot2l\dot2l.h"\
-       ".\code.h"\
-       ".\common.h"\
-       ".\leftyio.h"\
-       ".\mem.h"\
-       ".\tbl.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\dot2l.obj" : $(SOURCE) $(DEP_CPP_DOT2L) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\os\mswin32\io.c
-DEP_CPP_IO_C22=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\leftyio.h"\
-       ".\mem.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\io.obj" : $(SOURCE) $(DEP_CPP_IO_C22) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\gview.c
-DEP_CPP_GVIEW=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gview.obj" : $(SOURCE) $(DEP_CPP_GVIEW) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\gtext.c
-DEP_CPP_GTEXT=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gtext.obj" : $(SOURCE) $(DEP_CPP_GTEXT) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\gscroll.c
-DEP_CPP_GSCRO=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gscroll.obj" : $(SOURCE) $(DEP_CPP_GSCRO) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\gquery.c
-DEP_CPP_GQUER=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gquery.obj" : $(SOURCE) $(DEP_CPP_GQUER) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\gpcanvas.c
-DEP_CPP_GPCAN=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gpcanvas.obj" : $(SOURCE) $(DEP_CPP_GPCAN) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\gmenu.c
-DEP_CPP_GMENU=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gmenu.obj" : $(SOURCE) $(DEP_CPP_GMENU) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\glabel.c
-DEP_CPP_GLABE=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\glabel.obj" : $(SOURCE) $(DEP_CPP_GLABE) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\gcommon.c
-DEP_CPP_GCOMM=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gcommon.obj" : $(SOURCE) $(DEP_CPP_GCOMM) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\gcanvas.c
-DEP_CPP_GCANV=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gcanvas.obj" : $(SOURCE) $(DEP_CPP_GCANV) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\gbutton.c
-DEP_CPP_GBUTT=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\gbutton.obj" : $(SOURCE) $(DEP_CPP_GBUTT) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\garray.c
-DEP_CPP_GARRA=\
-       ".\common.h"\
-       ".\g.h"\
-       ".\mem.h"\
-       ".\ws\mswin32\gcommon.h"\
-       {$(INCLUDE)}"\sys\STAT.H"\
-       {$(INCLUDE)}"\sys\TYPES.H"\
-       
-
-"$(INTDIR)\garray.obj" : $(SOURCE) $(DEP_CPP_GARRA) "$(INTDIR)"
-   $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\dotparse.c
-DEP_CPP_DOTPA=\
-       ".\./dot2l\dot2l.h"\
-       
-
-"$(INTDIR)\dotparse.obj" : $(SOURCE) $(DEP_CPP_DOTPA) "$(INTDIR)"
-
-
-# End Source File
-################################################################################
-# Begin Source File
-
-SOURCE=.\ws\mswin32\lefty.rc
-
-!IF  "$(CFG)" == "lefty - Win32 Release"
-
-
-"$(INTDIR)\lefty.res" : $(SOURCE) "$(INTDIR)"
-   $(RSC) /l 0x409 /fo"$(INTDIR)/lefty.res" /i "ws\mswin32" /d "NDEBUG"\
- $(SOURCE)
-
-
-!ELSEIF  "$(CFG)" == "lefty - Win32 Debug"
-
-
-"$(INTDIR)\lefty.res" : $(SOURCE) "$(INTDIR)"
-   $(RSC) /l 0x409 /fo"$(INTDIR)/lefty.res" /i "ws\mswin32" /d "_DEBUG"\
- $(SOURCE)
-
-
-!ENDIF 
-
-# End Source File
-# End Target
-# End Project
-################################################################################
diff --git a/cmd/lefty/os/unix/io.c b/cmd/lefty/os/unix/io.c
deleted file mode 100644 (file)
index 3b39a14..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "leftyio.h"
-#ifdef FEATURE_CS
-#include "cs2l.h"
-#endif
-#include "mem.h"
-#include <fcntl.h>
-#include <signal.h>
-#include <stdbool.h>
-#include <string.h>
-#include <sys/wait.h>
-#ifndef HAVE_TERMIOS_H
-#include <termio.h>
-#else
-#include <termios.h>
-#endif
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifdef FEATURE_VFORK
-#define FORK vfork
-#else
-#define FORK fork
-#endif
-#include <netdb.h>
-#include <unistd.h>
-
-/* AI_NUMERICSERV as a value for the `ai_flags' member
- * of `struct addrinfo' of header <netdb.h> has only
- * been available since:
- *
- *   POSIX 1003.1-2008, Issue 7
- *   glibc 2.3.4
- *   Mac OS X 10.6
- *   etc.
- *
- * Fortunately, its main purpose seems to be only
- * to optimize calls of `getaddrinfo', and because it
- * is meant to be a bit flag, it can therefore be
- * [relatively] safely ignored by defining it to have
- * the value zero.
- */
-
-#ifndef AI_NUMERICSERV
-#define AI_NUMERICSERV 0
-#endif
-
-io_t *iop;
-int ion;
-
-static char *shell;
-static char *shbname;
-
-static FILE *serverconnect (char *);
-static void ptyopen (char *, FILE **, FILE **, int *);
-static int findpty (int *);
-static void pipeopen (char *, FILE **, FILE **, int *);
-static void socketopen (char *, int, FILE **, FILE **, int *);
-
-static void sigchldhandler (int);
-
-void IOinit (void) {
-    struct stat statbuf;
-    int ioi;
-
-    if (!(shell = getenv ("SHELL")))
-        shell = "/bin/sh";
-    if (shell[0] != '/' && shell[0] != '.') {
-        if (!(shell = buildpath (shell, true)))
-            shell = "/bin/sh";
-        else
-            shell = strdup (shell);
-    }
-    shbname = shell + strlen (shell) - 1;
-    while (shbname >= shell && *shbname != '/')
-        shbname--;
-    if (*shbname == '/')
-        shbname++;
-    ion = IOINCR;
-    for (ioi = FD_SETSIZE - 1; ioi >= 0; ioi--) {
-        if (fstat (ioi, &statbuf) == 0) {
-            ion = (ioi / IOINCR + 1) * IOINCR;
-            break;
-        }
-    }
-    iop = Marrayalloc ((long) ion * IOSIZE);
-    for (ioi = 0; ioi < ion; ioi++)
-        iop[ioi].inuse = FALSE;
-    for (ioi = 0; ioi < ion; ioi++) {
-        if (fstat (ioi, &statbuf) == 0) {
-            if ((iop[ioi].ifp = iop[ioi].ofp = fdopen (
-                ioi, (ioi == 0 ? "r" : "w")
-            ))) {
-                iop[ioi].inuse = TRUE;
-                iop[ioi].type = IO_FILE;
-                iop[ioi].ismonitored = FALSE;
-                iop[ioi].pid = -1;
-                iop[ioi].buf = NULL;
-            }
-        }
-    }
-    signal (SIGCHLD, sigchldhandler);
-    signal (SIGPIPE, SIG_IGN);
-}
-
-void IOterm (void) {
-    int ioi;
-
-    for (ioi = 3; ioi < ion; ioi++)
-        if (iop[ioi].inuse)
-            IOclose (ioi, NULL);
-    Marrayfree (iop), iop = NULL, ion = 0;
-}
-
-int IOopen (char *kind, char *name, char *mode, char *fmt) {
-    io_t *p;
-    int type;
-    char *path, *command;
-    char hname[200];
-    int sfd;
-    unsigned int slen;
-    int i;
-    struct sockaddr_in sname;
-
-    if (strcmp (kind, "file") == 0)
-        type = IO_FILE;
-    else if (strcmp (kind, "pty") == 0)
-        type = IO_PTY;
-    else if (strcmp (kind, "pipe") == 0)
-        type = IO_PIPE;
-    else if (strcmp (kind, "socket") == 0)
-        type = IO_SOCKET;
-#ifdef FEATURE_CS
-    else if (strcmp (kind, "cs") == 0)
-        type = IO_CS;
-#endif
-    else
-        return -1;
-    for (i = 0; i < ion; i++)
-        if (!iop[i].inuse)
-            break;
-    if (i == ion) {
-        iop = Marraygrow (iop, (long) (ion + IOINCR) * IOSIZE);
-        for (i = ion + IOINCR - 1; i >= ion; i--)
-            iop[i].inuse = FALSE;
-        i++, ion += IOINCR;
-    }
-    p = &iop[i];
-    p->type = type;
-    p->pid = -1;
-    switch (type) {
-    case IO_FILE:
-        if (!(p->ifp = p->ofp = fopen (name, mode))) {
-            if (strncmp (name, "/dev/tcp/", 9) == 0) {
-                if (!(p->ifp = p->ofp = serverconnect (name)))
-                    return -1;
-                break;
-            }
-            path = buildpath (name, false);
-            if (!path || !(p->ifp = p->ofp = fopen (path, mode)))
-                return -1;
-        }
-        break;
-    case IO_PTY:
-        if (!fmt)
-            fmt = "%e";
-        if (
-            !(path = buildpath (name, true)) ||
-            !(command = buildcommand (path, NULL, -1, -1, fmt))
-        )
-            return -1;
-        ptyopen (command, &p->ifp, &p->ofp, &p->pid);
-        if (!p->ifp || !p->ofp)
-            return -1;
-        break;
-    case IO_PIPE:
-        if (!fmt)
-            fmt = "%e";
-        if (
-            !(path = buildpath (name, true)) ||
-            !(command = buildcommand (path, NULL, -1, -1, fmt))
-        )
-            return -1;
-        pipeopen (command, &p->ifp, &p->ofp, &p->pid);
-        if (!p->ifp || !p->ofp)
-            return -1;
-        break;
-    case IO_SOCKET:
-        if (!fmt)
-            fmt = "%e";
-        if ((sfd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
-            return -1;
-        sname.sin_family = AF_INET;
-        sname.sin_port = 0;
-        sname.sin_addr.s_addr = htonl (INADDR_ANY);
-        slen = sizeof (sname);
-        if (
-            bind (sfd, (struct sockaddr *) &sname, slen) < 0 ||
-            getsockname (sfd, (struct sockaddr *) &sname, &slen) < 0
-        )
-            return -1;
-        if (listen (sfd, 5) < 0)
-            return -1;
-        gethostname (hname, sizeof (hname));
-        if (!(path = buildpath (name, true)) || !(command = buildcommand (
-            path, hname, (int) ntohs (sname.sin_port),
-            (int) ntohs (sname.sin_port), fmt
-        )))
-            return -1;
-        socketopen (command, sfd, &p->ifp, &p->ofp, &p->pid);
-        if (!p->ifp || !p->ofp)
-            return -1;
-        close (sfd);
-        break;
-#ifdef FEATURE_CS
-    case IO_CS:
-        if (C2Lopen (name, mode, &p->ifp, &p->ofp) == -1)
-            return -1;
-        break;
-#endif
-    }
-    p->inuse = TRUE;
-    FD_CLR (fileno (p->ifp), &inputfds);
-    FD_CLR (fileno (p->ofp), &inputfds);
-    return i;
-}
-
-int IOclose (int ioi, char *action) {
-    io_t *p;
-
-    if (ioi < 0 || ioi >= ion || !iop[ioi].inuse)
-        return -1;
-    p = &iop[ioi];
-    FD_CLR (fileno (p->ifp), &inputfds);
-    FD_CLR (fileno (p->ofp), &inputfds);
-    if (p->ifp != p->ofp)
-        fclose (p->ifp);
-    fclose (p->ofp);
-    p->inuse = FALSE;
-    if (action && strcmp (action, "kill") == 0 && p->pid != -1)
-        kill (p->pid, 15);
-    return 0;
-}
-
-int IOreadline (int ioi, char *bufp, int bufn) {
-    io_t *p;
-    int l;
-
-    if (ioi < 0 || ioi >= ion || !iop[ioi].inuse)
-        return -1;
-    p = &iop[ioi];
-    fseek (p->ofp, 0L, 1);
-    if (fgets (bufp, bufn, p->ifp) == NULL)
-        return -1;
-    l = strlen (bufp) - 1;
-    while (bufp[l] == '\n' || bufp[l] == '\r')
-        bufp[l--] = '\000';
-    return l + 1;
-}
-
-int IOread (int ioi, char *bufp, int bufn) {
-    io_t *p;
-    int l;
-
-    if (ioi < 0 || ioi >= ion || !iop[ioi].inuse)
-        return -1;
-    p = &iop[ioi];
-    if ((l = read (fileno (p->ifp), bufp, bufn - 1)) == -1)
-        return -1;
-    else if (l == 0)
-        return 0;
-    bufp[l] = '\000';
-    return l;
-}
-
-int IOwriteline (int ioi, char *bufp) {
-    io_t *p;
-
-    if (ioi < 0 || ioi >= ion || !iop[ioi].inuse)
-        return -1;
-    p = &iop[ioi];
-    fseek (p->ofp, 0L, 1);
-    if (fputs (bufp, p->ofp) == EOF || fputs ("\n", p->ofp) == EOF)
-        return -1;
-    fflush (p->ofp);
-    fseek (p->ofp, 0L, 1);
-    return 0;
-}
-
-static FILE *serverconnect (char *name) {
-    char *host, *portp, buf[1024];
-    int cfd;
-    struct addrinfo hints;
-    struct addrinfo *result, *rp;
-
-    memset(&hints, 0, sizeof(struct addrinfo));
-
-    hints.ai_family = AF_UNSPEC;    /* Allow IPv4 or IPv6 */
-    hints.ai_socktype = SOCK_STREAM;/* Stream socket */
-    hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;
-    hints.ai_protocol = 0;          /* Any protocol */
-    hints.ai_canonname = NULL;
-    hints.ai_addr = NULL;
-    hints.ai_next = NULL;
-
-    strcpy (buf, name);
-    host = buf + 9;
-    portp = strchr (host, '/');
-
-    if (*host == 0 || !portp)
-        return NULL;
-
-    *portp++ = 0;
-
-    if (!(cfd = getaddrinfo(host, portp, &hints, &result)))
-        return NULL;
-
-    for (rp = result; rp != NULL; rp = rp->ai_next) {
-        cfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
-
-        if (cfd == -1)
-            continue;
-        if (connect(cfd, rp->ai_addr, rp->ai_addrlen) != -1)
-            break;                  /* Success */
-    }
-
-    freeaddrinfo(result);
-
-    if (cfd < 0 || rp == NULL)
-        return NULL;
-
-    return fdopen (cfd, "w+");
-}
-
-static void ptyopen (char *cmd, FILE **ifp, FILE **ofp, int *pidp) {
-    int fd[2];
-
-    if (findpty (fd) == -1) {
-        *ifp = NULL;
-        return;
-    }
-    switch ((*pidp = FORK ())) {
-    case -1:
-        panic2 (POS, "ptyopen", "cannot fork");
-    case 0:
-        close (fd[0]), dup2 (fd[1], 0);
-        dup2 (fd[1], 1), close (fd[1]);
-        execl (shell, shbname, "-c", cmd, NULL);
-        panic2 (POS, "ptyopen", "child cannot exec: %s\n", cmd);
-    default:
-        close (fd[1]);
-    }
-    fcntl (fd[0], F_SETFD, FD_CLOEXEC);
-    *ifp = fdopen (fd[0], "r"), *ofp = fdopen (fd[0], "a+");
-    return;
-}
-
-static int findpty (int *fd) {
-    char *majorp, *minorp;
-    char pty[32], tty[32];
-#ifndef HAVE_TERMIOS_H
-    struct termio tio;
-#else
-    struct termios tio;
-#endif
-    static char ptymajor[] = "pqrs";
-    static char ptyminor[] = "0123456789abcdefghijklmnopqrstuvwxyz";
-
-    for (majorp = ptymajor; *majorp; majorp++) {
-        for (minorp = ptyminor; *minorp; minorp++) {
-            snprintf(pty, sizeof(pty), "/dev/pty%c%c", *majorp, *minorp);
-            if ((fd[0] = open (pty, O_RDWR)) >= 0) {
-                snprintf(tty, sizeof(tty), "/dev/tty%c%c", *majorp, *minorp);
-                if ((fd[1] = open (tty, O_RDWR)) >= 0) {
-#ifndef HAVE_TERMIOS_H
-                    ioctl (fd[1], TCGETA, &tio);
-                    tio.c_lflag &= ~ECHO;
-                    ioctl (fd[1], TCSETA, &tio);
-#else
-                    tcgetattr (fd[1], &tio);
-                    tio.c_lflag &= ~ECHO;
-                    tcsetattr (fd[1], TCSANOW, &tio);
-#endif
-                    return 0;
-                }
-                close (fd[0]);
-            }
-        }
-    }
-    return -1;
-}
-
-static void pipeopen (char *cmd, FILE **ifp, FILE **ofp, int *pidp) {
-    int p1[2], p2[2];
-    char cmd2[1024];
-    char *s;
-
-    if (pipe (p1) == -1 || pipe (p2) == -1) {
-        *ifp = NULL;
-        return;
-    }
-    switch ((*pidp = FORK ())) {
-    case -1:
-        panic2 (POS, "pipeopen", "cannot fork");
-    case 0:
-        close (p1[0]), close (p2[1]);
-        for (s = cmd; *s; s++)
-            if (strncmp(s, "%d", 2) == 0) {
-                snprintf(cmd2, sizeof(cmd2), cmd, p2[0], p1[1]);
-                execl (shell, shbname, "-c", cmd2, NULL);
-                panic2 (POS, "pipeopen", "child cannot exec: %s\n", cmd2);
-            }
-        dup2 (p1[1], 1), close (p1[1]);
-        dup2 (p2[0], 0), close (p2[0]);
-        execl (shell, shbname, "-c", cmd, NULL);
-        panic2 (POS, "pipeopen", "child cannot exec: %s\n", cmd);
-    default:
-        close (p1[1]), close (p2[0]);
-    }
-    fcntl (p1[0], F_SETFD, FD_CLOEXEC);
-    fcntl (p2[1], F_SETFD, FD_CLOEXEC);
-    *ifp = fdopen (p1[0], "r"), *ofp = fdopen (p2[1], "a");
-    return;
-}
-
-static void socketopen (char *cmd, int sfd, FILE **ifp, FILE **ofp, int *pidp) {
-    int fd;
-
-    switch ((*pidp = FORK ())) {
-    case -1:
-        panic2 (POS, "socketopen", "cannot fork");
-    case 0:
-        execl (shell, shbname, "-c", cmd, NULL);
-        panic2 (POS, "socketopen", "child cannot exec: %s\n", cmd);
-    default:
-        if ((fd = accept (sfd, NULL, NULL)) < 0) {
-            *ifp = NULL;
-            return;
-        }
-    }
-    fcntl (fd, F_SETFD, FD_CLOEXEC);
-    *ifp = fdopen (fd, "r"), *ofp = fdopen (fd, "a+");
-    return;
-}
-
-static void sigchldhandler (int data) {
-    while (waitpid (-1, NULL, WNOHANG) > 0)
-        ;
-    signal (SIGCHLD, sigchldhandler);
-}
diff --git a/cmd/lefty/parse.c b/cmd/lefty/parse.c
deleted file mode 100644 (file)
index 0dffce6..0000000
+++ /dev/null
@@ -1,654 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "mem.h"
-#include "code.h"
-#include "tbl.h"
-#include "lex.h"
-#include "parse.h"
-#include "internal.h"
-
-static jmp_buf eljbuf;
-
-#define GTOKIFEQ(t) { \
-    if (Ltok == (t)) \
-        Lgtok (); \
-    else \
-        err ("expected token: '%s', found: '%s'", Lnames[t], Lnames[Ltok]); \
-}
-
-typedef struct lv_t {
-    int si, vi;
-} lv_t;
-static lv_t *lvp;
-static int lvn, flvi, llvi;
-#define GETLVSTR(i) (char *) Cgetstring (lvp[i].si)
-#define GETLVNUM(i) lvp[i].vi
-#define LVINCR 1000
-#define LVSIZE sizeof (lv_t)
-
-static int pexpr (void);
-static int getop (int, int);
-static int pexpi (int);
-static int pexp5 (void);
-static int pexp6 (void);
-static int pexp7 (void);
-static int pargs (void);
-static int pcons (void);
-static int pvar (void);
-static int pfunc (void);
-static int pdecl (int *);
-static int ptcons (void);
-static int pstmt (void);
-static int pifst (void);
-static int pwhilest (void);
-static int pforst (void);
-static int pbreakst (void);
-static int pcontinuest (void);
-static int preturnst (void);
-
-static void addlv (int, int);
-static void err (char *, ...);
-
-void Pinit (void) {
-    lvp = Marrayalloc ((long) LVINCR * LVSIZE);
-    lvn = LVINCR;
-    flvi = llvi = 0;
-}
-
-void Pterm (void) {
-    Marrayfree (lvp);
-    lvp = NULL;
-    lvn = flvi = llvi = 0;
-}
-
-Tobj Punit (Psrc_t *sp) {
-    int ui, ei;
-
-    Lsetsrc (sp->flag, sp->s, sp->fp, sp->tok, sp->lnum);
-    Creset ();
-    flvi = llvi = 0;
-
-    if (setjmp (eljbuf) != 0)
-        return NULL;
-
-    while (Ltok == L_SEMI)
-        Lgtok ();
-    if (Ltok == L_EOF)
-        return NULL;
-
-    ui = Cnew (C_CODE);
-    ei = pexpr ();
-    Csetfp (ui, ei);
-    Lgetsrc (&sp->flag, &sp->s, &sp->fp, &sp->tok, &sp->lnum);
-    return Tcode (cbufp, 0, cbufi);
-}
-
-/*  shortcut: this function creates a piece of code that corresponds to
-    <internal func name> = function () internal "<internal func name>";
-*/
-Tobj Pfunction (char *ifnam, int ifnum) {
-    int ui, ai, vi, si, fi, li1, li2, di, ifi, ifn;
-
-    Creset ();
-    ui = Cnew (C_CODE);
-    ai = Cnew (C_ASSIGN);
-    Csetfp (ui, ai);
-    vi = Cnew (C_GVAR);
-    si = Cstring (ifnam);
-    Csetfp (vi, si);
-    Csetfp (ai, vi);
-    fi = Cnew (C_FUNCTION);
-    Csetnext (vi, fi);
-    li1 = Cinteger (0);
-    Csetfp (fi, li1);
-    li2 = Cinteger (0);
-    Csetnext (li1, li2);
-    di = Cnew (C_DECL);
-    Csetfp (di, C_NULL);
-    Csetnext (li2, di);
-    ifi = Cnew (C_INTERNAL);
-    ifn = Cinteger ((long) ifnum);
-    Csetfp (ifi, ifn);
-    Csetnext (di, ifi);
-    Csetinteger (li1, (long) (Cgetindex () - fi));
-    Csetinteger (li2, 0);
-    return Tcode (cbufp, 0, cbufi);
-}
-
-/*  shortcut: this function creates a piece of code that corresponds to
-    <func name> (<args>); where <args> is the second argument (ao)
-*/
-Tobj Pfcall (Tobj fo, Tobj ao) {
-    int ui, fi, ffi, ai, aai;
-
-    Creset ();
-    ui = Cnew (C_CODE);
-    fi = Cnew (C_FCALL);
-    Csetfp (ui, fi);
-    ffi = Cnew (C_PVAR);
-    Csetobject (ffi, fo);
-    Csetfp (fi, ffi);
-    ai = Cnew (C_ARGS);
-    Csetnext (ffi, ai);
-    if (ao) {
-        aai = Cnew (C_PVAR);
-        Csetobject (aai, ao);
-        Csetfp (ai, aai);
-    } else
-        Csetfp (ai, C_NULL);
-    return Tcode (cbufp, 0, cbufi);
-}
-
-static int pexpr (void) {
-    int ai, ei0, ei1;
-
-    ei0 = pexpi (0);
-    if (Ltok != C_ASSIGN)
-        return ei0;
-
-    ai = Cnew (C_ASSIGN);
-    Csetfp (ai, ei0);
-    Lgtok ();
-    ei1 = pexpr ();
-    Csetnext (ei0, ei1);
-    return ai;
-}
-
-static int lextab[][7] = {
-    {   L_OR,       0,     0,    0,    0,    0, 0 },
-    {  L_AND,       0,     0,    0,    0,    0, 0 },
-    {   L_EQ,    L_NE,  L_LT, L_LE, L_GT, L_GE, 0 },
-    { L_PLUS, L_MINUS,     0,    0,    0,    0, 0 },
-    {  L_MUL,   L_DIV, L_MOD,    0,    0,    0, 0 },
-    {      0,       0,     0,    0,    0,    0, 0 }
-};
-
-static int parsetab[][7] = {
-    {   C_OR,       0,     0,    0,    0,    0, 0 },
-    {  C_AND,       0,     0,    0,    0,    0, 0 },
-    {   C_EQ,    C_NE,  C_LT, C_LE, C_GT, C_GE, 0 },
-    { C_PLUS, C_MINUS,     0,    0,    0,    0, 0 },
-    {  C_MUL,   C_DIV, C_MOD,    0,    0,    0, 0 },
-    {      0,       0,     0,    0,    0,    0, 0 }
-};
-
-static int getop (int t, int i) {
-    int j;
-
-    for (j = 0; lextab[i][j] != 0; j++)
-        if (t == lextab[i][j])
-            return parsetab[i][j];
-    return -1;
-}
-
-static int pexpi (int k) {
-    int ei0, ei1, ei2, ptok;
-
-    if (lextab[k][0] == 0)
-        return pexp5 ();
-
-    ei0 = pexpi (k + 1);
-    while ((ptok = getop (Ltok, k)) != -1) {
-        ei1 = Cnew (ptok);
-        Csetfp (ei1, ei0);
-        Lgtok ();
-        ei2 = pexpi (k + 1);
-        Csetnext (ei0, ei2);
-        ei0 = ei1;
-    }
-    return ei0;
-}
-
-static int pexp5 (void) {
-    int ei0, ei1;
-
-    if (Ltok == L_MINUS) {
-        ei0 = Cnew (C_UMINUS);
-        Lgtok ();
-        ei1 = pexp5 ();
-        Csetfp (ei0, ei1);
-        return ei0;
-    }
-    return pexp6 ();
-}
-
-static int pexp6 (void) {
-    int ei0, ei1;
-
-    if (Ltok == L_NOT) {
-        ei0 = Cnew (C_NOT);
-        Lgtok ();
-        ei1 = pexp6 ();
-        Csetfp (ei0, ei1);
-        return ei0;
-    }
-    return pexp7 ();
-}
-
-static int pexp7 (void) {
-    int ei0, ei1, ei2;
-
-    ei0 = 0;
-    switch (Ltok) {
-    case L_FUNCTION:
-        Lgtok ();
-        ei0 =  pfunc ();
-        break;
-    case L_LP:
-        ei0 = Cnew (C_PEXPR);
-        Lgtok ();
-        ei1 = pexpr ();
-        GTOKIFEQ (L_RP);
-        Csetfp (ei0, ei1);
-        break;
-    case L_LB:
-        ei0 = ptcons ();
-        break;
-    case L_STRING:
-    case L_NUMBER:
-        ei0 = pcons ();
-        break;
-    case L_ID:
-        ei0 = pvar ();
-        if (Ltok == L_LP) { /* ie: it's really a function call */
-            ei1 = ei0;
-            ei0 = Cnew (C_FCALL);
-            Csetfp (ei0, ei1);
-            Lgtok ();
-            ei2 = pargs ();
-            Csetnext (ei1, ei2);
-            GTOKIFEQ (L_RP);
-        }
-        break;
-    default:
-        err ("expected EXP7 type token, found: %s", Lnames[Ltok]);
-    }
-    return ei0;
-}
-
-static int pargs (void) {
-    int ai, ei0, ei1;
-
-    ai = Cnew (C_ARGS);
-    if (Ltok == L_RP) {
-        Csetfp (ai, C_NULL);
-        return ai;
-    }
-    ei0 = pexpr ();
-    Csetfp (ai, ei0);
-    while (Ltok != L_RP) {
-        GTOKIFEQ (L_COMMA);
-        if (Ltok == L_RP)
-            err ("expected expression, found: %s", Lnames[Ltok]);
-
-        ei1 = pexpr ();
-        Csetnext (ei0, ei1);
-        ei0 = ei1;
-    }
-    return ai;
-}
-
-static int pcons (void) {
-    int ci;
-    double d;
-
-    ci = 0;
-    switch (Ltok) {
-    case L_NUMBER:
-        d = atof (Lstrtok);
-        ci = (d == (double) (long) d) ? Cinteger ((long) d) : Creal (d);
-        break;
-    case L_STRING:
-        ci = Cstring (Lstrtok);
-        break;
-    default:
-        err ("expected scalar constant, found: %s", Lnames[Ltok]);
-    }
-    Lgtok ();
-    return ci;
-}
-
-static int pvar (void) {
-    int vi, ci0, ci1, i;
-
-    vi = Cnew (C_GVAR);
-    ci0 = Cstring (Lstrtok);
-    Csetfp (vi, ci0);
-    for (i = flvi; i < llvi; i++) {
-        if (strcmp (GETLVSTR (i), Lstrtok) == 0) {
-            Csettype (vi, C_LVAR);
-            ci1 = Cinteger ((long) GETLVNUM (i));
-            Csetnext (ci0, ci1);
-            ci0 = ci1;
-            break;
-        }
-    }
-    Lgtok ();
-    if (Ltok != L_DOT && Ltok != L_LB)
-        return vi;
-
-    while (Ltok == L_DOT || Ltok == L_LB) {
-        if (Ltok == L_DOT) {
-            Lgtok ();
-            if (Ltok != L_ID)
-                err ("expected identifier, found: %s", Lnames[Ltok]);
-            ci1 = Cstring (Lstrtok);
-            Csetnext (ci0, ci1);
-            Lgtok ();
-        } else {
-            Lgtok ();
-            ci1 = pexpr ();
-            Csetnext (ci0, ci1);
-            GTOKIFEQ (L_RB);
-        }
-        ci0 = ci1;
-    }
-    return vi;
-}
-
-static int pfunc (void) {
-    int fi, di, si, ifi, ifn, ldi, i, li1, li2;
-    int owncbufi, ownflvi, ownllvi, flvn, ifnum;
-
-    owncbufi = Cgetindex ();
-    ownflvi = flvi, ownllvi = llvi;
-    flvi = llvi;
-    flvn = 0;
-
-    fi = Cnew (C_FUNCTION);
-    GTOKIFEQ (L_LP);
-    li1 = Cinteger (0);
-    Csetfp (fi, li1);
-    li2 = Cinteger (0);
-    Csetnext (li1, li2);
-    di = pdecl (&flvn);
-    Csetnext (li2, di);
-    i = di;
-    GTOKIFEQ (L_RP);
-    if (Ltok == L_INTERNAL) {
-        Lgtok ();
-        if (Ltok == L_STRING) {
-            if ((ifnum = Igetfunc (Lstrtok)) == -1)
-                err ("no such internal function: %s", Lstrtok);
-            ifi = Cnew (C_INTERNAL);
-            ifn = Cinteger ((long) ifnum);
-            Csetfp (ifi, ifn);
-            Csetnext (i, ifi);
-            Lgtok ();
-        } else
-            err ("expected token: STRING, found: '%s'", Lnames[Ltok]);
-    } else {
-        GTOKIFEQ (L_LCB);
-        while (Ltok == L_LOCAL) {
-            Lgtok ();
-            ldi = pdecl (&flvn);
-            Csetnext (i, ldi);
-            i = ldi;
-            GTOKIFEQ (L_SEMI);
-        }
-        while (Ltok != L_RCB) {
-            si = pstmt ();
-            Csetnext (i, si);
-            i = si;
-        }
-        GTOKIFEQ (L_RCB);
-    }
-    Csetinteger (li1, (long) (Cgetindex () - owncbufi));
-    Csetinteger (li2, (long) flvn);
-    flvi = ownflvi, llvi = ownllvi;
-    return fi;
-}
-
-static int pdecl (int *lvnp) {
-    int di, si, i;
-
-    di = Cnew (C_DECL);
-    if (Ltok != L_ID) {
-        Csetfp (di, C_NULL);
-        return di;
-    }
-    si = Cstring (Lstrtok);
-    addlv (si, (*lvnp)++);
-    Csetfp (di, si);
-    i = si;
-    Lgtok ();
-    if (Ltok != L_COMMA)
-        return di;
-    Lgtok ();
-    while (Ltok == L_ID) {
-        si = Cstring (Lstrtok);
-        addlv (si, (*lvnp)++);
-        Lgtok ();
-        Csetnext (i, si);
-        i = si;
-        if (Ltok == L_COMMA) {
-            Lgtok ();
-            if (Ltok != L_ID)
-                err ("expected identifier, found %s", Lnames[Ltok]);
-        }
-    }
-    return di;
-}
-
-static int ptcons (void) {
-    int ti, ei0, ei1;
-
-    ti = Cnew (C_TCONS);
-    Lgtok ();
-    if (Ltok == L_RB) {
-        Csetfp (ti, C_NULL);
-        Lgtok ();
-        return ti;
-    }
-    ei1 = pexpi (0);
-    Csetfp (ti, ei1);
-    ei0 = ei1;
-    GTOKIFEQ (L_ASSIGN);
-    ei1 = pexpr ();
-    Csetnext (ei0, ei1);
-    ei0 = ei1;
-    GTOKIFEQ (L_SEMI);
-    while (Ltok != L_RB) {
-        ei1 = pexpi (0);
-        Csetnext (ei0, ei1);
-        ei0 = ei1;
-        GTOKIFEQ (L_ASSIGN);
-        ei1 = pexpr ();
-        Csetnext (ei0, ei1);
-        ei0 = ei1;
-        GTOKIFEQ (L_SEMI);
-    }
-    Lgtok ();
-    return ti;
-}
-
-static int pstmt (void) {
-    int si, i0, i1;
-
-    si = Cnew (C_STMT);
-    switch (Ltok) {
-    case L_SEMI:
-        Csetfp (si, C_NULL);
-        Lgtok ();
-        break;
-    case L_LCB:
-        Lgtok ();
-        if (Ltok == L_RCB) {
-            Csetfp (si, C_NULL);
-        } else {
-            i1 = pstmt ();
-            Csetfp (si, i1);
-            i0 = i1;
-            while (Ltok != L_RCB) {
-                i1 = pstmt ();
-                Csetnext (i0, i1);
-                i0 = i1;
-            }
-        }
-        Lgtok ();
-        break;
-    case L_IF:
-        i0 = pifst ();
-        Csetfp (si, i0);
-        break;
-    case L_WHILE:
-        i0 = pwhilest ();
-        Csetfp (si, i0);
-        break;
-    case L_FOR:
-        i0 = pforst ();
-        Csetfp (si, i0);
-        break;
-    case L_BREAK:
-        i0 = pbreakst ();
-        Csetfp (si, i0);
-        break;
-    case L_CONTINUE:
-        i0 = pcontinuest ();
-        Csetfp (si, i0);
-        break;
-    case L_RETURN:
-        i0 = preturnst ();
-        Csetfp (si, i0);
-        break;
-    default:
-        i0 = pexpr ();
-        Csetfp (si, i0);
-        GTOKIFEQ (L_SEMI);
-    }
-    return si;
-}
-
-static int pifst (void) {
-    int isi, ii, ti, ei;
-
-    isi = Cnew (C_IF);
-    Lgtok ();
-    GTOKIFEQ (L_LP);
-    ii = pexpr ();
-    Csetfp (isi, ii);
-    GTOKIFEQ (L_RP);
-    ti = pstmt ();
-    Csetnext (ii, ti);
-    if (Ltok == L_ELSE) {
-        Lgtok ();
-        ei = pstmt ();
-        Csetnext (ti, ei);
-    }
-    return isi;
-}
-
-static int pwhilest (void) {
-    int wi, ei, si;
-
-    wi = Cnew (C_WHILE);
-    Lgtok ();
-    GTOKIFEQ (L_LP);
-    ei = pexpr ();
-    Csetfp (wi, ei);
-    GTOKIFEQ (L_RP);
-    si = pstmt ();
-    Csetnext (ei, si);
-    return wi;
-}
-
-static int pforst (void) {
-    int fi, i0, i1, si;
-
-    fi = Cnew (C_FOR);
-    Lgtok ();
-    GTOKIFEQ (L_LP);
-    i0 = (Ltok == L_SEMI) ? Cnew (C_NOP): pexpr ();
-    Csetfp (fi, i0);
-    if (Ltok == L_IN) {
-        Csettype (fi, C_FORIN);
-        Lgtok ();
-        i1 = pexpr ();
-        Csetnext (i0, i1);
-        i0 = i1;
-    } else {
-        GTOKIFEQ (L_SEMI);
-        i1 = (Ltok == L_SEMI) ? Cnew (C_NOP): pexpr ();
-        Csetnext (i0, i1);
-        i0 = i1;
-        GTOKIFEQ (L_SEMI);
-        i1 = (Ltok == L_SEMI) ? Cnew (C_NOP): pexpr ();
-        Csetnext (i0, i1);
-        i0 = i1;
-    }
-    GTOKIFEQ (L_RP);
-    si = pstmt ();
-    Csetnext (i0, si);
-    return fi;
-}
-
-static int pbreakst (void) {
-    int bi;
-
-    bi = Cnew (C_BREAK);
-    Csetfp (bi, C_NULL);
-    Lgtok ();
-    GTOKIFEQ (L_SEMI);
-    return bi;
-}
-
-static int pcontinuest (void) {
-    int ci;
-
-    ci = Cnew (C_CONTINUE);
-    Csetfp (ci, C_NULL);
-    Lgtok ();
-    GTOKIFEQ (L_SEMI);
-    return ci;
-}
-
-static int preturnst (void) {
-    int ri, ei;
-
-    ri = Cnew (C_RETURN);
-    Lgtok ();
-    if (Ltok == L_SEMI) {
-        Csetfp (ri, C_NULL);
-        GTOKIFEQ (L_SEMI);
-        return ri;
-    }
-    ei = pexpr ();
-    Csetfp (ri, ei);
-    GTOKIFEQ (L_SEMI);
-    return ri;
-}
-
-static void addlv (int si, int vi) {
-    int i;
-
-    if (llvi >= lvn) {
-        lvp = Marraygrow (lvp, (long) (lvn + LVINCR) + LVSIZE);
-        lvn += LVINCR;
-    }
-    lvp[llvi].si = si, lvp[llvi].vi = vi, llvi++;
-    for (i = llvi - 2; i >= flvi; i--)
-        if (strcmp (GETLVSTR (i), GETLVSTR (llvi - 1)) == 0)
-            err ("local variable %s multiply defined", GETLVSTR (i));
-}
-
-static void err (char *fmt, ...) {
-    va_list args;
-
-    va_start(args, fmt);
-    Lprintpos ();
-    vfprintf (stderr, fmt, args);
-    fprintf (stderr, "\n");
-    fflush (stdout);
-    longjmp (eljbuf, 1);
-}
diff --git a/cmd/lefty/parse.h b/cmd/lefty/parse.h
deleted file mode 100644 (file)
index 14f923b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-typedef struct Psrc_t {
-    int flag;
-    char *s;
-    FILE *fp;
-    int tok;
-    int lnum;
-} Psrc_t;
-
-void Pinit (void);
-void Pterm (void);
-Tobj Punit (Psrc_t *);
-Tobj Pfcall (Tobj, Tobj);
-Tobj Pfunction (char *, int);
diff --git a/cmd/lefty/str.c b/cmd/lefty/str.c
deleted file mode 100644 (file)
index 03a0f91..0000000
+++ /dev/null
@@ -1,489 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "mem.h"
-#include "code.h"
-#include "tbl.h"
-#include "str.h"
-#include "internal.h"
-
-static int highci;
-static int indent;
-#define INDINC(i) (indent += (i))
-#define INDDEC(i) (indent -= (i))
-
-static char *sbufp;
-static int sbufi, sbufn;
-#define SBUFINCR 1000
-#define SBUFSIZE sizeof (char)
-
-static void scalarstr (Tobj);
-static void codestr (Tobj, int);
-static void appends (char *);
-static void appendi (long);
-static void appendd (double);
-static void appendnl (void);
-static void growsbuf (int);
-static char *copysbuf (void);
-
-void Sinit (void) {
-    if (!(sbufp = malloc (SBUFINCR * SBUFSIZE)))
-        panic1 (POS, "Sinit", "sbuf malloc failed");
-    sbufi = 0;
-    sbufn = SBUFINCR;
-    indent = 0;
-    highci = -1;
-}
-
-void Sterm (void) {
-    indent = 0;
-    free (sbufp), sbufp = NULL;
-    sbufn = sbufi = 0;
-}
-
-char *Spath (char *path, Tobj ko) {
-    sbufp[(sbufi = 0)] = '\000';
-    appends ((path) ? path : "");
-    scalarstr (ko);
-    return copysbuf ();
-}
-
-char *Sseen (Tobj ko, char *path) {
-    sbufp[(sbufi = 0)] = '\000';
-    scalarstr (ko), appends (" = "), appends (path), appends (";");
-    return copysbuf ();
-}
-
-char *Sabstract (Tobj ko, Tobj vo) {
-    sbufp[(sbufi = 0)] = '\000';
-    scalarstr (ko), appends (" = ");
-    switch (Tgettype (vo)) {
-    case T_STRING:
-    case T_INTEGER:
-    case T_REAL:
-        scalarstr (vo);
-        break;
-    case T_CODE:
-        appends ("function (...) { ... }");
-        break;
-    case T_TABLE:
-        appends ("[ ... ]");
-        break;
-    }
-    appends (";");
-    return copysbuf ();
-}
-
-char *Stfull (Tobj ko) {
-    sbufp[(sbufi = 0)] = '\000';
-    scalarstr (ko), appends (" = [");
-    return copysbuf ();
-}
-
-char *Ssfull (Tobj ko, Tobj vo) {
-    sbufp[(sbufi = 0)] = '\000';
-    if (ko)
-        scalarstr (ko), appends (" = ");
-    switch (Tgettype (vo)) {
-    case T_STRING:
-    case T_INTEGER:
-    case T_REAL:
-    case T_CODE:
-        scalarstr (vo);
-        break;
-    }
-    appends (";");
-    return copysbuf ();
-}
-
-char *Scfull (Tobj co, int ci, int mci) {
-    sbufp[(sbufi = 0)] = '\000';
-    highci = mci;
-    codestr (co, ci);
-    highci = -1;
-    return copysbuf ();
-}
-
-static void scalarstr (Tobj to) {
-    switch (Tgettype (to)) {
-    case T_INTEGER:
-        appendi (Tgetinteger (to));
-        break;
-    case T_REAL:
-        appendd (Tgetreal (to));
-        break;
-    case T_STRING:
-        appends ("\""), appends (Tgetstring (to)), appends ("\"");
-        break;
-    case T_CODE:
-        codestr (to, 0);
-        break;
-    }
-}
-
-static void codestr (Tobj co, int ci) {
-    int ct, ct1;
-    int ci1, ci2;
-
-    if (highci == ci)
-        appends (" >> ");
-    switch ((ct = TCgettype (co, ci))) {
-    case C_ASSIGN:
-        codestr (co, (ci1 = TCgetfp (co, ci)));
-        appends (" = ");
-        codestr (co, TCgetnext (co, ci1));
-        break;
-    case C_OR:
-    case C_AND:
-    case C_EQ:
-    case C_NE:
-    case C_LT:
-    case C_LE:
-    case C_GT:
-    case C_GE:
-    case C_PLUS:
-    case C_MINUS:
-    case C_MUL:
-    case C_DIV:
-    case C_MOD:
-        codestr (co, (ci1 = TCgetfp (co, ci)));
-        switch (ct) {
-        case C_OR:    appends (" | ");  break;
-        case C_AND:   appends (" & ");  break;
-        case C_EQ:    appends (" == "); break;
-        case C_NE:    appends (" ~= "); break;
-        case C_LT:    appends (" < ");  break;
-        case C_LE:    appends (" <= "); break;
-        case C_GT:    appends (" > ");  break;
-        case C_GE:    appends (" >= "); break;
-        case C_PLUS:  appends (" + ");  break;
-        case C_MINUS: appends (" - ");  break;
-        case C_MUL:   appends (" * ");  break;
-        case C_DIV:   appends (" / ");  break;
-        case C_MOD:   appends (" % ");  break;
-        }
-        codestr (co, TCgetnext (co, ci1));
-        break;
-    case C_NOT:
-        appends ("~");
-        codestr (co, TCgetfp (co, ci));
-        break;
-    case C_UMINUS:
-        appends ("-");
-        codestr (co, TCgetfp (co, ci));
-        break;
-    case C_PEXPR:
-        appends ("(");
-        codestr (co, TCgetfp (co, ci));
-        appends (")");
-        break;
-    case C_FCALL:
-        codestr (co, (ci1 = TCgetfp (co, ci)));
-        appends (" (");
-        codestr (co, TCgetnext (co, ci1));
-        appends (")");
-        break;
-    case C_INTEGER:
-        appendi (TCgetinteger (co, ci));
-        break;
-    case C_REAL:
-        appendd (TCgetreal (co, ci));
-        break;
-    case C_STRING:
-        appends ("\""), appends (TCgetstring (co, ci)), appends ("\"");
-        break;
-    case C_GVAR:
-    case C_LVAR:
-        ci1 = TCgetfp (co, ci);
-        appends (TCgetstring (co, ci1));
-        if (ct == C_LVAR)
-            ci1 = TCgetnext (co, ci1);
-        for (
-            ci1 = TCgetnext (co, ci1); ci1 != C_NULL;
-            ci1 = TCgetnext (co, ci1)
-        ) {
-            switch (TCgettype (co, ci1)) {
-            case C_STRING:
-                appends ("."), appends (TCgetstring (co, ci1));
-                break;
-            case C_INTEGER:
-                appends ("[");
-                appendi (TCgetinteger (co, ci1));
-                appends ("]");
-                break;
-            case C_REAL:
-                appends ("[");
-                appendd (TCgetreal (co, ci1));
-                appends ("]");
-                break;
-            default:
-                appends ("[");
-                codestr (co, ci1);
-                appends ("]");
-            }
-        }
-        break;
-    case C_PVAR:
-        appends ("<var>");
-        break;
-    case C_FUNCTION:
-        ci1 = TCgetnext (co, TCgetnext (co, TCgetfp (co, ci)));
-        appends ("function (");
-        codestr (co, ci1);
-        ci1 = TCgetnext (co, ci1);
-        if (TCgettype (co, ci1) == C_INTERNAL) {
-            appends (") internal \"");
-            appends (Ifuncs[TCgetinteger (co, TCgetfp (co, ci1))].name);
-            appends ("\"");
-        } else {
-            appends (") {");
-            INDINC (2);
-            for (; ci1 != C_NULL; ci1 = TCgetnext (co, ci1)) {
-                appendnl ();
-                if (TCgettype (co, ci1) == C_DECL)
-                    appends ("local "), codestr (co, ci1), appends (";");
-                else
-                    codestr (co, ci1);
-            }
-            INDDEC (2);
-            appendnl ();
-            appends ("}");
-        }
-        break;
-    case C_TCONS:
-        appends ("[");
-        INDINC (2);
-        ci1 = TCgetfp (co, ci);
-        while (ci1 != C_NULL) {
-            appendnl ();
-            codestr (co, ci1);
-            appends (" = ");
-            ci1 = TCgetnext (co, ci1);
-            codestr (co, ci1);
-            appends (";");
-            ci1 = TCgetnext (co, ci1);
-        }
-        INDDEC (2);
-        appendnl ();
-        appends ("]");
-        break;
-    case C_DECL:
-        ci1 = TCgetfp (co, ci);
-        while (ci1 != C_NULL) {
-            appends (TCgetstring (co, ci1));
-            ci1 = TCgetnext (co, ci1);
-            if (ci1 != C_NULL)
-                appends (", ");
-        }
-        break;
-    case C_STMT:
-        ci1 = TCgetfp (co, ci);
-        if (ci1 == C_NULL) {
-            appends (";");
-            break;
-        }
-        if (TCgetnext (co, ci1) == C_NULL) {
-            codestr (co, ci1);
-            ct1 = TCgettype (co, ci1);
-            if (!C_ISSTMT (ct1))
-                appends (";");
-        } else {
-            appends (" {");
-            INDINC (2);
-            for (; ci1 != C_NULL; ci1 = TCgetnext (co, ci1)) {
-                appendnl ();
-                codestr (co, ci1);
-            }
-            INDDEC (2);
-            appendnl ();
-            appends ("}");
-        }
-        break;
-    case C_IF:
-        ci1 = TCgetfp (co, ci);
-        appends ("if (");
-        codestr (co, ci1);
-        appends (")");
-        ci1 = TCgetnext (co, ci1);
-        ci2 = TCgetfp (co, ci1);
-        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
-            INDINC (2);
-            appendnl ();
-            codestr (co, ci1);
-            INDDEC (2);
-        } else {
-            codestr (co, ci1);
-        }
-        ci1 = TCgetnext (co, ci1);
-        if (ci1 == C_NULL)
-            break;
-        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
-            appendnl ();
-            appends ("else");
-        } else {
-            appends (" else");
-        }
-        ci2 = TCgetfp (co, ci1);
-        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
-            INDINC (2);
-            appendnl ();
-            codestr (co, ci1);
-            INDDEC (2);
-        } else {
-            codestr (co, ci1);
-        }
-        break;
-    case C_WHILE:
-        ci1 = TCgetfp (co, ci);
-        appends ("while (");
-        codestr (co, ci1);
-        ci1 = TCgetnext (co, ci1);
-        ci2 = TCgetfp (co, ci1);
-        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
-            appends (")");
-            INDINC (2);
-            appendnl ();
-            codestr (co, ci1);
-            INDDEC (2);
-        } else {
-            appends (")");
-            codestr (co, ci1);
-        }
-        break;
-    case C_FOR:
-        ci1 = TCgetfp (co, ci);
-        appends ("for (");
-        codestr (co, ci1);
-        appends ("; ");
-        ci1 = TCgetnext (co, ci1);
-        codestr (co, ci1);
-        appends ("; ");
-        ci1 = TCgetnext (co, ci1);
-        codestr (co, ci1);
-        ci1 = TCgetnext (co, ci1);
-        ci2 = TCgetfp (co, ci1);
-        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
-            appends (")");
-            INDINC (2);
-            appendnl ();
-            codestr (co, ci1);
-            INDDEC (2);
-        } else {
-            appends (")");
-            codestr (co, ci1);
-        }
-        break;
-    case C_FORIN:
-        ci1 = TCgetfp (co, ci);
-        appends ("for (");
-        codestr (co, ci1);
-        appends (" in ");
-        ci1 = TCgetnext (co, ci1);
-        codestr (co, ci1);
-        ci1 = TCgetnext (co, ci1);
-        ci2 = TCgetfp (co, ci1);
-        if (ci2 == C_NULL || TCgetnext (co, ci2) == C_NULL) {
-            appends (")");
-            INDINC (2);
-            appendnl ();
-            codestr (co, ci1);
-            INDDEC (2);
-        } else {
-            appends (")");
-            codestr (co, ci1);
-        }
-        break;
-    case C_BREAK:
-        appends ("break;");
-        break;
-    case C_CONTINUE:
-        appends ("continue;");
-        break;
-    case C_RETURN:
-        ci1 = TCgetfp (co, ci);
-        appends ("return");
-        if (ci1 != C_NULL) {
-            appends (" ");
-            codestr (co, ci1);
-        }
-        appends (";");
-        break;
-    case C_ARGS:
-        ci1 = TCgetfp (co, ci);
-        while (ci1 != C_NULL) {
-            codestr (co, ci1);
-            ci1 = TCgetnext (co, ci1);
-            if (ci1 != C_NULL)
-                appends (", ");
-        }
-        break;
-    default:
-        panic1 (POS, "codestr", "bad object type: %d", ct);
-    }
-}
-
-static void appends (char *s) {
-    int n;
-
-    n = strlen (s) + 1;
-    if (sbufi + n > sbufn)
-        growsbuf (n);
-    strcpy (&sbufp[sbufi], s);
-    sbufi += (n - 1);
-}
-
-static void appendi (long i) {
-    int n = snprintf(NULL, 0, "%ld", i) + 1;
-    if (sbufi + n > sbufn)
-        growsbuf (n);
-    sprintf(&sbufp[sbufi], "%ld", i);
-    sbufi += (n - 1);
-}
-
-static void appendd (double d) {
-    int n = snprintf(NULL, 0, "%lf", d) + 1;
-    if (sbufi + n > sbufn)
-        growsbuf (n);
-    sprintf(&sbufp[sbufi], "%lf", d);
-    sbufi += (n - 1);
-}
-
-static void appendnl (void) {
-    int i, n;
-
-    n = indent + 1;
-    if (sbufi + n > sbufn)
-        growsbuf (n);
-    sbufp[sbufi++] = '\n';
-    for (i = 0; i < indent; i++)
-        sbufp[sbufi++] = ' ';
-}
-
-static void growsbuf (int ssize) {
-    int nsize;
-
-    nsize = ((sbufn + ssize) / SBUFINCR + 1) * SBUFINCR;
-    if (!(sbufp = realloc (sbufp, nsize * SBUFSIZE)))
-        panic1 (POS, "growsbuf", "sbuf realloc failed");
-    sbufn = nsize;
-}
-
-static char *copysbuf (void) {
-    char *newsbufp;
-
-    sbufp[sbufi++] = '\000';
-    if (!(newsbufp = malloc (sbufi * sizeof (char))))
-        panic1 (POS, "copysbuf", "newsbuf malloc failed");
-    strcpy (newsbufp, sbufp);
-    return newsbufp;
-}
diff --git a/cmd/lefty/str.h b/cmd/lefty/str.h
deleted file mode 100644 (file)
index a9f4dc1..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-void Sinit (void);
-void Sterm (void);
-char *Spath (char *, Tobj);
-char *Sseen (Tobj, char *);
-char *Sabstract (Tobj, Tobj);
-char *Stfull (Tobj);
-char *Ssfull (Tobj, Tobj);
-char *Scfull (Tobj, int, int);
diff --git a/cmd/lefty/tbl.c b/cmd/lefty/tbl.c
deleted file mode 100644 (file)
index 9a923a7..0000000
+++ /dev/null
@@ -1,672 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include <stdbool.h>
-#include "common.h"
-#include "mem.h"
-#include "code.h"
-#include "tbl.h"
-
-long Ttime = 0;
-int Tstringoffset, Tcodeoffset, Tkvoffset;
-Tobj Ttrue, Tfalse;
-
-#define ISEQIK(ik, ko) ( \
-    T_ISNUMBER (ko) && Tgetnumber (ko) == (ik) \
-)
-#define ISEQRK(rk, ko) ( \
-    T_ISNUMBER (ko) && Tgetnumber (ko) == (rk) \
-)
-#define ISEQSK(sk, ko) ( \
-    T_ISSTRING (ko)  && strcmp (((Tstring_t *) (ko))->s, (sk)) == 0 \
-)
-
-#define GETIKINDEX(tp, ik) (uint64_t) ik  % tp->ln
-#define GETRKINDEX(tp, rk) (uint64_t) rk  % tp->ln
-#define GETSKINDEX(tp, sk) (uint64_t) *sk % tp->ln
-
-typedef struct mapentry_t {
-    struct mapentry_t *next;
-    Tobj fmo, too;
-} mapentry_t;
-#define MAPENTRYSIZE sizeof (mapentry_t)
-#define MAPLISTN 100
-typedef struct Map_t {
-    struct mapentry_t *list[MAPLISTN];
-} Map_t;
-static Map_t map;
-static long mapentrybyte2size;
-
-static long truem, falsem;
-
-static Tinteger_t keyi;
-static Treal_t keyr;
-static Tstring_t keys;
-
-static void insert (Ttable_t *, Tobj, char *, Tobj);
-static Tobj find (Ttable_t *, Tobj, char *);
-static void delete (Ttable_t *, Tobj, char *);
-static void copytable (Ttable_t *, long);
-static void reccopytable (Ttable_t *, Ttable_t *);
-static void mapinit (void);
-static void mapterm (void);
-static void mapinsert (Tobj, Tobj);
-static Tobj mapfind (Tobj);
-
-void Tinit (void) {
-    Tstring_t s;
-    Tcode_t c;
-    Tkvlist_t kvl;
-
-    Mhaspointers[T_INTEGER] = false;
-    Mhaspointers[T_REAL] = false;
-    Mhaspointers[T_STRING] = false;
-    Mhaspointers[T_CODE] = false;
-    Mhaspointers[T_TABLE] = true;
-    Ttrue = Tinteger (1);
-    truem = Mpushmark (Ttrue);
-    Tfalse = Tinteger (0);
-    falsem = Mpushmark (Tfalse);
-    Tstringoffset = (char *) &s.s[0] - (char *) &s + 1;
-    /* the + 1 above accounts for the null character */
-    Tcodeoffset = (char *) &c.c[0] - (char *) &c;
-    Tkvoffset = (char *) &kvl.kv[0] - (char *) &kvl;
-    keyi.head.type = T_INTEGER;
-    keyr.head.type = T_REAL;
-    keys.head.type = T_STRING;
-    mapentrybyte2size = M_BYTE2SIZE (MAPENTRYSIZE);
-}
-
-void Tterm (void) {
-    Mpopmark (falsem);
-    Tfalse = NULL;
-    Mpopmark (truem);
-    Ttrue = NULL;
-    Mdogc (M_GCFULL);
-    Mdogc (M_GCFULL);
-}
-
-void Tgchelper (void *p) {
-    Ttable_t *tp;
-    Tkvlist_t *kvlp;
-    long i, j;
-
-    /* must be a table */
-    tp = (Ttable_t *) p;
-    for (i = 0; i < tp->ln; i++)
-        if ((kvlp = tp->lp[i]))
-            for (j = 0; j < kvlp->i; j++)
-                Mmkcurr (kvlp->kv[j].ko), Mmkcurr (kvlp->kv[j].vo);
-}
-
-void Tfreehelper (void *p) {
-    Ttable_t *tp;
-    Tkvlist_t *kvlp;
-    long i;
-
-    /* must be a table */
-    tp = (Ttable_t *) p;
-    for (i = 0; i < tp->ln; i++)
-        if ((kvlp = tp->lp[i]))
-            Mfree (kvlp, M_BYTE2SIZE (T_KVLISTSIZE (kvlp->n)));
-    Mfree (tp->lp, M_BYTE2SIZE (tp->ln * T_KVLISTPTRSIZE));
-}
-
-Tobj Tinteger (long i) {
-    Tinteger_t *ip;
-
-    ip = Mnew (T_INTEGERSIZE, T_INTEGER);
-    ip->i = i;
-    return ip;
-}
-
-Tobj Treal (double d) {
-    Treal_t *rp;
-
-    if (d == (double) (long) d)
-        return Tinteger ((long) d);
-    rp = Mnew (T_REALSIZE, T_REAL);
-    rp->d = d;
-    return rp;
-}
-
-Tobj Tstring (char *s) {
-    Tstring_t *sp;
-
-    sp = Mnew ((long) T_STRINGSIZE (strlen (s)), T_STRING);
-    strcpy (&sp->s[0], s);
-    return sp;
-}
-
-Tobj Tcode (Code_t *cp, int ci, int cl) {
-    Tcode_t *codep;
-    Code_t *cp2;
-    char *s;
-    int i, j, cn;
-
-    codep = Mnew ((long) T_CODESIZE (cl), T_CODE);
-    cp2 = codep->c;
-    for (i = 0; i < cl; i++) {
-        switch (cp[i].ctype) {
-        case C_INTEGER:
-            cp2[i] = cp[i];
-            if (cp2[i].next != C_NULL)
-                cp2[i].next -= ci;
-            break;
-        case C_REAL:
-            cp2[i] = cp[i];
-            if (cp2[i].next != C_NULL)
-                cp2[i].next -= ci;
-            break;
-        case C_STRING:
-            cp2[i] = cp[i];
-            if (cp2[i].next != C_NULL)
-                cp2[i].next -= ci;
-            s = &cp[i].u.s;
-            while (*s)
-                s++;
-            cn = (long) (s - (char *) &cp[i]) / sizeof (Code_t);
-            for (j = 0; j < cn; j++)
-                i++, cp2[i] = cp[i];
-            break;
-        default:
-            cp2[i] = cp[i];
-            if (cp2[i].next != C_NULL)
-                cp2[i].next -= ci;
-            if (cp2[i].u.fp != C_NULL)
-                cp2[i].u.fp -= ci;
-            break;
-        }
-    }
-    return codep;
-}
-
-Tobj Ttable (long sizehint) {
-    Ttable_t *tp;
-    Tkvlist_t **lp;
-    long i;
-
-    sizehint = (sizehint < 2) ? 2 : sizehint;
-    tp = Mnew (T_TABLESIZE, T_TABLE);
-    lp = Mallocate ((long) (sizehint * T_KVLISTPTRSIZE));
-    tp->lp = lp;
-    tp->ln = sizehint;
-    tp->n = 0;
-    tp->time = Ttime;
-    for (i = 0; i < sizehint; i++)
-        lp[i] = NULL;
-    return tp;
-}
-
-
-void Tinsi (Tobj to, long ik, Tobj vo) {
-    long tm;
-
-    if (!to || !T_ISTABLE (to))
-        panic1 (POS, "Tinsi", "insert attempted on non-table");
-    tm = Mpushmark (to);
-    if (vo)
-        Mpushmark (vo);
-    keyi.i = ik;
-    insert (to, &keyi, NULL, vo);
-    Mpopmark (tm);
-}
-
-void Tinsr (Tobj to, double rk, Tobj vo) {
-    long tm;
-
-    if (!to || !T_ISTABLE (to))
-        panic1 (POS, "Tinsr", "insert attempted on non-table");
-    tm = Mpushmark (to);
-    if (vo)
-        Mpushmark (vo);
-    keyr.d = rk;
-    insert (to, &keyr, NULL, vo);
-    Mpopmark (tm);
-}
-
-void Tinss (Tobj to, char *sk, Tobj vo) {
-    long tm;
-
-    if (!to || !T_ISTABLE (to))
-        panic1 (POS, "Tinss", "insert attempted on non-table");
-    tm = Mpushmark (to);
-    if (vo)
-        Mpushmark (vo);
-    insert (to, &keys, sk, vo);
-    Mpopmark (tm);
-}
-
-void Tinso (Tobj to, Tobj ko, Tobj vo) {
-    long tm;
-
-    if (!to || !T_ISTABLE (to))
-        panic1 (POS, "Tinso", "insert attempted on non-table");
-    if (!ko || !(T_ISINTEGER (ko) || T_ISREAL (ko) || T_ISSTRING (ko)))
-        panic1 (POS, "Tinso", "bad key");
-    tm = Mpushmark (to);
-    Mpushmark (ko);
-    if (vo)
-        Mpushmark (vo);
-    insert (to, ko, NULL, vo);
-    Mpopmark (tm);
-}
-
-Tobj Tfindi (Tobj to, long ik) {
-    if (!to)
-        return NULL;
-    if (!T_ISTABLE (to))
-        panic1 (POS, "Tfindi", "find attempted on non-table");
-    keyi.i = ik;
-    return find (to, &keyi, NULL);
-}
-
-Tobj Tfindr (Tobj to, double rk) {
-    if (!to)
-        return NULL;
-    if (!T_ISTABLE (to))
-        panic1 (POS, "Tfindr", "find attempted on non-table");
-    keyr.d = rk;
-    return find (to, &keyr, NULL);
-}
-
-Tobj Tfinds (Tobj to, char *sk) {
-    if (!to)
-        return NULL;
-    if (!T_ISTABLE (to))
-        panic1 (POS, "Tfinds", "find attempted on non-table");
-    return find (to, &keys, sk);
-}
-
-Tobj Tfindo (Tobj to, Tobj ko) {
-    if (!to || !ko)
-        return NULL;
-    if (!T_ISTABLE (to))
-        panic1 (POS, "Tfindo", "find attempted on non-table");
-    if (!(T_ISINTEGER (ko) || T_ISREAL (ko) || T_ISSTRING (ko)))
-        panic1 (POS, "Tfindo", "bad key");
-    return find (to, ko, NULL);
-}
-
-void Tdeli (Tobj to, long ik) {
-    if (!to)
-        return;
-    if (!T_ISTABLE (to))
-        panic1 (POS, "Tdeli", "delete attempted on non-table");
-    keyi.i = ik;
-    delete (to, &keyi, NULL);
-}
-
-void Tdelr (Tobj to, double rk) {
-    if (!to)
-        return;
-    if (!T_ISTABLE (to))
-        panic1 (POS, "Tdelr", "delete attempted on non-table");
-    keyr.d = rk;
-    delete (to, &keyr, NULL);
-}
-
-void Tdels (Tobj to, char *sk) {
-    if (!to)
-        return;
-    if (!T_ISTABLE (to))
-        panic1 (POS, "Tdels", "delete attempted on non-table");
-    delete (to, &keys, sk);
-}
-
-void Tdelo (Tobj to, Tobj ko) {
-    if (!to || !ko)
-        return;
-    if (!T_ISTABLE (to))
-        panic1 (POS, "Tdelo", "delete attempted on non-table");
-    if (!(T_ISINTEGER (ko) || T_ISREAL (ko) || T_ISSTRING (ko)))
-        panic1 (POS, "Tdelo", "bad key");
-    delete (to, ko, NULL);
-}
-
-Tobj Tcopy (Tobj fmvo) {
-    Tobj tovo;
-    long m;
-
-    tovo = NULL;
-    switch (M_TYPEOF (fmvo)) {
-    case T_INTEGER: case T_REAL: case T_STRING: case T_CODE:
-        tovo = fmvo;
-        break;
-    case T_TABLE:
-        mapinit ();
-        m = Mpushmark (fmvo);
-        tovo = Mnew (T_TABLESIZE, T_TABLE);
-        mapinsert (fmvo, tovo);
-        reccopytable (fmvo, tovo);
-        Mpopmark (m);
-        mapterm ();
-        break;
-    }
-    return tovo;
-}
-
-void Tgetfirst (Tobj to, Tkvindex_t *p) {
-    if (!to || !T_ISTABLE (to))
-        return;
-    p->tp = to, p->kvp = NULL, p->i = 0, p->j = 0;
-    for (; p->i < p->tp->ln; p->i++) {
-        if (!p->tp->lp[p->i])
-            continue;
-        for (; p->j < p->tp->lp[p->i]->i; p->j++) {
-            if ((p->kvp = &p->tp->lp[p->i]->kv[p->j]))
-                return;
-        }
-        p->j = 0;
-    }
-}
-
-void Tgetnext (Tkvindex_t *p) {
-    p->kvp = NULL;
-    p->j++;
-    for (; p->i < p->tp->ln; p->i++) {
-        if (!p->tp->lp[p->i])
-            continue;
-        for (; p->j < p->tp->lp[p->i]->i; p->j++) {
-            if ((p->kvp = &p->tp->lp[p->i]->kv[p->j]))
-                return;
-        }
-        p->j = 0;
-    }
-}
-
-static void insert (Ttable_t *tp, Tobj ko, char *sk, Tobj vo) {
-    Tkvlist_t *kvlp, *nkvlp;
-    Tkv_t *kvp;
-    int kt;
-    long ik, i, ind, nln;
-    double rk;
-
-    rk = 0.0;
-    kvlp = NULL;
-    ind = ik = 0;
-    switch ((kt = M_TYPEOF (ko))) {
-    case T_INTEGER:
-        ik = ((Tinteger_t *) ko)->i;
-        if ((kvlp = tp->lp[(ind = GETIKINDEX (tp, ik))]))
-            for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-                if (ISEQIK (ik, kvp[i].ko))
-                    goto found;
-        break;
-    case T_REAL:
-        rk = ((Treal_t *) ko)->d;
-        if ((kvlp = tp->lp[(ind = GETRKINDEX (tp, rk))]))
-            for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-                if (ISEQRK (rk, kvp[i].ko))
-                    goto found;
-        break;
-    case T_STRING:
-        if (M_AREAOF (ko) != 0)
-            sk = ((Tstring_t *) ko)->s;
-        if ((kvlp = tp->lp[(ind = GETSKINDEX (tp, sk))]))
-            for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-                if (ISEQSK (sk, kvp[i].ko))
-                    goto found;
-        break;
-    }
-    if ((nln = tp->n + 1) > 4 * tp->ln && nln < M_SIZEMAX) {
-        copytable (tp, nln);
-        switch (kt) {
-        case T_INTEGER: ind = GETIKINDEX (tp, ik); break;
-        case T_REAL:    ind = GETRKINDEX (tp, rk); break;
-        case T_STRING:  ind = GETSKINDEX (tp, sk); break;
-        }
-        kvlp = tp->lp[ind];
-    }
-    if (!kvlp) {
-        tp->lp[ind] = kvlp = Mallocate ((long) T_KVLISTSIZE (1));
-        kvlp->i = 0, kvlp->n = 1;
-    } else if (kvlp->i == kvlp->n) {
-        tp->lp[ind] = nkvlp = Mallocate ((long) T_KVLISTSIZE (kvlp->n * 2));
-        nkvlp->n = kvlp->n * 2;
-        for (i = 0; i < kvlp->n; i++)
-            nkvlp->kv[i] = kvlp->kv[i];
-        nkvlp->i = kvlp->i;
-        Mfree (kvlp, M_BYTE2SIZE (T_KVLISTSIZE (kvlp->n))), kvlp = nkvlp;
-    }
-    if (M_AREAOF (ko) == 0) { /* ko must be allocated */
-        switch (kt) {
-        case T_INTEGER: ko = Tinteger (ik); break;
-        case T_REAL:    ko = Treal (rk);    break;
-        case T_STRING:  ko = Tstring (sk);  break;
-        }
-    }
-
-    kvlp->kv[kvlp->i].ko = ko, kvlp->kv[kvlp->i++].vo = vo;
-    tp->n++;
-    tp->time = Ttime;
-    return;
-
-found:
-    kvp[i].vo = vo;
-    tp->time = Ttime;
-}
-
-static Tobj find (Ttable_t *tp, Tobj ko, char *sk) {
-    Tkvlist_t *kvlp;
-    Tkv_t *kvp;
-    long ik, i;
-    double rk;
-
-    switch (M_TYPEOF (ko)) {
-    case T_INTEGER:
-        ik = ((Tinteger_t *) ko)->i;
-        if ((kvlp = tp->lp[GETIKINDEX (tp, ik)]))
-            for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-                if (ISEQIK (ik, kvp[i].ko))
-                    goto found;
-        break;
-    case T_REAL:
-        rk = ((Treal_t *) ko)->d;
-        if ((kvlp = tp->lp[GETRKINDEX (tp, rk)]))
-            for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-                if (ISEQRK (rk, kvp[i].ko))
-                    goto found;
-        break;
-    case T_STRING:
-        if (M_AREAOF (ko) != 0)
-            sk = ((Tstring_t *) ko)->s;
-        if ((kvlp = tp->lp[GETSKINDEX (tp, sk)]))
-            for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-                if (ISEQSK (sk, kvp[i].ko))
-                    goto found;
-        break;
-    }
-    return NULL;
-
-found:
-    return kvp[i].vo;
-}
-
-static void delete (Ttable_t *tp, Tobj ko, char *sk) {
-    Tkvlist_t *kvlp;
-    Tkv_t *kvp;
-    long ik, i, j;
-    double rk;
-
-    switch (M_TYPEOF (ko)) {
-    case T_INTEGER:
-        ik = ((Tinteger_t *) ko)->i;
-        if ((kvlp = tp->lp[GETIKINDEX (tp, ik)]))
-            for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-                if (ISEQIK (ik, kvp[i].ko))
-                    goto found;
-        break;
-    case T_REAL:
-        rk = ((Treal_t *) ko)->d;
-        if ((kvlp = tp->lp[GETRKINDEX (tp, rk)]))
-            for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-                if (ISEQRK (rk, kvp[i].ko))
-                    goto found;
-        break;
-    case T_STRING:
-        if (M_AREAOF (ko) != 0)
-            sk = ((Tstring_t *) ko)->s;
-        if ((kvlp = tp->lp[GETSKINDEX (tp, sk)]))
-            for (i = 0, kvp = &kvlp->kv[0]; i < kvlp->i; i++)
-                if (ISEQSK (sk, kvp[i].ko))
-                    goto found;
-        break;
-    }
-    return;
-
-found:
-    for (j = i, kvp = &kvlp->kv[0]; j < kvlp->i - 1; j++)
-        kvp[j] = kvp[j + 1];
-    kvlp->i--;
-    tp->n--;
-    tp->time = Ttime;
-}
-
-static void copytable (Ttable_t *tp, long ln) {
-    Tkvlist_t **olp, **lp;
-    Tkvlist_t *okvlp, *kvlp, *nkvlp;
-    Tkv_t *kvp;
-    long ik, oln, i, j, k, ind;
-    double rk;
-    char *sk;
-
-    lp = Mallocate ((long) (ln * T_KVLISTPTRSIZE));
-    oln = tp->ln, tp->ln = ln;
-    olp = tp->lp, tp->lp = lp;
-    kvlp = NULL;
-    ind = 0;
-    for (i = 0; i < ln; i++)
-        lp[i] = NULL;
-    for (i = 0; i < oln; i++) {
-        if (!(okvlp = olp[i]))
-            continue;
-        for (j = 0; j < okvlp->i; j++) {
-            kvp = &okvlp->kv[j];
-            switch (M_TYPEOF (kvp->ko)) {
-            case T_INTEGER:
-                ik = ((Tinteger_t *) kvp->ko)->i;
-                kvlp = lp[(ind = GETIKINDEX (tp, ik))];
-                break;
-            case T_REAL:
-                rk = ((Treal_t *) kvp->ko)->d;
-                kvlp = lp[(ind = GETRKINDEX (tp, rk))];
-                break;
-            case T_STRING:
-                sk = ((Tstring_t *) kvp->ko)->s;
-                kvlp = lp[(ind = GETSKINDEX (tp, sk))];
-                break;
-            }
-            if (!kvlp) {
-                lp[ind] = kvlp = Mallocate ((long) T_KVLISTSIZE (1));
-                kvlp->i = 0, kvlp->n = 1;
-            } else if (kvlp->i == kvlp->n) {
-                lp[ind] = nkvlp = Mallocate ((long) T_KVLISTSIZE (kvlp->n * 2));
-                nkvlp->n = kvlp->n * 2;
-                for (k = 0; k < kvlp->i; k++)
-                    nkvlp->kv[k] = kvlp->kv[k];
-                nkvlp->i = kvlp->i;
-                Mfree (kvlp, M_BYTE2SIZE (T_KVLISTSIZE (kvlp->n)));
-                kvlp = nkvlp;
-            }
-            kvlp->kv[kvlp->i].ko = kvp->ko, kvlp->kv[kvlp->i++].vo = kvp->vo;
-        }
-        Mfree (okvlp, M_BYTE2SIZE (T_KVLISTSIZE (okvlp->n)));
-    }
-    Mfree (olp, M_BYTE2SIZE (oln * T_KVLISTPTRSIZE));
-}
-
-static void reccopytable (Ttable_t *fmtp, Ttable_t *totp) {
-    Tkv_t *fmkvp, *tokvp;
-    long i, j, m;
-
-    totp->lp = Mallocate ((long) (fmtp->ln * T_KVLISTPTRSIZE));
-    totp->ln = fmtp->ln;
-    totp->n = fmtp->n;
-    totp->time = Ttime;
-    for (i = 0; i < totp->ln; i++) {
-        if (!fmtp->lp[i]) {
-            totp->lp[i] = NULL;
-            continue;
-        }
-        totp->lp[i] = Mallocate ((long) T_KVLISTSIZE (fmtp->lp[i]->n));
-        totp->lp[i]->n = fmtp->lp[i]->n;
-        totp->lp[i]->i = 0;
-    }
-    m = Mpushmark (totp);
-    for (i = 0; i < totp->ln; i++) {
-        if (!totp->lp[i])
-            continue;
-        for (j = 0; j < fmtp->lp[i]->i; j++) {
-            fmkvp = &fmtp->lp[i]->kv[j], tokvp = &totp->lp[i]->kv[j];
-            tokvp->ko = fmkvp->ko;
-            switch (M_TYPEOF (fmkvp->vo)) {
-            case T_INTEGER: case T_REAL: case T_STRING: case T_CODE:
-                tokvp->vo = fmkvp->vo;
-                break;
-            case T_TABLE:
-                if (!(tokvp->vo = mapfind (fmkvp->vo))) {
-                    tokvp->vo = Mnew (T_TABLESIZE, T_TABLE);
-                    mapinsert (fmkvp->vo, tokvp->vo);
-                    reccopytable (fmkvp->vo, tokvp->vo);
-                }
-                break;
-            }
-            totp->lp[i]->i++;
-        }
-    }
-    Mpopmark (m);
-}
-
-static void mapinit (void) {
-    long li;
-
-    for (li = 0; li < MAPLISTN; li++)
-        map.list[li] = NULL;
-}
-
-static void mapterm (void) {
-    mapentry_t **lp;
-    mapentry_t *cep, *nep;
-    long li;
-
-    for (li = 0; li < MAPLISTN; li++) {
-        lp = &map.list[li];
-        for (cep = *lp; cep; cep = nep) {
-            nep = cep->next;
-            Mfree (cep, mapentrybyte2size);
-        }
-        *lp = NULL;
-    }
-}
-
-static void mapinsert (Tobj fmo, Tobj too) {
-    mapentry_t **lp;
-    mapentry_t *cep;
-
-    lp = &map.list[(uint64_t) fmo % MAPLISTN];
-    if (!(cep = Mallocate (MAPENTRYSIZE)))
-        panic1 (POS, "mapinsert", "cannot allocate mapentry");
-    cep->fmo = fmo, cep->too = too;
-    cep->next = *lp, *lp = cep;
-}
-
-static Tobj mapfind (Tobj fmo) {
-    mapentry_t **lp;
-    mapentry_t *cep;
-
-    lp = &map.list[(uint64_t) fmo % MAPLISTN];
-    for (cep = *lp; cep; cep = cep->next)
-        if (cep->fmo == fmo)
-            return cep->too;
-    return NULL;
-}
diff --git a/cmd/lefty/tbl.h b/cmd/lefty/tbl.h
deleted file mode 100644 (file)
index 777c2bc..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#pragma once
-
-#ifdef _WIN32
-#include "mem.h"
-#endif
-
-
-
-#define T_INTEGER 1
-#define T_REAL    2
-#define T_STRING  3
-#define T_CODE    4
-#define T_TABLE   5
-#define T_SIZE    6
-
-typedef struct Tinteger_t {
-    Mheader_t head;
-    long i;
-} Tinteger_t;
-#define T_INTEGERSIZE sizeof (Tinteger_t)
-typedef struct Treal_t {
-    Mheader_t head;
-    double d;
-} Treal_t;
-#define T_REALSIZE sizeof (Treal_t)
-typedef struct Tstring_t {
-    Mheader_t head;
-    char s[1];
-} Tstring_t;
-#define T_STRINGSIZE(l) (l + Tstringoffset)
-typedef struct Tcode_t {
-    Mheader_t head;
-    Code_t c[1];
-} Tcode_t;
-#define T_CODESIZE(l) (l * C_CODESIZE + Tcodeoffset)
-typedef struct Tkv_t {
-    void *ko;
-    void *vo;
-} Tkv_t;
-#define T_KVSIZE sizeof (Tkv_t)
-typedef struct Tkvlist_t {
-    long i, n;
-    Tkv_t kv[1];
-} Tkvlist_t;
-#define T_KVLISTSIZE(l) (l * T_KVSIZE + Tkvoffset)
-#define T_KVLISTPTRSIZE sizeof (Tkvlist_t *)
-typedef struct Ttable_t {
-    Mheader_t head;
-    long n, ln;
-    long time;
-    Tkvlist_t **lp;
-} Ttable_t;
-#define T_TABLESIZE sizeof (Ttable_t)
-typedef struct Tkvindex_t {
-    Ttable_t *tp;
-    Tkv_t *kvp;
-    long i, j;
-} Tkvindex_t;
-
-typedef void *Tobj;
-
-typedef struct Tonm_t { /* Object aNd Mark */
-    Tobj o;
-    long m;
-} Tonm_t;
-
-#define T_ISSTRING(o)  (M_TYPEOF (o) == T_STRING)
-#define T_ISTABLE(o)   (M_TYPEOF (o) == T_TABLE)
-#define T_ISINTEGER(o) (M_TYPEOF (o) == T_INTEGER)
-#define T_ISREAL(o)    (M_TYPEOF (o) == T_REAL)
-#define T_ISNUMBER(o)  (M_TYPEOF (o) == T_REAL || M_TYPEOF (o) == T_INTEGER)
-
-#define Tgettype(p)    (((Mheader_t *) p)->type)
-#define Tgettablen(p)  (((Ttable_t *) p)->n)
-#define Tgettime(p)    (((Ttable_t *) p)->time)
-#define Tgetstring(p)  (char *) &(((Tstring_t *) p)->s[0])
-#define Tgetcode(p)    (Code_t *) &(((Tcode_t *) p)->c[0])
-#define Tgetinteger(p) (((Tinteger_t *) p)->i)
-#define Tgetreal(p)    (((Treal_t *) p)->d)
-#define Tgetnumber(p)  (T_ISINTEGER (p) ? Tgetinteger (p) : Tgetreal (p))
-
-#define TCgettype(p, off)    ((Tgetcode (p) + off)->ctype)
-#define TCgetfp(p, off)      ((Tgetcode (p) + off)->u.fp)
-#define TCgetinteger(p, off) ((Tgetcode (p) + off)->u.i)
-#define TCgetobject(p, off)  ((Tgetcode (p) + off)->u.o)
-#define TCgetreal(p, off)    ((Tgetcode (p) + off)->u.d)
-#define TCgetstring(p, off)  ((char *) &((Tgetcode (p) + off)->u.s))
-#define TCgetnext(p, off)    ((Tgetcode (p) + off)->next)
-#define TCgetaddr(p, off)    (Tgetcode (p) + off)
-
-extern long Ttime;
-extern int Tstringoffset, Tcodeoffset, Tkvoffset;
-extern Tobj Ttrue, Tfalse;
-
-void Tinit (void);
-void Tterm (void);
-void Tgchelper (void *);
-void Tfreehelper (void *);
-Tobj Tinteger (long);
-Tobj Treal (double);
-Tobj Tstring (char *);
-Tobj Tcode (Code_t *, int, int);
-Tobj Ttable (long);
-void Tinsi (Tobj, long, Tobj);
-void Tinsr (Tobj, double, Tobj);
-void Tinss (Tobj, char *, Tobj);
-void Tinso (Tobj, Tobj, Tobj);
-Tobj Tfindi (Tobj, long);
-Tobj Tfindr (Tobj, double);
-Tobj Tfinds (Tobj, char *);
-Tobj Tfindo (Tobj, Tobj);
-void Tdeli (Tobj, long);
-void Tdelr (Tobj, double);
-void Tdels (Tobj, char *);
-void Tdelo (Tobj, Tobj);
-Tobj Tcopy (Tobj);
-void Tgetfirst (Tobj, Tkvindex_t *);
-void Tgetnext (Tkvindex_t *);
diff --git a/cmd/lefty/txtview.c b/cmd/lefty/txtview.c
deleted file mode 100644 (file)
index b1ed3c7..0000000
+++ /dev/null
@@ -1,674 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "mem.h"
-#include "code.h"
-#include "tbl.h"
-#include "parse.h"
-#include "exec.h"
-#include "str.h"
-#include "txtview.h"
-
-#define TXT_SEEN     0
-#define TXT_ABSTRACT 1
-#define TXT_FULL     2
-
-typedef struct txtnode_t {
-    int mode;
-    int ttype;
-    Tobj ko, vo;
-    long time;
-    char *path;
-    union {
-        struct {
-            struct txtnode_t *txtnode;
-            Tobj ko;
-            char *text;
-            int wi;
-        } s;
-        struct {
-            char *text;
-            int wi;
-        } a;
-        union {
-            struct {
-                char *text;
-                int wi;
-            } s;
-            struct {
-                char *ftext, *ltext;
-                int fwi, mwi, lwi;
-                struct txtnode_t *list;
-                int n;
-            } t;
-        } f;
-    } u;
-} txtnode_t;
-static txtnode_t *txtroot;
-static txtnode_t defnode;
-
-static txtnode_t **seenp;
-static long seeni, seenn;
-#define SEENINCR 100
-#define SEENSIZE sizeof (txtnode_t)
-
-static Tobj txtvo2toggle = NULL;
-
-static Gwattr_t arraydata[2], buttondata[5];
-
-static int txton, txtx, txty, txtwidth, txtheight;
-static int txtwi, queryws[G_QWMODES + 1], listwi, scrollwi, arraywi, cmdwi;
-
-static Psrc_t src;
-
-#define __max(a, b) (((a) >= (b)) ? (a) : (b))
-
-static void viewon (void);
-static void viewoff (void);
-static void update (txtnode_t *, long);
-static void buildlist (txtnode_t *);
-static void rebuildlist (txtnode_t *);
-static void fillnode (txtnode_t *, txtnode_t *);
-static void unfillnode (txtnode_t *);
-static int cmp (const void *, const void *);
-static txtnode_t *findseen (txtnode_t *);
-static void add2seen (txtnode_t *);
-static void orderfunc (void *, Gawdata_t *);
-static void coordsfunc (int, Gawdata_t *);
-static void coords2func (int, Gawdata_t *);
-
-void TXTinit (Grect_t r) {
-    Gwattr_t data[1];
-    int i;
-
-    txton = TRUE;
-    txtwi = -1;
-    txtx = r.o.x, txty = r.o.y;
-    txtwidth = r.c.x - r.o.x + 1, txtheight = r.c.y - r.o.y + 1;
-
-    buttondata[0].id = G_ATTRBUTTONCB;
-    buttondata[0].u.func = TXTtoggle;
-    buttondata[1].id = G_ATTRSIZE;
-    buttondata[1].u.s.x = buttondata[1].u.s.y = 0;
-    buttondata[2].id = G_ATTRBORDERWIDTH;
-    buttondata[2].u.i = 0;
-    buttondata[3].id = G_ATTRTEXT;
-    buttondata[4].id = G_ATTRUSERDATA;
-
-    arraydata[0].id = G_ATTRRESIZECB;
-    arraydata[0].u.func = coordsfunc;
-    arraydata[1].id = G_ATTRSIZE;
-    arraydata[1].u.s.x = arraydata[1].u.s.y = 0;
-
-    defnode.mode = TXT_ABSTRACT;
-    defnode.ttype = T_TABLE;
-    defnode.ko = defnode.vo = NULL;
-    defnode.time = -1;
-    defnode.path = NULL;
-    defnode.u.s.txtnode = NULL;
-    defnode.u.s.ko = NULL;
-    defnode.u.s.text = NULL;
-    defnode.u.s.wi = 0;
-    defnode.u.a.text = NULL;
-    defnode.u.a.wi = 0;
-    defnode.u.f.s.text = NULL;
-    defnode.u.f.s.wi = 0;
-    defnode.u.f.t.ftext = defnode.u.f.t.ltext = NULL;
-    defnode.u.f.t.fwi = 0;
-    defnode.u.f.t.mwi = 0;
-    defnode.u.f.t.lwi = 0;
-    defnode.u.f.t.list = NULL;
-    defnode.u.f.t.n = 0;
-
-    for (i = 1; i <= G_QWMODES; i++) {
-        data[0].id = G_ATTRMODE;
-        switch (i) {
-        case G_QWSTRING:
-            data[0].u.t = "string";
-            break;
-        case G_QWFILE:
-            data[0].u.t = "file";
-            break;
-        case G_QWCHOICE:
-            data[0].u.t = "choice";
-            break;
-        }
-        queryws[i] = Gcreatewidget (-1, G_QUERYWIDGET, 1, &data[0]);
-    }
-
-    src.flag = CHARSRC, src.fp = NULL, src.tok = -1, src.lnum = 1;
-}
-
-void TXTterm (void) {
-    int i;
-
-    for (i = 1; i <= G_QWMODES; i++)
-        Gdestroywidget (queryws[i]);
-    if (txton)
-        viewoff (), txton = FALSE;
-}
-
-/* LEFTY builtin */
-int TXTmode (int argc, lvar_t *argv) {
-    char *s;
-
-    if (!argv[0].o || Tgettype (argv[0].o) != T_STRING)
-        return L_FAILURE;
-    s = Tgetstring (argv[0].o);
-    if (strcmp (s, "on") == 0) {
-        if (txtwi == -1)
-            viewon ();
-    } else if (strcmp (s, "off") == 0) {
-        if (txtwi != -1)
-            viewoff ();
-        else
-            txton = FALSE;
-    }
-    return L_SUCCESS;
-}
-
-static void viewon (void) {
-    Gwattr_t data[5];
-
-    data[0].id = G_ATTRNAME;
-    data[0].u.t = "LEFTY text view";
-    data[1].id = G_ATTRORIGIN;
-    data[1].u.p.x = txtx, data[1].u.p.y = txty;
-    data[2].id = G_ATTRSIZE;
-    data[2].u.s.x = txtwidth, data[2].u.s.y = txtheight;
-    txtwi = Gcreatewidget (-1, G_VIEWWIDGET, 3, &data[0]);
-
-    data[0].id = G_ATTRSIZE;
-    data[0].u.s.x = txtwidth, data[0].u.s.y = txtheight;
-    data[1].id = G_ATTRBORDERWIDTH;
-    data[1].u.i = 1;
-    data[2].id = G_ATTRRESIZECB;
-    data[2].u.func = coords2func;
-    listwi = Gcreatewidget (txtwi, G_ARRAYWIDGET, 3, &data[0]);
-    Gawsetmode (&Gwidgets[listwi], TRUE);
-
-    data[0].id = G_ATTRSIZE;
-    data[0].u.s.x = txtwidth, data[0].u.s.y = txtheight / 3;
-    data[1].id = G_ATTRBORDERWIDTH;
-    data[1].u.i = 0;
-    data[2].id = G_ATTRTEXT;
-    data[2].u.t = NULL;
-    data[3].id = G_ATTRNEWLINECB;
-    data[3].u.func = TXTprocess;
-    data[4].id = G_ATTRMODE;
-    data[4].u.t = "oneline";
-    cmdwi = Gcreatewidget (listwi, G_TEXTWIDGET, 5, &data[0]);
-
-    data[0].id = G_ATTRSIZE;
-    data[0].u.s.x = txtwidth, data[0].u.s.y = txtheight * 2 / 3;
-    data[1].id = G_ATTRMODE;
-    data[1].u.t = "forcebars";
-    scrollwi = Gcreatewidget (listwi, G_SCROLLWIDGET, 2, &data[0]);
-
-    data[0].id = G_ATTRRESIZECB;
-    data[0].u.func = coordsfunc;
-    data[1].id = G_ATTRSIZE;
-    data[1].u.s.x = txtwidth, data[1].u.s.y = txtheight;
-    data[2].id = G_ATTRBORDERWIDTH;
-    data[2].u.i = 0;
-    arraywi = Gcreatewidget (scrollwi, G_ARRAYWIDGET, 3, &data[0]);
-
-    Gawsetmode (&Gwidgets[listwi], FALSE);
-
-    if (!(txtroot = malloc (sizeof (txtnode_t))))
-        panic1 (POS, "TXTinit", "txtroot malloc failed");
-    *txtroot = defnode;
-    txtroot->mode = TXT_FULL;
-    txtroot->vo = root;
-    txtroot->path = NULL;
-    txtroot->u.f.t.mwi = arraywi;
-
-    seenp = Marrayalloc ((long) SEENINCR * SEENSIZE);
-    seeni = 0;
-    seenn = SEENINCR;
-    txton = TRUE;
-}
-
-static void viewoff (void) {
-    Marrayfree (seenp);
-    seeni = seenn = 0;
-    unfillnode (txtroot);
-    free (txtroot);
-    Gdestroywidget (arraywi);
-    Gdestroywidget (scrollwi);
-    Gdestroywidget (cmdwi);
-    Gdestroywidget (listwi);
-    Gdestroywidget (txtwi);
-    txton = FALSE;
-    txtwi = -1;
-}
-
-/* LEFTY builtin */
-int TXTask (int argc, lvar_t *argv) {
-    Tobj so, ao;
-    char buf[1200];
-    char *sp, *ap;
-    int mode;
-
-    mode = 0;
-    ap = NULL;
-    if (argc < 2)
-        mode = G_QWSTRING;
-    else {
-        so = argv[1].o;
-        if (T_ISSTRING (so)) {
-            sp = Tgetstring (so);
-            if (strcmp (sp, "string") == 0)
-                mode = G_QWSTRING;
-            else if (strcmp (sp, "file") == 0)
-                mode = G_QWFILE;
-            else if (strcmp (sp, "choice") == 0)
-                mode = G_QWCHOICE;
-            else mode = 0;
-        }
-    }
-    if (argc < 3)
-        ap = NULL;
-    else {
-        ao = argv[2].o;
-        if (T_ISSTRING (ao))
-            ap = Tgetstring (ao);
-    }
-    if (Gqueryask (queryws[mode], Tgetstring (argv[0].o), ap, buf, 1200) == 0)
-        rtno = Tstring (buf);
-    else
-        rtno = NULL;
-#ifndef NOQUERYFIX
-    if (mode == G_QWCHOICE) {
-        Gwattr_t data[1];
-
-        data[0].id = G_ATTRMODE;
-        data[0].u.t = "choice";
-        Gdestroywidget (queryws[mode]);
-        queryws[mode] = Gcreatewidget (-1, G_QUERYWIDGET, 1, &data[0]);
-    }
-#endif
-    return L_SUCCESS;
-}
-
-void TXTprocess (int wi, char *sp) {
-    Tobj co;
-
-    src.s = sp;
-    if ((co = Punit (&src)))
-        Eunit(co);
-}
-
-void TXTupdate (void) {
-    if (!txton)
-        return;
-    if (txtwi == -1)
-        viewon ();
-    seeni = 0;
-    update (txtroot, txtroot->time);
-    txtroot->time = Ttime;
-    Ttime++;
-}
-
-void TXTtoggle (int wi, void *data) {
-    txtvo2toggle = data;
-    TXTupdate ();
-    txtvo2toggle = NULL;
-}
-
-/* update is called only for TXT_FULL tables */
-static void update (txtnode_t *pnode, long ptim) {
-    txtnode_t *cnode, *seennode;
-    long ctim;
-    int i;
-
-    Gawsetmode (&Gwidgets[pnode->u.f.t.mwi], TRUE);
-    if (!pnode->u.f.t.list)
-        buildlist (pnode);
-    else if (ptim < Tgettime (pnode->vo))
-        rebuildlist (pnode);
-    for (
-        i = 0, cnode = &pnode->u.f.t.list[0]; i < pnode->u.f.t.n;
-        i++, cnode++
-    ) {
-        ctim = cnode->time;
-        if (txtvo2toggle == cnode->vo) {
-            switch (cnode->mode) {
-            case TXT_SEEN:
-                break;
-            case TXT_ABSTRACT:
-                unfillnode (cnode);
-                cnode->mode = TXT_FULL;
-                fillnode (pnode, cnode);
-                break;
-            case TXT_FULL:
-                unfillnode (cnode);
-                cnode->mode = TXT_ABSTRACT;
-                fillnode (pnode, cnode);
-                break;
-            }
-        }
-        if (!(seennode = findseen (cnode)))
-            add2seen (cnode);
-        if (
-            seennode && cnode->mode == TXT_SEEN && seennode->ko != cnode->u.s.ko
-        ) {
-            unfillnode (cnode);
-            cnode->u.s.txtnode = seennode;
-            cnode->u.s.ko = seennode->ko;
-            fillnode (pnode, cnode);
-        } else if (seennode && cnode->mode != TXT_SEEN) {
-            unfillnode (cnode);
-            cnode->mode = TXT_SEEN;
-            cnode->u.s.txtnode = seennode;
-            cnode->u.s.ko = seennode->ko;
-            fillnode (pnode, cnode);
-        } else if (!seennode && cnode->mode == TXT_SEEN) {
-            unfillnode (cnode);
-            cnode->mode = TXT_ABSTRACT;
-            fillnode (pnode, cnode);
-        } else if (cnode->time == -1) {
-            unfillnode (cnode);
-            if (seennode)
-                cnode->u.s.txtnode = seennode;
-            fillnode (pnode, cnode);
-        }
-        if (cnode->ttype == T_TABLE && cnode->mode == TXT_FULL)
-            update (cnode, ctim);
-    }
-    Gaworder (&Gwidgets[pnode->u.f.t.mwi], pnode, orderfunc);
-    Gawsetmode (&Gwidgets[pnode->u.f.t.mwi], FALSE);
-}
-
-static void buildlist (txtnode_t *pnode) {
-    Tkvindex_t tkvi;
-    Tobj ko, vo;
-    int vtype;
-    txtnode_t *cnode;
-
-    pnode->u.f.t.n = ((Ttable_t *) pnode->vo)->n;
-    if (!(pnode->u.f.t.list = malloc (
-        __max (pnode->u.f.t.n, 1) * sizeof (txtnode_t)
-    )))
-        panic1 (POS, "buildlist", "list malloc failed");
-
-    for (
-        cnode = &pnode->u.f.t.list[0], Tgetfirst (pnode->vo, &tkvi);
-        tkvi.kvp; Tgetnext (&tkvi)
-    ) {
-        ko = tkvi.kvp->ko, vo = tkvi.kvp->vo;
-        vtype = Tgettype (vo);
-        if (vtype == T_CODE && TCgettype (vo, TCgetnext (
-            vo, TCgetnext (vo, TCgetnext (vo, TCgetfp (vo, 0)))
-        )) == C_INTERNAL) {
-            pnode->u.f.t.n--;
-            continue;
-        }
-        *cnode = defnode;
-        cnode->vo = vo;
-        cnode->ko = ko;
-        cnode->ttype = vtype;
-        cnode++;
-    }
-    qsort (
-        (char *) pnode->u.f.t.list, pnode->u.f.t.n, sizeof (txtnode_t), cmp
-    );
-}
-
-static void rebuildlist (txtnode_t *pnode) {
-    Tkvindex_t tkvi;
-    Tobj ko, vo;
-    int vtype;
-    txtnode_t *cnode;
-    txtnode_t *olist, *nlist;
-    txtnode_t tmpnode;
-    int on, nn, i, j, cmpval;
-
-    cmpval = 0;
-    olist = pnode->u.f.t.list;
-    on = pnode->u.f.t.n;
-    pnode->u.f.t.n = ((Ttable_t *) pnode->vo)->n;
-    if (!(pnode->u.f.t.list = malloc (
-        __max (pnode->u.f.t.n, 1) * sizeof (txtnode_t)
-    )))
-        panic1 (POS, "rebuildlist", "list malloc failed");
-
-    for (
-        cnode = &pnode->u.f.t.list[0], Tgetfirst (pnode->vo, &tkvi);
-        tkvi.kvp; Tgetnext (&tkvi)
-    ) {
-        ko = tkvi.kvp->ko, vo = tkvi.kvp->vo;
-        vtype = Tgettype (vo);
-        if (vtype == T_CODE && TCgettype (vo, TCgetnext (
-            vo, TCgetnext (vo, TCgetnext (vo, TCgetfp (vo, 0)))
-        )) == C_INTERNAL) {
-            pnode->u.f.t.n--;
-            continue;
-        }
-        *cnode = defnode;
-        cnode->vo = vo;
-        cnode->ko = ko;
-        cnode->ttype = vtype;
-        cnode++;
-    }
-    qsort ((char *) pnode->u.f.t.list, pnode->u.f.t.n, sizeof (txtnode_t), cmp);
-    nlist = pnode->u.f.t.list;
-    nn = pnode->u.f.t.n;
-    for (i = 0, j = 0; i < nn; i++) {
-        while (j < on && (cmpval = cmp (&olist[j], &nlist[i])) < 0)
-            j++;
-        if (j < on && cmpval == 0 && nlist[i].vo == olist[j].vo)
-            tmpnode = olist[j], olist[j] = nlist[i], nlist[i] = tmpnode, j++;
-    }
-    for (j = 0; j < on; j++)
-        unfillnode (&olist[j]);
-    free (olist);
-}
-
-static void fillnode (txtnode_t *pnode, txtnode_t *cnode) {
-    cnode->time = Ttime;
-    cnode->path = Spath (pnode->path, cnode->ko);
-    switch (cnode->mode) {
-    case TXT_SEEN:
-        cnode->u.s.text = Sseen (cnode->ko, cnode->u.s.txtnode->path);
-        buttondata[3].u.t = cnode->u.s.text;
-        buttondata[4].u.u = (uint64_t) cnode->vo;
-        cnode->u.s.wi = Gcreatewidget (
-            pnode->u.f.t.mwi, G_BUTTONWIDGET, 5, &buttondata[0]
-        );
-        break;
-    case TXT_ABSTRACT:
-        cnode->u.a.text = Sabstract (cnode->ko, cnode->vo);
-        buttondata[3].u.t = cnode->u.a.text;
-        buttondata[4].u.u = (uint64_t) cnode->vo;
-        cnode->u.a.wi = Gcreatewidget (
-            pnode->u.f.t.mwi, G_BUTTONWIDGET, 5, &buttondata[0]
-        );
-        break;
-    case TXT_FULL:
-        if (cnode->ttype == T_TABLE) {
-            cnode->u.f.t.ftext = Stfull (cnode->ko);
-            cnode->u.f.t.ltext = "];";
-            buttondata[3].u.t = cnode->u.f.t.ftext;
-            buttondata[4].u.u = (uint64_t) cnode->vo;
-            cnode->u.f.t.fwi = Gcreatewidget (
-                pnode->u.f.t.mwi, G_BUTTONWIDGET, 5, &buttondata[0]
-            );
-            cnode->u.f.t.mwi = Gcreatewidget (
-                pnode->u.f.t.mwi, G_ARRAYWIDGET, 2, &arraydata[0]
-            );
-            buttondata[3].u.t = cnode->u.f.t.ltext;
-            buttondata[4].u.u = (uint64_t) cnode->vo;
-            cnode->u.f.t.lwi = Gcreatewidget (
-                pnode->u.f.t.mwi, G_BUTTONWIDGET, 5, &buttondata[0]
-            );
-        } else {
-            cnode->u.f.s.text = Ssfull (cnode->ko, cnode->vo);
-            buttondata[3].u.t = cnode->u.f.s.text;
-            buttondata[4].u.u = (uint64_t) cnode->vo;
-            cnode->u.f.s.wi = Gcreatewidget (
-                pnode->u.f.t.mwi, G_BUTTONWIDGET, 5, &buttondata[0]
-            );
-        }
-        break;
-    }
-}
-
-static void unfillnode (txtnode_t *cnode) {
-    int i;
-
-    free (cnode->path), cnode->path = NULL;
-    switch (cnode->mode) {
-    case TXT_SEEN:
-        free (cnode->u.s.text);
-        if (cnode->u.s.wi)
-            Gdestroywidget (cnode->u.s.wi);
-        break;
-    case TXT_ABSTRACT:
-        free (cnode->u.a.text);
-        if (cnode->u.a.wi)
-            Gdestroywidget (cnode->u.a.wi);
-        break;
-    case TXT_FULL:
-        if (cnode->ttype == T_TABLE) {
-            for (i = 0; i < cnode->u.f.t.n; i++)
-                unfillnode (&cnode->u.f.t.list[i]);
-            free (cnode->u.f.t.list);
-            free (cnode->u.f.t.ftext);
-            if (cnode->u.f.t.fwi) {
-                Gdestroywidget (cnode->u.f.t.fwi);
-                Gdestroywidget (cnode->u.f.t.mwi);
-                Gdestroywidget (cnode->u.f.t.lwi);
-            }
-        } else {
-            free (cnode->u.f.s.text);
-            if (cnode->u.f.s.wi)
-                Gdestroywidget (cnode->u.f.s.wi);
-        }
-        break;
-    }
-    cnode->u.s.text = NULL;
-    cnode->u.s.wi = 0;
-    cnode->u.a.text = NULL;
-    cnode->u.a.wi = 0;
-    cnode->u.f.t.list = NULL;
-    cnode->u.f.t.ftext = NULL;
-    cnode->u.f.t.fwi = 0;
-    cnode->u.f.t.mwi = 0;
-    cnode->u.f.t.lwi = 0;
-    cnode->u.f.s.text = NULL;
-    cnode->u.f.s.wi = 0;
-}
-
-static int cmp (const void *a, const void *b) {
-    int atype, btype;
-    txtnode_t *anode, *bnode;
-    double d1, d2;
-
-    d1 = 0.0, d2 = 0.0;
-    anode = (txtnode_t *) a, bnode = (txtnode_t *) b;
-    atype = Tgettype (anode->ko), btype = Tgettype (bnode->ko);
-    if (atype != btype)
-        return (atype - btype);
-    if (atype == T_STRING)
-        return strcmp (Tgetstring (anode->ko), Tgetstring (bnode->ko));
-    if (atype == T_INTEGER)
-        d1 = Tgetinteger (anode->ko), d2 = Tgetinteger (bnode->ko);
-    else if (atype == T_REAL)
-        d1 = Tgetreal (anode->ko), d2 = Tgetreal (bnode->ko);
-    if (d1 < d2)
-        return -1;
-    else if (d1 > d2)
-        return 1;
-    else
-        return 0; /* but this should never happen since keys are unique */
-}
-
-static txtnode_t *findseen (txtnode_t *cnode) {
-    int i;
-
-    for (i = 0; i < seeni; i++)
-        if (seenp[i]->vo == cnode->vo)
-            return seenp[i];
-    return NULL;
-}
-
-static void add2seen (txtnode_t *cnode) {
-    if (seeni >= seenn) {
-        seenp = Marraygrow (seenp, (long) (seenn + SEENINCR) * SEENSIZE);
-        seenn += SEENINCR;
-    }
-    seenp[seeni++] = cnode;
-}
-
-static void orderfunc (void *data, Gawdata_t *dp) {
-    txtnode_t *pnode, *cnode;
-    int i;
-
-    pnode = data;
-    dp->cj = 0;
-    for (i = 0, cnode = &pnode->u.f.t.list[0]; i < pnode->u.f.t.n; i++, cnode++)
-        switch (cnode->mode) {
-        case TXT_SEEN:
-            dp->carray[dp->cj++].w = Gwidgets[cnode->u.s.wi].w;
-            break;
-        case TXT_ABSTRACT:
-            dp->carray[dp->cj++].w = Gwidgets[cnode->u.a.wi].w;
-            break;
-        case TXT_FULL:
-            if (cnode->ttype == T_TABLE) {
-                dp->carray[dp->cj++].w = Gwidgets[cnode->u.f.t.fwi].w;
-                dp->carray[dp->cj++].w = Gwidgets[cnode->u.f.t.mwi].w;
-                dp->carray[dp->cj++].w = Gwidgets[cnode->u.f.t.lwi].w;
-            } else
-                dp->carray[dp->cj++].w = Gwidgets[cnode->u.f.s.wi].w;
-            break;
-        }
-}
-
-static void coordsfunc (int wi, Gawdata_t *dp) {
-    Gawcarray_t *cp;
-    int cox, coy;
-    int ci;
-
-    cox = coy = 0;
-    for (ci = 0; ci < dp->cj; ci++) {
-        cp = &dp->carray[ci];
-        if (!cp->flag)
-            continue;
-        cp->ox = cox, cp->oy = coy;
-        cp->sx = dp->sx - 2 * cp->bs;
-        coy += cp->sy + 2 * cp->bs;
-    }
-    dp->sy = coy;
-}
-
-static void coords2func (int wi, Gawdata_t *dp) {
-    Gawcarray_t *cp;
-    int cox, coy;
-    int ci, cj;
-
-    cox = coy = 0;
-    for (ci = 0, cj = 0; ci < dp->cj; ci++) {
-        cp = &dp->carray[ci];
-        if (!cp->flag)
-            continue;
-        cp->ox = cox, cp->oy = coy;
-        cj++;
-        cp->sx = dp->sx - 2 * cp->bs;
-        if (cj == 2)
-            cp->sy = dp->sy - coy - 2 * cp->bs;
-        coy += cp->sy + 2 * cp->bs;
-    }
-}
diff --git a/cmd/lefty/txtview.h b/cmd/lefty/txtview.h
deleted file mode 100644 (file)
index 441a3a3..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-void TXTinit (Grect_t);
-void TXTterm (void);
-int TXTmode (int argc, lvar_t *argv);
-int TXTask (int argc, lvar_t *argv);
-void TXTprocess (int, char *);
-void TXTupdate (void);
-void TXTtoggle (int, void *);
diff --git a/cmd/lefty/ws/gtk/garray.c b/cmd/lefty/ws/gtk/garray.c
deleted file mode 100644 (file)
index 84f87df..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WAU widget->u.a
-
-int GAcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-    PIXsize_t ps;
-    int ai;
-    GdkColor c;
-    int color;
-
-    if (!parent) {
-       Gerr(POS, G_ERRNOPARENTWIDGET);
-       return -1;
-    }
-    WAU->func = NULL;
-    ps.x = ps.y = MINAWSIZE;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINAWSIZE);
-           break;
-       case G_ATTRBORDERWIDTH:
-           break;
-       case G_ATTRMODE:
-           if (strcmp("horizontal", attrp[ai].u.t) == 0) {
-               WAU->mode = G_AWHARRAY;
-           } else if (strcmp("vertical", attrp[ai].u.t) == 0) {
-               WAU->mode = G_AWVARRAY;
-           } else {
-               Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-               return -1;
-           }
-           break;
-       case G_ATTRLAYOUT:
-           if (strcmp("on", attrp[ai].u.t) == 0)
-               Gawsetmode(widget, FALSE);
-           else if (strcmp("off", attrp[ai].u.t) == 0)
-               Gawsetmode(widget, TRUE);
-           else {
-               Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-               return -1;
-           }
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color != 0 && color != 1) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           c.red = attrp[ai].u.c.r * 257;
-           c.green = attrp[ai].u.c.g * 257;
-           c.blue = attrp[ai].u.c.b * 257;
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
-           return -1;
-       case G_ATTRRESIZECB:
-           WAU->func = (Gawcoordscb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    if (WAU->mode == G_AWHARRAY)
-       widget->w = gtk_hbox_new(FALSE, 0);
-    else
-       widget->w = gtk_vbox_new(FALSE, 0);
-    if (parent->type == 7) {
-       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW
-                                             (parent->w), widget->w);
-    } else {
-       gtk_container_add(GTK_CONTAINER(parent->w), widget->w);
-    }
-    gtk_widget_set_usize(widget->w, ps.x, ps.y);
-    gtk_widget_show(widget->w);
-
-    return 0;
-}
-
-
-int GAsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    PIXsize_t ps;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINAWSIZE);
-           break;
-       case G_ATTRBORDERWIDTH:
-           break;
-       case G_ATTRMODE:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "mode");
-           return -1;
-       case G_ATTRLAYOUT:
-           if (strcmp("on", attrp[ai].u.t) == 0)
-               Gawsetmode(widget, FALSE);
-           else if (strcmp("off", attrp[ai].u.t) == 0)
-               Gawsetmode(widget, TRUE);
-           else {
-               Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-               return -1;
-           }
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
-           return -1;
-       case G_ATTRRESIZECB:
-           WAU->func = (Gawcoordscb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    return 0;
-}
-
-
-int GAgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int width, height;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-           break;
-       case G_ATTRBORDERWIDTH:
-           attrp[ai].u.i = width;
-           break;
-       case G_ATTRMODE:
-           attrp[ai].u.t =
-               (WAU->mode == G_AWHARRAY) ? "horizontal" : "vertical";
-           break;
-       case G_ATTRLAYOUT:
-           break;
-       case G_ATTRWINDOWID:
-
-           break;
-       case G_ATTRRESIZECB:
-           attrp[ai].u.func = WAU->func;
-           break;
-       case G_ATTRUSERDATA:
-           attrp[ai].u.u = widget->udata;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GAdestroywidget(Gwidget_t * widget)
-{
-    gtk_widget_destroy(widget->w);
-    return 0;
-}
-
-
-void Gawdefcoordscb(int wi, Gawdata_t * dp)
-{
-    Gawcarray_t *cp;
-    int sx, sy, csx, csy, ci;
-
-    sx = dp->sx, sy = dp->sy;
-    csx = csy = 0;
-    for (ci = 0; ci < dp->cj; ci++) {
-       cp = &dp->carray[ci];
-       if (!cp->flag)
-           continue;
-
-       cp->ox = csx, cp->oy = csy;
-       if (dp->type == G_AWVARRAY)
-           cp->sx = sx - 2 * cp->bs, csy += cp->sy + 2 * cp->bs;
-       else
-           cp->sy = sy - 2 * cp->bs, csx += cp->sx + 2 * cp->bs;
-
-    }
-    if (dp->type == G_AWVARRAY)
-       dp->sy = csy;
-    else
-       dp->sx = csx;
-}
-
-int Gawsetmode(Gwidget_t * widget, int mode)
-{
-    return 0;
-}
-
-
-int Gaworder(Gwidget_t * widget, void *data, Gawordercb func)
-{
-}
diff --git a/cmd/lefty/ws/gtk/gbutton.c b/cmd/lefty/ws/gtk/gbutton.c
deleted file mode 100644 (file)
index 73ba612..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WBU widget->u.b
-
-gint bwcallback(GtkWidget * w, GdkEvent * event, gpointer * data);
-
-int GBcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-
-    PIXsize_t ps;
-    char *s;
-    int ai;
-    GdkColor c;
-    int color;
-    GtkWidget *label;
-
-    if (!parent) {
-       Gerr(POS, G_ERRNOPARENTWIDGET);
-       return -1;
-    }
-    WBU->func = NULL;
-    ps.x = ps.y = MINBWSIZE;
-    s = NULL;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINBWSIZE);
-           break;
-       case G_ATTRBORDERWIDTH:
-           break;
-       case G_ATTRTEXT:
-           s = attrp[ai].u.t;
-           label = gtk_label_new(s);
-           gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_RIGHT);
-           gtk_widget_show(label);
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color != 0 && color != 1) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           c.red = attrp[ai].u.c.r * 257;
-           c.green = attrp[ai].u.c.g * 257;
-           c.blue = attrp[ai].u.c.b * 257;
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
-           return -1;
-       case G_ATTRBUTTONCB:
-           WBU->func = (Gbuttoncb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-
-    widget->w = gtk_button_new();
-    gtk_button_set_relief(widget->w, GTK_RELIEF_NONE);
-    if (label != NULL)
-       gtk_container_add(GTK_CONTAINER(widget->w), label);
-    if (GTK_BOX(parent->w)) {
-       gtk_box_pack_start(GTK_BOX(parent->w), widget->w, FALSE, TRUE, 0);
-    } else {
-       gtk_container_add(GTK_CONTAINER(parent->w), widget->w);
-    }
-
-    gtk_signal_connect(G_OBJECT(widget->w), "clicked",
-                      GTK_SIGNAL_FUNC(bwcallback), widget->udata);
-    gtk_widget_show(widget->w);
-    return 0;
-}
-
-
-int GBsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    PIXsize_t ps;
-    int ai;
-    GdkColor c;
-    int color;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-
-           break;
-       case G_ATTRBORDERWIDTH:
-
-           break;
-       case G_ATTRTEXT:
-
-           break;
-       case G_ATTRCOLOR:
-
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
-           return -1;
-       case G_ATTRBUTTONCB:
-           WBU->func = (Gbuttoncb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    return 0;
-}
-
-
-int GBgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int width, height;
-    char *s;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-
-           break;
-       case G_ATTRBORDERWIDTH:
-
-           break;
-       case G_ATTRTEXT:
-
-           break;
-       case G_ATTRWINDOWID:
-
-           break;
-       case G_ATTRBUTTONCB:
-           attrp[ai].u.func = WBU->func;
-           break;
-       case G_ATTRUSERDATA:
-           attrp[ai].u.u = widget->udata;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GBdestroywidget(Gwidget_t * widget)
-{
-    gtk_widget_destroy(widget->w);
-    return 0;
-}
-
-
-gint bwcallback(GtkWidget * w, GdkEvent * event, gpointer * data)
-{
-    Gwidget_t *widget;
-    unsigned long l;
-
-    widget = findwidget((unsigned long) w, G_BUTTONWIDGET);
-
-    /* calls   TXTtoggle in the case of txtview */
-    if (WBU->func)
-       (*WBU->func) (widget - &Gwidgets[0], widget->udata);
-
-    return 1;
-}
diff --git a/cmd/lefty/ws/gtk/gcanvas.c b/cmd/lefty/ws/gtk/gcanvas.c
deleted file mode 100644 (file)
index 3e25397..0000000
+++ /dev/null
@@ -1,1128 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include <math.h>
-#include <string.h>
-
-#define WCU widget->u.c
-#define WINDOW widget->u.c->window
-#define GC widget->u.c->gc
-#define ISVISIBLE(r) ( \
-       (r.o.x <= WCU->clip.c.x) && (r.c.x >= WCU->clip.o.x) && \
-       (r.o.y <= WCU->clip.c.y) && (r.c.y >= WCU->clip.o.y) \
-)
-
-#define IS8BIT(font) ((font)->min_byte1 == 0 && (font)->max_byte1 == 0)
-#define max(a, b) (((a) >= (b)) ? (a) : (b))
-#define min(a, b) (((a) <= (b)) ? (a) : (b))
-
-#define SETFONT(font) { \
-       if(font != WCU->font) { \
-               WCU->font = font; \
-               gdk_gc_set_font(GC, font); \
-       } \
-}
-
-Gwidget_t *canvas;
-static int curcursori = -1;
-
-static gchar gstyles[][2] = {
-    /* G_SOLID */ {16},
-    /* G_DASHED */ {4, 4},
-    /* G_DOTTED */ {2, 2},
-    /* G_LONGDASHED */ {4, 12},
-    /* G_SHORTDASHED */ {12, 4}
-};
-
-static char grays[][4] = {
-    {0x00, 0x00, 0x00, 0x00,},
-    {0x08, 0x00, 0x00, 0x00,},
-    {0x08, 0x00, 0x02, 0x00,},
-    {0x0A, 0x00, 0x02, 0x00,},
-    {0x0A, 0x00, 0x0A, 0x00,},
-    {0x0A, 0x04, 0x0A, 0x00,},
-    {0x0A, 0x04, 0x0A, 0x01,},
-    {0x0A, 0x05, 0x0A, 0x01,},
-    {0x0A, 0x05, 0x0A, 0x05,},
-    {0x0E, 0x05, 0x0A, 0x05,},
-    {0x0E, 0x05, 0x0B, 0x05,},
-    {0x0F, 0x05, 0x0B, 0x05,},
-    {0x0F, 0x05, 0x0F, 0x05,},
-    {0x0F, 0x0D, 0x0F, 0x05,},
-    {0x0F, 0x0D, 0x0F, 0x07,},
-    {0x0F, 0x0F, 0x0F, 0x07,},
-    {0x0F, 0x0F, 0x0F, 0x0F,},
-};
-
-static void setgattr(Gwidget_t *, Ggattr_t *);
-
-static PIXrect_t rdrawtopix(Gwidget_t *, Grect_t);
-static PIXpoint_t pdrawtopix(Gwidget_t *, Gpoint_t);
-static PIXsize_t sdrawtopix(Gwidget_t *, Gsize_t);
-static Gpoint_t Gppixtodraw(Gwidget_t *, PIXpoint_t);
-static Gsize_t spixtodraw(Gwidget_t *, PIXsize_t);
-static Grect_t rpixtodraw(Gwidget_t *, PIXrect_t);
-static PIXrect_t rdrawtobpix(Gbitmap_t *, Grect_t);
-static PIXpoint_t pdrawtobpix(Gbitmap_t *, Gpoint_t);
-
-int GCcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-    PIXsize_t ps;
-    int width, height;
-    int ai, i;
-    GdkGCValues gcv;
-    int r, g, b, color;
-    GdkColor *cp;
-
-    if (!parent) {
-       Gerr(POS, G_ERRNOPARENTWIDGET);
-       return -1;
-    }
-
-    canvas = widget;
-    WCU->func = NULL;
-    WCU->needredraw = FALSE;
-    WCU->buttonsdown = 0;
-    WCU->bstate[0] = WCU->bstate[1] = WCU->bstate[2] = 0;
-    ps.x = ps.y = MINCWSIZE;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINCWSIZE);
-           break;
-       case G_ATTRBORDERWIDTH:
-           break;
-#ifdef FEATURE_GMAP
-       case G_ATTRMODE:
-           if (strcmp("gmap", attrp[ai].u.t) == 0) {
-               gmapmode = TRUE;
-           } else {
-               Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-               return -1;
-           }
-           break;
-#endif
-       case G_ATTRCURSOR:
-           break;
-       case G_ATTRCOLOR:
-           break;
-       case G_ATTRVIEWPORT:
-           break;
-       case G_ATTRWINDOW:
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
-           return -1;
-       case G_ATTREVENTCB:
-           WCU->func = (Gcanvascb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-/*     XtSetValues (widget->w, argp, argn);    */
-
-    widget->w = gtk_drawing_area_new();
-    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(parent->w),
-                                         widget->w);
-    gtk_drawing_area_size(GTK_DRAWING_AREA(widget->w), ps.x, ps.y);
-
-    gtk_widget_add_events(widget->w, GDK_ALL_EVENTS_MASK);
-    gtk_signal_connect(GTK_OBJECT(widget->w), "key_release_event",
-                      GTK_SIGNAL_FUNC(Gcwkeyaction), NULL);
-    gtk_signal_connect(GTK_OBJECT(widget->w), "key_press_event",
-                      GTK_SIGNAL_FUNC(Gcwkeyaction), NULL);
-    gtk_signal_connect(G_OBJECT(widget->w), "button_press_event",
-                      GTK_SIGNAL_FUNC(Gcwbutaction), NULL);
-    gtk_signal_connect(G_OBJECT(widget->w), "button_release_event",
-                      GTK_SIGNAL_FUNC(Gcwbutaction), NULL);
-    gtk_signal_connect(G_OBJECT(widget->w), "visibility_notify_event",
-                      GTK_SIGNAL_FUNC(cweventhandler), NULL);
-    gtk_signal_connect(G_OBJECT(widget->w), "expose_event",
-                      GTK_SIGNAL_FUNC(exposeeventhandler), NULL);
-    gtk_signal_connect(G_OBJECT(widget->w), "motion_notify_event",
-                      GTK_SIGNAL_FUNC(cweventhandler), NULL);
-
-    gtk_widget_show(widget->w);
-    gtk_widget_show(parent->w);
-
-    GC = gdk_gc_new(widget->w->window);
-    WCU->cmap = gdk_colormap_get_system();
-    WCU->colors[0].color.pixel = WCU->colors[1].color.pixel = 1000000;
-    if (WCU->colors[0].color.pixel == 1000000) {
-       gdk_gc_get_values(GC, &gcv);
-       WCU->colors[0].color = gcv.background;
-    }
-    if (WCU->colors[1].color.pixel == 1000000) {
-       gdk_gc_get_values(GC, &gcv);
-       WCU->colors[1].color = gcv.foreground;
-    }
-
-    WCU->colors[0].color.red = 65535;
-    WCU->colors[0].color.green = 65535;
-    WCU->colors[0].color.blue = 65535;
-    WCU->colors[1].color.red = 0;
-    WCU->colors[1].color.green = 0;
-    WCU->colors[1].color.blue = 0;
-
-    gdk_colormap_alloc_color(WCU->cmap, &WCU->colors[0].color, FALSE,
-                            TRUE);
-    WCU->colors[0].inuse = TRUE;
-    gdk_colormap_alloc_color(WCU->cmap, &WCU->colors[1].color, FALSE,
-                            TRUE);
-    WCU->colors[1].inuse = TRUE;
-
-    WCU->allocedcolor[0] = WCU->allocedcolor[1] = FALSE;
-    for (i = 2; i < G_MAXCOLORS; i++)
-       WCU->colors[i].inuse = FALSE;
-
-    WCU->gattr.color = 1;
-
-    WCU->gattr.width = 0;
-    WCU->gattr.mode = 0;
-    WCU->gattr.fill = 0;
-    WCU->gattr.style = 0;
-    WCU->defgattr = WCU->gattr;
-    WCU->font = NULL;
-    WCU->wrect.o.x = 0.0, WCU->wrect.o.y = 0.0;
-    WCU->wrect.c.x = 1.0, WCU->wrect.c.y = 1.0;
-    WCU->vsize.x = ps.x, WCU->vsize.y = ps.y;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRCURSOR:
-           if (strcmp(attrp[ai].u.t, "default") == 0) {
-               curcursori = -1;
-           }
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color < 0 || color > G_MAXCOLORS) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           r = attrp[ai].u.c.r * 257;
-           g = attrp[ai].u.c.g * 257;
-           b = attrp[ai].u.c.b * 257;
-           cp = &WCU->colors[color].color;
-           if (WCU->colors[color].inuse)
-               if (cp->red != r || cp->green != g || cp->blue != b)
-                   if (color > 1 || WCU->allocedcolor[color])
-                       gdk_colormap_free_colors(WCU->cmap, cp, 1);
-
-           cp->red = r, cp->green = g, cp->blue = b;
-           if (gdk_colormap_alloc_color(WCU->cmap, cp, TRUE, TRUE)) {
-               WCU->colors[color].inuse = TRUE;
-               if (color <= 1)
-                   WCU->allocedcolor[color] = TRUE;
-           }
-           cp->red = r, cp->green = g, cp->blue = b;
-           if (color == WCU->gattr.color)
-               WCU->gattr.color = -1;
-           break;
-       case G_ATTRVIEWPORT:
-           WCU->vsize.x = (int) (attrp[ai].u.s.x + 0.5);
-           WCU->vsize.y = (int) (attrp[ai].u.s.y + 0.5);
-           break;
-       case G_ATTRWINDOW:
-           WCU->wrect = attrp[ai].u.r;
-           break;
-       }
-    }
-    return 0;
-}
-
-
-int GCsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    PIXsize_t ps;
-    int ai, r, g, b, color;
-    GdkColor *cp;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINCWSIZE);
-           gtk_drawing_area_size(GTK_DRAWING_AREA(widget->w), ps.x, ps.y);
-           break;
-       case G_ATTRBORDERWIDTH:
-           break;
-       case G_ATTRCURSOR:
-           if (strcmp(attrp[ai].u.t, "watch") == 0) {
-               gdk_window_set_cursor(widget->w->window,
-                                     gdk_cursor_new(GDK_WATCH));
-           } else {
-               gdk_window_set_cursor(widget->w->window,
-                                     gdk_cursor_new(GDK_LEFT_PTR));
-           }
-           Gsync();
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color < 0 || color > G_MAXCOLORS) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           r = attrp[ai].u.c.r * 257;
-           g = attrp[ai].u.c.g * 257;
-           b = attrp[ai].u.c.b * 257;
-           cp = &WCU->colors[color].color;
-           if (WCU->colors[color].inuse)
-               if (cp->red != r || cp->green != g || cp->blue != b)
-                   if (color > 1 || WCU->allocedcolor[color])
-                       gdk_colormap_free_colors(WCU->cmap, cp, 1);
-
-           cp->red = r, cp->green = g, cp->blue = b;
-           if (gdk_colormap_alloc_color(WCU->cmap, cp, TRUE, TRUE)) {
-               WCU->colors[color].inuse = TRUE;
-               if (color <= 1)
-                   WCU->allocedcolor[color] = TRUE;
-           }
-           cp->red = r, cp->green = g, cp->blue = b;
-           if (color == WCU->gattr.color)
-               WCU->gattr.color = -1;
-           break;
-       case G_ATTRVIEWPORT:
-           WCU->vsize.x = (int) (attrp[ai].u.s.x + 0.5);
-           WCU->vsize.y = (int) (attrp[ai].u.s.y + 0.5);
-           break;
-       case G_ATTRWINDOW:
-           WCU->wrect = attrp[ai].u.r;
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
-           return -1;
-       case G_ATTREVENTCB:
-           WCU->func = (Gcanvascb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GCgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    GdkColor *cp;
-    int width, height;
-    int ai, color;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-           break;
-       case G_ATTRBORDERWIDTH:
-           attrp[ai].u.i = width;
-           break;
-       case G_ATTRCURSOR:
-           attrp[ai].u.t = (curcursori == -1) ? "default" : "watch";
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color < 0 || color > G_MAXCOLORS) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           if (WCU->colors[color].inuse) {
-               cp = &WCU->colors[color].color;
-               attrp[ai].u.c.r = cp->red / 257.0;
-               attrp[ai].u.c.g = cp->green / 257.0;
-               attrp[ai].u.c.b = cp->blue / 257.0;
-           } else {
-               attrp[ai].u.c.r = -1;
-               attrp[ai].u.c.g = -1;
-               attrp[ai].u.c.b = -1;
-           }
-           break;
-       case G_ATTRVIEWPORT:
-           attrp[ai].u.s = WCU->vsize;
-           break;
-       case G_ATTRWINDOW:
-           attrp[ai].u.r = WCU->wrect;
-           break;
-       case G_ATTRWINDOWID:
-           sprintf(&Gbufp[0], "0x%lx", (unsigned long) widget->w);
-           break;
-       case G_ATTREVENTCB:
-           attrp[ai].u.func = WCU->func;
-           break;
-       case G_ATTRUSERDATA:
-           attrp[ai].u.u = widget->udata;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GCdestroywidget(Gwidget_t * widget)
-{
-    gtk_widget_destroy(widget->w);
-    return 0;
-}
-
-
-int GCsetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
-{
-    setgattr(widget, ap);
-    WCU->defgattr = WCU->gattr;
-    return 0;
-}
-
-
-int GCarrow(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
-{
-
-    PIXpoint_t pp1, pp2, pa, pb, pd;
-    Grect_t gr;
-    double tangent, l;
-
-    if (gp1.x < gp2.x)
-       gr.o.x = gp1.x, gr.c.x = gp2.x;
-    else
-       gr.o.x = gp2.x, gr.c.x = gp1.x;
-    if (gp1.y < gp2.y)
-       gr.o.y = gp1.y, gr.c.y = gp2.y;
-    else
-       gr.o.y = gp2.y, gr.c.y = gp1.y;
-
-    pp1 = pdrawtopix(widget, gp1), pp2 = pdrawtopix(widget, gp2);
-    pd.x = pp1.x - pp2.x, pd.y = pp1.y - pp2.y;
-    if (pd.x == 0 && pd.y == 0)
-       return 0;
-    tangent = atan2((double) pd.y, (double) pd.x);
-    if ((l = hypot(pd.x, pd.y)) > 30)
-       l = 30;
-    pa.x = l * cos(tangent + M_PI / 7) + pp2.x;
-    pa.y = l * sin(tangent + M_PI / 7) + pp2.y;
-    pb.x = l * cos(tangent - M_PI / 7) + pp2.x;
-    pb.y = l * sin(tangent - M_PI / 7) + pp2.y;
-    setgattr(widget, ap);
-
-    gdk_draw_line(widget->w->window, GC, pp1.x, pp1.y, pp2.x, pp2.y);
-    gdk_draw_line(widget->w->window, GC, pa.x, pa.y, pp2.x, pp2.y);
-    gdk_draw_line(widget->w->window, GC, pb.x, pb.y, pp2.x, pp2.y);
-    return 0;
-}
-
-
-int GCline(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
-{
-    PIXpoint_t pp1, pp2;
-    Grect_t gr;
-
-    if (gp1.x < gp2.x)
-       gr.o.x = gp1.x, gr.c.x = gp2.x;
-    else
-       gr.o.x = gp2.x, gr.c.x = gp1.x;
-    if (gp1.y < gp2.y)
-       gr.o.y = gp1.y, gr.c.y = gp2.y;
-    else
-       gr.o.y = gp2.y, gr.c.y = gp1.y;
-
-    pp1 = pdrawtopix(widget, gp1), pp2 = pdrawtopix(widget, gp2);
-    setgattr(widget, ap);
-    gdk_draw_line(widget->w->window, GC, pp1.x, pp1.y, pp2.x, pp2.y);
-    return 0;
-}
-
-
-int GCbox(Gwidget_t * widget, Grect_t gr, Ggattr_t * ap)
-{
-    PIXrect_t pr;
-    Gxy_t p;
-
-    if (gr.o.x > gr.c.x)
-       p.x = gr.o.x, gr.o.x = gr.c.x, gr.c.x = p.x;
-    if (gr.o.y > gr.c.y)
-       p.y = gr.o.y, gr.o.y = gr.c.y, gr.c.y = p.y;
-
-    pr = rdrawtopix(widget, gr);
-    setgattr(widget, ap);
-    if (WCU->gattr.fill)
-       gdk_draw_rectangle(widget->w->window, GC, TRUE, pr.o.x, pr.o.y,
-                          pr.c.x - pr.o.x, pr.c.y - pr.o.y);
-    else {
-       gdk_draw_rectangle(widget->w->window, GC, FALSE, pr.o.x, pr.o.y,
-                          pr.c.x - pr.o.x, pr.c.y - pr.o.y);
-    }
-
-    return 0;
-}
-
-
-int GCpolygon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
-{
-
-    Grect_t gr;
-    int n, i;
-
-    if (gpn == 0)
-       return 0;
-
-    gr.o = gpp[0], gr.c = gpp[0];
-    for (i = 1; i < gpn; i++) {
-       gr.o.x = min(gr.o.x, gpp[i].x);
-       gr.o.y = min(gr.o.y, gpp[i].y);
-       gr.c.x = min(gr.c.x, gpp[i].x);
-       gr.c.y = min(gr.c.y, gpp[i].y);
-    }
-    if (gpn + 1 > Gppn) {
-       n = (((gpn + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-       Gppp = Marraygrow(Gppp, (long) n * PPSIZE);
-       Gppn = n;
-    }
-    for (i = 0; i < gpn; i++)
-       Gppp[i] = pdrawtopix(widget, gpp[i]);
-
-    setgattr(widget, ap);
-    if (WCU->gattr.fill) {
-       if (Gppp[gpn - 1].x != Gppp[0].x || Gppp[gpn - 1].y != Gppp[0].y)
-           Gppp[gpn] = Gppp[0], gpn++;
-
-       gdk_draw_polygon(widget->w, GC, TRUE, Gppp, gpn);
-    } else
-       gdk_draw_polygon(widget->w, GC, FALSE, Gppp, gpn);
-
-    return 0;
-}
-
-
-static void bezier(PIXpoint_t p0, PIXpoint_t p1, PIXpoint_t p2,
-                  PIXpoint_t p3)
-{
-
-    Gpoint_t gp0, gp1, gp2;
-    Gsize_t s;
-    PIXpoint_t p;
-    double t;
-    int n, i, steps;
-
-    if ((s.x = p3.x - p0.x) < 0)
-       s.x = -s.x;
-    if ((s.y = p3.y - p0.y) < 0)
-       s.y = -s.y;
-    if (s.x > s.y)
-       steps = s.x / 5 + 1;
-    else
-       steps = s.y / 5 + 1;
-    for (i = 0; i <= steps; i++) {
-       t = i / (double) steps;
-       gp0.x = p0.x + t * (p1.x - p0.x);
-       gp0.y = p0.y + t * (p1.y - p0.y);
-       gp1.x = p1.x + t * (p2.x - p1.x);
-       gp1.y = p1.y + t * (p2.y - p1.y);
-       gp2.x = p2.x + t * (p3.x - p2.x);
-       gp2.y = p2.y + t * (p3.y - p2.y);
-       gp0.x = gp0.x + t * (gp1.x - gp0.x);
-       gp0.y = gp0.y + t * (gp1.y - gp0.y);
-       gp1.x = gp1.x + t * (gp2.x - gp1.x);
-       gp1.y = gp1.y + t * (gp2.y - gp1.y);
-       p.x = gp0.x + t * (gp1.x - gp0.x) + 0.5;
-       p.y = gp0.y + t * (gp1.y - gp0.y) + 0.5;
-       if (Gppi >= Gppn) {
-           n = (((Gppi + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-           Gppp = Marraygrow(Gppp, (long) n * PPSIZE);
-           Gppn = n;
-       }
-       Gppp[Gppi++] = p;
-    }
-}
-
-
-int GCsplinegon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
-{
-
-    PIXpoint_t p0, p1, p2, p3;
-    Grect_t gr;
-    int n, i;
-
-    if (gpn == 0)
-       return 0;
-
-    gr.o = gpp[0], gr.c = gpp[0];
-    for (i = 1; i < gpn; i++) {
-       gr.o.x = min(gr.o.x, gpp[i].x);
-       gr.o.y = min(gr.o.y, gpp[i].y);
-       gr.c.x = max(gr.c.x, gpp[i].x);
-       gr.c.y = max(gr.c.y, gpp[i].y);
-    }
-
-    Gppi = 1;
-    if (Gppi >= Gppn) {
-       n = (((Gppi + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-       Gppp = Marraygrow(Gppp, (long) n * PPSIZE);
-       Gppn = n;
-    }
-    Gppp[0] = p3 = pdrawtopix(widget, gpp[0]);
-    for (i = 1; i < gpn; i += 3) {
-       p0 = p3;
-       p1 = pdrawtopix(widget, gpp[i]);
-       p2 = pdrawtopix(widget, gpp[i + 1]);
-       p3 = pdrawtopix(widget, gpp[i + 2]);
-       bezier(p0, p1, p2, p3);
-    }
-    setgattr(widget, ap);
-    gdk_draw_lines(widget->w->window, GC, Gppp, Gppi);
-    return 0;
-}
-
-
-int GCarc(Gwidget_t * widget, Gpoint_t gc, Gsize_t gs, double ang1,
-         double ang2, Ggattr_t * ap)
-{
-
-    PIXpoint_t pc;
-    PIXsize_t ps;
-    Grect_t gr;
-
-    gr.o.x = gc.x - gs.x, gr.o.y = gc.y - gs.y;
-    gr.c.x = gc.x + gs.x, gr.c.y = gc.y + gs.y;
-
-    pc = pdrawtopix(widget, gc), ps = sdrawtopix(widget, gs);
-    setgattr(widget, ap);
-
-    if (WCU->gattr.fill) {
-       gdk_draw_arc(widget->w->window, GC, TRUE, pc.x - ps.x, pc.y - ps.y,
-                    ps.x * 2, ps.y * 2, (int) (ang1 * 64), (ang2 * 64));
-    } else {
-       gdk_draw_arc(widget->w->window, GC, FALSE, pc.x - ps.x,
-                    pc.y - ps.y, ps.x * 2, ps.y * 2, (int) (ang1 * 64),
-                    (ang2 * 64));
-    }
-    return 0;
-}
-
-
-static GdkFont *findfont(char *name, int size)
-{
-    GdkFont *font;
-    int fi, n, i;
-
-    if (strcmp(name, "") == 0)
-       return Gfontp[0].font;
-
-    sprintf(&Gbufp[0], name, size);
-    for (fi = 0; fi < Gfontn; fi++)
-       if (strcmp(&Gbufp[0], Gfontp[fi].name) == 0)
-           return Gfontp[fi].font;
-
-    if (!(font = gdk_font_load(&Gbufp[0]))) {
-       n = strlen(&Gbufp[0]) + 1;
-       for (i = 1; i < size; i++) {
-           sprintf(&Gbufp[n], name, size - i);
-           if ((font = gdk_font_load(&Gbufp[n])))
-               break;
-           sprintf(&Gbufp[n], name, size + i);
-           if ((font = gdk_font_load(&Gbufp[n])))
-               break;
-       }
-    }
-    if (!font)
-       font = Gfontp[0].font;
-
-    Gfontp = Marraygrow(Gfontp, (long) (Gfontn + 1) * FONTSIZE);
-    Gfontp[Gfontn].name = strdup(&Gbufp[0]);
-    Gfontp[Gfontn].font = font;
-    Gfontn++;
-    return font;
-}
-
-
-int GCtext(Gwidget_t * widget, Gtextline_t * tlp, int n, Gpoint_t go,
-          char *fn, double fs, char *justs, Ggattr_t * ap)
-{
-
-    Gsize_t gs;
-    PIXpoint_t po;
-    PIXsize_t ps;
-    PIXrect_t pr;
-    Grect_t gr;
-    GdkFont *font;
-    int dir, asc, des, x = 0, y, w, h, i;
-    int lbearing, rbearing, width;
-
-    po = pdrawtopix(widget, go);
-    gs.x = 0, gs.y = fs;
-    ps = sdrawtopix(widget, gs);
-    if (!(font = findfont(fn, ps.y))) {
-       printf("NO FONT\n");
-       gdk_draw_rectangle(widget->w, GC, FALSE, po.x, po.y, 1, 1);
-       return 0;
-    }
-
-    setgattr(widget, ap);
-    SETFONT(font);
-
-    for (w = h = 0, i = 0; i < n; i++) {
-       gdk_text_extents(font, tlp[i].p, tlp[i].n, &lbearing, &rbearing,
-                        &width, &asc, &des);
-
-       tlp[i].w = width, tlp[i].h = asc + des;
-       w = max(w, width), h += asc + des;
-
-    }
-
-    switch (justs[0]) {
-    case 'l':
-       po.x += w / 2;
-       break;
-    case 'r':
-       po.x -= w / 2;
-       break;
-    }
-    switch (justs[1]) {
-    case 'd':
-       po.y -= h;
-       break;
-    case 'c':
-       po.y -= h / 2;
-       break;
-    }
-    pr.o.x = po.x - w / 2, pr.o.y = po.y;
-    pr.c.x = po.x + w / 2, pr.c.y = po.y + h;
-    gr = rpixtodraw(widget, pr);
-
-    for (i = 0; i < n; i++) {
-       switch (tlp[i].j) {
-       case 'l':
-           x = po.x - w / 2;
-           break;
-       case 'n':
-           x = po.x - tlp[i].w / 2;
-           break;
-       case 'r':
-           x = po.x - (tlp[i].w - w / 2);
-           break;
-       }
-       y = po.y + (i + 1) * tlp[i].h - des;
-
-       gdk_draw_text(widget->w->window, font, GC, x, y, tlp[i].p,
-                     tlp[i].n);
-    }
-
-    return 0;
-}
-
-
-int GCgettextsize(Gwidget_t * widget, Gtextline_t * tlp, int n, char *fn,
-                 double fs, Gsize_t * gsp)
-{
-
-    Gsize_t gs;
-    PIXsize_t ps;
-    GdkFont *font;
-    int i, dir, asc, des, rbearing, lbearing, width;
-
-    gs.x = 0, gs.y = fs;
-    ps = sdrawtopix(widget, gs);
-    if (!(font = findfont(fn, ps.y))) {
-       gsp->x = 1, gsp->y = 1;
-       return 0;
-    }
-    SETFONT(font);
-    for (ps.x = ps.y = 0, i = 0; i < n; i++) {
-       gdk_text_extents(font, tlp[i].p, tlp[i].n, &lbearing, &rbearing,
-                        &width, &asc, &des);
-       ps.x = max(ps.x, width), ps.y += asc + des;
-    }
-
-    *gsp = spixtodraw(widget, ps);
-    return 0;
-}
-
-
-int GCcreatebitmap(Gwidget_t * widget, Gbitmap_t * bitmap, Gsize_t s)
-{
-
-    return 0;
-}
-
-
-int GCdestroybitmap(Gbitmap_t * bitmap)
-{
-
-    return 0;
-}
-
-
-int GCreadbitmap(Gwidget_t * widget, Gbitmap_t * bitmap, FILE * fp)
-{
-
-    return 0;
-}
-
-
-int GCwritebitmap(Gbitmap_t * bitmap, FILE * fp)
-{
-
-    return 0;
-}
-
-
-int GCbitblt(Gwidget_t * widget, Gpoint_t gp, Grect_t gr,
-            Gbitmap_t * bitmap, char *mode, Ggattr_t * ap)
-{
-}
-
-
-int GCgetmousecoords(Gwidget_t * widget, Gpoint_t * gpp, int *count)
-{
-    PIXpoint_t pp;
-    int state;
-
-    gdk_window_get_pointer(widget->w->window, &pp.x, &pp.y, &state);
-    *gpp = Gppixtodraw(widget, pp);
-    *count = 1;
-
-    return 0;
-}
-
-
-int GCcanvasclear(Gwidget_t * widget)
-{
-    int gotit;
-    GdkDrawable *drawable;
-    GtkWidget *drawing_area = widget->w;
-    drawable = drawing_area->window;
-
-    gdk_window_clear(widget->w->window);
-    gdk_draw_rectangle(drawable, drawing_area->style->white_gc, TRUE, 0, 0,
-                      drawing_area->allocation.width,
-                      drawing_area->allocation.height);
-    WCU->needredraw = FALSE;
-    gotit = FALSE;
-
-    return 0;
-}
-
-
-int GCgetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
-{
-
-    if ((ap->flags & G_GATTRCOLOR))
-       ap->color = WCU->gattr.color;
-    if ((ap->flags & G_GATTRWIDTH))
-       ap->width = WCU->gattr.width;
-    if ((ap->flags & G_GATTRMODE))
-       ap->mode = WCU->gattr.mode;
-    if ((ap->flags & G_GATTRFILL))
-       ap->fill = WCU->gattr.fill;
-    if ((ap->flags & G_GATTRSTYLE))
-       ap->style = WCU->gattr.style;
-    return 0;
-}
-
-
-gint Gcwbutaction(GtkWidget * w, GdkEvent * event, gpointer data)
-{
-    Gwidget_t *widget;
-    Gevent_t gev;
-    int xtype, bn, wi;
-    PIXpoint_t pp;
-
-    widget = findwidget((unsigned long) w, G_CANVASWIDGET);
-    switch ((xtype = event->type)) {
-    case GDK_BUTTON_PRESS:
-    case GDK_2BUTTON_PRESS:
-    case GDK_3BUTTON_PRESS:
-    case GDK_BUTTON_RELEASE:
-
-       gev.type = G_MOUSE;
-       gev.code = (xtype == GDK_BUTTON_PRESS) ? G_DOWN : G_UP;
-
-       gev.data = event->button.button - 1;
-       pp.x = event->button.x, pp.y = event->button.y;
-       gev.p = Gppixtodraw(widget, pp);
-       bn = WCU->bstate[gev.data];
-       WCU->bstate[gev.data] = (xtype == GDK_BUTTON_PRESS) ? 1 : 0;
-       bn = WCU->bstate[gev.data] - bn;
-       WCU->buttonsdown += bn;
-       Gbuttonsdown += bn;
-       break;
-    default:
-       break;
-    }
-
-    wi = gev.wi = widget - &Gwidgets[0];
-    Gpopdownflag = FALSE;
-    if (WCU->func) {
-       (*WCU->func) (&gev);
-    }
-
-    if (Gpopdownflag) {
-       Gpopdownflag = FALSE;
-       if (gev.code == G_DOWN) {
-
-           gev.code = G_UP;
-           widget = &Gwidgets[wi];
-           WCU->bstate[gev.data] = 0;
-           WCU->buttonsdown--;
-           Gbuttonsdown--;
-           if (widget->inuse && WCU->func)
-               (*WCU->func) (&gev);
-       }
-    }
-    return TRUE;
-}
-
-
-void Gcwkeyaction(GtkWidget * w, GdkEventKey * event, gpointer data)
-{
-    Gwidget_t *widget;
-    Gevent_t gev;
-    int xtype, bn, wi, state;
-    PIXpoint_t pp;
-    unsigned int mask;
-    char c;
-
-    widget = findwidget((unsigned long) canvas->w, G_CANVASWIDGET);
-    switch ((xtype = event->type)) {
-    case GDK_KEY_PRESS:
-    case GDK_KEY_RELEASE:
-       gdk_window_get_pointer(event->window, &pp.x, &pp.y, &state);
-       gev.type = G_KEYBD;
-       gev.code = (xtype == GDK_KEY_PRESS) ? G_DOWN : G_UP;
-       gev.data = event->keyval;
-       gev.p = Gppixtodraw(widget, pp);
-       break;
-    default:
-       return;
-    }
-    gev.wi = widget - &Gwidgets[0];
-    Gpopdownflag = FALSE;
-    if (WCU->func)
-       (*WCU->func) (&gev);
-    if (Gpopdownflag)
-       Gpopdownflag = FALSE;
-
-}
-
-
-gint exposeeventhandler(GtkWidget * w, GdkEvent * event, gpointer data)
-{
-    Gwidget_t *widget;
-
-    widget = findwidget((unsigned long) w, G_CANVASWIDGET);
-    gdk_draw_rectangle(widget->w->window, widget->w->style->white_gc, TRUE,
-                      0, 0, widget->w->allocation.width,
-                      widget->w->allocation.height);
-}
-
-
-gint cweventhandler(GtkWidget * w, GdkEvent * event, gpointer data)
-{
-    Gwidget_t *widget;
-
-    widget = findwidget((unsigned long) w, G_CANVASWIDGET);
-    Gneedredraw = WCU->needredraw = TRUE;
-
-    gtk_signal_connect(G_OBJECT(w), "visibility_notify_event",
-                      GTK_SIGNAL_FUNC(cweventhandler), NULL);
-    gtk_signal_connect(G_OBJECT(w), "motion_notify_event",
-                      GTK_SIGNAL_FUNC(cweventhandler), NULL);
-}
-
-
-static void setgattr(Gwidget_t * widget, Ggattr_t * ap)
-{
-    GdkGCValues gcv;
-    GdkColor c;
-    int color, width, mode, style, pati;
-    double intens;
-
-    if (!(ap->flags & G_GATTRCOLOR))
-       ap->color = WCU->defgattr.color;
-    if (!(ap->flags & G_GATTRWIDTH))
-       ap->width = WCU->defgattr.width;
-    if (!(ap->flags & G_GATTRMODE))
-       ap->mode = WCU->defgattr.mode;
-    if (!(ap->flags & G_GATTRFILL))
-       ap->fill = WCU->defgattr.fill;
-    if (!(ap->flags & G_GATTRSTYLE))
-       ap->style = WCU->defgattr.style;
-    color = ap->color;
-
-    if (color >= G_MAXCOLORS || !(WCU->colors[color].inuse))
-       color = 1;
-
-    if (color != WCU->gattr.color) {
-
-       WCU->gattr.color = color;
-       gdk_gc_set_foreground(GC, &WCU->colors[WCU->gattr.color].color);
-    }
-    mode = ap->mode;
-    if (mode != WCU->gattr.mode) {
-       WCU->gattr.mode = mode;
-       gdk_gc_set_foreground(GC, &WCU->colors[WCU->gattr.color].color);
-    }
-    width = ap->width;
-    if (width != WCU->gattr.width) {
-       gdk_gc_set_line_attributes(GC, width, GDK_LINE_SOLID,
-                                  GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
-    }
-
-    WCU->gattr.fill = ap->fill;
-    style = ap->style;
-    if (style != WCU->gattr.style) {
-       WCU->gattr.style = style;
-       if (style == G_SOLID) {
-           gdk_gc_set_line_attributes(GC, width, GDK_LINE_SOLID,
-                                      GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
-       } else {
-           gdk_gc_set_dashes(GC, 0, gstyles[style], 2);
-           gdk_gc_set_line_attributes(GC, width, GDK_LINE_ON_OFF_DASH,
-                                      GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
-       }
-    }
-}
-
-
-static PIXrect_t rdrawtopix(Gwidget_t * widget, Grect_t gr)
-{
-    PIXrect_t pr;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    pr.o.x = tvx * (gr.o.x - WCU->wrect.o.x) / twx + 0.5;
-    pr.o.y = tvy * (1.0 - (gr.c.y - WCU->wrect.o.y) / twy) + 0.5;
-    pr.c.x = tvx * (gr.c.x - WCU->wrect.o.x) / twx + 0.5;
-    pr.c.y = tvy * (1.0 - (gr.o.y - WCU->wrect.o.y) / twy) + 0.5;
-    return pr;
-}
-
-
-static PIXpoint_t pdrawtopix(Gwidget_t * widget, Gpoint_t gp)
-{
-    PIXpoint_t pp;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-
-    pp.x = tvx * (gp.x - WCU->wrect.o.x) / twx + 0.5;
-    pp.y = tvy * (1.0 - (gp.y - WCU->wrect.o.y) / twy) + 0.5;
-    return pp;
-}
-
-
-static PIXsize_t sdrawtopix(Gwidget_t * widget, Gsize_t gs)
-{
-    PIXsize_t ps;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    ps.x = tvx * (gs.x - 1) / twx + 1.5;
-    ps.y = tvy * (gs.y - 1) / twy + 1.5;
-
-    return ps;
-}
-
-
-static Gpoint_t Gppixtodraw(Gwidget_t * widget, PIXpoint_t pp)
-{
-    Gpoint_t gp;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-
-    gp.x = (pp.x / tvx) * twx + WCU->wrect.o.x;
-    gp.y = (1.0 - pp.y / tvy) * twy + WCU->wrect.o.y;
-    return gp;
-}
-
-
-static Gsize_t spixtodraw(Gwidget_t * widget, PIXsize_t ps)
-{
-    Gsize_t gs;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    gs.x = ((ps.x - 1) / tvx) * twx + 1;
-    gs.y = ((ps.y - 1) / tvy) * twy + 1;
-    return gs;
-}
-
-
-static Grect_t rpixtodraw(Gwidget_t * widget, PIXrect_t pr)
-{
-    Grect_t gr;
-    double tvx, tvy, twx, twy, n;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-
-    gr.o.x = (pr.o.x / tvx) * twx + WCU->wrect.o.x;
-    gr.o.y = (1.0 - pr.c.y / tvy) * twy + WCU->wrect.o.y;
-    gr.c.x = (pr.c.x / tvx) * twx + WCU->wrect.o.x;
-    gr.c.y = (1.0 - pr.o.y / tvy) * twy + WCU->wrect.o.y;
-
-    if (gr.o.x > gr.c.x)
-       n = gr.o.x, gr.o.x = gr.c.x, gr.c.x = n;
-    if (gr.o.y > gr.c.y)
-       n = gr.o.y, gr.o.y = gr.c.y, gr.c.y = n;
-    return gr;
-}
-
-
-static PIXrect_t rdrawtobpix(Gbitmap_t * bitmap, Grect_t gr)
-{
-    PIXrect_t pr;
-    double tvy;
-
-    tvy = (bitmap->size.y - 1) * bitmap->scale.y;
-    pr.o.x = gr.o.x + 0.5;
-    pr.o.y = tvy - gr.c.y + 0.5;
-    pr.c.x = gr.c.x + 0.5;
-    pr.c.y = tvy - gr.o.y + 0.5;
-    return pr;
-}
-
-
-static PIXpoint_t pdrawtobpix(Gbitmap_t * bitmap, Gpoint_t gp)
-{
-    PIXpoint_t pp;
-    double tvy;
-
-    tvy = (bitmap->size.y - 1) * bitmap->scale.y;
-    pp.x = gp.x + 0.5;
-    pp.y = tvy - gp.y + 0.5;
-    return pp;
-}
diff --git a/cmd/lefty/ws/gtk/gcommon.c b/cmd/lefty/ws/gtk/gcommon.c
deleted file mode 100644 (file)
index 6117f19..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Krishnam Raju Pericherla */
-
-#include <gtk/gtk.h>
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-int Gxfd;
-GtkWidget *Groot;
-GdkDisplay *Gdisplay;
-int Gpopdownflag;
-int Gscreenn;
-int Gdepth;
-Glazyq_t Glazyq;
-
-PIXpoint_t *Gppp;
-int Gppn, Gppi;
-
-char *Gbufp = NULL;
-int Gbufn = 0, Gbufi = 0;
-
-Gfont_t *Gfontp;
-GdkFont *deffont;
-int Gfontn;
-
-int argn;
-
-int Ginitgraphics(void)
-{
-
-    gtk_init(0, NULL);
-
-    Gpopdownflag = FALSE;
-    Gdisplay = gdk_display_get_default();
-    deffont = gdk_font_load("fixed");
-
-    Gpopdownflag = FALSE;
-    Glazyq.flag = 0;
-    Gbufp = Marrayalloc((long) BUFINCR * BUFSIZE);
-    Gbufn = BUFINCR;
-    Gppp = Marrayalloc((long) PPINCR * PPSIZE);
-    Gppn = BUFINCR;
-    Gfontp = Marrayalloc((long) FONTSIZE);
-    Gfontn = 1;
-    Gfontp[0].name = strdup("default");
-    if (!Gdefaultfont)
-       Gfontp[0].font = deffont;
-    else if (Gdefaultfont[0] != '\000')
-       Gfontp[0].font = gdk_font_load(Gdefaultfont);
-    else
-       Gfontp[0].font = NULL;
-    return 0;
-}
-
-int Gtermgraphics(void)
-{
-    int fi;
-
-    for (fi = 0; fi < Gfontn; fi++)
-       free(Gfontp[fi].name);
-
-    Marrayfree(Gfontp), Gfontp = NULL, Gfontn = 0;
-    Marrayfree(Gppp), Gppp = NULL, Gppn = 0;
-    Marrayfree(Gbufp), Gbufp = NULL, Gbufn = 0;
-
-    return 0;
-}
-
-void Gflushlazyq(void)
-{
-
-}
-
-void Glazymanage(GtkWidget w)
-{
-
-}
-
-int Gsync(void)
-{
-    if (Glazyq.flag)
-       Gflushlazyq();
-    gdk_display_sync(Gdisplay);
-    return 0;
-}
-
-int Gresetbstate(int wi)
-{
-    Gcw_t *cw;
-    int bn;
-
-    cw = Gwidgets[wi].u.c;
-    bn = cw->bstate[0] + cw->bstate[1] + cw->bstate[2];
-    cw->bstate[0] = cw->bstate[1] = cw->bstate[2] = 0;
-    cw->buttonsdown -= bn;
-    Gbuttonsdown -= bn;
-    return 0;
-}
-
-int Gprocessevents(int waitflag, Geventmode_t mode)
-{
-    int rtn;
-
-    if (Glazyq.flag)
-       Gflushlazyq();
-    rtn = 0;
-    switch (waitflag) {
-    case TRUE:
-       gtk_main_iteration();
-       if (mode == G_ONEEVENT)
-           return 1;
-       rtn = 1;
-    case FALSE:
-       while (gtk_events_pending()) {
-           gtk_main_iteration();
-           if (mode == G_ONEEVENT)
-               return 1;
-           rtn = 1;
-       }
-       break;
-    }
-    return rtn;
-}
diff --git a/cmd/lefty/ws/gtk/gcommon.h b/cmd/lefty/ws/gtk/gcommon.h
deleted file mode 100644 (file)
index ceb03f7..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#define GETSIZE(sin, sout, smin) \
-       sout.x = (sin.x > smin) ? sin.x + 0.5 : smin, \
-       sout.y = (sin.y > smin) ? sin.y + 0.5 : smin
-#define GETORIGIN(oin, oout) \
-       oout.x = oin.x + 0.5, oout.y = oin.y + 0.5
-
-typedef GdkPoint PIXxy_t;
-typedef PIXxy_t PIXpoint_t;
-typedef PIXxy_t PIXsize_t;
-typedef struct PIXrect_t {
-    PIXxy_t o, c;
-} PIXrect_t;
-
-extern GtkWidget *Groot;
-extern GdkDisplay *Gdisplay;
-extern int Gpopdownflag;
-
-
-extern int argn;
-#define MAXARGS 50
-#define RESETARGS (argn = 0)
-
-typedef enum {
-    LAZYREALIZE = 1, LAZYRHINTS = 2, LAZYMANAGE = 4
-} Glazyflag_t;
-#define LAZYQNUM 100
-typedef struct Glazyq_t {
-    Glazyflag_t flag;
-    GtkWidget rw;
-
-    GtkWidget mws[LAZYQNUM];
-    int mwn;
-} Glazyq_t;
-extern Glazyq_t Glazyq;
-
-typedef struct Gfont_t {
-    char *name;
-    GdkFont *font;
-} Gfont_t;
-extern Gfont_t *Gfontp;
-extern int Gfontn;
-#define FONTSIZE sizeof (Gfont_t)
-
-extern char *Gbufp;
-extern int Gbufn, Gbufi;
-#define BUFINCR 1024
-#define BUFSIZE sizeof (char)
-
-extern PIXpoint_t *Gppp;
-extern int Gppn, Gppi;
-#define PPINCR 100
-#define PPSIZE sizeof (PIXpoint_t)
-
-#define GETSIZE(sin, sout, smin) \
-       sout.x = (sin.x > smin) ? sin.x + 0.5 : smin, \
-       sout.y = (sin.y > smin) ? sin.y + 0.5 : smin
-#define GETORIGIN(oin, oout) \
-       oout.x = oin.x + 0.5, oout.y = oin.y + 0.5
-
-
-int Ginitgraphics(void);
-int Gtermgraphics(void);
-void Gflushlazyq(void);
-/*void Glazyrealize (GtkWidget, int, XSizeHints *); */
-void Glazymanage(GtkWidget);
-int Gsync(void);
-
-int GQcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GQsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GQgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GQdestroywidget(Gwidget_t *);
-int GQqueryask(Gwidget_t *, char *, char *, char *, int);
-
-int GBcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GBsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GBgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GBdestroywidget(Gwidget_t *);
-
-int GAcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GAsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GAgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GAdestroywidget(Gwidget_t *);
-
-int GScreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GSsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GSgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GSdestroywidget(Gwidget_t *);
-
-int GLcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GLsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GLgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GLdestroywidget(Gwidget_t *);
-
-int GTcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GTsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GTgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GTdestroywidget(Gwidget_t *);
-
-int GVcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GVsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GVgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GVdestroywidget(Gwidget_t *);
-
-int GMcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GMsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GMgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GMdestroywidget(Gwidget_t *);
-int GMmenuaddentries(Gwidget_t *, int, char **);
-int GMmenudisplay(Gwidget_t *, Gwidget_t *);
-
-int GCcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GCsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GCgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GCdestroywidget(Gwidget_t *);
-int GCcanvasclear(Gwidget_t *);
-int GCsetgfxattr(Gwidget_t *, Ggattr_t *);
-int GCgetgfxattr(Gwidget_t *, Ggattr_t *);
-int GCarrow(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GCline(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GCbox(Gwidget_t *, Grect_t, Ggattr_t *);
-int GCpolygon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GCsplinegon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GCarc(Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
-int GCtext(Gwidget_t *, Gtextline_t *, int, Gpoint_t,
-          char *, double, char *, Ggattr_t *);
-int GCgettextsize(Gwidget_t *, Gtextline_t *, int, char *, double,
-                 Gsize_t *);
-int GCcreatebitmap(Gwidget_t *, Gbitmap_t *, Gsize_t);
-int GCdestroybitmap(Gbitmap_t *);
-int GCreadbitmap(Gwidget_t *, Gbitmap_t *, FILE *);
-int GCwritebitmap(Gbitmap_t *, FILE *);
-int GCbitblt(Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *,
-            Ggattr_t *);
-int GCgetmousecoords(Gwidget_t *, Gpoint_t *, int *);
-
-int GPcreatewidget(Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GPsetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GPgetwidgetattr(Gwidget_t *, int, Gwattr_t *);
-int GPdestroywidget(Gwidget_t *);
-int GPcanvasclear(Gwidget_t *);
-int GPsetgfxattr(Gwidget_t *, Ggattr_t *);
-int GPgetgfxattr(Gwidget_t *, Ggattr_t *);
-int GParrow(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GPline(Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GPbox(Gwidget_t *, Grect_t, Ggattr_t *);
-int GPpolygon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GPsplinegon(Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GParc(Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
-int GPtext(Gwidget_t *, Gtextline_t *, int, Gpoint_t,
-          char *, double, char *, Ggattr_t *);
-int GPcreatebitmap(Gwidget_t *, Gbitmap_t *, Gsize_t);
-int GPdestroybitmap(Gbitmap_t *);
-int GPreadbitmap(Gwidget_t *, Gbitmap_t *, FILE *);
-int GPwritebitmap(Gbitmap_t *, FILE *);
-int GPbitblt(Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *,
-            Ggattr_t *);
-
-
-gint Gcwbutaction(GtkWidget *, GdkEvent * event, gpointer);
-void Gcwkeyaction(GtkWidget *, GdkEventKey * event, gpointer);
-gint keyevent(GtkWidget *, GdkEventKey * event, gpointer);
-gint Gmotionaction(GtkWidget *, GdkEvent * event, gpointer);
-gint Gexposeaction(GtkWidget *, GdkEvent * event, gpointer);
-gint Gconfigureaction(GtkWidget *, GdkEvent * event, gpointer);
-gint cweventhandler(GtkWidget *, GdkEvent * event, gpointer);
-gint exposeeventhandler(GtkWidget *, GdkEvent * event, gpointer);
diff --git a/cmd/lefty/ws/gtk/glabel.c b/cmd/lefty/ws/gtk/glabel.c
deleted file mode 100644 (file)
index f6c8759..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WLU widget->u.l
-
-int GLcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-    PIXsize_t ps;
-    int ai;
-    GdkColor c;
-    int color;
-
-    if (!parent) {
-       Gerr(POS, G_ERRNOPARENTWIDGET);
-       return -1;
-    }
-
-    WLU->func = NULL;
-    ps.x = ps.y = MINLWSIZE;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINLWSIZE);
-           break;
-       case G_ATTRBORDERWIDTH:
-           break;
-       case G_ATTRTEXT:
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color != 0 && color != 1) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
-           return -1;
-       case G_ATTREVENTCB:
-           WLU->func = (Glabelcb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    widget->w = gtk_label_new(NULL);
-
-    return 0;
-}
-
-
-int GLsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    PIXsize_t ps;
-    int ai;
-    GdkColor c;
-    int color;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINLWSIZE);
-           break;
-       case G_ATTRBORDERWIDTH:
-
-           break;
-       case G_ATTRTEXT:
-
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color != 0 && color != 1) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
-           return -1;
-       case G_ATTREVENTCB:
-           WLU->func = (Glabelcb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    return 0;
-}
-
-
-int GLgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int width, height;
-    char *s;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-
-           break;
-       case G_ATTRBORDERWIDTH:
-
-           break;
-       case G_ATTRTEXT:
-
-           break;
-       case G_ATTRWINDOWID:
-
-           break;
-       case G_ATTREVENTCB:
-           attrp[ai].u.func = WLU->func;
-           break;
-       case G_ATTRUSERDATA:
-           attrp[ai].u.u = widget->udata;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    return 0;
-}
-
-
-int GLdestroywidget(Gwidget_t * widget)
-{
-    gtk_widget_destroy(widget->w);
-    return 0;
-}
diff --git a/cmd/lefty/ws/gtk/gmenu.c b/cmd/lefty/ws/gtk/gmenu.c
deleted file mode 100644 (file)
index ac28777..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WMU widget->u.m
-
-static int menupoped;
-static int menuselected;
-
-void mwcallback(gpointer * l);
-
-int GMcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    widget->w = gtk_menu_new();
-    gtk_menu_attach_to_widget(widget->w, parent->w, mwcallback);
-    WMU->count = 0;
-    return 0;
-}
-
-
-int GMsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GMgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRUSERDATA:
-           attrp[ai].u.u = widget->udata;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GMdestroywidget(Gwidget_t * widget)
-{
-    gtk_widget_destroy(widget->w);
-    return 0;
-}
-
-
-int GMmenuaddentries(Gwidget_t * widget, int en, char **ep)
-{
-    GtkWidget *mep;
-    int ei;
-
-    for (ei = 0; ei < en; ei++) {
-       mep = gtk_menu_item_new_with_label(ep[ei]);
-       gtk_menu_append(GTK_MENU(widget->w), mep);
-       gtk_signal_connect_object(GTK_OBJECT(mep), "activate",
-                                 GTK_SIGNAL_FUNC(mwcallback),
-                                 GINT_TO_POINTER(WMU->count++));
-       gtk_widget_show(mep);
-    }
-
-    return 0;
-}
-
-
-int GMmenudisplay(Gwidget_t * parent, Gwidget_t * widget)
-{
-
-    gtk_menu_popup(GTK_MENU(widget->w), NULL, NULL, NULL, NULL, 0, 0);
-    menupoped = TRUE;
-    menuselected = -1;
-
-    while (menupoped) {
-       Gprocessevents(TRUE, G_ONEEVENT);
-
-    }
-    Gpopdownflag = TRUE;
-    return menuselected;
-}
-
-
-void mwcallback(gpointer * l)
-{
-
-    if (GPOINTER_TO_INT(l) > -1)
-       menuselected = GPOINTER_TO_INT(l);
-    menupoped = FALSE;
-}
diff --git a/cmd/lefty/ws/gtk/gpcanvas.c b/cmd/lefty/ws/gtk/gpcanvas.c
deleted file mode 100644 (file)
index cb56cd4..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-
-char *Gpscanvasname = "out.ps";
-
-int GPcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-
-    return 0;
-}
-
-
-int GPsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-
-    return 0;
-}
-
-
-int GPgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-
-    return 0;
-}
-
-
-int GPdestroywidget(Gwidget_t * widget)
-{
-
-    return 0;
-}
-
-
-int GPsetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
-{
-
-    return 0;
-}
-
-
-int GParrow(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
-{
-
-    return 0;
-}
-
-
-int GPline(Gwidget_t * widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t * ap)
-{
-
-    return 0;
-}
-
-
-int GPbox(Gwidget_t * widget, Grect_t gr, Ggattr_t * ap)
-{
-
-    return 0;
-}
-
-
-int GPpolygon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
-{
-
-    return 0;
-}
-
-
-int GPsplinegon(Gwidget_t * widget, int gpn, Gpoint_t * gpp, Ggattr_t * ap)
-{
-
-    return 0;
-}
-
-
-int GParc(Gwidget_t * widget, Gpoint_t gc, Gsize_t gs, double ang1,
-         double ang2, Ggattr_t * ap)
-{
-
-    return 0;
-}
-
-
-int GPtext(Gwidget_t * widget, Gtextline_t * tlp, int n, Gpoint_t go,
-          char *fn, double fs, char *justs, Ggattr_t * ap)
-{
-
-    return 0;
-}
-
-
-int GPgettextsize(Gwidget_t * widget, Gtextline_t * tlp, int n, char *fn,
-                 double fs, Gsize_t * gsp)
-{
-
-    return 0;
-}
-
-
-int GPcreatebitmap(Gwidget_t * widget, Gbitmap_t * bitmap, Gsize_t s)
-{
-
-    return 0;
-}
-
-
-int GPdestroybitmap(Gbitmap_t * bitmap)
-{
-
-    return 0;
-}
-
-
-int GPreadbitmap(Gwidget_t * widget, Gbitmap_t * bitmap, FILE * fp)
-{
-
-    return 0;
-}
-
-
-int GPwritebitmap(Gbitmap_t * bitmap, FILE * fp)
-{
-
-    return 0;
-}
-
-
-int GPbitblt(Gwidget_t * widget, Gpoint_t gp, Grect_t gr,
-            Gbitmap_t * bitmap, char *mode, Ggattr_t * ap)
-{
-
-    return 0;
-}
-
-
-int GPcanvasclear(Gwidget_t * widget)
-{
-
-    return 0;
-}
-
-
-int GPgetgfxattr(Gwidget_t * widget, Ggattr_t * ap)
-{
-
-    return 0;
-}
diff --git a/cmd/lefty/ws/gtk/gquery.c b/cmd/lefty/ws/gtk/gquery.c
deleted file mode 100644 (file)
index 6116c1c..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WQU widget->u.q
-
-GtkWidget *w;
-void butcallback(gpointer * l);
-void file_ok_sel(GtkWidget * w2, GtkFileSelection * fs);
-
-int GQcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-
-    int ai;
-
-    WQU->mode = G_QWSTRING;
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRMODE:
-           if (strcmp("string", attrp[ai].u.t) == 0)
-               WQU->mode = G_QWSTRING;
-           else if (strcmp("file", attrp[ai].u.t) == 0)
-               WQU->mode = G_QWFILE;
-           else if (strcmp("choice", attrp[ai].u.t) == 0)
-               WQU->mode = G_QWCHOICE;
-           else {
-               Gerr(POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-               return -1;
-           }
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GQsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRMODE:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "mode");
-           return -1;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GQgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRMODE:
-           switch (WQU->mode) {
-           case G_QWSTRING:
-               attrp[ai].u.t = "string";
-               break;
-           case G_QWFILE:
-               attrp[ai].u.t = "file";
-               break;
-           case G_QWCHOICE:
-               attrp[ai].u.t = "choice";
-               break;
-           }
-           break;
-       case G_ATTRUSERDATA:
-           attrp[ai].u.u = widget->udata;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GQdestroywidget(Gwidget_t * widget)
-{
-    switch (WQU->mode) {
-    case G_QWSTRING:
-       gtk_widget_destroy(widget->w);
-       break;
-    case G_QWFILE:
-       break;
-    case G_QWCHOICE:
-       gtk_widget_destroy(widget->w);
-       break;
-    }
-    return 0;
-}
-
-
-int GQqueryask(Gwidget_t * widget, char *prompt, char *args,
-              char *responsep, int responsen)
-{
-    GtkWidget *vbox, *hbox;
-    GtkWidget *okBut, *cancelBut;
-    GtkWidget *qstringlabel;
-    GtkWidget *qstringentry;
-    char buttons[20][40];
-    char *s1, *s2;
-    char c;
-    long i;
-
-    switch (WQU->mode) {
-    case G_QWSTRING:
-       widget->w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-       gtk_window_set_title(GTK_WINDOW(widget->w), "popup");
-       vbox = gtk_vbox_new(FALSE, 0);
-       gtk_container_add(GTK_CONTAINER(widget->w), vbox);
-       gtk_widget_show(vbox);
-
-       qstringlabel = gtk_label_new("label");
-       gtk_box_pack_start(GTK_BOX(vbox), qstringlabel, TRUE, TRUE, 0);
-       gtk_widget_show(qstringlabel);
-       qstringentry = gtk_entry_new();
-       gtk_entry_set_max_length(G_OBJECT(qstringentry), 50);
-       if (args)
-           gtk_entry_set_text(qstringentry, args);
-       gtk_box_pack_start(GTK_BOX(vbox), qstringentry, TRUE, TRUE, 0);
-       gtk_widget_show(qstringentry);
-
-       hbox = gtk_hbox_new(FALSE, 0);
-       gtk_container_add(GTK_CONTAINER(vbox), hbox);
-       gtk_widget_show(hbox);
-
-       cancelBut = gtk_button_new_with_label("Cancel");
-       gtk_box_pack_start(GTK_BOX(hbox), cancelBut, TRUE, TRUE, 0);
-       gtk_widget_show(cancelBut);
-
-       okBut = gtk_button_new_with_label("OK");
-       gtk_box_pack_start(GTK_BOX(hbox), okBut, TRUE, TRUE, 0);
-
-       gtk_signal_connect_object(GTK_OBJECT(okBut), "clicked",
-                                 GTK_SIGNAL_FUNC(butcallback),
-                                 GINT_TO_POINTER(2));
-       gtk_signal_connect_object(GTK_OBJECT(cancelBut), "clicked",
-                                 GTK_SIGNAL_FUNC(butcallback),
-                                 GINT_TO_POINTER(1));
-       gtk_widget_show(okBut);
-
-       gtk_label_set_text(qstringlabel, prompt);
-       gtk_widget_show(widget->w);
-
-       w = widget->w;
-       WQU->state = 2;
-       WQU->button = 0;
-       while (WQU->state) {
-           if (WQU->state == 1) {
-               if (WQU->button != 1)
-                   strncpy(responsep, gtk_entry_get_text(qstringentry),
-                           responsen);
-               WQU->state = 0;
-           }
-           Gprocessevents(TRUE, G_ONEEVENT);
-       }
-
-
-       gtk_widget_hide(widget->w);
-       Gpopdownflag = TRUE;
-       if (WQU->button == 1)
-           return -1;
-       break;
-    case G_QWFILE:
-       widget->w = gtk_file_selection_new("File selection");
-       g_signal_connect(G_OBJECT(widget->w), "destroy",
-                        G_CALLBACK(gtk_main_quit), NULL);
-       g_signal_connect(G_OBJECT
-                        (GTK_FILE_SELECTION(widget->w)->ok_button),
-                        "clicked", G_CALLBACK(file_ok_sel), NULL);
-       g_signal_connect_swapped(G_OBJECT
-                                (GTK_FILE_SELECTION(widget->w)->
-                                 cancel_button), "clicked",
-                                G_CALLBACK(gtk_widget_destroy),
-                                G_OBJECT(widget->w));
-       gtk_widget_show(widget->w);
-
-       w = widget->w;
-       WQU->state = 2;
-       while (WQU->state) {
-           if (WQU->state == 1) {
-               if (WQU->button > 0)
-                   strncpy(responsep,
-                           gtk_file_selection_get_filename
-                           (GTK_FILE_SELECTION(widget->w)), responsen);
-               WQU->state = 0;
-           }
-           Gprocessevents(TRUE, G_ONEEVENT);
-       }
-       gtk_widget_hide(widget->w);
-       break;
-    case G_QWCHOICE:
-       if (!args)
-           return -1;
-
-       widget->w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-       gtk_window_set_title(GTK_WINDOW(widget->w), "popup");
-       vbox = gtk_vbox_new(FALSE, 0);
-       gtk_container_add(GTK_CONTAINER(widget->w), vbox);
-       gtk_widget_show(vbox);
-
-       qstringlabel = gtk_label_new("label");
-       gtk_box_pack_start(GTK_BOX(vbox), qstringlabel, TRUE, TRUE, 0);
-       hbox = gtk_hbox_new(FALSE, 0);
-       gtk_container_add(GTK_CONTAINER(vbox), hbox);
-       gtk_widget_show(hbox);
-
-       for (s1 = args, i = 1; *s1; i++) {
-           s2 = s1;
-           while (*s2 && *s2 != '|')
-               s2++;
-           c = *s2, *s2 = 0;
-           strcpy(buttons[i], s1);
-           okBut = gtk_button_new_with_label(buttons[i]);
-           gtk_box_pack_start(GTK_BOX(hbox), okBut, TRUE, TRUE, 0);
-           gtk_signal_connect_object(GTK_OBJECT(okBut), "clicked",
-                                     GTK_SIGNAL_FUNC(butcallback),
-                                     GINT_TO_POINTER(i));
-           gtk_widget_show(okBut);
-
-           *s2 = c;
-           s1 = s2;
-           if (*s1)
-               s1++;
-       }
-       gtk_widget_show(widget->w);
-       w = widget->w;
-
-       WQU->state = 2;
-       while (WQU->state) {
-           if (WQU->state == 1) {
-               if (WQU->button > 0)
-                   strncpy(responsep, buttons[WQU->button], responsen);
-               WQU->state = 0;
-           }
-           Gprocessevents(TRUE, G_ONEEVENT);
-       }
-       Gpopdownflag = TRUE;
-       gtk_widget_hide(widget->w);
-       break;
-    }
-
-    return 0;
-}
-
-
-void butcallback(gpointer * l)
-{
-    Gwidget_t *widget;
-
-    widget = findwidget((unsigned long) w, G_QUERYWIDGET);
-    if (GPOINTER_TO_INT(l) > -1) {
-       WQU->button = GPOINTER_TO_INT(l);
-    }
-    WQU->state = 1;
-}
-
-
-void file_ok_sel(GtkWidget * w2, GtkFileSelection * fs)
-{
-    Gwidget_t *widget;
-    widget = findwidget((unsigned long) w, G_QUERYWIDGET);
-    WQU->state = 1;
-    WQU->button = 1;
-}
diff --git a/cmd/lefty/ws/gtk/gscroll.c b/cmd/lefty/ws/gtk/gscroll.c
deleted file mode 100644 (file)
index 37161a6..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-
-int GScreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-
-    PIXsize_t ps;
-    GtkWidget *draw;
-    int ai;
-    GdkColor c;
-    int color;
-
-    if (!parent) {
-       Gerr(POS, G_ERRNOPARENTWIDGET);
-       return -1;
-    }
-    ps.x = ps.y = MINSWSIZE;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINSWSIZE);
-           break;
-       case G_ATTRBORDERWIDTH:
-           break;
-       case G_ATTRCHILDCENTER:
-           Gerr(POS, G_ERRCANNOTSETATTR1, "childcenter");
-           return -1;
-       case G_ATTRMODE:
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color != 0 && color != 1) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           c.red = attrp[ai].u.c.r * 257;
-           c.green = attrp[ai].u.c.g * 257;
-           c.blue = attrp[ai].u.c.b * 257;
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
-           return -1;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    widget->w = gtk_scrolled_window_new(NULL, NULL);
-
-    if (GTK_CONTAINER(parent->w)) {
-       gtk_container_add(GTK_CONTAINER(parent->w), widget->w);
-    } else if (GTK_BOX(parent->w)) {
-       gtk_box_pack_start(GTK_BOX(parent->w), widget->w, TRUE, TRUE, 0);
-
-    }
-    gtk_widget_set_usize(widget->w, ps.x, ps.y);
-    gtk_widget_show(widget->w);
-    return 0;
-}
-
-
-int GSsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    PIXpoint_t po;
-    PIXsize_t ps;
-    GdkColor c;
-    int width, height;
-    int ai;
-    int color;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINSWSIZE);
-           gtk_widget_set_usize(widget->w, ps.x, ps.y);
-           break;
-       case G_ATTRBORDERWIDTH:
-           break;
-       case G_ATTRCHILDCENTER:
-           GETORIGIN(attrp[ai].u.p, po);
-
-           break;
-       case G_ATTRMODE:
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color != 0 && color != 1) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           c.red = attrp[ai].u.c.r * 257;
-           c.green = attrp[ai].u.c.g * 257;
-           c.blue = attrp[ai].u.c.b * 257;
-
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
-           return -1;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-
-       }
-    }
-
-    return 0;
-}
-
-
-int GSgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int x, y;
-    Gwidget_t *child;
-    int ai, wi;
-    int width, height;
-    child = 0;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-           break;
-       case G_ATTRBORDERWIDTH:
-           attrp[ai].u.i = width;
-           break;
-       case G_ATTRCHILDCENTER:
-           for (wi = 0; wi < Gwidgetn; wi++) {
-               child = &Gwidgets[wi];
-               if (child->inuse && child->pwi == widget - &Gwidgets[0])
-                   break;
-           }
-           if (wi == Gwidgetn) {
-               Gerr(POS, G_ERRNOCHILDWIDGET);
-               return -1;
-           }
-
-           break;
-       case G_ATTRMODE:
-
-           break;
-       case G_ATTRWINDOWID:
-
-           break;
-       case G_ATTRUSERDATA:
-           attrp[ai].u.u = widget->udata;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-
-    }
-
-    return 0;
-}
-
-
-int GSdestroywidget(Gwidget_t * widget)
-{
-    gtk_widget_destroy(widget->w);
-    return 0;
-}
diff --git a/cmd/lefty/ws/gtk/gtext.c b/cmd/lefty/ws/gtk/gtext.c
deleted file mode 100644 (file)
index 96095b1..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WTU widget->u.t
-
-int pos = 0;
-
-gint keyevent(GtkWidget * w, GdkEventKey * event, gpointer data);
-
-int GTcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-
-    PIXsize_t ps;
-    char *s;
-    int ai;
-    int color;
-    GdkColor c;
-
-    if (!parent) {
-       Gerr(POS, G_ERRNOPARENTWIDGET);
-       return -1;
-    }
-
-    WTU->func = NULL;
-    ps.x = ps.y = MINTWSIZE;
-    s = "oneline";
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINTWSIZE);
-           break;
-       case G_ATTRBORDERWIDTH:
-           break;
-       case G_ATTRTEXT:
-           break;
-       case G_ATTRAPPENDTEXT:
-           Gerr(POS, G_ERRCANNOTSETATTR1, "appendtext");
-           return -1;
-       case G_ATTRMODE:
-           s = attrp[ai].u.t;
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color != 0 && color != 1) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           c.red = attrp[ai].u.c.r * 257;
-           c.green = attrp[ai].u.c.g * 257;
-           c.blue = attrp[ai].u.c.b * 257;
-/*                         if (XAllocColor (
-                               Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-                           )) {
-                               if (color == 0)
-                                   ADD2ARGS (XtNbackground, c.pixel);
-                               else
-                                   ADD2ARGS (XtNforeground, c.pixel);
-                           }
-*/ break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
-           return -1;
-       case G_ATTRNEWLINECB:
-           WTU->func = (Gtwnewlinecb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    widget->w = gtk_text_new(NULL, NULL);
-    gtk_text_set_editable(widget->w, TRUE);
-    gtk_box_pack_start(GTK_BOX(parent->w), widget->w, TRUE, TRUE, 0);
-
-    gtk_signal_connect(GTK_OBJECT(widget->w), "key_press_event",
-                      GTK_SIGNAL_FUNC(keyevent), NULL);
-    gtk_widget_show(widget->w);
-
-    return 0;
-}
-
-
-int GTsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    PIXsize_t ps;
-    int ai, li;
-    GdkColor c;
-    int color;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINTWSIZE);
-           break;
-       case G_ATTRBORDERWIDTH:
-
-           break;
-       case G_ATTRTEXT:
-
-           break;
-       case G_ATTRAPPENDTEXT:
-
-           break;
-       case G_ATTRMODE:
-
-           break;
-       case G_ATTRCOLOR:
-
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
-           return -1;
-       case G_ATTRNEWLINECB:
-           WTU->func = (Gtwnewlinecb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    return 0;
-}
-
-
-int GTgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int width, height;
-    GtkWidget w;
-    int rtn, ai;
-    long fi, li;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRSIZE:
-
-           break;
-       case G_ATTRBORDERWIDTH:
-
-           break;
-       case G_ATTRTEXT:
-
-           break;
-       case G_ATTRAPPENDTEXT:
-           Gerr(POS, G_ERRCANNOTGETATTR, "appendtext");
-           return -1;
-       case G_ATTRSELECTION:
-
-           break;
-       case G_ATTRMODE:
-
-           break;
-       case G_ATTRWINDOWID:
-
-           break;
-       case G_ATTRNEWLINECB:
-           attrp[ai].u.func = WTU->func;
-           break;
-       case G_ATTRUSERDATA:
-           attrp[ai].u.u = widget->udata;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-
-
-       }
-    }
-    return 0;
-}
-
-
-int GTdestroywidget(Gwidget_t * widget)
-{
-    gtk_widget_destroy(widget->w);
-    return 0;
-}
-
-
-gint keyevent(GtkWidget * w, GdkEventKey * event, gpointer data)
-{
-    Gwidget_t *widget;
-    widget = findwidget((unsigned long) w, G_TEXTWIDGET);
-
-    if (event->keyval == 65293) {
-       Gbufp = gtk_editable_get_chars(w, pos, -1);
-       pos = gtk_text_get_point(w);
-
-       if (WTU->func) {
-           /* calls TXTprocess in the case of txtview   */
-           (*WTU->func) (widget - &Gwidgets[0], Gbufp);
-       }
-    }
-
-    return FALSE;
-}
diff --git a/cmd/lefty/ws/gtk/gview.c b/cmd/lefty/ws/gtk/gview.c
deleted file mode 100644 (file)
index f0ea35c..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include <cgraph/exit.h>
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WVU widget->u.v
-
-int GVcreatewidget(Gwidget_t * parent, Gwidget_t * widget,
-                  int attrn, Gwattr_t * attrp)
-{
-
-    PIXsize_t ps;
-    PIXpoint_t po;
-    int haveorigin, ai, color;
-    char *s;
-    GdkColor c;
-
-    WVU->func = NULL;
-    WVU->closing = FALSE;
-    s = "LEFTY";
-    po.x = po.y = 0;
-    ps.x = ps.y = MINVWSIZE;
-    haveorigin = FALSE;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRORIGIN:
-           haveorigin = TRUE;
-           GETORIGIN(attrp[ai].u.p, po);
-           break;
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINVWSIZE);
-           break;
-       case G_ATTRNAME:
-           s = attrp[ai].u.t;
-           break;
-       case G_ATTRCOLOR:
-           color = attrp[ai].u.c.index;
-           if (color != 0 && color != 1) {
-               Gerr(POS, G_ERRBADCOLORINDEX, color);
-               return -1;
-           }
-           c.red = attrp[ai].u.c.r * 257;
-           c.green = attrp[ai].u.c.g * 257;
-           c.blue = attrp[ai].u.c.b * 257;
-           break;
-       case G_ATTRZORDER:
-           Gerr(POS, G_ERRCANNOTSETATTR1, "zorder");
-           return -1;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR1, "windowid");
-           return -1;
-       case G_ATTREVENTCB:
-           WVU->func = (Gviewcb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    widget->w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    gtk_widget_set_events(widget->w, GDK_ALL_EVENTS_MASK);
-
-    gtk_window_set_default_size(widget->w, ps.x, ps.y);
-    gtk_widget_set_uposition(widget->w, po.x, po.y);
-    gtk_widget_show(widget->w);
-
-    gdk_window_set_title(widget->w->window, s);
-    return 0;
-}
-
-
-int GVsetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    PIXpoint_t po;
-    PIXsize_t ps;
-    int ai;
-    GdkColor c;
-    int color;
-
-    for (ai = 0; ai < attrn; ai++) {
-       switch (attrp[ai].id) {
-       case G_ATTRORIGIN:
-           GETORIGIN(attrp[ai].u.p, po);
-           gtk_widget_set_uposition(widget->w, po.x, po.y);
-           break;
-       case G_ATTRSIZE:
-           GETSIZE(attrp[ai].u.s, ps, MINVWSIZE);
-           gtk_window_set_default_size(widget->w, ps.x, ps.y);
-           break;
-       case G_ATTRNAME:
-
-           break;
-       case G_ATTRCOLOR:
-
-           break;
-       case G_ATTRZORDER:
-
-           break;
-       case G_ATTRWINDOWID:
-           Gerr(POS, G_ERRCANNOTSETATTR2, "windowid");
-           return -1;
-       case G_ATTREVENTCB:
-           WVU->func = (Gviewcb) attrp[ai].u.func;
-           break;
-       case G_ATTRUSERDATA:
-           widget->udata = attrp[ai].u.u;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-
-    return 0;
-}
-
-
-int GVgetwidgetattr(Gwidget_t * widget, int attrn, Gwattr_t * attrp)
-{
-    int x, y;
-    int width, height;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-       RESETARGS;
-       switch (attrp[ai].id) {
-       case G_ATTRORIGIN:
-           break;
-       case G_ATTRSIZE:
-           break;
-       case G_ATTRNAME:
-           Gerr(POS, G_ERRNOTIMPLEMENTED);
-           return -1;
-       case G_ATTRZORDER:
-           Gerr(POS, G_ERRNOTIMPLEMENTED);
-           return -1;
-       case G_ATTRWINDOWID:
-           break;
-       case G_ATTREVENTCB:
-           attrp[ai].u.func = WVU->func;
-           break;
-       case G_ATTRUSERDATA:
-           attrp[ai].u.u = widget->udata;
-           break;
-       default:
-           Gerr(POS, G_ERRBADATTRID, attrp[ai].id);
-           return -1;
-       }
-    }
-    return 0;
-}
-
-
-int GVdestroywidget(Gwidget_t * widget)
-{
-    WVU->closing = TRUE;
-    gtk_widget_destroy(widget->w);
-    return 0;
-}
-
-
-void Gwmdelaction(GtkWidget * w, GdkEvent * evp, char **app,
-                 unsigned int *anp)
-{
-    Gwidget_t *widget;
-    Gevent_t gev;
-
-    widget = findwidget((unsigned long) w, G_VIEWWIDGET);
-    if (!widget)
-       graphviz_exit(0);
-
-    gev.type = 0, gev.code = 0, gev.data = 0;
-    gev.wi = widget - &Gwidgets[0];
-    if (WVU->func)
-       (*WVU->func) (&gev);
-    else
-       graphviz_exit(0);
-}
diff --git a/cmd/lefty/ws/mswin32/garray.c b/cmd/lefty/ws/mswin32/garray.c
deleted file mode 100644 (file)
index 795bc28..0000000
+++ /dev/null
@@ -1,329 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-#define WAU widget->u.a
-
-int GAcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    DWORD wflags;
-    int mode, ai;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    wflags = WS_CHILDWINDOW;
-    mode = G_AWVARRAY;
-    WAU->func = NULL;
-    ps.x = ps.y = MINAWSIZE;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINAWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            wflags |= WS_BORDER;
-            break;
-        case G_ATTRMODE:
-            if (strcmp ("horizontal", attrp[ai].u.t) == 0)
-                mode = G_AWHARRAY;
-            else if (strcmp ("vertical", attrp[ai].u.t) == 0)
-                mode = G_AWVARRAY;
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRLAYOUT:
-            if (strcmp ("on", attrp[ai].u.t) == 0) {
-                Gawsetmode (widget, FALSE);
-                WAU->mode = G_AWHARRAY;
-            } else if (strcmp ("off", attrp[ai].u.t) == 0) {
-                Gawsetmode (widget, TRUE);
-                WAU->mode = G_AWHARRAY;
-            } else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRRESIZECB:
-            WAU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    Gawinitialize (widget, mode);
-    Gadjustwrect (parent, &ps);
-    if (!(widget->w = CreateWindow (
-        "ArrayClass", "array", wflags, 0, 0, ps.x,
-        ps.y, parent->w, (HMENU) (widget - &Gwidgets[0]),
-        hinstance, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    ShowWindow (widget->w, SW_SHOW);
-    UpdateWindow (widget->w);
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawinsertchild (parent, widget);
-    return 0;
-}
-
-int GAsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Gwidget_t *parent;
-    PIXsize_t ps;
-    DWORD wflags1;
-    int ai;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINAWSIZE);
-/*            Gadjustwrect (parent, &ps);*/
-            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "borderwidth");
-            return -1;
-        case G_ATTRMODE:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "mode");
-            return -1;
-        case G_ATTRLAYOUT:
-            if (strcmp ("on", attrp[ai].u.t) == 0)
-                Gawsetmode (widget, FALSE);
-            else if (strcmp ("off", attrp[ai].u.t) == 0)
-                Gawsetmode (widget, TRUE);
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRRESIZECB:
-            WAU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GAgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    RECT r;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GetWindowRect (widget->w, &r);
-            attrp[ai].u.s.x = r.right - r.left;
-            attrp[ai].u.s.y = r.bottom - r.top;
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTGETATTR, "borderwidth");
-            return -1;
-        case G_ATTRMODE:
-            attrp[ai].u.t = (
-                WAU->mode == G_AWHARRAY
-            ) ? "horizontal" : "vertical";
-            break;
-        case G_ATTRLAYOUT:
-            attrp[ai].u.t = (Gawgetmode (widget)) ? "off" : "on";
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", widget->w);
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRRESIZECB:
-            attrp[ai].u.func = WAU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GAdestroywidget (Gwidget_t *widget) {
-    Gwidget_t *parent;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawdeletechild (parent, widget);
-    Gawdestroy (widget);
-    DestroyWindow (widget->w);
-    return 0;
-}
-
-/* the rest of this file contains the implementation of the array widget */
-
-static void dolayout (Gwidget_t *, int);
-
-int Gaworder (Gwidget_t *widget, void *data, Gawordercb func) {
-    (*func) (data, &WAU->data);
-    dolayout (widget, TRUE);
-    return 0;
-}
-
-int Gawsetmode (Gwidget_t *widget, int mode) {
-    WAU->data.batchmode = mode;
-    dolayout (widget, TRUE);
-    return 0;
-}
-
-int Gawgetmode (Gwidget_t *widget) {
-    return WAU->data.batchmode;
-}
-
-void Gawdefcoordscb (int wi, Gawdata_t *dp) {
-    Gawcarray_t *cp;
-    int sx, sy, csx, csy, ci;
-
-    sx = dp->sx, sy = dp->sy;
-    csx = csy = 0;
-    for (ci = 0; ci < dp->cj; ci++) {
-        cp = &dp->carray[ci];
-        if (!cp->flag)
-            continue;
-        cp->ox = csx, cp->oy = csy;
-        if (dp->type == G_AWVARRAY)
-            cp->sx = sx - 2 * cp->bs, csy += cp->sy + 2 * cp->bs;
-        else
-            cp->sy = sy - 2 * cp->bs, csx += cp->sx + 2 * cp->bs;
-    }
-    if (dp->type == G_AWVARRAY)
-        dp->sy = csy;
-    else
-        dp->sx = csx;
-}
-
-void Gawinitialize (Gwidget_t *widget, int mode) {
-    WAU->data.type = mode;
-    if (!(WAU->data.carray = Marrayalloc ((long) AWCARRAYINCR * AWCARRAYSIZE)))
-        panic1 (POS, "Gawinitialize", "cannot allocate carray");
-    WAU->data.cn = AWCARRAYINCR;
-    WAU->data.cj = 0;
-    WAU->data.batchmode = FALSE;
-    WAU->data.working = FALSE;
-}
-
-void Gawdestroy (Gwidget_t *widget) {
-    Marrayfree (WAU->data.carray);
-    WAU->data.cn = WAU->data.cj = 0;
-}
-
-void Gawresize (Gwidget_t *widget) {
-    dolayout (widget, FALSE);
-}
-
-void Gawinsertchild (Gwidget_t *parent, Gwidget_t *child) {
-    if (parent->u.a->data.cj == parent->u.a->data.cn) {
-        parent->u.a->data.carray = Marraygrow (
-            parent->u.a->data.carray,
-            (long) (parent->u.a->data.cn + AWCARRAYINCR) * AWCARRAYSIZE
-        );
-        parent->u.a->data.cn += AWCARRAYINCR;
-    }
-    parent->u.a->data.carray[parent->u.a->data.cj++].w = child->w;
-    dolayout (parent, TRUE);
-}
-
-void Gawdeletechild (Gwidget_t *parent, Gwidget_t *child) {
-    int ci;
-
-    for (ci = 0; ci < parent->u.a->data.cj; ci++)
-        if (parent->u.a->data.carray[ci].w == child->w)
-            break;
-    if (ci < parent->u.a->data.cj) {
-        for (; ci + 1 < parent->u.a->data.cj; ci++)
-            parent->u.a->data.carray[ci].w = parent->u.a->data.carray[ci + 1].w;
-        parent->u.a->data.cj--;
-        dolayout (parent, TRUE);
-    }
-}
-
-static void dolayout (Gwidget_t *widget, int flag) {
-    Gawdata_t *dp;
-    Gawcarray_t *cp;
-    RECT r;
-    int sx, sy, ci;
-
-    if (WAU->data.batchmode || WAU->data.working)
-        return;
-    WAU->data.working = TRUE;
-    dp = &WAU->data;
-    for (ci = 0; ci < dp->cj; ci++) {
-        cp = &dp->carray[ci];
-        GetWindowRect (cp->w, &r);
-        cp->flag = 1;
-        cp->ox = 0;
-        cp->oy = 0;
-        cp->sx = r.right - r.left;
-        cp->sy = r.bottom - r.top;
-        cp->bs = 0;
-    }
-    GetClientRect (widget->w, &r);
-    dp->sx = r.right - r.left, dp->sy = r.bottom - r.top;
-    if (WAU->func)
-        (*WAU->func) (widget - &Gwidgets[0], dp);
-    else
-        Gawdefcoordscb (widget - &Gwidgets[0], dp);
-    if ((sx = dp->sx) < MINAWSIZE)
-        sx = MINAWSIZE;
-    if ((sy = dp->sy) < MINAWSIZE)
-        sy = MINAWSIZE;
-    if (flag && (r.right - r.left != sx || r.bottom - r.top != sy)) {
-        sx -= (r.right - r.left);
-        sy -= (r.bottom - r.top);
-        GetWindowRect (widget->w, &r);
-        sx += (r.right - r.left);
-        sy += (r.bottom - r.top);
-        SetWindowPos (
-            widget->w, (HWND) NULL, 0, 0, sx, sy, SWP_NOMOVE | SWP_NOZORDER
-        );
-    }
-    for (ci = 0; ci < dp->cj; ci++) {
-        cp = &dp->carray[ci];
-        SetWindowPos (
-            cp->w, (HWND) NULL, cp->ox, cp->oy, cp->sx, cp->sy, SWP_NOZORDER
-        );
-    }
-    WAU->data.working = FALSE;
-}
diff --git a/cmd/lefty/ws/mswin32/gbutton.c b/cmd/lefty/ws/mswin32/gbutton.c
deleted file mode 100644 (file)
index e98f501..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-#define WBU widget->u.b
-
-int GBcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    DWORD wflags;
-    char *s;
-    int ai;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    wflags = WS_CHILDWINDOW | BS_PUSHBUTTON;
-    WBU->func = NULL;
-    ps.x = ps.y = MINBWSIZE;
-    s = "button";
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINBWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            wflags |= WS_BORDER;
-            break;
-        case G_ATTRTEXT:
-            s = attrp[ai].u.t;
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRBUTTONCB:
-            WBU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    Gadjustwrect (parent, &ps);
-    if (!(widget->w = CreateWindow (
-        "BUTTON", s, wflags, 0, 0, ps.x, ps.y,
-        parent->w, (HMENU) (widget - &Gwidgets[0]), hinstance, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    ShowWindow (widget->w, SW_SHOW);
-    UpdateWindow (widget->w);
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawinsertchild (parent, widget);
-    return 0;
-}
-
-int GBsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Gwidget_t *parent;
-    PIXsize_t ps;
-    DWORD wflags1;
-    int ai;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINBWSIZE);
-            Gadjustwrect (parent, &ps);
-            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "borderwidth");
-            return -1;
-        case G_ATTRTEXT:
-            SetWindowText (widget->w, attrp[ai].u.t);
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRBUTTONCB:
-            WBU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GBgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    RECT r;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GetWindowRect (widget->w, &r);
-            attrp[ai].u.s.x = r.right - r.left;
-            attrp[ai].u.s.y = r.bottom - r.top;
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTGETATTR, "borderwidth");
-            return -1;
-        case G_ATTRTEXT:
-            GetWindowText (widget->w, &Gbufp[0], Gbufn);
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", widget->w);
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRBUTTONCB:
-            attrp[ai].u.func = WBU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GBdestroywidget (Gwidget_t *widget) {
-    Gwidget_t *parent;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawdeletechild (parent, widget);
-    DestroyWindow (widget->w);
-    return 0;
-}
diff --git a/cmd/lefty/ws/mswin32/gcanvas.c b/cmd/lefty/ws/mswin32/gcanvas.c
deleted file mode 100644 (file)
index cb8aad8..0000000
+++ /dev/null
@@ -1,1372 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-#include <math.h>
-#include <string.h>
-
-#define WCU widget->u.c
-#define WINDOW widget->u.c->window
-#define GC widget->u.c->gc
-#define ISVISIBLE(r) ( \
-    (r.o.x <= WCU->clip.c.x) && (r.c.x >= WCU->clip.o.x) && \
-    (r.o.y <= WCU->clip.c.y) && (r.c.y >= WCU->clip.o.y) \
-)
-
-#define max(a, b) (((a) >= (b)) ? (a) : (b))
-#define min(a, b) (((a) <= (b)) ? (a) : (b))
-
-static long gstyles[5] = {
-    /* G_SOLID */       PS_SOLID,
-    /* G_DASHED */      PS_DASH,
-    /* G_DOTTED */      PS_DOT,
-    /* G_LONGDASHED */  PS_DASH,
-    /* G_SHORTDASHED */ PS_DASH,
-};
-
-static char grays[][4] = {
-    { 0x00, 0x00, 0x00, 0x00 },
-    { 0x08, 0x00, 0x00, 0x00 },
-    { 0x08, 0x00, 0x02, 0x00 },
-    { 0x0A, 0x00, 0x02, 0x00 },
-    { 0x0A, 0x00, 0x0A, 0x00 },
-    { 0x0A, 0x04, 0x0A, 0x00 },
-    { 0x0A, 0x04, 0x0A, 0x01 },
-    { 0x0A, 0x05, 0x0A, 0x01 },
-    { 0x0A, 0x05, 0x0A, 0x05 },
-    { 0x0E, 0x05, 0x0A, 0x05 },
-    { 0x0E, 0x05, 0x0B, 0x05 },
-    { 0x0F, 0x05, 0x0B, 0x05 },
-    { 0x0F, 0x05, 0x0F, 0x05 },
-    { 0x0F, 0x0D, 0x0F, 0x05 },
-    { 0x0F, 0x0D, 0x0F, 0x07 },
-    { 0x0F, 0x0F, 0x0F, 0x07 },
-    { 0x0F, 0x0F, 0x0F, 0x0F }
-};
-
-static int curcursori = -1;
-
-static void bezier (PIXpoint_t, PIXpoint_t, PIXpoint_t, PIXpoint_t);
-static HFONT findfont (char *, int);
-static int scalebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t, int, int);
-static void setgattr (Gwidget_t *, Ggattr_t *);
-
-static PIXrect_t  rdrawtopix (Gwidget_t *, Grect_t);
-static PIXpoint_t pdrawtopix (Gwidget_t *, Gpoint_t);
-static PIXsize_t  sdrawtopix (Gwidget_t *, Gsize_t);
-static Gsize_t    spixtodraw (Gwidget_t *, PIXsize_t);
-static Grect_t    rpixtodraw (Gwidget_t *, PIXrect_t);
-static PIXrect_t  rdrawtobpix (Gbitmap_t *, Grect_t);
-static PIXpoint_t pdrawtobpix (Gbitmap_t *, Gpoint_t);
-
-int GCcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    /* the 2 here is to provide enough space for palPalEntry[0] and [1] */
-    LOGPALETTE pal[2];
-
-    HBRUSH brush;
-    HPEN pen;
-    HBITMAP bmap;
-    HCURSOR cursor;
-    DWORD wflags;
-    int color, ai, i;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    wflags = WS_CHILDWINDOW;
-    WCU->func = NULL;
-    WCU->needredraw = FALSE;
-    WCU->buttonsdown = 0;
-    WCU->bstate[0] = WCU->bstate[1] = WCU->bstate[2] = 0;
-    ps.x = ps.y = MINCWSIZE;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINCWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            wflags |= WS_BORDER;
-            break;
-        case G_ATTRCURSOR:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRCOLOR:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRVIEWPORT:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRWINDOW:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WCU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    Gadjustwrect (parent, &ps);
-    WCU->wrect.o.x = 0.0, WCU->wrect.o.y = 0.0;
-    WCU->wrect.c.x = 1.0, WCU->wrect.c.y = 1.0;
-    WCU->vsize.x = ps.x, WCU->vsize.y = ps.y;
-    if (!(widget->w = CreateWindow (
-        "CanvasClass", "canvas", wflags, 0, 0,
-        ps.x, ps.y, parent->w, (HMENU) (widget - &Gwidgets[0]),
-        hinstance, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    ShowWindow (widget->w, SW_SHOW);
-    UpdateWindow (widget->w);
-    SetCursor (LoadCursor ((HINSTANCE) NULL, IDC_ARROW));
-    GC = GetDC (widget->w);
-    WCU->ncolor = 2;
-    pal[0].palVersion = 0x300; /* HA HA HA */
-    pal[0].palNumEntries = 2;
-    pal[0].palPalEntry[0].peRed = 255;
-    pal[0].palPalEntry[0].peGreen = 255;
-    pal[0].palPalEntry[0].peBlue = 255;
-    pal[0].palPalEntry[0].peFlags = 0;
-    pal[0].palPalEntry[1].peRed = 0;
-    pal[0].palPalEntry[1].peGreen = 0;
-    pal[0].palPalEntry[1].peBlue = 0;
-    pal[0].palPalEntry[1].peFlags = 0;
-    WCU->cmap = CreatePalette (&pal[0]);
-    WCU->colors[0].color = pal[0].palPalEntry[0];
-    for (i = 1; i < G_MAXCOLORS; i++)
-        WCU->colors[i].color = pal[0].palPalEntry[1];
-    SelectPalette (GC, WCU->cmap, FALSE);
-    RealizePalette (GC);
-    WCU->colors[0].inuse = TRUE;
-    WCU->colors[1].inuse = TRUE;
-    for (i = 2; i < G_MAXCOLORS; i++)
-        WCU->colors[i].inuse = FALSE;
-    WCU->gattr.color = 1;
-    brush = CreateSolidBrush (PALETTEINDEX (1));
-    SelectObject (GC, brush);
-    pen = CreatePen (PS_SOLID, 1, PALETTEINDEX (1));
-    SelectObject (GC, pen);
-    SetTextColor (GC, PALETTEINDEX (1));
-    SetBkMode (GC, TRANSPARENT);
-    WCU->gattr.width = 0;
-    WCU->gattr.mode = G_SRC;
-    WCU->gattr.fill = 0;
-    WCU->gattr.style = 0;
-    WCU->defgattr = WCU->gattr;
-    WCU->font = NULL;
-    if (Gdepth == 1) {
-        for (i = 0; i < 17; i++) {
-            if (!(bmap = CreateBitmap (4, 4, 1, 1, &grays[i][0])))
-                continue;
-            WCU->grays[i] = CreatePatternBrush (bmap);
-        }
-    }
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRCURSOR:
-            if (strcmp (attrp[ai].u.t, "watch") == 0) {
-                curcursori = 1;
-                cursor = LoadCursor ((HINSTANCE) NULL, IDC_WAIT);
-            } else if (strcmp (attrp[ai].u.t, "default") == 0) {
-                curcursori = -1;
-                cursor = LoadCursor ((HINSTANCE) NULL, IDC_ARROW);
-            } else {
-                Gerr (POS, G_ERRNOSUCHCURSOR, attrp[ai].u.t);
-                return -1;
-            }
-            SetCursor (cursor);
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            WCU->colors[color].color.peRed = attrp[ai].u.c.r;
-            WCU->colors[color].color.peGreen = attrp[ai].u.c.g;
-            WCU->colors[color].color.peBlue = attrp[ai].u.c.b;
-            WCU->colors[color].color.peFlags = 0;
-            if (color >= WCU->ncolor)
-                ResizePalette (WCU->cmap, color + 1), WCU->ncolor = color + 1;
-            SetPaletteEntries (
-                WCU->cmap, (int) color, 1, &WCU->colors[color].color);
-            RealizePalette (GC);
-            WCU->colors[color].inuse = TRUE;
-            if (color == WCU->gattr.color)
-                WCU->gattr.color = -1;
-            break;
-        case G_ATTRVIEWPORT:
-            if (attrp[ai].u.s.x == 0)
-                attrp[ai].u.s.x = 1;
-            if (attrp[ai].u.s.y == 0)
-                attrp[ai].u.s.y = 1;
-            WCU->vsize.x = (int) (attrp[ai].u.s.x + 0.5);
-            WCU->vsize.y = (int) (attrp[ai].u.s.y + 0.5);
-            SetWindowPos (
-                widget->w, (HWND) NULL, 0, 0, WCU->vsize.x,
-                WCU->vsize.y, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE
-            );
-            break;
-        case G_ATTRWINDOW:
-            if (attrp[ai].u.r.o.x == attrp[ai].u.r.c.x)
-                attrp[ai].u.r.c.x = attrp[ai].u.r.o.x + 1;
-            if (attrp[ai].u.r.o.y == attrp[ai].u.r.c.y)
-                attrp[ai].u.r.c.y = attrp[ai].u.r.o.y + 1;
-            WCU->wrect = attrp[ai].u.r;
-            break;
-        }
-    }
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawinsertchild (parent, widget);
-    Gadjustclip (widget);
-    return 0;
-}
-
-int GCsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    HCURSOR cursor;
-    Gwidget_t *parent;
-    PIXsize_t ps;
-    DWORD wflags1;
-    int ai, color;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINCWSIZE);
-            Gadjustwrect (parent, &ps);
-            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "borderwidth");
-            return -1;
-        case G_ATTRCURSOR:
-            if (strcmp (attrp[ai].u.t, "watch") == 0) {
-                curcursori = 1;
-                cursor = LoadCursor ((HINSTANCE) NULL, IDC_WAIT);
-            } else if (strcmp (attrp[ai].u.t, "default") == 0) {
-                curcursori = -1;
-                cursor = LoadCursor ((HINSTANCE) NULL, IDC_ARROW);
-            } else {
-                Gerr (POS, G_ERRNOSUCHCURSOR, attrp[ai].u.t);
-                return -1;
-            }
-            SetCursor (cursor);
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            WCU->colors[color].color.peRed = attrp[ai].u.c.r;
-            WCU->colors[color].color.peGreen = attrp[ai].u.c.g;
-            WCU->colors[color].color.peBlue = attrp[ai].u.c.b;
-            WCU->colors[color].color.peFlags = 0;
-            if (color >= WCU->ncolor)
-                ResizePalette (WCU->cmap, color + 1), WCU->ncolor = color + 1;
-            SetPaletteEntries (
-                WCU->cmap, (int) color, 1, &WCU->colors[color].color
-            );
-            RealizePalette (GC);
-            WCU->colors[color].inuse = TRUE;
-            if (color == WCU->gattr.color)
-                WCU->gattr.color = -1;
-            break;
-        case G_ATTRVIEWPORT:
-            if (attrp[ai].u.s.x == 0)
-                attrp[ai].u.s.x = 1;
-            if (attrp[ai].u.s.y == 0)
-                attrp[ai].u.s.y = 1;
-            WCU->vsize.x = (int) (attrp[ai].u.s.x + 0.5);
-            WCU->vsize.y = (int) (attrp[ai].u.s.y + 0.5);
-            ps.x = WCU->vsize.x, ps.y = WCU->vsize.y;
-            Gadjustwrect (&Gwidgets[widget->pwi], &ps);
-            SetWindowPos (
-                widget->w, (HWND) NULL, 0, 0, ps.x,
-                ps.y, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE
-            );
-            Gadjustclip (widget);
-            break;
-        case G_ATTRWINDOW:
-            if (attrp[ai].u.r.o.x == attrp[ai].u.r.c.x)
-                attrp[ai].u.r.c.x = attrp[ai].u.r.o.x + 1;
-            if (attrp[ai].u.r.o.y == attrp[ai].u.r.c.y)
-                attrp[ai].u.r.c.y = attrp[ai].u.r.o.y + 1;
-            WCU->wrect = attrp[ai].u.r;
-            Gadjustclip (widget);
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WCU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GCgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PALETTEENTRY *cp;
-    RECT r;
-    int color, ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GetWindowRect (widget->w, &r);
-            attrp[ai].u.s.x = r.right - r.left;
-            attrp[ai].u.s.y = r.bottom - r.top;
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTGETATTR, "borderwidth");
-            return -1;
-        case G_ATTRCURSOR:
-            attrp[ai].u.t = (curcursori == -1) ? "default" : "watch";
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            if (WCU->colors[color].inuse) {
-                cp = &WCU->colors[color].color;
-                attrp[ai].u.c.r = cp->peRed;
-                attrp[ai].u.c.g = cp->peGreen;
-                attrp[ai].u.c.b = cp->peBlue;
-            } else {
-                attrp[ai].u.c.r = -1;
-                attrp[ai].u.c.g = -1;
-                attrp[ai].u.c.b = -1;
-            }
-            break;
-        case G_ATTRVIEWPORT:
-            attrp[ai].u.s = WCU->vsize;
-            break;
-        case G_ATTRWINDOW:
-            attrp[ai].u.r = WCU->wrect;
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", widget->w);
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTREVENTCB:
-            attrp[ai].u.func = WCU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GCdestroywidget (Gwidget_t *widget) {
-    Gwidget_t *parent;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawdeletechild (parent, widget);
-    DestroyWindow (widget->w);
-    return 0;
-}
-
-int GCcanvasclear (Gwidget_t *widget) {
-    Ggattr_t attr;
-    RECT r;
-    HBRUSH brush, pbrush;
-
-    attr.flags = 0;
-    setgattr (widget, &attr);
-    brush = CreateSolidBrush (PALETTEINDEX (0));
-    pbrush = SelectObject (GC, brush);
-    GetClientRect (widget->w, &r);
-    Rectangle (GC, r.left, r.top, r.right, r.bottom);
-    SelectObject (GC, pbrush);
-    DeleteObject (brush);
-    WCU->needredraw = FALSE;
-    return 0;
-}
-
-int GCsetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    setgattr (widget, ap);
-    WCU->defgattr = WCU->gattr;
-    return 0;
-}
-
-int GCgetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    if ((ap->flags & G_GATTRCOLOR))
-        ap->color = WCU->gattr.color;
-    if ((ap->flags & G_GATTRWIDTH))
-        ap->width = WCU->gattr.width;
-    if ((ap->flags & G_GATTRMODE))
-        ap->mode = WCU->gattr.mode;
-    if ((ap->flags & G_GATTRFILL))
-        ap->fill = WCU->gattr.fill;
-    if ((ap->flags & G_GATTRSTYLE))
-        ap->style = WCU->gattr.style;
-    return 0;
-}
-
-int GCarrow (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    PIXpoint_t pp1, pp2, pa, pb, pd;
-    Grect_t gr;
-    double tangent, l;
-
-    if (gp1.x < gp2.x)
-        gr.o.x = gp1.x, gr.c.x = gp2.x;
-    else
-        gr.o.x = gp2.x, gr.c.x = gp1.x;
-    if (gp1.y < gp2.y)
-        gr.o.y = gp1.y, gr.c.y = gp2.y;
-    else
-        gr.o.y = gp2.y, gr.c.y = gp1.y;
-    if (!ISVISIBLE (gr))
-        return 1;
-    pp1 = pdrawtopix (widget, gp1), pp2 = pdrawtopix (widget, gp2);
-    pd.x = pp1.x - pp2.x, pd.y = pp1.y - pp2.y;
-    if (pd.x == 0 && pd.y == 0)
-        return 0;
-    tangent = atan2 ((double) pd.y, (double) pd.x);
-    if ((l = hypot(pd.x, pd.y)) > 30)
-        l = 30;
-    pa.x = l * cos (tangent + M_PI / 7) + pp2.x;
-    pa.y = l * sin (tangent + M_PI / 7) + pp2.y;
-    pb.x = l * cos (tangent - M_PI / 7) + pp2.x;
-    pb.y = l * sin (tangent - M_PI / 7) + pp2.y;
-    setgattr (widget, ap);
-    MoveToEx (GC, pp1.x, pp1.y, NULL), LineTo (GC, pp2.x, pp2.y);
-    MoveToEx (GC, pa.x, pa.y, NULL), LineTo (GC, pp2.x, pp2.y);
-    MoveToEx (GC, pb.x, pb.y, NULL), LineTo (GC, pp2.x, pp2.y);
-    return 0;
-}
-
-int GCline (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    PIXpoint_t pp1, pp2;
-    Grect_t gr;
-
-    if (gp1.x < gp2.x)
-        gr.o.x = gp1.x, gr.c.x = gp2.x;
-    else
-        gr.o.x = gp2.x, gr.c.x = gp1.x;
-    if (gp1.y < gp2.y)
-        gr.o.y = gp1.y, gr.c.y = gp2.y;
-    else
-        gr.o.y = gp2.y, gr.c.y = gp1.y;
-    if (!ISVISIBLE (gr))
-        return 1;
-    pp1 = pdrawtopix (widget, gp1), pp2 = pdrawtopix (widget, gp2);
-    setgattr (widget, ap);
-    MoveToEx (GC, pp1.x, pp1.y, NULL);
-    LineTo (GC, pp2.x, pp2.y);
-    return 0;
-}
-
-int GCbox (Gwidget_t *widget, Grect_t gr, Ggattr_t *ap) {
-    PIXrect_t pr;
-    Grect_t gr2;
-
-    if (gr.o.x <= gr.c.x)
-        gr2.o.x = gr.o.x, gr2.c.x = gr.c.x;
-    else
-        gr2.o.x = gr.c.x, gr2.c.x = gr.o.x;
-    if (gr.o.y <= gr.c.y)
-        gr2.o.y = gr.o.y, gr2.c.y = gr.c.y;
-    else
-        gr2.o.y = gr.c.y, gr2.c.y = gr.o.y;
-    if (!ISVISIBLE (gr2))
-        return 1;
-    pr = rdrawtopix (widget, gr);
-    setgattr (widget, ap);
-    if (WCU->gattr.fill)
-        Rectangle (GC, pr.o.x, pr.o.y, pr.c.x, pr.c.y);
-    else {
-        Gppp[0].x = pr.o.x, Gppp[0].y = pr.o.y;
-        Gppp[1].x = pr.c.x, Gppp[1].y = pr.o.y;
-        Gppp[2].x = pr.c.x, Gppp[2].y = pr.c.y;
-        Gppp[3].x = pr.o.x, Gppp[3].y = pr.c.y;
-        Gppp[4].x = pr.o.x, Gppp[4].y = pr.o.y;
-        Polyline (GC, Gppp, 5);
-    }
-    return 0;
-}
-
-int GCpolygon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    Grect_t gr;
-    int n, i;
-
-    if (gpn == 0)
-        return 0;
-    gr.o = gpp[0], gr.c = gpp[0];
-    for (i = 1; i < gpn; i++) {
-        gr.o.x = min (gr.o.x, gpp[i].x);
-        gr.o.y = min (gr.o.y, gpp[i].y);
-        gr.c.x = max (gr.c.x, gpp[i].x);
-        gr.c.y = max (gr.c.y, gpp[i].y);
-    }
-    if (!ISVISIBLE (gr))
-        return 1;
-    if (gpn + 1 > Gppn) {
-        n = (((gpn + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-        Gppp = Marraygrow (Gppp, (long) n * PPSIZE);
-        Gppn = n;
-    }
-    for (i = 0; i < gpn; i++)
-        Gppp[i] = pdrawtopix (widget, gpp[i]);
-    setgattr (widget, ap);
-    if (WCU->gattr.fill) {
-        if (Gppp[gpn - 1].x != Gppp[0].x || Gppp[gpn - 1].y != Gppp[0].y)
-            Gppp[gpn] = Gppp[0], gpn++;
-        Polygon (GC, Gppp, (int) gpn);
-    } else
-        Polyline (GC, Gppp, (int) gpn);
-    return 0;
-}
-
-int GCsplinegon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    PIXpoint_t p0, p1, p2, p3;
-    Grect_t gr;
-    int n, i;
-
-    if (gpn == 0)
-        return 0;
-    gr.o = gpp[0], gr.c = gpp[0];
-    for (i = 1; i < gpn; i++) {
-        gr.o.x = min (gr.o.x, gpp[i].x);
-        gr.o.y = min (gr.o.y, gpp[i].y);
-        gr.c.x = max (gr.c.x, gpp[i].x);
-        gr.c.y = max (gr.c.y, gpp[i].y);
-    }
-    if (!ISVISIBLE (gr))
-        return 1;
-    Gppi = 1;
-    if (Gppi >= Gppn) {
-        n = (((Gppi + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-        Gppp = Marraygrow (Gppp, (long) n * PPSIZE);
-        Gppn = n;
-    }
-    Gppp[0] = p3 = pdrawtopix (widget, gpp[0]);
-    for (i = 1; i < gpn; i += 3) {
-        p0 = p3;
-        p1 = pdrawtopix (widget, gpp[i]);
-        p2 = pdrawtopix (widget, gpp[i + 1]);
-        p3 = pdrawtopix (widget, gpp[i + 2]);
-        bezier (p0, p1, p2, p3);
-    }
-    setgattr (widget, ap);
-    if (WCU->gattr.fill) {
-        if (Gppp[Gppi - 1].x != Gppp[0].x || Gppp[Gppi - 1].y != Gppp[0].y)
-            Gppp[Gppi] = Gppp[0], Gppi++;
-        Polygon (GC, Gppp, (int) Gppi);
-    } else
-        Polyline (GC, Gppp, (int) Gppi);
-    return 0;
-}
-
-static void bezier (
-    PIXpoint_t p0, PIXpoint_t p1, PIXpoint_t p2, PIXpoint_t p3
-) {
-    Gpoint_t gp0, gp1, gp2;
-    Gsize_t s;
-    PIXpoint_t p;
-    double t;
-    int n, i, steps;
-
-    if ((s.x = p3.x - p0.x) < 0)
-        s.x = - s.x;
-    if ((s.y = p3.y - p0.y) < 0)
-        s.y = - s.y;
-    if (s.x > s.y)
-        steps = s.x / 5 + 1;
-    else
-        steps = s.y / 5 + 1;
-    for (i = 0; i <= steps; i++) {
-        t = i / (double) steps;
-        gp0.x = p0.x + t * (p1.x - p0.x);
-        gp0.y = p0.y + t * (p1.y - p0.y);
-        gp1.x = p1.x + t * (p2.x - p1.x);
-        gp1.y = p1.y + t * (p2.y - p1.y);
-        gp2.x = p2.x + t * (p3.x - p2.x);
-        gp2.y = p2.y + t * (p3.y - p2.y);
-        gp0.x = gp0.x + t * (gp1.x - gp0.x);
-        gp0.y = gp0.y + t * (gp1.y - gp0.y);
-        gp1.x = gp1.x + t * (gp2.x - gp1.x);
-        gp1.y = gp1.y + t * (gp2.y - gp1.y);
-        p.x = gp0.x + t * (gp1.x - gp0.x) + 0.5;
-        p.y = gp0.y + t * (gp1.y - gp0.y) + 0.5;
-        if (Gppi >= Gppn) {
-            n = (((Gppi + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-            Gppp = Marraygrow (Gppp, (long) n * PPSIZE);
-            Gppn = n;
-        }
-        Gppp[Gppi++] = p;
-    }
-}
-
-int GCarc (
-    Gwidget_t *widget, Gpoint_t gc, Gsize_t gs, double ang1,
-    double ang2, Ggattr_t *ap
-) {
-    PIXpoint_t pc;
-    PIXsize_t ps;
-    Grect_t gr;
-    double a1, a2;
-
-    gr.o.x = gc.x - gs.x, gr.o.y = gc.y - gs.y;
-    gr.c.x = gc.x + gs.x, gr.c.y = gc.y + gs.y;
-    if (!ISVISIBLE (gr))
-        return 1;
-    pc = pdrawtopix (widget, gc), ps = sdrawtopix (widget, gs);
-    setgattr (widget, ap);
-    a1 = ang1 * M_PI / 180, a2 = ang2 * M_PI / 180;
-    if (WCU->gattr.fill)
-        Chord (
-            GC, pc.x - ps.x, pc.y - ps.y, pc.x + ps.x, pc.y + ps.y,
-            (int) (cos (a1) * ps.x), (int) (sin (a1) * ps.x),
-            (int) (cos (a2) * ps.x), (int) (sin (a2) * ps.x)
-        );
-    else
-        Arc (
-            GC, pc.x - ps.x, pc.y - ps.y, pc.x + ps.x, pc.y + ps.y,
-            (int) (cos (a1) * ps.x), (int) (sin (a1) * ps.x),
-            (int) (cos (a2) * ps.x), (int) (sin (a2) * ps.x)
-        );
-    return 0;
-}
-
-#define YSCALE ((WCU->vsize.y) / (WCU->wrect.c.y - WCU->wrect.o.y))
-
-int GCtext (
-    Gwidget_t *widget, Gtextline_t *tlp, int n, Gpoint_t go,
-    char *fn, double fs, char *justs, Ggattr_t *ap
-) {
-    Gsize_t gs;
-    PIXpoint_t po;
-    PIXsize_t ps;
-    PIXrect_t pr;
-    Grect_t gr;
-    HFONT font;
-    TEXTMETRIC tm;
-    SIZE size;
-    RECT r;
-    int x, y, w, h, i;
-
-    po = pdrawtopix (widget, go);
-    gs.x = 0, gs.y = fs;
-    ps = sdrawtopix (widget, gs);
-    if (!(font = findfont (fn, ps.y))) {
-        Rectangle (GC, po.x, po.y, po.x + 1, po.y + 1);
-        return 0;
-    }
-    setgattr (widget, ap);
-    SETFONT (font);
-    GetTextMetrics (GC, &tm);
-    for (w = h = 0, i = 0; i < n; i++) {
-        if (tlp[i].n)
-            GetTextExtentPoint32 (GC, tlp[i].p, (int) tlp[i].n, &size);
-        else
-            GetTextExtentPoint32 (GC, "M", (int) 1, &size);
-        tlp[i].w = size.cx, tlp[i].h = size.cy;
-        w = max (w, size.cx), h += size.cy;
-    }
-    switch (justs[0]) {
-    case 'l': po.x += w / 2; break;
-    case 'r': po.x -= w / 2; break;
-    }
-    switch (justs[1]) {
-    case 'd': po.y -= h; break;
-    case 'b': po.y -= (h - tm.tmDescent); break;
-    case 'c': po.y -= h / 2; break;
-    }
-    pr.o.x = po.x - w / 2, pr.o.y = po.y;
-    pr.c.x = po.x + w / 2, pr.c.y = po.y + h;
-    gr = rpixtodraw (widget, pr);
-    if (!ISVISIBLE (gr))
-        return 1;
-    for (i = 0; i < n; i++) {
-        switch (tlp[i].j) {
-        case 'l': x = po.x - w / 2; break;
-        case 'n': x = po.x - tlp[i].w / 2; break;
-        case 'r': x = po.x - (tlp[i].w - w / 2); break;
-        }
-        y = po.y + i * tlp[i].h;
-        r.left = x, r.top = y;
-        r.right = x + tlp[i].w, r.bottom = y + tlp[i].h;
-        DrawText (GC, tlp[i].p, (int) tlp[i].n, &r, DT_LEFT | DT_TOP);
-    }
-    return 0;
-}
-
-int GCgettextsize (
-    Gwidget_t *widget, Gtextline_t *tlp, int n, char *fn,
-    double fs, Gsize_t *gsp
-) {
-    Gsize_t gs;
-    PIXsize_t ps;
-    HFONT font;
-    int i;
-    SIZE size;
-
-    gs.x = 0, gs.y = fs;
-    ps = sdrawtopix (widget, gs);
-    if (!(font = findfont (fn, ps.y))) {
-        gsp->x = 1, gsp->y = 1;
-        return 0;
-    }
-    SETFONT (font);
-    for (ps.x = ps.y = 0, i = 0; i < n; i++) {
-        GetTextExtentPoint32 (GC, tlp[i].p, (int) tlp[i].n, &size);
-        ps.x = max (ps.x, size.cx), ps.y += size.cy;
-    }
-    *gsp = spixtodraw (widget, ps);
-    return 0;
-}
-
-static HFONT findfont (char *name, int size) {
-    HFONT font;
-    int fi;
-
-    if (strcmp(name, "") == 0)
-        return Gfontp[0].font;
-
-    sprintf (&Gbufp[0], name, size);
-    for (fi = 0; fi < Gfontn; fi++)
-        if (strcmp (&Gbufp[0], Gfontp[fi].name) == 0 && Gfontp[fi].size == size)
-            return Gfontp[fi].font;
-    font = CreateFont (
-        (int) size, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &Gbufp[0]
-    );
-    if (!font)
-        font = Gfontp[0].font;
-
-    Gfontp = Marraygrow (Gfontp, (long) (Gfontn + 1) * FONTSIZE);
-    Gfontp[Gfontn].name = strdup (&Gbufp[0]);
-    Gfontp[Gfontn].size = size;
-    Gfontp[Gfontn].font = font;
-    Gfontn++;
-    return font;
-}
-
-int GCcreatebitmap (Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t s) {
-    if (!widget) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    if (!(bitmap->u.bmap.orig = CreateBitmap (
-        (int) s.x, (int) s.y, 1, Gdepth, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    bitmap->u.bmap.scaled = 0;
-    bitmap->scale.x = bitmap->scale.y = 1;
-    bitmap->ctype = widget->type;
-    bitmap->canvas = widget - &Gwidgets[0];
-    bitmap->size = s;
-    return 0;
-}
-
-int GCdestroybitmap (Gbitmap_t *bitmap) {
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    DeleteObject (bitmap->u.bmap.orig);
-    if (bitmap->u.bmap.scaled)
-        DeleteObject (bitmap->u.bmap.scaled);
-    return 0;
-}
-
-int GCreadbitmap (Gwidget_t *widget, Gbitmap_t *bitmap, FILE *fp) {
-    Gsize_t s;
-    HDC gc;
-    char bufp[2048];
-    unsigned int rgb[3];
-    char *s1, *s2;
-    char c;
-    int bufn, bufi, step, x, y, k;
-
-    if (!widget) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    step = 0;
-    while (step < 3) {
-l1:
-        if (!fgets (bufp, 2048, fp)) {
-            Gerr (POS, G_ERRCANNOTREADBITMAP);
-            return -1;
-        }
-        s1 = &bufp[0];
-l2:
-        for (; *s1 && isspace (*s1); s1++)
-            ;
-        if (!*s1 || *s1 == '#')
-            goto l1;
-        switch (step) {
-        case 0:
-            if (strncmp (s1, "P6", 2) != 0) {
-                Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            step++, s1 += 2;
-            goto l2;
-        case 1:
-            for (s2 = s1; *s2 && *s2 >= '0' && *s2 <= '9'; s2++)
-                ;
-            c = *s2, *s2 = 0;
-            if (s2 == s1 || (s.x = atoi (s1)) <= 0) {
-                *s2 = c, Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            *s2 = c, step++, s1 = s2;
-            goto l2;
-        case 2:
-            for (s2 = s1; *s2 && *s2 >= '0' && *s2 <= '9'; s2++)
-                ;
-            c = *s2, *s2 = 0;
-            if (s2 == s1 || (s.y = atoi (s1)) <= 0) {
-                *s2 = c, Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            *s2 = c, step++, s1 = s2;
-            goto l2;
-        }
-    }
-    if (!(bitmap->u.bmap.orig = CreateBitmap (
-        (int) s.x, (int) s.y, 1, Gdepth, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    gc = CreateCompatibleDC (GC);
-    SelectObject (gc, bitmap->u.bmap.orig);
-    bitmap->u.bmap.scaled = 0;
-    bitmap->scale.x = bitmap->scale.y = 1;
-    bitmap->ctype = widget->type;
-    bitmap->canvas = widget - &Gwidgets[0];
-    bitmap->size = s;
-    bufi = bufn = 0;
-    bufp[bufi] = 0;
-    for (y = 0; y < s.y; y++) {
-        for (x = 0; x < s.x; x++) {
-            for (k = 0; k < 3; k++) {
-                if (bufi == bufn) {
-                    if ((bufn = fread (bufp, 1, 2047, fp)) == 0) {
-                        if (ferror (fp))
-                            bufn = -1;
-                        DeleteDC (gc);
-                        DeleteObject (bitmap->u.bmap.orig);
-                        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-                        return -1;
-                    }
-                    bufi = 0;
-                }
-                rgb[k] = (unsigned char) bufp[bufi++];
-            }
-            SetPixel (gc, x, y, RGB (rgb[0], rgb[1], rgb[2]));
-        }
-    }
-    DeleteDC (gc);
-    return 0;
-}
-
-int GCwritebitmap (Gbitmap_t *bitmap, FILE *fp) {
-    Gwidget_t *widget;
-    HDC gc;
-    COLORREF color;
-    char bufp[2048];
-    int bufi, x, y, w, h;
-
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    if (
-        bitmap->canvas < 0 || bitmap->canvas >= Gwidgetn ||
-        !Gwidgets[bitmap->canvas].inuse
-    ) {
-        Gerr (POS, G_ERRBADWIDGETID, bitmap->canvas);
-        return -1;
-    }
-    widget = &Gwidgets[bitmap->canvas];
-    if (widget->type != G_CANVASWIDGET && widget->type != G_PCANVASWIDGET) {
-        Gerr (POS, G_ERRNOTACANVAS, bitmap->canvas);
-        return -1;
-    }
-    gc = CreateCompatibleDC (GC);
-    SelectObject (gc, bitmap->u.bmap.orig);
-    fprintf (fp, "P6\n%d %d 255\n", (int) bitmap->size.x, (int) bitmap->size.y);
-    bufi = 0;
-    w = bitmap->size.x;
-    h = bitmap->size.y;
-    for (y = 0; y < h; y++) {
-        for (x = 0; x < w; x++) {
-            color = GetPixel (gc, x, y);
-            bufp[bufi++] = GetRValue (color);
-            bufp[bufi++] = GetGValue (color);
-            bufp[bufi++] = GetBValue (color);
-            if (bufi + 3 >= 2048) {
-                fwrite (bufp, 1, bufi, fp);
-                bufi = 0;
-            }
-        }
-    }
-    if (bufi > 0)
-        fwrite (bufp, 1, bufi, fp);
-    DeleteDC (gc);
-    return 0;
-}
-
-int GCbitblt (
-    Gwidget_t *widget, Gpoint_t gp, Grect_t gr, Gbitmap_t *bitmap,
-    char *mode, Ggattr_t *ap
-) {
-    PIXrect_t pr, r;
-    PIXpoint_t pp;
-    PIXsize_t s;
-    Gsize_t scale;
-    Gxy_t p;
-    HBITMAP pix;
-    HDC gc;
-    double tvx, tvy, twx, twy;
-
-    if (gr.o.x > gr.c.x)
-        p.x = gr.o.x, gr.o.x = gr.c.x, gr.c.x = p.x;
-    if (gr.o.y > gr.c.y)
-        p.y = gr.o.y, gr.o.y = gr.c.y, gr.c.y = p.y;
-    if (strcmp (mode, "b2c") == 0) {
-        if (!ISVISIBLE (gr))
-            return 1;
-        tvx = WCU->vsize.x, tvy = WCU->vsize.y;
-        twx = WCU->wrect.c.x - WCU->wrect.o.x;
-        twy = WCU->wrect.c.y - WCU->wrect.o.y;
-        scale.x = tvx / twx, scale.y = tvy / twy;
-        if (scale.x == 1 && scale.y == 1)
-            pix = bitmap->u.bmap.orig;
-        else {
-            if (scale.x != bitmap->scale.x || scale.y != bitmap->scale.y)
-                scalebitmap (widget, bitmap, scale, TRUE, 1);
-            pix = bitmap->u.bmap.scaled;
-        }
-        pr = rdrawtopix (widget, gr);
-        pp = pdrawtobpix (bitmap, gp);
-        s.x = pr.c.x - pr.o.x + 1, s.y = pr.c.y - pr.o.y + 1;
-        r.o.x = pp.x, r.o.y = pp.y - s.y + 1;
-        r.c.x = r.o.x + s.x - 1, r.c.y = r.o.y + s.y - 1;
-        if (r.o.x < 0)
-            pr.o.x -= r.o.x, r.o.x = 0;
-        if (r.o.y < 0)
-            pr.o.y -= r.o.y, r.o.y = 0;
-        if (r.c.x >= bitmap->size.x * scale.x) {
-            pr.c.x -= (r.c.x + 1 - bitmap->size.x * scale.x);
-            r.c.x = bitmap->size.x * scale.x - 1;
-        }
-        if (r.c.y >= bitmap->size.y * scale.y) {
-            pr.c.y -= (r.c.y + 1 - bitmap->size.y * scale.y);
-            r.c.y = bitmap->size.y * scale.y - 1;
-        }
-        if (pr.o.x < 0)
-            r.o.x -= pr.o.x, pr.o.x = 0;
-        if (pr.o.y < 0)
-            r.o.y -= pr.o.y, pr.o.y = 0;
-        setgattr (widget, ap);
-        gc = CreateCompatibleDC (GC);
-        SelectObject (gc, pix);
-        BitBlt (
-            GC, pr.o.x, pr.o.y, r.c.x - r.o.x + 1, r.c.y - r.o.y + 1,
-            gc, r.o.x, r.o.y, (WCU->gattr.mode == G_SRC) ? SRCCOPY : SRCINVERT
-        );
-        DeleteDC (gc);
-    } else if (strcmp (mode, "c2b") == 0) {
-        tvx = WCU->vsize.x, tvy = WCU->vsize.y;
-        twx = WCU->wrect.c.x - WCU->wrect.o.x;
-        twy = WCU->wrect.c.y - WCU->wrect.o.y;
-        scale.x = tvx / twx, scale.y = tvy / twy;
-        if (scale.x == 1 && scale.y == 1)
-            pix = bitmap->u.bmap.orig;
-        else {
-            if (scale.x != bitmap->scale.x || scale.y != bitmap->scale.y)
-                scalebitmap (widget, bitmap, scale, FALSE, 1);
-            pix = bitmap->u.bmap.scaled;
-        }
-        pr = rdrawtobpix (bitmap, gr);
-        pp = pdrawtopix (widget, gp);
-        s.x = pr.c.x - pr.o.x + 1, s.y = pr.c.y - pr.o.y + 1;
-        r.o.x = pp.x, r.o.y = pp.y - s.y + 1;
-        r.c.x = r.o.x + s.x - 1, r.c.y = r.o.y + s.y - 1;
-        if (pr.o.x < 0)
-            r.o.x -= pr.o.x, pr.o.x = 0;
-        if (pr.o.y < 0)
-            r.o.y -= pr.o.y, pr.o.y = 0;
-        if (pr.c.x >= bitmap->size.x * scale.x) {
-            r.c.x -= (pr.c.x + 1 - bitmap->size.x * scale.x);
-            pr.c.x = bitmap->size.x * scale.x - 1;
-        }
-        if (pr.c.y >= bitmap->size.y * scale.y) {
-            r.c.y -= (pr.c.y + 1 - bitmap->size.y * scale.y);
-            pr.c.y = bitmap->size.y * scale.y - 1;
-        }
-        if (r.o.x < 0)
-            pr.o.x -= r.o.x, r.o.x = 0;
-        if (r.o.y < 0)
-            pr.o.y -= r.o.y, r.o.y = 0;
-        setgattr (widget, ap);
-        gc = CreateCompatibleDC (GC);
-        SelectObject (gc, pix);
-        BitBlt (
-            gc, pr.o.x, pr.o.y, r.c.x - r.o.x + 1, r.c.y - r.o.y + 1,
-            GC, r.o.x, r.o.y, (WCU->gattr.mode == G_SRC) ? SRCCOPY : SRCINVERT
-        );
-        if (pix != bitmap->u.bmap.orig)
-            scalebitmap (widget, bitmap, scale, TRUE, -1);
-        DeleteDC (gc);
-    }
-    return 0;
-}
-
-static int scalebitmap (
-    Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t scale,
-    int copybits, int dir
-) {
-    Gsize_t nsize, o2n;
-    HBITMAP opix, spix;
-    COLORREF color;
-    HDC gc1, gc2;
-    int x, y, x2, y2, xp, yp;
-    double prod, rgb[3], xr2, yr2, xl2, yl2, xf2, yf2, xr, yr, xl, yl;
-
-    if (!copybits) {
-        if (dir == 1) {
-            nsize.x = (int) (bitmap->size.x * scale.x);
-            nsize.y = (int) (bitmap->size.y * scale.y);
-            if (!(spix = CreateBitmap (
-                (int) nsize.x, (int) nsize.y, 1, Gdepth, NULL
-            ))) {
-                Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-                return -1;
-            }
-            if (bitmap->u.bmap.scaled)
-                DeleteObject (bitmap->u.bmap.scaled);
-            bitmap->u.bmap.scaled = spix;
-            bitmap->scale = scale;
-        }
-        return 0;
-    }
-    if (dir == 1) {
-        nsize.x = (int) (bitmap->size.x * scale.x);
-        nsize.y = (int) (bitmap->size.y * scale.y);
-        o2n.x = 1 / scale.x, o2n.y = 1 / scale.y;
-        if (!(spix = CreateBitmap (
-            (int) nsize.x, (int) nsize.y, 1, Gdepth, NULL
-        ))) {
-            Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-            return -1;
-        }
-        opix = bitmap->u.bmap.orig;
-    } else {
-        nsize.x = (int) bitmap->size.x;
-        nsize.y = (int) bitmap->size.y;
-        o2n.x = scale.x, o2n.y = scale.y;
-        spix = bitmap->u.bmap.orig;
-        opix = bitmap->u.bmap.scaled;
-    }
-    gc1 = CreateCompatibleDC (GC);
-    SelectObject (gc1, opix);
-    gc2 = CreateCompatibleDC (GC);
-    SelectObject (gc2, spix);
-    prod = o2n.x * o2n.y;
-    y = 0;
-    yr = o2n.y;
-    yl = 0;
-    for (yp = 0; yp < nsize.y; yp++) {
-        x = 0;
-        xr = o2n.x;
-        xl = 0;
-        for (xp = 0; xp < nsize.x; xp++) {
-            y2 = y;
-            yr2 = yr;
-            yl2 = yl;
-            rgb[0] = rgb[1] = rgb[2] = 0;
-            do {
-                x2 = x;
-                xr2 = xr;
-                xl2 = xl;
-                yf2 = (yl2 + yr2 > 1) ? 1 - yl2 : yr2, yr2 -= yf2;
-                do {
-                    xf2 = (xl2 + xr2 > 1) ? 1 - xl2 : xr2, xr2 -= xf2;
-                    color = GetPixel (gc1, x2, y2);
-                    rgb[0] += (GetRValue (color) * xf2 * yf2 / prod);
-                    rgb[1] += (GetGValue (color) * xf2 * yf2 / prod);
-                    rgb[2] += (GetBValue (color) * xf2 * yf2 / prod);
-                    xl2 += xf2;
-                    if (xl2 >= 1)
-                        x2++, xl2 -= 1;
-                } while (xr2 > 0);
-                xr2 = o2n.x;
-                yl2 += yf2;
-                if (yl2 >= 1)
-                    y2++, yl2 -= 1;
-            } while (yr2 > 0);
-            yr2 = o2n.y;
-            SetPixel (gc2, xp, yp, RGB (rgb[0], rgb[1], rgb[2]));
-            x = x2;
-            xr = xr2;
-            xl = xl2;
-        }
-        y = y2;
-        yr = yr2;
-        yl = yl2;
-    }
-    DeleteDC (gc1);
-    DeleteDC (gc2);
-    if (dir == 1) {
-        if (bitmap->u.bmap.scaled)
-            DeleteObject (bitmap->u.bmap.scaled);
-        bitmap->u.bmap.scaled = spix;
-        bitmap->scale = scale;
-    }
-    return 0;
-}
-
-int GCgetmousecoords (Gwidget_t *widget, Gpoint_t *gpp, int *count) {
-    PIXpoint_t pp;
-    POINT p;
-    int n1, n2, n3;
-
-    GetCursorPos (&p);
-    ScreenToClient (widget->w, &p);
-    pp.x = p.x, pp.y = p.y;
-    *gpp = ppixtodraw (widget, pp);
-    n1 = GetAsyncKeyState (VK_LBUTTON);
-    n2 = GetAsyncKeyState (VK_MBUTTON);
-    n3 = GetAsyncKeyState (VK_RBUTTON);
-    *count = (n1 < 0 ? 1 : 0) + (n2 < 0 ? 1 : 0) + (n3 < 0 ? 1 : 0);
-    return 0;
-}
-
-static void setgattr (Gwidget_t *widget, Ggattr_t *ap) {
-    HBRUSH brush, pbrush;
-    HPEN pen, ppen;
-    PALETTEENTRY *colorp;
-    long color, mode, style, width, flag, pati;
-    double intens;
-
-    if (!(ap->flags & G_GATTRCOLOR))
-        ap->color = WCU->defgattr.color;
-    if (!(ap->flags & G_GATTRWIDTH))
-        ap->width = WCU->defgattr.width;
-    if (!(ap->flags & G_GATTRMODE))
-        ap->mode = WCU->defgattr.mode;
-    if (!(ap->flags & G_GATTRFILL))
-        ap->fill = WCU->defgattr.fill;
-    if (!(ap->flags & G_GATTRSTYLE))
-        ap->style = WCU->defgattr.style;
-    flag = FALSE;
-    mode = ap->mode;
-    if (mode != WCU->gattr.mode) {
-        WCU->gattr.mode = mode;
-        SetROP2 (GC, (int) mode);
-    }
-    WCU->gattr.fill = ap->fill;
-    color = ap->color;
-    if (color >= G_MAXCOLORS || !(WCU->colors[color].inuse))
-        color = 1;
-    if (color != WCU->gattr.color)
-        WCU->gattr.color = color, flag = TRUE;
-    width = ap->width;
-    if (width != WCU->gattr.width)
-        WCU->gattr.width = width, flag = TRUE;
-    style = ap->style;
-    if (style != WCU->gattr.style)
-        WCU->gattr.style = style, flag = TRUE;
-
-    if (!flag)
-        return;
-    WCU->gattr.color = color;
-    if (Gdepth == 1) {
-        colorp = &WCU->colors[color].color;
-        intens = (
-            0.3 * colorp->peBlue + 0.59 * colorp->peRed +
-            0.11 * colorp->peGreen
-        ) / 255.0;
-        pati = (intens <= 0.0625) ? 16 : -16.0 * (log (intens) / 2.7725887222);
-        brush = WCU->grays[pati];
-    } else
-        brush = CreateSolidBrush (PALETTEINDEX (WCU->gattr.color));
-    pbrush = SelectObject (GC, brush);
-    if (Gdepth != 1)
-        DeleteObject (pbrush);
-    pen = CreatePen (
-        (int) gstyles[WCU->gattr.style], WCU->gattr.width,
-        PALETTEINDEX (WCU->gattr.color)
-    );
-    ppen = SelectObject (GC, pen);
-    DeleteObject (ppen);
-    SetTextColor (GC, PALETTEINDEX (WCU->gattr.color));
-}
-
-static PIXrect_t rdrawtopix (Gwidget_t *widget, Grect_t gr) {
-    PIXrect_t pr;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    pr.o.x = tvx * (gr.o.x - WCU->wrect.o.x) / twx + 0.5;
-    pr.o.y = tvy * (1.0  - (gr.c.y - WCU->wrect.o.y) / twy) + 0.5;
-    pr.c.x = tvx * (gr.c.x - WCU->wrect.o.x) / twx + 0.5;
-    pr.c.y = tvy * (1.0  - (gr.o.y - WCU->wrect.o.y) / twy) + 0.5;
-    return pr;
-}
-
-static PIXpoint_t pdrawtopix (Gwidget_t *widget, Gpoint_t gp) {
-    PIXpoint_t pp;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    pp.x = tvx * (gp.x - WCU->wrect.o.x) / twx + 0.5;
-    pp.y = tvy * (1.0  - (gp.y - WCU->wrect.o.y) / twy) + 0.5;
-    return pp;
-}
-
-static PIXsize_t sdrawtopix (Gwidget_t *widget, Gsize_t gs) {
-    PIXsize_t ps;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    ps.x = tvx * (gs.x - 1) / twx + 1.5;
-    ps.y = tvy * (gs.y - 1) / twy + 1.5;
-    return ps;
-}
-
-Gpoint_t ppixtodraw (Gwidget_t *widget, PIXpoint_t pp) {
-    Gpoint_t gp;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    gp.x = (pp.x / tvx) * twx + WCU->wrect.o.x;
-    gp.y = (1.0 - pp.y / tvy) * twy + WCU->wrect.o.y;
-    return gp;
-}
-
-static Gsize_t spixtodraw (Gwidget_t *widget, PIXsize_t ps) {
-    Gsize_t gs;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    gs.x = ((ps.x - 1) / tvx) * twx + 1;
-    gs.y = ((ps.y - 1) / tvy) * twy + 1;
-    return gs;
-}
-
-static Grect_t rpixtodraw (Gwidget_t *widget, PIXrect_t pr) {
-    Grect_t gr;
-    double tvx, tvy, twx, twy, n;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    gr.o.x = (pr.o.x / tvx) * twx + WCU->wrect.o.x;
-    gr.o.y = (1.0 - pr.c.y / tvy) * twy + WCU->wrect.o.y;
-    gr.c.x = (pr.c.x / tvx) * twx + WCU->wrect.o.x;
-    gr.c.y = (1.0 - pr.o.y / tvy) * twy + WCU->wrect.o.y;
-    if (gr.o.x > gr.c.x)
-        n = gr.o.x, gr.o.x = gr.c.x, gr.c.x = n;
-    if (gr.o.y > gr.c.y)
-        n = gr.o.y, gr.o.y = gr.c.y, gr.c.y = n;
-    return gr;
-}
-
-static PIXrect_t rdrawtobpix (Gbitmap_t *bitmap, Grect_t gr) {
-    PIXrect_t pr;
-    double tvy;
-
-    tvy = (int) ((bitmap->size.y - 1) * bitmap->scale.y);
-    pr.o.x = gr.o.x + 0.5;
-    pr.o.y = tvy - gr.c.y + 0.5;
-    pr.c.x = gr.c.x + 0.5;
-    pr.c.y = tvy - gr.o.y + 0.5;
-    return pr;
-}
-
-static PIXpoint_t pdrawtobpix (Gbitmap_t *bitmap, Gpoint_t gp) {
-    PIXpoint_t pp;
-    double tvy;
-
-    tvy = (int) ((bitmap->size.y - 1) * bitmap->scale.y);
-    pp.x = gp.x + 0.5;
-    pp.y = tvy - gp.y + 0.5;
-    return pp;
-}
-
-void Gadjustclip (Gwidget_t *widget) {
-    Gwidget_t *parent;
-    PIXrect_t pr;
-    RECT r1, r2, r3;
-
-    parent = &Gwidgets[widget->pwi];
-    GetWindowRect (widget->w, &r1);
-    GetClientRect (parent->w, &r2);
-    GetWindowRect (parent->w, &r3);
-    pr.o.x = max (0, -(r1.left - r3.left));
-    pr.o.y = max (0, -(r1.top - r3.top));
-    pr.c.x = min (r1.right - r1.left, pr.o.x + r2.right - r2.left);
-    pr.c.y = min (r1.bottom - r1.top, pr.o.y + r2.bottom - r2.top);
-    pr.c.x = max (pr.o.x, pr.c.x);
-    pr.c.y = max (pr.o.y, pr.c.y);
-    WCU->clip = rpixtodraw (widget, pr);
-}
diff --git a/cmd/lefty/ws/mswin32/gcommon.c b/cmd/lefty/ws/mswin32/gcommon.c
deleted file mode 100644 (file)
index e63ccf0..0000000
+++ /dev/null
@@ -1,700 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include <stdbool.h>
-
-#include <cgraph/exit.h>
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-#define WCU widget->u.c
-#define WVU widget->u.v
-
-FILE *Gxfp;
-int Gxfd;
-int Gpopdownflag;
-int Gdepth;
-int Gnocallbacks;
-int menuselected;
-int menupoped;
-
-char *Gbufp = NULL;
-int Gbufn = 0, Gbufi = 0;
-
-PIXpoint_t *Gppp;
-int Gppn, Gppi;
-
-Gfont_t *Gfontp;
-int Gfontn;
-
-static HFONT deffont;
-static int twobmouse;
-static HWND palettechanged;
-
-LRESULT CALLBACK LeftyWndProc (HWND, UINT, WPARAM, LPARAM);
-LRESULT CALLBACK ArrayWndProc (HWND, UINT, WPARAM, LPARAM);
-LRESULT CALLBACK CanvasWndProc (HWND, UINT, WPARAM, LPARAM);
-LRESULT CALLBACK LabelWndProc (HWND, UINT, WPARAM, LPARAM);
-LRESULT CALLBACK ScrollWndProc (HWND, UINT, WPARAM, LPARAM);
-
-static void processcommand (Gwidget_t *, WPARAM, LPARAM);
-static void handleresize (Gwidget_t *);
-
-int Ginitgraphics (void) {
-    WNDCLASS wc;
-    HDC hdc;
-    ATOM rtn;
-
-    if (!hprevinstance) {
-        wc.style = NULL;
-        wc.lpfnWndProc = LeftyWndProc;
-        wc.cbClsExtra = 0;
-        wc.cbWndExtra = 0;
-        wc.hInstance = hinstance;
-        wc.hIcon = LoadIcon ((HINSTANCE) NULL, IDI_APPLICATION);
-        wc.hCursor = LoadCursor ((HINSTANCE) NULL, IDC_ARROW);
-        wc.hbrBackground = GetStockObject (WHITE_BRUSH);
-        wc.lpszMenuName = 0;
-        wc.lpszClassName = "LeftyClass";
-        if (!(rtn = RegisterClass (&wc)))
-            panic1 (POS, "GXinit", "register class rtn = %d", (int) rtn);
-
-        wc.style = NULL;
-        wc.lpfnWndProc = ArrayWndProc;
-        wc.cbClsExtra = 0;
-        wc.cbWndExtra = 0;
-        wc.hInstance = hinstance;
-        wc.hIcon = LoadIcon ((HINSTANCE) NULL, IDI_APPLICATION);
-        wc.hCursor = LoadCursor ((HINSTANCE) NULL, IDC_ARROW);
-        wc.hbrBackground = GetStockObject (WHITE_BRUSH);
-        wc.lpszMenuName = 0;
-        wc.lpszClassName = "ArrayClass";
-        if (!(rtn = RegisterClass (&wc)))
-            panic1 (POS, "GXinit", "register class rtn = %d", (int) rtn);
-
-        wc.style = CS_OWNDC;
-        wc.lpfnWndProc = CanvasWndProc;
-        wc.cbClsExtra = 0;
-        wc.cbWndExtra = 0;
-        wc.hInstance = hinstance;
-        wc.hIcon = LoadIcon ((HINSTANCE) NULL, IDI_APPLICATION);
-        wc.hCursor = NULL;
-        wc.hbrBackground = GetStockObject (WHITE_BRUSH);
-        wc.lpszMenuName = 0;
-        wc.lpszClassName = "CanvasClass";
-        if (!(rtn = RegisterClass (&wc)))
-            panic1 (POS, "GXinit", "register class rtn = %d", (int) rtn);
-
-        wc.style = NULL;
-        wc.lpfnWndProc = ScrollWndProc;
-        wc.cbClsExtra = 0;
-        wc.cbWndExtra = 0;
-        wc.hInstance = hinstance;
-        wc.hIcon = LoadIcon ((HINSTANCE) NULL, IDI_APPLICATION);
-        wc.hCursor = LoadCursor ((HINSTANCE) NULL, IDC_ARROW);
-        wc.hbrBackground = GetStockObject (WHITE_BRUSH);
-        wc.lpszMenuName = 0;
-        wc.lpszClassName = "ScrollClass";
-        if (!(rtn = RegisterClass (&wc)))
-            panic1 (POS, "GXinit", "register class rtn = %d", (int) rtn);
-
-        wc.style = NULL;
-        wc.lpfnWndProc = LabelWndProc;
-        wc.cbClsExtra = 0;
-        wc.cbWndExtra = 0;
-        wc.hInstance = hinstance;
-        wc.hIcon = LoadIcon ((HINSTANCE) NULL, IDI_APPLICATION);
-        wc.hCursor = LoadCursor ((HINSTANCE) NULL, IDC_ARROW);
-        wc.hbrBackground = GetStockObject (WHITE_BRUSH);
-        wc.lpszMenuName = 0;
-        wc.lpszClassName = "LabelClass";
-        if (!(rtn = RegisterClass (&wc)))
-            panic1 (POS, "GXinit", "register class rtn = %d", (int) rtn);
-    }
-    if (getenv ("LEFTY3BMOUSE"))
-        twobmouse = FALSE;
-    else
-        twobmouse = TRUE;
-    hdc = GetDC ((HWND) NULL);
-    Gdepth = GetDeviceCaps (hdc, BITSPIXEL);
-    deffont = GetStockObject (SYSTEM_FONT);
-#ifndef FEATURE_MS
-    if (!(Gxfp = fopen ("/dev/windows", "r")))
-        panic1 (POS, "GXinit", "cannot open windows device");
-    Gxfd = fileno (Gxfp);
-#endif
-    Gpopdownflag = FALSE;
-    Gbufp = Marrayalloc ((long) BUFINCR * BUFSIZE);
-    Gbufn = BUFINCR;
-    Gppp = Marrayalloc ((long) PPINCR * PPSIZE);
-    Gppn = PPINCR;
-    Gfontp = Marrayalloc ((long) FONTSIZE);
-    Gfontn = 1;
-    Gfontp[0].name = strdup ("default");
-    if (!Gdefaultfont)
-        Gfontp[0].font = deffont;
-    else if (Gdefaultfont[0] != '\000')
-        Gfontp[0].font = CreateFont (
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Gdefaultfont
-        );
-    else
-        Gfontp[0].font = NULL;
-    ReleaseDC ((HWND) NULL, hdc);
-    Gnocallbacks = false;
-    return 0;
-}
-
-int Gtermgraphics (void) {
-    int fi;
-
-    for (fi = 0; fi < Gfontn; fi++)
-        free (Gfontp[fi].name);
-    Marrayfree (Gfontp), Gfontp = NULL, Gfontn = 0;
-    Marrayfree (Gppp), Gppp = NULL, Gppn = 0;
-    Marrayfree (Gbufp), Gbufp = NULL, Gbufn = 0;
-    return 0;
-}
-
-int Gsync (void) {
-    return 0;
-}
-
-int Gresetbstate (int wi) {
-    Gcw_t *cw;
-    int bn;
-
-    cw = Gwidgets[wi].u.c;
-    bn = cw->bstate[0] + cw->bstate[1] + cw->bstate[2];
-    cw->bstate[0] = cw->bstate[1] = cw->bstate[2] = 0;
-    cw->buttonsdown -= bn;
-    Gbuttonsdown -= bn;
-    return 0;
-}
-
-int Gprocessevents (int waitflag, int mode) {
-    MSG msg;
-    int rtn;
-
-    rtn = 0;
-    switch (waitflag) {
-    case TRUE:
-        if (!GetMessage(&msg, (HWND) NULL, (UINT) NULL, (UINT) NULL))
-            graphviz_exit(msg.wParam);
-        TranslateMessage(&msg);
-        DispatchMessage(&msg);
-        if (mode == G_ONEEVENT)
-            return 1;
-        rtn = 1;
-        /* FALL THROUGH */
-    case FALSE:
-        while (PeekMessage(&msg, (HWND) 0, (UINT) 0, (UINT) 0, PM_REMOVE)) {
-            if (msg.message == WM_QUIT)
-                graphviz_exit(msg.wParam);
-            TranslateMessage(&msg);
-            DispatchMessage(&msg);
-            if (mode == G_ONEEVENT)
-                return 1;
-            rtn = 1;
-        }
-        break;
-    }
-    return rtn;
-}
-
-LRESULT CALLBACK LeftyWndProc (
-    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
-) {
-    Gwidget_t *widget;
-    WINDOWPOS *wpos;
-    Gevent_t gev;
-
-    widget = findwidget (hwnd, G_VIEWWIDGET);
-    switch (message) {
-    case WM_WINDOWPOSCHANGED:
-        if (Gnocallbacks || !widget)
-            return (DefWindowProc(hwnd, message, wparam, lparam));
-        wpos = (WINDOWPOS *) lparam;
-        if (!(wpos->flags & SWP_NOSIZE))
-            handleresize (widget);
-        break;
-    case WM_COMMAND:
-        if (Gnocallbacks || !widget)
-            return (DefWindowProc(hwnd, message, wparam, lparam));
-        processcommand (widget, wparam, lparam);
-        break;
-    case WM_CLOSE:
-        if (!widget)
-            graphviz_exit(0);
-        if (WVU->closing)
-            DestroyWindow (hwnd);
-        if (Gnocallbacks)
-            graphviz_exit(0);
-        gev.type = 0, gev.code = 0, gev.data = 0;
-        gev.wi = widget - &Gwidgets[0];
-        if (WVU->func)
-            (*WVU->func) (&gev);
-        else
-            graphviz_exit(0);
-        break;
-    case WM_PALETTECHANGED:
-        palettechanged = (HWND) wparam;
-        break;
-    default:
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    }
-    return 0;
-}
-
-LRESULT CALLBACK ArrayWndProc (
-    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
-) {
-    Gwidget_t *widget;
-    WINDOWPOS *wpos;
-
-    if (Gnocallbacks || !(widget = findwidget (hwnd, G_ARRAYWIDGET)))
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    switch (message) {
-    case WM_WINDOWPOSCHANGED:
-        wpos = (WINDOWPOS *) lparam;
-        if (!(wpos->flags & SWP_NOSIZE))
-            handleresize (widget);
-        break;
-    case WM_COMMAND:
-        processcommand (widget, wparam, lparam);
-        break;
-    default:
-        return (DefWindowProc (hwnd, message, wparam, lparam));
-    }
-    return 0;
-}
-
-LRESULT CALLBACK CanvasWndProc (
-    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
-) {
-    Gwidget_t *widget;
-    WINDOWPOS *wpos;
-    PIXpoint_t pp;
-    Gevent_t gev;
-    POINT p;
-    int wi, bn;
-
-    static int cntlflag;
-
-    if (Gnocallbacks || !(widget = findwidget (hwnd, G_CANVASWIDGET)))
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    Gpopdownflag = FALSE;
-    switch (message) {
-    case WM_PAINT:
-        if (palettechanged != hwnd)
-            RealizePalette (widget->u.c->gc);
-        Gneedredraw = widget->u.c->needredraw = TRUE;
-        Gadjustclip (widget);
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    case WM_WINDOWPOSCHANGED:
-        wpos = (WINDOWPOS *) lparam;
-        if (!(wpos->flags & SWP_NOSIZE))
-            handleresize (widget);
-        return 0;
-    case WM_MOUSEACTIVATE:
-        SetFocus (widget->w);
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    case WM_COMMAND:
-        processcommand (widget, wparam, lparam);
-        return 0;
-    case WM_CHAR:
-        gev.type = G_KEYBD;
-        gev.code = G_DOWN;   /* I don't know how to get up events so I make */
-        Gpopdownflag = TRUE; /* the code after this switch send the up event */
-        gev.data = wparam;
-        GetCursorPos (&p);
-        ScreenToClient (widget->w, &p);
-        pp.x = p.x, pp.y = p.y;
-        gev.p = ppixtodraw (widget, pp);
-        /* continues after the end of this switch */
-        break;
-    case WM_LBUTTONDOWN:
-    case WM_LBUTTONUP:
-    case WM_MBUTTONDOWN:
-    case WM_MBUTTONUP:
-    case WM_RBUTTONDOWN:
-    case WM_RBUTTONUP:
-        gev.type = G_MOUSE;
-        if (twobmouse) {
-            if (message == WM_LBUTTONDOWN && (wparam & MK_CONTROL))
-                message = WM_MBUTTONDOWN, cntlflag = TRUE;
-            if (message == WM_LBUTTONUP && cntlflag)
-                message = WM_MBUTTONUP, cntlflag = FALSE;
-        }
-        switch (message) {
-        case WM_LBUTTONDOWN: gev.code = G_DOWN, gev.data = G_LEFT;   break;
-        case WM_LBUTTONUP:   gev.code = G_UP,   gev.data = G_LEFT;   break;
-        case WM_MBUTTONDOWN: gev.code = G_DOWN, gev.data = G_MIDDLE; break;
-        case WM_MBUTTONUP:   gev.code = G_UP,   gev.data = G_MIDDLE; break;
-        case WM_RBUTTONDOWN: gev.code = G_DOWN, gev.data = G_RIGHT;  break;
-        case WM_RBUTTONUP:   gev.code = G_UP,   gev.data = G_RIGHT;  break;
-        }
-        pp.x = LOWORD (lparam), pp.y = HIWORD (lparam);
-        gev.p = ppixtodraw (widget, pp);
-        bn = WCU->bstate[gev.data];
-        WCU->bstate[gev.data] = (gev.code == G_DOWN) ? 1 : 0;
-        bn = WCU->bstate[gev.data] - bn;
-        widget->u.c->buttonsdown += bn;
-        Gbuttonsdown += bn;
-        /* continues after the end of this switch */
-        break;
-    default:
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    }
-    wi = gev.wi = widget - &Gwidgets[0];
-    if (widget->u.c->func)
-        (*widget->u.c->func) (&gev);
-    if (Gpopdownflag) {
-        Gpopdownflag = FALSE;
-        if (gev.code == G_DOWN) {
-            gev.code = G_UP;
-            widget = &Gwidgets[wi];
-            WCU->bstate[gev.data] = 0;
-            widget->u.c->buttonsdown--;
-            Gbuttonsdown--;
-            if (widget->inuse && widget->u.c->func)
-                (*widget->u.c->func) (&gev);
-        }
-    }
-    return 0;
-}
-
-LRESULT CALLBACK LabelWndProc (
-    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
-) {
-    Gwidget_t *widget;
-    PAINTSTRUCT paintstruct;
-    WINDOWPOS *wpos;
-    Gevent_t gev;
-    RECT r;
-    HDC hdc;
-    int wi;
-
-    if (Gnocallbacks || !(widget = findwidget (hwnd, G_LABELWIDGET)))
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    switch (message) {
-    case WM_PAINT:
-        hdc = BeginPaint (widget->w, &paintstruct);
-        GetWindowText (widget->w, &Gbufp[0], Gbufn);
-        GetClientRect (widget->w, &r);
-        DrawText (hdc, (LPCSTR) &Gbufp[0], strlen (Gbufp), &r, DT_LEFT);
-        EndPaint (widget->w, &paintstruct);
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    case WM_WINDOWPOSCHANGED:
-        wpos = (WINDOWPOS *) lparam;
-        if (!(wpos->flags & SWP_NOSIZE))
-            handleresize (widget);
-        return 0;
-    case WM_COMMAND:
-        processcommand (widget, wparam, lparam);
-        return 0;
-    case WM_KEYDOWN:
-    case WM_KEYUP:
-        gev.type = G_KEYBD;
-        gev.code = (message == WM_KEYDOWN) ? G_DOWN : G_UP;
-        gev.data = wparam;
-        /* continues after the end of this switch */
-        break;
-    case WM_LBUTTONDOWN:
-    case WM_LBUTTONUP:
-    case WM_MBUTTONDOWN:
-    case WM_MBUTTONUP:
-    case WM_RBUTTONDOWN:
-    case WM_RBUTTONUP:
-        gev.type = G_MOUSE;
-        if (wparam & MK_CONTROL) {
-            if (message == WM_LBUTTONDOWN)
-                message = WM_MBUTTONDOWN;
-            else if (message == WM_LBUTTONUP)
-                message = WM_MBUTTONUP;
-        }
-        switch (message) {
-        case WM_LBUTTONDOWN: gev.code = G_DOWN, gev.data = G_LEFT;   break;
-        case WM_LBUTTONUP:   gev.code = G_UP,   gev.data = G_LEFT;   break;
-        case WM_MBUTTONDOWN: gev.code = G_DOWN, gev.data = G_MIDDLE; break;
-        case WM_MBUTTONUP:   gev.code = G_UP,   gev.data = G_MIDDLE; break;
-        case WM_RBUTTONDOWN: gev.code = G_DOWN, gev.data = G_RIGHT;  break;
-        case WM_RBUTTONUP:   gev.code = G_UP,   gev.data = G_RIGHT;  break;
-        }
-        /* continues after the end of this switch */
-        break;
-    default:
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    }
-    wi = gev.wi = widget - &Gwidgets[0];
-    if (widget->u.l->func)
-        (*widget->u.l->func) (&gev);
-    if (Gpopdownflag) {
-        Gpopdownflag = FALSE;
-        if (gev.type == G_MOUSE && gev.code == G_DOWN) {
-            gev.code = G_UP;
-            widget = &Gwidgets[wi];
-            if (widget->inuse && widget->u.l->func)
-                (*widget->u.l->func) (&gev);
-        }
-    }
-    return 0;
-}
-
-LRESULT CALLBACK ScrollWndProc (
-    HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam
-) {
-    Gwidget_t *widget, *child;
-    WINDOWPOS *wpos;
-    PIXpoint_t po;
-    RECT r;
-    int dummy, dx, dy, wi;
-
-    if (Gnocallbacks || !(widget = findwidget (hwnd, G_SCROLLWIDGET)))
-        return (DefWindowProc(hwnd, message, wparam, lparam));
-    switch (message) {
-    case WM_WINDOWPOSCHANGED:
-        wpos = (WINDOWPOS *) lparam;
-        if (!(wpos->flags & SWP_NOSIZE))
-            handleresize (widget);
-        break;
-    case WM_HSCROLL:
-    case WM_VSCROLL:
-        for (wi = 0; wi < Gwidgetn; wi++) {
-            child = &Gwidgets[wi];
-            if (child->inuse && child->pwi == widget - &Gwidgets[0])
-                break;
-        }
-        if (wi == Gwidgetn)
-            return (DefWindowProc(hwnd, message, wparam, lparam));
-        GetClientRect (widget->w, &r);
-        GetScrollRange (widget->w, SB_HORZ, &dummy, &dx);
-        GetScrollRange (widget->w, SB_VERT, &dummy, &dy);
-        po.x = GetScrollPos (widget->w, SB_HORZ);
-        po.y = GetScrollPos (widget->w, SB_VERT);
-        switch (message) {
-        case WM_HSCROLL:
-            switch (LOWORD (wparam)) {
-            case SB_BOTTOM:        po.x = dx;                  break;
-            case SB_LINEDOWN:      po.x += 10;                 break;
-            case SB_LINEUP:        po.x -= 10;                 break;
-            case SB_PAGEDOWN:      po.x += (r.right - r.left); break;
-            case SB_PAGEUP:        po.x -= (r.right - r.left); break;
-            case SB_THUMBPOSITION: po.x = HIWORD (wparam);     break;
-            case SB_THUMBTRACK:    po.x = HIWORD (wparam);     break;
-            case SB_TOP:           po.x = 0;                   break;
-            }
-            po.x = min (po.x, dx);
-            po.x = max (po.x, 0);
-            SetScrollPos (widget->w, SB_HORZ, po.x, TRUE);
-            SetWindowPos (
-                child->w, (HWND) NULL, -po.x, -po.y, 0, 0,
-                SWP_NOSIZE | SWP_NOZORDER
-            );
-            break;
-        case WM_VSCROLL:
-            switch (LOWORD (wparam)) {
-            case SB_BOTTOM:        po.y = dy;                  break;
-            case SB_LINEDOWN:      po.y += 10;                 break;
-            case SB_LINEUP:        po.y -= 10;                 break;
-            case SB_PAGEDOWN:      po.y += (r.bottom - r.top); break;
-            case SB_PAGEUP:        po.y -= (r.bottom - r.top); break;
-            case SB_THUMBPOSITION: po.y = HIWORD (wparam);     break;
-            case SB_THUMBTRACK:    po.y = HIWORD (wparam);     break;
-            case SB_TOP:           po.y = 0;                   break;
-            }
-            po.y = min (po.y, dy);
-            po.y = max (po.y, 0);
-            SetScrollPos (widget->w, SB_VERT, po.y, TRUE);
-            SetWindowPos (
-                child->w, (HWND) NULL, -po.x, -po.y, 0, 0,
-                SWP_NOSIZE | SWP_NOZORDER
-            );
-            break;
-        }
-        break;
-    default:
-        return (DefWindowProc (hwnd, message, wparam, lparam));
-    }
-    return 0;
-}
-
-static void processcommand (Gwidget_t *widget, WPARAM wparam, LPARAM lparam) {
-    Gwidget_t *child;
-    WORD l;
-    int n;
-
-    if (lparam == 0) { /* it's a menu */
-        if (LOWORD (wparam) != 999)
-            menuselected = LOWORD (wparam);
-        menupoped = FALSE;
-        return;
-    }
-    if (!(LOWORD (wparam) > 0 && LOWORD (wparam) < Gwidgetn))
-        return;
-    child = &Gwidgets[LOWORD (wparam)];
-    if (!child->inuse)
-        return;
-
-    switch (child->type) {
-    case G_TEXTWIDGET:
-        if (HIWORD (wparam) == EN_CHANGE) { /* it's a text widget message */
-            if ((n = SendMessage (child->w, EM_GETLINECOUNT, 0, 0L)) < 2)
-                return;
-            *((WORD *) &Gbufp[0]) = Gbufn - 1;
-            l = SendMessage (
-                child->w, EM_GETLINE, n - 1, (LPARAM) (LPSTR) &Gbufp[0]
-            );
-            if (l != 0)
-                return; /* no carriage return yet */
-            *((WORD *) &Gbufp[0]) = Gbufn - 1;
-            l = SendMessage (
-                child->w, EM_GETLINE, n - 2, (LPARAM) (LPSTR) &Gbufp[0]
-            );
-            Gbufp[l] = 0;
-            if (l > 0 && child->u.t->func)
-                (*child->u.t->func) (child - &Gwidgets[0], &Gbufp[0]);
-        }
-        break;
-    case G_BUTTONWIDGET:
-        if (child->u.b->func)
-            (*child->u.b->func) (child - &Gwidgets[0], child->udata);
-        break;
-    }
-}
-
-void Gadjustwrect (Gwidget_t *parent, PIXsize_t *psp) {
-    RECT r;
-
-    GetClientRect (parent->w, &r);
-    switch (parent->type) {
-    case G_ARRAYWIDGET:
-        if (parent->u.a->data.type == G_AWHARRAY)
-            psp->y = r.bottom - r.top;
-        else
-            psp->x = r.right - r.left;
-        break;
-    case G_SCROLLWIDGET:
-        psp->x = max (psp->x, r.right - r.left);
-        psp->y = max (psp->y, r.bottom - r.top);
-        break;
-    case G_VIEWWIDGET:
-    case G_QUERYWIDGET:
-        psp->x = r.right - r.left;
-        psp->y = r.bottom - r.top;
-        break;
-    }
-}
-
-static void handleresize (Gwidget_t *widget) {
-    Gwidget_t *parent, *child;
-    PIXsize_t ps1, ps2;
-    PIXpoint_t po;
-    DWORD wflags1, wflags2;
-    RECT r;
-    int dx, dy, wi, i;
-
-    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
-    wflags2 = SWP_NOSIZE | SWP_NOZORDER;
-    GetWindowRect (widget->w, &r);
-    ps1.x = r.right - r.left, ps1.y = r.bottom - r.top;
-    ps2 = ps1;
-    /* first, take care of parent */
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    if (!parent)
-        goto handlechildren;
-    switch (parent->type) {
-    case G_VIEWWIDGET:
-        Gadjustwrect (parent, &ps1);
-        if (ps1.x != ps2.x || ps1.y != ps2.y) {
-            Gnocallbacks = true;
-            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps1.x, ps1.y, wflags1);
-            Gnocallbacks = false;
-        }
-        break;
-    case G_ARRAYWIDGET:
-        Gnocallbacks = true;
-        Gawresize (parent);
-        Gnocallbacks = false;
-        break;
-    case G_SCROLLWIDGET:
-        Gnocallbacks = true;
-        for (i = 0; i  < 2; i++) {
-            Gadjustwrect (parent, &ps1);
-            if (ps1.x > ps2.x || ps1.y > ps2.y)
-                SetWindowPos (
-                    widget->w, (HWND) NULL, 0, 0, ps1.x, ps1.y, wflags1
-                );
-            GetClientRect (parent->w, &r);
-            ps2.x = r.right - r.left, ps2.y = r.bottom - r.top;
-            dx = max (0, ps1.x - ps2.x);
-            dy = max (0, ps1.y - ps2.y);
-            SetScrollRange (parent->w, SB_HORZ, 0, dx, TRUE);
-            SetScrollRange (parent->w, SB_VERT, 0, dy, TRUE);
-            po.x = GetScrollPos (parent->w, SB_HORZ);
-            po.y = GetScrollPos (parent->w, SB_VERT);
-            po.x = min (po.x, dx);
-            po.x = max (po.x, 0);
-            SetScrollPos (parent->w, SB_HORZ, po.x, TRUE);
-            po.y = min (po.y, dy);
-            po.y = max (po.y, 0);
-            SetScrollPos (parent->w, SB_VERT, po.y, TRUE);
-            SetWindowPos (widget->w, (HWND) NULL, -po.x, -po.y, 0, 0, wflags2);
-            ps2 = ps1;
-        }
-        Gnocallbacks = false;
-        break;
-    }
-
-handlechildren:
-    for (wi = 0; wi < Gwidgetn; wi++) {
-        child = &Gwidgets[wi];
-        if (child->inuse && child->pwi == widget - &Gwidgets[0])
-            break;
-    }
-    if (wi == Gwidgetn)
-        return;
-    GetWindowRect (child->w, &r);
-    ps1.x = r.right - r.left, ps1.y = r.bottom - r.top;
-    ps2 = ps1;
-    switch (widget->type) {
-    case G_VIEWWIDGET:
-        Gadjustwrect (widget, &ps1);
-        if (ps1.x != ps2.x || ps1.y != ps2.y)
-            SetWindowPos (child->w, (HWND) NULL, 0, 0, ps1.x, ps1.y, wflags1);
-        break;
-    case G_ARRAYWIDGET:
-        Gawresize (widget);
-        break;
-    case G_SCROLLWIDGET:
-        Gadjustwrect (widget, &ps1);
-        if (ps1.x > ps2.x || ps1.y > ps2.y)
-            SetWindowPos (child->w, (HWND) NULL, 0, 0, ps1.x, ps1.y, wflags1);
-        GetClientRect (widget->w, &r);
-        ps2.x = r.right - r.left, ps2.y = r.bottom - r.top;
-        dx = max (0, ps1.x - ps2.x);
-        dy = max (0, ps1.y - ps2.y);
-        SetScrollRange (widget->w, SB_HORZ, 0, dx, TRUE);
-        SetScrollRange (widget->w, SB_VERT, 0, dy, TRUE);
-        po.x = GetScrollPos (widget->w, SB_HORZ);
-        po.y = GetScrollPos (widget->w, SB_VERT);
-        po.x = min (po.x, dx);
-        po.x = max (po.x, 0);
-        SetScrollPos (widget->w, SB_HORZ, po.x, TRUE);
-        po.y = min (po.y, dy);
-        po.y = max (po.y, 0);
-        SetScrollPos (widget->w, SB_VERT, po.y, TRUE);
-        SetWindowPos (child->w, (HWND) NULL, -po.x, -po.y, 0, 0, wflags2);
-        break;
-    }
-}
diff --git a/cmd/lefty/ws/mswin32/gcommon.h b/cmd/lefty/ws/mswin32/gcommon.h
deleted file mode 100644 (file)
index b45d314..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-extern HANDLE hinstance, hprevinstance;
-
-/* point and rect structures */
-typedef POINT PIXxy_t;
-typedef PIXxy_t PIXpoint_t;
-typedef PIXxy_t PIXsize_t;
-typedef struct PIXrect_t {
-    PIXxy_t o, c;
-} PIXrect_t;
-
-extern int Gpopdownflag;
-extern int Gdepth;
-extern int Gnocallbacks;
-extern int menuselected;
-extern int menupoped;
-
-extern char *Gbufp;
-extern int Gbufn, Gbufi;
-#define BUFINCR 1024
-#define BUFSIZE sizeof (char)
-
-extern PIXpoint_t *Gppp;
-extern int Gppn, Gppi;
-#define PPINCR 100
-#define PPSIZE sizeof (PIXpoint_t)
-
-typedef struct Gfont_t {
-    char *name;
-    int size;
-    HFONT font;
-} Gfont_t;
-extern Gfont_t *Gfontp;
-extern int Gfontn;
-#define FONTSIZE sizeof (Gfont_t)
-#define SETFONT(font) { \
-    if (font != WCU->font) { \
-        WCU->font = font; \
-        SelectObject (GC, font); \
-    } \
-}
-
-#define GETSIZE(sin, sout, smin) ( \
-    sout.x = (sin.x > smin) ? sin.x + 0.5 : smin, \
-    sout.y = (sin.y > smin) ? sin.y + 0.5 : smin \
-)
-#define GETORIGIN(oin, oout) ( \
-    oout.x = oin.x + 0.5, oout.y = oin.y + 0.5 \
-)
-
-int Ginitgraphics (void);
-int Gtermgraphics (void);
-int Gsync (void);
-
-int GAcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GAsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GAgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GAdestroywidget (Gwidget_t *);
-
-int GBcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GBsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GBgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GBdestroywidget (Gwidget_t *);
-
-int GCcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GCsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GCgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GCdestroywidget (Gwidget_t *);
-int GCcanvasclear (Gwidget_t *);
-int GCsetgfxattr (Gwidget_t *, Ggattr_t *);
-int GCgetgfxattr (Gwidget_t *, Ggattr_t *);
-int GCarrow (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GCline (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GCbox (Gwidget_t *, Grect_t, Ggattr_t *);
-int GCpolygon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GCsplinegon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GCarc (Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
-int GCtext (
-    Gwidget_t *, Gtextline_t *, int, Gpoint_t,
-    char *, double, char *, Ggattr_t *
-);
-int GCgettextsize (Gwidget_t *, Gtextline_t *, int, char *, double, Gsize_t *);
-int GCcreatebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t);
-int GCdestroybitmap (Gbitmap_t *);
-int GCreadbitmap (Gwidget_t *, Gbitmap_t *, FILE *);
-int GCwritebitmap (Gbitmap_t *, FILE *);
-int GCbitblt (Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *, Ggattr_t *);
-int GCgetmousecoords (Gwidget_t *, Gpoint_t *, int *);
-
-int GLcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GLsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GLgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GLdestroywidget (Gwidget_t *);
-
-int GMcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GMsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GMgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GMdestroywidget (Gwidget_t *);
-int GMmenuaddentries (Gwidget_t *, int, char **);
-int GMmenudisplay (Gwidget_t *, Gwidget_t *);
-
-int GPcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GPsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GPgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GPdestroywidget (Gwidget_t *);
-int GPcanvasclear (Gwidget_t *);
-int GPsetgfxattr (Gwidget_t *, Ggattr_t *);
-int GPgetgfxattr (Gwidget_t *, Ggattr_t *);
-int GParrow (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GPline (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GPbox (Gwidget_t *, Grect_t, Ggattr_t *);
-int GPpolygon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GPsplinegon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GParc (Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
-int GPtext (
-    Gwidget_t *, Gtextline_t *, int, Gpoint_t,
-    char *, double, char *, Ggattr_t *
-);
-int GPcreatebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t);
-int GPdestroybitmap (Gbitmap_t *);
-int GPreadbitmap (Gwidget_t *, Gbitmap_t *, FILE *);
-int GPwritebitmap (Gbitmap_t *, FILE *);
-int GPbitblt (Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *, Ggattr_t *);
-
-int GQcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GQsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GQgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GQdestroywidget (Gwidget_t *);
-int GQqueryask (Gwidget_t *, char *, char *, char *, int);
-
-int GScreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GSsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GSgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GSdestroywidget (Gwidget_t *);
-
-int GTcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GTsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GTgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GTdestroywidget (Gwidget_t *);
-
-int GVcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GVsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GVgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GVdestroywidget (Gwidget_t *);
-
-void Gawinitialize (Gwidget_t *, int);
-void Gawdestroy (Gwidget_t *);
-void Gawresize (Gwidget_t *);
-void Gawinsertchild (Gwidget_t *, Gwidget_t *);
-void Gawdeletechild (Gwidget_t *, Gwidget_t *);
-
-void Gadjustwrect (Gwidget_t *, PIXsize_t *);
-void Gadjustclip (Gwidget_t *);
-Gpoint_t ppixtodraw (Gwidget_t *, PIXpoint_t);
diff --git a/cmd/lefty/ws/mswin32/glabel.c b/cmd/lefty/ws/mswin32/glabel.c
deleted file mode 100644 (file)
index 65c185f..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-#define WLU widget->u.l
-
-int GLcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    DWORD wflags;
-    char *s;
-    int ai;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    wflags = WS_CHILDWINDOW;
-    WLU->func = NULL;
-    ps.x = ps.y = MINLWSIZE;
-    s = "";
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINLWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            wflags |= WS_BORDER;
-            break;
-        case G_ATTRTEXT:
-            s = attrp[ai].u.t;
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WLU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    Gadjustwrect (parent, &ps);
-    if (!(widget->w = CreateWindow (
-        "LabelClass", s, wflags, 0, 0, ps.x, ps.y,
-        parent->w, (HMENU) (widget - &Gwidgets[0]), hinstance, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    ShowWindow (widget->w, SW_SHOW);
-    UpdateWindow (widget->w);
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawinsertchild (parent, widget);
-    return 0;
-}
-
-int GLsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Gwidget_t *parent;
-    PIXsize_t ps;
-    RECT r;
-    DWORD wflags1;
-    int ai;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINLWSIZE);
-            Gadjustwrect (parent, &ps);
-            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
-            r.top = r.left = 0;
-            r.bottom = ps.y, r.right = ps.x;
-            InvalidateRect (widget->w, NULL, FALSE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "borderwidth");
-            return -1;
-        case G_ATTRTEXT:
-            SetWindowText (widget->w, attrp[ai].u.t);
-            GetClientRect (widget->w, &r);
-            InvalidateRect (widget->w, &r, TRUE);
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            attrp[ai].u.func = WLU->func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GLgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    RECT r;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GetWindowRect (widget->w, &r);
-            attrp[ai].u.s.x = r.right - r.left;
-            attrp[ai].u.s.y = r.bottom - r.top;
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTGETATTR, "borderwidth");
-            return -1;
-        case G_ATTRTEXT:
-            GetWindowText (widget->w, &Gbufp[0], Gbufn);
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", widget->w);
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTREVENTCB:
-            attrp[ai].u.func = WLU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GLdestroywidget (Gwidget_t *widget) {
-    Gwidget_t *parent;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawdeletechild (parent, widget);
-    DestroyWindow (widget->w);
-    return 0;
-}
diff --git a/cmd/lefty/ws/mswin32/gmenu.c b/cmd/lefty/ws/mswin32/gmenu.c
deleted file mode 100644 (file)
index 27c8984..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-#define WMU widget->u.m
-
-int GMcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    if (!(widget->w = CreatePopupMenu ())) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    WMU->count = 0;
-    return 0;
-}
-
-int GMsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GMgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GMdestroywidget (Gwidget_t *widget) {
-    DestroyMenu (widget->w);
-    return 0;
-}
-
-int GMmenuaddentries (Gwidget_t *widget, int en, char **ep) {
-    int ei;
-
-    for (ei = 0; ei < en; ei++)
-        AppendMenu (widget->w, MF_ENABLED | MF_STRING, WMU->count++, ep[ei]);
-    return 0;
-}
-
-int GMmenudisplay (Gwidget_t *parent, Gwidget_t *widget) {
-    MSG msg;
-    POINT p;
-    UINT flag;
-
-    /* FIXME not only right button */
-    menupoped = TRUE;
-    menuselected = -1;
-    GetCursorPos (&p);
-    if (GetAsyncKeyState (VK_LBUTTON) < 0)
-        flag = TPM_LEFTALIGN | TPM_LEFTBUTTON;
-    else
-        flag = TPM_LEFTALIGN | TPM_RIGHTBUTTON;
-    TrackPopupMenu (widget->w, flag, p.x, p.y, 0, parent->w, NULL);
-    PostMessage (parent->w, WM_COMMAND, 999, 0);
-    if (!GetMessage(&msg, parent->w, WM_COMMAND, WM_COMMAND))
-        panic1 (POS, "GMmenudisplay", "exit code in GetMessage");
-    TranslateMessage(&msg);
-    DispatchMessage(&msg);
-    Gpopdownflag = TRUE;
-    return menuselected;
-}
diff --git a/cmd/lefty/ws/mswin32/gpcanvas.c b/cmd/lefty/ws/mswin32/gpcanvas.c
deleted file mode 100644 (file)
index 6c500d7..0000000
+++ /dev/null
@@ -1,1207 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-#include <math.h>
-#include <string.h>
-
-#define WPU widget->u.p
-#define WINDOW widget->u.p->window
-#define GC widget->u.p->gc
-
-static long gstyles[5] = {
-    /* G_SOLID */       PS_SOLID,
-    /* G_DASHED */      PS_DASH,
-    /* G_DOTTED */      PS_DOT,
-    /* G_LONGDASHED */  PS_DASH,
-    /* G_SHORTDASHED */ PS_DASH,
-};
-
-static char grays[][4] = {
-    { 0x00, 0x00, 0x00, 0x00 },
-    { 0x08, 0x00, 0x00, 0x00 },
-    { 0x08, 0x00, 0x02, 0x00 },
-    { 0x0A, 0x00, 0x02, 0x00 },
-    { 0x0A, 0x00, 0x0A, 0x00 },
-    { 0x0A, 0x04, 0x0A, 0x00 },
-    { 0x0A, 0x04, 0x0A, 0x01 },
-    { 0x0A, 0x05, 0x0A, 0x01 },
-    { 0x0A, 0x05, 0x0A, 0x05 },
-    { 0x0E, 0x05, 0x0A, 0x05 },
-    { 0x0E, 0x05, 0x0B, 0x05 },
-    { 0x0F, 0x05, 0x0B, 0x05 },
-    { 0x0F, 0x05, 0x0F, 0x05 },
-    { 0x0F, 0x0D, 0x0F, 0x05 },
-    { 0x0F, 0x0D, 0x0F, 0x07 },
-    { 0x0F, 0x0F, 0x0F, 0x07 },
-    { 0x0F, 0x0F, 0x0F, 0x0F }
-};
-
-char *Gpscanvasname = "out.emf";
-
-static void bezier (PIXpoint_t, PIXpoint_t, PIXpoint_t, PIXpoint_t);
-static HFONT findfont (char *, int);
-static int scalebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t, int, int);
-static void setgattr (Gwidget_t *, Ggattr_t *);
-
-static PIXrect_t  rdrawtopix (Gwidget_t *, Grect_t);
-static PIXpoint_t pdrawtopix (Gwidget_t *, Gpoint_t);
-static PIXsize_t  sdrawtopix (Gwidget_t *, Gsize_t);
-static PIXrect_t  rdrawtobpix (Gbitmap_t *, Grect_t);
-static PIXpoint_t pdrawtobpix (Gbitmap_t *, Gpoint_t);
-
-int GPcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXpoint_t po;
-    PIXsize_t ps;
-    PRINTDLG pd;
-    DOCINFO di;
-    DEVMODE *dmp;
-    /* the 2 here is to provide enough space for palPalEntry[0] and [1] */
-    LOGPALETTE pal[2];
-
-    HBRUSH brush;
-    HPEN pen;
-    HBITMAP bmap;
-    char *s, *s1;
-    int color, lflag, ai, dpix, dpiy, i;
-
-    s = Gpscanvasname;
-    lflag = FALSE;
-    po.x = po.y = 0;
-    ps.x = ps.y = MINPWSIZE;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            GETORIGIN (attrp[ai].u.p, po);
-            break;
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINPWSIZE);
-            break;
-        case G_ATTRNAME:
-            if (attrp[ai].u.t && attrp[ai].u.t[0])
-                s = attrp[ai].u.t;
-            break;
-        case G_ATTRMODE:
-            if (strcmp ("landscape", attrp[ai].u.t) == 0)
-                lflag = TRUE;
-            else if (strcmp ("portrait", attrp[ai].u.t) == 0)
-                lflag = FALSE;
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRCOLOR:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRVIEWPORT:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRWINDOW:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    s1 = s + strlen (s) - 3;
-    if (s1 > s && strncmp (s1, "emf", 3) == 0) {
-        WPU->mode = 1;
-        ps.x *= 8.235, ps.y *= 8.235;
-        if (!(GC = CreateEnhMetaFile (NULL, s, NULL, "LEFTY\\0GRAPH\\0\\0"))) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-    } else { /* open the printer device */
-        WPU->mode = 2;
-        di.cbSize = sizeof (DOCINFO);
-        di.lpszDocName = NULL;
-        di.lpszOutput = NULL;
-        di.lpszDatatype = "LEFTY";
-        di.fwType = 0;
-        pd.lStructSize = sizeof (pd);
-        pd.hwndOwner = NULL;
-        pd.hDevMode = NULL;
-        pd.hDevNames = NULL;
-        pd.hDC = NULL;
-        pd.Flags = PD_RETURNDC | PD_RETURNDEFAULT;
-        pd.nFromPage = 0;
-        pd.nToPage = 0;
-        pd.nMinPage = 0;
-        pd.nMaxPage = 0;
-        pd.nCopies = 1;
-        pd.hInstance = NULL;
-        pd.lCustData = NULL;
-        pd.lpfnPrintHook = NULL;
-        pd.lpfnSetupHook = NULL;
-        pd.lpPrintTemplateName = NULL;
-        pd.lpSetupTemplateName = NULL;
-        pd.hPrintTemplate = NULL;
-        pd.hSetupTemplate = NULL;
-        if (!PrintDlg (&pd)) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-        if (lflag && pd.hDevMode) {
-            dmp = (DEVMODE *) GlobalLock (pd.hDevMode);
-            dmp->dmOrientation = DMORIENT_LANDSCAPE;
-            GlobalUnlock (pd.hDevMode);
-            pd.Flags = PD_RETURNDC;
-            if (!PrintDlg (&pd)) {
-                Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-                return -1;
-            }
-        }
-        GC = pd.hDC;
-        dpix = GetDeviceCaps (GC, LOGPIXELSX);
-        if (dpix != 300)
-            ps.x = ps.x * (double) dpix / 300.0;
-        dpiy = GetDeviceCaps (GC, LOGPIXELSY);
-        if (dpiy != 300)
-            ps.y = ps.y * (double) dpiy / 300.0;
-        if (StartDoc (GC, &di) <= 0 || StartPage (GC) <= 0) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-    }
-    WPU->wrect.o.x = 0.0, WPU->wrect.o.y = 0.0;
-    WPU->wrect.c.x = 1.0, WPU->wrect.c.y = 1.0;
-    WPU->vsize.x = ps.x, WPU->vsize.y = ps.y;
-    WPU->ncolor = 2;
-    pal[0].palVersion = 0x300; /* HA HA HA */
-    pal[0].palNumEntries = 2;
-    pal[0].palPalEntry[0].peRed = 255;
-    pal[0].palPalEntry[0].peGreen = 255;
-    pal[0].palPalEntry[0].peBlue = 255;
-    pal[0].palPalEntry[0].peFlags = 0;
-    pal[0].palPalEntry[1].peRed = 0;
-    pal[0].palPalEntry[1].peGreen = 0;
-    pal[0].palPalEntry[1].peBlue = 0;
-    pal[0].palPalEntry[1].peFlags = 0;
-    WPU->cmap = CreatePalette (&pal[0]);
-    WPU->colors[0].color = pal[0].palPalEntry[0];
-    for (i = 1; i < G_MAXCOLORS; i++)
-        WPU->colors[i].color = pal[0].palPalEntry[1];
-    SelectPalette (GC, WPU->cmap, FALSE);
-    RealizePalette (GC);
-    WPU->colors[0].inuse = TRUE;
-    WPU->colors[1].inuse = TRUE;
-    for (i = 2; i < G_MAXCOLORS; i++)
-        WPU->colors[i].inuse = FALSE;
-    WPU->gattr.color = 1;
-    brush = CreateSolidBrush (PALETTEINDEX (1));
-    SelectObject (GC, brush);
-    pen = CreatePen (PS_SOLID, 1, PALETTEINDEX (1));
-    SelectObject (GC, pen);
-    SetTextColor (GC, PALETTEINDEX (1));
-    SetBkMode (GC, TRANSPARENT);
-    WPU->gattr.width = 0;
-    WPU->gattr.mode = G_SRC;
-    WPU->gattr.fill = 0;
-    WPU->gattr.style = 0;
-    WPU->defgattr = WPU->gattr;
-    WPU->font = NULL;
-    if (Gdepth == 1) {
-        for (i = 0; i < 17; i++) {
-            if (!(bmap = CreateBitmap (4, 4, 1, 1, &grays[i][0])))
-                continue;
-            WPU->grays[i] = CreatePatternBrush (bmap);
-        }
-    }
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            WPU->colors[color].color.peRed = attrp[ai].u.c.r;
-            WPU->colors[color].color.peGreen = attrp[ai].u.c.g;
-            WPU->colors[color].color.peBlue = attrp[ai].u.c.b;
-            WPU->colors[color].color.peFlags = 0;
-            if (color >= WPU->ncolor)
-                ResizePalette (WPU->cmap, color + 1), WPU->ncolor = color + 1;
-            SetPaletteEntries (
-                WPU->cmap, (int) color, 1, &WPU->colors[color].color
-            );
-            RealizePalette (GC);
-            WPU->colors[color].inuse = TRUE;
-            if (color == WPU->gattr.color)
-                WPU->gattr.color = -1;
-            break;
-        case G_ATTRVIEWPORT:
-            if (attrp[ai].u.s.x == 0)
-                attrp[ai].u.s.x = 1;
-            if (attrp[ai].u.s.y == 0)
-                attrp[ai].u.s.y = 1;
-            WPU->vsize.x = attrp[ai].u.s.x + 0.5;
-            WPU->vsize.y = attrp[ai].u.s.y + 0.5;
-            SetWindowPos (
-                widget->w, (HWND) NULL, 0, 0, WPU->vsize.x,
-                WPU->vsize.y, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE
-            );
-            break;
-        case G_ATTRWINDOW:
-            if (attrp[ai].u.r.o.x == attrp[ai].u.r.c.x)
-                attrp[ai].u.r.c.x = attrp[ai].u.r.o.x + 1;
-            if (attrp[ai].u.r.o.y == attrp[ai].u.r.c.y)
-                attrp[ai].u.r.c.y = attrp[ai].u.r.o.y + 1;
-            WPU->wrect = attrp[ai].u.r;
-            break;
-        }
-    }
-    return 0;
-}
-
-int GPsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PIXsize_t ps;
-    int color, ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            break;
-        case G_ATTRSIZE:
-            break;
-        case G_ATTRNAME:
-            break;
-        case G_ATTRMODE:
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            WPU->colors[color].color.peRed = attrp[ai].u.c.r;
-            WPU->colors[color].color.peGreen = attrp[ai].u.c.g;
-            WPU->colors[color].color.peBlue = attrp[ai].u.c.b;
-            WPU->colors[color].color.peFlags = 0;
-            if (color >= WPU->ncolor)
-                ResizePalette (WPU->cmap, color + 1), WPU->ncolor = color + 1;
-            SetPaletteEntries (
-                WPU->cmap, (int) color, 1, &WPU->colors[color].color
-            );
-            RealizePalette (GC);
-            WPU->colors[color].inuse = TRUE;
-            if (color == WPU->gattr.color)
-                WPU->gattr.color = -1;
-            break;
-        case G_ATTRVIEWPORT:
-            if (attrp[ai].u.s.x == 0)
-                attrp[ai].u.s.x = 1;
-            if (attrp[ai].u.s.y == 0)
-                attrp[ai].u.s.y = 1;
-            WPU->vsize.x = attrp[ai].u.s.x + 0.5;
-            WPU->vsize.y = attrp[ai].u.s.y + 0.5;
-            ps.x = WPU->vsize.x, ps.y = WPU->vsize.y;
-            break;
-        case G_ATTRWINDOW:
-            if (attrp[ai].u.r.o.x == attrp[ai].u.r.c.x)
-                attrp[ai].u.r.c.x = attrp[ai].u.r.o.x + 1;
-            if (attrp[ai].u.r.o.y == attrp[ai].u.r.c.y)
-                attrp[ai].u.r.c.y = attrp[ai].u.r.o.y + 1;
-            WPU->wrect = attrp[ai].u.r;
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GPgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PALETTEENTRY *cp;
-    int color, ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            break;
-        case G_ATTRSIZE:
-            break;
-        case G_ATTRNAME:
-            break;
-        case G_ATTRMODE:
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            if (WPU->colors[color].inuse) {
-                cp = &WPU->colors[color].color;
-                attrp[ai].u.c.r = cp->peRed;
-                attrp[ai].u.c.g = cp->peGreen;
-                attrp[ai].u.c.b = cp->peBlue;
-            } else {
-                attrp[ai].u.c.r = -1;
-                attrp[ai].u.c.g = -1;
-                attrp[ai].u.c.b = -1;
-            }
-            break;
-        case G_ATTRVIEWPORT:
-            attrp[ai].u.s = WPU->vsize;
-            break;
-        case G_ATTRWINDOW:
-            attrp[ai].u.r = WPU->wrect;
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTGETATTR, "windowid");
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GPdestroywidget (Gwidget_t *widget) {
-    HENHMETAFILE mfile;
-
-    if (WPU->mode == 1) {
-        mfile = CloseEnhMetaFile (GC);
-        OpenClipboard (NULL);
-        EmptyClipboard ();
-        SetClipboardData (CF_ENHMETAFILE, mfile);
-        CloseClipboard ();
-        DeleteMetaFile (mfile);
-    } else {
-        EndPage (GC);
-        EndDoc (GC);
-    }
-    return 0;
-}
-
-int GPcanvasclear (Gwidget_t *widget) {
-    HBRUSH brush, pbrush;
-
-    /* FIXME: drain repaint messages */
-    brush = CreateSolidBrush (PALETTEINDEX (0));
-    pbrush = SelectObject (GC, brush);
-    Rectangle (GC, 0, 0, (int) WPU->vsize.x, (int) WPU->vsize.y);
-    SelectObject (GC, pbrush);
-    return 0;
-}
-
-int GPsetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    setgattr (widget, ap);
-    WPU->defgattr = WPU->gattr;
-    return 0;
-}
-
-int GPgetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    if ((ap->flags & G_GATTRCOLOR))
-        ap->color = WPU->gattr.color;
-    if ((ap->flags & G_GATTRWIDTH))
-        ap->width = WPU->gattr.width;
-    if ((ap->flags & G_GATTRMODE))
-        ap->mode = WPU->gattr.mode;
-    if ((ap->flags & G_GATTRFILL))
-        ap->fill = WPU->gattr.fill;
-    if ((ap->flags & G_GATTRSTYLE))
-        ap->style = WPU->gattr.style;
-    return 0;
-}
-
-int GParrow (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    PIXpoint_t pp1, pp2, pa, pb, pd;
-    double tangent, l;
-
-    pp1 = pdrawtopix (widget, gp1), pp2 = pdrawtopix (widget, gp2);
-    pd.x = pp1.x - pp2.x, pd.y = pp1.y - pp2.y;
-    if (pd.x == 0 && pd.y == 0)
-        return 0;
-    tangent = atan2 ((double) pd.y, (double) pd.x);
-    if ((l = hypot(pd.x, pd.y)) > 30)
-        l = 30;
-    pa.x = l * cos (tangent + M_PI / 7) + pp2.x;
-    pa.y = l * sin (tangent + M_PI / 7) + pp2.y;
-    pb.x = l * cos (tangent - M_PI / 7) + pp2.x;
-    pb.y = l * sin (tangent - M_PI / 7) + pp2.y;
-    setgattr (widget, ap);
-    MoveToEx (GC, pp1.x, pp1.y, NULL), LineTo (GC, pp2.x, pp2.y);
-    MoveToEx (GC, pa.x, pa.y, NULL), LineTo (GC, pp2.x, pp2.y);
-    MoveToEx (GC, pb.x, pb.y, NULL), LineTo (GC, pp2.x, pp2.y);
-    return 0;
-}
-
-int GPline (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    PIXpoint_t pp1, pp2;
-
-    pp1 = pdrawtopix (widget, gp1), pp2 = pdrawtopix (widget, gp2);
-    setgattr (widget, ap);
-    MoveToEx (GC, pp1.x, pp1.y, NULL);
-    LineTo (GC, pp2.x, pp2.y);
-    return 0;
-}
-
-int GPbox (Gwidget_t *widget, Grect_t gr, Ggattr_t *ap) {
-    PIXrect_t pr;
-    Grect_t gr2;
-
-    if (gr.o.x <= gr.c.x)
-        gr2.o.x = gr.o.x, gr2.c.x = gr.c.x;
-    else
-        gr2.o.x = gr.c.x, gr2.c.x = gr.o.x;
-    if (gr.o.y <= gr.c.y)
-        gr2.o.y = gr.o.y, gr2.c.y = gr.c.y;
-    else
-        gr2.o.y = gr.c.y, gr2.c.y = gr.o.y;
-    pr = rdrawtopix (widget, gr);
-    setgattr (widget, ap);
-    if (WPU->gattr.fill)
-        Rectangle (GC, pr.o.x, pr.o.y, pr.c.x, pr.c.y);
-    else {
-        Gppp[0].x = pr.o.x, Gppp[0].y = pr.o.y;
-        Gppp[1].x = pr.c.x, Gppp[1].y = pr.o.y;
-        Gppp[2].x = pr.c.x, Gppp[2].y = pr.c.y;
-        Gppp[3].x = pr.o.x, Gppp[3].y = pr.c.y;
-        Gppp[4].x = pr.o.x, Gppp[4].y = pr.o.y;
-        Polyline (GC, Gppp, 5);
-    }
-    return 0;
-}
-
-int GPpolygon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    int n, i;
-
-    if (gpn == 0)
-        return 0;
-    if (gpn + 1 > Gppn) {
-        n = (((gpn + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-        Gppp = Marraygrow (Gppp, (long) n * PPSIZE);
-        Gppn = n;
-    }
-    for (i = 0; i < gpn; i++)
-        Gppp[i] = pdrawtopix (widget, gpp[i]);
-    setgattr (widget, ap);
-    if (WPU->gattr.fill) {
-        if (Gppp[gpn - 1].x != Gppp[0].x || Gppp[gpn - 1].y != Gppp[0].y)
-            Gppp[gpn] = Gppp[0], gpn++;
-        Polygon (GC, Gppp, (int) gpn);
-    } else
-        Polyline (GC, Gppp, (int) gpn);
-    return 0;
-}
-
-int GPsplinegon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    PIXpoint_t p0, p1, p2, p3;
-    int n, i;
-
-    if (gpn == 0)
-        return 0;
-    Gppi = 1;
-    if (Gppi >= Gppn) {
-        n = (((Gppi + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-        Gppp = Marraygrow (Gppp, (long) n * PPSIZE);
-        Gppn = n;
-    }
-    Gppp[0] = p3 = pdrawtopix (widget, gpp[0]);
-    for (i = 1; i < gpn; i += 3) {
-        p0 = p3;
-        p1 = pdrawtopix (widget, gpp[i]);
-        p2 = pdrawtopix (widget, gpp[i + 1]);
-        p3 = pdrawtopix (widget, gpp[i + 2]);
-        bezier (p0, p1, p2, p3);
-    }
-    setgattr (widget, ap);
-    if (WPU->gattr.fill) {
-        if (Gppp[Gppi - 1].x != Gppp[0].x || Gppp[Gppi - 1].y != Gppp[0].y)
-            Gppp[Gppi] = Gppp[0], Gppi++;
-        Polygon (GC, Gppp, (int) Gppi);
-    } else
-        Polyline (GC, Gppp, (int) Gppi);
-    return 0;
-}
-
-static void bezier (
-    PIXpoint_t p0, PIXpoint_t p1, PIXpoint_t p2, PIXpoint_t p3
-) {
-    Gpoint_t gp0, gp1, gp2;
-    Gsize_t s;
-    PIXpoint_t p;
-    double t;
-    int n, i, steps;
-
-    if ((s.x = p3.x - p0.x) < 0)
-        s.x = - s.x;
-    if ((s.y = p3.y - p0.y) < 0)
-        s.y = - s.y;
-    if (s.x > s.y)
-        steps = s.x / 5 + 1;
-    else
-        steps = s.y / 5 + 1;
-    for (i = 0; i <= steps; i++) {
-        t = i / (double) steps;
-        gp0.x = p0.x + t * (p1.x - p0.x);
-        gp0.y = p0.y + t * (p1.y - p0.y);
-        gp1.x = p1.x + t * (p2.x - p1.x);
-        gp1.y = p1.y + t * (p2.y - p1.y);
-        gp2.x = p2.x + t * (p3.x - p2.x);
-        gp2.y = p2.y + t * (p3.y - p2.y);
-        gp0.x = gp0.x + t * (gp1.x - gp0.x);
-        gp0.y = gp0.y + t * (gp1.y - gp0.y);
-        gp1.x = gp1.x + t * (gp2.x - gp1.x);
-        gp1.y = gp1.y + t * (gp2.y - gp1.y);
-        p.x = gp0.x + t * (gp1.x - gp0.x) + 0.5;
-        p.y = gp0.y + t * (gp1.y - gp0.y) + 0.5;
-        if (Gppi >= Gppn) {
-            n = (((Gppi + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-            Gppp = Marraygrow (Gppp, (long) n * PPSIZE);
-            Gppn = n;
-        }
-        Gppp[Gppi++] = p;
-    }
-}
-
-int GParc (
-    Gwidget_t *widget, Gpoint_t gc, Gsize_t gs,
-    double ang1, double ang2, Ggattr_t *ap
-) {
-    PIXpoint_t pc;
-    PIXsize_t ps;
-    double a1, a2;
-
-    pc = pdrawtopix (widget, gc), ps = sdrawtopix (widget, gs);
-    setgattr (widget, ap);
-    a1 = ang1 * M_PI / 180, a2 = ang2 * M_PI / 180;
-    if (WPU->gattr.fill)
-        Chord (
-            GC, pc.x - ps.x, pc.y - ps.y, pc.x + ps.x, pc.y + ps.y,
-            (int) (cos (a1) * ps.x), (int) (sin (a1) * ps.x),
-            (int) (cos (a2) * ps.x), (int) (sin (a2) * ps.x)
-        );
-    else
-        Arc (
-            GC, pc.x - ps.x, pc.y - ps.y, pc.x + ps.x, pc.y + ps.y,
-            (int) (cos (a1) * ps.x), (int) (sin (a1) * ps.x),
-            (int) (cos (a2) * ps.x), (int) (sin (a2) * ps.x)
-        );
-    return 0;
-}
-
-int GPtext (
-    Gwidget_t *widget, Gtextline_t *tlp, int n, Gpoint_t go, char *fn,
-    double fs, char *justs, Ggattr_t *ap
-) {
-    Gsize_t gs;
-    PIXpoint_t po;
-    PIXsize_t ps;
-    PIXrect_t pr;
-    HFONT font;
-    SIZE size;
-    RECT r;
-    int x, y, w, h, i;
-
-    po = pdrawtopix (widget, go);
-    gs.x = 0, gs.y = fs;
-    ps = sdrawtopix (widget, gs);
-    if (!(font = findfont (fn, ps.y))) {
-        Rectangle (GC, po.x, po.y, po.x + 1, po.y + 1);
-        return 0;
-    }
-    setgattr (widget, ap);
-    if (font != WPU->font) {
-        WPU->font = font;
-        SelectObject (GC, font);
-    }
-    for (w = h = 0, i = 0; i < n; i++) {
-        if (tlp[i].n)
-            GetTextExtentPoint32 (GC, tlp[i].p, (int) tlp[i].n, &size);
-        else
-            GetTextExtentPoint32 (GC, "M", (int) 1, &size);
-        tlp[i].w = size.cx, tlp[i].h = size.cy;
-        w = max (w, size.cx), h += size.cy;
-    }
-    switch (justs[0]) {
-    case 'l': po.x += w / 2; break;
-    case 'r': po.x -= w / 2; break;
-    }
-    switch (justs[1]) {
-    case 'd': po.y -= h; break;
-    case 'c': po.y -= h / 2; break;
-    }
-    pr.o.x = po.x - w / 2, pr.o.y = po.y;
-    pr.c.x = po.x + w / 2, pr.c.y = po.y + h;
-    for (i = 0; i < n; i++) {
-        switch (tlp[i].j) {
-        case 'l': x = po.x - w / 2; break;
-        case 'n': x = po.x - tlp[i].w / 2; break;
-        case 'r': x = po.x - (tlp[i].w - w / 2); break;
-        }
-        y = po.y + i * tlp[i].h;
-        r.left = x, r.top = y;
-        r.right = x + tlp[i].w, r.bottom = y + tlp[i].h;
-        DrawText (GC, tlp[i].p, (int) tlp[i].n, &r, DT_LEFT | DT_TOP);
-    }
-    return 0;
-}
-
-static HFONT findfont (char *name, int size) {
-    HFONT font;
-    int fi;
-
-    if (strcmp(name, "") == 0)
-        return Gfontp[0].font;
-
-    sprintf (&Gbufp[0], name, size);
-    for (fi = 0; fi < Gfontn; fi++)
-        if (strcmp (&Gbufp[0], Gfontp[fi].name) == 0 && Gfontp[fi].size == size)
-            return Gfontp[fi].font;
-    font = CreateFont (
-        (int) size, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &Gbufp[0]
-    );
-    if (!font)
-        font = Gfontp[0].font;
-
-    Gfontp = Marraygrow (Gfontp, (long) (Gfontn + 1) * FONTSIZE);
-    Gfontp[Gfontn].name = strdup (&Gbufp[0]);
-    Gfontp[Gfontn].size = size;
-    Gfontp[Gfontn].font = font;
-    Gfontn++;
-    return font;
-}
-
-int GPcreatebitmap (Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t s) {
-    if (!widget) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    if (!(bitmap->u.bmap.orig = CreateBitmap (
-        (int) s.x, (int) s.y, 1, Gdepth, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    bitmap->u.bmap.scaled = 0;
-    bitmap->scale.x = bitmap->scale.y = 1;
-    bitmap->ctype = widget->type;
-    bitmap->canvas = widget - &Gwidgets[0];
-    bitmap->size = s;
-    return 0;
-}
-
-int GPdestroybitmap (Gbitmap_t *bitmap) {
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    DeleteObject (bitmap->u.bmap.orig);
-    return 0;
-}
-
-int GPreadbitmap (Gwidget_t *widget, Gbitmap_t *bitmap, FILE *fp) {
-    Gsize_t s;
-    HDC gc;
-    char bufp[2048];
-    unsigned int rgb[3];
-    char *s1, *s2;
-    char c;
-    int bufn, bufi, step, x, y, k;
-
-    if (!widget) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    step = 0;
-    while (step < 3) {
-l1:
-        if (!fgets (bufp, 2048, fp)) {
-            Gerr (POS, G_ERRCANNOTREADBITMAP);
-            return -1;
-        }
-        s1 = &bufp[0];
-l2:
-        for (; *s1 && isspace (*s1); s1++)
-            ;
-        if (!*s1 || *s1 == '#')
-            goto l1;
-        switch (step) {
-        case 0:
-            if (strncmp (s1, "P6", 2) != 0) {
-                Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            step++, s1 += 2;
-            goto l2;
-        case 1:
-            for (s2 = s1; *s2 && *s2 >= '0' && *s2 <= '9'; s2++)
-                ;
-            c = *s2, *s2 = 0;
-            if (s2 == s1 || (s.x = atoi (s1)) <= 0) {
-                *s2 = c, Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            *s2 = c, step++, s1 = s2;
-            goto l2;
-        case 2:
-            for (s2 = s1; *s2 && *s2 >= '0' && *s2 <= '9'; s2++)
-                ;
-            c = *s2, *s2 = 0;
-            if (s2 == s1 || (s.y = atoi (s1)) <= 0) {
-                *s2 = c, Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            *s2 = c, step++, s1 = s2;
-            goto l2;
-        }
-    }
-    if (!(bitmap->u.bmap.orig = CreateBitmap (
-        (int) s.x, (int) s.y, 1, Gdepth, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    gc = CreateCompatibleDC (GC);
-    SelectObject (gc, bitmap->u.bmap.orig);
-    bitmap->u.bmap.scaled = 0;
-    bitmap->scale.x = bitmap->scale.y = 1;
-    bitmap->ctype = widget->type;
-    bitmap->canvas = widget - &Gwidgets[0];
-    bitmap->size = s;
-    bufi = bufn = 0;
-    bufp[bufi] = 0;
-    for (y = 0; y < s.y; y++) {
-        for (x = 0; x < s.x; x++) {
-            for (k = 0; k < 3; k++) {
-                if (bufi == bufn) {
-                    if ((bufn = fread (bufp, 1, 2047, fp)) == 0) {
-                        if (ferror (fp))
-                            bufn = -1;
-                        DeleteDC (gc);
-                        DeleteObject (bitmap->u.bmap.orig);
-                        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-                        return -1;
-                    }
-                    bufi = 0;
-                }
-                rgb[k] = (unsigned char) bufp[bufi++];
-            }
-            SetPixel (gc, x, y, RGB (rgb[0], rgb[1], rgb[2]));
-        }
-    }
-    DeleteDC (gc);
-    return 0;
-}
-
-int GPwritebitmap (Gbitmap_t *bitmap, FILE *fp) {
-    Gwidget_t *widget;
-    HDC gc;
-    COLORREF color;
-    char bufp[2048];
-    int bufi, x, y, w, h;
-
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    if (
-        bitmap->canvas < 0 || bitmap->canvas >= Gwidgetn ||
-        !Gwidgets[bitmap->canvas].inuse
-    ) {
-        Gerr (POS, G_ERRBADWIDGETID, bitmap->canvas);
-        return -1;
-    }
-    widget = &Gwidgets[bitmap->canvas];
-    if (widget->type != G_CANVASWIDGET && widget->type != G_PCANVASWIDGET) {
-        Gerr (POS, G_ERRNOTACANVAS, bitmap->canvas);
-        return -1;
-    }
-    gc = CreateCompatibleDC (GC);
-    SelectObject (gc, bitmap->u.bmap.orig);
-    fprintf (fp, "P6\n%d %d 255\n", (int) bitmap->size.x, (int) bitmap->size.y);
-    bufi = 0;
-    w = bitmap->size.x;
-    h = bitmap->size.y;
-    for (y = 0; y < h; y++) {
-        for (x = 0; x < w; x++) {
-            color = GetPixel (gc, x, y);
-            bufp[bufi++] = GetRValue (color);
-            bufp[bufi++] = GetGValue (color);
-            bufp[bufi++] = GetBValue (color);
-            if (bufi + 3 >= 2048) {
-                fwrite (bufp, 1, bufi, fp);
-                bufi = 0;
-            }
-        }
-    }
-    if (bufi > 0)
-        fwrite (bufp, 1, bufi, fp);
-    DeleteDC (gc);
-    return 0;
-}
-
-int GPbitblt (
-    Gwidget_t *widget, Gpoint_t gp, Grect_t gr, Gbitmap_t *bitmap,
-    char *mode, Ggattr_t *ap
-) {
-    PIXrect_t pr, r;
-    PIXpoint_t pp;
-    PIXsize_t s;
-    Gsize_t scale;
-    Gxy_t p;
-    HBITMAP pix;
-    HDC gc;
-    double tvx, tvy, twx, twy;
-
-    if (gr.o.x > gr.c.x)
-        p.x = gr.o.x, gr.o.x = gr.c.x, gr.c.x = p.x;
-    if (gr.o.y > gr.c.y)
-        p.y = gr.o.y, gr.o.y = gr.c.y, gr.c.y = p.y;
-    if (strcmp (mode, "b2c") == 0) {
-        tvx = WPU->vsize.x, tvy = WPU->vsize.y;
-        twx = WPU->wrect.c.x - WPU->wrect.o.x;
-        twy = WPU->wrect.c.y - WPU->wrect.o.y;
-        scale.x = tvx / twx, scale.y = tvy / twy;
-        if (scale.x == 1 && scale.y == 1) {
-            pix = bitmap->u.bmap.orig;
-            bitmap->scale = scale;
-        } else {
-            if (scale.x != bitmap->scale.x || scale.y != bitmap->scale.y)
-                scalebitmap (widget, bitmap, scale, TRUE, 1);
-            pix = bitmap->u.bmap.scaled;
-        }
-        pr = rdrawtopix (widget, gr);
-        pp = pdrawtobpix (bitmap, gp);
-        s.x = pr.c.x - pr.o.x + 1, s.y = pr.c.y - pr.o.y + 1;
-        r.o.x = pp.x, r.o.y = pp.y - s.y + 1;
-        r.c.x = r.o.x + s.x - 1, r.c.y = r.o.y + s.y - 1;
-        if (r.o.x < 0)
-            pr.o.x -= r.o.x, r.o.x = 0;
-        if (r.o.y < 0)
-            pr.o.y -= r.o.y, r.o.y = 0;
-        if (r.c.x >= bitmap->size.x * scale.x) {
-            pr.c.x -= (r.c.x + 1 - bitmap->size.x * scale.x);
-            r.c.x = bitmap->size.x * scale.x - 1;
-        }
-        if (r.c.y >= bitmap->size.y * scale.y) {
-            pr.c.y -= (r.c.y + 1 - bitmap->size.y * scale.y);
-            r.c.y = bitmap->size.y * scale.y - 1;
-        }
-        if (pr.o.x < 0)
-            r.o.x -= pr.o.x, pr.o.x = 0;
-        if (pr.o.y < 0)
-            r.o.y -= pr.o.y, pr.o.y = 0;
-        setgattr (widget, ap);
-        gc = CreateCompatibleDC (GC);
-        SelectObject (gc, pix);
-        BitBlt (
-            GC, pr.o.x, pr.o.y, r.c.x - r.o.x + 1, r.c.y - r.o.y + 1,
-            gc, r.o.x, r.o.y, (WPU->gattr.mode == G_SRC) ? SRCCOPY : SRCINVERT
-        );
-        DeleteDC (gc);
-    } else if (strcmp (mode, "c2b") == 0) {
-        tvx = WPU->vsize.x, tvy = WPU->vsize.y;
-        twx = WPU->wrect.c.x - WPU->wrect.o.x;
-        twy = WPU->wrect.c.y - WPU->wrect.o.y;
-        scale.x = tvx / twx, scale.y = tvy / twy;
-        if (scale.x == 1 && scale.y == 1) {
-            pix = bitmap->u.bmap.orig;
-            bitmap->scale = scale;
-        } else {
-            if (scale.x != bitmap->scale.x || scale.y != bitmap->scale.y)
-                scalebitmap (widget, bitmap, scale, FALSE, 1);
-            pix = bitmap->u.bmap.scaled;
-        }
-        pr = rdrawtobpix (bitmap, gr);
-        pp = pdrawtopix (widget, gp);
-        s.x = pr.c.x - pr.o.x + 1, s.y = pr.c.y - pr.o.y + 1;
-        r.o.x = pp.x, r.o.y = pp.y - s.y + 1;
-        r.c.x = r.o.x + s.x - 1, r.c.y = r.o.y + s.y - 1;
-        if (pr.o.x < 0)
-            r.o.x -= pr.o.x, pr.o.x = 0;
-        if (pr.o.y < 0)
-            r.o.y -= pr.o.y, pr.o.y = 0;
-        if (pr.c.x >= bitmap->size.x * scale.x) {
-            r.c.x -= (pr.c.x + 1 - bitmap->size.x * scale.x);
-            pr.c.x = bitmap->size.x * scale.x - 1;
-        }
-        if (pr.c.y >= bitmap->size.y * scale.y) {
-            r.c.y -= (pr.c.y + 1 - bitmap->size.y * scale.y);
-            pr.c.y = bitmap->size.y * scale.y - 1;
-        }
-        if (r.o.x < 0)
-            pr.o.x -= r.o.x, r.o.x = 0;
-        if (r.o.y < 0)
-            pr.o.y -= r.o.y, r.o.y = 0;
-        setgattr (widget, ap);
-        gc = CreateCompatibleDC (GC);
-        SelectObject (gc, pix);
-        BitBlt (
-            gc, pr.o.x, pr.o.y, r.c.x - r.o.x + 1, r.c.y - r.o.y + 1,
-            GC, r.o.x, r.o.y, (WPU->gattr.mode == G_SRC) ? SRCCOPY : SRCINVERT
-        );
-        if (pix != bitmap->u.bmap.orig)
-            scalebitmap (widget, bitmap, scale, TRUE, -1);
-        DeleteDC (gc);
-    }
-    return 0;
-}
-
-static int scalebitmap (
-    Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t scale,
-    int copybits, int dir
-) {
-    Gsize_t nsize, o2n;
-    HBITMAP opix, spix;
-    COLORREF color;
-    HDC gc1, gc2;
-    int x, y, x2, y2, xp, yp;
-    double prod, rgb[3], xr2, yr2, xl2, yl2, xf2, yf2, xr, yr, xl, yl;
-
-    if (!copybits) {
-        if (dir == 1) {
-            nsize.x = (int) (bitmap->size.x * scale.x);
-            nsize.y = (int) (bitmap->size.y * scale.y);
-            if (!(spix = CreateBitmap (
-                (int) nsize.x, (int) nsize.y, 1, Gdepth, NULL
-            ))) {
-                Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-                return -1;
-            }
-            if (bitmap->u.bmap.scaled)
-                DeleteObject (bitmap->u.bmap.scaled);
-            bitmap->u.bmap.scaled = spix;
-            bitmap->scale = scale;
-        }
-        return 0;
-    }
-    if (dir == 1) {
-        nsize.x = (int) (bitmap->size.x * scale.x);
-        nsize.y = (int) (bitmap->size.y * scale.y);
-        o2n.x = 1 / scale.x, o2n.y = 1 / scale.y;
-        if (!(spix = CreateBitmap (
-            (int) nsize.x, (int) nsize.y, 1, Gdepth, NULL
-        ))) {
-            Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-            return -1;
-        }
-        opix = bitmap->u.bmap.orig;
-    } else {
-        nsize.x = (int) bitmap->size.x;
-        nsize.y = (int) bitmap->size.y;
-        o2n.x = scale.x, o2n.y = scale.y;
-        spix = bitmap->u.bmap.orig;
-        opix = bitmap->u.bmap.scaled;
-    }
-    gc1 = CreateCompatibleDC (GC);
-    SelectObject (gc1, opix);
-    gc2 = CreateCompatibleDC (GC);
-    SelectObject (gc2, spix);
-    prod = o2n.x * o2n.y;
-    y = 0;
-    yr = o2n.y;
-    yl = 0;
-    for (yp = 0; yp < nsize.y; yp++) {
-        x = 0;
-        xr = o2n.x;
-        xl = 0;
-        for (xp = 0; xp < nsize.x; xp++) {
-            y2 = y;
-            yr2 = yr;
-            yl2 = yl;
-            rgb[0] = rgb[1] = rgb[2] = 0;
-            do {
-                x2 = x;
-                xr2 = xr;
-                xl2 = xl;
-                yf2 = (yl2 + yr2 > 1) ? 1 - yl2 : yr2, yr2 -= yf2;
-                do {
-                    xf2 = (xl2 + xr2 > 1) ? 1 - xl2 : xr2, xr2 -= xf2;
-                    color = GetPixel (gc1, x2, y2);
-                    rgb[0] += (GetRValue (color) * xf2 * yf2 / prod);
-                    rgb[1] += (GetGValue (color) * xf2 * yf2 / prod);
-                    rgb[2] += (GetBValue (color) * xf2 * yf2 / prod);
-                    xl2 += xf2;
-                    if (xl2 >= 1)
-                        x2++, xl2 -= 1;
-                } while (xr2 > 0);
-                xr2 = o2n.x;
-                yl2 += yf2;
-                if (yl2 >= 1)
-                    y2++, yl2 -= 1;
-            } while (yr2 > 0);
-            yr2 = o2n.y;
-            SetPixel (gc2, xp, yp, RGB (rgb[0], rgb[1], rgb[2]));
-            x = x2;
-            xr = xr2;
-            xl = xl2;
-        }
-        y = y2;
-        yr = yr2;
-        yl = yl2;
-    }
-    DeleteDC (gc1);
-    DeleteDC (gc2);
-    if (dir == 1) {
-        if (bitmap->u.bmap.scaled)
-            DeleteObject (bitmap->u.bmap.scaled);
-        bitmap->u.bmap.scaled = spix;
-        bitmap->scale = scale;
-    }
-    return 0;
-}
-
-static void setgattr (Gwidget_t *widget, Ggattr_t *ap) {
-    HBRUSH brush, pbrush;
-    HPEN pen, ppen;
-    PALETTEENTRY *colorp;
-    long color, mode, style, width, flag, pati;
-    double intens;
-
-    if (!(ap->flags & G_GATTRCOLOR))
-        ap->color = WPU->defgattr.color;
-    if (!(ap->flags & G_GATTRWIDTH))
-        ap->width = WPU->defgattr.width;
-    if (!(ap->flags & G_GATTRMODE))
-        ap->mode = WPU->defgattr.mode;
-    if (!(ap->flags & G_GATTRFILL))
-        ap->fill = WPU->defgattr.fill;
-    if (!(ap->flags & G_GATTRSTYLE))
-        ap->style = WPU->defgattr.style;
-    flag = FALSE;
-    mode = ap->mode;
-    if (mode != WPU->gattr.mode) {
-        WPU->gattr.mode = mode;
-        SetROP2 (GC, (int) mode);
-    }
-    WPU->gattr.fill = ap->fill;
-    color = ap->color;
-    if (color >= G_MAXCOLORS || !(WPU->colors[color].inuse))
-        color = 1;
-    if (color != WPU->gattr.color)
-        WPU->gattr.color = color, flag = TRUE;
-    width = ap->width;
-    if (width != WPU->gattr.width)
-        WPU->gattr.width = width, flag = TRUE;
-    style = ap->style;
-    if (style != WPU->gattr.style)
-        WPU->gattr.style = style, flag = TRUE;
-
-    if (!flag)
-        return;
-    WPU->gattr.color = color;
-    if (Gdepth == 1) {
-        colorp = &WPU->colors[color].color;
-        intens = (
-            0.3 * colorp->peBlue + 0.59 * colorp->peRed +
-            0.11 * colorp->peGreen
-        ) / 255.0;
-        pati = (intens <= 0.0625) ? 16 : -16.0 * (log (intens) / 2.7725887222);
-        brush = WPU->grays[pati];
-    } else
-        brush = CreateSolidBrush (PALETTEINDEX (WPU->gattr.color));
-    pbrush = SelectObject (GC, brush);
-    if (Gdepth != 1)
-        DeleteObject (pbrush);
-    pen = CreatePen (
-        (int) gstyles[WPU->gattr.style], WPU->gattr.width,
-        PALETTEINDEX (WPU->gattr.color)
-    );
-    ppen = SelectObject (GC, pen);
-    DeleteObject (ppen);
-    SetTextColor (GC, PALETTEINDEX (WPU->gattr.color));
-}
-
-static PIXrect_t rdrawtopix (Gwidget_t *widget, Grect_t gr) {
-    PIXrect_t pr;
-    double tvx, tvy, twx, twy;
-
-    tvx = WPU->vsize.x - 1, tvy = WPU->vsize.y - 1;
-    twx = WPU->wrect.c.x - WPU->wrect.o.x;
-    twy = WPU->wrect.c.y - WPU->wrect.o.y;
-    pr.o.x = tvx * (gr.o.x - WPU->wrect.o.x) / twx + 0.5;
-    pr.o.y = tvy * (1.0  - (gr.c.y - WPU->wrect.o.y) / twy) + 0.5;
-    pr.c.x = tvx * (gr.c.x - WPU->wrect.o.x) / twx + 0.5;
-    pr.c.y = tvy * (1.0  - (gr.o.y - WPU->wrect.o.y) / twy) + 0.5;
-    return pr;
-}
-
-static PIXpoint_t pdrawtopix (Gwidget_t *widget, Gpoint_t gp) {
-    PIXpoint_t pp;
-    double tvx, tvy, twx, twy;
-
-    tvx = WPU->vsize.x - 1, tvy = WPU->vsize.y - 1;
-    twx = WPU->wrect.c.x - WPU->wrect.o.x;
-    twy = WPU->wrect.c.y - WPU->wrect.o.y;
-    pp.x = tvx * (gp.x - WPU->wrect.o.x) / twx + 0.5;
-    pp.y = tvy * (1.0  - (gp.y - WPU->wrect.o.y) / twy) + 0.5;
-    return pp;
-}
-
-static PIXsize_t sdrawtopix (Gwidget_t *widget, Gsize_t gs) {
-    PIXsize_t ps;
-    double tvx, tvy, twx, twy;
-
-    tvx = WPU->vsize.x - 1, tvy = WPU->vsize.y - 1;
-    twx = WPU->wrect.c.x - WPU->wrect.o.x;
-    twy = WPU->wrect.c.y - WPU->wrect.o.y;
-    ps.x = tvx * (gs.x - 1) / twx + 1.5;
-    ps.y = tvy * (gs.y - 1) / twy + 1.5;
-    return ps;
-}
-
-static PIXrect_t rdrawtobpix (Gbitmap_t *bitmap, Grect_t gr) {
-    PIXrect_t pr;
-    double tvy;
-
-    tvy = (int) ((bitmap->size.y - 1) * bitmap->scale.y);
-    pr.o.x = gr.o.x + 0.5;
-    pr.o.y = tvy - gr.c.y + 0.5;
-    pr.c.x = gr.c.x + 0.5;
-    pr.c.y = tvy - gr.o.y + 0.5;
-    return pr;
-}
-
-static PIXpoint_t pdrawtobpix (Gbitmap_t *bitmap, Gpoint_t gp) {
-    PIXpoint_t pp;
-    double tvy;
-
-    tvy = (int) ((bitmap->size.y - 1) * bitmap->scale.y);
-    pp.x = gp.x + 0.5;
-    pp.y = tvy - gp.y + 0.5;
-    return pp;
-}
diff --git a/cmd/lefty/ws/mswin32/gquery.c b/cmd/lefty/ws/mswin32/gquery.c
deleted file mode 100644 (file)
index 34e6063..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-#include "resource.h"
-
-#define WQU widget->u.q
-
-BOOL CALLBACK stringproc (HWND, UINT, WPARAM, LPARAM);
-BOOL CALLBACK choiceproc (HWND, UINT, WPARAM, LPARAM);
-
-int GQcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    DWORD wflags;
-    int ai;
-
-    WQU->mode = G_QWSTRING;
-    wflags = WS_OVERLAPPEDWINDOW;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRMODE:
-            if (strcmp ("string", attrp[ai].u.t) == 0)
-                WQU->mode = G_QWSTRING;
-            else if (strcmp ("file", attrp[ai].u.t) == 0)
-                WQU->mode = G_QWFILE;
-            else if (strcmp ("choice", attrp[ai].u.t) == 0)
-                WQU->mode = G_QWCHOICE;
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    switch (WQU->mode) {
-    case G_QWSTRING:
-        widget->w = 0;
-        break;
-    case G_QWFILE:
-        widget->w = 0;
-        break;
-    case G_QWCHOICE:
-        widget->w = 0;
-        break;
-    }
-    return 0;
-}
-
-int GQsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRMODE:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "mode");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GQgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRMODE:
-            switch (WQU->mode) {
-            case G_QWSTRING:
-                attrp[ai].u.t = "string";
-                break;
-            case G_QWFILE:
-                attrp[ai].u.t = "file";
-                break;
-            case G_QWCHOICE:
-                attrp[ai].u.t = "choice";
-                break;
-            }
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GQdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
-
-static Gwidget_t *choicew;
-static char *buttons[20];
-static char *stringp;
-static int stringn;
-
-int GQqueryask (
-    Gwidget_t *widget, char *prompt, char *args,
-    char *responsep, int responsen
-) {
-    OPENFILENAME ofn;
-    char buf[256];
-    char *s1, *s2;
-    char c;
-    int i;
-
-    switch (WQU->mode) {
-    case G_QWSTRING:
-        stringp = responsep;
-        stringn = responsen;
-        buttons[0] = prompt;
-        buttons[1] = args;
-        DialogBox (hinstance, (LPCSTR) "STRINGDIALOG", (HWND) NULL, stringproc);
-        Gpopdownflag = TRUE;
-        if (stringp)
-            return 0;
-        return -1;
-        break;
-    case G_QWFILE:
-        strcpy (buf, args);
-        ofn.lStructSize       = sizeof (OPENFILENAME);
-        ofn.hwndOwner         = (HWND) NULL;
-        ofn.lpstrFilter       = "All Files (*.*)\0*.*\0";
-        ofn.lpstrCustomFilter = NULL;
-        ofn.nMaxCustFilter    = 0;
-        ofn.nFilterIndex      = 1;
-        ofn.lpstrFile         = buf;
-        ofn.nMaxFile          = 256;
-        ofn.lpstrFileTitle    = NULL;
-        ofn.nMaxFileTitle     = 0;
-        ofn.lpstrInitialDir   = NULL;
-        ofn.lpstrTitle        = prompt;
-        ofn.Flags             = 0;
-        ofn.lpstrDefExt       = NULL;
-        if (!GetOpenFileName (&ofn)) {
-            Gpopdownflag = TRUE;
-            return -1;
-        }
-        strncpy (responsep, buf, responsen);
-        Gpopdownflag = TRUE;
-        break;
-    case G_QWCHOICE:
-        if (!args)
-            return -1;
-        WQU->button = 0;
-        choicew = widget;
-        buttons[0] = prompt;
-        for (s1 = args, i = 1; *s1; i++) {
-            buttons[i] = s1;
-            s2 = s1;
-            while (*s2 && *s2 != '|')
-                s2++;
-            c = *s2, *s2 = 0;
-            s1 = s2;
-            if (c)
-                s1++;
-        }
-        buttons[i] = NULL;
-        DialogBox (hinstance, "CHOICEDIALOG", (HWND) NULL, choiceproc);
-        if (WQU->button > 0)
-            strncpy (responsep, buttons[WQU->button], responsen);
-        for (s2 = args; s2 < s1; s2++)
-            if (!*s2)
-                *s2 = '|';
-        Gpopdownflag = TRUE;
-        if (WQU->button > 0)
-            return 0;
-        return -1;
-        break;
-    }
-    if (responsep[0] && responsep[strlen(responsep) - 1] == '\n')
-        responsep[strlen(responsep) - 1] = 0;
-    return 0;
-}
-
-BOOL CALLBACK stringproc (
-    HWND hdlg, UINT message, WPARAM wparam, LPARAM lparam
-) {
-    switch (message) {
-    case WM_INITDIALOG:
-        SetDlgItemText (hdlg, IDC_STATIC1, (LPCSTR) buttons[0]);
-        if (buttons[1])
-            SetDlgItemText (hdlg, IDC_EDIT1, (LPCSTR) buttons[1]);
-        return TRUE;
-        break;
-    case WM_COMMAND:
-        switch (wparam) {
-        case IDOK:
-            GetDlgItemText (hdlg, IDC_EDIT1, stringp, stringn);
-            EndDialog (hdlg, TRUE);
-            return TRUE;
-        case IDCANCEL:
-            stringp = NULL;
-            EndDialog(hdlg, TRUE);
-            return TRUE;
-            break;
-        }
-    }
-    return FALSE;
-}
-
-BOOL CALLBACK choiceproc (HWND hdlg, UINT message,
-        WPARAM wparam, LPARAM lparam) {
-    int sel, i;
-
-    switch (message) {
-    case WM_INITDIALOG:
-        SetDlgItemText (hdlg, IDC_STATIC1, (LPCSTR) buttons[0]);
-        for (i = 1; buttons[i]; i++)
-            SendDlgItemMessage (
-                hdlg, IDC_LIST1, LB_ADDSTRING, 0, (LPARAM) buttons[i]
-            );
-        return TRUE;
-        break;
-    case WM_COMMAND:
-        if ((sel = (int) SendDlgItemMessage (
-            hdlg, IDC_LIST1, LB_GETCURSEL, 0,  0
-        )) >= 0) {
-            choicew->u.q->button = sel + 1;
-            EndDialog (hdlg, TRUE);
-        }
-        return TRUE;
-        break;
-    }
-    return FALSE;
-}
diff --git a/cmd/lefty/ws/mswin32/gscroll.c b/cmd/lefty/ws/mswin32/gscroll.c
deleted file mode 100644 (file)
index af66375..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-int GScreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    DWORD wflags;
-    int ai;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    wflags = WS_CHILDWINDOW | WS_HSCROLL | WS_VSCROLL;
-    ps.x = ps.y = MINSWSIZE;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINSWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            wflags |= WS_BORDER;
-            break;
-        case G_ATTRCHILDCENTER:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "childcenter");
-            return -1;
-        case G_ATTRMODE:
-            if (strcmp ("forcebars", attrp[ai].u.t) != 0) {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    Gadjustwrect (parent, &ps);
-    if (!(widget->w = CreateWindow (
-        "ScrollClass", "scroll", wflags, 0, 0,
-        ps.x, ps.y, parent->w, (HMENU) (widget - &Gwidgets[0]),
-        hinstance, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    ShowWindow (widget->w, SW_SHOW);
-    UpdateWindow (widget->w);
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawinsertchild (parent, widget);
-    return 0;
-}
-
-int GSsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Gwidget_t *parent, *child;
-    PIXpoint_t po;
-    PIXsize_t ps, pps, cps;
-    RECT r;
-    DWORD wflags1, wflags2;
-    int ai, wi;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
-    wflags2 = SWP_NOSIZE | SWP_NOZORDER;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINSWSIZE);
-            Gadjustwrect (parent, &ps);
-            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "borderwidth");
-            return -1;
-        case G_ATTRCHILDCENTER:
-            for (wi = 0; wi < Gwidgetn; wi++) {
-                child = &Gwidgets[wi];
-                if (child->inuse && child->pwi == widget - &Gwidgets[0])
-                    break;
-            }
-            if (wi == Gwidgetn)
-                return 0;
-            GETORIGIN (attrp[ai].u.p, po);
-            GetClientRect (widget->w, &r);
-            pps.x = r.right - r.left, pps.y = r.bottom - r.top;
-            po.x -= pps.x / 2, po.y -= pps.y / 2;
-            GetWindowRect (child->w, &r);
-            cps.x = r.right - r.left, cps.y = r.bottom - r.top;
-            if (po.x < 0)
-                po.x = 0;
-            if (po.y < 0)
-                po.y = 0;
-            if (po.x > cps.x - pps.x)
-                po.x = cps.x - pps.x;
-            if (po.y > cps.y - pps.y)
-                po.y = cps.y - pps.y;
-            SetWindowPos (child->w, (HWND) NULL, -po.x, -po.y, 0, 0, wflags2);
-            SetScrollPos (widget->w, SB_HORZ, po.x, TRUE);
-            SetScrollPos (widget->w, SB_VERT, po.y, TRUE);
-            break;
-        case G_ATTRMODE:
-            if (strcmp ("forcebars", attrp[ai].u.t) != 0) {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GSgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Gwidget_t *child;
-    RECT r;
-    int width, height, ai, wi;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GetWindowRect (widget->w, &r);
-            attrp[ai].u.s.x = r.right - r.left;
-            attrp[ai].u.s.y = r.bottom - r.top;
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTGETATTR, "borderwidth");
-            return -1;
-        case G_ATTRCHILDCENTER:
-            for (wi = 0; wi < Gwidgetn; wi++) {
-                child = &Gwidgets[wi];
-                if (child->inuse && child->pwi == widget - &Gwidgets[0])
-                    break;
-            }
-            if (wi == Gwidgetn) {
-                Gerr (POS, G_ERRNOCHILDWIDGET);
-                return -1;
-            }
-            GetWindowRect (widget->w, &r);
-            width = r.right - r.left;
-            height = r.bottom - r.top;
-            GetWindowRect (widget->w, &r);
-            attrp[ai].u.p.x = width / 2 - r.left;
-            attrp[ai].u.p.y = height / 2 - r.top;
-            break;
-        case G_ATTRMODE:
-            attrp[ai].u.t = "forcebars";
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", widget->w);
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GSdestroywidget (Gwidget_t *widget) {
-    Gwidget_t *parent;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawdeletechild (parent, widget);
-    DestroyWindow (widget->w);
-    return 0;
-}
diff --git a/cmd/lefty/ws/mswin32/gtext.c b/cmd/lefty/ws/mswin32/gtext.c
deleted file mode 100644 (file)
index 7a96b32..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include <stdbool.h>
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-#define WTU widget->u.t
-
-int GTcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    DWORD wflags;
-    char *s;
-    int ai;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    wflags = WS_CHILDWINDOW;
-    WTU->func = NULL;
-    ps.x = ps.y = MINTWSIZE;
-    s = "";
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINTWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            wflags |= WS_BORDER;
-            break;
-        case G_ATTRTEXT:
-            s = attrp[ai].u.t;
-            break;
-        case G_ATTRAPPENDTEXT:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "appendtext");
-            return -1;
-        case G_ATTRMODE:
-            if (
-                strcmp ("oneline", attrp[ai].u.t) != 0 &&
-                strcmp ("input", attrp[ai].u.t) != 0 &&
-                strcmp ("output", attrp[ai].u.t) != 0
-            ) {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRNEWLINECB:
-            WTU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    Gadjustwrect (parent, &ps);
-    wflags |= (ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
-    if (ps.y > 40)
-        wflags |= (WS_HSCROLL | WS_VSCROLL);
-    if (!(widget->w = CreateWindow (
-        "EDIT", s, wflags, 0, 0, ps.x, ps.y,
-        parent->w, (HMENU) (widget - &Gwidgets[0]), hinstance, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    ShowWindow (widget->w, SW_SHOW);
-    UpdateWindow (widget->w);
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawinsertchild (parent, widget);
-    return 0;
-}
-
-int GTsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Gwidget_t *parent;
-    PIXsize_t ps;
-    DWORD wflags1;
-    int ai;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINTWSIZE);
-            Gadjustwrect (parent, &ps);
-            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "borderwidth");
-            return -1;
-        case G_ATTRTEXT:
-            Gnocallbacks = true;
-            SendMessage (widget->w, WM_SETTEXT, 0, "");
-            SendMessage (widget->w, EM_SETSEL, -1, 32760);
-            SendMessage (widget->w, EM_REPLACESEL, 0, (LPARAM) attrp[ai].u.t);
-            SendMessage (widget->w, EM_SETSEL, -1, 32760);
-            Gnocallbacks = false;
-            break;
-        case G_ATTRAPPENDTEXT:
-            Gnocallbacks = true;
-            SendMessage (widget->w, EM_SETSEL, -1, 32760);
-            SendMessage (widget->w, EM_REPLACESEL, 0, (LPARAM) attrp[ai].u.t);
-            SendMessage (widget->w, EM_SETSEL, -1, 32760);
-            SendMessage (widget->w, EM_REPLACESEL, 0, (LPARAM) "\r\n");
-            SendMessage (widget->w, EM_SETSEL, -1, 32760);
-            Gnocallbacks = false;
-            break;
-        case G_ATTRMODE:
-            if (
-                strcmp ("oneline", attrp[ai].u.t) != 0 &&
-                strcmp ("input", attrp[ai].u.t) != 0 &&
-                strcmp ("output", attrp[ai].u.t) != 0
-            ) {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GTgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    RECT r;
-    int rtn, ai, i, j;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GetWindowRect (widget->w, &r);
-            attrp[ai].u.s.x = r.right - r.left;
-            attrp[ai].u.s.y = r.bottom - r.top;
-            break;
-        case G_ATTRBORDERWIDTH:
-            Gerr (POS, G_ERRCANNOTGETATTR, "borderwidth");
-            return -1;
-        case G_ATTRTEXT:
-            if ((rtn = GetWindowTextLength (widget->w)) + 1 > Gbufn) {
-                Gbufp = Marraygrow (Gbufp, (long) (rtn + 1) * BUFSIZE);
-                Gbufn = rtn + 1;
-            }
-            GetWindowText (widget->w, &Gbufp[0], Gbufn - 1);
-            for (i = 0, j = 0; Gbufp[i]; i++)
-                if (Gbufp[i] != '\r')
-                    Gbufp[j++] = Gbufp[i];
-            Gbufp[j++] = 0;
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRAPPENDTEXT:
-            Gerr (POS, G_ERRCANNOTGETATTR, "appendtext");
-            return -1;
-        case G_ATTRMODE:
-            attrp[ai].u.t = "oneline";
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", widget->w);
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRNEWLINECB:
-            attrp[ai].u.func = WTU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GTdestroywidget (Gwidget_t *widget) {
-    Gwidget_t *parent;
-
-    parent = (widget->pwi == -1) ? NULL : &Gwidgets[widget->pwi];
-    if (parent && parent->type == G_ARRAYWIDGET)
-        Gawdeletechild (parent, widget);
-    DestroyWindow (widget->w);
-    return 0;
-}
diff --git a/cmd/lefty/ws/mswin32/gview.c b/cmd/lefty/ws/mswin32/gview.c
deleted file mode 100644 (file)
index 6807277..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-#define WVU widget->u.v
-
-int GVcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXpoint_t po;
-    PIXsize_t ps;
-    DWORD wflags;
-    char *s;
-    int ai;
-
-    WVU->func = NULL;
-    WVU->closing = FALSE;
-    wflags = WS_OVERLAPPEDWINDOW;
-    s = "LEFTY";
-    po.x = po.y = CW_USEDEFAULT;
-    ps.x = ps.y = MINVWSIZE;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            GETORIGIN (attrp[ai].u.p, po);
-            break;
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
-            break;
-        case G_ATTRNAME:
-            s = attrp[ai].u.t;
-            break;
-        case G_ATTRZORDER:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "zorder");
-            return -1;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WVU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    if (!(widget->w = CreateWindow (
-        "LeftyClass", s, wflags, po.x, po.y,
-        ps.x, ps.y, (HWND) 0, (HMENU) 0, hinstance, NULL
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    ShowWindow (widget->w, SW_SHOW);
-    UpdateWindow (widget->w);
-    return 0;
-}
-
-int GVsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PIXpoint_t po;
-    PIXsize_t ps;
-    DWORD wflags1, wflags2, wflags3, wflags4;
-    int ai;
-
-    wflags1 = SWP_NOMOVE | SWP_NOZORDER;
-    wflags2 = SWP_NOSIZE | SWP_NOZORDER;
-    wflags3 = SWP_NOSIZE | SWP_NOMOVE;
-    wflags4 = SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            GETORIGIN (attrp[ai].u.p, po);
-            SetWindowPos (widget->w, (HWND) NULL, po.x, po.y, 0, 0, wflags2);
-            break;
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
-            SetWindowPos (widget->w, (HWND) NULL, 0, 0, ps.x, ps.y, wflags1);
-            break;
-        case G_ATTRNAME:
-            SetWindowText (widget->w, attrp[ai].u.t);
-            return -1;
-        case G_ATTRZORDER:
-            if (strcmp (attrp[ai].u.t, "top") == 0)
-                SetWindowPos (widget->w, (HWND) HWND_TOP, 0, 0, 0, 0, wflags3);
-            else if (strcmp (attrp[ai].u.t, "bottom") == 0)
-                SetWindowPos (
-                    widget->w, (HWND) HWND_BOTTOM, 0, 0, 0, 0, wflags4
-                );
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WVU->func = attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GVgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    RECT r;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            GetWindowRect (widget->w, &r);
-            attrp[ai].u.p.x = r.left, attrp[ai].u.p.y = r.top;
-            break;
-        case G_ATTRSIZE:
-            GetWindowRect (widget->w, &r);
-            attrp[ai].u.s.x = r.right - r.left;
-            attrp[ai].u.s.y = r.bottom - r.top;
-            break;
-        case G_ATTRNAME:
-            Gerr (POS, G_ERRNOTIMPLEMENTED);
-            return -1;
-        case G_ATTRZORDER:
-            Gerr (POS, G_ERRNOTIMPLEMENTED);
-            return -1;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", widget->w);
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTREVENTCB:
-            attrp[ai].u.func = WVU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GVdestroywidget (Gwidget_t *widget) {
-    WVU->closing = TRUE;
-    DestroyWindow (widget->w);
-    return 0;
-}
diff --git a/cmd/lefty/ws/mswin32/lefty.rc b/cmd/lefty/ws/mswin32/lefty.rc
deleted file mode 100644 (file)
index 5060e11..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#define APSTUDIO_HIDDEN_SYMBOLS
-#include "windows.h"
-#undef APSTUDIO_HIDDEN_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-CHOICEDIALOG DIALOG MOVEABLE IMPURE  0, 0, 186, 92
-STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-CAPTION "Dialog"
-FONT 8, "MS Sans Serif"
-BEGIN
-    LISTBOX         IDC_LIST1,40,21,105,71,LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
-                    WS_TABSTOP
-    CTEXT           "Static",IDC_STATIC1,8,3,171,12
-END
-
-STRINGDIALOG DIALOG DISCARDABLE  0, 0, 186, 75
-STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
-CAPTION "Dialog"
-FONT 8, "MS Sans Serif"
-BEGIN
-    DEFPUSHBUTTON   "OK",IDOK,114,56,50,14
-    PUSHBUTTON      "Cancel",IDCANCEL,20,57,50,14
-    EDITTEXT        IDC_EDIT1,19,31,147,18,ES_AUTOHSCROLL
-    CTEXT           "Static",IDC_STATIC1,15,5,155,19
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE DISCARDABLE
-BEGIN
-    "resource.h\0"
-END
-
-2 TEXTINCLUDE DISCARDABLE
-BEGIN
-    "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
-    "#include ""windows.h""\r\n"
-    "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
-    "\0"
-END
-
-3 TEXTINCLUDE DISCARDABLE
-BEGIN
-    "\r\n"
-    "\0"
-END
-
-#endif    // APSTUDIO_INVOKED
-
-#endif    // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif    // not APSTUDIO_INVOKED
-
diff --git a/cmd/lefty/ws/mswin32/resource.h b/cmd/lefty/ws/mswin32/resource.h
deleted file mode 100644 (file)
index a310975..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by lefty.rc
-//
-#define IDD_DIALOG1                     101
-#define IDC_LIST1                       1000
-#define IDC_EDIT1                       1002
-#define IDC_STATIC1                     1005
-#define IDC_STATIC                      -1
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        104
-#define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1006
-#define _APS_NEXT_SYMED_VALUE           101
-#endif
-#endif
diff --git a/cmd/lefty/ws/none/garray.c b/cmd/lefty/ws/none/garray.c
deleted file mode 100644 (file)
index 1252c41..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-int GAcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-}
-
-int GAsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GAgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GAdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
-
-int Gaworder (Gwidget_t *widget, void *data, Gawordercb func) {
-    return 0;
-}
-
-int Gawsetmode (Gwidget_t *widget, int mode) {
-    return 0;
-}
-
-int Gawgetmode (Gwidget_t *widget) {
-    return 0;
-}
-
-void Gawdefcoordscb (int wi, Gawdata_t *dp) {
-}
diff --git a/cmd/lefty/ws/none/gbutton.c b/cmd/lefty/ws/none/gbutton.c
deleted file mode 100644 (file)
index 3062b19..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-int GBcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-    return 0;
-}
-
-int GBsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GBgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GBdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
diff --git a/cmd/lefty/ws/none/gcanvas.c b/cmd/lefty/ws/none/gcanvas.c
deleted file mode 100644 (file)
index a5038f4..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-int GCcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-}
-
-int GCsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GCgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GCdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
-
-int GCcanvasclear (Gwidget_t *widget) {
-    return 0;
-}
-
-int GCsetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    return 0;
-}
-
-int GCgetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    return 0;
-}
-
-int GCarrow (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    return 0;
-}
-
-int GCline (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    return 0;
-}
-
-int GCbox (Gwidget_t *widget, Grect_t gr, Ggattr_t *ap) {
-    return 0;
-}
-
-int GCpolygon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    return 0;
-}
-
-int GCsplinegon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    return 0;
-}
-
-int GCarc (
-    Gwidget_t *widget, Gpoint_t gc, Gsize_t gs, double ang1,
-    double ang2, Ggattr_t *ap
-) {
-    return 0;
-}
-
-int GCtext (
-    Gwidget_t *widget, Gtextline_t *tlp, int n, Gpoint_t go,
-    char *fn, double fs, char *justs, Ggattr_t *ap
-) {
-    return 0;
-}
-
-int GCgettextsize (
-    Gwidget_t *widget, Gtextline_t *tlp, int n, char *fn,
-    double fs, Gsize_t *gsp
-) {
-    return -1;
-}
-
-int GCcreatebitmap (Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t s) {
-    return 0;
-}
-
-int GCdestroybitmap (Gbitmap_t *bitmap) {
-    return 0;
-}
-
-#define COMPDIFF(a, b) (((a) > (b)) ? (a) - (b) : (b) - (a))
-#define CDIFF(a, b) ( \
-    COMPDIFF (a.red, b[0]) + COMPDIFF (a.green, b[1]) + \
-    COMPDIFF (a.blue, b[2]) \
-)
-#define CMINMAXDIFF 20000
-
-int GCreadbitmap (Gwidget_t *widget, Gbitmap_t *bitmap, FILE *fp) {
-    return 0;
-}
-
-int GCwritebitmap (Gbitmap_t *bitmap, FILE *fp) {
-    return 0;
-}
-
-int GCbitblt (
-    Gwidget_t *widget, Gpoint_t gp, Grect_t gr, Gbitmap_t *bitmap,
-    char *mode, Ggattr_t *ap
-) {
-    return 0;
-}
-
-int GCgetmousecoords (Gwidget_t *widget, Gpoint_t *gpp, int *count) {
-    return 0;
-}
diff --git a/cmd/lefty/ws/none/gcommon.c b/cmd/lefty/ws/none/gcommon.c
deleted file mode 100644 (file)
index 6cbef52..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-int Gxfd;
-Widget Groot;
-Display *Gdisplay;
-int Gpopdownflag;
-int Gscreenn;
-int Gdepth;
-
-int Ginitgraphics (void) {
-    return 0;
-}
-
-int Gtermgraphics (void) {
-    return 0;
-}
-
-int Gsync (void) {
-    return 0;
-}
-
-int Gresetbstate (int wi) {
-    return 0;
-}
-
-int Gprocessevents (int waitflag, int mode) {
-    return 0;
-}
diff --git a/cmd/lefty/ws/none/gcommon.h b/cmd/lefty/ws/none/gcommon.h
deleted file mode 100644 (file)
index 70cc685..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-typedef struct {
-    int x, y;
-} XPoint;
-typedef int Widget;
-typedef int Display;
-
-extern Widget Groot;
-extern Display *Gdisplay;
-extern int Gpopdownflag;
-extern int Gscreenn;
-extern int Gdepth;
-
-int Ginitgraphics (void);
-int Gtermgraphics (void);
-int Gsync (void);
-
-int GAcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GAsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GAgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GAdestroywidget (Gwidget_t *);
-
-int GBcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GBsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GBgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GBdestroywidget (Gwidget_t *);
-
-int GCcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GCsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GCgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GCdestroywidget (Gwidget_t *);
-int GCcanvasclear (Gwidget_t *);
-int GCsetgfxattr (Gwidget_t *, Ggattr_t *);
-int GCgetgfxattr (Gwidget_t *, Ggattr_t *);
-int GCarrow (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GCline (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GCbox (Gwidget_t *, Grect_t, Ggattr_t *);
-int GCpolygon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GCsplinegon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GCarc (Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
-int GCtext (
-    Gwidget_t *, Gtextline_t *, int, Gpoint_t,
-    char *, double, char *, Ggattr_t *
-);
-int GCgettextsize (Gwidget_t *, Gtextline_t *, int, char *, double, Gsize_t *);
-int GCcreatebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t);
-int GCdestroybitmap (Gbitmap_t *);
-int GCreadbitmap (Gwidget_t *, Gbitmap_t *, FILE *);
-int GCwritebitmap (Gbitmap_t *, FILE *);
-int GCbitblt (Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *, Ggattr_t *);
-int GCgetmousecoords (Gwidget_t *, Gpoint_t *, int *);
-
-int GLcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GLsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GLgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GLdestroywidget (Gwidget_t *);
-
-int GMcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GMsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GMgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GMdestroywidget (Gwidget_t *);
-int GMmenuaddentries (Gwidget_t *, int, char **);
-int GMmenudisplay (Gwidget_t *, Gwidget_t *);
-
-int GPcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GPsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GPgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GPdestroywidget (Gwidget_t *);
-int GPcanvasclear (Gwidget_t *);
-int GPsetgfxattr (Gwidget_t *, Ggattr_t *);
-int GPgetgfxattr (Gwidget_t *, Ggattr_t *);
-int GParrow (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GPline (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GPbox (Gwidget_t *, Grect_t, Ggattr_t *);
-int GPpolygon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GPsplinegon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GParc (Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
-int GPtext (
-    Gwidget_t *, Gtextline_t *, int, Gpoint_t,
-    char *, double, char *, Ggattr_t *
-);
-int GPcreatebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t);
-int GPdestroybitmap (Gbitmap_t *);
-int GPreadbitmap (Gwidget_t *, Gbitmap_t *, FILE *);
-int GPwritebitmap (Gbitmap_t *, FILE *);
-int GPbitblt (Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *, Ggattr_t *);
-
-int GQcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GQsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GQgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GQdestroywidget (Gwidget_t *);
-int GQqueryask (Gwidget_t *, char *, char *, char *, int);
-
-int GScreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GSsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GSgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GSdestroywidget (Gwidget_t *);
-
-int GTcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GTsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GTgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GTdestroywidget (Gwidget_t *);
-
-int GVcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GVsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GVgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GVdestroywidget (Gwidget_t *);
-
-void Gawdefcoordscb (int, Gawdata_t *);
diff --git a/cmd/lefty/ws/none/glabel.c b/cmd/lefty/ws/none/glabel.c
deleted file mode 100644 (file)
index 0607551..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-int GLcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-}
-
-int GLsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GLgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GLdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
diff --git a/cmd/lefty/ws/none/gmenu.c b/cmd/lefty/ws/none/gmenu.c
deleted file mode 100644 (file)
index 101f7e4..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-int GMcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-}
-
-int GMsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GMgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GMdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
-
-int GMmenuaddentries (Gwidget_t *widget, int en, char **ep) {
-    return 0;
-}
-
-int GMmenudisplay (Gwidget_t *parent, Gwidget_t *widget) {
-    return -1;
-}
diff --git a/cmd/lefty/ws/none/gpcanvas.c b/cmd/lefty/ws/none/gpcanvas.c
deleted file mode 100644 (file)
index a70b678..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-char *Gpscanvasname = "out.ps";
-
-int GPcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-}
-
-int GPsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GPgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GPdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
-
-int GPcanvasclear (Gwidget_t *widget) {
-    return 0;
-}
-
-int GPsetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    return 0;
-}
-
-int GPgetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    return 0;
-}
-
-int GParrow (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    return 0;
-}
-
-int GPline (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    return 0;
-}
-
-int GPbox (Gwidget_t *widget, Grect_t gr, Ggattr_t *ap) {
-    return 0;
-}
-
-int GPpolygon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    return 0;
-}
-
-int GPsplinegon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    return 0;
-}
-
-int GParc (
-    Gwidget_t *widget, Gpoint_t gc, Gsize_t gs,
-    double ang1, double ang2, Ggattr_t *ap
-) {
-    return 0;
-}
-
-int GPtext (
-    Gwidget_t *widget, Gtextline_t *tlp, int n, Gpoint_t go, char *fn,
-    double fs, char *justs, Ggattr_t *ap
-) {
-    return 0;
-}
-
-static char *findfont (char *name) {
-    return NULL;
-}
-
-int GPcreatebitmap (Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t s) {
-    return 0;
-}
-
-int GPdestroybitmap (Gbitmap_t *bitmap) {
-    return 0;
-}
-
-int GPreadbitmap (Gwidget_t *widget, Gbitmap_t *bitmap, FILE *fp) {
-    return 0;
-}
-
-int GPwritebitmap (Gbitmap_t *bitmap, FILE *fp) {
-    return -1;
-}
-
-int GPbitblt (
-    Gwidget_t *widget, Gpoint_t gp, Grect_t gr, Gbitmap_t *bitmap,
-    char *mode, Ggattr_t *ap
-) {
-    return 0;
-}
diff --git a/cmd/lefty/ws/none/gquery.c b/cmd/lefty/ws/none/gquery.c
deleted file mode 100644 (file)
index 08c02c2..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-int GQcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-}
-
-int GQsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GQgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GQdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
-
-int GQqueryask (
-    Gwidget_t *widget, char *prompt, char *args,
-    char *responsep, int responsen
-) {
-    return 0;
-}
diff --git a/cmd/lefty/ws/none/gscroll.c b/cmd/lefty/ws/none/gscroll.c
deleted file mode 100644 (file)
index 6da078c..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-int GScreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-}
-
-int GSsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GSgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GSdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
diff --git a/cmd/lefty/ws/none/gtext.c b/cmd/lefty/ws/none/gtext.c
deleted file mode 100644 (file)
index c45200d..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-int GTcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-}
-
-int GTsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GTgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GTdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
diff --git a/cmd/lefty/ws/none/gview.c b/cmd/lefty/ws/none/gview.c
deleted file mode 100644 (file)
index 371c98f..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-int GVcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    return -1;
-}
-
-int GVsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GVgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    return 0;
-}
-
-int GVdestroywidget (Gwidget_t *widget) {
-    return 0;
-}
diff --git a/cmd/lefty/ws/x11/garray.c b/cmd/lefty/ws/x11/garray.c
deleted file mode 100644 (file)
index dfd3e7f..0000000
+++ /dev/null
@@ -1,544 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-#define WAU widget->u.a
-
-extern WidgetClass arrayWidgetClass;
-
-static void awcallback (Widget, XtPointer, XtPointer);
-
-int GAcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    int ai;
-    XColor c;
-    int color;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    WAU->func = NULL;
-    ps.x = ps.y = MINAWSIZE;
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINAWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRMODE:
-            if (strcmp ("horizontal", attrp[ai].u.t) == 0) {
-                ADD2ARGS (XtNorientation, XtorientHorizontal);
-                WAU->mode = G_AWHARRAY;
-            } else if (strcmp ("vertical", attrp[ai].u.t) == 0) {
-                WAU->mode = G_AWVARRAY;
-            } else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRLAYOUT:
-            if (strcmp ("on", attrp[ai].u.t) == 0)
-                Gawsetmode (widget, FALSE);
-            else if (strcmp ("off", attrp[ai].u.t) == 0)
-                Gawsetmode (widget, TRUE);
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRRESIZECB:
-            WAU->func = (Gawcoordscb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    ADD2ARGS (XtNwidth, ps.x);
-    ADD2ARGS (XtNheight, ps.y);
-    if (!(widget->w = XtCreateWidget (
-        "array", arrayWidgetClass, parent->w, argp, argn
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    XtAddCallback (widget->w, XtNcallback, awcallback, (XtPointer) NULL);
-    Glazymanage (widget->w);
-    return 0;
-}
-
-int GAsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PIXsize_t ps;
-    int ai;
-
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINAWSIZE);
-            ADD2ARGS (XtNwidth, ps.x);
-            ADD2ARGS (XtNheight, ps.y);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRMODE:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "mode");
-            return -1;
-        case G_ATTRLAYOUT:
-            if (strcmp ("on", attrp[ai].u.t) == 0)
-                Gawsetmode (widget, FALSE);
-            else if (strcmp ("off", attrp[ai].u.t) == 0)
-                Gawsetmode (widget, TRUE);
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRRESIZECB:
-            WAU->func = (Gawcoordscb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    XtSetValues (widget->w, argp, argn);
-    return 0;
-}
-
-int GAgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Dimension width, height;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        RESETARGS;
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            ADD2ARGS (XtNwidth, &width);
-            ADD2ARGS (XtNheight, &height);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, &width);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.i = width;
-            break;
-        case G_ATTRMODE:
-            attrp[ai].u.t = (
-                WAU->mode == G_AWHARRAY
-            ) ? "horizontal" : "vertical";
-            break;
-        case G_ATTRLAYOUT:
-            attrp[ai].u.t = (Gawgetmode (widget)) ? "off" : "on";
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRRESIZECB:
-            attrp[ai].u.func = WAU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GAdestroywidget (Gwidget_t *widget) {
-    XtDestroyWidget (widget->w);
-    return 0;
-}
-
-static void awcallback (Widget w, XtPointer clientdata, XtPointer calldata) {
-    Gwidget_t *widget;
-
-    if (!(widget = findwidget ((unsigned long) w, G_ARRAYWIDGET)))
-        return;
-    if (WAU->func)
-        (*WAU->func) (widget - &Gwidgets[0], (Gawdata_t *) calldata);
-    else
-        Gawdefcoordscb (widget - &Gwidgets[0], (Gawdata_t *) calldata);
-}
-
-/* the rest of this file contains the implementation of the array widget */
-
-#include <X11/IntrinsicP.h>
-
-typedef struct _ArrayClassRec *ArrayWidgetClass;
-typedef struct _ArrayRec *ArrayWidget;
-
-typedef struct _ArrayClassPart {
-    int dummy; /* not used */
-} ArrayClassPart;
-
-typedef struct _ArrayClassRec {
-    CoreClassPart core_class;
-    CompositeClassPart composite_class;
-    ArrayClassPart array_class;
-} ArrayClassRec;
-
-typedef struct _ArrayPart {
-    XtCallbackList callbacks;
-    XtOrientation orientation;
-    Gawdata_t data;
-    int batchmode;
-} ArrayPart;
-
-typedef struct _ArrayRec {
-    CorePart core;
-    CompositePart composite;
-    ArrayPart array;
-} ArrayRec;
-
-#define CHILDINCR 10
-#define CHILDSIZE sizeof (Gawcarray_t)
-
-static XtResource resources[] = {
-    {
-        XtNcallback,
-        XtCCallback,
-        XtRCallback,
-        sizeof (XtPointer),
-        XtOffsetOf (ArrayRec, array.callbacks),
-        XtRCallback, (XtPointer) NULL
-    },
-    {
-        XtNorientation,
-        XtCOrientation,
-        XtROrientation,
-        sizeof (XtOrientation),
-        XtOffsetOf (ArrayRec, array.orientation),
-        XtRImmediate, (XtPointer) XtorientVertical
-    }
-};
-
-static void ClassInitialize (void);
-static void Initialize (Widget, Widget, ArgList, Cardinal *);
-static void Destroy (Widget);
-static void Resize (Widget);
-static Boolean SetValues (Widget, Widget, Widget, ArgList, Cardinal *);
-static XtGeometryResult GeometryManager (
-    Widget, XtWidgetGeometry *, XtWidgetGeometry *
-);
-static void ChangeManaged (Widget);
-static void InsertChild (Widget);
-static void DeleteChild (Widget);
-static void dolayout (ArrayWidget, int);
-
-ArrayClassRec arrayClassRec = {
-    { /* core_class fields */
-        /* superclass          */ (WidgetClass) &compositeClassRec,
-        /* class_name          */ "Array",
-        /* widget_size         */ sizeof(ArrayRec),
-        /* class_initialize    */ ClassInitialize,
-        /* class_part_init     */ NULL,
-        /* class_inited        */ FALSE,
-        /* initialize          */ Initialize,
-        /* initialize_hook     */ NULL,
-        /* realize             */ XtInheritRealize,
-        /* actions             */ NULL,
-        /* num_actions         */ 0,
-        /* resources           */ resources,
-        /* num_resources       */ XtNumber (resources),
-        /* xrm_class           */ NULLQUARK,
-        /* compress_motion     */ TRUE,
-        /* compress_exposure   */ TRUE,
-        /* compress_enterleave */ TRUE,
-        /* visible_interest    */ FALSE,
-        /* destroy             */ Destroy,
-        /* resize              */ Resize,
-        /* expose              */ XtInheritExpose,
-        /* set_values          */ SetValues,
-        /* set_values_hook     */ NULL,
-        /* set_values_almost   */ XtInheritSetValuesAlmost,
-        /* get_values_hook     */ NULL,
-        /* accept_focus        */ NULL,
-        /* version             */ XtVersion,
-        /* callback_private    */ NULL,
-        /* tm_table            */ NULL,
-        /* query_geometry      */ XtInheritQueryGeometry,
-        /* display_accelerator */ XtInheritDisplayAccelerator,
-        /* extension           */ NULL
-    },
-    { /* composite_class fields */
-        /* geometry_manager */ GeometryManager,
-        /* change_managed   */ ChangeManaged,
-        /* insert_child     */ InsertChild,
-        /* delete_child     */ DeleteChild,
-        /* extension        */ NULL
-    },
-    { /* array_class fields */
-        /* dummy */ 0
-    }
-};
-
-WidgetClass arrayWidgetClass = (WidgetClass)&arrayClassRec;
-
-int Gaworder (Gwidget_t *widget, void *data, Gawordercb func) {
-    ArrayWidget aw;
-
-    aw = (ArrayWidget) widget->w;
-    (*func) (data, &aw->array.data);
-    dolayout (aw, TRUE);
-    return 0;
-}
-
-int Gawsetmode (Gwidget_t *widget, int mode) {
-    ArrayWidget aw;
-
-    aw = (ArrayWidget) widget->w;
-    aw->array.batchmode = mode;
-    dolayout (aw, TRUE);
-    return 0;
-}
-
-int Gawgetmode (Gwidget_t *widget) {
-    ArrayWidget aw;
-
-    aw = (ArrayWidget) widget->w;
-    return aw->array.batchmode;
-}
-
-void Gawdefcoordscb (int wi, Gawdata_t *dp) {
-    Gawcarray_t *cp;
-    int sx, sy, csx, csy, ci;
-
-    sx = dp->sx, sy = dp->sy;
-    csx = csy = 0;
-    for (ci = 0; ci < dp->cj; ci++) {
-        cp = &dp->carray[ci];
-        if (!cp->flag)
-            continue;
-        cp->ox = csx, cp->oy = csy;
-        if (dp->type == G_AWVARRAY)
-            cp->sx = sx - 2 * cp->bs, csy += cp->sy + 2 * cp->bs;
-        else
-            cp->sy = sy - 2 * cp->bs, csx += cp->sx + 2 * cp->bs;
-    }
-    if (dp->type == G_AWVARRAY)
-        dp->sy = csy;
-    else
-        dp->sx = csx;
-}
-
-static void ClassInitialize (void) {
-    XtAddConverter (
-        XtRString, XtROrientation, XmuCvtStringToOrientation, NULL, 0
-    );
-}
-
-static void Initialize (
-    Widget reqw, Widget neww, ArgList args, Cardinal *num_args
-) {
-    ArrayWidget aw;
-
-    aw = (ArrayWidget) neww;
-    if (aw->array.orientation == XtorientVertical)
-        aw->array.data.type = G_AWVARRAY;
-    else
-        aw->array.data.type = G_AWHARRAY;
-    aw->array.data.carray = Marrayalloc ((long) CHILDINCR * CHILDSIZE);
-    aw->array.data.cn = CHILDINCR;
-    aw->array.data.cj = 0;
-    aw->array.batchmode = FALSE;
-    if (aw->core.width == 0)
-        aw->core.width = 100;
-    if (aw->core.height == 0)
-        aw->core.height = 100;
-}
-
-static void Destroy (Widget w) {
-    ArrayWidget aw;
-
-    aw = (ArrayWidget) w;
-    Marrayfree (aw->array.data.carray);
-    aw->array.data.cn = aw->array.data.cj = 0;
-}
-
-static void Resize (Widget w) {
-    dolayout ((ArrayWidget) w, FALSE);
-}
-
-static Boolean SetValues (
-    Widget curw, Widget reqw, Widget neww, ArgList args, Cardinal *num_args
-) {
-    ArrayWidget curaw;
-    ArrayWidget newaw;
-
-    curaw = (ArrayWidget) curw;
-    newaw = (ArrayWidget) neww;
-    if (curaw->array.orientation != newaw->array.orientation) {
-        if (newaw->array.orientation == XtorientVertical)
-            newaw->array.data.type = G_AWVARRAY;
-        else
-            newaw->array.data.type = G_AWHARRAY;
-        dolayout (newaw, TRUE);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-static XtGeometryResult GeometryManager (
-    Widget w, XtWidgetGeometry *req, XtWidgetGeometry *rep
-) {
-    Dimension width, height;
-
-    if (req->request_mode & ~(CWX | CWY | CWWidth | CWHeight))
-        return XtGeometryNo;
-
-    if (req->request_mode & (CWX | CWY | CWWidth | CWHeight)) {
-        width = (req->request_mode & CWWidth) ? req->width : w->core.width;
-        height = (req->request_mode & CWHeight) ? req->height : w->core.height;
-        w->core.width = width, w->core.height = height;
-        dolayout ((ArrayWidget) XtParent (w), TRUE);
-        return XtGeometryYes;
-    }
-    return XtGeometryYes;
-}
-
-static void ChangeManaged (Widget w) {
-    ArrayWidget aw;
-
-    aw = (ArrayWidget) w;
-    if (!aw->array.batchmode)
-        dolayout (aw, TRUE);
-}
-
-static void InsertChild (Widget w) {
-    ArrayWidget aw;
-    CompositeWidgetClass sclass;
-
-    sclass = (CompositeWidgetClass) compositeWidgetClass;
-    (*sclass->composite_class.insert_child) (w);
-    aw = (ArrayWidget) XtParent (w);
-    if (aw->array.data.cj == aw->array.data.cn) {
-        aw->array.data.carray = Marraygrow (
-            aw->array.data.carray,
-            (long) (aw->array.data.cn + CHILDINCR) * CHILDSIZE
-        );
-        aw->array.data.cn += CHILDINCR;
-    }
-    aw->array.data.carray[aw->array.data.cj++].w = w;
-}
-
-static void DeleteChild (Widget w) {
-    ArrayWidget aw;
-    CompositeWidgetClass sclass;
-    int ci;
-
-    sclass = (CompositeWidgetClass) compositeWidgetClass;
-    (*sclass->composite_class.delete_child) (w);
-    aw = (ArrayWidget) XtParent (w);
-    for (ci = 0; ci < aw->array.data.cj; ci++)
-        if (aw->array.data.carray[ci].w == w)
-            break;
-    if (ci < aw->array.data.cj) {
-        for (; ci + 1 < aw->array.data.cj; ci++)
-            aw->array.data.carray[ci].w = aw->array.data.carray[ci + 1].w;
-        aw->array.data.cj--;
-    }
-}
-
-static void dolayout (ArrayWidget aw, int flag) {
-    XtWidgetGeometry req, ret_req;
-    Gawdata_t *dp;
-    Gawcarray_t *cp;
-    int sx, sy, ci;
-
-    if (aw->array.batchmode)
-        return;
-    dp = &aw->array.data;
-    for (ci = 0; ci < dp->cj; ci++) {
-        if (!XtIsManaged (dp->carray[ci].w)) {
-            dp->carray[ci].flag = 0;
-            continue;
-        }
-        cp = &dp->carray[ci];
-        cp->flag = 1;
-        cp->ox = cp->w->core.x;
-        cp->oy = cp->w->core.y;
-        cp->sx = cp->w->core.width;
-        cp->sy = cp->w->core.height;
-        cp->bs = cp->w->core.border_width;
-    }
-    dp->sx = aw->core.width, dp->sy = aw->core.height;
-    XtCallCallbackList ((Widget) aw, aw->array.callbacks, dp);
-    if ((sx = dp->sx) < MINAWSIZE)
-        sx = MINAWSIZE;
-    if ((sy = dp->sy) < MINAWSIZE)
-        sy = MINAWSIZE;
-    if (flag && (aw->core.width != sx || aw->core.height != sy)) {
-        req.width = sx, req.height = sy;
-        req.request_mode = CWWidth | CWHeight;
-        if (XtMakeGeometryRequest (
-            (Widget) aw, &req, &ret_req
-        ) == XtGeometryAlmost) {
-            req = ret_req;
-            XtMakeGeometryRequest ((Widget) aw, &req, &ret_req);
-            dp->sx = req.width, dp->sy = req.height;
-            XtCallCallbackList ((Widget) aw, aw->array.callbacks, dp);
-        }
-    }
-    for (ci = 0; ci < dp->cj; ci++) {
-        cp = &dp->carray[ci];
-        if (!cp->flag)
-            continue;
-        XtConfigureWidget (cp->w, cp->ox, cp->oy, cp->sx, cp->sy, cp->bs);
-    }
-}
diff --git a/cmd/lefty/ws/x11/gbutton.c b/cmd/lefty/ws/x11/gbutton.c
deleted file mode 100644 (file)
index 93d1d3f..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include <string.h>
-
-#define WBU widget->u.b
-
-static void bwcallback (Widget, XtPointer, XtPointer);
-
-int GBcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget,
-    int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    char *s;
-    int ai;
-    XColor c;
-    int color;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    WBU->func = NULL;
-    ps.x = ps.y = MINBWSIZE;
-    s = NULL;
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINBWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRTEXT:
-            s = attrp[ai].u.t;
-            ADD2ARGS (XtNlabel, s);
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRBUTTONCB:
-            WBU->func = (Gbuttoncb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    if (!s || strcmp(s, "") == 0) {
-        ADD2ARGS (XtNwidth, ps.x);
-        ADD2ARGS (XtNheight, ps.y);
-    } else {
-        if (ps.x > MINBWSIZE)
-            ADD2ARGS (XtNwidth, ps.x);
-        if (ps.y > MINBWSIZE)
-            ADD2ARGS (XtNheight, ps.y);
-    }
-    ADD2ARGS (XtNhighlightThickness, 0);
-    ADD2ARGS (XtNinternalHeight, 0);
-    ADD2ARGS (XtNinternalWidth, 0);
-    ADD2ARGS (XtNjustify, XtJustifyLeft);
-    if (!(widget->w = XtCreateWidget (
-        "command", commandWidgetClass, parent->w, argp, argn
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    XtAddCallback (
-        widget->w, XtNcallback, bwcallback, (XtPointer) widget->udata
-    );
-    Glazymanage (widget->w);
-    return 0;
-}
-
-int GBsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PIXsize_t ps;
-    int ai;
-    XColor c;
-    int color;
-
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINBWSIZE);
-            ADD2ARGS (XtNwidth, ps.x);
-            ADD2ARGS (XtNheight, ps.y);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRTEXT:
-            ADD2ARGS (XtNlabel, attrp[ai].u.t);
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRBUTTONCB:
-            WBU->func = (Gbuttoncb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    XtSetValues (widget->w, argp, argn);
-    return 0;
-}
-
-int GBgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Dimension width, height;
-    char *s;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        RESETARGS;
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            ADD2ARGS (XtNwidth, &width);
-            ADD2ARGS (XtNheight, &height);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, &width);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.i = width;
-            break;
-        case G_ATTRTEXT:
-            ADD2ARGS (XtNlabel, &s);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.t = s;
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRBUTTONCB:
-            attrp[ai].u.func = WBU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GBdestroywidget (Gwidget_t *widget) {
-    XtDestroyWidget (widget->w);
-    return 0;
-}
-
-static void bwcallback (Widget w, XtPointer clientdata, XtPointer calldata) {
-    Gwidget_t *widget;
-
-    widget = findwidget ((unsigned long) w, G_BUTTONWIDGET);
-    if (WBU->func)
-        (*WBU->func) (widget - &Gwidgets[0], clientdata);
-}
diff --git a/cmd/lefty/ws/x11/gcanvas.c b/cmd/lefty/ws/x11/gcanvas.c
deleted file mode 100644 (file)
index 7215ffd..0000000
+++ /dev/null
@@ -1,1715 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-#ifdef FEATURE_GMAP
-#include <gmap.h>
-#endif
-#include <math.h>
-#include <string.h>
-
-#define WCU widget->u.c
-#define WINDOW widget->u.c->window
-#define GC widget->u.c->gc
-#define ISVISIBLE(r) ( \
-    (r.o.x <= WCU->clip.c.x) && (r.c.x >= WCU->clip.o.x) && \
-    (r.o.y <= WCU->clip.c.y) && (r.c.y >= WCU->clip.o.y) \
-)
-
-#define IS8BIT(font) ((font)->min_byte1 == 0 && (font)->max_byte1 == 0)
-
-static struct cursormap_t {
-    Cursor id;
-    char name[40];
-} cursormap[XC_num_glyphs];
-static int curcursori = -1;
-
-#define max(a, b) (((a) >= (b)) ? (a) : (b))
-#define min(a, b) (((a) <= (b)) ? (a) : (b))
-
-static char gstyles[][2] = {
-    /* G_SOLID */       { 16,  0, },
-    /* G_DASHED */      {  4,  4, },
-    /* G_DOTTED */      {  2,  2, },
-    /* G_LONGDASHED */  {  4, 12, },
-    /* G_SHORTDASHED */ { 12,  4, },
-};
-
-static char grays[][4] = {
-    { 0x00,0x00,0x00,0x00, },
-    { 0x08,0x00,0x00,0x00, },
-    { 0x08,0x00,0x02,0x00, },
-    { 0x0A,0x00,0x02,0x00, },
-    { 0x0A,0x00,0x0A,0x00, },
-    { 0x0A,0x04,0x0A,0x00, },
-    { 0x0A,0x04,0x0A,0x01, },
-    { 0x0A,0x05,0x0A,0x01, },
-    { 0x0A,0x05,0x0A,0x05, },
-    { 0x0E,0x05,0x0A,0x05, },
-    { 0x0E,0x05,0x0B,0x05, },
-    { 0x0F,0x05,0x0B,0x05, },
-    { 0x0F,0x05,0x0F,0x05, },
-    { 0x0F,0x0D,0x0F,0x05, },
-    { 0x0F,0x0D,0x0F,0x07, },
-    { 0x0F,0x0F,0x0F,0x07, },
-    { 0x0F,0x0F,0x0F,0x0F, },
-};
-
-static void bezier (PIXpoint_t, PIXpoint_t, PIXpoint_t, PIXpoint_t);
-static XFontStruct *findfont (char *, int);
-static int scalebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t, int, int);
-static void setgattr (Gwidget_t *, Ggattr_t *);
-
-static PIXrect_t  rdrawtopix (Gwidget_t *, Grect_t);
-static PIXpoint_t pdrawtopix (Gwidget_t *, Gpoint_t);
-static PIXsize_t  sdrawtopix (Gwidget_t *, Gsize_t);
-static Gpoint_t   Gppixtodraw (Gwidget_t *, PIXpoint_t);
-static Gsize_t    spixtodraw (Gwidget_t *, PIXsize_t);
-static Grect_t    rpixtodraw (Gwidget_t *, PIXrect_t);
-static PIXrect_t  rdrawtobpix (Gbitmap_t *, Grect_t);
-static PIXpoint_t pdrawtobpix (Gbitmap_t *, Gpoint_t);
-static void       adjustclip (Gwidget_t *);
-
-static Bool cwvpredicate (Display *, XEvent *, XPointer);
-static void cweventhandler (Widget, XtPointer, XEvent *, Boolean *);
-static Bool cwepredicate (Display *, XEvent *, XPointer);
-
-int GCcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    Dimension width, height;
-#ifdef FEATURE_BACKINGSTORE
-    XSetWindowAttributes xswa;
-#endif
-    XEvent ev;
-    XColor *cp;
-    XGCValues gcv;
-    int curi, color, ai, r, g, b, i;
-#ifdef FEATURE_GMAP
-    XVisualInfo *vip;
-    int gmapmode = FALSE;
-#endif
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    WCU->func = NULL;
-    WCU->needredraw = FALSE;
-    WCU->buttonsdown = 0;
-    WCU->bstate[0] = WCU->bstate[1] = WCU->bstate[2] = 0;
-    WCU->bstate[3] = WCU->bstate[4] = 0;
-    ps.x = ps.y = MINCWSIZE;
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINCWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-#ifdef FEATURE_GMAP
-        case G_ATTRMODE:
-            if (strcmp ("gmap", attrp[ai].u.t) == 0) {
-                gmapmode = TRUE;
-            } else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-#endif
-        case G_ATTRCURSOR:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRCOLOR:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRVIEWPORT:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRWINDOW:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WCU->func = (Gcanvascb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    ADD2ARGS (XtNwidth, ps.x);
-    ADD2ARGS (XtNheight, ps.y);
-#ifdef FEATURE_GMAP
-    if (gmapmode) {
-        vip = pfChooseFBConfig (Gdisplay, -1, NULL);
-        ADD2ARGS (GLwNvisualInfo, vip);
-        if (!(widget->w = XtCreateWidget (
-            "graphics", glwDrawingAreaWidgetClass, parent->w, argp, argn
-        ))) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-    } else {
-        if (!(widget->w = XtCreateWidget (
-            "graphics", coreWidgetClass, parent->w, argp, argn
-        ))) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-    }
-    WCU->gmapmode = gmapmode;
-#else
-    if (!(widget->w = XtCreateWidget (
-        "graphics", coreWidgetClass, parent->w, argp, argn
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-#endif
-    XtOverrideTranslations (widget->w, Gcwanytable);
-    XtAddEventHandler (
-        widget->w, VisibilityChangeMask | ExposureMask,
-        FALSE, cweventhandler, NULL
-    );
-    Glazymanage (widget->w);
-    Gflushlazyq ();
-#ifdef FEATURE_BACKINGSTORE
-    xswa.backing_store = WhenMapped;
-    XChangeWindowAttributes (
-        Gdisplay, XtWindow (widget->w), CWBackingStore, &xswa
-    );
-#endif
-    /* wait for window to become visible */
-    XPeekIfEvent (Gdisplay, &ev, cwvpredicate, (XPointer) XtWindow (widget->w));
-    RESETARGS;
-    ADD2ARGS (XtNwidth, &width);
-    ADD2ARGS (XtNheight, &height);
-    XtGetValues (widget->w, argp, argn);
-    ps.x = width, ps.y = height;
-    WCU->window = XtWindow (widget->w);
-    WCU->cmap = DefaultColormap (Gdisplay, Gscreenn);
-    WCU->gc = XCreateGC (Gdisplay, WCU->window, 0, NULL);
-    RESETARGS;
-    WCU->colors[0].color.pixel = WCU->colors[1].color.pixel = 1000000;
-    ADD2ARGS (XtNbackground, &WCU->colors[0].color.pixel);
-    ADD2ARGS (XtNforeground, &WCU->colors[1].color.pixel);
-    XtGetValues (widget->w, argp, argn);
-    if (WCU->colors[0].color.pixel == 1000000) {
-        if (XGetGCValues (Gdisplay, GC, GCBackground, &gcv) != 0)
-            WCU->colors[0].color.pixel = gcv.background;
-        else
-            WCU->colors[0].color.pixel = WhitePixel (Gdisplay, Gscreenn);
-    }
-    if (WCU->colors[1].color.pixel == 1000000) {
-        if (XGetGCValues (Gdisplay, GC, GCForeground, &gcv) != 0)
-            WCU->colors[1].color.pixel = gcv.foreground;
-        else
-            WCU->colors[1].color.pixel = BlackPixel (Gdisplay, Gscreenn);
-    }
-    XQueryColor (Gdisplay, WCU->cmap, &WCU->colors[0].color);
-    WCU->colors[0].inuse = TRUE;
-    XQueryColor (Gdisplay, WCU->cmap, &WCU->colors[1].color);
-    WCU->colors[1].inuse = TRUE;
-    WCU->allocedcolor[0] = WCU->allocedcolor[1] = FALSE;
-    for (i = 2; i < G_MAXCOLORS; i++)
-        WCU->colors[i].inuse = FALSE;
-    WCU->gattr.color = 1;
-    XSetBackground (Gdisplay, GC, WCU->colors[0].color.pixel);
-    XSetForeground (Gdisplay, GC, WCU->colors[1].color.pixel);
-    WCU->gattr.width = 0;
-    WCU->gattr.mode = G_SRC;
-    WCU->gattr.fill = 0;
-    WCU->gattr.style = 0;
-    WCU->defgattr = WCU->gattr;
-    WCU->font = NULL;
-    WCU->wrect.o.x = 0.0, WCU->wrect.o.y = 0.0;
-    WCU->wrect.c.x = 1.0, WCU->wrect.c.y = 1.0;
-    WCU->vsize.x = ps.x, WCU->vsize.y = ps.y;
-    if (Gdepth == 1) {
-        XSetFillStyle (Gdisplay, GC, FillTiled);
-        for (i = 0; i < 17; i++)
-            WCU->grays[i] = XCreatePixmapFromBitmapData (
-                Gdisplay, WCU->window, &grays[i][0], 4, 4,
-                BlackPixel (Gdisplay, Gscreenn),
-                WhitePixel (Gdisplay, Gscreenn), 1
-            );
-    }
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRCURSOR:
-            if ((curi = XmuCursorNameToIndex (attrp[ai].u.t)) == -1) {
-                if (strcmp (attrp[ai].u.t, "default") == 0) {
-                    XUndefineCursor (Gdisplay, XtWindow (widget->w));
-                    curcursori = -1;
-                } else {
-                    Gerr (POS, G_ERRNOSUCHCURSOR, attrp[ai].u.t);
-                    return -1;
-                }
-            } else {
-                if (!cursormap[curi].id) {
-                    cursormap[curi].id = XCreateFontCursor (Gdisplay, curi);
-                    strcpy (cursormap[curi].name, attrp[ai].u.t);
-                }
-                XDefineCursor (
-                    Gdisplay, XtWindow (widget->w), cursormap[curi].id
-                );
-                curcursori = curi;
-            }
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            r = attrp[ai].u.c.r * 257;
-            g = attrp[ai].u.c.g * 257;
-            b = attrp[ai].u.c.b * 257;
-            cp = &WCU->colors[color].color;
-            if (WCU->colors[color].inuse)
-                if (cp->red != r || cp->green != g || cp->blue != b)
-                    if (color > 1 || WCU->allocedcolor[color])
-                        XFreeColors (Gdisplay, WCU->cmap, &cp->pixel, 1, 0);
-            cp->red = r, cp->green = g, cp->blue = b;
-            if (XAllocColor (Gdisplay, WCU->cmap, cp)) {
-                WCU->colors[color].inuse = TRUE;
-                if (color <= 1)
-                    WCU->allocedcolor[color] = TRUE;
-            }
-            /* XAllocColor may change the rgb values */
-            cp->red = r, cp->green = g, cp->blue = b;
-            if (color == WCU->gattr.color)
-                WCU->gattr.color = -1;
-            if (color == 0 || color == 1) {
-                RESETARGS;
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, cp->pixel);
-                else
-                    ADD2ARGS (XtNforeground, cp->pixel);
-                XtSetValues (widget->w, argp, argn);
-            }
-            break;
-        case G_ATTRVIEWPORT:
-            WCU->vsize.x = (int) (attrp[ai].u.s.x + 0.5);
-            WCU->vsize.y = (int) (attrp[ai].u.s.y + 0.5);
-            if (WCU->vsize.x > 32767)
-                WCU->vsize.x = 32767;
-            if (WCU->vsize.y > 32767)
-                WCU->vsize.y = 32767;
-            RESETARGS;
-            ADD2ARGS (XtNwidth, WCU->vsize.x);
-            ADD2ARGS (XtNheight, WCU->vsize.y);
-            XtSetValues (widget->w, argp, argn);
-            break;
-        case G_ATTRWINDOW:
-            WCU->wrect = attrp[ai].u.r;
-            break;
-        }
-    }
-    adjustclip (widget);
-    return 0;
-}
-
-int GCsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PIXsize_t ps;
-    XColor *cp;
-    int curi, color, ai, r, g, b;
-
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINCWSIZE);
-            ADD2ARGS (XtNwidth, ps.x);
-            ADD2ARGS (XtNheight, ps.y);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRCURSOR:
-            if ((curi = XmuCursorNameToIndex (attrp[ai].u.t)) == -1) {
-                if (strcmp (attrp[ai].u.t, "default") == 0) {
-                    XUndefineCursor (Gdisplay, XtWindow (widget->w));
-                    curcursori = -1;
-                } else {
-                    Gerr (POS, G_ERRNOSUCHCURSOR, attrp[ai].u.t);
-                    return -1;
-                }
-            } else {
-                if (!cursormap[curi].id) {
-                    cursormap[curi].id = XCreateFontCursor (Gdisplay, curi);
-                    strcpy (cursormap[curi].name, attrp[ai].u.t);
-                }
-                XDefineCursor (
-                    Gdisplay, XtWindow (widget->w), cursormap[curi].id
-                );
-                curcursori = curi;
-            }
-            Gsync ();
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            r = attrp[ai].u.c.r * 257;
-            g = attrp[ai].u.c.g * 257;
-            b = attrp[ai].u.c.b * 257;
-            cp = &WCU->colors[color].color;
-            if (WCU->colors[color].inuse)
-                if (cp->red != r || cp->green != g || cp->blue != b)
-                    if (color > 1 || WCU->allocedcolor[color])
-                        XFreeColors (Gdisplay, WCU->cmap, &cp->pixel, 1, 0);
-            cp->red = r, cp->green = g, cp->blue = b;
-            if (XAllocColor (Gdisplay, WCU->cmap, cp)) {
-                WCU->colors[color].inuse = TRUE;
-                if (color <= 1)
-                    WCU->allocedcolor[color] = TRUE;
-            }
-            /* XAllocColor may change the rgb values */
-            cp->red = r, cp->green = g, cp->blue = b;
-            if (color == 0) {
-                XSetBackground (Gdisplay, GC, WCU->colors[0].color.pixel);
-                ADD2ARGS (XtNbackground, WCU->colors[0].color.pixel);
-            } else if (color == 1) {
-                XSetForeground (Gdisplay, GC, WCU->colors[1].color.pixel);
-                ADD2ARGS (XtNforeground, WCU->colors[1].color.pixel);
-            }
-            XtSetValues (widget->w, argp, argn);
-            RESETARGS;
-            if (color == WCU->gattr.color)
-                WCU->gattr.color = -1;
-            break;
-        case G_ATTRVIEWPORT:
-            WCU->vsize.x = (int) (attrp[ai].u.s.x + 0.5);
-            WCU->vsize.y = (int) (attrp[ai].u.s.y + 0.5);
-            if (WCU->vsize.x > 32767)
-                WCU->vsize.x = 32767;
-            if (WCU->vsize.y > 32767)
-                WCU->vsize.y = 32767;
-            ADD2ARGS (XtNwidth, WCU->vsize.x);
-            ADD2ARGS (XtNheight, WCU->vsize.y);
-            XtSetValues (widget->w, argp, argn);
-            adjustclip (widget);
-            RESETARGS;
-            break;
-        case G_ATTRWINDOW:
-            WCU->wrect = attrp[ai].u.r;
-            XtSetValues (widget->w, argp, argn);
-            adjustclip (widget);
-            RESETARGS;
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WCU->func = (Gcanvascb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    XtSetValues (widget->w, argp, argn);
-    return 0;
-}
-
-int GCgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    XColor *cp;
-    Dimension width, height;
-    int ai, color;
-
-    for (ai = 0; ai < attrn; ai++) {
-        RESETARGS;
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            ADD2ARGS (XtNwidth, &width);
-            ADD2ARGS (XtNheight, &height);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, &width);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.i = width;
-            break;
-        case G_ATTRCURSOR:
-            attrp[ai].u.t = (
-                curcursori == -1
-            ) ? "default" : cursormap[curcursori].name;
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            if (WCU->colors[color].inuse) {
-                cp = &WCU->colors[color].color;
-                attrp[ai].u.c.r = cp->red / 257.0;
-                attrp[ai].u.c.g = cp->green / 257.0;
-                attrp[ai].u.c.b = cp->blue / 257.0;
-            } else {
-                attrp[ai].u.c.r = -1;
-                attrp[ai].u.c.g = -1;
-                attrp[ai].u.c.b = -1;
-            }
-            break;
-        case G_ATTRVIEWPORT:
-            attrp[ai].u.s = WCU->vsize;
-            break;
-        case G_ATTRWINDOW:
-            attrp[ai].u.r = WCU->wrect;
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTREVENTCB:
-            attrp[ai].u.func = WCU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GCdestroywidget (Gwidget_t *widget) {
-    XtDestroyWidget (widget->w);
-    return 0;
-}
-
-int GCcanvasclear (Gwidget_t *widget) {
-    XEvent ev;
-    int gotit;
-
-    XClearWindow (Gdisplay, WINDOW);
-    /* avoid a redraw */
-    WCU->needredraw = FALSE;
-    XSync (Gdisplay, False);
-    gotit = FALSE;
-    while (XCheckIfEvent (
-        Gdisplay, &ev, cwepredicate, (XPointer) WINDOW
-    ) == True)
-        gotit = TRUE;
-    if (gotit)
-        adjustclip (widget);
-    return 0;
-}
-
-int GCsetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    setgattr (widget, ap);
-    WCU->defgattr = WCU->gattr;
-    return 0;
-}
-
-int GCgetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    if ((ap->flags & G_GATTRCOLOR))
-        ap->color = WCU->gattr.color;
-    if ((ap->flags & G_GATTRWIDTH))
-        ap->width = WCU->gattr.width;
-    if ((ap->flags & G_GATTRMODE))
-        ap->mode = WCU->gattr.mode;
-    if ((ap->flags & G_GATTRFILL))
-        ap->fill = WCU->gattr.fill;
-    if ((ap->flags & G_GATTRSTYLE))
-        ap->style = WCU->gattr.style;
-    return 0;
-}
-
-int GCarrow (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    PIXpoint_t pp1, pp2, pa, pb, pd;
-    Grect_t gr;
-    double tangent, l;
-
-    if (gp1.x < gp2.x)
-        gr.o.x = gp1.x, gr.c.x = gp2.x;
-    else
-        gr.o.x = gp2.x, gr.c.x = gp1.x;
-    if (gp1.y < gp2.y)
-        gr.o.y = gp1.y, gr.c.y = gp2.y;
-    else
-        gr.o.y = gp2.y, gr.c.y = gp1.y;
-    if (!ISVISIBLE (gr))
-        return 1;
-    pp1 = pdrawtopix (widget, gp1), pp2 = pdrawtopix (widget, gp2);
-    pd.x = pp1.x - pp2.x, pd.y = pp1.y - pp2.y;
-    if (pd.x == 0 && pd.y == 0)
-        return 0;
-    tangent = atan2 ((double) pd.y, (double) pd.x);
-    if ((l = hypot(pd.x, pd.y)) > 30)
-        l = 30;
-    pa.x = l * cos (tangent + M_PI / 7) + pp2.x;
-    pa.y = l * sin (tangent + M_PI / 7) + pp2.y;
-    pb.x = l * cos (tangent - M_PI / 7) + pp2.x;
-    pb.y = l * sin (tangent - M_PI / 7) + pp2.y;
-    setgattr (widget, ap);
-    XDrawLine (Gdisplay, WINDOW, GC, pp1.x, pp1.y, pp2.x, pp2.y);
-    XDrawLine (Gdisplay, WINDOW, GC, pa.x, pa.y, pp2.x, pp2.y);
-    XDrawLine (Gdisplay, WINDOW, GC, pb.x, pb.y, pp2.x, pp2.y);
-    return 0;
-}
-
-int GCline (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    PIXpoint_t pp1, pp2;
-    Grect_t gr;
-
-    if (gp1.x < gp2.x)
-        gr.o.x = gp1.x, gr.c.x = gp2.x;
-    else
-        gr.o.x = gp2.x, gr.c.x = gp1.x;
-    if (gp1.y < gp2.y)
-        gr.o.y = gp1.y, gr.c.y = gp2.y;
-    else
-        gr.o.y = gp2.y, gr.c.y = gp1.y;
-    if (!ISVISIBLE (gr))
-        return 1;
-    pp1 = pdrawtopix (widget, gp1), pp2 = pdrawtopix (widget, gp2);
-    setgattr (widget, ap);
-    XDrawLine (Gdisplay, WINDOW, GC, pp1.x, pp1.y, pp2.x, pp2.y);
-    return 0;
-}
-
-int GCbox (Gwidget_t *widget, Grect_t gr, Ggattr_t *ap) {
-    PIXrect_t pr;
-    Gxy_t p;
-
-    if (gr.o.x > gr.c.x)
-        p.x = gr.o.x, gr.o.x = gr.c.x, gr.c.x = p.x;
-    if (gr.o.y > gr.c.y)
-        p.y = gr.o.y, gr.o.y = gr.c.y, gr.c.y = p.y;
-    if (!ISVISIBLE (gr))
-        return 1;
-    pr = rdrawtopix (widget, gr);
-    setgattr (widget, ap);
-    if (WCU->gattr.fill)
-        XFillRectangle (
-            Gdisplay, WINDOW, GC,
-            pr.o.x, pr.o.y, pr.c.x - pr.o.x, pr.c.y - pr.o.y
-        );
-    else
-        XDrawRectangle (
-            Gdisplay, WINDOW, GC,
-            pr.o.x, pr.o.y, pr.c.x - pr.o.x, pr.c.y - pr.o.y
-        );
-    return 0;
-}
-
-int GCpolygon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    Grect_t gr;
-    int n, i;
-
-    if (gpn == 0)
-        return 0;
-    gr.o = gpp[0], gr.c = gpp[0];
-    for (i = 1; i < gpn; i++) {
-        gr.o.x = min (gr.o.x, gpp[i].x);
-        gr.o.y = min (gr.o.y, gpp[i].y);
-        gr.c.x = max (gr.c.x, gpp[i].x);
-        gr.c.y = max (gr.c.y, gpp[i].y);
-    }
-    if (!ISVISIBLE (gr))
-        return 1;
-    if (gpn + 1 > Gppn) {
-        n = (((gpn + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-        Gppp = Marraygrow (Gppp, (long) n * PPSIZE);
-        Gppn = n;
-    }
-    for (i = 0; i < gpn; i++)
-        Gppp[i] = pdrawtopix (widget, gpp[i]);
-    setgattr (widget, ap);
-    if (WCU->gattr.fill) {
-        if (Gppp[gpn - 1].x != Gppp[0].x || Gppp[gpn - 1].y != Gppp[0].y)
-            Gppp[gpn] = Gppp[0], gpn++;
-        XFillPolygon (
-            Gdisplay, WINDOW, GC, Gppp, gpn, Complex, CoordModeOrigin
-        );
-    } else
-        XDrawLines (Gdisplay, WINDOW, GC, Gppp, gpn, CoordModeOrigin);
-    return 0;
-}
-
-int GCsplinegon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    PIXpoint_t p0, p1, p2, p3;
-    Grect_t gr;
-    int n, i;
-
-    if (gpn == 0)
-        return 0;
-    gr.o = gpp[0], gr.c = gpp[0];
-    for (i = 1; i < gpn; i++) {
-        gr.o.x = min (gr.o.x, gpp[i].x);
-        gr.o.y = min (gr.o.y, gpp[i].y);
-        gr.c.x = max (gr.c.x, gpp[i].x);
-        gr.c.y = max (gr.c.y, gpp[i].y);
-    }
-    if (!ISVISIBLE (gr))
-        return 1;
-    Gppi = 1;
-    if (Gppi >= Gppn) {
-        n = (((Gppi + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-        Gppp = Marraygrow (Gppp, (long) n * PPSIZE);
-        Gppn = n;
-    }
-    Gppp[0] = p3 = pdrawtopix (widget, gpp[0]);
-    for (i = 1; i < gpn; i += 3) {
-        p0 = p3;
-        p1 = pdrawtopix (widget, gpp[i]);
-        p2 = pdrawtopix (widget, gpp[i + 1]);
-        p3 = pdrawtopix (widget, gpp[i + 2]);
-        bezier (p0, p1, p2, p3);
-    }
-    setgattr (widget, ap);
-    if (WCU->gattr.fill) {
-        if (Gppp[Gppi - 1].x != Gppp[0].x || Gppp[Gppi - 1].y != Gppp[0].y)
-            Gppp[Gppi] = Gppp[0], Gppi++;
-        XFillPolygon (
-            Gdisplay, WINDOW, GC, Gppp, Gppi, Complex, CoordModeOrigin
-        );
-    } else
-        XDrawLines (Gdisplay, WINDOW, GC, Gppp, Gppi, CoordModeOrigin);
-    return 0;
-}
-
-static void bezier (
-    PIXpoint_t p0, PIXpoint_t p1, PIXpoint_t p2, PIXpoint_t p3
-) {
-    Gpoint_t gp0, gp1, gp2;
-    Gsize_t s;
-    PIXpoint_t p;
-    double t;
-    int n, i, steps;
-
-    if ((s.x = p3.x - p0.x) < 0)
-        s.x = - s.x;
-    if ((s.y = p3.y - p0.y) < 0)
-        s.y = - s.y;
-    if (s.x > s.y)
-        steps = s.x / 5 + 1;
-    else
-        steps = s.y / 5 + 1;
-    for (i = 0; i <= steps; i++) {
-        t = i / (double) steps;
-        gp0.x = p0.x + t * (p1.x - p0.x);
-        gp0.y = p0.y + t * (p1.y - p0.y);
-        gp1.x = p1.x + t * (p2.x - p1.x);
-        gp1.y = p1.y + t * (p2.y - p1.y);
-        gp2.x = p2.x + t * (p3.x - p2.x);
-        gp2.y = p2.y + t * (p3.y - p2.y);
-        gp0.x = gp0.x + t * (gp1.x - gp0.x);
-        gp0.y = gp0.y + t * (gp1.y - gp0.y);
-        gp1.x = gp1.x + t * (gp2.x - gp1.x);
-        gp1.y = gp1.y + t * (gp2.y - gp1.y);
-        p.x = gp0.x + t * (gp1.x - gp0.x) + 0.5;
-        p.y = gp0.y + t * (gp1.y - gp0.y) + 0.5;
-        if (Gppi >= Gppn) {
-            n = (((Gppi + 1) + PPINCR - 1) / PPINCR) * PPINCR;
-            Gppp = Marraygrow (Gppp, (long) n * PPSIZE);
-            Gppn = n;
-        }
-        Gppp[Gppi++] = p;
-    }
-}
-
-int GCarc (
-    Gwidget_t *widget, Gpoint_t gc, Gsize_t gs, double ang1,
-    double ang2, Ggattr_t *ap
-) {
-    PIXpoint_t pc;
-    PIXsize_t ps;
-    Grect_t gr;
-
-    gr.o.x = gc.x - gs.x, gr.o.y = gc.y - gs.y;
-    gr.c.x = gc.x + gs.x, gr.c.y = gc.y + gs.y;
-    if (!ISVISIBLE (gr))
-        return 1;
-    pc = pdrawtopix (widget, gc), ps = sdrawtopix (widget, gs);
-    setgattr (widget, ap);
-    if (WCU->gattr.fill)
-        XFillArc (
-            Gdisplay, WINDOW, GC, pc.x - ps.x, pc.y - ps.y,
-            ps.x * 2, ps.y * 2, (int) (ang1 * 64), (int) (ang2 * 64)
-        );
-    else
-        XDrawArc (
-            Gdisplay, WINDOW, GC, pc.x - ps.x, pc.y - ps.y,
-            ps.x * 2, ps.y * 2, (int) (ang1 * 64), (int) (ang2 * 64)
-        );
-    return 0;
-}
-
-int GCtext (
-    Gwidget_t *widget, Gtextline_t *tlp, int n, Gpoint_t go,
-    char *fn, double fs, char *justs, Ggattr_t *ap
-) {
-    Gsize_t gs;
-    PIXpoint_t po;
-    PIXsize_t ps;
-    PIXrect_t pr;
-    Grect_t gr;
-    XFontStruct *font;
-    int dir, asc, des, x, y, w, h, i;
-    XCharStruct txtinfo;
-
-    x = 0;
-    po = pdrawtopix (widget, go);
-    gs.x = 0, gs.y = fs;
-    ps = sdrawtopix (widget, gs);
-    if (!(font = findfont (fn, ps.y))) {
-        XDrawRectangle (Gdisplay, WINDOW, GC, po.x, po.y, 1, 1);
-        return 0;
-    }
-    setgattr (widget, ap);
-    SETFONT (font);
-    for (w = h = 0, i = 0; i < n; i++) {
-        if (IS8BIT (font))
-            XTextExtents (font, tlp[i].p, tlp[i].n, &dir, &asc, &des, &txtinfo);
-        else
-            XTextExtents16 (
-                font, (XChar2b *) tlp[i].p, tlp[i].n / 2,
-                &dir, &asc, &des, &txtinfo
-            );
-        tlp[i].w = txtinfo.width, tlp[i].h = asc + des;
-        w = max (w, txtinfo.width), h += asc + des;
-    }
-    switch (justs[0]) {
-    case 'l': po.x += w / 2; break;
-    case 'r': po.x -= w / 2; break;
-    }
-    switch (justs[1]) {
-    case 'd': po.y -= h; break;
-    case 'b': po.y -= (h - des); break;
-    case 'c': po.y -= h / 2; break;
-    }
-    pr.o.x = po.x - w / 2, pr.o.y = po.y;
-    pr.c.x = po.x + w / 2, pr.c.y = po.y + h;
-    gr = rpixtodraw (widget, pr);
-    if (!ISVISIBLE (gr))
-        return 1;
-    for (i = 0; i < n; i++) {
-        switch (tlp[i].j) {
-        case 'l': x = po.x - w / 2; break;
-        case 'n': x = po.x - tlp[i].w / 2; break;
-        case 'r': x = po.x - (tlp[i].w - w / 2); break;
-        }
-        y = po.y + (i + 1) * tlp[i].h - des;
-        if (IS8BIT (font))
-            XDrawString (Gdisplay, WINDOW, GC, x, y, tlp[i].p, tlp[i].n);
-        else
-            XDrawString16 (
-                Gdisplay, WINDOW, GC, x, y, (XChar2b *) tlp[i].p, tlp[i].n / 2
-            );
-    }
-    return 0;
-}
-
-int GCgettextsize (
-    Gwidget_t *widget, Gtextline_t *tlp, int n, char *fn,
-    double fs, Gsize_t *gsp
-) {
-    Gsize_t gs;
-    PIXsize_t ps;
-    XFontStruct *font;
-    int i, dir, asc, des;
-    XCharStruct txtinfo;
-
-    gs.x = 0, gs.y = fs;
-    ps = sdrawtopix (widget, gs);
-    if (!(font = findfont (fn, ps.y))) {
-        gsp->x = 1, gsp->y = 1;
-        return 0;
-    }
-    SETFONT (font);
-    for (ps.x = ps.y = 0, i = 0; i < n; i++) {
-        if (IS8BIT (font))
-            XTextExtents (font, tlp[i].p, tlp[i].n, &dir, &asc, &des, &txtinfo);
-        else
-            XTextExtents16 (
-                font, (XChar2b *) tlp[i].p, tlp[i].n / 2,
-                &dir, &asc, &des, &txtinfo
-            );
-        ps.x = max (ps.x, txtinfo.width), ps.y += asc + des;
-    }
-    *gsp = spixtodraw (widget, ps);
-    return 0;
-}
-
-static XFontStruct *findfont (char *name, int size) {
-    XFontStruct *font;
-    int fi, n, i;
-
-    if (strcmp(name, "") == 0)
-        return Gfontp[0].font;
-
-    sprintf (&Gbufp[0], name, size);
-    for (fi = 0; fi < Gfontn; fi++)
-        if (strcmp (&Gbufp[0], Gfontp[fi].name) == 0)
-            return Gfontp[fi].font;
-    if (!(font = XLoadQueryFont (Gdisplay, &Gbufp[0]))) {
-        n = strlen (&Gbufp[0]) + 1;
-        for (i = 1; i < size; i++) {
-            sprintf (&Gbufp[n], name, size - i);
-            if ((font = XLoadQueryFont (Gdisplay, &Gbufp[n])))
-                break;
-            sprintf (&Gbufp[n], name, size + i);
-            if ((font = XLoadQueryFont (Gdisplay, &Gbufp[n])))
-                break;
-        }
-    }
-    if (!font)
-        font = Gfontp[0].font;
-
-    Gfontp = Marraygrow (Gfontp, (long) (Gfontn + 1) * FONTSIZE);
-    Gfontp[Gfontn].name = strdup (&Gbufp[0]);
-    Gfontp[Gfontn].font = font;
-    Gfontn++;
-    return font;
-}
-
-int GCcreatebitmap (Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t s) {
-    if (!widget) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    if (!(bitmap->u.bmap.orig = XCreatePixmap (
-        Gdisplay, XtWindow (widget->w), (int) s.x, (int) s.y, Gdepth))
-    ) {
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    bitmap->u.bmap.scaled = 0;
-    bitmap->scale.x = bitmap->scale.y = 1;
-    bitmap->ctype = widget->type;
-    bitmap->canvas = widget - &Gwidgets[0];
-    bitmap->size = s;
-    return 0;
-}
-
-int GCdestroybitmap (Gbitmap_t *bitmap) {
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    XFreePixmap (Gdisplay, bitmap->u.bmap.orig);
-    if (bitmap->u.bmap.scaled)
-        XFreePixmap (Gdisplay, bitmap->u.bmap.scaled);
-    return 0;
-}
-
-#define COMPDIFF(a, b) (((a) > (b)) ? (a) - (b) : (b) - (a))
-#define CDIFF(a, b) ( \
-    COMPDIFF (a.red, b[0]) + COMPDIFF (a.green, b[1]) + \
-    COMPDIFF (a.blue, b[2]) \
-)
-#define CMINMAXDIFF 20000
-
-int GCreadbitmap (Gwidget_t *widget, Gbitmap_t *bitmap, FILE *fp) {
-    Gsize_t s;
-    XImage *img;
-    XColor colors[G_MAXCOLORS];
-    char bufp[2048];
-    int rgb[3];
-    char *s1, *s2;
-    char c;
-    int cmaxdiff, colori, colorn, bufn, bufi, step, x, y, k;
-
-    s.x = s.y = 0;
-    if (!widget) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    step = 0;
-    while (step < 3) {
-l1:
-        if (!fgets (bufp, 2048, fp)) {
-            Gerr (POS, G_ERRCANNOTREADBITMAP);
-            return -1;
-        }
-        s1 = &bufp[0];
-l2:
-        for (; *s1 && isspace (*s1); s1++)
-            ;
-        if (!*s1 || *s1 == '#')
-            goto l1;
-        switch (step) {
-        case 0:
-            if (strncmp (s1, "P6", 2) != 0) {
-                Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            step++, s1 += 2;
-            goto l2;
-        case 1:
-            for (s2 = s1; *s2 && *s2 >= '0' && *s2 <= '9'; s2++)
-                ;
-            c = *s2, *s2 = 0;
-            if (s2 == s1 || (s.x = atoi (s1)) <= 0) {
-                *s2 = c, Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            *s2 = c, step++, s1 = s2;
-            goto l2;
-        case 2:
-            for (s2 = s1; *s2 && *s2 >= '0' && *s2 <= '9'; s2++)
-                ;
-            c = *s2, *s2 = 0;
-            if (s2 == s1 || (s.y = atoi (s1)) <= 0) {
-                *s2 = c, Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            *s2 = c, step++, s1 = s2;
-            goto l2;
-        }
-    }
-    if (!(bitmap->u.bmap.orig = XCreatePixmap (
-        Gdisplay, XtWindow (widget->w), (int) s.x, (int) s.y, Gdepth
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    bitmap->u.bmap.scaled = 0;
-    bitmap->scale.x = bitmap->scale.y = 1;
-    bitmap->ctype = widget->type;
-    bitmap->canvas = widget - &Gwidgets[0];
-    bitmap->size = s;
-    if ((img = XCreateImage (
-        Gdisplay, DefaultVisual (Gdisplay, Gscreenn),
-        Gdepth, ZPixmap, 0, NULL, (int) s.x, (int) s.y, 32, 0
-    )) == NULL) {
-        XFreePixmap (Gdisplay, bitmap->u.bmap.orig);
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    if ((img->data = malloc (img->bytes_per_line * img->height)) == NULL) {
-        XFreePixmap (Gdisplay, bitmap->u.bmap.orig);
-        XDestroyImage (img);
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    colorn = 0;
-    for (colori = 0; colori < G_MAXCOLORS; colori++) {
-        if (widget->u.c->colors[colori].inuse) {
-            colors[colorn] = widget->u.c->colors[colori].color;
-            colorn++;
-        }
-    }
-    bufi = bufn = 0;
-    bufp[bufi] = 0;
-    for (y = 0; y < s.y; y++) {
-        for (x = 0; x < s.x; x++) {
-            for (k = 0; k < 3; k++) {
-                if (bufi == bufn) {
-                    if ((bufn = fread (bufp, 1, 2047, fp)) == 0) {
-                        XFreePixmap (Gdisplay, bitmap->u.bmap.orig);
-                        XDestroyImage (img);
-                        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-                        return -1;
-                    }
-                    bufi = 0;
-                }
-                rgb[k] = 257 * (unsigned char) bufp[bufi++];
-            }
-            cmaxdiff = CMINMAXDIFF;
-l3:
-            for (colori = 0; colori < colorn; colori++)
-                if (CDIFF (colors[colori], rgb) < cmaxdiff)
-                    break;
-            if (
-                colori == colorn && colorn < G_MAXCOLORS &&
-                cmaxdiff == CMINMAXDIFF
-            ) {
-                colors[colorn].red = rgb[0];
-                colors[colorn].green = rgb[1];
-                colors[colorn].blue = rgb[2];
-                if (XAllocColor (Gdisplay, widget->u.c->cmap, &colors[colorn]))
-                    colorn++;
-            }
-            if (colori == colorn) {
-                cmaxdiff *= 10;
-                goto l3;
-            }
-            XPutPixel (img, x, y, colors[colori].pixel);
-        }
-    }
-    for (colori = 0; colori < G_MAXCOLORS && colori < colorn; colori++) {
-        if (!widget->u.c->colors[colori].inuse) {
-            widget->u.c->colors[colori].color = colors[colori];
-            widget->u.c->colors[colori].inuse = TRUE;
-        }
-    }
-    XPutImage (
-        Gdisplay, bitmap->u.bmap.orig, widget->u.c->gc, img,
-        0, 0, 0, 0, (int) s.x, (int) s.y
-    );
-    XDestroyImage (img);
-    return 0;
-}
-
-int GCwritebitmap (Gbitmap_t *bitmap, FILE *fp) {
-    Gwidget_t *widget;
-    XImage *img;
-    XColor colors[G_MAXCOLORS];
-    char bufp[2048];
-    int colori, colorn, bufi, x, y, w, h;
-
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    if (
-        bitmap->canvas < 0 || bitmap->canvas >= Gwidgetn ||
-        !Gwidgets[bitmap->canvas].inuse
-    ) {
-        Gerr (POS, G_ERRBADWIDGETID, bitmap->canvas);
-        return -1;
-    }
-    widget = &Gwidgets[bitmap->canvas];
-    if (widget->type != G_CANVASWIDGET && widget->type != G_PCANVASWIDGET) {
-        Gerr (POS, G_ERRNOTACANVAS, bitmap->canvas);
-        return -1;
-    }
-    for (colori = 0, colorn = 0; colori < G_MAXCOLORS; colori++)
-        if (widget->u.c->colors[colori].inuse) {
-            colors[colori].pixel = widget->u.c->colors[colori].color.pixel;
-            colorn++;
-        }
-    XQueryColors (Gdisplay, widget->u.c->cmap, &colors[0], colorn);
-    if (!(img = XGetImage (
-        Gdisplay, bitmap->u.bmap.orig, 0, 0,
-        bitmap->size.x, bitmap->size.y, AllPlanes, ZPixmap
-    ))) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    fprintf (fp, "P6\n%d %d 255\n", (int) bitmap->size.x, (int) bitmap->size.y);
-    bufi = 0;
-    w = bitmap->size.x;
-    h = bitmap->size.y;
-    for (y = 0; y < h; y++) {
-        for (x = 0; x < w; x++) {
-            colori = XGetPixel (img, x, y);
-            bufp[bufi++] = colors[colori].red / 257;
-            bufp[bufi++] = colors[colori].green / 257;
-            bufp[bufi++] = colors[colori].blue / 257;
-            if (bufi + 3 >= 2048) {
-                fwrite (bufp, 1, bufi, fp);
-                bufi = 0;
-            }
-        }
-    }
-    if (bufi > 0)
-        fwrite (bufp, 1, bufi, fp);
-    XDestroyImage (img);
-    return 0;
-}
-
-int GCbitblt (
-    Gwidget_t *widget, Gpoint_t gp, Grect_t gr, Gbitmap_t *bitmap,
-    char *mode, Ggattr_t *ap
-) {
-    PIXrect_t pr;
-    PIXpoint_t pp;
-    Gsize_t scale;
-    Gxy_t p;
-    Pixmap pix;
-    double tvx, tvy, twx, twy;
-
-    if (gr.o.x > gr.c.x)
-        p.x = gr.o.x, gr.o.x = gr.c.x, gr.c.x = p.x;
-    if (gr.o.y > gr.c.y)
-        p.y = gr.o.y, gr.o.y = gr.c.y, gr.c.y = p.y;
-    if (strcmp (mode, "b2c") == 0) {
-        if (!ISVISIBLE (gr))
-            return 1;
-        tvx = WCU->vsize.x, tvy = WCU->vsize.y;
-        twx = WCU->wrect.c.x - WCU->wrect.o.x;
-        twy = WCU->wrect.c.y - WCU->wrect.o.y;
-        scale.x = tvx / twx, scale.y = tvy / twy;
-        if (
-            scale.x >= 1.0 - 1E-4 && scale.x <= 1.0 + 1E-4 &&
-            scale.y >= 1.0 - 1E-4 && scale.y <= 1.0 + 1E-4
-        ) {
-            pix = bitmap->u.bmap.orig;
-            bitmap->scale = scale;
-        } else {
-            if (scale.x != bitmap->scale.x || scale.y != bitmap->scale.y)
-                scalebitmap (widget, bitmap, scale, TRUE, 1);
-            pix = bitmap->u.bmap.scaled;
-        }
-        pr = rdrawtopix (widget, gr);
-        pp = pdrawtobpix (bitmap, gp);
-        setgattr (widget, ap);
-        XCopyArea (
-            Gdisplay, pix, WINDOW, GC, pp.x, pp.y - pr.c.y + pr.o.y,
-            pr.c.x - pr.o.x + 1, pr.c.y - pr.o.y + 1, pr.o.x, pr.o.y
-        );
-    } else if (strcmp (mode, "c2b") == 0) {
-        tvx = WCU->vsize.x, tvy = WCU->vsize.y;
-        twx = WCU->wrect.c.x - WCU->wrect.o.x;
-        twy = WCU->wrect.c.y - WCU->wrect.o.y;
-        scale.x = tvx / twx, scale.y = tvy / twy;
-        if (
-            scale.x >= 1.0 - 1E-4 && scale.x <= 1.0 + 1E-4 &&
-            scale.y >= 1.0 - 1E-4 && scale.y <= 1.0 + 1E-4
-        ) {
-            pix = bitmap->u.bmap.orig;
-            bitmap->scale = scale;
-        } else {
-            if (scale.x != bitmap->scale.x || scale.y != bitmap->scale.y)
-                scalebitmap (widget, bitmap, scale, FALSE, 1);
-            pix = bitmap->u.bmap.scaled;
-        }
-        pr = rdrawtobpix (bitmap, gr);
-        pp = pdrawtopix (widget, gp);
-        setgattr (widget, ap);
-        XCopyArea (
-            Gdisplay, WINDOW, pix, GC, pp.x, pp.y - pr.c.y + pr.o.y,
-            pr.c.x - pr.o.x + 1, pr.c.y - pr.o.y + 1, pr.o.x, pr.o.y
-        );
-        if (pix != bitmap->u.bmap.orig)
-            scalebitmap (widget, bitmap, scale, TRUE, -1);
-    }
-    return 0;
-}
-
-static int scalebitmap (
-    Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t scale, int copybits, int dir
-) {
-    Gsize_t nsize, o2n;
-    Pixmap spix;
-    XImage *oimg, *simg;
-    XColor colors[G_MAXCOLORS + 1];
-    int cmaxdiff, colorn, colori, x, y, x2, y2, xp, yp;
-    double prod, rgb[3], xr2, yr2, xl2, yl2, xf2, yf2, xr, yr, xl, yl;
-    unsigned long pixel;
-
-    if (!copybits) {
-        if (dir == 1) {
-            nsize.x = (int) (bitmap->size.x * scale.x);
-            nsize.y = (int) (bitmap->size.y * scale.y);
-            if (!(spix = XCreatePixmap (
-                Gdisplay, XtWindow (widget->w),
-                (int) nsize.x, (int) nsize.y, Gdepth
-            ))) {
-                Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-                return -1;
-            }
-            if (bitmap->u.bmap.scaled)
-                XFreePixmap (Gdisplay, bitmap->u.bmap.scaled);
-            bitmap->u.bmap.scaled = spix;
-            bitmap->scale = scale;
-        }
-        return 0;
-    }
-    for (colori = 0, colorn = 0; colori < G_MAXCOLORS; colori++)
-        if (widget->u.c->colors[colori].inuse) {
-            colors[colori].pixel = widget->u.c->colors[colori].color.pixel;
-            colorn++;
-        }
-    XQueryColors (Gdisplay, widget->u.c->cmap, &colors[0], colorn);
-    if (dir == 1) {
-        nsize.x = (int) (bitmap->size.x * scale.x);
-        nsize.y = (int) (bitmap->size.y * scale.y);
-        o2n.x = 1 / scale.x, o2n.y = 1 / scale.y;
-        if (!(oimg = XGetImage (
-            Gdisplay, bitmap->u.bmap.orig, 0, 0,
-            (int) bitmap->size.x, (int) bitmap->size.y, AllPlanes, ZPixmap
-        ))) {
-            Gerr (POS, G_ERRNOBITMAP);
-            return -1;
-        }
-        if (!(spix = XCreatePixmap (
-            Gdisplay, XtWindow (widget->w), (int) nsize.x, (int) nsize.y, Gdepth
-        ))) {
-            XDestroyImage (oimg);
-            Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-            return -1;
-        }
-    } else {
-        nsize.x = (int) bitmap->size.x;
-        nsize.y = (int) bitmap->size.y;
-        o2n.x = scale.x, o2n.y = scale.y;
-        if (!(oimg = XGetImage (
-            Gdisplay, bitmap->u.bmap.scaled, 0, 0,
-            (int) (bitmap->size.x * scale.x),
-            (int) (bitmap->size.y * scale.y), AllPlanes, ZPixmap
-        ))) {
-            Gerr (POS, G_ERRNOBITMAP);
-            return -1;
-        }
-        spix = bitmap->u.bmap.orig;
-    }
-    prod = o2n.x * o2n.y;
-    if (!(simg = XCreateImage (
-        Gdisplay, DefaultVisual (Gdisplay, Gscreenn),
-        Gdepth, ZPixmap, 0, NULL, (int) nsize.x, (int) nsize.y, 32, 0
-    ))) {
-        XFreePixmap (Gdisplay, spix);
-        XDestroyImage (oimg);
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    if ((simg->data = malloc (simg->bytes_per_line * simg->height)) == NULL) {
-        XFreePixmap (Gdisplay, spix);
-        XDestroyImage (oimg);
-        XDestroyImage (simg);
-        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-        return -1;
-    }
-    y = 0;
-    yr = o2n.y;
-    yl = 0;
-    y2 = yr2 = yl2 = 0;
-    for (yp = 0; yp < nsize.y; yp++) {
-        x = 0;
-        xr = o2n.x;
-        xl = 0;
-        for (xp = 0; xp < nsize.x; xp++) {
-            y2 = y;
-            yr2 = yr;
-            yl2 = yl;
-            rgb[0] = rgb[1] = rgb[2] = 0;
-            do {
-                x2 = x;
-                xr2 = xr;
-                xl2 = xl;
-                yf2 = (yl2 + yr2 > 1) ? 1 - yl2 : yr2, yr2 -= yf2;
-                do {
-                    xf2 = (xl2 + xr2 > 1) ? 1 - xl2 : xr2, xr2 -= xf2;
-                    pixel = XGetPixel (oimg, x2, y2);
-                    for (colori = 0; colori < colorn; colori++)
-                        if (colors[colori].pixel == pixel)
-                            break;
-                    if (colori == colorn) {
-                        colors[colori].pixel = pixel;
-                        XQueryColor (Gdisplay, WCU->cmap, &colors[colori]);
-                    }
-                    rgb[0] += (colors[colori].red * xf2 * yf2 / prod);
-                    rgb[1] += (colors[colori].green * xf2 * yf2 / prod);
-                    rgb[2] += (colors[colori].blue * xf2 * yf2 / prod);
-                    xl2 += xf2;
-                    if (xl2 >= 1)
-                        x2++, xl2 -= 1;
-                } while (xr2 > 0);
-                xr2 = o2n.x;
-                yl2 += yf2;
-                if (yl2 >= 1)
-                    y2++, yl2 -= 1;
-            } while (yr2 > 0);
-            yr2 = o2n.y;
-            cmaxdiff = CMINMAXDIFF;
-l4:
-            for (colori = 0; colori < colorn; colori++)
-                if (CDIFF (colors[colori], rgb) < cmaxdiff)
-                    break;
-            if (
-                colori == colorn && colorn < G_MAXCOLORS &&
-                cmaxdiff == CMINMAXDIFF
-            ) {
-                colors[colorn].red = rgb[0];
-                colors[colorn].green = rgb[1];
-                colors[colorn].blue = rgb[2];
-                if (XAllocColor (Gdisplay, widget->u.c->cmap, &colors[colorn]))
-                    colorn++;
-            }
-            if (colori == colorn) {
-                cmaxdiff *= 10;
-                goto l4;
-            }
-            XPutPixel (simg, xp, yp, colors[colori].pixel);
-            x = x2;
-            xr = xr2;
-            xl = xl2;
-        }
-        y = y2;
-        yr = yr2;
-        yl = yl2;
-    }
-    XPutImage (
-        Gdisplay, spix, widget->u.c->gc, simg, 0, 0, 0, 0,
-        (int) nsize.x, (int) nsize.y
-    );
-    XDestroyImage (simg);
-    XDestroyImage (oimg);
-    if (dir == 1) {
-        if (bitmap->u.bmap.scaled)
-            XFreePixmap (Gdisplay, bitmap->u.bmap.scaled);
-        bitmap->u.bmap.scaled = spix;
-        bitmap->scale = scale;
-    }
-    return 0;
-}
-
-int GCgetmousecoords (Gwidget_t *widget, Gpoint_t *gpp, int *count) {
-    PIXpoint_t pp;
-    Window rwin, cwin;
-    int rx, ry, x, y;
-    unsigned int mask;
-
-    XQueryPointer (Gdisplay, WINDOW, &rwin, &cwin, &rx, &ry, &x, &y, &mask);
-    pp.x = x, pp.y = y;
-    *gpp = Gppixtodraw (widget, pp);
-    *count = (
-        ((mask & Button1Mask) ? 1 : 0) + ((mask & Button2Mask) ? 1 : 0) +
-        ((mask & Button3Mask) ? 1 : 0)
-    );
-    return 0;
-}
-
-void Gcwbutaction (Widget w, XEvent *evp, char **app, unsigned int *anp) {
-    Gwidget_t *widget;
-    Gevent_t gev;
-    PIXpoint_t pp;
-    int wi, xtype, bn;
-
-    widget = findwidget ((unsigned long) w, G_CANVASWIDGET);
-    switch ((xtype = evp->type)) {
-    case ButtonPress:
-    case ButtonRelease:
-        gev.type = G_MOUSE;
-        gev.code = (xtype == ButtonPress) ? G_DOWN : G_UP;
-        gev.data = evp->xbutton.button - Button1;
-        if (gev.data > 4)
-            return;
-        pp.x = evp->xbutton.x, pp.y = evp->xbutton.y;
-        gev.p = Gppixtodraw (widget, pp);
-        bn = WCU->bstate[gev.data];
-        WCU->bstate[gev.data] = (xtype == ButtonPress) ? 1 : 0;
-        bn = WCU->bstate[gev.data] - bn;
-        WCU->buttonsdown += bn;
-        Gbuttonsdown += bn;
-        break;
-    default:
-        return;
-    }
-    wi = gev.wi = widget - &Gwidgets[0];
-    Gpopdownflag = FALSE;
-    if (WCU->func)
-        (*WCU->func) (&gev);
-    if (Gpopdownflag) {
-        Gpopdownflag = FALSE;
-        if (gev.code == G_DOWN) {
-            gev.code = G_UP;
-            widget = &Gwidgets[wi];
-            WCU->bstate[gev.data] = 0;
-            WCU->buttonsdown--;
-            Gbuttonsdown--;
-            if (widget->inuse && WCU->func)
-                (*WCU->func) (&gev);
-        }
-    }
-}
-
-void Gcwkeyaction (Widget w, XEvent *evp, char **app, unsigned int *anp) {
-    Gwidget_t *widget;
-    Gevent_t gev;
-    PIXpoint_t pp;
-    Window rwin, cwin;
-    int xtype, rx, ry, x, y;
-    unsigned int mask;
-    char c;
-
-    widget = findwidget ((unsigned long) w, G_CANVASWIDGET);
-    switch ((xtype = evp->type)) {
-    case KeyPress:
-    case KeyRelease:
-        if (!XLookupString ((XKeyEvent *) evp, &c, 1, NULL, NULL))
-            return;
-        XQueryPointer (
-            Gdisplay, WCU->window, &rwin, &cwin, &rx, &ry, &x, &y, &mask
-        );
-        gev.type = G_KEYBD;
-        gev.code = (xtype == KeyPress) ? G_DOWN : G_UP;
-        gev.data = c;
-        pp.x = x, pp.y = y;
-        gev.p = Gppixtodraw (widget, pp);
-        break;
-    default:
-        return;
-    }
-    gev.wi = widget - &Gwidgets[0];
-    Gpopdownflag = FALSE;
-    if (WCU->func)
-        (*WCU->func) (&gev);
-    if (Gpopdownflag)
-        Gpopdownflag = FALSE;
-}
-
-static void setgattr (Gwidget_t *widget, Ggattr_t *ap) {
-    XGCValues gcv;
-    XColor *cp;
-    int color, width, mode, style, pati;
-    double intens;
-
-    if (!(ap->flags & G_GATTRCOLOR))
-        ap->color = WCU->defgattr.color;
-    if (!(ap->flags & G_GATTRWIDTH))
-        ap->width = WCU->defgattr.width;
-    if (!(ap->flags & G_GATTRMODE))
-        ap->mode = WCU->defgattr.mode;
-    if (!(ap->flags & G_GATTRFILL))
-        ap->fill = WCU->defgattr.fill;
-    if (!(ap->flags & G_GATTRSTYLE))
-        ap->style = WCU->defgattr.style;
-    color = ap->color;
-    if (color >= G_MAXCOLORS || !(WCU->colors[color].inuse))
-        color = 1;
-    if (color != WCU->gattr.color) {
-        WCU->gattr.color = color;
-        if (ap->mode == G_XOR)
-            XSetForeground (
-                Gdisplay, GC,
-                WCU->colors[WCU->gattr.color].color.pixel ^
-                WCU->colors[0].color.pixel
-            );
-        else
-            XSetForeground (
-                Gdisplay, GC, WCU->colors[WCU->gattr.color].color.pixel
-            );
-        if (Gdepth == 1) {
-            cp = &WCU->colors[color].color;
-            intens = (
-                0.3 * cp->blue + 0.59 * cp->red + 0.11 * cp->green
-            ) / 65535.0;
-            pati = (
-                intens <= 0.0625
-            ) ? 16 : -16.0 * (log (intens) / 2.7725887222);
-            XSetTile (Gdisplay, GC, WCU->grays[pati]);
-        }
-    }
-    mode = ap->mode;
-    if (mode != WCU->gattr.mode) {
-        WCU->gattr.mode = mode;
-        XSetFunction (Gdisplay, GC, WCU->gattr.mode);
-        if (mode == G_XOR)
-            XSetForeground (
-                Gdisplay, GC,
-                WCU->colors[WCU->gattr.color].color.pixel ^
-                WCU->colors[0].color.pixel
-            );
-        else
-            XSetForeground (
-                Gdisplay, GC,
-                WCU->colors[WCU->gattr.color].color.pixel
-            );
-    }
-    width = ap->width;
-    if (width != WCU->gattr.width) {
-        gcv.line_width = WCU->gattr.width = width;
-        XChangeGC (Gdisplay, GC, GCLineWidth, &gcv);
-    }
-    WCU->gattr.fill = ap->fill;
-    style = ap->style;
-    if (style != WCU->gattr.style) {
-        WCU->gattr.style = style;
-        if (style == G_SOLID) {
-            gcv.line_style = LineSolid;
-            XChangeGC (Gdisplay, GC, GCLineStyle, &gcv);
-        } else {
-            XSetDashes (Gdisplay, GC, 0, gstyles[style], 2);
-            gcv.line_style = LineOnOffDash;
-            XChangeGC (Gdisplay, GC, GCLineStyle, &gcv);
-        }
-    }
-}
-
-static PIXrect_t rdrawtopix (Gwidget_t *widget, Grect_t gr) {
-    PIXrect_t pr;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    pr.o.x = tvx * (gr.o.x - WCU->wrect.o.x) / twx + 0.5;
-    pr.o.y = tvy * (1.0  - (gr.c.y - WCU->wrect.o.y) / twy) + 0.5;
-    pr.c.x = tvx * (gr.c.x - WCU->wrect.o.x) / twx + 0.5;
-    pr.c.y = tvy * (1.0  - (gr.o.y - WCU->wrect.o.y) / twy) + 0.5;
-    return pr;
-}
-
-static PIXpoint_t pdrawtopix (Gwidget_t *widget, Gpoint_t gp) {
-    PIXpoint_t pp;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    pp.x = tvx * (gp.x - WCU->wrect.o.x) / twx + 0.5;
-    pp.y = tvy * (1.0  - (gp.y - WCU->wrect.o.y) / twy) + 0.5;
-    return pp;
-}
-
-static PIXsize_t sdrawtopix (Gwidget_t *widget, Gsize_t gs) {
-    PIXsize_t ps;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    ps.x = tvx * (gs.x - 1) / twx + 1.5;
-    ps.y = tvy * (gs.y - 1) / twy + 1.5;
-    return ps;
-}
-
-static Gpoint_t Gppixtodraw (Gwidget_t *widget, PIXpoint_t pp) {
-    Gpoint_t gp;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    gp.x = (pp.x / tvx) * twx + WCU->wrect.o.x;
-    gp.y = (1.0 - pp.y / tvy) * twy + WCU->wrect.o.y;
-    return gp;
-}
-
-static Gsize_t spixtodraw (Gwidget_t *widget, PIXsize_t ps) {
-    Gsize_t gs;
-    double tvx, tvy, twx, twy;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    gs.x = ((ps.x - 1) / tvx) * twx + 1;
-    gs.y = ((ps.y - 1) / tvy) * twy + 1;
-    return gs;
-}
-
-static Grect_t rpixtodraw (Gwidget_t *widget, PIXrect_t pr) {
-    Grect_t gr;
-    double tvx, tvy, twx, twy, n;
-
-    tvx = WCU->vsize.x - 1, tvy = WCU->vsize.y - 1;
-    twx = WCU->wrect.c.x - WCU->wrect.o.x;
-    twy = WCU->wrect.c.y - WCU->wrect.o.y;
-    gr.o.x = (pr.o.x / tvx) * twx + WCU->wrect.o.x;
-    gr.o.y = (1.0 - pr.c.y / tvy) * twy + WCU->wrect.o.y;
-    gr.c.x = (pr.c.x / tvx) * twx + WCU->wrect.o.x;
-    gr.c.y = (1.0 - pr.o.y / tvy) * twy + WCU->wrect.o.y;
-    if (gr.o.x > gr.c.x)
-        n = gr.o.x, gr.o.x = gr.c.x, gr.c.x = n;
-    if (gr.o.y > gr.c.y)
-        n = gr.o.y, gr.o.y = gr.c.y, gr.c.y = n;
-    return gr;
-}
-
-static PIXrect_t rdrawtobpix (Gbitmap_t *bitmap, Grect_t gr) {
-    PIXrect_t pr;
-    double tvy;
-
-    tvy = (bitmap->size.y - 1) * bitmap->scale.y;
-    pr.o.x = gr.o.x + 0.5;
-    pr.o.y = tvy - gr.c.y + 0.5;
-    pr.c.x = gr.c.x + 0.5;
-    pr.c.y = tvy - gr.o.y + 0.5;
-    return pr;
-}
-
-static PIXpoint_t pdrawtobpix (Gbitmap_t *bitmap, Gpoint_t gp) {
-    PIXpoint_t pp;
-    double tvy;
-
-    tvy = (bitmap->size.y - 1) * bitmap->scale.y;
-    pp.x = gp.x + 0.5;
-    pp.y = tvy - gp.y + 0.5;
-    return pp;
-}
-
-static void adjustclip (Gwidget_t *widget) {
-    Gwidget_t *parent;
-    Dimension width, height, pwidth, pheight;
-    Position x, y;
-    PIXrect_t pr;
-
-    parent = &Gwidgets[widget->pwi];
-    RESETARGS;
-    ADD2ARGS (XtNx, &x);
-    ADD2ARGS (XtNy, &y);
-    ADD2ARGS (XtNwidth, &width);
-    ADD2ARGS (XtNheight, &height);
-    XtGetValues (widget->w, argp, argn);
-    RESETARGS;
-    ADD2ARGS (XtNwidth, &pwidth);
-    ADD2ARGS (XtNheight, &pheight);
-    XtGetValues (parent->w, argp, argn);
-    pr.o.x = max (0, -x);
-    pr.o.y = max (0, -y);
-    pr.c.x = min (width, pr.o.x + pwidth);
-    pr.c.y = min (height, pr.o.y + pheight);
-    pr.c.x = max (pr.o.x, pr.c.x);
-    pr.c.y = max (pr.o.y, pr.c.y);
-    WCU->clip = rpixtodraw (widget, pr);
-#ifdef FEATURE_GMAP
-    if (WCU->gmapmode) {
-        GMAPwinsetsize (XtWindow (widget->w), width, height);
-        GMAPchansetaspect (XtWindow (widget->w), width, height);
-    }
-#endif
-}
-
-static Bool cwepredicate (Display *display, XEvent *evp, XPointer data) {
-    if (evp->type == Expose && ((XAnyEvent *) evp)->window == (Window) data)
-        return True;
-    return False;
-}
-
-static void cweventhandler (
-    Widget w, XtPointer data, XEvent *evp, Boolean *cont
-) {
-    Gwidget_t *widget;
-
-    widget = findwidget ((unsigned long) w, G_CANVASWIDGET);
-    Gneedredraw = WCU->needredraw = TRUE;
-    adjustclip (widget);
-#ifdef FEATURE_GMAP
-    if (WCU->gmapmode)
-        GMAPneedupdate = TRUE;
-#endif
-}
-
-static Bool cwvpredicate (Display *display, XEvent *evp, XPointer data) {
-    if (
-        evp->type == VisibilityNotify &&
-        ((XAnyEvent *) evp)->window == (Window) data
-    )
-        return True;
-    return False;
-}
diff --git a/cmd/lefty/ws/x11/gcommon.c b/cmd/lefty/ws/x11/gcommon.c
deleted file mode 100644 (file)
index 780a491..0000000
+++ /dev/null
@@ -1,316 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-int Gxfd;
-Widget Groot;
-Display *Gdisplay;
-int Gpopdownflag;
-int Gscreenn;
-int Gdepth;
-Glazyq_t Glazyq;
-
-PIXpoint_t *Gppp;
-int Gppn, Gppi;
-
-char *Gbufp = NULL;
-int Gbufn = 0, Gbufi = 0;
-
-Gfont_t *Gfontp;
-int Gfontn;
-
-/* Xt[GS]etValues arguments */
-Arg argp[MAXARGS];
-int argn;
-
-/* action and translation tables */
-static XtActionsRec actiontable[] = {
-    { "cwbut", Gcwbutaction },
-    { "cwkey", Gcwkeyaction },
-    { "lwbut", Glwbutaction },
-    { "lwkey", Glwkeyaction },
-    { "tweol", Gtweolaction },
-    { "qwpop", Gqwpopaction },
-    { "qwdel", Gqwdelaction },
-    { "wmdel", Gwmdelaction },
-};
-static char defcwanytrans[] = "\
-    <BtnDown>: cwbut()\n\
-    <BtnUp>: cwbut()\n\
-    <KeyDown>: cwkey()\n\
-    <KeyUp>: cwkey()";
-static char deflwanytrans[] = "\
-    <BtnDown>: lwbut()\n\
-    <BtnUp>: lwbut()\n\
-    <KeyDown>: lwkey()\n\
-    <KeyUp>: lwkey()";
-static char deftweoltrans[] = "<Key>Return: newline()\n<KeyUp>Return: tweol()";
-static char defqwpoptrans[] = "<KeyDown>Return:\n<KeyUp>Return: qwpop()";
-static char defqwdeltrans[] = "<Message>WM_PROTOCOLS: qwdel()\n";
-static char defwmdeltrans[] = "<Message>WM_PROTOCOLS: wmdel()\n";
-XtTranslations Gtweoltable;
-XtTranslations Gqwpoptable;
-XtTranslations Glwanytable;
-XtTranslations Gcwanytable;
-XtTranslations Gqwdeltable;
-XtTranslations Gwmdeltable;
-
-Atom Gqwdelatom, Gwmdelatom;
-
-static XtAppContext appcontext;
-static XFontStruct *deffont;
-
-#ifdef FEATURE_NEXTAW
-static char *props[] = {
-    "*Font: -*-lucidatypewriter-*-r-*-*-*-120-*-*-*-*-iso8859-1",
-    "*ShapeStyle: Rectangle",
-    "*Command.ShapeStyle: Rectangle",
-    "*Toggle.ShapeStyle: Rectangle",
-    "*ShadowWidth: 2",
-    "*Form*Text*Background: white",
-    "*Form*Text*Scrollbar*Background: gray",
-    "*Text*Background: white",
-    "*Text*Foreground: black",
-    "*Text*ThreeD*Background: gray",
-    "*Text*Scrollbar*Background: gray",
-    "*Viewport.background: gray",
-    "*BeNiceToColormap: 0",
-    "*Toggle.Font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*Command.Font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*Command.Background: gray",
-    "*Command.highlightThickness: 0",
-    "*Toggle.highlightThickness: 0",
-    "*Toggle.Background: gray",
-    "*MenuButton.Background: gray",
-    "*SimpleMenu.Background: gray",
-    "*List*Background: gray",
-    "*Box.Background: gray",
-    "*Label.Background: gray",
-    "*Label.ShadowWidth: 0",
-    "*Label*shadowWidth: 2",
-    "*Scrollbar.Background: gray",
-    "*SimpleMenu*MenuLabel*Background: black",
-    "*SimpleMenu*MenuLabel*Font: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*",
-    "*SimpleMenu*Font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*Dialog.Background: gray",
-    "*Form*Background: gray",
-    "*Form*Viewport*Background: white",
-    "*Form*Viewport*Scrollbar*Background: grey",
-    "*MenuButton.translations: Any<BtnDown>: PopupMenu()",
-    NULL
-};
-#else
-#ifdef FEATURE_XAW3D
-static char *props[] = {
-    "*Font: -*-lucidatypewriter-*-r-*-*-*-120-*-*-*-*-iso8859-1",
-    "*ShapeStyle: Rectangle",
-    "*Command.ShapeStyle: Rectangle",
-    "*Toggle.ShapeStyle: Rectangle",
-    "*ShadowWidth: 2",
-    "*Form*Text*Background: white",
-    "*Form*Text*Scrollbar*Background: gray",
-    "*Text*Background: white",
-    "*Text*Foreground: black",
-    "*Text*ThreeD*Background: gray",
-    "*Text*Scrollbar*Background: gray",
-    "*Viewport.background: gray",
-    "*BeNiceToColormap: 0",
-    "*Toggle.Font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*Command.Font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*Command.Background: gray",
-    "*Command.highlightThickness: 0",
-    "*Toggle.highlightThickness: 0",
-    "*Toggle.Background: gray",
-    "*MenuButton.Background: gray",
-    "*SimpleMenu.Background: gray",
-    "*List*Background: gray",
-    "*Box.Background: gray",
-    "*Label.Background: gray",
-    "*Label.ShadowWidth: 0",
-    "*Label*shadowWidth: 2",
-    "*Scrollbar.Background: gray",
-    "*SimpleMenu*MenuLabel*Background: black",
-    "*SimpleMenu*MenuLabel*Font: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*",
-    "*SimpleMenu*Font: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-*-*",
-    "*Dialog.Background: gray",
-    "*Form*Background: gray",
-    "*Form*Viewport*Background: white",
-    "*Form*Viewport*Scrollbar*Background: grey",
-    "*MenuButton.translations: Any<BtnDown>: PopupMenu()",
-    NULL
-};
-#endif
-#endif
-
-int Ginitgraphics (void) {
-    argn = 0;
-#if defined(FEATURE_NEXTAW) || defined(FEATURE_XAW3D)
-    if (!(Groot = XtAppInitialize (
-        &appcontext, "LEFTY", NULL, 0, &argn, NULL, props, NULL, 0
-    )))
-#else
-    if (!(Groot = XtAppInitialize (
-        &appcontext, "LEFTY", NULL, 0, &argn, NULL, NULL, NULL, 0
-    )))
-#endif
-        Gerr (POS, G_ERRINITFAILED);
-    XtAppAddActions (appcontext, actiontable, XtNumber (actiontable));
-    Gtweoltable = XtParseTranslationTable (deftweoltrans);
-    Gqwpoptable = XtParseTranslationTable (defqwpoptrans);
-    Glwanytable = XtParseTranslationTable (deflwanytrans);
-    Gcwanytable = XtParseTranslationTable (defcwanytrans);
-    Gqwdeltable = XtParseTranslationTable (defqwdeltrans);
-    Gwmdeltable = XtParseTranslationTable (defwmdeltrans);
-    XtRegisterGrabAction (
-        Glwbutaction, True,
-        ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync
-    );
-    XtRegisterGrabAction (
-        Gcwbutaction, True,
-        ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync
-    );
-    Gdisplay = XtDisplay (Groot);
-    Gscreenn = DefaultScreen (Gdisplay);
-    Gdepth = DefaultDepth (Gdisplay, Gscreenn);
-    deffont = XLoadQueryFont (Gdisplay, "fixed");
-    Gxfd = ConnectionNumber (Gdisplay);
-    Gqwdelatom = XInternAtom (Gdisplay, "WM_DELETE_WINDOW", False);
-    Gwmdelatom = XInternAtom (Gdisplay, "WM_DELETE_WINDOW", False);
-    Gpopdownflag = FALSE;
-    Glazyq.flag = 0;
-    Gbufp = Marrayalloc ((long) BUFINCR * BUFSIZE);
-    Gbufn = BUFINCR;
-    Gppp = Marrayalloc ((long) PPINCR * PPSIZE);
-    Gppn = PPINCR;
-    Gfontp = Marrayalloc ((long) FONTSIZE);
-    Gfontn = 1;
-    Gfontp[0].name = strdup ("default");
-    if (!Gdefaultfont)
-        Gfontp[0].font = deffont;
-    else if (Gdefaultfont[0] != '\000')
-        Gfontp[0].font = XLoadQueryFont (Gdisplay, Gdefaultfont);
-    else
-        Gfontp[0].font = NULL;
-    return 0;
-}
-
-int Gtermgraphics (void) {
-    int fi;
-
-    for (fi = 0; fi < Gfontn; fi++)
-        free (Gfontp[fi].name);
-    Marrayfree (Gfontp), Gfontp = NULL, Gfontn = 0;
-    Marrayfree (Gppp), Gppp = NULL, Gppn = 0;
-    Marrayfree (Gbufp), Gbufp = NULL, Gbufn = 0;
-    XtDestroyWidget (Groot);
-    return 0;
-}
-
-void Gflushlazyq (void) {
-    if (Glazyq.flag & LAZYMANAGE) {
-        XtManageChildren (Glazyq.mws, Glazyq.mwn);
-        Glazyq.flag &= ~LAZYMANAGE;
-    }
-    if (Glazyq.flag & LAZYREALIZE) {
-        XtRealizeWidget (Glazyq.rw);
-        if (Glazyq.flag & LAZYRHINTS)
-            XSetWMNormalHints (Gdisplay, XtWindow (Glazyq.rw), &Glazyq.hints);
-        XSetWMProtocols (Gdisplay, XtWindow (Glazyq.rw), &Gwmdelatom, 1);
-        XtOverrideTranslations (Glazyq.rw, Gwmdeltable);
-        Glazyq.flag &= ~LAZYRHINTS;
-        Glazyq.flag &= ~LAZYREALIZE;
-    }
-}
-
-void Glazyrealize (Widget w, int hintsflag, XSizeHints *hintsp) {
-    if (Glazyq.flag & LAZYREALIZE) {
-        XtRealizeWidget (Glazyq.rw);
-        if (Glazyq.flag & LAZYRHINTS)
-            XSetWMNormalHints (Gdisplay, XtWindow (Glazyq.rw), &Glazyq.hints);
-        XSetWMProtocols (Gdisplay, XtWindow (Glazyq.rw), &Gwmdelatom, 1);
-        XtOverrideTranslations (Glazyq.rw, Gwmdeltable);
-    } else
-        Glazyq.flag |= LAZYREALIZE;
-    Glazyq.rw = w;
-    if (hintsflag) {
-        Glazyq.flag |= LAZYRHINTS;
-        Glazyq.hints = *hintsp;
-    } else
-        Glazyq.flag &= ~LAZYRHINTS;
-}
-
-void Glazymanage (Widget w) {
-    if (Glazyq.flag & LAZYMANAGE) {
-        if (
-            XtParent (Glazyq.mws[Glazyq.mwn - 1]) != XtParent (w) ||
-            Glazyq.mwn >= LAZYQNUM
-        ) {
-            XtManageChildren (Glazyq.mws, Glazyq.mwn);
-            Glazyq.mwn = 0;
-        }
-    } else {
-        Glazyq.flag |= LAZYMANAGE;
-        Glazyq.mwn = 0;
-    }
-    Glazyq.mws[Glazyq.mwn++] = w;
-}
-
-int Gsync (void) {
-    if (Glazyq.flag)
-        Gflushlazyq ();
-    XFlush (Gdisplay);
-    return 0;
-}
-
-int Gresetbstate (int wi) {
-    Gcw_t *cw;
-    int bn;
-
-    cw = Gwidgets[wi].u.c;
-    bn = (
-        cw->bstate[0] + cw->bstate[1] + cw->bstate[2] +
-        cw->bstate[3] + cw->bstate[4]
-    );
-    cw->bstate[0] = cw->bstate[1] = cw->bstate[2] = 0;
-    cw->bstate[3] = cw->bstate[4] = 0;
-    cw->buttonsdown -= bn;
-    Gbuttonsdown -= bn;
-    return 0;
-}
-
-int Gprocessevents (int waitflag, int mode) {
-    int rtn;
-
-    if (Glazyq.flag)
-        Gflushlazyq ();
-    rtn = 0;
-    switch (waitflag) {
-    case TRUE:
-        XtAppProcessEvent (appcontext, XtIMAll);
-        if (mode == G_ONEEVENT)
-            return 1;
-        rtn = 1;
-        /* FALL THROUGH */
-    case FALSE:
-        while (XtAppPending (appcontext)) {
-            XtAppProcessEvent (appcontext, XtIMAll);
-            if (mode == G_ONEEVENT)
-                return 1;
-            rtn = 1;
-        }
-        break;
-    }
-    return rtn;
-}
diff --git a/cmd/lefty/ws/x11/gcommon.h b/cmd/lefty/ws/x11/gcommon.h
deleted file mode 100644 (file)
index 3d3760e..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#pragma once
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#if XlibSpecificationRelease < 5
-typedef char *XPointer;
-#endif
-
-/* point and rect structures */
-typedef XPoint PIXxy_t;
-typedef PIXxy_t PIXpoint_t;
-typedef PIXxy_t PIXsize_t;
-typedef struct PIXrect_t {
-    PIXxy_t o, c;
-} PIXrect_t;
-
-extern Widget Groot;
-extern Display *Gdisplay;
-extern int Gpopdownflag;
-extern int Gscreenn;
-extern int Gdepth;
-
-extern Arg argp[];
-extern int argn;
-#define MAXARGS 50
-#define RESETARGS (argn = 0)
-#define ADD2ARGS(var, val) ( \
-    XtSetArg (argp[argn], (var), (val)), argn++ \
-)
-
-/*  structures used to minimize number of calls to
-    XtManage and XtRealize functions (which are expensive)
-*/
-#define LAZYREALIZE 1
-#define LAZYRHINTS  2
-#define LAZYMANAGE  4
-
-#define LAZYQNUM 100
-typedef struct Glazyq_t {
-    int flag;
-    Widget rw;
-    XSizeHints hints;
-    Widget mws[LAZYQNUM];
-    int mwn;
-} Glazyq_t;
-extern Glazyq_t Glazyq;
-
-typedef struct Gfont_t {
-    char *name;
-    XFontStruct *font;
-} Gfont_t;
-extern Gfont_t *Gfontp;
-extern int Gfontn;
-#define FONTSIZE sizeof (Gfont_t)
-#define SETFONT(font) { \
-    XGCValues gcv; \
-    if (font != WCU->font) { \
-        WCU->font = font, gcv.font = font->fid; \
-        XChangeGC (Gdisplay, GC, GCFont, &gcv); \
-    } \
-}
-
-extern char *Gbufp;
-extern int Gbufn, Gbufi;
-#define BUFINCR 1024
-#define BUFSIZE sizeof (char)
-
-extern PIXpoint_t *Gppp;
-extern int Gppn, Gppi;
-#define PPINCR 100
-#define PPSIZE sizeof (PIXpoint_t)
-
-#define GETSIZE(sin, sout, smin) ( \
-    sout.x = (sin.x > smin) ? sin.x + 0.5 : smin, \
-    sout.y = (sin.y > smin) ? sin.y + 0.5 : smin \
-)
-#define GETORIGIN(oin, oout) ( \
-    oout.x = oin.x + 0.5, oout.y = oin.y + 0.5 \
-)
-
-int Ginitgraphics (void);
-int Gtermgraphics (void);
-void Gflushlazyq (void);
-void Glazyrealize (Widget, int, XSizeHints *);
-void Glazymanage (Widget);
-int Gsync (void);
-
-int GAcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GAsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GAgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GAdestroywidget (Gwidget_t *);
-
-int GBcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GBsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GBgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GBdestroywidget (Gwidget_t *);
-
-int GCcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GCsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GCgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GCdestroywidget (Gwidget_t *);
-int GCcanvasclear (Gwidget_t *);
-int GCsetgfxattr (Gwidget_t *, Ggattr_t *);
-int GCgetgfxattr (Gwidget_t *, Ggattr_t *);
-int GCarrow (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GCline (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GCbox (Gwidget_t *, Grect_t, Ggattr_t *);
-int GCpolygon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GCsplinegon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GCarc (Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
-int GCtext (
-    Gwidget_t *, Gtextline_t *, int, Gpoint_t,
-    char *, double, char *, Ggattr_t *
-);
-int GCgettextsize (Gwidget_t *, Gtextline_t *, int, char *, double, Gsize_t *);
-int GCcreatebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t);
-int GCdestroybitmap (Gbitmap_t *);
-int GCreadbitmap (Gwidget_t *, Gbitmap_t *, FILE *);
-int GCwritebitmap (Gbitmap_t *, FILE *);
-int GCbitblt (Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *, Ggattr_t *);
-int GCgetmousecoords (Gwidget_t *, Gpoint_t *, int *);
-
-int GLcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GLsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GLgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GLdestroywidget (Gwidget_t *);
-
-int GMcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GMsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GMgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GMdestroywidget (Gwidget_t *);
-int GMmenuaddentries (Gwidget_t *, int, char **);
-int GMmenudisplay (Gwidget_t *, Gwidget_t *);
-
-int GPcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GPsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GPgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GPdestroywidget (Gwidget_t *);
-int GPcanvasclear (Gwidget_t *);
-int GPsetgfxattr (Gwidget_t *, Ggattr_t *);
-int GPgetgfxattr (Gwidget_t *, Ggattr_t *);
-int GParrow (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GPline (Gwidget_t *, Gpoint_t, Gpoint_t, Ggattr_t *);
-int GPbox (Gwidget_t *, Grect_t, Ggattr_t *);
-int GPpolygon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GPsplinegon (Gwidget_t *, int, Gpoint_t *, Ggattr_t *);
-int GParc (Gwidget_t *, Gpoint_t, Gsize_t, double, double, Ggattr_t *);
-int GPtext (
-    Gwidget_t *, Gtextline_t *, int, Gpoint_t,
-    char *, double, char *, Ggattr_t *
-);
-int GPcreatebitmap (Gwidget_t *, Gbitmap_t *, Gsize_t);
-int GPdestroybitmap (Gbitmap_t *);
-int GPreadbitmap (Gwidget_t *, Gbitmap_t *, FILE *);
-int GPwritebitmap (Gbitmap_t *, FILE *);
-int GPbitblt (Gwidget_t *, Gpoint_t, Grect_t, Gbitmap_t *, char *, Ggattr_t *);
-
-int GQcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GQsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GQgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GQdestroywidget (Gwidget_t *);
-int GQqueryask (Gwidget_t *, char *, char *, char *, int);
-
-int GScreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GSsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GSgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GSdestroywidget (Gwidget_t *);
-
-int GTcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GTsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GTgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GTdestroywidget (Gwidget_t *);
-
-int GVcreatewidget (Gwidget_t *, Gwidget_t *, int, Gwattr_t *);
-int GVsetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GVgetwidgetattr (Gwidget_t *, int, Gwattr_t *);
-int GVdestroywidget (Gwidget_t *);
-
-void Gcwbutaction (Widget, XEvent *, char **, unsigned int *);
-void Gcwkeyaction (Widget, XEvent *, char **, unsigned int *);
-void Glwbutaction (Widget, XEvent *, char **, unsigned int *);
-void Glwkeyaction (Widget, XEvent *, char **, unsigned int *);
-void Gtweolaction (Widget, XEvent *, char **, unsigned int *);
-void Gqwpopaction (Widget, XEvent *, char **, unsigned int *);
-void Gqwdelaction (Widget, XEvent *, char **, unsigned int *);
-void Gwmdelaction (Widget, XEvent *, char **, unsigned int *);
-extern XtTranslations Gtweoltable;
-extern XtTranslations Gqwpoptable;
-extern XtTranslations Glwanytable;
-extern XtTranslations Gcwanytable;
-extern XtTranslations Gqwdeltable;
-extern XtTranslations Gwmdeltable;
-
-extern Atom Gqwdelatom, Gwmdelatom;
diff --git a/cmd/lefty/ws/x11/glabel.c b/cmd/lefty/ws/x11/glabel.c
deleted file mode 100644 (file)
index 163e855..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WLU widget->u.l
-
-int GLcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    int ai;
-    XColor c;
-    int color;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    WLU->func = NULL;
-    ps.x = ps.y = MINLWSIZE;
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINLWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRTEXT:
-            ADD2ARGS (XtNlabel, attrp[ai].u.t);
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WLU->func = (Glabelcb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    ADD2ARGS (XtNwidth, ps.x);
-    ADD2ARGS (XtNheight, ps.y);
-    ADD2ARGS (XtNhighlightThickness, 0);
-    ADD2ARGS (XtNinternalHeight, 0);
-    ADD2ARGS (XtNinternalWidth, 0);
-    ADD2ARGS (XtNjustify, XtJustifyLeft);
-    if (!(widget->w = XtCreateWidget (
-        "label", labelWidgetClass, parent->w, argp, argn
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    XtOverrideTranslations (widget->w, Glwanytable);
-    Glazymanage (widget->w);
-    return 0;
-}
-
-int GLsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PIXsize_t ps;
-    int ai;
-    XColor c;
-    int color;
-
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINLWSIZE);
-            ADD2ARGS (XtNwidth, ps.x);
-            ADD2ARGS (XtNheight, ps.y);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRTEXT:
-            ADD2ARGS (XtNlabel, attrp[ai].u.t);
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WLU->func = (Glabelcb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    XtSetValues (widget->w, argp, argn);
-    return 0;
-}
-
-int GLgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Dimension width, height;
-    char *s;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        RESETARGS;
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            ADD2ARGS (XtNwidth, &width);
-            ADD2ARGS (XtNheight, &height);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, &width);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.i = width;
-            break;
-        case G_ATTRTEXT:
-            ADD2ARGS (XtNlabel, &s);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.t = s;
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTREVENTCB:
-            attrp[ai].u.func = WLU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GLdestroywidget (Gwidget_t *widget) {
-    XtDestroyWidget (widget->w);
-    return 0;
-}
-
-void Glwbutaction (Widget w, XEvent *evp, char **app, unsigned int *anp) {
-    Gwidget_t *widget;
-    Gevent_t gev;
-    int wi, xtype;
-
-    widget = findwidget ((unsigned long) w, G_LABELWIDGET);
-    switch ((xtype = evp->type)) {
-    case ButtonPress:
-    case ButtonRelease:
-        gev.type = G_MOUSE;
-        gev.code = (xtype == ButtonPress) ? G_DOWN : G_UP;
-        if ((gev.data = evp->xbutton.button - Button1) > 4)
-            return;
-        break;
-    default:
-        return;
-    }
-    wi = gev.wi = widget - &Gwidgets[0];
-    if (WLU->func)
-        (*WLU->func) (&gev);
-    if (Gpopdownflag) {
-        Gpopdownflag = FALSE;
-        if (gev.code == G_DOWN) {
-            gev.code = G_UP;
-            widget = &Gwidgets[wi];
-            if (widget->inuse && WLU->func)
-                (*WLU->func) (&gev);
-        }
-    }
-}
-
-void Glwkeyaction (Widget w, XEvent *evp, char **app, unsigned int *anp) {
-    Gwidget_t *widget;
-    Gevent_t gev;
-    int xtype;
-    char c;
-
-    widget = findwidget ((unsigned long) w, G_LABELWIDGET);
-    switch ((xtype = evp->type)) {
-    case KeyPress:
-    case KeyRelease:
-        if (!XLookupString ((XKeyEvent *) evp, &c, 1, NULL, NULL))
-            return;
-        gev.type = G_KEYBD;
-        gev.code = (xtype == KeyPress) ? G_DOWN : G_UP;
-        gev.data = c;
-        break;
-    default:
-        return;
-    }
-    gev.wi = widget - &Gwidgets[0];
-    if (WLU->func)
-        (*WLU->func) (&gev);
-    if (Gpopdownflag)
-        Gpopdownflag = FALSE;
-}
diff --git a/cmd/lefty/ws/x11/gmenu.c b/cmd/lefty/ws/x11/gmenu.c
deleted file mode 100644 (file)
index f16b8d7..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WMU widget->u.m
-
-static int menupoped;
-static int menuselected;
-
-static void mwcallback (Widget, XtPointer, XtPointer);
-
-int GMcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    if (!(widget->w = XtCreatePopupShell (
-        "menu", simpleMenuWidgetClass, Groot, NULL, 0
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    XtAddCallback (widget->w, XtNpopdownCallback, mwcallback, (XtPointer) -1);
-    WMU->count = 0;
-    return 0;
-}
-
-int GMsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GMgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GMdestroywidget (Gwidget_t *widget) {
-    XtDestroyWidget (widget->w);
-    return 0;
-}
-
-int GMmenuaddentries (Gwidget_t *widget, int en, char **ep) {
-    Widget mep;
-    int ei;
-
-    for (ei = 0; ei < en; ei++) {
-        mep = XtCreateManagedWidget (
-            ep[ei], smeBSBObjectClass, widget->w, NULL, 0
-        );
-        XtAddCallback (mep, XtNcallback, mwcallback, (XtPointer) WMU->count++);
-    }
-    return 0;
-}
-
-int GMmenudisplay (Gwidget_t *parent, Gwidget_t *widget) {
-    Window rwin, cwin;
-    Dimension width, height;
-    int rx, ry, x, y;
-    unsigned int mask;
-
-    XQueryPointer (
-        Gdisplay, XtWindow (parent->w),
-        &rwin, &cwin, &rx, &ry, &x, &y, &mask
-    );
-    XtRealizeWidget (widget->w);
-    RESETARGS;
-    ADD2ARGS (XtNwidth, &width);
-    ADD2ARGS (XtNheight, &height);
-    XtGetValues (widget->w, argp, argn);
-    if (rx + width > DisplayWidth (Gdisplay, Gscreenn))
-        rx = DisplayWidth (Gdisplay, Gscreenn) - width;
-    if (ry + height > DisplayHeight (Gdisplay, Gscreenn))
-        ry = DisplayHeight (Gdisplay, Gscreenn) - height;
-    if (rx < 0)
-        rx = 0;
-    if (ry < 0)
-        ry = 0;
-    RESETARGS;
-    ADD2ARGS (XtNx, rx);
-    ADD2ARGS (XtNy, ry);
-    XtSetValues (widget->w, argp, argn);
-    menupoped = TRUE;
-    menuselected = -1;
-    XtPopupSpringLoaded (widget->w);
-    while (menupoped)
-        Gprocessevents (TRUE, G_ONEEVENT);
-    Gpopdownflag = TRUE;
-    return menuselected;
-}
-
-static void mwcallback (Widget w, XtPointer clientdata, XtPointer calldata) {
-    if (((long) clientdata) > -1)
-        menuselected = (long) clientdata;
-    menupoped = FALSE;
-}
diff --git a/cmd/lefty/ws/x11/gpcanvas.c b/cmd/lefty/ws/x11/gpcanvas.c
deleted file mode 100644 (file)
index 4df9b84..0000000
+++ /dev/null
@@ -1,793 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-#include <math.h>
-#include <stdbool.h>
-#include <string.h>
-
-#define PSDPI 300.0
-#define PSMAXPIXW (8.0  * PSDPI)
-#define PSMAXPIXH (10.5 * PSDPI)
-#define PSPTPI 72.0
-#define PSMAXPTW (8.0  * PSPTPI)
-#define PSMAXPTH (10.5 * PSPTPI)
-#define PSXOFF 18
-#define PSYOFF 18
-
-static PIXsize_t maxsize = { PSMAXPIXW, PSMAXPIXH };
-static long count;
-
-#define WPU widget->u.p
-#define FP widget->u.p->fp
-
-#define RED   WPU->colors[WPU->gattr.color].nr
-#define GREEN WPU->colors[WPU->gattr.color].ng
-#define BLUE  WPU->colors[WPU->gattr.color].nb
-
-static char *gstyles[5] = {
-    /* G_SOLID */       "16  0",
-    /* G_DASHED */      " 4  4",
-    /* G_DOTTED */      " 2  2",
-    /* G_LONGDASHED */  " 4 12",
-    /* G_SHORTDASHED */ "12  4",
-};
-
-char *Gpscanvasname = "out.ps";
-
-static char *findfont (char *);
-static void setgattr (Gwidget_t *, Ggattr_t *);
-
-static PIXrect_t rdrawtopix (Gwidget_t *, Grect_t);
-static PIXpoint_t pdrawtopix (Gwidget_t *, Gpoint_t);
-static PIXsize_t sdrawtopix (Gwidget_t *, Gsize_t);
-static PIXpoint_t pdrawtobpix (Gbitmap_t *, Gpoint_t);
-
-int GPcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget,
-    int attrn, Gwattr_t *attrp
-) {
-    PIXpoint_t po;
-    PIXsize_t ps;
-    struct Gpwcolor_t *cp;
-    FILE *pfp;
-    char buf[120];
-    char *s, *path;
-    int color, lflag, ai, i, x, y, w, h, r, g, b;
-
-    if (
-        !(path = buildpath ("lefty.psp", false)) ||
-        !(pfp = fopen (path, "r"))
-    ) {
-        Gerr (POS, G_ERRCANNOTOPENFILE, "lefty.psp");
-        return -1;
-    }
-    s = Gpscanvasname;
-    lflag = FALSE;
-    po.x = po.y = 0;
-    ps.x = ps.y = MINPWSIZE;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            GETORIGIN (attrp[ai].u.p, po);
-            break;
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINPWSIZE);
-            break;
-        case G_ATTRNAME:
-            if (attrp[ai].u.t && attrp[ai].u.t[0])
-                s = attrp[ai].u.t;
-            break;
-        case G_ATTRMODE:
-            if (strcmp ("landscape", attrp[ai].u.t) == 0)
-                lflag = TRUE;
-            else if (strcmp ("portrait", attrp[ai].u.t) == 0)
-                lflag = FALSE;
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRCOLOR:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRVIEWPORT:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRWINDOW:
-            /* will do it after the widget is created */
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    if (!(FP = fopen (s, "w"))) {
-        Gerr (POS, G_ERRCANNOTOPENFILE, s);
-        return -1;
-    }
-    WPU->colors[0].r = WPU->colors[0].g = WPU->colors[0].b = 255;
-    WPU->colors[0].nr = WPU->colors[0].ng = WPU->colors[0].nb = 1.0;
-    WPU->colors[0].inuse = TRUE;
-    WPU->colors[1].r = WPU->colors[1].g = WPU->colors[1].b = 0;
-    WPU->colors[1].nr = WPU->colors[1].ng = WPU->colors[1].nb = 0.0;
-    WPU->colors[1].inuse = TRUE;
-    for (i = 2; i < G_MAXCOLORS; i++)
-        WPU->colors[i].inuse = FALSE;
-    WPU->gattr.color = 1;
-    WPU->gattr.width = 0;
-    WPU->gattr.mode = -1;
-    WPU->gattr.fill = 0;
-    WPU->gattr.style = 0;
-    WPU->wrect.o.x = 0.0, WPU->wrect.o.y = 0.0;
-    WPU->wrect.c.x = 1.0, WPU->wrect.c.y = 1.0;
-    WPU->vsize.x = ps.x, WPU->vsize.y = ps.y;
-    if (lflag)
-        x = po.y, y = po.x, w = ps.y, h = ps.x;
-    else
-        x = po.x, y = po.y, w = ps.x, h = ps.y;
-    fprintf (FP, "%%! LEFTY Output\n");
-    fprintf (
-        FP, "%%%%BoundingBox: %d %d %d %d\n",
-        (int) (PSXOFF + PSMAXPTW * x / maxsize.x + 0.5),
-        (int) (PSYOFF + PSMAXPTH * y / maxsize.y + 0.5),
-        (int) (PSXOFF + PSMAXPTW * w / maxsize.x + 0.5),
-        (int) (PSYOFF + PSMAXPTH * h / maxsize.y + 0.5)
-    );
-    fprintf (FP, "%%%%EndComments\n");
-    while (fgets (buf, 120, pfp))
-        fputs (&buf[0], FP);
-    fclose (pfp);
-    fprintf (
-        FP, "/ICP { %d %d %d %d SCP } def\n",
-        (int) po.x, (int) po.y,
-        (int) (po.x + ps.x - 1), (int) (po.y + ps.y - 1)
-    );
-    fprintf (
-        FP, "/BB { %d %d %d %d } def\n",
-        (int) po.x, (int) po.y,
-        (int) (po.x + ps.x - 1), (int) (po.y + ps.y - 1)
-    );
-    if (!lflag)
-        fprintf (
-            FP, "[%f 0 0 %f %d %d] concat\n",
-            PSPTPI / PSDPI, PSPTPI / PSDPI, PSXOFF, PSYOFF
-        );
-    else
-        fprintf (
-            FP, "[0 %f %f 0 %d %d] concat\n",
-            PSPTPI / PSDPI, - PSPTPI / PSDPI,
-            (int) (PSXOFF + ps.y * PSPTPI / PSDPI), PSYOFF
-        );
-    fprintf (FP, "%d %d translate ICP\n", (int) po.x, (int) po.y);
-    fprintf (FP, "1 setlinecap\n");
-    fprintf (FP, "ICP\n");
-    WPU->gattr.color = 1;
-    fprintf (FP, "%f %f %f CL\n", RED, GREEN, BLUE);
-    WPU->defgattr = WPU->gattr;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, attrp[ai].u.c.index);
-                return -1;
-            }
-            cp = &WPU->colors[color];
-            r = attrp[ai].u.c.r;
-            g = attrp[ai].u.c.g;
-            b = attrp[ai].u.c.b;
-            cp->r = r, cp->g = g, cp->b = b;
-            cp->nr = r / 256.0, cp->ng = g / 256.0, cp->nb = b / 256.0;
-            cp->inuse = TRUE;
-            break;
-        case G_ATTRVIEWPORT:
-            WPU->vsize.x = (int) (attrp[ai].u.s.x + 0.5);
-            WPU->vsize.y = (int) (attrp[ai].u.s.y + 0.5);
-            fprintf (
-                FP, "0 0 %d %d SCP\n", (int) WPU->vsize.x, (int) WPU->vsize.y
-            );
-            break;
-        case G_ATTRWINDOW:
-            WPU->wrect = attrp[ai].u.r;
-            break;
-        }
-    }
-    return 0;
-}
-
-int GPsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    struct Gpwcolor_t *cp;
-    int color, ai, r, g, b;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            break;
-        case G_ATTRSIZE:
-            break;
-        case G_ATTRNAME:
-            break;
-        case G_ATTRMODE:
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS) {
-                Gerr (POS, G_ERRBADCOLORINDEX, attrp[ai].u.c.index);
-                return -1;
-            }
-            cp = &WPU->colors[color];
-            r = attrp[ai].u.c.r;
-            g = attrp[ai].u.c.g;
-            b = attrp[ai].u.c.b;
-            cp->r = r, cp->g = g, cp->b = b;
-            cp->nr = r / 256.0, cp->ng = g / 256.0, cp->nb = b / 256.0;
-            cp->inuse = TRUE;
-            break;
-        case G_ATTRVIEWPORT:
-            WPU->vsize.x = (int) (attrp[ai].u.s.x + 0.5);
-            WPU->vsize.y = (int) (attrp[ai].u.s.y + 0.5);
-            fprintf (
-                FP, "0 0 %d %d SCP\n", (int) WPU->vsize.x, (int) WPU->vsize.y
-            );
-            break;
-        case G_ATTRWINDOW:
-            WPU->wrect = attrp[ai].u.r;
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GPgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    struct Gpwcolor_t *cp;
-    int color, ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            break;
-        case G_ATTRSIZE:
-            break;
-        case G_ATTRNAME:
-            break;
-        case G_ATTRMODE:
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color < 0 || color > G_MAXCOLORS || !WPU->colors[color].inuse) {
-                Gerr (POS, G_ERRBADCOLORINDEX, attrp[ai].u.c.index);
-                return -1;
-            }
-            cp = &WPU->colors[color];
-            attrp[ai].u.c.r = cp->r;
-            attrp[ai].u.c.g = cp->g;
-            attrp[ai].u.c.b = cp->b;
-            break;
-        case G_ATTRVIEWPORT:
-            attrp[ai].u.s = WPU->vsize;
-            break;
-        case G_ATTRWINDOW:
-            attrp[ai].u.r = WPU->wrect;
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTGETATTR, "windowid");
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GPdestroywidget (Gwidget_t *widget) {
-    fprintf (FP, "stroke showpage\n");
-    fclose (FP);
-    return 0;
-}
-
-int GPcanvasclear (Gwidget_t *widget) {
-    fprintf (FP, "ICP DO\n");
-    WPU->gattr.color = 0;
-    fprintf (FP, "%f %f %f CL\n", RED, GREEN, BLUE);
-    fprintf (FP, "BB BOX FI\n");
-    WPU->gattr.color = -1;
-    fprintf (FP, "0 0 %d %d SCP\n", (int) WPU->vsize.x, (int) WPU->vsize.y);
-    return 0;
-}
-
-int GPsetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    setgattr (widget, ap);
-    WPU->defgattr = WPU->gattr;
-    return 0;
-}
-
-int GPgetgfxattr (Gwidget_t *widget, Ggattr_t *ap) {
-    if ((ap->flags & G_GATTRCOLOR))
-        ap->color = WPU->gattr.color;
-    if ((ap->flags & G_GATTRWIDTH))
-        ap->width = WPU->gattr.width;
-    if ((ap->flags & G_GATTRMODE))
-        ap->mode = WPU->gattr.mode;
-    if ((ap->flags & G_GATTRFILL))
-        ap->fill = WPU->gattr.fill;
-    if ((ap->flags & G_GATTRSTYLE))
-        ap->style = WPU->gattr.style;
-    return 0;
-}
-
-int GParrow (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    PIXpoint_t pp1, pp2, pa, pb, pd;
-    double tangent;
-    int l;
-
-    pp1 = pdrawtopix (widget, gp1), pp2 = pdrawtopix (widget, gp2);
-    pd.x = pp1.x - pp2.x, pd.y = pp1.y - pp2.y;
-    if (pd.x == 0 && pd.y == 0)
-        return 0;
-    tangent = atan2 ((double) pd.y, (double) pd.x);
-    if ((l = hypot(pd.x, pd.y)) < 30)
-        l = 30;
-    pa.x = l * cos (tangent + M_PI / 7) + pp2.x;
-    pa.y = l * sin (tangent + M_PI / 7) + pp2.y;
-    pb.x = l * cos (tangent - M_PI / 7) + pp2.x;
-    pb.y = l * sin (tangent - M_PI / 7) + pp2.y;
-    setgattr (widget, ap);
-    fprintf (
-        FP, "%d %d %d %d LI\n",
-        (int) pp2.x, (int) pp2.y, (int) pp1.x, (int) pp1.y
-    );
-    fprintf (
-        FP, "%d %d %d %d LI\n",
-        (int) pp2.x, (int) pp2.y, (int) pa.x, (int) pa.y
-    );
-    fprintf (
-        FP, "%d %d %d %d LI\n",
-        (int) pp2.x, (int) pp2.y, (int) pb.x, (int) pb.y
-    );
-    return 0;
-}
-
-int GPline (Gwidget_t *widget, Gpoint_t gp1, Gpoint_t gp2, Ggattr_t *ap) {
-    PIXpoint_t pp1, pp2;
-
-    pp1 = pdrawtopix (widget, gp1), pp2 = pdrawtopix (widget, gp2);
-    if (count++ == 100)
-        count = 0, fprintf (FP, "DO\n");
-    setgattr (widget, ap);
-    fprintf (
-        FP, "%d %d %d %d LI\n",
-        (int) pp2.x, (int) pp2.y, (int) pp1.x, (int) pp1.y
-    );
-    return 0;
-}
-
-int GPbox (Gwidget_t *widget, Grect_t gr, Ggattr_t *ap) {
-    PIXrect_t pr;
-
-    pr = rdrawtopix (widget, gr);
-    setgattr (widget, ap);
-    if (WPU->gattr.fill)
-        fprintf (
-            FP, "DO %d %d %d %d BOX FI\n",
-            (int) pr.o.x, (int) pr.o.y, (int) pr.c.x, (int) pr.c.y
-        );
-    else
-        fprintf (
-            FP, "DO %d %d %d %d BOX DO\n",
-            (int) pr.o.x, (int) pr.o.y, (int) pr.c.x, (int) pr.c.y
-        );
-    return 0;
-}
-
-int GPpolygon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    PIXpoint_t pp;
-    int i;
-
-    if (gpn == 0)
-        return 0;
-
-    pp = pdrawtopix (widget, gpp[0]);
-    setgattr (widget, ap);
-    fprintf (FP, "DO %d %d moveto\n", (int) pp.x, (int) pp.y);
-    for (i = 1; i < gpn; i++) {
-        pp = pdrawtopix (widget, gpp[i]);
-        fprintf (FP, "%d %d lineto\n", (int) pp.x, (int) pp.y);
-    }
-    if (WPU->gattr.fill)
-        fprintf (FP, "FI\n");
-    else
-        fprintf (FP, "DO\n");
-    return 0;
-}
-
-int GPsplinegon (Gwidget_t *widget, int gpn, Gpoint_t *gpp, Ggattr_t *ap) {
-    PIXpoint_t p0, p1, p2, p3;
-    int i;
-
-    if (gpn == 0)
-        return 0;
-
-    p0 = pdrawtopix (widget, gpp[0]);
-    setgattr (widget, ap);
-    fprintf (FP, "DO %d %d moveto\n", (int) p0.x, (int) p0.y);
-    for (i = 1; i < gpn; i += 3) {
-        p1 = pdrawtopix (widget, gpp[i]);
-        p2 = pdrawtopix (widget, gpp[i + 1]);
-        p3 = pdrawtopix (widget, gpp[i + 2]);
-        fprintf (
-            FP, "%d %d %d %d %d %d CT\n", (int) p1.x, (int) p1.y,
-            (int) p2.x, (int) p2.y, (int) p3.x, (int) p3.y
-        );
-    }
-    if (WPU->gattr.fill)
-        fprintf (FP, "FI\n");
-    else
-        fprintf (FP, "DO\n");
-    return 0;
-}
-
-int GParc (
-    Gwidget_t *widget, Gpoint_t gc, Gsize_t gs,
-    double ang1, double ang2, Ggattr_t *ap
-) {
-    PIXpoint_t pc;
-    PIXsize_t ps;
-
-    pc = pdrawtopix (widget, gc), ps = sdrawtopix (widget, gs);
-    setgattr (widget, ap);
-    if (WPU->gattr.fill)
-        fprintf (
-            FP, "DO %d %d %f %d %f %f ARF\n",
-            pc.x, pc.y, (double) ps.y / (double) ps.x, ps.x, ang1, ang2
-        );
-    else
-        fprintf (
-            FP, "DO %d %d %f %d %f %f AR\n",
-            pc.x, pc.y, (double) ps.y / (double) ps.x, ps.x, ang1, ang2
-        );
-    return 0;
-}
-
-int GPtext (
-    Gwidget_t *widget, Gtextline_t *tlp, int n, Gpoint_t go, char *fn,
-    double fs, char *justs, Ggattr_t *ap
-) {
-    Gsize_t gs;
-    PIXpoint_t po;
-    PIXsize_t ps;
-    char *font;
-    char c, *p;
-    int i;
-
-    po = pdrawtopix (widget, go);
-    gs.x = 0, gs.y = fs;
-    ps = sdrawtopix (widget, gs);
-    font = findfont (fn);
-    setgattr (widget, ap);
-    fprintf (
-        FP, "DO %d (%c) %d (%c) [",
-        (int) po.x, justs[0], (int) po.y, justs[1]
-    );
-    for (i = 0; i < n; i++) {
-        c = tlp[i].p[tlp[i].n], tlp[i].p[tlp[i].n] = '\000';
-        fprintf (FP, "[ (");
-        for (p = tlp[i].p; *p; p++) { /* generate PS escapes as needed */
-            if ((*p == '(') || (*p == ')') || (*p == '\\'))
-                fputc('\\',FP);
-            fputc(*p,FP);
-        }
-        fprintf (FP,") (%c) ] ", tlp[i].j);
-        tlp[i].p[tlp[i].n] = c;
-    }
-    fprintf (FP, "] %d /%s %d TXT\n", n, font, (int) ps.y);
-    return 0;
-}
-
-static char *findfont (char *name) {
-    char *font;
-
-    if (strcmp(name, "") == 0 || strcmp (name, "default") == 0)
-        font = "Times-Roman";
-    else
-        font = name;
-    return font;
-}
-
-int GPcreatebitmap (Gwidget_t *widget, Gbitmap_t *bitmap, Gsize_t s) {
-    if (!widget) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    bitmap->u.bits = Marrayalloc ((long) ((int) s.x * (int) s.y * 3));
-    bitmap->ctype = widget->type;
-    bitmap->canvas = widget - &Gwidgets[0];
-    bitmap->size = s;
-    return 0;
-}
-
-int GPdestroybitmap (Gbitmap_t *bitmap) {
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    Marrayfree (bitmap->u.bits);
-    return 0;
-}
-
-int GPreadbitmap (Gwidget_t *widget, Gbitmap_t *bitmap, FILE *fp) {
-    Gsize_t s;
-    char bufp[2048];
-    char *s1, *s2;
-    char c;
-    int bufn, bufi, step, x, y, k;
-
-    s.x = s.y = 0;
-    if (!widget) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    if (!bitmap) {
-        Gerr (POS, G_ERRNOBITMAP);
-        return -1;
-    }
-    step = 0;
-    while (step < 3) {
-l1:
-        if (!fgets (bufp, 2048, fp)) {
-            Gerr (POS, G_ERRCANNOTREADBITMAP);
-            return -1;
-        }
-        s1 = &bufp[0];
-l2:
-        for (; *s1 && isspace (*s1); s1++)
-            ;
-        if (!*s1 || *s1 == '#')
-            goto l1;
-        switch (step) {
-        case 0:
-            if (strncmp (s1, "P6", 2) != 0) {
-                Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            step++, s1 += 2;
-            goto l2;
-        case 1:
-            for (s2 = s1; *s2 && *s2 >= '0' && *s2 <= '9'; s2++)
-                ;
-            c = *s2, *s2 = 0;
-            if (s2 == s1 || (s.x = atoi (s1)) <= 0) {
-                *s2 = c, Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            *s2 = c, step++, s1 = s2;
-            goto l2;
-        case 2:
-            for (s2 = s1; *s2 && *s2 >= '0' && *s2 <= '9'; s2++)
-                ;
-            c = *s2, *s2 = 0;
-            if (s2 == s1 || (s.y = atoi (s1)) <= 0) {
-                *s2 = c, Gerr (POS, G_ERRCANNOTREADBITMAP);
-                return -1;
-            }
-            *s2 = c, step++, s1 = s2;
-            goto l2;
-        }
-    }
-    bitmap->u.bits = Marrayalloc ((long) ((int) s.x * (int) s.y * 3));
-    bitmap->ctype = widget->type;
-    bitmap->canvas = widget - &Gwidgets[0];
-    bitmap->size = s;
-    bufi = bufn = 0;
-    bufp[bufi] = 0;
-    s1 = (char *) bitmap->u.bits;
-    for (y = 0; y < s.y; y++) {
-        for (x = 0; x < s.x; x++) {
-            for (k = 0; k < 3; k++) {
-                if (bufi == bufn) {
-                    if ((bufn = fread (bufp, 1, 2047, fp)) == 0) {
-                        Marrayfree (bitmap->u.bits);
-                        Gerr (POS, G_ERRCANNOTCREATEBITMAP);
-                        return -1;
-                    }
-                    bufi = 0;
-                }
-                *s1++ = bufp[bufi++];
-            }
-        }
-    }
-    return 0;
-}
-
-int GPwritebitmap (Gbitmap_t *bitmap, FILE *fp) {
-    return -1;
-}
-
-int GPbitblt (
-    Gwidget_t *widget, Gpoint_t gp, Grect_t gr, Gbitmap_t *bitmap,
-    char *mode, Ggattr_t *ap
-) {
-    PIXrect_t pr, br;
-    PIXpoint_t pp;
-    PIXsize_t bs;
-    Gsize_t scale;
-    Gxy_t p;
-    int x, y, hi, lo;
-    double tvx, tvy, twx, twy;
-    char *s;
-
-    if (gr.o.x > gr.c.x)
-        p.x = gr.o.x, gr.o.x = gr.c.x, gr.c.x = p.x;
-    if (gr.o.y > gr.c.y)
-        p.y = gr.o.y, gr.o.y = gr.c.y, gr.c.y = p.y;
-    tvx = WPU->vsize.x, tvy = WPU->vsize.y;
-    twx = WPU->wrect.c.x - WPU->wrect.o.x;
-    twy = WPU->wrect.c.y - WPU->wrect.o.y;
-    scale.x = tvx / twx, scale.y = tvy / twy;
-    pr = rdrawtopix (widget, gr);
-    pp = pdrawtobpix (bitmap, gp);
-    bs.x = (pr.c.x - pr.o.x + 1) / scale.x;
-    bs.y = (pr.c.y - pr.o.y + 1) / scale.y;
-    br.o.x = pp.x, br.o.y = pp.y - bs.y + 1;
-    br.c.x = br.o.x + bs.x - 1, br.c.y = br.o.y + bs.y - 1;
-    if (br.o.x < 0)
-        pr.o.x -= br.o.x * scale.x, br.o.x = 0;
-    if (br.o.y < 0)
-        pr.o.y -= br.o.y * scale.y, br.o.y = 0;
-    if (br.c.x >= bitmap->size.x) {
-        pr.c.x -= (br.c.x + 1 - bitmap->size.x) * scale.x;
-        br.c.x = bitmap->size.x - 1;
-    }
-    if (br.c.y >= bitmap->size.y) {
-        pr.c.y -= (br.c.y + 1 - bitmap->size.y) * scale.y;
-        br.c.y = bitmap->size.y - 1;
-    }
-    if (pr.o.x < 0)
-        br.o.x -= pr.o.x / scale.x, pr.o.x = 0;
-    if (pr.o.y < 0)
-        br.o.y -= pr.o.y / scale.y, pr.o.y = 0;
-    if (pr.c.x >= tvx)
-        br.c.x -= (pr.c.x + 1 - tvx) / scale.x, pr.c.x = tvx - 1;
-    if (pr.c.y >= tvy)
-        br.c.y -= (pr.c.y + 1 - tvy) / scale.y, pr.c.y = tvy - 1;
-    bs.x = (pr.c.x - pr.o.x + 1) / scale.x;
-    bs.y = (pr.c.y - pr.o.y + 1) / scale.y;
-    setgattr (widget, ap);
-    fprintf (FP, "DO gsave\n");
-    fprintf (FP, "%d %d translate\n", pr.o.x, pr.o.y);
-    fprintf (FP, "%f %f scale\n", scale.x * bs.x, scale.y * bs.y);
-    fprintf (FP, "/mystr %d string def\n", 3 * bs.x);
-    fprintf (FP, "%d %d 8\n", bs.x, bs.y);
-    fprintf (FP, "[%d 0 0 %d 0 %d]\n", bs.x, -bs.y, bs.y);
-    fprintf (FP, "{currentfile mystr readhexstring pop} false 3 colorimage\n");
-    for (y = 0; y < bs.y; y++) {
-        s = (char *) (
-            bitmap->u.bits + 3 * ((int) bitmap->size.x * (br.o.y + y) + br.o.x)
-        );
-        for (x = 0; x < bs.x; x++) {
-            hi = (*s >> 4) & 15, lo = *s++ & 15;
-            fprintf (FP, "%x%x", hi, lo);
-            hi = (*s >> 4) & 15, lo = *s++ & 15;
-            fprintf (FP, "%x%x", hi, lo);
-            hi = (*s >> 4) & 15, lo = *s++ & 15;
-            fprintf (FP, "%x%x", hi, lo);
-        }
-        fprintf (FP, "\n");
-    }
-    fprintf (FP, "grestore\nNP\n");
-    return 0;
-}
-
-static void setgattr (Gwidget_t *widget, Ggattr_t *ap) {
-    int color, width, style;
-
-    if (!(ap->flags & G_GATTRCOLOR))
-        ap->color = WPU->defgattr.color;
-    if (!(ap->flags & G_GATTRWIDTH))
-        ap->width = WPU->defgattr.width;
-    if (!(ap->flags & G_GATTRFILL))
-        ap->fill = WPU->defgattr.fill;
-    if (!(ap->flags & G_GATTRSTYLE))
-    ap->style = WPU->defgattr.style;
-    color = ap->color;
-    if (color >= G_MAXCOLORS || !(WPU->colors[color].inuse))
-        color = 1;
-    if (color != WPU->gattr.color) {
-        WPU->gattr.color = color;
-        fprintf (FP, "%f %f %f CL\n", RED, GREEN, BLUE);
-    }
-    width = ap->width;
-    if (width != WPU->gattr.width) {
-        WPU->gattr.width = width;
-        fprintf (FP, "DO %d setlinewidth NP\n", width);
-    }
-    WPU->gattr.fill = ap->fill;
-    style = ap->style;
-    if (style != WPU->gattr.style) {
-        WPU->gattr.style = style;
-        fprintf (FP, "DO [ %s ] 0 setdash NP\n", gstyles[style]);
-    }
-}
-
-static PIXrect_t rdrawtopix (Gwidget_t *widget, Grect_t gr) {
-    PIXrect_t pr;
-    double tvx, tvy, twx, twy;
-
-    tvx = WPU->vsize.x - 1, tvy = WPU->vsize.y - 1;
-    twx = WPU->wrect.c.x - WPU->wrect.o.x;
-    twy = WPU->wrect.c.y - WPU->wrect.o.y;
-    pr.o.x = tvx * (gr.o.x - WPU->wrect.o.x) / twx + 0.5;
-    pr.o.y = tvy * (gr.o.y - WPU->wrect.o.y) / twy + 0.5;
-    pr.c.x = tvx * (gr.c.x - WPU->wrect.o.x) / twx + 0.5;
-    pr.c.y = tvy * (gr.c.y - WPU->wrect.o.y) / twy + 0.5;
-    return pr;
-}
-
-static PIXpoint_t pdrawtopix (Gwidget_t *widget, Gpoint_t gp) {
-    PIXpoint_t pp;
-    double tvx, tvy, twx, twy;
-
-    tvx = WPU->vsize.x - 1, tvy = WPU->vsize.y - 1;
-    twx = WPU->wrect.c.x - WPU->wrect.o.x;
-    twy = WPU->wrect.c.y - WPU->wrect.o.y;
-    pp.x = tvx * (gp.x - WPU->wrect.o.x) / twx + 0.5;
-    pp.y = tvy * (gp.y - WPU->wrect.o.y) / twy + 0.5;
-    return pp;
-}
-
-static PIXsize_t sdrawtopix (Gwidget_t *widget, Gsize_t gs) {
-    PIXsize_t ps;
-    double tvx, tvy, twx, twy;
-
-    tvx = WPU->vsize.x - 1, tvy = WPU->vsize.y - 1;
-    twx = WPU->wrect.c.x - WPU->wrect.o.x;
-    twy = WPU->wrect.c.y - WPU->wrect.o.y;
-    ps.x = tvx * (gs.x - 1) / twx + 1.5;
-    ps.y = tvy * (gs.y - 1) / twy + 1.5;
-    return ps;
-}
-
-static PIXpoint_t pdrawtobpix (Gbitmap_t *bitmap, Gpoint_t gp) {
-    PIXpoint_t pp;
-    double tvy;
-
-    tvy = bitmap->size.y - 1;
-    pp.x = gp.x + 0.5;
-    pp.y = tvy - gp.y + 0.5;
-    return pp;
-}
diff --git a/cmd/lefty/ws/x11/gquery.c b/cmd/lefty/ws/x11/gquery.c
deleted file mode 100644 (file)
index 285cca4..0000000
+++ /dev/null
@@ -1,340 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "SF.h"
-
-#define WQU widget->u.q
-
-static void qwcallback (Widget, XtPointer, XtPointer);
-static void qbwcallback (Widget, XtPointer, XtPointer);
-
-int GQcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    Widget w;
-    int ai;
-
-    WQU->mode = G_QWSTRING;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRMODE:
-            if (strcmp ("string", attrp[ai].u.t) == 0)
-                WQU->mode = G_QWSTRING;
-            else if (strcmp ("file", attrp[ai].u.t) == 0)
-                WQU->mode = G_QWFILE;
-            else if (strcmp ("choice", attrp[ai].u.t) == 0)
-                WQU->mode = G_QWCHOICE;
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    switch (WQU->mode) {
-    case G_QWSTRING:
-        if (!(widget->w = XtCreatePopupShell (
-            "popup", transientShellWidgetClass, Groot, NULL, 0
-        ))) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-        XtAddCallback (widget->w, XtNpopdownCallback, qwcallback, NULL);
-        RESETARGS;
-        ADD2ARGS (XtNlabel, "abcdefghijklmno");
-        ADD2ARGS (XtNvalue, "");
-        if (!(WQU->w = XtCreateManagedWidget (
-            "dialog", dialogWidgetClass, widget->w, argp, argn
-        ))) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-        XawDialogAddButton (WQU->w, "Cancel", qbwcallback, (XtPointer) 1);
-        XawDialogAddButton (WQU->w, "OK", qbwcallback, (XtPointer) 2);
-        if (!(w = XtNameToWidget (WQU->w, "value"))) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-        XtOverrideTranslations (w, Gqwpoptable);
-        XtOverrideTranslations (widget->w, Gqwdeltable);
-        break;
-    case G_QWFILE:
-        widget->w = 0;
-        break;
-    case G_QWCHOICE:
-        if (!(widget->w = XtCreatePopupShell (
-            "popup", transientShellWidgetClass, Groot, NULL, 0
-        ))) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-        XtAddCallback (widget->w, XtNpopdownCallback, qwcallback, NULL);
-        RESETARGS;
-        ADD2ARGS (XtNlabel, "abcdefghijklmno");
-        if (!(WQU->w = XtCreateManagedWidget (
-            "dialog", dialogWidgetClass, widget->w, argp, argn
-        ))) {
-            Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-            return -1;
-        }
-        XtOverrideTranslations (widget->w, Gqwdeltable);
-        break;
-    }
-    return 0;
-}
-
-int GQsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRMODE:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "mode");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GQgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRMODE:
-            switch (WQU->mode) {
-            case G_QWSTRING:
-                attrp[ai].u.t = "string";
-                break;
-            case G_QWFILE:
-                attrp[ai].u.t = "file";
-                break;
-            case G_QWCHOICE:
-                attrp[ai].u.t = "choice";
-                break;
-            }
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GQdestroywidget (Gwidget_t *widget) {
-    switch (WQU->mode) {
-    case G_QWSTRING:
-        XtDestroyWidget (widget->w);
-        break;
-    case G_QWFILE:
-        break;
-    case G_QWCHOICE:
-        XtDestroyWidget (widget->w);
-        break;
-    }
-    return 0;
-}
-
-int GQqueryask (
-    Gwidget_t *widget, char *prompt, char *args,
-    char *responsep, int responsen
-) {
-    Window rwin, cwin;
-    Dimension width, height;
-    int rx, ry, x, y;
-    long i;
-    unsigned int mask;
-    Widget widgets[20];
-    char buttons[20][40];
-    char *s1, *s2;
-    char c;
-
-    switch (WQU->mode) {
-    case G_QWSTRING:
-        RESETARGS;
-        ADD2ARGS (XtNlabel, prompt);
-        ADD2ARGS (XtNvalue, args ? args : "");
-        XtSetValues (WQU->w, argp, argn);
-        XtRealizeWidget (widget->w);
-        XSetWMProtocols (Gdisplay, XtWindow (widget->w), &Gqwdelatom, 1);
-        XQueryPointer (
-            Gdisplay, XtWindow (widget->w),
-            &rwin, &cwin, &rx, &ry, &x, &y, &mask
-        );
-        RESETARGS;
-        ADD2ARGS (XtNwidth, &width);
-        ADD2ARGS (XtNheight, &height);
-        XtGetValues (widget->w, argp, argn);
-        rx -= (width / 2), ry -= (height / 2);
-        if (rx + width > DisplayWidth (Gdisplay, Gscreenn))
-            rx = DisplayWidth (Gdisplay, Gscreenn) - width;
-        if (ry + height > DisplayHeight (Gdisplay, Gscreenn))
-            ry = DisplayHeight (Gdisplay, Gscreenn) - height;
-        if (rx < 0)
-            rx = 0;
-        if (ry < 0)
-            ry = 0;
-        RESETARGS;
-        ADD2ARGS (XtNx, rx);
-        ADD2ARGS (XtNy, ry);
-        XtSetValues (widget->w, argp, argn);
-        WQU->state = 2;
-        WQU->button = 0;
-        XtPopup (widget->w, XtGrabExclusive);
-        while (WQU->state) {
-            if (WQU->state == 1) {
-                if (WQU->button != 1) {
-                    strncpy (
-                        responsep, XawDialogGetValueString (WQU->w), responsen
-                    );
-                }
-                XtPopdown (widget->w);
-            }
-            Gprocessevents (TRUE, G_ONEEVENT);
-        }
-        XtUnrealizeWidget (widget->w);
-        Gpopdownflag = TRUE;
-        if (WQU->button == 1)
-            return -1;
-        break;
-    case G_QWFILE:
-        if (!XsraSelFile (
-            Groot, prompt, "OK", "Cancel", "FAIL",
-            (args ? args : "/"), "r", NULL, responsep, responsen
-        )) {
-            Gpopdownflag = TRUE;
-            return -1;
-        }
-        Gpopdownflag = TRUE;
-        break;
-    case G_QWCHOICE:
-        if (!args)
-            return -1;
-        RESETARGS;
-        ADD2ARGS (XtNlabel, prompt);
-        XtSetValues (WQU->w, argp, argn);
-        for (s1 = args, i = 1; *s1; i++) {
-            s2 = s1;
-            while (*s2 && *s2 != '|')
-                s2++;
-            c = *s2, *s2 = 0;
-            strcpy (buttons[i], s1);
-            widgets[i] = XtCreateManagedWidget (
-                s1, commandWidgetClass, WQU->w, NULL, 0
-            );
-            XtAddCallback (widgets[i], XtNcallback, qbwcallback, (XtPointer) i);
-            *s2 = c;
-            s1 = s2;
-            if (*s1)
-                s1++;
-        }
-        XtRealizeWidget (widget->w);
-        XSetWMProtocols (Gdisplay, XtWindow (widget->w), &Gqwdelatom, 1);
-        XQueryPointer (
-            Gdisplay, XtWindow (widget->w),
-            &rwin, &cwin, &rx, &ry, &x, &y, &mask
-        );
-        RESETARGS;
-        ADD2ARGS (XtNwidth, &width);
-        ADD2ARGS (XtNheight, &height);
-        XtGetValues (widget->w, argp, argn);
-        rx -= (width / 2), ry -= (height / 2);
-        if (rx + width > DisplayWidth (Gdisplay, Gscreenn))
-            rx = DisplayWidth (Gdisplay, Gscreenn) - width;
-        if (ry + height > DisplayHeight (Gdisplay, Gscreenn))
-            ry = DisplayHeight (Gdisplay, Gscreenn) - height;
-        if (rx < 0)
-            rx = 0;
-        if (ry < 0)
-            ry = 0;
-        RESETARGS;
-        ADD2ARGS (XtNx, rx);
-        ADD2ARGS (XtNy, ry);
-        XtSetValues (widget->w, argp, argn);
-        WQU->state = 2;
-        WQU->button = 0;
-        XtPopup (widget->w, XtGrabExclusive);
-        while (WQU->state) {
-            if (WQU->state == 1) {
-                if (WQU->button > 0)
-                    strncpy (responsep, buttons[WQU->button], responsen);
-                XtPopdown (widget->w);
-            }
-            Gprocessevents (TRUE, G_ONEEVENT);
-        }
-        XtUnrealizeWidget (widget->w);
-        for (i--; i > 0; i--)
-            XtDestroyWidget (widgets[i]);
-        Gpopdownflag = TRUE;
-        break;
-    }
-    if (responsep[0] && responsep[strlen(responsep) - 1] == '\n')
-        responsep[strlen(responsep) - 1] = 0;
-    return 0;
-}
-
-void Gqwpopaction (Widget w, XEvent *evp, char **app, unsigned int *anp) {
-    Gwidget_t *widget;
-    char c = 0;
-
-    if (evp->type == KeyPress || evp->type == KeyRelease)
-        XLookupString ((XKeyEvent *) evp, &c, 1, NULL, NULL);
-    if (c != 13)
-        return;
-    widget = findwidget (
-        (unsigned long) XtParent (XtParent (w)), G_QUERYWIDGET
-    );
-    WQU->state = 1;
-}
-
-void Gqwdelaction (Widget w, XEvent *evp, char **app, unsigned int *anp) {
-    Gwidget_t *widget;
-
-    widget = findwidget ((unsigned long) w, G_QUERYWIDGET);
-    WQU->state = 1;
-}
-
-static void qwcallback (Widget w, XtPointer clientdata, XtPointer calldata) {
-    Gwidget_t *widget;
-
-    widget = findwidget ((unsigned long) w, G_QUERYWIDGET);
-    WQU->state = 0;
-}
-
-static void qbwcallback (Widget w, XtPointer clientdata, XtPointer calldata) {
-    Gwidget_t *widget;
-
-    widget = findwidget (
-        (unsigned long) XtParent (XtParent (w)), G_QUERYWIDGET
-    );
-    WQU->button = (long) clientdata;
-    WQU->state = 1;
-}
diff --git a/cmd/lefty/ws/x11/gscroll.c b/cmd/lefty/ws/x11/gscroll.c
deleted file mode 100644 (file)
index 3c36be0..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-int GScreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-#if XlibSpecificationRelease < 5
-    Widget w;
-#endif
-    int ai;
-    XColor c;
-    int color;
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    ps.x = ps.y = MINSWSIZE;
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINSWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRCHILDCENTER:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "childcenter");
-            return -1;
-        case G_ATTRMODE:
-            if (strcmp ("forcebars", attrp[ai].u.t) == 0)
-                ADD2ARGS (XtNforceBars, True);
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    ADD2ARGS (XtNallowHoriz, True);
-    ADD2ARGS (XtNallowVert, True);
-    ADD2ARGS (XtNwidth, ps.x);
-    ADD2ARGS (XtNheight, ps.y);
-    if (!(widget->w = XtCreateWidget (
-        "scroll", viewportWidgetClass, parent->w, argp, argn
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-#if XlibSpecificationRelease < 5
-    RESETARGS;
-    ADD2ARGS (XtNwidth, ps.x);
-    ADD2ARGS (XtNheight, ps.y);
-    if (!(w = XtCreateWidget (
-        "owsucks", formWidgetClass, widget->w, argp, argn
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    Glazymanage (w);
-    Glazymanage (widget->w);
-    XtDestroyWidget (w);
-#else
-    Glazymanage (widget->w);
-#endif
-    return 0;
-}
-
-int GSsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PIXpoint_t po;
-    PIXsize_t ps;
-    Dimension width, height;
-    int ai;
-    XColor c;
-    int color;
-
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINSWSIZE);
-            ADD2ARGS (XtNwidth, ps.x);
-            ADD2ARGS (XtNheight, ps.y);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRCHILDCENTER:
-            GETORIGIN (attrp[ai].u.p, po);
-            ADD2ARGS (XtNwidth, &width);
-            ADD2ARGS (XtNheight, &height);
-            XtGetValues (widget->w, argp, argn);
-            po.x -= width / 2, po.y -= height / 2;
-            if (po.x < 0)
-                po.x = 0;
-            if (po.y < 0)
-                po.y = 0;
-            XawViewportSetCoordinates (widget->w, po.x, po.y);
-            break;
-        case G_ATTRMODE:
-            if (strcmp ("forcebars", attrp[ai].u.t) == 0)
-                ADD2ARGS (XtNforceBars, True);
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    XtSetValues (widget->w, argp, argn);
-    return 0;
-}
-
-int GSgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Dimension width, height;
-    Position x, y;
-    Boolean tf;
-    Gwidget_t *child;
-    int ai, wi;
-
-    child = NULL;
-    for (ai = 0; ai < attrn; ai++) {
-        RESETARGS;
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            ADD2ARGS (XtNwidth, &width);
-            ADD2ARGS (XtNheight, &height);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, &width);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.i = width;
-            break;
-        case G_ATTRCHILDCENTER:
-            for (wi = 0; wi < Gwidgetn; wi++) {
-                child = &Gwidgets[wi];
-                if (child->inuse && child->pwi == widget - &Gwidgets[0])
-                    break;
-            }
-            if (wi == Gwidgetn) {
-                Gerr (POS, G_ERRNOCHILDWIDGET);
-                return -1;
-            }
-            ADD2ARGS (XtNwidth, &width);
-            ADD2ARGS (XtNheight, &height);
-            XtGetValues (widget->w, argp, argn);
-            RESETARGS;
-            ADD2ARGS (XtNx, &x);
-            ADD2ARGS (XtNy, &y);
-            XtGetValues (child->w, argp, argn);
-            attrp[ai].u.p.x = width / 2 - x, attrp[ai].u.p.y = height / 2 - y;
-            break;
-        case G_ATTRMODE:
-            ADD2ARGS (XtNforceBars, &tf);
-            attrp[ai].u.t = (tf == True) ? "forcebars" : "";
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GSdestroywidget (Gwidget_t *widget) {
-    XtDestroyWidget (widget->w);
-    return 0;
-}
-
-#if XlibSpecificationRelease < 5
-#include <X11/IntrinsicP.h>
-#include <X11/Xaw/ViewportP.h>
-
-void XawViewportSetCoordinates (Widget gw, Position x, Position y) {
-    ViewportWidget w = (ViewportWidget) gw;
-    Widget child = w->viewport.child;
-    Widget clip = w->viewport.clip;
-    Position mx, my;
-
-    if (x > (int) child->core.width)
-        x = child->core.width;
-    else if (x < 0)
-        x = child->core.x;
-
-    if (y > (int) child->core.height)
-        y = child->core.height;
-    else if (y < 0)
-        y = child->core.y;
-
-    mx = -x, my = -y;
-
-    if (- mx + (int) clip->core.width > (int) child->core.width)
-        mx = - (child->core.width - clip->core.width);
-
-    if (- my + (int) clip->core.height > (int) child->core.height)
-        my = - (child->core.height - clip->core.height);
-
-    /* make sure we never move past left/top borders */
-    if (mx >= 0) mx = 0;
-    if (my >= 0) my = 0;
-
-    XtMoveWidget (child, mx, my);
-    XtUnmanageChild (child);
-    XtManageChild (child);
-}
-#endif
diff --git a/cmd/lefty/ws/x11/gtext.c b/cmd/lefty/ws/x11/gtext.c
deleted file mode 100644 (file)
index 6961437..0000000
+++ /dev/null
@@ -1,313 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-#include "mem.h"
-
-#define WTU widget->u.t
-
-int GTcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXsize_t ps;
-    char *s;
-    int ai;
-    XColor c;
-    int color;
-
-    static XawTextSelectType sarray[] = {
-        XawselectLine, XawselectNull
-    };
-
-    if (!parent) {
-        Gerr (POS, G_ERRNOPARENTWIDGET);
-        return -1;
-    }
-    WTU->func = NULL;
-    ps.x = ps.y = MINTWSIZE;
-    s = "oneline";
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINTWSIZE);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRTEXT:
-            ADD2ARGS (XtNstring, attrp[ai].u.t);
-            break;
-        case G_ATTRAPPENDTEXT:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "appendtext");
-            return -1;
-        case G_ATTRMODE:
-            s = attrp[ai].u.t;
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTRNEWLINECB:
-            WTU->func = (Gtwnewlinecb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    ADD2ARGS (XtNwidth, ps.x);
-    ADD2ARGS (XtNheight, ps.y);
-    if (strcmp ("oneline", s) == 0)
-        ADD2ARGS (XtNeditType, XawtextAppend);
-    else if (strcmp ("input", s) == 0 || strcmp ("select", s) == 0)
-        ADD2ARGS (XtNeditType, XawtextEdit);
-    else if (strcmp ("output", s) == 0)
-        ADD2ARGS (XtNeditType, XawtextRead);
-    else {
-        Gerr (POS, G_ERRBADATTRVALUE, s);
-        return -1;
-    }
-    ADD2ARGS (XtNscrollHorizontal, XawtextScrollWhenNeeded);
-    ADD2ARGS (XtNscrollVertical, XawtextScrollWhenNeeded);
-    if (!(widget->w = XtCreateWidget (
-        "ascii", asciiTextWidgetClass, parent->w, argp, argn
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    if (strcmp ("oneline", s) == 0 || strcmp ("input", s) == 0)
-        XtOverrideTranslations (widget->w, Gtweoltable);
-    else if (strcmp ("select", s) == 0)
-        XawTextSetSelectionArray (widget->w, sarray);
-    Glazymanage (widget->w);
-    return 0;
-}
-
-int GTsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PIXsize_t ps;
-    XawTextBlock tb;
-    int ai, li;
-    XColor c;
-    int color;
-
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINTWSIZE);
-            ADD2ARGS (XtNwidth, ps.x);
-            ADD2ARGS (XtNheight, ps.y);
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, attrp[ai].u.i);
-            break;
-        case G_ATTRTEXT:
-            ADD2ARGS (XtNstring, attrp[ai].u.t);
-            break;
-        case G_ATTRAPPENDTEXT:
-            XawTextSetInsertionPoint (widget->w, 327670000);
-            li = XawTextGetInsertionPoint (widget->w);
-            tb.firstPos = 0, tb.length = strlen (attrp[ai].u.t);
-            tb.ptr = attrp[ai].u.t, tb.format = FMT8BIT;
-            XawTextReplace (widget->w, li, li, &tb);
-            li = XawTextGetInsertionPoint (widget->w);
-            tb.firstPos = 0, tb.length = 1;
-            tb.ptr = "\n", tb.format = FMT8BIT;
-            XawTextReplace (widget->w, li, li, &tb);
-            break;
-        case G_ATTRMODE:
-            if (strcmp ("oneline", attrp[ai].u.t) == 0)
-                ADD2ARGS (XtNeditType, XawtextAppend);
-            else if (strcmp ("input", attrp[ai].u.t) == 0)
-                ADD2ARGS (XtNeditType, XawtextEdit);
-            else if (strcmp ("output", attrp[ai].u.t) == 0)
-                ADD2ARGS (XtNeditType, XawtextRead);
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTRNEWLINECB:
-            WTU->func = (Gtwnewlinecb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    XtSetValues (widget->w, argp, argn);
-    return 0;
-}
-
-int GTgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Dimension width, height;
-    XawTextEditType mode;
-    XawTextBlock tb;
-    Widget w;
-    int rtn, ai;
-    long fi, li;
-
-    for (ai = 0; ai < attrn; ai++) {
-        RESETARGS;
-        switch (attrp[ai].id) {
-        case G_ATTRSIZE:
-            ADD2ARGS (XtNwidth, &width);
-            ADD2ARGS (XtNheight, &height);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-            break;
-        case G_ATTRBORDERWIDTH:
-            ADD2ARGS (XtNborderWidth, &width);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.i = width;
-            break;
-        case G_ATTRTEXT:
-            w = XawTextGetSource (widget->w);
-            tb.firstPos = 0, tb.ptr = NULL, tb.format = FMT8BIT, tb.length = 0;
-            rtn = XawTextSourceRead (w, 0, &tb, 30000);
-            if (rtn > Gbufn + 1) {
-                Gbufp = Marraygrow (Gbufp, (long) (rtn + 1) * BUFSIZE);
-                Gbufn = rtn + 1;
-            }
-            for (Gbufi = 0; Gbufi < rtn; Gbufi++)
-                Gbufp[Gbufi] = tb.ptr[Gbufi];
-            Gbufp[Gbufi++] = '\000';
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRAPPENDTEXT:
-            Gerr (POS, G_ERRCANNOTGETATTR, "appendtext");
-            return -1;
-        case G_ATTRSELECTION:
-            w = XawTextGetSource (widget->w);
-            XawTextGetSelectionPos (widget->w, &fi, &li);
-            tb.firstPos = 0, tb.ptr = NULL, tb.format = FMT8BIT, tb.length = 0;
-            rtn = XawTextSourceRead (w, fi, &tb, li - fi);
-            if (li - fi > Gbufn + 1) {
-                Gbufp = Marraygrow (Gbufp, (long) (rtn + 1) * BUFSIZE);
-                Gbufn = rtn + 1;
-            }
-            for (Gbufi = 0; Gbufi < li - fi; Gbufi++)
-                Gbufp[Gbufi] = tb.ptr[Gbufi];
-            Gbufp[Gbufi++] = '\000';
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRMODE:
-            ADD2ARGS (XtNeditType, &mode);
-            XtGetValues (widget->w, argp, argn);
-            if (mode == XawtextAppend)
-                attrp[ai].u.t = "oneline";
-            else if (mode == XawtextEdit)
-                attrp[ai].u.t = "input";
-            else if (mode == XawtextRead)
-                attrp[ai].u.t = "output";
-            else {
-                panic1 (POS, "GTgetwidgetattr", "unexpected text mode");
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTRNEWLINECB:
-            attrp[ai].u.func = WTU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GTdestroywidget (Gwidget_t *widget) {
-    XtDestroyWidget (widget->w);
-    return 0;
-}
-
-/* used for one line text input widgets */
-void Gtweolaction (Widget w, XEvent *evp, char **app, unsigned int *anp) {
-    Gwidget_t *widget;
-    Widget ww;
-    XawTextBlock tb;
-    int ret, fi, li, n, i;
-
-    widget = findwidget ((unsigned long) w, G_TEXTWIDGET);
-    li = XawTextGetInsertionPoint (w) - 1;
-    ww = XawTextGetSource (w);
-    tb.firstPos = 0, tb.ptr = "\n", tb.format = FMT8BIT, tb.length = 1;
-    fi = XawTextSourceSearch (ww, li, XawsdLeft, &tb);
-    if (fi == XawTextSearchError)
-        fi = 0;
-    else
-        fi++;
-    n = li - fi;
-    Gbufp[(Gbufi = 0)] = '\000';
-    while (Gbufi != n) {
-        ret = XawTextSourceRead (ww, fi, &tb, n - Gbufi) - fi;
-        for (i = 0; i < ret; i++)
-            Gbufp[Gbufi++] = tb.ptr[i];
-    }
-    Gbufp[Gbufi] = '\000';
-    if (n >= 0 && WTU->func)
-        (*WTU->func) (widget - &Gwidgets[0], Gbufp);
-}
diff --git a/cmd/lefty/ws/x11/gview.c b/cmd/lefty/ws/x11/gview.c
deleted file mode 100644 (file)
index acec823..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Labs Research */
-
-#include <cgraph/exit.h>
-#include "common.h"
-#include "g.h"
-#include "gcommon.h"
-
-#define WVU widget->u.v
-
-int GVcreatewidget (
-    Gwidget_t *parent, Gwidget_t *widget, int attrn, Gwattr_t *attrp
-) {
-    PIXpoint_t po;
-    PIXsize_t ps;
-    XSizeHints hints;
-    char *s;
-    int haveorigin, ai;
-    XColor c;
-    int color;
-
-    WVU->func = NULL;
-    WVU->closing = FALSE;
-    s = "LEFTY";
-    ps.x = ps.y = MINVWSIZE;
-    po.x = po.y = 0;
-    haveorigin = FALSE;
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            haveorigin = TRUE;
-            GETORIGIN (attrp[ai].u.p, po);
-            ADD2ARGS (XtNx, po.x);
-            ADD2ARGS (XtNy, po.y);
-            break;
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
-            break;
-        case G_ATTRNAME:
-            s = attrp[ai].u.t;
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRZORDER:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "zorder");
-            return -1;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR1, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WVU->func = (Gviewcb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    ADD2ARGS (XtNwidth, ps.x);
-    ADD2ARGS (XtNheight, ps.y);
-    if (!(widget->w = XtAppCreateShell (
-        s, "LEFTY", topLevelShellWidgetClass, Gdisplay, argp, argn
-    ))) {
-        Gerr (POS, G_ERRCANNOTCREATEWIDGET);
-        return -1;
-    }
-    if (haveorigin) {
-        hints.x = po.x, hints.y = po.y;
-        hints.width = ps.x, hints.height = ps.y;
-        hints.flags = USPosition;
-        Glazyrealize (widget->w, TRUE, &hints);
-    } else
-        Glazyrealize (widget->w, FALSE, NULL);
-    return 0;
-}
-
-int GVsetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    PIXpoint_t po;
-    PIXsize_t ps;
-    int ai;
-    XColor c;
-    int color;
-
-    RESETARGS;
-    for (ai = 0; ai < attrn; ai++) {
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            GETORIGIN (attrp[ai].u.p, po);
-            ADD2ARGS (XtNx, po.x);
-            ADD2ARGS (XtNy, po.y);
-            break;
-        case G_ATTRSIZE:
-            GETSIZE (attrp[ai].u.s, ps, MINVWSIZE);
-            ADD2ARGS (XtNwidth, ps.x);
-            ADD2ARGS (XtNheight, ps.y);
-            break;
-        case G_ATTRNAME:
-#if XlibSpecificationRelease < 5
-            return -1;
-#else
-            XmbSetWMProperties (
-                Gdisplay, XtWindow (widget->w),
-                attrp[ai].u.t, attrp[ai].u.t, NULL, 0, NULL, NULL, NULL
-            );
-#endif
-            break;
-        case G_ATTRCOLOR:
-            color = attrp[ai].u.c.index;
-            if (color != 0 && color != 1) {
-                Gerr (POS, G_ERRBADCOLORINDEX, color);
-                return -1;
-            }
-            c.red = attrp[ai].u.c.r * 257;
-            c.green = attrp[ai].u.c.g * 257;
-            c.blue = attrp[ai].u.c.b * 257;
-            if (XAllocColor (
-                Gdisplay, DefaultColormap (Gdisplay, Gscreenn), &c
-            )) {
-                if (color == 0)
-                    ADD2ARGS (XtNbackground, c.pixel);
-                else
-                    ADD2ARGS (XtNforeground, c.pixel);
-           }
-            break;
-        case G_ATTRZORDER:
-            Gflushlazyq ();
-            if (strcmp (attrp[ai].u.t, "top") == 0)
-                XRaiseWindow (Gdisplay, XtWindow (widget->w));
-            else if (strcmp (attrp[ai].u.t, "bottom") == 0)
-                XLowerWindow (Gdisplay, XtWindow (widget->w));
-            else {
-                Gerr (POS, G_ERRBADATTRVALUE, attrp[ai].u.t);
-                return -1;
-            }
-            break;
-        case G_ATTRWINDOWID:
-            Gerr (POS, G_ERRCANNOTSETATTR2, "windowid");
-            return -1;
-        case G_ATTREVENTCB:
-            WVU->func = (Gviewcb) attrp[ai].u.func;
-            break;
-        case G_ATTRUSERDATA:
-            widget->udata = attrp[ai].u.u;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    XtSetValues (widget->w, argp, argn);
-    return 0;
-}
-
-int GVgetwidgetattr (Gwidget_t *widget, int attrn, Gwattr_t *attrp) {
-    Position x, y;
-    Dimension width, height;
-    int ai;
-
-    for (ai = 0; ai < attrn; ai++) {
-        RESETARGS;
-        switch (attrp[ai].id) {
-        case G_ATTRORIGIN:
-            ADD2ARGS (XtNx, &x);
-            ADD2ARGS (XtNy, &y);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.p.x = x, attrp[ai].u.p.y = y;
-            break;
-        case G_ATTRSIZE:
-            ADD2ARGS (XtNwidth, &width);
-            ADD2ARGS (XtNheight, &height);
-            XtGetValues (widget->w, argp, argn);
-            attrp[ai].u.s.x = width, attrp[ai].u.s.y = height;
-            break;
-        case G_ATTRNAME:
-            Gerr (POS, G_ERRNOTIMPLEMENTED);
-            return -1;
-        case G_ATTRZORDER:
-            Gerr (POS, G_ERRNOTIMPLEMENTED);
-            return -1;
-        case G_ATTRWINDOWID:
-            sprintf (&Gbufp[0], "0x%lx", XtWindow (widget->w));
-            attrp[ai].u.t = &Gbufp[0];
-            break;
-        case G_ATTREVENTCB:
-            attrp[ai].u.func = WVU->func;
-            break;
-        case G_ATTRUSERDATA:
-            attrp[ai].u.u = widget->udata;
-            break;
-        default:
-            Gerr (POS, G_ERRBADATTRID, attrp[ai].id);
-            return -1;
-        }
-    }
-    return 0;
-}
-
-int GVdestroywidget (Gwidget_t *widget) {
-    WVU->closing = TRUE;
-    XtDestroyWidget (widget->w);
-    return 0;
-}
-
-void Gwmdelaction (Widget w, XEvent *evp, char **app, unsigned int *anp) {
-    Gwidget_t *widget;
-    Gevent_t gev;
-
-    widget = findwidget ((unsigned long) w, G_VIEWWIDGET);
-    if (!widget)
-        graphviz_exit(0);
-    gev.type = 0, gev.code = 0, gev.data = 0;
-    gev.wi = widget - &Gwidgets[0];
-    if (WVU->func)
-        (*WVU->func) (&gev);
-    else
-        graphviz_exit(0);
-}
diff --git a/cmd/lefty/ws/x11/libfilereq/Dir.c b/cmd/lefty/ws/x11/libfilereq/Dir.c
deleted file mode 100644 (file)
index db75d85..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#ifdef FEATURE_CS
-#include <ast.h>
-#endif
-/*
- * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Software Research Associates not be used
- * in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission.  Software Research Associates
- * makes no representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- *
- * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Erik M. van der Poel
- *         Software Research Associates, Inc., Tokyo, Japan
- *         erik@sra.co.jp
- */
-
-#include "config.h"
-#include <stdio.h>
-#include <string.h>
-#include <strings.h>
-
-#include "SFinternal.h"
-
-#include <dirent.h>
-
-#include <sys/stat.h>
-
-#include <stdlib.h>
-
-#include "SFDecls.h"
-
-int SFcompareEntries (const void *vp, const void *vq) {
-    const SFEntry *p = vp, *q = vq;
-#ifdef SEL_FILE_IGNORE_CASE
-    return strcasecmp(p->real, q->real);
-#else /* def SEL_FILE_IGNORE_CASE */
-    return strcmp (p->real, q->real);
-#endif /* def SEL_FILE_IGNORE_CASE */
-}
-
-int SFgetDir (SFDir *dir) {
-    SFEntry       *result = NULL;
-    int           alloc = 0;
-    int           i;
-    DIR           *dirp;
-    struct dirent *dp;
-    char          *str;
-    int           len;
-    int           maxChars;
-    struct stat   statBuf;
-
-    maxChars = strlen (dir->dir) - 1;
-    dir->entries = NULL;
-    dir->nEntries = 0;
-    dir->nChars = 0;
-    result = NULL;
-    i = 0;
-    dirp = opendir (".");
-    if (!dirp) {
-        return 1;
-    }
-    stat (".", &statBuf);
-    dir->mtime = statBuf.st_mtime;
-    readdir (dirp);    /* throw away "." */
-
-#ifndef S_IFLNK
-    readdir (dirp);    /* throw away ".." */
-#endif /* ndef S_IFLNK */
-
-    while ((dp = readdir (dirp))) {
-        if (i >= alloc) {
-            alloc = 2 * (alloc + 1);
-            result = (SFEntry *) XtRealloc (
-                (char *) result, (unsigned) (alloc * sizeof (SFEntry))
-            );
-        }
-        result[i].statDone = 0;
-        str = dp->d_name;
-        len = strlen (str);
-        result[i].real = XtMalloc ((unsigned) (len + 2));
-        strcat (strcpy (result[i].real, str), " ");
-        if (len > maxChars) {
-            maxChars = len;
-        }
-        result[i].shown = result[i].real;
-        i++;
-    }
-
-    qsort(result, (size_t)i, sizeof(SFEntry), SFcompareEntries);
-
-    dir->entries = result;
-    dir->nEntries = i;
-    dir->nChars = maxChars + 1;
-    closedir (dirp);
-    return 0;
-}
diff --git a/cmd/lefty/ws/x11/libfilereq/Draw.c b/cmd/lefty/ws/x11/libfilereq/Draw.c
deleted file mode 100644 (file)
index add6e1f..0000000
+++ /dev/null
@@ -1,700 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#ifdef FEATURE_CS
-#include <ast.h>
-#endif
-/*
- * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Software Research Associates not be used
- * in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission.  Software Research Associates
- * makes no representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- *
- * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Erik M. van der Poel
- *         Software Research Associates, Inc., Tokyo, Japan
- *         erik@sra.co.jp
- */
-
-#include "config.h"
-#include <stddef.h>
-#include <stdio.h>
-#include <stdint.h>
-#include "SFinternal.h"
-#include "xstat.h"
-#include <X11/StringDefs.h>
-#include <X11/Xaw/Scrollbar.h>
-#include <X11/Xaw/Cardinals.h>
-
-#include "SFDecls.h"
-
-#define SF_DEFAULT_FONT "9x15"
-
-#ifdef ABS
-#undef ABS
-#endif
-#define ABS(x) (((x) < 0) ? (-(x)) : (x))
-
-typedef struct {
-    char *fontname;
-} TextData, *textPtr;
-
-int SFcharWidth, SFcharAscent, SFcharHeight;
-
-int SFcurrentInvert[3] = { -1, -1, -1 };
-
-static GC SFlineGC, SFscrollGC, SFinvertGC, SFtextGC;
-
-static XtResource textResources[] = {
-    {
-        XtNfont, XtCFont, XtRString, sizeof (char *),
-        XtOffset (textPtr, fontname), XtRString, SF_DEFAULT_FONT
-    },
-};
-
-static XFontStruct *SFfont;
-
-static int SFcurrentListY;
-
-static XtIntervalId SFscrollTimerId;
-
-void SFinitFont (void) {
-    TextData    *data;
-
-    data = XtNew (TextData);
-    XtGetApplicationResources (
-        selFileForm, (XtPointer) data, textResources,
-        XtNumber (textResources), NULL, ZERO
-    );
-
-    SFfont = XLoadQueryFont (SFdisplay, data->fontname);
-    if (!SFfont) {
-        SFfont = XLoadQueryFont (SFdisplay, SF_DEFAULT_FONT);
-        if (!SFfont) {
-            char sbuf[256];
-
-            sprintf (sbuf, "XsraSelFile: can't get font %s", SF_DEFAULT_FONT);
-            XtAppError (SFapp, sbuf);
-        }
-    }
-
-    SFcharWidth = (SFfont->max_bounds.width + SFfont->min_bounds.width) / 2;
-    SFcharAscent = SFfont->max_bounds.ascent;
-    SFcharHeight = SFcharAscent + SFfont->max_bounds.descent;
-}
-
-void SFcreateGC (void) {
-    XGCValues  gcValues;
-    XRectangle rectangles[1];
-
-    gcValues.foreground = SFfore;
-
-    SFlineGC = XtGetGC (selFileLists[0], GCForeground, &gcValues);
-    SFscrollGC = XtGetGC (selFileLists[0], 0, &gcValues);
-    gcValues.function = GXinvert;
-    gcValues.plane_mask = (SFfore ^ SFback);
-    SFinvertGC = XtGetGC (selFileLists[0], GCFunction | GCPlaneMask, &gcValues);
-    gcValues.foreground = SFfore;
-    gcValues.background = SFback;
-    gcValues.font = SFfont->fid;
-    SFtextGC = XCreateGC (
-        SFdisplay, XtWindow (selFileLists[0]),
-        GCForeground | GCBackground | GCFont, &gcValues
-    );
-    rectangles[0].x = SFlineToTextH + SFbesideText;
-    rectangles[0].y = 0;
-    rectangles[0].width = SFcharsPerEntry * SFcharWidth;
-    rectangles[0].height = SFupperY + 1;
-    XSetClipRectangles (SFdisplay, SFtextGC, 0, 0, rectangles, 1, Unsorted);
-}
-
-void SFclearList (int n, int doScroll) {
-    SFDir *dir;
-
-    SFcurrentInvert[n] = -1;
-    XClearWindow (SFdisplay, XtWindow (selFileLists[n]));
-    XDrawSegments (SFdisplay, XtWindow (selFileLists[n]), SFlineGC, SFsegs, 2);
-    if (doScroll) {
-        dir = &(SFdirs[SFdirPtr + n]);
-        if ((SFdirPtr + n < SFdirEnd) && dir->nEntries && dir->nChars) {
-            XawScrollbarSetThumb (
-                selFileVScrolls[n],
-                (float) (((double) dir->vOrigin) / dir->nEntries),
-                (float) (((double) ((
-                    dir->nEntries < SFlistSize
-                ) ? dir->nEntries : SFlistSize)) / dir->nEntries)
-            );
-            XawScrollbarSetThumb (
-                selFileHScrolls[n],
-                (float) (((double) dir->hOrigin) / dir->nChars),
-                (float) (((double) ((
-                    dir->nChars < SFcharsPerEntry
-                ) ? dir->nChars : SFcharsPerEntry)) / dir->nChars)
-            );
-        } else {
-            XawScrollbarSetThumb(selFileVScrolls[n], 0.0f, 1.0f);
-            XawScrollbarSetThumb(selFileHScrolls[n], 0.0f, 1.0f);
-        }
-    }
-}
-
-static void SFdeleteEntry (SFDir *dir, SFEntry *entry) {
-    SFEntry *e;
-    SFEntry *end;
-    int     n;
-    int    idx;
-
-    idx = entry - dir->entries;
-    if (idx < dir->beginSelection) {
-        dir->beginSelection--;
-    }
-    if (idx <= dir->endSelection) {
-        dir->endSelection--;
-    }
-    if (dir->beginSelection > dir->endSelection) {
-        dir->beginSelection = dir->endSelection = -1;
-    }
-    if (idx < dir->vOrigin) {
-        dir->vOrigin--;
-    }
-    XtFree (entry->real);
-    end = & (dir->entries[dir->nEntries - 1]);
-    for (e = entry; e < end; e++) {
-        *e = * (e + 1);
-    }
-    if (! (--dir->nEntries)) {
-        return;
-    }
-
-    n = dir - & (SFdirs[SFdirPtr]);
-    if ((n < 0) || (n > 2)) {
-        return;
-    }
-
-    XawScrollbarSetThumb (
-        selFileVScrolls[n],
-        (float) (((double) dir->vOrigin) / dir->nEntries),
-        (float) (((double) ((
-            dir->nEntries < SFlistSize
-        ) ? dir->nEntries : SFlistSize)) / dir->nEntries)
-    );
-}
-
-static void SFwriteStatChar(char *name, size_t last, struct stat *statBuf) {
-    name[last] = SFstatChar (statBuf);
-}
-
-static int SFstatAndCheck (SFDir *dir, SFEntry *entry) {
-    struct stat statBuf;
-    char        save;
-
-    /* must be restored before returning */
-    save = *(dir->path);
-    *(dir->path) = 0;
-
-    if (!SFchdir (SFcurrentPath)) {
-        size_t last = strlen(entry->real) - 1;
-        entry->real[last] = 0;
-        entry->statDone = 1;
-        if (
-            (!stat (entry->real, &statBuf))
-#ifdef S_IFLNK
-            || (!lstat (entry->real, &statBuf))
-#endif /* ndef S_IFLNK */
-        ) {
-            if (SFfunc) {
-                char *shown;
-
-                shown = NULL;
-                if (SFfunc (entry->real, &shown, &statBuf)) {
-                    if (shown) {
-                        size_t len = strlen(shown);
-                        entry->shown = XtMalloc ((unsigned) (len + 2));
-                        strcpy (entry->shown, shown);
-                        SFwriteStatChar (entry->shown, len, &statBuf);
-                        entry->shown[len + 1] = 0;
-                    }
-                } else {
-                    SFdeleteEntry (dir, entry);
-                    *(dir->path) = save;
-                    return 1;
-                }
-            }
-            SFwriteStatChar (entry->real, last, &statBuf);
-        } else {
-            entry->real[last] = ' ';
-        }
-    }
-    *(dir->path) = save;
-    return 0;
-}
-
-static void SFdrawStrings (Window w, SFDir *dir, int from, int to) {
-    int     i;
-    SFEntry *entry;
-    int     x;
-
-    x = SFtextX - dir->hOrigin * SFcharWidth;
-    if (dir->vOrigin + to >= dir->nEntries) {
-        to = dir->nEntries - dir->vOrigin - 1;
-    }
-    for (i = from; i <= to; i++) {
-        entry = & (dir->entries[dir->vOrigin + i]);
-        if (! (entry->statDone)) {
-            if (SFstatAndCheck (dir, entry)) {
-                if (dir->vOrigin + to >= dir->nEntries) {
-                    to = dir->nEntries - dir->vOrigin - 1;
-                }
-                i--;
-                continue;
-            }
-        }
-        XDrawImageString (
-            SFdisplay, w, SFtextGC, x, SFtextYoffset + i * SFentryHeight,
-            entry->shown, strlen (entry->shown)
-        );
-        if (dir->vOrigin + i == dir->beginSelection) {
-            XDrawLine (
-                SFdisplay, w, SFlineGC, SFlineToTextH + 1,
-                SFlowerY + i * SFentryHeight,
-                SFlineToTextH + SFentryWidth - 2,
-                SFlowerY + i * SFentryHeight
-            );
-        }
-        if (
-            (dir->vOrigin + i >= dir->beginSelection) &&
-            (dir->vOrigin + i <= dir->endSelection)
-        ) {
-            SFcompletionSegs[0].y1 = SFcompletionSegs[1].y1 = (
-                SFlowerY + i * SFentryHeight
-            );
-            SFcompletionSegs[0].y2 = SFcompletionSegs[1].y2 = (
-                SFlowerY + (i + 1) * SFentryHeight - 1
-            );
-            XDrawSegments (SFdisplay, w, SFlineGC, SFcompletionSegs, 2);
-        }
-        if (dir->vOrigin + i == dir->endSelection) {
-            XDrawLine (
-                SFdisplay, w, SFlineGC,
-                SFlineToTextH + 1,
-                SFlowerY + (i + 1) * SFentryHeight - 1,
-                SFlineToTextH + SFentryWidth - 2,
-                SFlowerY + (i + 1) * SFentryHeight - 1
-            );
-        }
-    }
-}
-
-void SFdrawList (int n, int doScroll) {
-    SFDir  *dir;
-    Window w;
-
-    SFclearList (n, doScroll);
-    if (SFdirPtr + n < SFdirEnd) {
-        dir = & (SFdirs[SFdirPtr + n]);
-        w = XtWindow (selFileLists[n]);
-        XDrawImageString (
-            SFdisplay, w, SFtextGC,
-            SFtextX - dir->hOrigin * SFcharWidth,
-            SFlineToTextV + SFaboveAndBelowText + SFcharAscent,
-            dir->dir, strlen (dir->dir)
-        );
-        SFdrawStrings (w, dir, 0, SFlistSize - 1);
-    }
-}
-
-void SFdrawLists (int doScroll) {
-    int i;
-
-    for (i = 0; i < 3; i++) {
-        SFdrawList (i, doScroll);
-    }
-}
-
-static void SFinvertEntry (int n) {
-    XFillRectangle (
-        SFdisplay, XtWindow (selFileLists[n]), SFinvertGC,
-        SFlineToTextH, SFcurrentInvert[n] * SFentryHeight + SFlowerY,
-        SFentryWidth, SFentryHeight
-    );
-}
-
-static unsigned long SFscrollTimerInterval (void) {
-    static int maxVal = 200;
-    static int varyDist = 50;
-    static int minDist = 50;
-    int        t;
-    int        dist;
-
-    if (SFcurrentListY < SFlowerY) {
-        dist = SFlowerY - SFcurrentListY;
-    } else if (SFcurrentListY > SFupperY) {
-        dist = SFcurrentListY - SFupperY;
-    } else {
-        return 1;
-    }
-    t = maxVal - ((maxVal / varyDist) * (dist - minDist));
-    if (t < 1) {
-        t = 1;
-    }
-    if (t > maxVal) {
-        t = maxVal;
-    }
-    return (unsigned long) t;
-}
-
-static void SFscrollTimer (XtPointer cd, XtIntervalId *id) {
-    SFDir *dir;
-    int   save;
-    intptr_t   n;
-
-    n = (intptr_t) cd;
-
-    dir = &(SFdirs[SFdirPtr + n]);
-    save = dir->vOrigin;
-    if (SFcurrentListY < SFlowerY) {
-        if (dir->vOrigin > 0) {
-            SFvSliderMovedCallback (
-                selFileVScrolls[n],
-                (XtPointer) n, (XtPointer) ((intptr_t)(dir->vOrigin) - 1)
-            );
-        }
-    } else if (SFcurrentListY > SFupperY) {
-        if (dir->vOrigin < dir->nEntries - SFlistSize) {
-            SFvSliderMovedCallback (
-                selFileVScrolls[n], (XtPointer) n,
-                (XtPointer) ((intptr_t)(dir->vOrigin) + 1)
-            );
-        }
-    }
-    if (dir->vOrigin != save) {
-        if (dir->nEntries) {
-            XawScrollbarSetThumb (
-                selFileVScrolls[n],
-                (float) (((double) dir->vOrigin) / dir->nEntries),
-                (float) (((double) ((
-                    dir->nEntries < SFlistSize
-                ) ? dir->nEntries : SFlistSize)) / dir->nEntries)
-            );
-        }
-    }
-    if (SFbuttonPressed) {
-        SFscrollTimerId = XtAppAddTimeOut (
-            SFapp, SFscrollTimerInterval (), SFscrollTimer, (XtPointer) n
-        );
-    }
-}
-
-static int SFnewInvertEntry (intptr_t n, XMotionEvent *event) {
-    int        x, y;
-    int        new;
-    static int SFscrollTimerAdded = 0;
-
-    x = event->x;
-    y = event->y;
-    if (SFdirPtr + n >= SFdirEnd) {
-        return -1;
-    } else if (
-        (x >= 0) && (x <= SFupperX) && (y >= SFlowerY) && (y <= SFupperY)
-    ) {
-        SFDir *dir = &(SFdirs[SFdirPtr + n]);
-
-        if (SFscrollTimerAdded) {
-            SFscrollTimerAdded = 0;
-            XtRemoveTimeOut (SFscrollTimerId);
-        }
-        new = (y - SFlowerY) / SFentryHeight;
-        if (dir->vOrigin + new >= dir->nEntries) {
-            return -1;
-        }
-        return new;
-    } else {
-        if (SFbuttonPressed) {
-            SFcurrentListY = y;
-            if (!SFscrollTimerAdded) {
-                SFscrollTimerAdded = 1;
-                SFscrollTimerId = XtAppAddTimeOut (
-                    SFapp, SFscrollTimerInterval (), SFscrollTimer,
-                    (XtPointer) n
-                );
-            }
-        }
-        return -1;
-    }
-}
-
-void SFenterList (Widget w, XtPointer cl, XEvent *ev, Boolean *b) {
-    int new;
-    intptr_t n;
-    XEnterWindowEvent *event;
-
-    n = (intptr_t) cl;
-    event = (XEnterWindowEvent *) ev;
-    /* sanity */
-    if (SFcurrentInvert[n] != -1) {
-        SFinvertEntry (n);
-        SFcurrentInvert[n] = -1;
-    }
-    new = SFnewInvertEntry (n, (XMotionEvent *) event);
-    if (new != -1) {
-        SFcurrentInvert[n] = new;
-        SFinvertEntry (n);
-    }
-}
-
-void SFleaveList (Widget w, XtPointer cl, XEvent *ev, Boolean *b) {
-    intptr_t n;
-
-    n = (intptr_t) cl;
-    if (SFcurrentInvert[n] != -1) {
-        SFinvertEntry (n);
-        SFcurrentInvert[n] = -1;
-    }
-}
-
-void SFmotionList (Widget w, XtPointer cl, XEvent *ev, Boolean *b) {
-    int new;
-    intptr_t n;
-    XMotionEvent *event;
-
-    n = (intptr_t) cl;
-    event = (XMotionEvent *) ev;
-    new = SFnewInvertEntry (n, event);
-    if (new != SFcurrentInvert[n]) {
-        if (SFcurrentInvert[n] != -1) {
-            SFinvertEntry (n);
-        }
-        SFcurrentInvert[n] = new;
-        if (new != -1) {
-            SFinvertEntry (n);
-        }
-    }
-}
-
-void SFvFloatSliderMovedCallback (Widget w, XtPointer cl, XtPointer cd) {
-    intptr_t n, new;
-    float *fnew;
-
-    n = (intptr_t) cl;
-    fnew = (float *) cd;
-    new = (*fnew) * SFdirs[SFdirPtr + n].nEntries;
-    SFvSliderMovedCallback (w, (XtPointer) n, (XtPointer) new);
-}
-
-void SFvSliderMovedCallback (Widget w, XtPointer cl, XtPointer cd) {
-    intptr_t    n, new, old;
-    Window win;
-    SFDir  *dir;
-
-    n = (intptr_t) cl;
-    new = (intptr_t) cd;
-    dir = &(SFdirs[SFdirPtr + n]);
-    old = dir->vOrigin;
-    dir->vOrigin = new;
-    if (old == new) {
-        return;
-    }
-
-    win = XtWindow (selFileLists[n]);
-    if (ABS (new - old) < SFlistSize) {
-        if (new > old) {
-            XCopyArea (
-                SFdisplay, win, win, SFscrollGC, SFlineToTextH,
-                SFlowerY + (new - old) * SFentryHeight,
-                SFentryWidth + SFlineToTextH,
-                (SFlistSize - (new - old)) * SFentryHeight,
-                SFlineToTextH, SFlowerY
-            );
-            XClearArea (
-                SFdisplay, win, SFlineToTextH,
-                SFlowerY + (SFlistSize - (new - old)) * SFentryHeight,
-                SFentryWidth + SFlineToTextH, (new - old) * SFentryHeight,
-                False
-            );
-            SFdrawStrings (win, dir, SFlistSize - (new - old), SFlistSize - 1);
-        } else {
-            XCopyArea (
-                SFdisplay, win, win, SFscrollGC, SFlineToTextH,
-                SFlowerY, SFentryWidth + SFlineToTextH,
-                (SFlistSize - (old - new)) * SFentryHeight, SFlineToTextH,
-                SFlowerY + (old - new) * SFentryHeight
-            );
-            XClearArea (
-                SFdisplay, win, SFlineToTextH, SFlowerY,
-                SFentryWidth + SFlineToTextH, (old - new) * SFentryHeight,
-                False
-            );
-            SFdrawStrings (win, dir, 0, old - new);
-        }
-    } else {
-        XClearArea (
-            SFdisplay, win, SFlineToTextH, SFlowerY,
-            SFentryWidth + SFlineToTextH, SFlistSize * SFentryHeight, False
-        );
-        SFdrawStrings (win, dir, 0, SFlistSize - 1);
-    }
-}
-
-void SFvAreaSelectedCallback (Widget w, XtPointer cl, XtPointer cd) {
-    SFDir *dir;
-    intptr_t   n, pnew, new;
-
-    n = (intptr_t) cl;
-    pnew = (intptr_t) cd;
-    dir = &(SFdirs[SFdirPtr + n]);
-    new = dir->vOrigin + (((double) pnew) / SFvScrollHeight) * dir->nEntries;
-    if (new > dir->nEntries - SFlistSize) {
-        new = dir->nEntries - SFlistSize;
-    }
-    if (new < 0) {
-        new = 0;
-    }
-    if (dir->nEntries) {
-        float f;
-
-        f = ((double) new) / dir->nEntries;
-        XawScrollbarSetThumb (
-            w, f,
-            (float) (((double) ((
-                dir->nEntries < SFlistSize
-            ) ? dir->nEntries : SFlistSize)) / dir->nEntries)
-        );
-    }
-    SFvSliderMovedCallback (w, (XtPointer) n, (XtPointer) new);
-}
-
-void SFhSliderMovedCallback (Widget w, XtPointer cl, XtPointer cd) {
-    SFDir *dir;
-    int   save;
-    float *new;
-    intptr_t   n;
-
-    n = (intptr_t) cl;
-    new = (float *) cd;
-    dir = &(SFdirs[SFdirPtr + n]);
-    save = dir->hOrigin;
-    dir->hOrigin = (*new) * dir->nChars;
-    if (dir->hOrigin == save) {
-        return;
-    }
-    SFdrawList (n, SF_DO_NOT_SCROLL);
-}
-
-void SFhAreaSelectedCallback (Widget w, XtPointer cl, XtPointer cd) {
-    SFDir *dir;
-    intptr_t   n, pnew, new;
-
-    n = (intptr_t) cl;
-    pnew = (intptr_t) cd;
-    dir = &(SFdirs[SFdirPtr + n]);
-    new = dir->hOrigin + (((double) pnew) / SFhScrollWidth) * dir->nChars;
-    if (new > dir->nChars - SFcharsPerEntry) {
-        new = dir->nChars - SFcharsPerEntry;
-    }
-    if (new < 0) {
-        new = 0;
-    }
-    if (dir->nChars) {
-        float f;
-        f = ((double) new) / dir->nChars;
-        XawScrollbarSetThumb (
-            w, f,
-            (float) (((double) ((
-                dir->nChars < SFcharsPerEntry
-            ) ? dir->nChars : SFcharsPerEntry)) / dir->nChars)
-        );
-        SFhSliderMovedCallback (w, (XtPointer) n, &f);
-    }
-}
-
-void SFpathSliderMovedCallback (Widget w, XtPointer cl, XtPointer cd) {
-    SFDir           *dir;
-    float           *new;
-    int             n;
-    XawTextPosition pos;
-    int             SFdirPtrSave;
-
-    new = (float *) cl;
-    SFdirPtrSave = SFdirPtr;
-    SFdirPtr = (*new) * SFdirEnd;
-    if (SFdirPtr == SFdirPtrSave) {
-        return;
-    }
-
-    SFdrawLists (SF_DO_SCROLL);
-    n = 2;
-    while (SFdirPtr + n >= SFdirEnd) {
-        n--;
-    }
-    dir = &(SFdirs[SFdirPtr + n]);
-    pos = dir->path - SFcurrentPath;
-    if (!strncmp (SFcurrentPath, SFstartDir, strlen (SFstartDir))) {
-        pos -= strlen (SFstartDir);
-        if (pos < 0) {
-            pos = 0;
-        }
-    }
-    XawTextSetInsertionPoint (selFileField, pos);
-}
-
-void SFpathAreaSelectedCallback (Widget w, XtPointer cl, XtPointer cd) {
-    intptr_t   pnew, new;
-    float f;
-
-    pnew = (intptr_t) cd;
-    new = SFdirPtr + (((double) pnew) / SFpathScrollWidth) * SFdirEnd;
-    if (new > SFdirEnd - 3) {
-        new = SFdirEnd - 3;
-    }
-    if (new < 0) {
-        new = 0;
-    }
-    f = ((double) new) / SFdirEnd;
-    XawScrollbarSetThumb (
-        w, f, (float) (((double) ((SFdirEnd < 3) ? SFdirEnd : 3)) / SFdirEnd)
-    );
-    SFpathSliderMovedCallback (w, (XtPointer) NULL, &f);
-}
-
-Boolean SFworkProc (XtPointer cl) {
-    SFDir   *dir;
-    SFEntry *entry;
-
-    for (dir = &(SFdirs[SFdirEnd - 1]); dir >= SFdirs; dir--) {
-        if (! (dir->nEntries)) {
-            continue;
-        }
-        for (
-            entry = & (dir->entries[dir->nEntries - 1]);
-            entry >= dir->entries; entry--
-        ) {
-            if (!(entry->statDone)) {
-                SFstatAndCheck (dir, entry);
-                return False;
-            }
-        }
-    }
-    SFworkProcAdded = 0;
-    return True;
-}
diff --git a/cmd/lefty/ws/x11/libfilereq/Path.c b/cmd/lefty/ws/x11/libfilereq/Path.c
deleted file mode 100644 (file)
index d19c8cc..0000000
+++ /dev/null
@@ -1,726 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#ifdef FEATURE_CS
-#include <ast.h>
-#endif
-/*
- * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Software Research Associates not be used
- * in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission.  Software Research Associates
- * makes no representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- *
- * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Erik M. van der Poel
- *         Software Research Associates, Inc., Tokyo, Japan
- *         erik@sra.co.jp
- */
-
-#include "config.h"
-#include <stdio.h>
-
-#include <X11/Xos.h>
-#include <pwd.h>
-#include "SFinternal.h"
-#include "xstat.h"
-#include <X11/Xaw/Scrollbar.h>
-
-#if defined (SVR4) || defined (SYSV) || defined (USG)
-extern uid_t getuid ();
-#endif /* defined (SVR4) || defined (SYSV) || defined (USG) */
-
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-
-#include "SFDecls.h"
-
-#include <stdint.h>
-
-typedef struct {
-    char *name;
-    char *dir;
-} SFLogin;
-
-SFDir *SFdirs = NULL;
-
-int SFdirEnd;
-
-int SFdirPtr;
-
-int SFbuttonPressed = 0;
-
-static int SFdoNotTouchDirPtr = 0;
-
-static int SFdoNotTouchVorigin = 0;
-
-static SFDir SFrootDir, SFhomeDir;
-
-static SFLogin *SFlogins;
-
-static int SFtwiddle = 0;
-
-void SFsetText (char *path);
-
-int SFchdir (char *path) {
-    int result;
-
-    result = 0;
-    if (strcmp (path, SFcurrentDir)) {
-        result = chdir (path);
-        if (!result) {
-            strcpy (SFcurrentDir, path);
-        }
-    }
-    return result;
-}
-
-static void SFfree (int i) {
-    SFDir *dir;
-    int   j;
-
-    dir = &(SFdirs[i]);
-    for (j = dir->nEntries - 1; j >= 0; j--) {
-        if (dir->entries[j].shown != dir->entries[j].real) {
-            XtFree (dir->entries[j].shown);
-        }
-        XtFree (dir->entries[j].real);
-    }
-    XtFree ((char *) dir->entries);
-    XtFree (dir->dir);
-    dir->dir = NULL;
-}
-
-static void SFstrdup (char **s1, char *s2) {
-    *s1 = strcpy (XtMalloc ((unsigned) (strlen (s2) + 1)), s2);
-}
-
-static void SFunreadableDir (SFDir *dir) {
-    char *cannotOpen = "<cannot open> ";
-
-    dir->entries = (SFEntry *) XtMalloc (sizeof (SFEntry));
-    dir->entries[0].statDone = 1;
-    SFstrdup (&dir->entries[0].real, cannotOpen);
-    dir->entries[0].shown = dir->entries[0].real;
-    dir->nEntries = 1;
-    dir->nChars = strlen (cannotOpen);
-}
-
-static void SFreplaceText (SFDir *dir, char *str) {
-    int len;
-
-    *(dir->path) = 0;
-    len = strlen (str);
-    if (str[len - 1] == '/') {
-        strcat (SFcurrentPath, str);
-    } else {
-        strncat (SFcurrentPath, str, len - 1);
-    }
-    if (strncmp (SFcurrentPath, SFstartDir, strlen (SFstartDir))) {
-        SFsetText (SFcurrentPath);
-    } else {
-        SFsetText (& (SFcurrentPath[strlen (SFstartDir)]));
-    }
-    SFtextChanged ();
-}
-
-static void SFexpand (char *str) {
-    int     len;
-    int     cmp;
-    char    *name, *growing;
-    SFDir   *dir;
-    SFEntry *entry, *max;
-
-    len = strlen (str);
-    dir = &(SFdirs[SFdirEnd - 1]);
-    if (dir->beginSelection == -1) {
-        SFstrdup (&str, str);
-        SFreplaceText (dir, str);
-        XtFree (str);
-        return;
-    } else if (dir->beginSelection == dir->endSelection) {
-        SFreplaceText (dir, dir->entries[dir->beginSelection].shown);
-        return;
-    }
-    max = &(dir->entries[dir->endSelection + 1]);
-    name = dir->entries[dir->beginSelection].shown;
-    SFstrdup (&growing, name);
-    cmp = 0;
-    while (!cmp) {
-        entry = & (dir->entries[dir->beginSelection]);
-        while (entry < max) {
-            if ((cmp = strncmp (growing, entry->shown, len))) {
-                break;
-            }
-            entry++;
-        }
-        len++;
-    }
-
-    /* SFreplaceText () expects filename */
-    growing[len - 2] = ' ';
-    growing[len - 1] = 0;
-    SFreplaceText (dir, growing);
-    XtFree (growing);
-}
-
-static int SFfindFile (SFDir *dir, char *str) {
-    int     i, last, max;
-    char    *name, save;
-    SFEntry *entries;
-    int     len;
-    int     begin, end;
-    int     result;
-
-    len = strlen (str);
-    if (str[len - 1] == ' ') {
-        SFexpand (str);
-        return 1;
-    } else if (str[len - 1] == '/') {
-        len--;
-    }
-    max = dir->nEntries;
-    entries = dir->entries;
-    i = 0;
-    while (i < max) {
-        name = entries[i].shown;
-        last = strlen (name) - 1;
-        save = name[last];
-        name[last] = 0;
-
-#ifdef SEL_FILE_IGNORE_CASE
-        result = strncasecmp(str, name, len);
-#else /* def SEL_FILE_IGNORE_CASE */
-        result = strncmp (str, name, len);
-#endif /* def SEL_FILE_IGNORE_CASE */
-
-        name[last] = save;
-        if (result <= 0) {
-            break;
-        }
-        i++;
-    }
-    begin = i;
-    while (i < max) {
-        name = entries[i].shown;
-        last = strlen (name) - 1;
-        save = name[last];
-        name[last] = 0;
-
-#ifdef SEL_FILE_IGNORE_CASE
-        result = strncasecmp(str, name, len);
-#else /* def SEL_FILE_IGNORE_CASE */
-        result = strncmp (str, name, len);
-#endif /* def SEL_FILE_IGNORE_CASE */
-
-        name[last] = save;
-        if (result) {
-            break;
-        }
-        i++;
-    }
-    end = i;
-
-    if (begin != end) {
-        if ((dir->beginSelection != begin) || (dir->endSelection != end - 1)) {
-            dir->changed = 1;
-            dir->beginSelection = begin;
-            if (str[strlen (str) - 1] == '/') {
-                dir->endSelection = begin;
-            } else {
-                dir->endSelection = end - 1;
-            }
-        }
-    } else {
-        if (dir->beginSelection != -1) {
-            dir->changed = 1;
-            dir->beginSelection = -1;
-            dir->endSelection = -1;
-        }
-    }
-    if (
-        SFdoNotTouchVorigin ||
-        ((begin > dir->vOrigin) && (end < dir->vOrigin + SFlistSize))
-    ) {
-        SFdoNotTouchVorigin = 0;
-        return 0;
-    }
-    i = begin - 1;
-    if (i > max - SFlistSize) {
-        i = max - SFlistSize;
-    }
-    if (i < 0) {
-        i = 0;
-    }
-    if (dir->vOrigin != i) {
-        dir->vOrigin = i;
-        dir->changed = 1;
-    }
-    return 0;
-}
-
-static void SFunselect (void) {
-    SFDir *dir;
-
-    dir = &(SFdirs[SFdirEnd - 1]);
-    if (dir->beginSelection != -1) {
-        dir->changed = 1;
-    }
-    dir->beginSelection = -1;
-    dir->endSelection = -1;
-}
-
-static int SFcompareLogins (const void *vp, const void *vq) {
-    const SFLogin *p = vp, *q = vq;
-
-    return strcmp (p->name, q->name);
-}
-
-static void SFgetHomeDirs (void) {
-    struct passwd *pw;
-    int           alloc;
-    int           i;
-    SFEntry       *entries = NULL;
-    int           len;
-    int           maxChars;
-
-    alloc = 1;
-    i = 1;
-    entries = (SFEntry *) XtMalloc (sizeof (SFEntry));
-    SFlogins = (SFLogin *) XtMalloc (sizeof (SFLogin));
-    entries[0].real = XtMalloc (3);
-    strcpy (entries[0].real, "~");
-    entries[0].shown = entries[0].real;
-    entries[0].statDone = 1;
-    SFlogins[0].name = "";
-    pw = getpwuid ((int) getuid ());
-    SFstrdup (&SFlogins[0].dir, pw ? pw->pw_dir : "/");
-    maxChars = 0;
-
-    setpwent ();
-    while ((pw = getpwent ()) && (*(pw->pw_name))) {
-        if (i >= alloc) {
-            alloc *= 2;
-            entries = (SFEntry *) XtRealloc (
-                (char *) entries, (unsigned) (alloc * sizeof (SFEntry))
-            );
-            SFlogins = (SFLogin *) XtRealloc (
-                (char *) SFlogins, (unsigned) (alloc * sizeof (SFLogin))
-            );
-        }
-        len = strlen (pw->pw_name);
-        entries[i].real = XtMalloc ((unsigned) (len + 3));
-        strcat (strcpy (entries[i].real, "~"), pw->pw_name);
-        entries[i].shown = entries[i].real;
-        entries[i].statDone = 1;
-        if (len > maxChars) {
-            maxChars = len;
-        }
-        SFstrdup (&SFlogins[i].name, pw->pw_name);
-        SFstrdup (&SFlogins[i].dir, pw->pw_dir);
-        i++;
-    }
-    SFhomeDir.dir            = XtMalloc (1);
-    SFhomeDir.dir[0]         = 0;
-    SFhomeDir.path           = SFcurrentPath;
-    SFhomeDir.entries        = entries;
-    SFhomeDir.nEntries       = i;
-    SFhomeDir.vOrigin        = 0;  /* :-) */
-    SFhomeDir.nChars         = maxChars + 2;
-    SFhomeDir.hOrigin        = 0;
-    SFhomeDir.changed        = 1;
-    SFhomeDir.beginSelection = -1;
-    SFhomeDir.endSelection   = -1;
-
-    qsort(entries, (size_t)i, sizeof(SFEntry), SFcompareEntries);
-    qsort(SFlogins, (size_t)i, sizeof(SFLogin), SFcompareLogins);
-
-    for (i--; i >= 0; i--) {
-        strcat (entries[i].real, "/");
-    }
-}
-
-static int SFfindHomeDir (char *begin, char *end) {
-    char save;
-    char *theRest;
-    int  i;
-
-    save = *end;
-    *end = 0;
-    for (i = SFhomeDir.nEntries - 1; i >= 0; i--) {
-        if (!strcmp (SFhomeDir.entries[i].real, begin)) {
-            *end = save;
-            SFstrdup (&theRest, end);
-            strcat (strcat (strcpy (
-                SFcurrentPath, SFlogins[i].dir
-            ), "/"), theRest);
-            XtFree (theRest);
-            SFsetText (SFcurrentPath);
-            SFtextChanged ();
-            return 1;
-        }
-    }
-    *end = save;
-    return 0;
-}
-
-void SFupdatePath (void) {
-    static int alloc;
-    static int wasTwiddle = 0;
-    char       *begin, *end;
-    int        i, j;
-    int        prevChange;
-    int        SFdirPtrSave, SFdirEndSave;
-    SFDir      *dir;
-
-    if (!SFdirs) {
-        SFdirs = (SFDir *) XtMalloc ((alloc = 10) * sizeof (SFDir));
-        dir = &(SFdirs[0]);
-        SFstrdup (&dir->dir, "/");
-        SFchdir ("/");
-        SFgetDir (dir);
-        for (j = 1; j < alloc; j++) {
-            SFdirs[j].dir = NULL;
-        }
-        dir->path = SFcurrentPath + 1;
-        dir->vOrigin = 0;
-        dir->hOrigin = 0;
-        dir->changed = 1;
-        dir->beginSelection = -1;
-        dir->endSelection = -1;
-        SFhomeDir.dir = NULL;
-    }
-    SFdirEndSave = SFdirEnd;
-    SFdirEnd = 1;
-    SFdirPtrSave = SFdirPtr;
-    SFdirPtr = 0;
-    begin = NULL;
-    if (SFcurrentPath[0] == '~') {
-        if (!SFtwiddle) {
-            SFtwiddle = 1;
-            dir = & (SFdirs[0]);
-            SFrootDir = *dir;
-            if (!SFhomeDir.dir) {
-                SFgetHomeDirs ();
-            }
-            *dir = SFhomeDir;
-            dir->changed = 1;
-        }
-        end = SFcurrentPath;
-        SFdoNotTouchDirPtr = 1;
-        wasTwiddle = 1;
-    } else {
-        if (SFtwiddle) {
-            SFtwiddle = 0;
-            dir = & (SFdirs[0]);
-            *dir = SFrootDir;
-            dir->changed = 1;
-        }
-        end = SFcurrentPath + 1;
-    }
-    i = 0;
-    prevChange = 0;
-    while (*end) {
-        while (*end++ == '/') {
-            ;
-        }
-        end--;
-        begin = end;
-        while ((*end) && (*end++ != '/')) {
-            ;
-        }
-        if ((end - SFcurrentPath <= SFtextPos) && (* (end - 1) == '/')) {
-            SFdirPtr = i - 1;
-            if (SFdirPtr < 0) {
-                SFdirPtr = 0;
-            }
-        }
-        if (*begin) {
-            if (*(end - 1) == '/') {
-                char save = *end;
-
-                if (SFtwiddle) {
-                    if (SFfindHomeDir (begin, end)) {
-                        return;
-                    }
-                }
-                *end = 0;
-                i++;
-                SFdirEnd++;
-                if (i >= alloc) {
-                    SFdirs = (SFDir *) XtRealloc (
-                        (char *) SFdirs,
-                        (unsigned) ((alloc *= 2) * sizeof (SFDir))
-                    );
-                    for (j = alloc / 2; j < alloc; j++) {
-                        SFdirs[j].dir = NULL;
-                    }
-                }
-                dir = &(SFdirs[i]);
-                if ((!(dir->dir)) || prevChange || strcmp (dir->dir, begin)) {
-                    if (dir->dir) {
-                        SFfree (i);
-                    }
-                    prevChange = 1;
-                    SFstrdup (&dir->dir, begin);
-                    dir->path = end;
-                    dir->vOrigin = 0;
-                    dir->hOrigin = 0;
-                    dir->changed = 1;
-                    dir->beginSelection = -1;
-                    dir->endSelection = -1;
-                    SFfindFile (dir - 1, begin);
-                    if (SFchdir (SFcurrentPath) || SFgetDir (dir)) {
-                        SFunreadableDir (dir);
-                        break;
-                    }
-                }
-                *end = save;
-                if (!save) {
-                    SFunselect ();
-                }
-            } else {
-                if (SFfindFile (& (SFdirs[SFdirEnd-1]), begin)) {
-                    return;
-                }
-            }
-        } else {
-            SFunselect ();
-        }
-    }
-    if ((end == SFcurrentPath + 1) && (!SFtwiddle)) {
-        SFunselect ();
-    }
-    for (i = SFdirEnd; i < alloc; i++) {
-        if (SFdirs[i].dir) {
-            SFfree (i);
-        }
-    }
-    if (SFdoNotTouchDirPtr) {
-        if (wasTwiddle) {
-            wasTwiddle = 0;
-            SFdirPtr = SFdirEnd - 2;
-            if (SFdirPtr < 0) {
-                SFdirPtr = 0;
-            }
-        } else {
-            SFdirPtr = SFdirPtrSave;
-        }
-        SFdoNotTouchDirPtr = 0;
-    }
-    if ((SFdirPtr != SFdirPtrSave) || (SFdirEnd != SFdirEndSave)) {
-        XawScrollbarSetThumb (
-            selFileHScroll,
-            (float) (((double) SFdirPtr) / SFdirEnd),
-            (float) (((double) ((SFdirEnd < 3) ? SFdirEnd : 3)) / SFdirEnd)
-        );
-    }
-    if (SFdirPtr != SFdirPtrSave) {
-        SFdrawLists (SF_DO_SCROLL);
-    } else {
-        for (i = 0; i < 3; i++) {
-            if (SFdirPtr + i < SFdirEnd) {
-                if (SFdirs[SFdirPtr + i].changed) {
-                    SFdirs[SFdirPtr + i].changed = 0;
-                    SFdrawList (i, SF_DO_SCROLL);
-                }
-            } else {
-                SFclearList (i, SF_DO_SCROLL);
-            }
-        }
-    }
-}
-
-void SFsetText (char *path) {
-    XawTextBlock text;
-
-    text.firstPos = 0;
-    text.length = strlen (path);
-    text.ptr = path;
-    text.format = FMT8BIT;
-    XawTextReplace (selFileField, 0, strlen (SFtextBuffer), &text);
-    XawTextSetInsertionPoint (selFileField, strlen (SFtextBuffer));
-}
-
-
-void SFbuttonPressList (Widget w, XtPointer cl, XEvent *ev, Boolean *b) {
-    SFbuttonPressed = 1;
-}
-
-void SFbuttonReleaseList (Widget w, XtPointer cl, XEvent *ev, Boolean *b) {
-    SFDir *dir;
-    intptr_t n;
-    XButtonReleasedEvent *event;
-
-    n = (intptr_t) cl;
-    event = (XButtonReleasedEvent *) ev;
-    SFbuttonPressed = 0;
-    if (SFcurrentInvert[n] != -1) {
-        if (n < 2) {
-            SFdoNotTouchDirPtr = 1;
-        }
-        SFdoNotTouchVorigin = 1;
-        dir = &(SFdirs[SFdirPtr + n]);
-        SFreplaceText (
-            dir, dir->entries[dir->vOrigin + SFcurrentInvert[n]].shown
-        );
-        SFmotionList (w, (XtPointer) n, (XEvent *) event, NULL);
-    }
-}
-
-static int SFcheckDir (int n, SFDir *dir) {
-    struct stat statBuf;
-    int         i;
-
-    if ((!stat (".", &statBuf)) && (statBuf.st_mtime != dir->mtime)) {
-        /*  If the pointer is currently in the window that we are about
-            to update, we must warp it to prevent the user from
-            accidentally selecting the wrong file.
-        */
-        if (SFcurrentInvert[n] != -1) {
-            XWarpPointer (
-                SFdisplay, None, XtWindow (selFileLists[n]), 0, 0, 0, 0, 0, 0
-            );
-        }
-        for (i = dir->nEntries - 1; i >= 0; i--) {
-            if (dir->entries[i].shown != dir->entries[i].real) {
-                XtFree (dir->entries[i].shown);
-            }
-            XtFree (dir->entries[i].real);
-        }
-        XtFree ((char *) dir->entries);
-        if (SFgetDir (dir)) {
-            SFunreadableDir (dir);
-        }
-        if (dir->vOrigin > dir->nEntries - SFlistSize) {
-            dir->vOrigin = dir->nEntries - SFlistSize;
-        }
-        if (dir->vOrigin < 0) {
-            dir->vOrigin = 0;
-        }
-        if (dir->hOrigin > dir->nChars - SFcharsPerEntry) {
-            dir->hOrigin = dir->nChars - SFcharsPerEntry;
-        }
-        if (dir->hOrigin < 0) {
-            dir->hOrigin = 0;
-        }
-        dir->beginSelection = -1;
-        dir->endSelection = -1;
-        SFdoNotTouchVorigin = 1;
-        if ((dir + 1)->dir) {
-            SFfindFile (dir, (dir + 1)->dir);
-        } else {
-            SFfindFile (dir, dir->path);
-        }
-        if (!SFworkProcAdded) {
-            SFworkProcId = XtAppAddWorkProc (SFapp, SFworkProc, NULL);
-            SFworkProcAdded = 1;
-        }
-        return 1;
-    }
-    return 0;
-}
-
-static int SFcheckFiles (SFDir *dir) {
-    int         from, to;
-    int         result;
-    char        old, new;
-    int         i;
-    char        *str;
-    int         last;
-    struct stat statBuf;
-
-    result = 0;
-    from = dir->vOrigin;
-    to = dir->vOrigin + SFlistSize;
-    if (to > dir->nEntries) {
-        to = dir->nEntries;
-    }
-    for (i = from; i < to; i++) {
-        str = dir->entries[i].real;
-        last = strlen (str) - 1;
-        old = str[last];
-        str[last] = 0;
-        if (stat (str, &statBuf)) {
-            new = ' ';
-        } else {
-            new = SFstatChar (&statBuf);
-        }
-        str[last] = new;
-        if (new != old) {
-            result = 1;
-        }
-    }
-    return result;
-}
-
-void SFdirModTimer (XtPointer cl, XtIntervalId *id) {
-    static int n = -1;
-    static int f = 0;
-    char       save;
-    SFDir      *dir;
-
-    if ((!SFtwiddle) && (SFdirPtr < SFdirEnd)) {
-        n++;
-        if ((n > 2) || (SFdirPtr + n >= SFdirEnd)) {
-            n = 0;
-            f++;
-            if ((f > 2) || (SFdirPtr + f >= SFdirEnd)) {
-                f = 0;
-            }
-        }
-        dir = & (SFdirs[SFdirPtr + n]);
-        save = * (dir->path);
-        * (dir->path) = 0;
-        if (SFchdir (SFcurrentPath)) {
-            *(dir->path) = save;
-            /* force a re-read */
-            *(dir->dir) = 0;
-            SFupdatePath ();
-        } else {
-            *(dir->path) = save;
-            if (SFcheckDir (n, dir) || ((f == n) && SFcheckFiles (dir))) {
-                SFdrawList (n, SF_DO_SCROLL);
-            }
-        }
-    }
-    SFdirModTimerId = XtAppAddTimeOut (
-        SFapp, (unsigned long) 1000, SFdirModTimer, (XtPointer) NULL
-    );
-}
-
-/* Return a single character describing what kind of file STATBUF is. */
-char SFstatChar (struct stat *statBuf) {
-    if (S_ISDIR (statBuf->st_mode)) {
-        return '/';
-    } else if (S_ISREG (statBuf->st_mode)) {
-        return S_ISXXX (statBuf->st_mode) ? '*' : ' ';
-#ifdef S_ISSOCK
-    } else if (S_ISSOCK (statBuf->st_mode)) {
-        return '=';
-#endif /* S_ISSOCK */
-    } else {
-        return ' ';
-    }
-}
diff --git a/cmd/lefty/ws/x11/libfilereq/README.selfile b/cmd/lefty/ws/x11/libfilereq/README.selfile
deleted file mode 100644 (file)
index e0929e0..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-                  XsraSelFile File Selection Dialog Package
-
-
-
-This directory contains the XsraSelFile file selection dialog package. This
-package allows an application to obtain a filename from a user. The filename is
-selected by typing in a text widget or by browsing with the mouse in directory
-listings.
-
-The following is a brief description of the available features.
-
-* filename completion
-
-    When the user types a filename in the Text widget, SelFile shows the
-    possible completions in the directory listings. The user can hit the space
-    bar to complete the filename.
-
-* fast directory reading
-
-    When a directory is opened, the entries are read and sorted. Then the stats
-    of only the first screenful of entries are taken, and these entries are
-    displayed. The stats of the other entries are taken upon demand (i.e. when
-    the user wishes to see them by scrolling, etc.) or in the background. The
-    Xt work procedure facility is used to do background work. The idea here is
-    to give the user some feedback as soon as possible.
-
-    "It's just an illu--sion" :-)
-
-* Xaw and/or Xw widgets
-
-    SelFile can be linked with Xaw (Athena) and/or Xw (Hewlett-Packard)
-    widgets. Normally, SelFile is linked with the R3 or a later version of the
-    Xt Intrinsics, but it can be linked with the R2 Xt. See the Imakefile for
-    details.
-
-* automatic display update after directory modification
-
-    Every now and then SelFile looks at the directories being displayed to see
-    if they have been updated, and updates the display accordingly. Similarly,
-    file modes are checked (but not as often).
-
-* tilde (~) for home directories
-
-    When the user types a tilde at the beginning of the Text widget, SelFile
-    shows the home directories.
-
--------------------------------------------------------------------------------
-
-This work is loosely based on (and the name comes from) an earlier X10 SelFile
-by Michiharu `NinjaTerm' Ariza.
-
-Admittedly, this X11 SelFile also looks a bit like the directory browser on the
-NeXT machine.
-
--------------------------------------------------------------------------------
-
-If you have any
-
-    porting problems
-
-    bug reports
-
-    comments (particularly about ideas in the TODO file)
-
-    or any other type of feedback
-
-please send mail to
-
-    erik@sra.co.jp
-                                           OR
-    erik%sra.co.jp@uunet.uu.net
-                                           OR
-    erik%sra.co.jp@mcvax.uucp
-                                           OR
-    try junet instead of co.jp
-                                           OR
-    Erik M. van der Poel
-    Software Research Associates, Inc.
-    1-1-1 Hirakawa-cho, Chiyoda-ku
-    Tokyo 102 Japan. TEL +81-3-234-2692
diff --git a/cmd/lefty/ws/x11/libfilereq/SF.h b/cmd/lefty/ws/x11/libfilereq/SF.h
deleted file mode 100644 (file)
index 61926eb..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-int XsraSelFile (
-    Widget, char *, char *, char *, char *, char *, char *,
-    int (*) (char *, char **, struct stat *), char *, int
-);
diff --git a/cmd/lefty/ws/x11/libfilereq/SFDecls.h b/cmd/lefty/ws/x11/libfilereq/SFDecls.h
deleted file mode 100644 (file)
index b158b5d..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* SFDecls.h */
-
-/* We don't rely on compiler doing the right thing
- * in absence of declarations.
- * C compilers should never have accepted this braindamage.
- * KG <garloff@suse.de>, 2002-01-28
- */
-
-/* SelFile.c */
-FILE * SFopenFile (char *, char *, char *, char *);
-void SFtextChanged (void);
-
-/* Draw.c */
-void SFinitFont (void);
-void SFcreateGC (void);
-void SFclearList (int, int);
-void SFdrawList (int, int);
-void SFdrawLists (int);
-
-/* Path.c */
-int SFchdir (char *path);
-void SFupdatePath (void);
-void SFsetText (char *path);
-
-/* Dir.c */
-int SFcompareEntries (const void *vp, const void *vq);
-int SFgetDir (SFDir *dir);
diff --git a/cmd/lefty/ws/x11/libfilereq/SFinternal.h b/cmd/lefty/ws/x11/libfilereq/SFinternal.h
deleted file mode 100644 (file)
index 94f01b4..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/*
- * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Software Research Associates not be used
- * in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission.  Software Research Associates
- * makes no representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- *
- * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Erik M. van der Poel
- *         Software Research Associates, Inc., Tokyo, Japan
- *         erik@sra.co.jp
- */
-
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-#include <X11/Xos.h>
-#include <X11/Xaw/Text.h>
-#include <X11/Xaw/AsciiText.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#define SEL_FILE_CANCEL -1
-#define SEL_FILE_OK      0
-#define SEL_FILE_NULL    1
-#define SEL_FILE_TEXT    2
-
-#define SF_DO_SCROLL     1
-#define SF_DO_NOT_SCROLL 0
-
-typedef struct {
-    int  statDone;
-    char *real;
-    char *shown;
-} SFEntry;
-
-typedef struct {
-    char    *dir;
-    char    *path;
-    SFEntry *entries;
-    int     nEntries;
-    int     vOrigin;
-    int     nChars;
-    int     hOrigin;
-    int     changed;
-    int     beginSelection;
-    int     endSelection;
-    time_t  mtime;
-} SFDir;
-
-extern int SFstatus;
-
-extern char SFcurrentPath[], SFstartDir[], SFcurrentDir[];
-
-extern Widget selFile, selFileCancel, selFileField, selFileForm;
-extern Widget selFileHScroll, selFileHScrolls[], selFileLists[];
-extern Widget selFileOK, selFilePrompt, selFileVScrolls[];
-
-extern Display *SFdisplay;
-
-extern int SFcharWidth, SFcharHeight, SFcharAscent;
-
-extern SFDir *SFdirs;
-
-extern int SFdirEnd, SFdirPtr;
-
-extern Pixel SFfore, SFback;
-
-extern Atom SFwmDeleteWindow;
-
-extern XSegment SFsegs[], SFcompletionSegs[];
-
-extern XawTextPosition SFtextPos;
-
-void SFenterList (Widget, XtPointer, XEvent *, Boolean *);
-void SFleaveList (Widget, XtPointer, XEvent *, Boolean *);
-void SFmotionList (Widget, XtPointer, XEvent *, Boolean *);
-
-void SFvFloatSliderMovedCallback (Widget, XtPointer, XtPointer);
-void SFvSliderMovedCallback (Widget, XtPointer, XtPointer);
-void SFvAreaSelectedCallback (Widget, XtPointer, XtPointer);
-void SFhSliderMovedCallback (Widget, XtPointer, XtPointer);
-void SFhAreaSelectedCallback (Widget, XtPointer, XtPointer);
-void SFpathSliderMovedCallback (Widget, XtPointer, XtPointer);
-void SFpathAreaSelectedCallback (Widget, XtPointer, XtPointer);
-
-void SFbuttonPressList (Widget, XtPointer, XEvent *, Boolean *);
-void SFbuttonReleaseList (Widget, XtPointer, XEvent *, Boolean *);
-
-extern int SFupperX, SFlowerY, SFupperY;
-
-extern int SFtextX, SFtextYoffset;
-
-extern int SFentryWidth, SFentryHeight;
-
-extern int SFlineToTextH, SFlineToTextV;
-
-extern int SFbesideText, SFaboveAndBelowText;
-
-extern int SFcharsPerEntry;
-
-extern int SFlistSize;
-
-extern int SFcurrentInvert[];
-
-extern int SFworkProcAdded;
-extern XtWorkProcId SFworkProcId;
-
-extern Boolean SFworkProc (XtPointer);
-
-extern XtAppContext SFapp;
-
-extern int SFpathScrollWidth, SFvScrollHeight, SFhScrollWidth;
-
-extern char SFtextBuffer[];
-
-extern int SFbuttonPressed;
-
-void SFdirModTimer (XtPointer cl, XtIntervalId *id);
-char SFstatChar (struct stat *);
-
-extern XtIntervalId SFdirModTimerId;
-
-extern int (*SFfunc) (char *, char **, struct stat *);
diff --git a/cmd/lefty/ws/x11/libfilereq/SelFile.c b/cmd/lefty/ws/x11/libfilereq/SelFile.c
deleted file mode 100644 (file)
index b86cb76..0000000
+++ /dev/null
@@ -1,739 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#ifdef FEATURE_CS
-#include <ast.h>
-#endif
-
-/*
- * Copyright 1989 Software Research Associates, Inc., Tokyo, Japan
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Software Research Associates not be used
- * in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission.  Software Research Associates
- * makes no representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- *
- * SOFTWARE RESEARCH ASSOCIATES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL SOFTWARE RESEARCH ASSOCIATES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Erik M. van der Poel
- *         Software Research Associates, Inc., Tokyo, Japan
- *         erik@sra.co.jp
- */
-
-/*
- * Author's address:
- *
- *     erik@sra.co.jp
- *                                            OR
- *     erik%sra.co.jp@uunet.uu.net
- *                                            OR
- *     erik%sra.co.jp@mcvax.uucp
- *                                            OR
- *     try junet instead of co.jp
- *                                            OR
- *     Erik M. van der Poel
- *     Software Research Associates, Inc.
- *     1-1-1 Hirakawa-cho, Chiyoda-ku
- *     Tokyo 102 Japan. TEL +81-3-234-2692
- */
-
-#include "config.h"
-#include <stdio.h>
-#include <errno.h>
-
-#include <sys/param.h>
-#include <X11/cursorfont.h>
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-#include <X11/Composite.h>
-#include <X11/Shell.h>
-#include <X11/Xaw/Form.h>
-#include <X11/Xaw/Command.h>
-#include <X11/Xaw/Scrollbar.h>
-#include <X11/Xaw/Label.h>
-#include <X11/Xaw/Cardinals.h>
-
-#include "SFinternal.h"
-
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 1024
-#endif /* ndef MAXPATHLEN */
-
-#include "SFDecls.h"
-
-#include <stdlib.h>
-
-#include <stdint.h>
-#ifdef HAVE_INTPTR_T
-#define INT2PTR(t,v) ((t)(intptr_t)(v))
-#define PTR2INT(v) ((Sflong_t)(intptr_t)(v))
-#else
-#define INT2PTR(t,v) ((t)(v))
-#define PTR2INT(v) ((Sflong_t)(v))
-#endif
-
-int SFstatus = SEL_FILE_NULL;
-
-char SFstartDir[MAXPATHLEN], SFcurrentPath[MAXPATHLEN];
-char SFcurrentDir[MAXPATHLEN];
-
-Widget selFile, selFileCancel, selFileField, selFileForm, selFileHScroll;
-Widget selFileHScrolls[3], selFileLists[3], selFileOK, selFilePrompt;
-Widget selFileVScrolls[3];
-
-Display *SFdisplay;
-
-Pixel SFfore, SFback;
-
-Atom SFwmDeleteWindow;
-
-XSegment SFsegs[2], SFcompletionSegs[2];
-
-XawTextPosition SFtextPos;
-
-int SFupperX, SFlowerY, SFupperY;
-
-int SFtextX, SFtextYoffset;
-
-int SFentryWidth, SFentryHeight;
-
-int SFlineToTextH = 3;
-
-int SFlineToTextV = 3;
-
-int SFbesideText = 3;
-
-int SFaboveAndBelowText = 2;
-
-int SFcharsPerEntry = 15;
-
-int SFlistSize = 10;
-
-int SFworkProcAdded = 0;
-XtWorkProcId SFworkProcId;
-
-XtAppContext SFapp;
-
-int SFpathScrollWidth, SFvScrollHeight, SFhScrollWidth;
-
-char SFtextBuffer[MAXPATHLEN];
-
-XtIntervalId SFdirModTimerId;
-
-int (*SFfunc) (char *, char **, struct stat *);
-
-static char *oneLineTextEditTranslations = "\
-    <Key>Return: redraw-display()\n\
-    Ctrl<Key>M:  redraw-display()\n\
-";
-
-static void SFexposeList (Widget w, XtPointer n, XEvent *event, Boolean *cont) {
-    if ((event->type == NoExpose) || event->xexpose.count) {
-        return;
-    }
-
-    SFdrawList ((intptr_t) n, SF_DO_NOT_SCROLL);
-}
-
-static void SFmodVerifyCallback (
-    Widget w, XtPointer client_data, XEvent *event, Boolean *cont
-) {
-    char buf[2];
-
-    if (
-        XLookupString (&event->xkey, buf, 2, NULL, NULL) == 1 && *buf == '\r'
-    ) {
-        SFstatus = SEL_FILE_OK;
-    } else {
-        SFstatus = SEL_FILE_TEXT;
-    }
-}
-
-static void SFokCallback (Widget w, XtPointer cl, XtPointer cd) {
-    SFstatus = SEL_FILE_OK;
-}
-
-static XtCallbackRec SFokSelect[] = {
-    { SFokCallback, (XtPointer) NULL },
-    { NULL,         (XtPointer) NULL },
-};
-
-static void SFcancelCallback (Widget w, XtPointer cl, XtPointer cd) {
-    SFstatus = SEL_FILE_CANCEL;
-}
-
-static XtCallbackRec SFcancelSelect[] = {
-    { SFcancelCallback, (XtPointer) NULL },
-    { NULL,             (XtPointer) NULL },
-};
-
-static void SFdismissAction (
-    Widget w, XEvent *event, String *params, Cardinal *num_params
-) {
-    if (
-        event->type == ClientMessage &&
-        event->xclient.data.l[0] != SFwmDeleteWindow
-    )
-        return;
-
-    SFstatus = SEL_FILE_CANCEL;
-}
-
-static char *wmDeleteWindowTranslation = "\
-    <Message>WM_PROTOCOLS: SelFileDismiss()\n\
-";
-
-static XtActionsRec actions[] = {
-    { "SelFileDismiss", SFdismissAction },
-};
-
-static void SFcreateWidgets (
-    Widget toplevel, char *prompt, char *ok, char *cancel
-) {
-    Cardinal i;
-    intptr_t n;
-    int      listWidth, listHeight;
-    int      listSpacing = 10;
-    int      scrollThickness = 15;
-    int      hScrollX, hScrollY;
-    int      vScrollX, vScrollY;
-    Cursor   xtermCursor, sbRightArrowCursor, dotCursor;
-    Arg      arglist[20];
-
-    i = 0;
-    XtSetArg (arglist[i], XtNtransientFor, toplevel); i++;
-
-    selFile = XtAppCreateShell (
-        "selFile", "SelFile", transientShellWidgetClass, SFdisplay, arglist, i
-    );
-
-    /* Add WM_DELETE_WINDOW protocol */
-    XtAppAddActions (
-        XtWidgetToApplicationContext (selFile), actions, XtNumber (actions)
-    );
-    XtOverrideTranslations (
-        selFile, XtParseTranslationTable (wmDeleteWindowTranslation)
-    );
-
-    i = 0;
-    XtSetArg (arglist[i], XtNdefaultDistance, 30); i++;
-    selFileForm = XtCreateManagedWidget (
-        "selFileForm", formWidgetClass, selFile, arglist, i
-    );
-
-    i = 0;
-    XtSetArg (arglist[i], XtNlabel, prompt); i++;
-    XtSetArg (arglist[i], XtNresizable, True); i++;
-    XtSetArg (arglist[i], XtNtop, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNbottom, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNleft, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNright, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNborderWidth, 0); i++;
-    selFilePrompt = XtCreateManagedWidget (
-        "selFilePrompt", labelWidgetClass, selFileForm, arglist, i
-    );
-
-    i = 0;
-    XtSetArg (arglist[i], XtNforeground, &SFfore); i++;
-    XtSetArg (arglist[i], XtNbackground, &SFback); i++;
-    XtGetValues (selFilePrompt, arglist, i);
-
-    SFinitFont ();
-
-    SFentryWidth = SFbesideText + SFcharsPerEntry * SFcharWidth + SFbesideText;
-    SFentryHeight = SFaboveAndBelowText + SFcharHeight + SFaboveAndBelowText;
-
-    listWidth = (
-        SFlineToTextH + SFentryWidth + SFlineToTextH + 1 + scrollThickness
-    );
-    listHeight = (
-        SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
-        SFlineToTextV + SFlistSize * SFentryHeight +
-        SFlineToTextV + 1 + scrollThickness
-    );
-
-    SFpathScrollWidth = 3 * listWidth + 2 * listSpacing + 4;
-
-    hScrollX = -1;
-    hScrollY = (
-        SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
-        SFlineToTextV + SFlistSize * SFentryHeight + SFlineToTextV
-    );
-    SFhScrollWidth = SFlineToTextH + SFentryWidth + SFlineToTextH;
-
-    vScrollX = SFlineToTextH + SFentryWidth + SFlineToTextH;
-    vScrollY = SFlineToTextV + SFentryHeight + SFlineToTextV;
-    SFvScrollHeight = (
-        SFlineToTextV + SFlistSize * SFentryHeight + SFlineToTextV
-    );
-
-    SFupperX = SFlineToTextH + SFentryWidth + SFlineToTextH - 1;
-    SFlowerY = (
-        SFlineToTextV + SFentryHeight + SFlineToTextV + 1 + SFlineToTextV
-    );
-    SFupperY = (
-        SFlineToTextV + SFentryHeight + SFlineToTextV + 1 +
-        SFlineToTextV + SFlistSize * SFentryHeight - 1
-    );
-
-    SFtextX = SFlineToTextH + SFbesideText;
-    SFtextYoffset = SFlowerY + SFaboveAndBelowText + SFcharAscent;
-
-    SFsegs[0].x1 = 0;
-    SFsegs[0].y1 = vScrollY;
-    SFsegs[0].x2 = vScrollX - 1;
-    SFsegs[0].y2 = vScrollY;
-    SFsegs[1].x1 = vScrollX;
-    SFsegs[1].y1 = 0;
-    SFsegs[1].x2 = vScrollX;
-    SFsegs[1].y2 = vScrollY - 1;
-
-    SFcompletionSegs[0].x1 = SFcompletionSegs[0].x2 = SFlineToTextH;
-    SFcompletionSegs[1].x1 = SFcompletionSegs[1].x2 = (
-        SFlineToTextH + SFentryWidth - 1
-    );
-
-    i = 0;
-    XtSetArg (arglist[i], XtNwidth, 3 * listWidth + 2 * listSpacing + 4); i++;
-    XtSetArg (arglist[i], XtNborderColor, SFfore); i++;
-
-    XtSetArg (arglist[i], XtNfromVert, selFilePrompt); i++;
-    XtSetArg (arglist[i], XtNvertDistance, 10); i++;
-    XtSetArg (arglist[i], XtNresizable, True); i++;
-    XtSetArg (arglist[i], XtNtop, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNbottom, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNleft, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNright, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNstring, SFtextBuffer); i++;
-    XtSetArg (arglist[i], XtNlength, MAXPATHLEN); i++;
-    XtSetArg (arglist[i], XtNeditType, XawtextEdit); i++;
-    XtSetArg (arglist[i], XtNwrap, XawtextWrapWord); i++;
-    XtSetArg (arglist[i], XtNresize, XawtextResizeHeight); i++;
-    XtSetArg (arglist[i], XtNuseStringInPlace, True); i++;
-    selFileField = XtCreateManagedWidget (
-        "selFileField", asciiTextWidgetClass, selFileForm, arglist, i
-    );
-
-    XtOverrideTranslations (
-        selFileField, XtParseTranslationTable (oneLineTextEditTranslations)
-    );
-    XtSetKeyboardFocus (selFileForm, selFileField);
-
-    i = 0;
-    XtSetArg (arglist[i], XtNorientation, XtorientHorizontal); i++;
-    XtSetArg (arglist[i], XtNwidth, SFpathScrollWidth); i++;
-    XtSetArg (arglist[i], XtNheight, scrollThickness); i++;
-    XtSetArg (arglist[i], XtNborderColor, SFfore); i++;
-    XtSetArg (arglist[i], XtNfromVert, selFileField); i++;
-    XtSetArg (arglist[i], XtNvertDistance, 30); i++;
-    XtSetArg (arglist[i], XtNtop, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNbottom, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNleft, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNright, XtChainLeft); i++;
-    selFileHScroll = XtCreateManagedWidget (
-        "selFileHScroll", scrollbarWidgetClass, selFileForm, arglist, i
-    );
-
-    XtAddCallback (
-        selFileHScroll, XtNjumpProc, SFpathSliderMovedCallback, (XtPointer) NULL
-    );
-    XtAddCallback (
-        selFileHScroll, XtNscrollProc, SFpathAreaSelectedCallback,
-        (XtPointer) NULL
-    );
-
-    i = 0;
-    XtSetArg (arglist[i], XtNwidth, listWidth); i++;
-    XtSetArg (arglist[i], XtNheight, listHeight); i++;
-    XtSetArg (arglist[i], XtNborderColor, SFfore); i++;
-    XtSetArg (arglist[i], XtNfromVert, selFileHScroll); i++;
-    XtSetArg (arglist[i], XtNvertDistance, 10); i++;
-    XtSetArg (arglist[i], XtNtop, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNbottom, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNleft, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNright, XtChainLeft); i++;
-    selFileLists[0] = XtCreateManagedWidget (
-        "selFileList1", compositeWidgetClass, selFileForm, arglist, i
-    );
-
-    i = 0;
-    XtSetArg (arglist[i], XtNwidth, listWidth); i++;
-    XtSetArg (arglist[i], XtNheight, listHeight); i++;
-    XtSetArg (arglist[i], XtNborderColor, SFfore); i++;
-    XtSetArg (arglist[i], XtNfromHoriz, selFileLists[0]); i++;
-    XtSetArg (arglist[i], XtNfromVert, selFileHScroll); i++;
-    XtSetArg (arglist[i], XtNhorizDistance, listSpacing); i++;
-    XtSetArg (arglist[i], XtNvertDistance, 10); i++;
-    XtSetArg (arglist[i], XtNtop, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNbottom, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNleft, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNright, XtChainLeft); i++;
-    selFileLists[1] = XtCreateManagedWidget (
-        "selFileList2", compositeWidgetClass, selFileForm, arglist, i
-    );
-
-    i = 0;
-    XtSetArg (arglist[i], XtNwidth, listWidth); i++;
-    XtSetArg (arglist[i], XtNheight, listHeight); i++;
-    XtSetArg (arglist[i], XtNborderColor, SFfore); i++;
-    XtSetArg (arglist[i], XtNfromHoriz, selFileLists[1]); i++;
-    XtSetArg (arglist[i], XtNfromVert, selFileHScroll); i++;
-    XtSetArg (arglist[i], XtNhorizDistance, listSpacing); i++;
-    XtSetArg (arglist[i], XtNvertDistance, 10); i++;
-    XtSetArg (arglist[i], XtNtop, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNbottom, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNleft, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNright, XtChainLeft); i++;
-    selFileLists[2] = XtCreateManagedWidget (
-        "selFileList3", compositeWidgetClass, selFileForm, arglist, i
-    );
-
-    for (n = 0; n < 3; n++) {
-
-        i = 0;
-        XtSetArg (arglist[i], XtNx, vScrollX); i++;
-        XtSetArg (arglist[i], XtNy, vScrollY); i++;
-        XtSetArg (arglist[i], XtNwidth, scrollThickness); i++;
-        XtSetArg (arglist[i], XtNheight, SFvScrollHeight); i++;
-        XtSetArg (arglist[i], XtNborderColor, SFfore); i++;
-        selFileVScrolls[n] = XtCreateManagedWidget (
-            "selFileVScroll", scrollbarWidgetClass, selFileLists[n], arglist, i
-        );
-
-        XtAddCallback (
-            selFileVScrolls[n], XtNjumpProc,
-            SFvFloatSliderMovedCallback, (XtPointer) n
-        );
-        XtAddCallback (
-            selFileVScrolls[n], XtNscrollProc,
-            SFvAreaSelectedCallback, (XtPointer) n
-        );
-
-        i = 0;
-
-        XtSetArg (arglist[i], XtNorientation, XtorientHorizontal); i++;
-        XtSetArg (arglist[i], XtNx, hScrollX); i++;
-        XtSetArg (arglist[i], XtNy, hScrollY); i++;
-        XtSetArg (arglist[i], XtNwidth, SFhScrollWidth); i++;
-        XtSetArg (arglist[i], XtNheight, scrollThickness); i++;
-        XtSetArg (arglist[i], XtNborderColor, SFfore); i++;
-        selFileHScrolls[n] = XtCreateManagedWidget (
-            "selFileHScroll", scrollbarWidgetClass, selFileLists[n], arglist, i
-        );
-
-        XtAddCallback (
-            selFileHScrolls[n], XtNjumpProc,
-            SFhSliderMovedCallback, (XtPointer) n
-        );
-        XtAddCallback (
-            selFileHScrolls[n], XtNscrollProc,
-            SFhAreaSelectedCallback, (XtPointer) n
-        );
-    }
-
-    i = 0;
-    XtSetArg (arglist[i], XtNlabel, ok); i++;
-    XtSetArg (arglist[i], XtNresizable, True); i++;
-    XtSetArg (arglist[i], XtNcallback, SFokSelect); i++;
-    XtSetArg (arglist[i], XtNborderColor, SFfore); i++;
-    XtSetArg (arglist[i], XtNfromVert, selFileLists[0]); i++;
-    XtSetArg (arglist[i], XtNvertDistance, 30); i++;
-    XtSetArg (arglist[i], XtNtop, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNbottom, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNleft, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNright, XtChainLeft); i++;
-    selFileOK = XtCreateManagedWidget (
-        "selFileOK", commandWidgetClass, selFileForm, arglist, i
-    );
-
-    i = 0;
-    XtSetArg (arglist[i], XtNlabel, cancel); i++;
-    XtSetArg (arglist[i], XtNresizable, True); i++;
-    XtSetArg (arglist[i], XtNcallback, SFcancelSelect); i++;
-    XtSetArg (arglist[i], XtNborderColor, SFfore); i++;
-    XtSetArg (arglist[i], XtNfromHoriz, selFileOK); i++;
-    XtSetArg (arglist[i], XtNfromVert, selFileLists[0]); i++;
-    XtSetArg (arglist[i], XtNhorizDistance, 30); i++;
-    XtSetArg (arglist[i], XtNvertDistance, 30); i++;
-    XtSetArg (arglist[i], XtNtop, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNbottom, XtChainTop); i++;
-    XtSetArg (arglist[i], XtNleft, XtChainLeft); i++;
-    XtSetArg (arglist[i], XtNright, XtChainLeft); i++;
-    selFileCancel = XtCreateManagedWidget (
-        "selFileCancel", commandWidgetClass, selFileForm, arglist, i
-    );
-
-    XtSetMappedWhenManaged (selFile, False);
-    XtRealizeWidget (selFile);
-
-    /* Add WM_DELETE_WINDOW protocol */
-    SFwmDeleteWindow = XInternAtom (SFdisplay, "WM_DELETE_WINDOW", False);
-    XSetWMProtocols (SFdisplay, XtWindow (selFile), &SFwmDeleteWindow, 1);
-
-    SFcreateGC ();
-
-    xtermCursor = XCreateFontCursor (SFdisplay, XC_xterm);
-
-    sbRightArrowCursor = XCreateFontCursor (SFdisplay, XC_sb_right_arrow);
-    dotCursor = XCreateFontCursor (SFdisplay, XC_dot);
-
-    XDefineCursor (SFdisplay, XtWindow (selFileForm), xtermCursor);
-    XDefineCursor (SFdisplay, XtWindow (selFileField), xtermCursor);
-
-    for (n = 0; n < 3; n++) {
-        XDefineCursor (
-            SFdisplay, XtWindow (selFileLists[n]), sbRightArrowCursor
-        );
-    }
-    XDefineCursor (SFdisplay, XtWindow (selFileOK), dotCursor);
-    XDefineCursor (SFdisplay, XtWindow (selFileCancel), dotCursor);
-
-    for (n = 0; n < 3; n++) {
-        XtAddEventHandler (
-            selFileLists[n], ExposureMask, True,
-            SFexposeList, (XtPointer) n
-        );
-        XtAddEventHandler (
-            selFileLists[n], EnterWindowMask, False,
-            SFenterList, (XtPointer) n
-        );
-        XtAddEventHandler (
-            selFileLists[n], LeaveWindowMask, False,
-            SFleaveList, (XtPointer) n
-        );
-        XtAddEventHandler (
-            selFileLists[n], PointerMotionMask, False,
-            SFmotionList, (XtPointer) n
-        );
-        XtAddEventHandler (
-            selFileLists[n], ButtonPressMask, False,
-            SFbuttonPressList, (XtPointer) n
-        );
-        XtAddEventHandler (
-            selFileLists[n], ButtonReleaseMask, False,
-            SFbuttonReleaseList, (XtPointer) n
-        );
-    }
-
-    XtAddEventHandler (
-        selFileField, KeyPressMask, False,
-        SFmodVerifyCallback, (XtPointer) NULL
-    );
-
-    SFapp = XtWidgetToApplicationContext (selFile);
-
-}
-
-/* position widget under the cursor */
-static void SFpositionWidget (Widget w) {
-    Arg args[3];
-    Cardinal num_args;
-    Dimension width, height, b_width;
-    int x, y, max_x, max_y;
-    Window root, child;
-    int dummyx, dummyy;
-    unsigned int dummymask;
-
-    XQueryPointer (
-        XtDisplay (w), XtWindow (w), &root, &child, &x, &y,
-        &dummyx, &dummyy, &dummymask
-    );
-    num_args = 0;
-    XtSetArg (args[num_args], XtNwidth, &width); num_args++;
-    XtSetArg (args[num_args], XtNheight, &height); num_args++;
-    XtSetArg (args[num_args], XtNborderWidth, &b_width); num_args++;
-    XtGetValues (w, args, num_args);
-
-    width += 2 * b_width;
-    height += 2 * b_width;
-
-    x -= ((Position) width / 2);
-    if (x < 0)
-        x = 0;
-    if (x > (max_x = (Position) (XtScreen (w)->width - width)))
-        x = max_x;
-
-    y -= ((Position) height / 2);
-    if (y < 0)
-        y = 0;
-    if (y > (max_y = (Position) (XtScreen (w)->height - height)))
-        y = max_y;
-
-    num_args = 0;
-    XtSetArg (args[num_args], XtNx, x); num_args++;
-    XtSetArg (args[num_args], XtNy, y); num_args++;
-    XtSetValues (w, args, num_args);
-}
-
-FILE *SFopenFile (char *name, char *mode, char *prompt, char *failed) {
-    Arg args[1];
-    FILE *fp;
-
-    SFchdir (SFstartDir);
-    if ((fp = fopen (name, mode)) == NULL) {
-        char *buf;
-        const char *errormsg = strerror (errno);
-        if (errormsg) {
-            buf = XtMalloc (
-                strlen (failed) + strlen (errormsg) + strlen (prompt) + 2
-            );
-            strcpy (buf, failed);
-            strcat (buf, errormsg);
-            strcat (buf, "\n");
-        } else {
-            buf = XtMalloc (strlen (failed) + strlen (prompt) + 2);
-            strcpy (buf, failed);
-            strcat (buf, "\n");
-            strcat (buf, prompt);
-        }
-        XtSetArg (args[0], XtNlabel, buf);
-        XtSetValues (selFilePrompt, args, ONE);
-        XtFree (buf);
-        return NULL;
-    }
-    return fp;
-}
-
-void SFtextChanged (void) {
-    if ((SFtextBuffer[0] == '/') || (SFtextBuffer[0] == '~')) {
-        strcpy (SFcurrentPath, SFtextBuffer);
-        SFtextPos = XawTextGetInsertionPoint (selFileField);
-    } else {
-        strcat (strcpy (SFcurrentPath, SFstartDir), SFtextBuffer);
-        SFtextPos = XawTextGetInsertionPoint (
-            selFileField
-        ) + strlen (SFstartDir);
-    }
-    if (!SFworkProcAdded) {
-        SFworkProcId = XtAppAddWorkProc (SFapp, SFworkProc, NULL);
-        SFworkProcAdded = 1;
-    }
-    SFupdatePath ();
-}
-
-static void SFprepareToReturn (void) {
-    SFstatus = SEL_FILE_NULL;
-    XtRemoveGrab (selFile);
-    XtUnmapWidget (selFile);
-    XtRemoveTimeOut (SFdirModTimerId);
-    if (SFchdir (SFstartDir)) {
-        XtAppError (SFapp, "XsraSelFile: can't return to current directory");
-    }
-}
-
-int
-XsraSelFile (
-    Widget toplevel, char *prompt, char *ok, char *cancel, char *failed,
-    char *init_path, char *mode,
-    int (*show_entry) (char *, char **, struct stat *),
-    char *name_return, int name_size
-) {
-    static int firstTime = 1;
-    Cardinal   i;
-    Arg        arglist[20];
-    XEvent     event;
-
-    if (!prompt) {
-        prompt = "Pathname:";
-    }
-    if (!ok) {
-        ok = "OK";
-    }
-    if (!cancel) {
-        cancel = "Cancel";
-    }
-    if (firstTime) {
-        firstTime = 0;
-        SFdisplay = XtDisplay (toplevel);
-        SFcreateWidgets (toplevel, prompt, ok, cancel);
-    } else {
-        i = 0;
-        XtSetArg (arglist[i], XtNlabel, prompt); i++;
-        XtSetValues (selFilePrompt, arglist, i);
-
-        i = 0;
-        XtSetArg (arglist[i], XtNlabel, ok); i++;
-        XtSetValues (selFileOK, arglist, i);
-
-        i = 0;
-        XtSetArg (arglist[i], XtNlabel, cancel); i++;
-        XtSetValues (selFileCancel, arglist, i);
-    }
-    SFpositionWidget (selFile);
-    XtMapWidget (selFile);
-
-    if (!getcwd (SFstartDir, MAXPATHLEN)) {
-        XtAppError (SFapp, "XsraSelFile: can't get current directory");
-    }
-    strcat (SFstartDir, "/");
-    strcpy (SFcurrentDir, SFstartDir);
-
-    if (init_path) {
-        if (init_path[0] == '/') {
-            strcpy (SFcurrentPath, init_path);
-            if (strncmp (SFcurrentPath, SFstartDir, strlen (SFstartDir))) {
-                SFsetText (SFcurrentPath);
-            } else {
-                SFsetText (& (SFcurrentPath[strlen (SFstartDir)]));
-            }
-        } else {
-            strcat (strcpy (SFcurrentPath, SFstartDir), init_path);
-            SFsetText (& (SFcurrentPath[strlen (SFstartDir)]));
-        }
-    } else {
-        strcpy (SFcurrentPath, SFstartDir);
-    }
-
-    SFfunc = show_entry;
-
-    SFtextChanged ();
-
-    XtAddGrab (selFile, True, True);
-
-    SFdirModTimerId = XtAppAddTimeOut (
-        SFapp, (unsigned long) 1000, SFdirModTimer, (XtPointer) NULL
-    );
-
-    while (1) {
-        XtAppNextEvent (SFapp, &event);
-        XtDispatchEvent (&event);
-        switch (SFstatus) {
-        case SEL_FILE_TEXT:
-            SFstatus = SEL_FILE_NULL;
-            SFtextChanged ();
-            break;
-        case SEL_FILE_OK:
-            strncpy (name_return, SFtextBuffer, name_size);
-            SFprepareToReturn ();
-            if (SFworkProcAdded) {
-                XtRemoveWorkProc (SFworkProcId);
-                SFworkProcAdded = 0;
-            }
-            return 1;
-        case SEL_FILE_CANCEL:
-            SFprepareToReturn ();
-            return 0;
-        case SEL_FILE_NULL:
-            break;
-        }
-    }
-    return 0;
-}
diff --git a/cmd/lefty/ws/x11/libfilereq/xstat.h b/cmd/lefty/ws/x11/libfilereq/xstat.h
deleted file mode 100644 (file)
index cadfdde..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#include <sys/stat.h>
-#if !defined(S_ISDIR) && defined(S_IFDIR)
-#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#endif
-#if !defined(S_ISREG) && defined(S_IFREG)
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-#endif
-#if !defined(S_ISSOCK) && defined(S_IFSOCK)
-#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
-#endif
-
-#ifndef S_IXUSR
-#define S_IXUSR 0100
-#endif
-#ifndef S_IXGRP
-#define S_IXGRP 0010
-#endif
-#ifndef S_IXOTH
-#define S_IXOTH 0001
-#endif
-
-#define S_ISXXX(m) ((m) & (S_IXUSR | S_IXGRP | S_IXOTH))
diff --git a/cmd/lneato/lneato.1 b/cmd/lneato/lneato.1
deleted file mode 100644 (file)
index b04fc25..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-.TH LNEATO 1
-.SH NAME
-lneato \- A Customizable Graph Editor
-.SH SYNOPSIS
-.B lneato
-[
-.B -V
-] [
-.BI -lm mode
-] [
-.BI -el lev
-] [
-.I file
-]
-.SH DESCRIPTION
-.B lneato
-is a graph editor for the X Window System.  It may be run as a standalone
-editor, or as a front end for applications that use graphs.  It can control
-multiple windows viewing different graphs.
-
-.B lneato
-is written on top of
-.B neato
-and
-.BR lefty .
-.B lefty
-is a general-purpose programmable editor for technical pictures.  It has an
-interpretive programming language similar to AWK and C.  The user interface and
-graph editing operations of
-.B lneato
-are written as
-.B lefty
-functions.
-Programmer-defined graph operations may be loaded as well.  Graph layouts are
-made by
-.BR neato ,
-which runs as a separate process that communicates with
-.B lefty
-through pipes.
-
-If the input graph contains xdot attributes,
-.B lneato
-will use that to display the graph. Otherwise, it runs
-.B neato
-to obtain layout information.
-.SH USAGE
-The file name is optional. If present, the graph contained in that file is
-displayed in the
-.B lneato
-window.
-.SH OPTIONS
-.TP
-.B -V
-Prints the version.
-.TP
-.BI -lm mode
-Sets the layout mode. The \fImode\fP can be \fBsync\fP or \fBasync\fP. The default is \fBasync\fP.
-.TP
-.BI -el lev
-Sets the mesage level. The \fIlev\fP can be \fB0\fP or \fB1\fP. The default is \fB0\fP.
-.SH SEE ALSO
-neato(1), lefty(1), dotty(1), xdot(3),
-.br
-.I dotty
-user guide.
diff --git a/cmd/lneato/lneato.bsh b/cmd/lneato/lneato.bsh
deleted file mode 100755 (executable)
index 319d82c..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/bin/sh
-FILES=""
-MLEVEL="0"
-LMODE="async"
-usage="echo usage: lneato [-V] [-lm (sync|async)] [-el (0|1)] <filename>"
-
-if test "x$DOTTYOPTIONS" != "x"
-then
-    options=$DOTTYOPTIONS
-else
-    options="$@"
-fi
-
-set -- $options
-
-for i in "$@"
-do
-       if test "x$i" = "x$1"
-       then
-               case $i in
-               -V)
-                       shift
-                       echo "lneato version 95 (04-18-95)"
-                       ;;
-               -lm)
-                       shift
-                       LMODE="$1"
-                       shift
-                       if test "x$LMODE" != "xsync" -a "x$LMODE" != "xasync"
-                       then
-                               $usage
-                               exit 1
-                       fi
-                       ;;
-               -el)
-                       shift
-                       MLEVEL="$1"
-                       shift
-                       if test "x$MLEVEL" != "x0" -a "x$MLEVEL" != "x1"
-                       then
-                               $usage
-                               exit 1
-                       fi
-                       ;;
-               -\?)
-                       $usage
-                       exit 0
-                       ;;
-               -?*)
-                       $usage
-                       exit 1
-                       ;;
-               *)
-                       FILES="$FILES '"$1"'"
-                       shift
-                       ;;
-               esac
-       fi
-done
-
-if test "x$MLEVEL" != "x0"
-then
-       echo "FILES  = $FILES"
-       echo "MLEVEL = $MLEVEL"
-       echo "LMODE  = $LMODE"
-fi
-
-if test "x$DOTTYPATH" != "x"
-then
-    LEFTYPATH="$DOTTYPATH:$LEFTYPATH"
-fi
-
-CMDS="dotty.layoutmode = '$LMODE';"
-CMDS="$CMDS dotty.mlevel = $MLEVEL; dot.mlevel =  $MLEVEL;"
-
-if test "x$FILES" = "x"
-then
-    FILES=null
-fi
-for i in $FILES
-do
-       CMDS="$CMDS dotty.createviewandgraph($i,'file',null,null);"
-done
-
-lefty -e "
-load ('dotty.lefty');
-
-checkpath = function () {
-       if (tablesize(dotty) > 0);      # because tablesize(undef) returns "" not 0
-       else {
-               echo('You must set LEFTYPATH to the lefty lib directory path name.');
-               exit();
-       }
-};
-checkpath ();
-
-dotty.protogt.lserver = 'neato';
-dotty.protogt.graph.type = 'graph';
-dotty.init ();
-monitorfile = dotty.monitorfile;
-$CMDS
-txtview ('off');
-"
diff --git a/cmd/lneato/lneato.ksh b/cmd/lneato/lneato.ksh
deleted file mode 100755 (executable)
index e6cd606..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-
-FILES=""
-MLEVEL="0"
-LMODE="async"
-FLAGS=
-
-function usage {
-    print "usage: lneato [-V] [-lm (sync|async)] [-el (0|1)] <filename>"
-}
-
-function processoptions {
-    while [[ $# > 0 ]] do
-        case $1 in
-        -V)
-            print "lneato version 96c (09-24-96)"
-                       FLAGS=$FLAGS" -V"
-            shift
-            ;;
-        -f)
-            shift
-            loadfile=$1
-            shift
-            ;;
-        -lm)
-            shift
-            LMODE=$1
-            if [[ $LMODE != 'sync' && $LMODE != 'async' ]] then
-                usage
-                exit 1
-            fi
-            shift
-            ;;
-        -el)
-            shift
-            MLEVEL=$1
-            if [[ $MLEVEL != '0' && $MLEVEL != '1' ]] then
-                usage
-                exit 1
-            fi
-            shift
-            ;;
-        -)
-            FILES=$(print $FILES "'"$1"'")
-            shift
-            ;;
-        -\?)
-            usage
-            exit 0
-            ;;
-        -*)
-            usage
-            exit 1
-            ;;
-        *)
-            FILES=$(print $FILES "'"$1"'")
-            shift
-            ;;
-        esac
-    done
-}
-
-if [[ $DOTTYOPTIONS != '' ]] then
-    processoptions $DOTTYOPTIONS
-fi
-processoptions "$@"
-
-if [[ $DOTTYPATH != '' ]] then
-    export LEFTYPATH="$DOTTYPATH:$LEFTYPATH"
-fi
-
-CMDS=""
-
-CMDS="dotty.protogt.layoutmode = '$LMODE';"
-
-CMDS=$(print $CMDS dotty.mlevel = $MLEVEL";")
-
-if [[ $loadfile != '' ]] then
-    CMDS=$(print $CMDS load \("'"$loadfile"'"\)";")
-fi
-
-if [[ $FILES = '' ]] then
-    FILES=null
-fi
-FUNC="dotty.createviewandgraph"
-for i in $FILES; do
-    CMDS=$(print $CMDS $FUNC \($i, "'"file"'", null, null\)";")
-done
-
-leftypath=$(whence -p lefty)
-if [[ $leftypath == '' ]] then
-    print -u2 "lneato: cannot locate the lefty program"
-    print -u2 "       make sure that your path includes"
-    print -u2 "       the directory containing lneato and lefty"
-    exit 1
-fi
-
-$leftypath $FLAGS -e "
-load ('dotty.lefty');
-dotty.protogt.lserver = 'neato';
-checkpath = function () {
-    if (tablesize (dotty) > 0)
-        remove ('checkpath');
-    else {
-        echo ('lneato: cannot locate the dotty scripts');
-        echo ('       make sure that the environment variable LEFTYPATH');
-        echo ('       is set to the directory containing dotty.lefty');
-        exit ();
-    }
-};
-checkpath ();
-dotty.init ();
-monitorfile = dotty.monitorfile;
-$CMDS
-txtview ('off');
-"
diff --git a/cmd/lneato/lneato.sh b/cmd/lneato/lneato.sh
deleted file mode 100755 (executable)
index 98b1b69..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/sh
-FILES=""
-MLEVEL="0"
-LMODE="async"
-FLAGS=
-
-usage="echo usage: lneato [-V] [-lm (sync|async)] [-el (0|1)] <filename>"
-
-if test "x$DOTTYOPTIONS" != "x"
-then
-    options=$DOTTYOPTIONS
-else
-    options="$@"
-fi
-
-set -- $options
-
-for i in "$@"
-do
-       if test "x$i" = "x$1"
-       then
-               case $i in
-               -V)
-                       shift
-                       echo "lneato version 95 (04-18-95)"
-                       FLAGS=$FLAGS" -V"
-                       ;;
-               -lm)
-                       shift
-                       LMODE="$1"
-                       shift
-                       if test "x$LMODE" != "xsync" -a "x$LMODE" != "xasync"
-                       then
-                               $usage
-                               exit 1
-                       fi
-                       ;;
-               -el)
-                       shift
-                       MLEVEL="$1"
-                       shift
-                       if test "x$MLEVEL" != "x0" -a "x$MLEVEL" != "x1"
-                       then
-                               $usage
-                               exit 1
-                       fi
-                       ;;
-               -\?)
-                       $usage
-                       exit 0
-                       ;;
-               -?*)
-                       $usage
-                       exit 1
-                       ;;
-               *)
-                       FILES="$FILES '"$1"'"
-                       shift
-                       ;;
-               esac
-       fi
-done
-
-if test "x$MLEVEL" != "x0"
-then
-       echo "FILES  = $FILES"
-       echo "MLEVEL = $MLEVEL"
-       echo "LMODE  = $LMODE"
-fi
-
-if test "x$DOTTYPATH" != "x"
-then
-    LEFTYPATH="$DOTTYPATH:$LEFTYPATH"
-fi
-
-CMDS="dotty.layoutmode = '$LMODE';"
-CMDS="$CMDS dotty.mlevel = $MLEVEL; dot.mlevel =  $MLEVEL;"
-
-if test "x$FILES" = "x"
-then
-    FILES=null
-fi
-for i in $FILES
-do
-       CMDS="$CMDS dotty.createviewandgraph($i,'file',null,null);"
-done
-
-lefty $FLAGS -e "
-load ('dotty.lefty');
-
-checkpath = function () {
-       if (tablesize(dotty) > 0);      # because tablesize(undef) returns "" not 0
-       else {
-               echo('You must set LEFTYPATH to the lefty lib directory path name.');
-               exit();
-       }
-};
-checkpath ();
-
-dotty.protogt.lserver = 'neato';
-dotty.protogt.graph.type = 'graph';
-dotty.init ();
-monitorfile = dotty.monitorfile;
-$CMDS
-txtview ('off');
-"
diff --git a/cmd/lneato/mswin32/doinst b/cmd/lneato/mswin32/doinst
deleted file mode 100755 (executable)
index be76d19..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-set -x
-
-if [[ $1 == '' || $1 == '-d' ]] then
-    cp -p debug/lneato.exe ../bin
-elif [[ $1 == '-a' ]] then
-    cp -p release/lneato.exe ../bin
-fi
diff --git a/cmd/lneato/mswin32/lneato.c b/cmd/lneato/mswin32/lneato.c
deleted file mode 100644 (file)
index 8c7d1b3..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* Lefteris Koutsofios - AT&T Bell Laboratories */
-
-#include <windows.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <shellapi.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <cgraph/exit.h>
-
-static char *shellpath;
-
-static char *buildpath (char *);
-
-int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
-        PWSTR pCmdLine, int nCmdShow) {
-    HANDLE handle;
-    char cmd[256];
-    char *path;
-    char *s;
-    int argc;
-    LPWSTR *argv;
-
-    shellpath = getenv ("PATH");
-    if (!shellpath || !(path = buildpath ("lefty"))) {
-        if (!GetModuleFileName (hInstance, cmd, 256) ||
-                !(s = strrchr (cmd, '\\')))
-            graphviz_exit(1);
-        *s = 0;
-        shellpath = &cmd[0];
-        if (!(path = buildpath ("lefty")))
-            graphviz_exit(1);
-    }
-    argv = CommandLineToArgvW(pCmdLine, &argc);
-    if (argc == 1 && wcscmp(argv[0], L"-?") == 0) {
-        fprintf(stderr, "usage: lneato [-V] [-lm (sync|async)] [-el (0|1)] <filename>\n");
-        graphviz_exit(0);
-    }
-    if (pCmdLine[0] == 0)
-        snprintf(cmd, sizeof(cmd), "%s -e \"load('dotty.lefty');"
-                 "dotty.protogt.lserver='neato';dotty.simple(null);\"", path);
-    else
-        snprintf(cmd, sizeof(cmd), "%s -e \"load('dotty.lefty');"
-                 "dotty.protogt.lserver='neato';dotty.simple('%Ns');\"", path,
-                 pCmdLine);
-
-    handle = WinExec (cmd, SW_SHOW);
-    graphviz_exit(0);
-}
-
-#define PATHDEL '\\'
-#define PATHSEP ';'
-
-static char pathbuf[1024];
-static char commandbuf[1024];
-
-static char *buildpath (char *file) {
-    struct stat statbuf;
-    char *s1, *s2;
-    int mode, pathi;
-
-    if (file && file[0] && (file[0] == '.' || file[0] == PATHDEL))
-        return file;
-    mode = ~0;
-    s1 = shellpath;
-    while (*s1) {
-        pathi = 0;
-        while (*s1 && *s1 != PATHSEP)
-            pathbuf[pathi++] = *s1++;
-        if (*s1)
-            s1++;
-        pathbuf[pathi++] = PATHDEL;
-        for (s2 = file; *s2; s2++)
-            pathbuf[pathi++] = *s2;
-        pathbuf[pathi++] = '.';
-        pathbuf[pathi++] = 'e';
-        pathbuf[pathi++] = 'x';
-        pathbuf[pathi++] = 'e';
-        pathbuf[pathi] = '\000';
-        if (stat (pathbuf, &statbuf) == 0 && (statbuf.st_mode & mode))
-            return pathbuf;
-    }
-    return NULL;
-}
diff --git a/cmd/lneato/mswin32/lneato.mak b/cmd/lneato/mswin32/lneato.mak
deleted file mode 100644 (file)
index 3a18af2..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-!IF "$(CFG)" == ""
-CFG=lneato - Win32 Debug
-!MESSAGE No configuration specified.  Defaulting to lneato - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "lneato - Win32 Release" && "$(CFG)" != "lneato - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE on this makefile
-!MESSAGE by defining the macro CFG on the command line.  For example:
-!MESSAGE
-!MESSAGE NMAKE /f "lneato.mak" CFG="lneato - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "lneato - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "lneato - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-################################################################################
-# Begin Project
-# PROP Target_Last_Scanned "lneato - Win32 Debug"
-CPP=cl.exe
-RSC=rc.exe
-MTL=mktyplib.exe
-
-!IF  "$(CFG)" == "lneato - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-OUTDIR=.\Release
-INTDIR=.\Release
-
-ALL : "$(OUTDIR)\lneato.exe"
-
-CLEAN :
-       -@erase "$(INTDIR)\lneato.obj"
-       -@erase "$(OUTDIR)\lneato.exe"
-
-"$(OUTDIR)" :
-    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "MSWIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /W3 /GX /O2 /D "MSWIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "MSWIN32" /D "NDEBUG" /D "_WINDOWS"\
- /Fp"$(INTDIR)/lneato.pch" /YX /Fo"$(INTDIR)/" /c
-CPP_OBJS=.\Release/
-CPP_SBRS=.\.
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /win32
-MTL_PROJ=/nologo /D "NDEBUG" /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/lneato.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
- advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
- odbccp32.lib /nologo /subsystem:windows /incremental:no\
- /pdb:"$(OUTDIR)/lneato.pdb" /machine:I386 /out:"$(OUTDIR)/lneato.exe"
-LINK32_OBJS= \
-       "$(INTDIR)\lneato.obj"
-
-"$(OUTDIR)\lneato.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-    $(LINK32) @<<
-  $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF  "$(CFG)" == "lneato - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-OUTDIR=.\Debug
-INTDIR=.\Debug
-
-ALL : "$(OUTDIR)\lneato.exe"
-
-CLEAN :
-       -@erase "$(INTDIR)\lneato.obj"
-       -@erase "$(INTDIR)\vc40.idb"
-       -@erase "$(INTDIR)\vc40.pdb"
-       -@erase "$(OUTDIR)\lneato.exe"
-       -@erase "$(OUTDIR)\lneato.ilk"
-       -@erase "$(OUTDIR)\lneato.pdb"
-
-"$(OUTDIR)" :
-    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "MSWIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "MSWIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "MSWIN32" /D "_DEBUG" /D\
- "_WINDOWS" /Fp"$(INTDIR)/lneato.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
-CPP_OBJS=.\Debug/
-CPP_SBRS=.\.
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /win32
-MTL_PROJ=/nologo /D "_DEBUG" /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/lneato.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
- advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
- odbccp32.lib /nologo /subsystem:windows /incremental:yes\
- /pdb:"$(OUTDIR)/lneato.pdb" /debug /machine:I386 /out:"$(OUTDIR)/lneato.exe"
-LINK32_OBJS= \
-       "$(INTDIR)\lneato.obj"
-
-"$(OUTDIR)\lneato.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
-    $(LINK32) @<<
-  $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-.c{$(CPP_OBJS)}.obj:
-   $(CPP) $(CPP_PROJ) $<
-
-.cpp{$(CPP_OBJS)}.obj:
-   $(CPP) $(CPP_PROJ) $<
-
-.cxx{$(CPP_OBJS)}.obj:
-   $(CPP) $(CPP_PROJ) $<
-
-.c{$(CPP_SBRS)}.sbr:
-   $(CPP) $(CPP_PROJ) $<
-
-.cpp{$(CPP_SBRS)}.sbr:
-   $(CPP) $(CPP_PROJ) $<
-
-.cxx{$(CPP_SBRS)}.sbr:
-   $(CPP) $(CPP_PROJ) $<
-
-################################################################################
-# Begin Target
-
-# Name "lneato - Win32 Release"
-# Name "lneato - Win32 Debug"
-
-!IF  "$(CFG)" == "lneato - Win32 Release"
-
-!ELSEIF  "$(CFG)" == "lneato - Win32 Debug"
-
-!ENDIF
-
-################################################################################
-# Begin Source File
-
-SOURCE=.\lneato.c
-DEP_CPP_LNEAT=\
-       {$(INCLUDE)}"\sys\stat.h"\
-       {$(INCLUDE)}"\sys\types.h"\
-
-
-"$(INTDIR)\lneato.obj" : $(SOURCE) $(DEP_CPP_LNEAT) "$(INTDIR)"
-
-
-# End Source File
-# End Target
-# End Project
-################################################################################