Article View: gnu.epoch.misc
Article #1570Re: popup menu for Epoch with OpenWindows
From: Dev Joneja
Date: Thu, 20 Feb 1992 14:58
Date: Thu, 20 Feb 1992 14:58
415 lines
13103 bytes
13103 bytes
Here it is. I am posting it since over a dozen people asked for it.
It should work both with epoch and xemacs.
(I have only used it with epoch-3.2 and epoch 4.0)
****************************************cut here*****************
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# README
# Makefile
# xvmenu.c
# xvmenu.1
# This archive created: Thu Feb 20 09:45:07 1992
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'README'" '(3380 characters)'
if test -f 'README'
then
echo shar: "will not over-write existing file 'README'"
else
sed 's/^ X//' << \SHAR_EOF > 'README'
Xxvmenu: popup menus for epoch and xemacs using XView.
X
X***************************************
XINSTALLATION
X***************************************
XUse the supplied makefile, or by hand, compile with
X cc xvmenu.c -o xvmenu -lxview -lolgx -lX11
XYou may need to put in the include path in the compilation command
X(for openwindows, it would be -I/usr/openwin/include).
X
XPut the executable somewhere on your path, the manual page (xvmenu.1)
Xwherever you put these things, and you are set to go.
X
X***************************************
XUSAGE
X***************************************
XI use this code with epoch-4.0, though it should also work fine with
Xxemacs. In epoch-4.0, I use the following code segment in my .emacs
Xfile. The operative funcions are interpret-output and make-menu, which
XI invoke by clicking the middle mouse button one the mode line. I also
Xinclude below the code segments that allow me to use this to
Xinteractively set fonts.
X
X(global-set-mouse mouse-mode-middle mouse-up 'make-menu)
X
X(defun interpret-output (process output)
X (command-execute (intern-soft output)))
X
X(defun make-menu (foo)
X (interactive)
X (set-process-filter (start-process "xvmenu" nil
X "xvmenu" "-Wl" "Epoch-Menu"
X "-WL" "Epoch"
X "Save Buffer" "save-buffer"
X "Buffer Menu" "list-buffers"
X "Dired" "dired"
X "Read Mail" "rmail"
X "Fonts..." "START"
X "Larger font" "set-bigger-font"
X "Smaller font" "set-smaller-font"
X "Fonts..." "END"
X "Help..." "START"
X "Describe key" "describe-key"
X "Describe function" "describe-function"
X "Where is this cmd" "where-is"
X "Command apropos" "apropos"
X "Describe mode" "describe-mode"
X "Help..." "END")
X 'interpret-output))
X
X
X(setq mouse-font-list
X (list
X "-adobe-courier-medium-o-normal--8-80-75-75-m-50-iso8859-1"
X "-adobe-courier-bold-o-normal--10-100-75-75-m-60-iso8859-1"
X "-adobe-courier-bold-r-normal--12-120-75-75-m-70-iso8859-1"
X "-adobe-courier-medium-r-normal--14-140-75-75-m-90-iso8859-1"
X "screen.r.16"
X "screen.b.16"
X "-adobe-courier-medium-r-normal--18-180-75-75-m-110-iso8859-1"
X "-adobe-courier-bold-r-normal--18-180-75-75-m-110-iso8859-1"
X "-adobe-courier-medium-r-normal--24-240-75-75-m-150-iso8859-1"
X )
X)
X
X(defvar current-font-in-list 5)
X(setq current-font-in-list 5)
X
X(defun set-smaller-font ()
X"Pick a smaller font from list of defaults."
X (interactive)
X (if (equal current-font-in-list 0)
X (error "If you can read this, you are too close.")
X (setq current-font-in-list (1- current-font-in-list))
X (font (nth current-font-in-list mouse-font-list))
X )
X)
X
X(defun set-bigger-font ()
X"Pick a biger font from the list of defaults."
X (interactive)
X (if (equal current-font-in-list (1- (length mouse-font-list)))
X (error "The font is as big as it gets!")
X (setq current-font-in-list (1+ current-font-in-list))
X (font (nth current-font-in-list mouse-font-list))
X )
X)
X
X***************************************
XDISCLAIMER
X***************************************
XThis code is provided as is, with no explicit or implied warranties.
XIt works for me; you may do what you wish with it. If you make any
Xchanges or have any enhancements, I'd appreciate a copy.
X
XDev Joneja, dj7@cunixf.cc.columbia.edu, Feb., 1992
X
X
SHAR_EOF
if test 3380 -ne "`wc -c < 'README'`"
then
echo shar: "error transmitting 'README'" '(should have been 3380 characters)'
fi
fi
echo shar: "extracting 'Makefile'" '(337 characters)'
if test -f 'Makefile'
then
echo shar: "will not over-write existing file 'Makefile'"
else
sed 's/^ X//' << \SHAR_EOF > 'Makefile'
X#
X# Makefile for xvmenu
X# Change the paths below if needed
X#
X#
XINCLUDE = -I${OPENWINHOME}/include
XCFLAGS = ${INCLUDE} -O
XXVIEW_LIBS = -L${OPENWINHOME}/lib -lxview -lolgx -lX11
X
XCFILES = xvmenu.c
XOBJS = xvmenu
Xall: ${OBJS}
X
X${OBJS}: $$@.c $$@.o
X ${CC} ${CFLAGS} ${LDFLAGS} -o $@ $@.o ${XVIEW_LIBS}
X
Xclean:
X rm -f core ${OBJS} *.o
SHAR_EOF
if test 337 -ne "`wc -c < 'Makefile'`"
then
echo shar: "error transmitting 'Makefile'" '(should have been 337 characters)'
fi
fi
echo shar: "extracting 'xvmenu.c'" '(3148 characters)'
if test -f 'xvmenu.c'
then
echo shar: "will not over-write existing file 'xvmenu.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'xvmenu.c'
X/* xvmenu.c: popup menus for epoch and xemacs using XView.
X
X It take arguments of the form "label string"
X and "label START sublabel1 string1 sublabel2 string2 ... label END"
X and create a panel with buttons named "label" that when pressed,
X output the corresponding "string". The sub- mechanism allows for
X one level of pullright menus. Note that START and END are case-
X sensitive.
X
X Writer: Dev Joneja, dj7@cunixf.cc.columbia.edu, 2/16/92
X
X Disclaimer: I take no reponsibility for what this program does. Change
X it if you wish, but drop me a note and your changes.
X
X Compile with: cc xvmenu.c -o xvmenu -lxview -lolgx -lX11
X
X */
X
X#include <stdio.h>
X#include <xview/xview.h>
X#include <xview/panel.h>
X#include <xview/frame.h>
X
XFrame frame;
X
Xvoid
Xquit()
X{
X xv_destroy_safe(frame);
X}
X
X
Xint
Xitem_proc(item, event)
XPanel_item item;
XEvent *event;
X{
X printf("%s", xv_get(item, PANEL_CLIENT_DATA));
X fflush(stdout);
X return XV_OK;
X}
X
X
Xint
Xmenu_proc(menu, menu_item)
XMenu menu;
XMenu_item menu_item;
X{
X/* if (strcmp((char *)xv_get(menu_item, MENU_STRING), "Quit") == 0)
X exit(0); */
X printf("%s", xv_get(menu_item, MENU_CLIENT_DATA));
X fflush(stdout);
X return XV_OK;
X}
X
XMenu
Xcreate_menu(intptr, argv)
Xint *intptr;
Xchar *argv[];
X{
X int i;
X Menu_item mi;
X Menu menu;
X
X i = *intptr;
X menu = (Menu) xv_create(NULL, MENU,
X MENU_GEN_PIN_WINDOW, frame, argv[i],
X NULL);
X i += 2;
X
X while (strcmp(argv[i+1], "END") != 0) {
X mi = (Menu_item)xv_create(NULL, MENUITEM,
X MENU_STRING, argv[i],
X MENU_NOTIFY_PROC, menu_proc,
X MENU_CLIENT_DATA, argv[i+1],
X MENU_RELEASE,
X NULL);
X xv_set(menu, MENU_APPEND_ITEM, mi, NULL);
X i += 2;
X }
X
X/* To put a quit on each menu, uncomment the following lines */
X/* mi = (Menu_item)xv_create(NULL, MENUITEM,
X MENU_STRING, "Quit",
X MENU_NOTIFY_PROC, quit,
X MENU_RELEASE,
X NULL);
X xv_set(menu, MENU_APPEND_ITEM, mi, NULL); */
X
X *intptr = i;
X return menu;
X}
X
X
X
Xmain (argc, argv)
Xint argc;
Xchar *argv[];
X{
X Menu menu;
X Panel panel;
X Panel_item item;
X void quit();
X int i = 1;
X int submenu = 0;
X
X xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
X frame = (Frame)xv_create (NULL, FRAME,
X FRAME_LABEL, argv[0],
X NULL);
X panel = (Panel)xv_create (frame, PANEL,
X PANEL_LAYOUT, PANEL_VERTICAL,
X NULL);
X
X if (argc%2 != 1) {
X printf ("\nincorrect number of arguments\n");
X exit(0);
X }
X
X while (i < argc) {
X if (strcmp(argv[i+1], "START") == 0)
X menu = create_menu(&i, argv);
X if (strcmp(argv[i+1], "END") == 0)
X (void) xv_create (panel, PANEL_BUTTON,
X PANEL_LABEL_STRING, argv[i],
X PANEL_NOTIFY_PROC, item_proc,
X PANEL_ITEM_MENU, menu,
X PANEL_CLIENT_DATA, "",
X NULL);
X else
X (void) xv_create (panel, PANEL_BUTTON,
X PANEL_LABEL_STRING, argv[i],
X PANEL_NOTIFY_PROC, item_proc,
X PANEL_CLIENT_DATA, argv[i+1],
X NULL);
X i += 2;
X }
X
X (void) xv_create (panel, PANEL_BUTTON,
X PANEL_LABEL_STRING, "Quit",
X PANEL_NOTIFY_PROC, quit,
X PANEL_CLIENT_DATA, frame,
X NULL);
X
X window_fit(panel);
X window_fit(frame);
X xv_main_loop(frame);
X}
X
X
X
X
X
X
X
X
X
SHAR_EOF
if test 3148 -ne "`wc -c < 'xvmenu.c'`"
then
echo shar: "error transmitting 'xvmenu.c'" '(should have been 3148 characters)'
fi
fi
echo shar: "extracting 'xvmenu.1'" '(2515 characters)'
if test -f 'xvmenu.1'
then
echo shar: "will not over-write existing file 'xvmenu.1'"
else
sed 's/^ X//' << \SHAR_EOF > 'xvmenu.1'
X.TH XVMENU l "19 Feb. 1992"
X.SH NAME
Xxvmenu \- provide simple popup menus for Epoch, xemacs, and shell scripts.
X.SH SYNOPSIS
X\fBxvmenu\fP argument-list
X.SH DESCRIPTION
X\fIxvmenu\fP provides a quick and easy way of producing popup menus
Xwith buttons, primarily for use with Epoch and xemacs. It is based on
Xthe XView toolkit. It could also be used with shell scripts.
X
X.nf
XThe argument list is of the form:
X button-label-1 string-1 button-label-2 string-2 ...
Xand:
X button-name START button-1 string-1 button-2 string-2 ...
X button-name END
X.fi
X
XThe first form creates a menu with buttons labelled button-label-1
Xetc. Pressing any of these buttons outputs the corresponding string.
XThe second form creates a button labelled button-name, with a
Xpull-right menu that can be pinned. The menu has buttons labelled
Xbutton-1 etc. with similar functionality.
X
XThe two forms of argument-list can be mixed. However, only one level
Xof pull-right menus is currently possible. So a START ... END sequence
Xwithin another such sequence will have unexpected results.
X
XStandard XView command line options can be used.
X
X.SH EXAMPLES
X.DS
Xxvmenu Hello "Hello World" \\
X Bye START Bye-1 goodbye Bye-2 "Goodbye World" Bye END\\
X WhatsUp "What's up, Doc"
X
XFrom within Epoch and xemacs, xvmenu can be called as an argument to
Xthe start-process command to get buttons with commands attached to them.
XOne can attatch the command make-menu below
Xto a mouse key, and then use the mouse on the menu buttons.
X
X.nf
X(defun interpret-output (process output)
X (command-execute (intern-soft output)))
X
X(defun make-menu (foo)
X (interactive)
X (set-process-filter (start-process "xvmenu" nil
X "xvmenu" "-Wl" "Epoch-Menu"
X "-WL" "Epoch"
X "Save Buffer" "save-buffer"
X "Buffer Menu" "list-buffers"
X "Dired" "dired"
X "Read Mail" "rmail"
X "Fonts..." "START"
X "Larger font" "set-bigger-font"
X "Smaller font" "set-smaller-font"
X "Fonts..." "END"
X "Help..." "START"
X "Describe key" "describe-key"
X "Describe function" "describe-function"
X "Where is this cmd" "where-is"
X "Command apropos" "apropos"
X "Describe mode" "describe-mode"
X "Help..." "END")
X 'interpret-output))
X.fi
X.DE
X.SH BUGS
XThe key words START and END are case sensitive. The program has only
Xbeen tested on a SunIPC with SunOS 4.1.1.
X.SH AUTHOR
XDev Joneja, Columbia Business School, Feb. 1992
X.br
Xdj7@cunixf.cc.columbia.edu
X
X
SHAR_EOF
if test 2515 -ne "`wc -c < 'xvmenu.1'`"
then
echo shar: "error transmitting 'xvmenu.1'" '(should have been 2515 characters)'
fi
fi
exit 0
# End of shell archive
Technical Details
Message-ID:
<1992Feb20.145820.1262@cunixf.cc.columbia.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!cunixf.cc.columbia.edu!dj7References:
<9202192006.AA07029@banach.math.ep.utexas.edu> <1992Feb20.001916.13410@cunixf.cc.columbia.edu> <JWG1.92Feb20092617@harvey.gte.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc7ee,c5913914d52d11b4 X-Google-Attributes: gidfc7ee,public X-Google-ArrivalTime: 1992-02-20 09:16:51 PST Newsgroups: gnu.epoch.misc Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!cunixf.cc.columbia.edu!dj7 From: dj7@cunixf.cc.columbia.edu (Dev Joneja) Subject: Re: popup menu for Epoch with OpenWindows Message-ID: <1992Feb20.145820.1262@cunixf.cc.columbia.edu> Reply-To: dj7@cunixf.cc.columbia.edu (Dev Joneja) Organization: Columbia University References: <9202192006.AA07029@banach.math.ep.utexas.edu> <1992Feb20.001916.13410@cunixf.cc.columbia.edu> <JWG1.92Feb20092617@harvey.gte.com> Distribution: gnu Date: Thu, 20 Feb 1992 14:58:20 GMT