home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume27
/
bam
/
part02
< prev
next >
Wrap
Text File
|
1992-01-06
|
18KB
|
599 lines
Newsgroups: comp.sources.misc
From: sbo@vlsi.polymtl.ca (Stephane Boucher)
Subject: v27i069: bam - Open Look Menu System for GNU Emacs, Part02/02
Message-ID: <1992Jan6.162142.9934@sparky.imd.sterling.com>
X-Md4-Signature: 30dd90c74c21933a1a831ede25a8d235
Date: Mon, 6 Jan 1992 16:21:42 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: sbo@vlsi.polymtl.ca (Stephane Boucher)
Posting-number: Volume 27, Issue 69
Archive-name: bam/part02
Environment: Xview, Sun
#! /bin/sh
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents: bam-1.0/DOC bam-1.0/args.c bam-1.0/bam.c bam-1.0/bam.el
# bam-1.0/bam.h bam-1.0/emacs_init_addin
# bam-1.0/menus/emacs-base-ol.el bam-1.0/menus/ex1
# bam-1.0/menus/ex1.el bam-1.0/menus/latex.el bam-1.0/send.c
# Wrapped by kent@sparky on Fri Jan 3 21:06:20 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive 2 (of 2)."'
if test -f 'bam-1.0/DOC' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/DOC'\"
else
echo shar: Extracting \"'bam-1.0/DOC'\" \(2067 characters\)
sed "s/^X//" >'bam-1.0/DOC' <<'END_OF_FILE'
XCommand Line Options
X--------------------
X
Xbam [-e <error command string>] [<XView switches>] <menufile>
X
X -e <error command string>
X the command string is the string sent to
X emacs when an error is encounter durring
X the excution of bam. This string
X must contain exactly one %s which will
X be replaced by the message genarated
X by bam.
X <XView swithes>
X The program can take any XView switches,
X since it is written in XView.
X The ones that are particularly interesting
X are:
X -Wp <x> <y> for the window position
X -Wt <font name> to specify a font for
X the menus. It is recommanded to use
X a fixed font since it is easier to align
X things in the menus.
X -Ws <x-size> <y-size> to specify the window
X size. What happens is that bam fits
X buttons in the window of the size specified
X and at the end resize the window to fit
X around the already placed menu buttons.
X <menufile>
X This is the file that contains the
X description of an entire menu.
X
X
XMenu File Format
X----------------
X
XThe indentation and spacing is rather loose,
Xsince the parser is built with lex and yacc.
X
XThe basic frame format for a menu is:
X<menu file>:
XFRAME TITLE <title string> PANEL <lst_buttons> END END
X
X<lst_buttons>:
XBUTTON <button name string> <action string> <menu>
X
X<menu>:
XMENU <lst menu attributes>* <menu items>+ END
X
X<lst menu attributes>:
XTITLE <string> (NO_PUSHPIN | PUSHPIN | nothing )
X
X<menu items>:
XTEXT <menu item name string> <action string> |
XTEXT <menu item name string> <action string> <menu> |
XBITMAP <file name of bitmap string> <action string> |
XBITMAP <file name of bitmap string> <action string> <menu>
X
X
Xall type of strings must be delimited by "". To
Xhave a " or \ within a string you simply use \"
Xand \\. You can't, however, use things like \n,
X\t etc.
X
Xit is possible to write :
X"this is a
Xmulti-line string".
X
XNote that PANEL is there for future use. It is
Xat the moment useless. It is however required.
X
XOnly one FRAME or PANEL is possible per file.
X
X<action string> is a lisp expression.
X
XThe bitmap file must be an X bitmap.
END_OF_FILE
if test 2067 -ne `wc -c <'bam-1.0/DOC'`; then
echo shar: \"'bam-1.0/DOC'\" unpacked with wrong size!
fi
# end of 'bam-1.0/DOC'
fi
if test -f 'bam-1.0/args.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/args.c'\"
else
echo shar: Extracting \"'bam-1.0/args.c'\" \(1442 characters\)
sed "s/^X//" >'bam-1.0/args.c' <<'END_OF_FILE'
X/*
X bam - the Born Again Menus for GNU Emacs.
X Copyright (C) 1991 Stephane Boucher
X
X This program is free software; you can redistribute it and/or modify
X it under the terms of the GNU General Public License as published by
X the Free Software Foundation; either version 1, or (at your option)
X any later version.
X
X This program is distributed in the hope that it will be useful,
X but WITHOUT ANY WARRANTY; without even the implied warranty of
X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X GNU General Public License for more details.
X
X You should have received a copy of the GNU General Public License
X along with this program; if not, write to the Free Software
X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X*/
X/* @(#)args.c 1.4 91/11/12 */
X
X#include "bam.h"
X
Xextern char *optarg;
Xextern int optind, opterr;
X
XprocessArgs(argc, argv)
X int argc;
X char **argv;
X{
X char c;
X int errflg=0;
X
X while ((c = getopt(argc, argv, "e")) != -1)
X switch (c) {
X case 'e':
X /* -e <error_format>
X Specify the error format where <error_format>
X is a format string like printf format with
X one %s */
X
X errorFormat=optarg;
X break;
X
X case '?':
X default:
X errflg++;
X break;
X }
X
X if (errflg || optind+1!=argc) {
X sendErrorToEmacs("usage: \n\
X\t%s [-e <error_format>] menu_file\n", argv[0]);
X exit (2);
X }
X
X menuFile=argv[optind];
X}
END_OF_FILE
if test 1442 -ne `wc -c <'bam-1.0/args.c'`; then
echo shar: \"'bam-1.0/args.c'\" unpacked with wrong size!
fi
# end of 'bam-1.0/args.c'
fi
if test -f 'bam-1.0/bam.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/bam.c'\"
else
echo shar: Extracting \"'bam-1.0/bam.c'\" \(1826 characters\)
sed "s/^X//" >'bam-1.0/bam.c' <<'END_OF_FILE'
X/*
X bam - the Born Again Menus for GNU Emacs.
X Copyright (C) 1991 Stephane Boucher
X
X This program is free software; you can redistribute it and/or modify
X it under the terms of the GNU General Public License as published by
X the Free Software Foundation; either version 1, or (at your option)
X any later version.
X
X This program is distributed in the hope that it will be useful,
X but WITHOUT ANY WARRANTY; without even the implied warranty of
X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X GNU General Public License for more details.
X
X You should have received a copy of the GNU General Public License
X along with this program; if not, write to the Free Software
X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X*/
X/* @(#)bam.c 1.5 91/11/12 */
X
X#include <unistd.h>
X
X#include "bam.h"
X
Xchar *menuFile=NULL;
Xchar *errorFormat="(command-process-error \"%s\")";
XFrame baseFrame;
X
X
Xmain(argc, argv)
X int argc;
X char **argv;
X{
X int exitVal=0;
X
X xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
X
X processArgs(argc, argv);
X
X if (access(menuFile, R_OK) == 0 ) {
X /* Menu File accessible */
X
X yyin=fopen(menuFile, "r");
X
X if (!yyparse()) {
X window_main_loop(baseFrame);
X }
X else {
X /* A parse error has occured */
X exitVal=1;
X }
X
X fclose(yyin);
X }
X else {
X /* Menu File not accessible */
X sendErrorToEmacs("Unaccessable File: %s\n", menuFile);
X exitVal=1;
X }
X
X return(exitVal);
X}
X
X
X
Xvoid
XmenuProc (menu, menuItem)
X Menu menu;
X Menu_item menuItem;
X{
X sendToEmacs( (char *)xv_get(menuItem,
X XV_KEY_DATA, M_COMMAND_STRING));
X}
X
Xint
Xselected(item, event)
XPanel_item item;
XEvent *event;
X{
X sendToEmacs((char *)xv_get(item,
X XV_KEY_DATA, M_COMMAND_STRING));
X return XV_OK;
X}
X
X
END_OF_FILE
if test 1826 -ne `wc -c <'bam-1.0/bam.c'`; then
echo shar: \"'bam-1.0/bam.c'\" unpacked with wrong size!
fi
# end of 'bam-1.0/bam.c'
fi
if test -f 'bam-1.0/bam.el' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/bam.el'\"
else
echo shar: Extracting \"'bam-1.0/bam.el'\" \(316 characters\)
sed "s/^X//" >'bam-1.0/bam.el' <<'END_OF_FILE'
X(require 'command-process)
X(load-library "bytecomp")
X
X(defun strings-to-buffer (string1 string2)
X "*Inserts STRING1 and STRING2 in current buffer, puts point after STRING1."
X (insert string1)
X (let ((newpoint (point)))
X (insert string2)
X (goto-char newpoint)))
X
X(byte-compile (function strings-to-buffer))
X
END_OF_FILE
if test 316 -ne `wc -c <'bam-1.0/bam.el'`; then
echo shar: \"'bam-1.0/bam.el'\" unpacked with wrong size!
fi
# end of 'bam-1.0/bam.el'
fi
if test -f 'bam-1.0/bam.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/bam.h'\"
else
echo shar: Extracting \"'bam-1.0/bam.h'\" \(1683 characters\)
sed "s/^X//" >'bam-1.0/bam.h' <<'END_OF_FILE'
X/*
X bam - the Born Again Menus for GNU Emacs.
X Copyright (C) 1991 Stephane Boucher
X
X This program is free software; you can redistribute it and/or modify
X it under the terms of the GNU General Public License as published by
X the Free Software Foundation; either version 1, or (at your option)
X any later version.
X
X This program is distributed in the hope that it will be useful,
X but WITHOUT ANY WARRANTY; without even the implied warranty of
X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X GNU General Public License for more details.
X
X You should have received a copy of the GNU General Public License
X along with this program; if not, write to the Free Software
X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X*/
X/* @(#)bam.h 1.5 91/11/12 */
X
X#ifndef _EMENU_H_
X#define _EMENU_H_
X
X#include <xview/xview.h>
X#include <xview/frame.h>
X#include <xview/panel.h>
X#include <xview/openmenu.h>
X
X#include <stdio.h>
X
X/* ---------------------------------- */
X
Xtypedef struct {
X struct {
X int pushpin;
X char *title;
X } attr;
X Menu id;
X Menu prevCur; /* Previous current menu */
X} MenuData;
X
X
X/* ---------------------------------- */
X/* Fonction Prototypes */
X
Xvoid sendToEmacs();
Xvoid sendErrorToEmacs();
X
Xvoid menuProc();
Xint selected();
X
Xint processArgs();
X
Xvoid initMenuData();
Xint setMenu();
X
X/* ---------------------------------- */
X
X#define TRUE 1
X#define FALSE 0
X
X#define M_COMMAND_STRING 100
X
X#define M_NO_PUSHPIN 0
X#define M_PUSHPIN 1
X
X/* ---------------------------------- */
X/* Global variables */
Xextern FILE *yyin;
Xextern char *menuFile;
Xextern char *errorFormat;
X
X#endif
END_OF_FILE
if test 1683 -ne `wc -c <'bam-1.0/bam.h'`; then
echo shar: \"'bam-1.0/bam.h'\" unpacked with wrong size!
fi
# end of 'bam-1.0/bam.h'
fi
if test -f 'bam-1.0/emacs_init_addin' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/emacs_init_addin'\"
else
echo shar: Extracting \"'bam-1.0/emacs_init_addin'\" \(788 characters\)
sed "s/^X//" >'bam-1.0/emacs_init_addin' <<'END_OF_FILE'
X(if (eq window-system 'x)
X (progn
X ;; get ready to load various menus
X (load-library "bam")
X
X ;; Change those 2 (*bam-..-dir*) variables to reflect your setup
X (setq *bam-exec-dir* "/usr/users/sboucher/gegi/emenu")
X
X ;; The *bam-menu-dir* variable is only necessary when you
X ;; load a menu. Therefore you can change it between each
X ;; load-file call to load menus from different directories.
X (setq *bam-menu-dir* "/usr/users/sboucher/gegi/emenu/menus")
X
X ;; Load various menus
X (load-file (concat *bam-menu-dir* "/emacs-base-ol.el"))
X (load-file (concat *bam-menu-dir* "/ex1.el"))
X (load-file (concat *bam-menu-dir* "/latex.el"))
X
X ;; Pop various menus
X (emacs-menu)
X (ex1-menu)
X (latex-menu)))
X
END_OF_FILE
if test 788 -ne `wc -c <'bam-1.0/emacs_init_addin'`; then
echo shar: \"'bam-1.0/emacs_init_addin'\" unpacked with wrong size!
fi
# end of 'bam-1.0/emacs_init_addin'
fi
if test -f 'bam-1.0/menus/emacs-base-ol.el' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/menus/emacs-base-ol.el'\"
else
echo shar: Extracting \"'bam-1.0/menus/emacs-base-ol.el'\" \(358 characters\)
sed "s/^X//" >'bam-1.0/menus/emacs-base-ol.el' <<'END_OF_FILE'
X(setq *bam-emacs-menu-dir* *bam-menu-dir*)
X(defun emacs-menu ()
X (interactive)
X (process-kill-without-query
X (command-process (concat *bam-exec-dir* "/bam")
X "-Wp" "0" "0" ; position of window
X "-Wt" "7x14" ; font
X "-Ws" "1000" "300" ;window size
X (concat *bam-emacs-menu-dir* "/emacs-base-ol") ;Menu filename
X )))
END_OF_FILE
if test 358 -ne `wc -c <'bam-1.0/menus/emacs-base-ol.el'`; then
echo shar: \"'bam-1.0/menus/emacs-base-ol.el'\" unpacked with wrong size!
fi
# end of 'bam-1.0/menus/emacs-base-ol.el'
fi
if test -f 'bam-1.0/menus/ex1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/menus/ex1'\"
else
echo shar: Extracting \"'bam-1.0/menus/ex1'\" \(866 characters\)
sed "s/^X//" >'bam-1.0/menus/ex1' <<'END_OF_FILE'
XFRAME
XTITLE "Emacs Menu example 1"
X PANEL
X BUTTON "Menu button 1" "(message \"button action 1\")"
X MENU
X TITLE "Menu 1"
X BITMAP "/usr/openwin/lib/bitmaps/c10pinin" "(message \"This is a bitmap item\")"
X TEXT "Text item" "(message \"This is a text item\")"
X BITMAP "/usr/openwin/lib/bitmaps/stones" "(message \"action bitmap\")"
X END
X BUTTON "Menu Button 2" "(message \"button action 2\")"
X MENU
X TITLE "Menu 2"
X TEXT "text item 2" "(message \"text item action\")"
X MENU
X TEXT "item 3" "(message \"action\")"
X TEXT "item 4" "(message \"action\")"
X END
X BITMAP "/usr/openwin/lib/bitmaps/grune" "(message \"action bitmap\")"
X MENU NO_PUSHPIN
X TITLE "Menu 3"
X TEXT "item 5" "(message \"action\")"
X TEXT "item 6" "(message \"action\")"
X END
X BITMAP "/usr/openwin/lib/bitmaps/nights" "(message \"action bitmap\")"
X END
X END
XEND
END_OF_FILE
if test 866 -ne `wc -c <'bam-1.0/menus/ex1'`; then
echo shar: \"'bam-1.0/menus/ex1'\" unpacked with wrong size!
fi
# end of 'bam-1.0/menus/ex1'
fi
if test -f 'bam-1.0/menus/ex1.el' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/menus/ex1.el'\"
else
echo shar: Extracting \"'bam-1.0/menus/ex1.el'\" \(328 characters\)
sed "s/^X//" >'bam-1.0/menus/ex1.el' <<'END_OF_FILE'
X(setq *bam-ex1-menu-dir* *bam-menu-dir*)
X(defun ex1-menu ()
X (interactive)
X (process-kill-without-query
X (command-process (concat *bam-exec-dir* "/bam")
X "-Wp" "0" "0" ; position of window
X "-Wt" "7x14" ; font
X "-Ws" "1000" "300" ;window size
X (concat *bam-ex1-menu-dir* "/ex1") ;Menu filename
X )))
END_OF_FILE
if test 328 -ne `wc -c <'bam-1.0/menus/ex1.el'`; then
echo shar: \"'bam-1.0/menus/ex1.el'\" unpacked with wrong size!
fi
# end of 'bam-1.0/menus/ex1.el'
fi
if test -f 'bam-1.0/menus/latex.el' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/menus/latex.el'\"
else
echo shar: Extracting \"'bam-1.0/menus/latex.el'\" \(336 characters\)
sed "s/^X//" >'bam-1.0/menus/latex.el' <<'END_OF_FILE'
X(setq *bam-latex-menu-dir* *bam-menu-dir*)
X(defun latex-menu ()
X (interactive)
X (process-kill-without-query
X (command-process (concat *bam-exec-dir* "/bam")
X "-Wp" "0" "0" ; position of window
X "-Wt" "7x14" ; font
X "-Ws" "1000" "300" ;window size
X (concat *bam-latex-menu-dir* "/latex") ;Menu filename
X )))
END_OF_FILE
if test 336 -ne `wc -c <'bam-1.0/menus/latex.el'`; then
echo shar: \"'bam-1.0/menus/latex.el'\" unpacked with wrong size!
fi
# end of 'bam-1.0/menus/latex.el'
fi
if test -f 'bam-1.0/send.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'bam-1.0/send.c'\"
else
echo shar: Extracting \"'bam-1.0/send.c'\" \(1328 characters\)
sed "s/^X//" >'bam-1.0/send.c' <<'END_OF_FILE'
X/*
X bam - the Born Again Menus for GNU Emacs.
X Copyright (C) 1991 Stephane Boucher
X
X This program is free software; you can redistribute it and/or modify
X it under the terms of the GNU General Public License as published by
X the Free Software Foundation; either version 1, or (at your option)
X any later version.
X
X This program is distributed in the hope that it will be useful,
X but WITHOUT ANY WARRANTY; without even the implied warranty of
X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
X GNU General Public License for more details.
X
X You should have received a copy of the GNU General Public License
X along with this program; if not, write to the Free Software
X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X*/
X/* @(#)send.c 1.5 91/11/12 */
X
X#include <stdio.h>
X#include <varargs.h>
X
X#include "bam.h"
X
X
Xvoid sendToEmacs(command)
X char *command;
X{
X fprintf(stdout, "%s", command);
X fflush(stdout);
X}
X
Xvoid sendErrorToEmacs(va_alist)
Xva_dcl
X{
X char tmpStr[4096+1]; /* Temporary string to
X construct the error
X string to send to emacs */
X va_list pvar;
X char *format;
X
X va_start(pvar);
X format=va_arg(pvar, char *);
X vsprintf(tmpStr, format, pvar);
X va_end(pvar);
X
X fprintf(stdout, errorFormat, tmpStr);
X
X fflush(stdout);
X}
END_OF_FILE
if test 1328 -ne `wc -c <'bam-1.0/send.c'`; then
echo shar: \"'bam-1.0/send.c'\" unpacked with wrong size!
fi
# end of 'bam-1.0/send.c'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked both archives.
rm -f ark[1-9]isdone
else
echo You still must unpack the following archives:
echo " " ${MISSING}
fi
exit 0
exit 0 # Just in case...