home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-02-03 | 43.5 KB | 1,808 lines |
- Path: xanth!mcnc!ncsuvx!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!necntc!ncoast!allbery
- From: BLARSON@ECLA.USC.EDU (Bob Larson)
- Newsgroups: comp.sources.misc
- Subject: v03i039: mg 2a part 15 of 15
- Message-ID: <12401571940.21.BLARSON@ECLA.USC.EDU>
- Date: 27 May 88 05:49:18 GMT
- Sender: allbery@ncoast.UUCP
- Reply-To: BLARSON@ECLA.USC.EDU (Bob Larson)
- Lines: 1795
- Approved: allbery@ncoast.UUCP
-
- comp.sources.misc: Volume 3, Issue 39
- Submitted-By: "Bob Larson" <BLARSON@ECLA.USC.EDU>
- Archive-Name: mg2a/Part15
-
- # This is a shell archive.
- # Remove everything above and including the cut line.
- # Then run the rest of the file through sh.
- #----cut here-----cut here-----cut here-----cut here----#
- #!/bin/sh
- # shar: Shell Archiver
- # Run the following text with /bin/sh to create:
- # sys/vms/ttyio.c
- # sys/vms/mgmailedit.com
- # sys/atari/maketop.mwc
- # sys/atari/chrdef.h
- # sys/amiga/ttykbd.c
- # sys/amiga/ttymenu.c
- # sys/amiga/ttymouse.c
- # sys/amiga/varargs.h
- # sys/amiga/iconify/iconify.c
- # sys/amiga/iconify/iconify.h
- # This archive created: Mon May 23 18:14:27 1988
- # By: blarson
- if test -d sys
- then true
- else mkdir sys
- fi
- if test -d sys/atari
- then true
- else mkdir sys/atari
- fi
- if test -d sys/vms
- then true
- else mdkir sys/vms
- fi
- if test -d sys/amiga
- then true
- else mkdir sys/amiga
- fi
- cat << \SHAR_EOF > sys/vms/ttyio.c
- /*
- * Name: MicroGnuEmacs
- * VAX/VMS terminal I/O.
- * o 16-Apr-86 ...!ihnp4!seismo!ut-sally!ut-ngp!mic
- * Turn off TTSYNC so ^S and ^Q are sent to program.
- * To get this back, compile with -DFLOWCONTROL
- * o 10-Jul-86 ...!ihnp4!seismo!ut-sally!ut-ngp!mic
- * Add setttysize(), typeahead() and panic() for Gnu v30
- * o 21-Jul-87 ...!ihnp4!seismo!ut-sally!ut-ngp!mic
- * Use transmit speed from iosb instead of receive, which
- * is only valid if different from the transmit speed...
- */
- #include "def.h"
-
- #include <stsdef.h>
- #include <ssdef.h>
- #include <descrip.h>
- #include <iodef.h>
- #include <ttdef.h>
- #include <tt2def.h>
-
- #define NIBUF 128 /* Probably excessive. */
- #define NOBUF 512 /* Not too big for 750/730. */
- #define EFN 0 /* Event flag */
-
- char obuf[NOBUF]; /* Output buffer */
- int nobuf; /* # of bytes in above */
- char ibuf[NIBUF]; /* Input buffer */
- int nibuf; /* # of bytes in above */
- int ibufi; /* Read index */
- int oldmode[3]; /* Old TTY mode bits */
- int newmode[3]; /* New TTY mode bits */
- short iochan; /* TTY I/O channel */
- int nrow; /* Terminal size, rows. */
- int ncol; /* Terminal size, columns. */
- short ospeed; /* Terminal output speed */
- /* for termcap library */
-
- /*
- * This routines gets called once, to set up the
- * terminal channel.
- * On VMS we find the translation of the SYS$COMMAND:
- * logical name, assign a channel to it, and set it raw.
- */
-
- ttopen()
- {
- struct dsc$descriptor idsc;
- struct dsc$descriptor odsc;
- char oname[40];
- int iosb[2];
- int status;
-
- odsc.dsc$a_pointer = "SYS$COMMAND";
- odsc.dsc$w_length = strlen(odsc.dsc$a_pointer);
- odsc.dsc$b_dtype = DSC$K_DTYPE_T;
- odsc.dsc$b_class = DSC$K_CLASS_S;
- idsc.dsc$b_dtype = DSC$K_DTYPE_T;
- idsc.dsc$b_class = DSC$K_CLASS_S;
- do {
- idsc.dsc$a_pointer = odsc.dsc$a_pointer;
- idsc.dsc$w_length = odsc.dsc$w_length;
- odsc.dsc$a_pointer = &oname[0];
- odsc.dsc$w_length = sizeof(oname);
- status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc);
- if (status!=SS$_NORMAL && status!=SS$_NOTRAN)
- exit(status);
- if (oname[0] == 0x1B) {
- odsc.dsc$a_pointer += 4;
- odsc.dsc$w_length -= 4;
- }
- } while (status == SS$_NORMAL);
- status = SYS$ASSIGN(&odsc, &iochan, 0, 0);
- if (status != SS$_NORMAL)
- exit(status);
- status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0,
- oldmode, sizeof(oldmode), 0, 0, 0, 0);
- if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
- exit(status);
-
- nrow = (oldmode[1]>>24) & 0xFF; /* Terminal length. */
- if (nrow > NROW)
- nrow = NROW;
- ncol = (oldmode[0]>>16) & 0xFFFF; /* Width. */
- if (ncol > NCOL)
- ncol = NCOL;
- ospeed = (iosb[0]>>16) & 0xFF; /* Speed (for termcap) */
- newmode[0] = oldmode[0]; /* Only in version 4. */
- #ifdef FLOWCONTROL
- newmode[1] = oldmode[1] | TT$M_NOECHO | TT$M_TTSYNC;
- #else
- newmode[1] = (oldmode[1] | TT$M_NOECHO) & ~TT$M_TTSYNC;
- #endif
- newmode[2] = oldmode[2] | TT2$M_PASTHRU;
- status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
- newmode, sizeof(newmode), 0, 0, 0, 0);
-
- if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
- exit(status);
- }
-
- /*
- * This function gets called just
- * before we go back home to the command interpreter.
- * On VMS it puts the terminal back in a reasonable state.
- */
- ttclose()
- {
- int status;
- int iosb[2];
-
- ttflush();
- status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
- oldmode, sizeof(oldmode), 0, 0, 0, 0);
- if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
- exit(status);
- status = SYS$DASSGN(iochan);
- if (status != SS$_NORMAL)
- exit(status);
- }
-
- /*
- * Write a character to the display.
- * On VMS, terminal output is buffered, and
- * we just put the characters in the big array,
- * after checking for overflow.
- */
- ttputc(c)
- {
- if (nobuf >= NOBUF)
- ttflush();
- obuf[nobuf++] = c;
- }
-
- /*
- * This function does the real work of
- * flushing out buffered I/O on VMS. All
- * we do is blast out the block with a write call. No status
- * checking is done on the write, because there isn't anything
- * clever that can be done, and because you will see the
- * error as a messed up screen.
- */
- ttflush()
- {
- int iosb[2];
-
- if (nobuf != 0) {
- SYS$QIOW(EFN, iochan, IO$_WRITELBLK|IO$M_NOFORMAT,
- iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0);
- nobuf = 0;
- }
- }
-
- /*
- * Read a character from the terminal,
- * performing no editing and doing no echo at all.
- * More complex in VMS that almost anyplace else,
- * which figures.
- */
- ttgetc()
- {
- int status;
- int iosb[2];
- int term[2];
-
- term[0] = 0;
- term[1] = 0;
- while (ibufi >= nibuf) {
- ibufi = 0;
- status = SYS$QIOW(EFN, iochan, IO$_READLBLK|IO$M_TIMED,
- iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0);
- if (status != SS$_NORMAL)
- continue;
- status = iosb[0] & 0xFFFF;
- if (status!=SS$_NORMAL && status!=SS$_TIMEOUT)
- continue;
- nibuf = (iosb[0]>>16) + (iosb[1]>>16);
- if (nibuf == 0) {
- status = SYS$QIOW(EFN, iochan, IO$_READLBLK,
- iosb, 0, 0, ibuf, 1, 0, term, 0, 0);
- if (status != SS$_NORMAL)
- continue;
- if ((iosb[0]&0xFFFF) != SS$_NORMAL)
- continue;
- nibuf = (iosb[0]>>16) + (iosb[1]>>16);
- }
- }
- return (ibuf[ibufi++] & 0xFF);
- }
-
- /*
- * Internal check for new terminal size.
- * Do this *before* setting terminal modes, so
- * the size changes are kept when.
- */
- ckttysize()
- {
- int status, mode[3], iosb[2], wid, len;
-
- status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0,
- mode, sizeof(mode), 0, 0, 0, 0);
- if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
- panic("ckttsize: can't sense terminal modes!");
-
- /* save new page length */
- len = (mode[1] >> 24) & 0xFF;
- oldmode[1] = (oldmode[1] & 0x00FFFFFF) | (len << 24);
- newmode[1] = (newmode[1] & 0x00FFFFFF) | (len << 24);
-
- /* save new page width */
- wid = (mode[0] >> 16) & 0xFF;
- oldmode[0] = (oldmode[0] & 0x0000FFFF) | (wid << 16);
- newmode[0] = (newmode[0] & 0x0000FFFF) | (wid << 16);
- }
-
- /*
- * Tell Emacs how big the terminal is now,
- * making sure the page size is in the range
- * 1..NROW.
- */
-
- setttysize()
- {
- nrow = (newmode[1]>>24) & 0xFF; /* Length. */
- if (nrow > NROW)
- nrow = NROW;
-
- ncol = (newmode[0]>>16) & 0xFFFF; /* Width. */
- if (ncol > NCOL)
- ncol = NCOL;
- }
-
- /*
- * Return the number of characters in the
- * typeahead buffer.
- */
-
- typeahead()
- {
- int status, SYS$QIOW(), iosb[2], mode[2];
-
- status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE|IO$M_TYPEAHDCNT,
- iosb, 0, 0, mode, sizeof(mode), 0, 0, 0, 0);
- if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
- exit(status);
- return (mode[0] & 0xFFFF); /* # characters in typeahead buf */
- }
-
- #ifndef NO_DPROMPT
- /*
- * Attempt to read for one character. Return TRUE if the
- * read times out after 2 seconds, return immediately with
- * FALSE if the user enters something.
- */
- ttwait()
- {
- int status;
- int iosb[2];
- int term[2];
-
- term[0] = 0; /* no termination char for read */
- term[1] = 0;
- while (ibufi >= nibuf) { /* anything in the buffer? */
- ibufi = 0; /* nope, read 1 char w/timeout */
- status = SYS$QIOW(EFN, iochan, IO$_READLBLK|IO$M_TIMED,
- iosb, 0, 0, ibuf, 1, 2, term, 0, 0);
- if (status != SS$_NORMAL)
- continue; /* did read succeed ? */
- status = iosb[0] & 0xFFFF; /* yes, get secondary status */
- if (status!=SS$_NORMAL && status!=SS$_TIMEOUT)
- continue; /* try again if bad */
- nibuf = (iosb[0]>>16) + (iosb[1]>>16);/* store # chars read */
- if (status == SS$_TIMEOUT)
- return (TRUE); /* the read timed out */
- }
- return (FALSE); /* read did not time out */
- }
- #endif
-
- /*
- * Just exit, as quickly as we can.
- */
-
- panic(s)
- char *s;
- {
- fprintf(stderr,"panic: %s\n\n", s);
- ttclose(); /* set the terminal back to sane state... */
- exit(SS$_ABORT); /* go away! */
- }
- SHAR_EOF
- cat << \SHAR_EOF > sys/vms/mgmailedit.com
- $ Verify = 'F$Verify(0)
- $ ! Command procedure to invoke MG from MAIL. You should
- $ ! have the symbol MG globally defined, either as
- $ !
- $ ! MG :== $dev:[dir]MG
- $ !
- $ ! Then
- $ ! DEFINE MAIL$EDIT dev:[dir]MGMAILEDIT.COM
- $ !
- $ ! to make MAIL look for this file.
- $ !
- $ ! or, if using the kept-fork capability,
- $ !
- $ ! MG :== @dev:[dir]MG.COM
- $ !
- $ ! Inputs:
- $ !
- $ ! P1 = Input file name.
- $ ! P2 = Output file name.
- $ !
- $ ! The default directory is the same as the parent process.
- $ !
- $ ! Copy the input file to the output file, then invoke MG on it.
- $ !
- $ Set Noon
- $ Define/Job MG$AttachTo "''F$Process()'"
- $ If P2 .Nes. "" .AND. P1 .Nes. "" Then Copy 'P1' 'P2'
- $ Define/User Sys$Input Sys$Command
- $ MG 'P2'
- $ If F$Trnlnm("MG$AttachTo") .Nes. "" Then - ! MG.COM might have done it already
- Deassign/Job MG$AttachTo
- $ If Verify Then -
- Set Verify
- SHAR_EOF
- cat << \SHAR_EOF > sys/atari/maketop.mwc
- #
- # MWC Makefile for MG (Atari ST)
- #
- # Marion Hakanson Jan '88
- #
- # Copy this file to "makefile" in the top level MG directory,
- # and make sure the atari stuff is in SYSDIR below. Then just
- # run "make" in the top level directory.
-
- # Warning: This makefile depends on having $(POUND) set to '#',
- # either on the make command line or in the shell environment.
- # Note that $(POUND) is a hack to get around the fact that
- # there is no way to put a literal "#" in a MWC make action.
- # I just put "setenv POUND '#'" in my PROFILE.
-
- SYSLIB = libsys.a
- SYSDIR = sys\atari
- LIBS = $(SYSDIR)\$(SYSLIB)
-
- # CDEFS gets defines, and gets passed to lint. CFLAGS gets flags,
- # and doesn't get passed to lint.
-
- CDEFS =
- CFLAGS = -O -DMWC $(CDEFS)
-
- # Objects which only depend on the "standard" includes
- OBJS = basic.o dir.o dired.o file.o line.o paragraph.o \
- random.o region.o version.o window.o word.o
-
- # Those with unique requirements
- IND = buffer.o display.o echo.o extend.o help.o kbd.o keymap.o \
- macro.o main.o match.o modes.o regex.o re_search.o search.o
-
- OBJ = $(OBJS) $(IND)
-
- SRCS = basic.c dir.c dired.c file.c line.c match.c paragraph.c \
- random.c region.c search.c version.c window.c word.c \
- buffer.c display.c echo.c extend.c help.c kbd.c keymap.c \
- macro.c main.c modes.c regex.c re_search.c
-
- OINCS = ttydef.h sysdef.h chrdef.h
- INCS = def.h
-
- all:
- cd $(SYSDIR); make -f makesys.mwc \
- "SYSLIB=$(SYSLIB)" "CFLAGS=$(CFLAGS)" $@
- make xmg.ttp
-
- xmg.ttp: $(OBJ) $(SYSDIR)\$(SYSLIB)
- $(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBS)
-
- # strip mg once you're satisfied it'll run -- makes it much smaller
- strip:
- strip xmg.ttp
-
-
- $(OBJS): $(INCS) $(OINCS)
-
- regex.o re_search.o: $(INCS) $(OINCS) regex.h
-
- extend.o help.o kbd.o: $(INCS) $(OINCS) macro.h kbd.h key.h
-
- main.o re_search.o search.o: $(INCS) $(OINCS) macro.h
-
- match.o: $(INCS) $(OINCS) key.h
-
- buffer.o display.o keymap.o modes.o: $(INCS) $(OINCS) kbd.h
-
- echo.o macro.o: $(INCS) $(OINCS) key.h macro.h
-
- echo.o: varargs.h
-
-
- sysdef.h: $(SYSDIR)\sysdef.h
- echo '$(POUND)include "$(SYSDIR)\sysdef.h"' > $@
-
- ttydef.h: $(SYSDIR)\ttydef.h
- echo '$(POUND)include "$(SYSDIR)\ttydef.h"' > $@
-
- chrdef.h: $(SYSDIR)\chrdef.h
- echo '$(POUND)include "$(SYSDIR)\chrdef.h"' > $@
-
- varargs.h: $(SYSDIR)\varargs.h
- echo '$(POUND)include "$(SYSDIR)\varargs.h"' > $@
-
-
- clean:
- cd $(SYSDIR); make -f makesys.mwc \
- "SYSLIB=$(SYSLIB)" "CFLAGS=$(CFLAGS)" $@
- -rm $(OBJ) $(OINCS) varargs.h xmg.ttp
-
- SHAR_EOF
- cat << \SHAR_EOF > sys/atari/chrdef.h
- /* chrdef.h -- sample character attribute macros
- *
- * author : Sandra Loosemore
- * date : 26 Oct 1987
- *
- * This file works for the Atari ST 8-bit character set. It probably
- * won't work for other character encodings.
- *
- */
-
-
- #define _W 0x01 /* Word. */
- #define _U 0x02 /* Upper case letter. */
- #define _L 0x04 /* Lower case letter. */
- #define _C 0x08 /* Control. */
- #define _P 0x10 /* end of sentence punctuation */
-
- #define ISWORD(c) ((cinfo[(c)]&_W)!=0)
- #define ISCTRL(c) ((cinfo[(c)]&_C)!=0)
- #define ISUPPER(c) ((cinfo[(c)]&_U)!=0)
- #define ISLOWER(c) ((cinfo[(c)]&_L)!=0)
- #define ISEOSP(c) ((cinfo[(c)]&_P)!=0)
- #define TOUPPER(c) (cupper[(c)])
- #define TOLOWER(c) (clower[(c)])
- #define ISDIGIT(c) (((c) >= '0') && ((c) <= '9'))
-
- extern char cupper[];
- extern char clower[];
- extern char cinfo[];
-
-
- /*
- * generally useful thing for chars
- */
- #define CCHR(x) ((x) ^ 0x40) /* CCHR('?') == DEL */
- #define CHARMASK(c) ((c)&0xff)
- SHAR_EOF
- cat << \SHAR_EOF > sys/amiga/ttykbd.c
- /*
- * Name: MG 2a
- * Amiga virtual terminal keyboard, default console keymap.
- * Created: Mic Kaczmarczik (mic@emx.cc.utexas.edu)
- * Last edit: May 14, 1988
- */
-
- #undef TRUE
- #undef FALSE
- #include "def.h"
- #include "kbd.h"
-
- /*
- * List of function key names, from KFIRST to KLAST
- */
- #ifdef FKEYS
- char *keystrings[] = {
- "Up", "Down", "Left", "Right",
- "Shift-Up", "Shift-Down", "Shift-Left", "Shift-Right",
- "Help", "The menu", "The resize gadget", "The mouse",
- "F1", "F2", "F3", "F4",
- "F5", "F6", "F7", "F8",
- "F9", "F10", "Shift-F1", "Shift-F2",
- "Shift-F3", "Shift-F4", "Shift-F5", "Shift-F6",
- "Shift-F7", "Shift-F8", "Shift-F9", "Shift-F10",
- "Mouse", "Ctrl-Mouse",
- "Shift-Mouse", "Shift-Ctrl-Mouse",
- "Meta-Mouse", "Meta-Ctrl-Mouse",
- "Meta-Shift-Mouse", "Meta-Shift-Ctrl-Mouse",
- "Mode-Mouse", "Ctrl-Mode-Mouse",
- "Shift-Mode-Mouse", "Shift-Ctrl-Mode-Mouse",
- "Meta-Mode-Mouse", "Meta-Ctrl-Mode-Mouse",
- "Meta-Shift-Mode-Mouse", "Meta-Shift-Ctrl-Mode-Mouse",
- "Echo-Mouse", "Ctrl-Echo-Mouse",
- "Shift-Echo-Mouse", "Shift-Ctrl-Echo-Mouse",
- "Meta-Echo-Mouse", "Meta-Ctrl-Echo-Mouse",
- "Meta-Shift-Echo-Mouse", "Meta-Shift-Ctrl-Echo-Mouse"
- };
- #endif
-
- /*
- * Read in a key, doing whatever low-level mapping of ASCII code to
- * 11 bit code. This has become a bit easier since keymaps.
- */
- #define CSI 0x9b
-
- getkbd()
- {
- register int c;
- #ifdef FKEYS
- register int n;
- #endif
- loop:
- if ((c = ttgetc()) == CSI) {
- c = ttgetc();
- #ifdef FKEYS
- if (c == '?') { /* HELP key */
- ttgetc(); /* discard '~' */
- return (KHELP);
- }
- /* Arrow keys */
- if (c == 'A')
- return (KUP);
- if (c == 'B')
- return (KDOWN);
- if (c == 'C')
- return (KRIGHT);
- if (c == 'D')
- return (KLEFT);
- if (c == 'T')
- return (KSUP);
- if (c == 'S')
- return (KSDOWN);
-
- /* Shifted left, right arrow */
- if (c == ' ') {
- c = ttgetc();
- if (c == 'A' || c == '@')
- return ((c == 'A') ? (KSLEFT) : (KSRIGHT));
- goto loop; /* try again, sucker */
- }
-
- /* Function keys */
- if (c >= '0' && c <= '9') {
- n = 0;
- do {
- n = 10*n + c - '0';
- c = ttgetc();
- } while (c>='0' && c<='9');
- if (c == '~' && n < 20)
- return (n < 9) ? (KF1 + n) : (KSF1 + (n - 10));
- else
- goto loop; /* Try again */
- }
- #endif
- goto loop; /* Try again */
- }
- return (c);
- }
-
- /*
- * Terminal specific keymap initialization, calling bind() to get
- * things done. All the keys bound here are done globally.
- */
-
- VOID
- ttykeymapinit()
- {
- #ifdef FKEYS
- KCHAR c;
- register KEYMAP **mapp = &map_table[0].p_map;
- #endif
- static KCHAR esc_bs[] = { CCHR('['), CCHR('H') };
- static KCHAR esc_del[] = { CCHR('['), CCHR('?') };
-
- #define BINDC(k,s) (c = k, bindkey(mapp, s, &c, 1))
- #define BINDM(m,s) bindkey(mapp, s, m, (sizeof(m)/sizeof(KCHAR)))
-
- /* Swap the backspace and del keys, at least in normal usage.
- * This loses the help feature of CTRL-H, but we rebind
- * CTRL-_ to do the same thing. Under FKEYS, the Help key
- * calls describe-key-briefly.
- */
- BINDC(CCHR('_'), "help-help"); /* CTRL-Backspace */
- BINDM(esc_bs, "backward-kill-word");
- BINDC(CCHR('H'), "delete-backward-char");
-
- BINDC(CCHR('?'), "delete-char");
- BINDM(esc_del, "kill-word");
- }
-
- SHAR_EOF
- cat << \SHAR_EOF > sys/amiga/ttymenu.c
- /*
- * ttymenu.c
- *
- * Incorporates the browser, for rummaging around on disks,
- * and the usual Emacs editing command menu
- *
- * Copyright (c) 1986, Mike Meyer
- * Mic Kaczmarczik did a few things along the way.
- *
- * Permission is hereby granted to distribute this program, so long as
- * this source file is distributed with it, and this copyright notice
- * is not removed from the file.
- *
- */
-
- #include <exec/types.h>
- #include <libraries/dos.h>
- #include <libraries/dosextens.h>
- #include <intuition/intuition.h>
- #undef TRUE
- #undef FALSE
- #include "def.h"
- #ifndef NO_MACRO
- #include "macro.h"
- #endif
-
- extern struct Menu *AutoMenu ;
- extern struct Window *EmW ;
-
- #ifdef LATTICE
- static VOID Add_Devices(ULONG) ;
- #else
- static VOID Add_Devices() ;
- #endif
-
- #define MNUM(menu,item,sub) (SHIFTMENU(menu)|SHIFTITEM(item)|SHIFTSUB(sub))
-
- #ifdef BROWSER
- #define LONGEST_NAME 80 /* Longest file name we can deal with */
-
- # ifdef LATTICE
- char *strchr(char *, int);
- # else
- char *index(); /* find first instance of c in s */
- #define strchr(s, c) index(s, c)
- # endif
-
- # ifdef MENU
- #define FIRSTMENU 1
- # else
- #define FIRSTMENU 0
- # endif
-
- #endif BROWSER
-
- #ifdef MENU
- /*
- * When ttgetc() sees a menu selection event, it stuffs the sequence
- * KMENU <menu><item><subitem> into the input buffer
- *
- * The menu item names are chosen to be relatively close to the extended
- * function names, so a user can usually figure out the key binding of
- * a menu item by searching through the "display-bindings" buffer
- * for something that's close.
- */
-
- /*
- * Commands for managing files and buffers
- */
-
- extern int filevisit();
- extern int poptofile();
- extern int fileinsert();
- extern int filesave();
- extern int filewrite();
- #ifndef NO_DIRED
- extern int dired();
- #endif
- extern int usebuffer();
- extern int poptobuffer();
- extern int killbuffer();
- extern int listbuffers();
- extern int savebuffers();
- extern int quit();
-
- static struct MenuBinding FileItems[] = {
- { "Find File C-x C-f", filevisit },
- { "Pop To File C-x 4 f", poptofile },
- { "Insert File C-x i", fileinsert },
- { "Save File C-x C-s", filesave },
- { "Write File C-x C-w", filewrite },
- #ifndef NO_DIRED
- { "Dired C-x d", dired },
- #endif
- { "Switch To Buffer C-x b", usebuffer },
- { "Pop To Buffer C-x 4 b", poptobuffer },
- { "Kill Buffer C-x k", killbuffer },
- { "List Buffers C-x C-b", listbuffers },
- { "Save Buffers C-x s", savebuffers },
- { "Save And Exit C-x C-c", quit }
- };
-
- /*
- * Commands for various editing functions
- */
-
- extern int yank();
- extern int openline();
- extern int killline();
- extern int deblank();
- extern int justone();
- extern int indent();
- extern int twiddle();
- extern int quote();
-
- static struct MenuBinding EditItems[] = {
- { "Yank C-y", yank },
- { "Blank Line C-o ", openline },
- { "Kill Line C-k", killline },
- { "Delete Blank Lines C-x C-o",deblank },
- { "Delete Blanks M-SPC", justone },
- { "Newline And Indent C-j", indent },
- { "Transpose Characters C-t", twiddle },
- { "Quoted Insert C-q", quote }
- };
-
- /*
- * Movement commands
- */
-
- extern int forwpage();
- extern int backpage();
- extern int gotobol();
- extern int gotobob();
- extern int gotoeol();
- extern int gotoeob();
- extern int gotoline();
- extern int showcpos();
-
- static struct MenuBinding MoveItems[] = {
- { "Scroll Up C-v", forwpage },
- { "Scroll Down M-v", backpage },
- { "Start Of Line C-a", gotobol },
- { "Start Of Buffer M-<", gotobob },
- { "End Of Line C-e", gotoeol },
- { "End Of Buffer M->", gotoeob },
- { "Goto Line", gotoline },
- { "Show Cursor C-x =", showcpos }
- };
-
- /*
- * Commands for searching and replacing
- */
-
- extern int forwisearch();
- extern int backisearch();
- extern int searchagain();
- extern int forwsearch();
- extern int backsearch();
- extern int queryrepl();
-
- static struct MenuBinding SearchItems[] = {
- { "I-Search Forward C-s", forwisearch },
- { "I-Search Backward C-r", backisearch },
- { "Search Again", searchagain },
- { "Search Forward M-s", forwsearch },
- { "Search Backward M-r", backsearch },
- { "Query Replace M-%", queryrepl }
- };
-
- /*
- * Commands that manipulate words
- */
- extern int forwword();
- extern int backword();
- extern int delfword();
- extern int delbword ();
- extern int capword();
- extern int lowerword();
- extern int upperword();
-
- static struct MenuBinding WordItems[] = {
- { "Forward Word M-f", forwword },
- { "Backward Word M-b", backword },
- { "Kill Word M-d", delfword },
- { "Backward Kill Word M-DEL", delbword },
- { "Capitalize Word M-c", capword },
- { "Downcase Word M-l", lowerword },
- { "Upcase Word M-u", upperword }
- };
-
- /*
- * Commands relating to paragraphs
- */
- extern int gotoeop();
- extern int gotobop();
- extern int fillpara();
- extern int setfillcol();
- extern int killpara();
- extern int fillmode();
-
- static struct MenuBinding ParaItems[] = {
- { "Forward Paragraph M-]", gotoeop },
- { "Backward Paragraph M-[", gotobop },
- { "Fill Paragraph M-q", fillpara },
- { "Set Fill Column C-x f", setfillcol },
- { "Kill Paragraph", killpara },
- { "Auto Fill Mode", fillmode }
- };
-
- /*
- * Region stuff
- */
- extern int setmark();
- extern int swapmark();
- extern int killregion();
- extern int copyregion();
- extern int lowerregion();
- extern int upperregion();
-
- static struct MenuBinding RegionItems[] = {
- { "Set Mark C-@", setmark },
- { "Exch Point And Mark C-x C-x",swapmark },
- { "Kill Region C-w", killregion },
- { "Copy Region As Kill M-w", copyregion },
- { "Downcase Region C-x C-l",lowerregion },
- { "Upcase Region C-x C-u",upperregion }
- };
-
- /*
- * Commands for manipulating windows
- */
-
- extern int splitwind();
- extern int delwind();
- extern int onlywind();
- extern int nextwind();
- #ifdef PREVWIND
- extern int prevwind();
- #endif
- extern int enlargewind();
- extern int shrinkwind();
- extern int refresh();
- extern int reposition();
- extern int togglewindow();
- #ifdef CHANGE_FONT
- extern int setfont();
- #endif
-
- static struct MenuBinding WindowItems[] = {
- { "Split Window C-x 2", splitwind },
- { "Delete Window C-x 0", delwind },
- { "Delete Other Windows C-x 1", onlywind },
- { "Next Window C-x o", nextwind },
- #ifdef PREVWIND
- { "Up Window", prevwind },
- #endif
- { "Enlarge Window C-x ^", enlargewind },
- { "Shrink Window", shrinkwind },
- { "Redraw Display", refresh },
- { "Recenter C-l", reposition },
- { "Toggle Border", togglewindow },
- #ifdef CHANGE_FONT
- { "Set Font", setfont }
- #endif
- };
-
- /*
- * Miscellaneous commands
- */
-
- extern int definemacro();
- extern int finishmacro();
- extern int executemacro();
- extern int extend();
- extern int bindtokey();
- extern int desckey();
- extern int wallchart();
- extern int showversion();
- extern int spawncli();
-
- static struct MenuBinding MiscItems[] = {
- { "Start Kbd Macro C-x (", definemacro },
- { "End Kbd Macro C-x )", finishmacro },
- { "Call Kbd Macro C-x e", executemacro },
- { "Execute Command M-x", extend },
- { "Global Set Key", bindtokey },
- { "Describe Key C-h c", desckey },
- { "Describe Bindings C-h b", wallchart },
- { "Emacs Version", showversion },
- { "New CLI C-z", spawncli }
- };
-
- /*
- * The following table contains the titles, number of items, and
- * pointers to, the individual menus.
- */
-
- static struct MenuInfo EMInfo[] = {
- { "File ", NITEMS(FileItems), &FileItems[0] },
- { "Edit ", NITEMS(EditItems), &EditItems[0] },
- { "Move ", NITEMS(MoveItems), &MoveItems[0] },
- { "Search ", NITEMS(SearchItems), &SearchItems[0] },
- { "Word ", NITEMS(WordItems), &WordItems[0] },
- { "Paragraph ", NITEMS(ParaItems), &ParaItems[0] },
- { "Region ", NITEMS(RegionItems), &RegionItems[0] },
- { "Window ", NITEMS(WindowItems), &WindowItems[0] },
- { "Miscellaneous ", NITEMS(MiscItems), &MiscItems[0] }
- };
-
- /* There are three cases to deal with; the menu alone, the Browser
- * alone, and both of them together. We #define some things to make
- * life a little easier to deal with
- */
- # ifdef BROWSER
- # define Edit_Menu_Init() Menu_Add("Edit ", TRUE, FALSE)
- # define Edit_Menu_Add(n) Menu_Item_Add(n,(USHORT)ITEMENABLED,0L,(BYTE)0,FALSE)
- # define Edit_Item_Add(n) Menu_SubItem_Add(n,(USHORT)ITEMENABLED,0L,(BYTE)0,FALSE)
- # else
- # define Edit_Menu_Init() cinf = NULL /* harmless */
- # define Edit_Menu_Add(n) n[strlen(n)-1] = '\0'; Menu_Add(n, TRUE, FALSE)
- # define Edit_Item_Add(n) Menu_Item_Add(n,(USHORT)ITEMENABLED,0L,(BYTE)0,FALSE)
- # endif BROWSER
-
- #endif MENU
-
- /*
- * Initialize the Emacs menu
- */
-
- struct Menu * InitEmacsMenu(EmW)
- struct Window *EmW;
- {
- #ifdef MENU
- register struct MenuInfo *cinf;
- register struct MenuBinding *lastbinding, *cb;
- struct MenuInfo *lastinfo;
- #endif
-
- Menu_Init() ; /* init the menu */
-
- #ifdef MENU
- Edit_Menu_Init() ; /* Set up for editing menu */
- lastinfo = &EMInfo[NITEMS(EMInfo)]; /* loop sentinel */
- for (cinf = EMInfo; cinf < lastinfo; cinf++) {
- Edit_Menu_Add(cinf->Name);
- lastbinding = &cinf->Items[cinf->NumItems];
- for (cb = cinf->Items; cb < lastbinding; cb++)
- Edit_Item_Add(cb->Command);
- }
- #endif MENU
-
- #ifdef BROWSER
- Menu_Add("Disks ", TRUE, FALSE) ;/* name is already there */
- Add_Devices(DLT_DEVICE); /* devices first */
- Add_Devices(DLT_VOLUME); /* mounted volume names next */
- Add_Devices(DLT_DIRECTORY); /* assigned directories last */
- #endif BROWSER
- return AutoMenu ;
- }
-
- /*
- * amigamenu() -- handles a menu pick.
- */
-
- amigamenu(f, n) {
- unsigned short menunum, itemnum, subnum, Menu_Number;
- char *name;
- register PF fp;
-
- #ifdef BROWSER
- register unsigned short level, i, dirp;
- register char *cp;
- int stat;
- struct MenuItem *ItemAddress() ;
-
- /* State variables that describe the current directory */
- static char Dir_Name[LONGEST_NAME] ;
- static unsigned short Menu_Level = 0 ;
- #endif
-
- #ifndef NO_MACRO
- if (inmacro)
- return (FALSE); /* menu picks aren't recorded */
- #endif
-
- /* read the menu, item, and subitem codes from the input stream */
- menunum = getkey(FALSE) - MN_OFFSET;
- itemnum = getkey(FALSE) - MN_OFFSET;
- subnum = getkey(FALSE) - MN_OFFSET;
-
- #ifndef NO_MACRO
- if (macrodef) { /* menu picks can't be practically recorded */
- ewprintf("Can't record menu selections");
- return (FALSE);
- }
- #endif
-
- Menu_Number = (USHORT)
- (SHIFTMENU(menunum) | SHIFTITEM(itemnum) | SHIFTSUB(subnum));
-
- #ifndef BROWSER
- # ifdef MENU
- fp = EMInfo[menunum].Items[itemnum].Function;
- return (*(fp)(f, n));
- # endif
- #else /* we're using the Browser */
- # ifdef MENU
- /* Handle commands from the Edit menu when using the Browser */
- if (0 == menunum) {
- fp = EMInfo[itemnum].Items[subnum].Function;
- return ((*fp)(f, n));
- }
- # endif
- /* Here when a selection was made in a Browser menu */
- name = (char *)((struct IntuiText *)
- (ItemAddress(AutoMenu,(ULONG) Menu_Number) -> ItemFill))
- -> IText ;
- level = MENUNUM(Menu_Number) - FIRSTMENU;
-
- /* Got what we want, so clear the menu to avoid confusing the user */
- ClearMenuStrip(EmW) ;
-
- /* set dirp to FALSE if the name is not a directory or disk */
- dirp = (strchr(name, '/') != NULL || strchr(name, ':') != NULL) ;
-
- /* First, set the directory name right */
- if (level > Menu_Level) /* Not possible, die */
- panic("impossible menu_level in amigamenu");
- else if (level == 0) /* picked a new disk */
- Dir_Name[0] = '\0' ;
- else if (level < Menu_Level) { /* Throw away some levels */
- for (i = 1, cp = strchr(Dir_Name, ':'); i < level; i++) {
- if (cp == NULL) return FALSE;
- cp = strchr(cp, '/') ;
- }
- if (cp == NULL) panic("broken file name in amigamenu");
- *++cp = '\0' ;
- }
- /* else Menu_Level == level, chose a file a current level */
-
- /* Now, fix up the menu and it's state variable */
- while (Menu_Level > level) {
- Menu_Level-- ;
- Menu_Pop() ;
- }
-
- /* If we added a file, visit it, else add a
- * new directory level to the menu.
- */
- if (!dirp)
- stat = Display_File(Dir_Name, name) ;
- else {
- Menu_Level++ ;
- (void) strncat(Dir_Name, name,
- LONGEST_NAME - strlen(Dir_Name) - 1) ;
- stat = Add_Dir(Dir_Name, name) ;
- }
- SetMenuStrip(EmW, AutoMenu) ;
- return stat ;
- #endif BROWSER
- }
-
- #ifdef BROWSER
- /*
- * Display_File - Go fetch a the requested file into a window.
- */
- Display_File(dir, file) char *dir, *file; {
- register BUFFER *bp, *findbuffer();
- int s;
- char File_Name[LONGEST_NAME], *fn, *adjustname();
-
- (void) strcpy(File_Name, dir);
- (void) strncat(File_Name, file, LONGEST_NAME - strlen(File_Name) - 1) ;
- fn = adjustname(File_Name);
- if ((bp = findbuffer(fn)) == NULL) return FALSE;
- curbp = bp;
- if (showbuffer(bp, curwp, WFHARD) != TRUE) return FALSE;
- if (bp->b_fname[0] == 0)
- return (readin(fn)); /* Read it in. */
- return TRUE;
- }
- /*
- * Add_Dir - given a dir and a name, add the menu name with the files in
- * dir as entries. Use AllocMem() in order to make
- * sure the file info block is on a longword boundary.
- */
- static
- Add_Dir(dir, name) char *dir, *name; {
- register char *last_char ;
- register struct FileLock *my_lock, *Lock() ;
- unsigned short count ;
- int stat = FALSE;
- static char Name_Buf[LONGEST_NAME] ;
- char *AllocMem();
- struct FileInfoBlock *File_Info;
-
- if ((File_Info = (struct FileInfoBlock *)
- AllocMem((LONG)sizeof(struct FileInfoBlock), 0L)) == NULL)
- return (FALSE);
-
- /* Fix up the trailing / if it needs it */
- last_char = &dir[strlen(dir) - 1] ;
- if (*last_char == '/') *last_char = '\0' ;
-
- /* Now, start on the directory */
- if ((my_lock = Lock(dir, ACCESS_READ)) == NULL) goto out;
-
- if (!Examine(my_lock, File_Info)) goto out;
- if (File_Info -> fib_DirEntryType < 0L)
- goto out;
-
- if (Menu_Add(name, TRUE, TRUE) == 0) goto out;
- for (count = 0; ExNext(my_lock, File_Info)
- || IoErr() != ERROR_NO_MORE_ENTRIES; count++)
- if (File_Info -> fib_DirEntryType < 0L) {
- if (Menu_Item_Add(File_Info -> fib_FileName,
- (USHORT)ITEMENABLED, 0L, (BYTE)0, TRUE)
- == MNUM(NOMENU, NOITEM, NOSUB))
- break ;
- }
- else {
- (void) strcpy(Name_Buf, File_Info -> fib_FileName) ;
- (void) strcat(Name_Buf, "/") ;
- if (Menu_Item_Add(Name_Buf,
- (USHORT) ITEMENABLED, 0L, (BYTE)0, TRUE)
- == MNUM(NOMENU, NOITEM, NOSUB))
- break ;
- }
- if (count == 0) Menu_Item_Add("EMPTY", (USHORT)0, 0L, (BYTE)0, FALSE) ;
-
- /* Put everything back */
- if (*last_char == '\0') *last_char = '/' ;
- stat = TRUE;
- out:
- UnLock(my_lock) ;
- FreeMem(File_Info, (LONG) sizeof(struct FileInfoBlock));
- return stat;
- }
-
- /*
- * Add all the devices currently known by the system
- * to the current menu, based on the type of device
- * list entry desired. Disable multitasking while
- * we look inside the device list, so we don't fly off
- * into space while traversing it.
- */
- struct DosLibrary *DosBase;
- extern APTR OpenLibrary();
-
- static VOID
- Add_Devices(devtype)
- ULONG devtype;
- {
- register struct DeviceList *devlist;
- struct RootNode *rootnode;
- struct DosInfo *dosinfo;
- UBYTE buffer[80];
- int ramflag = 0;
-
- /* if you've gotten this far, none of these will be null. */
- DosBase = (struct DosLibrary *) OpenLibrary(DOSNAME,0L);
-
- Forbid(); /* let's be careful out there... */
- rootnode = (struct RootNode *) DosBase->dl_Root;
- dosinfo = (struct DosInfo *) BADDR(rootnode->rn_Info);
- devlist = (struct DeviceList *) BADDR(dosinfo->di_DevInfo);
-
- while (devlist) {
- /* select by specified device type */
- if (devlist->dl_Type != devtype) {
- devlist = (struct DeviceList *) BADDR(devlist->dl_Next);
- continue;
- }
-
- /* convert device's name into AmigaDOS name and concat a ":" */
- btocstr((BPTR) devlist->dl_Name,buffer,sizeof(buffer));
- strcat(buffer,":");
-
- /* Always add volumes and assigned directories. However,
- * disks should be the only devices added to the list. Magic
- * disk test courtesy of Phillip Lindsay, Commodore-Amiga Inc.
- */
- if (devtype != DLT_DEVICE)
- Menu_Item_Add(buffer, (USHORT)ITEMENABLED,
- 0L, (BYTE)0, TRUE);
- else if (devlist->dl_Task) { /* why does this work? */
- Menu_Item_Add(buffer, (USHORT)ITEMENABLED,
- 0L, (BYTE)0, TRUE);
- if (!strcmp(buffer,"RAM:")) ramflag = 1;
- }
- devlist = (struct DeviceList *) BADDR(devlist->dl_Next);
- }
- /* if ramdisk isn't loaded yet, add it anyway */
- if ((devtype == DLT_DEVICE) && !ramflag)
- Menu_Item_Add("RAM:",(USHORT)ITEMENABLED, 0L, (BYTE) 0, FALSE);
- Permit();
- CloseLibrary(DosBase);
- }
-
- btocstr(bp,buf,bufsiz)
- BPTR bp;
- char *buf;
- int bufsiz;
- {
- register UBYTE *cp;
- register int len, i;
-
- cp = (UBYTE *) BADDR(bp);
- len = (int) *(cp++);
- len = (len > bufsiz) ? bufsiz : len; /* truncate if necessary */
- for (i = 0; i < len; i++)
- buf[i] = *(cp++);
- buf[i] = '\0';
- return (len < bufsiz); /* return FALSE if truncated */
- }
-
- #endif BROWSER
- SHAR_EOF
- cat << \SHAR_EOF > sys/amiga/ttymouse.c
- /*
- * Name: MG 2a
- * Commodore Amiga mouse handling
- * Created: Distant past
- * Last edit: 28-Nov-87 mic@emx.cc.utexas.edu
- */
-
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #undef TRUE
- #undef FALSE
- #include "def.h"
- #ifndef NO_MACRO
- #include "macro.h"
- #endif
-
- extern int ttmouse();
- extern int forwline();
- extern int forwchar();
- extern int setmark();
- extern int isetmark();
-
- /* stuff for go-to-window-and-do-it functions */
- extern int reposition();
- extern int delfword();
- extern int killline();
- extern int forwdel();
- extern int justone();
- extern int killregion();
- extern int yank();
- extern int forwpage();
- extern int backpage();
- extern int splitwind();
- extern int delwind();
- extern int gotobob();
- extern int gotoeob();
- extern int enlargewind();
- extern int shrinkwind();
-
- /*
- * Handle the mouse click that's been passed by ttgetc() and position
- * dot where the user pointed at. If this is the same position
- * where the user pointed the last time, set the mark, whether or
- * not this is a true double-click. This isn't a true double-click,
- * but it does most of what we want.
- */
-
- static USHORT oldrow = HUGE, oldcol = HUGE; /* last mouse click */
- static USHORT newrow, newcol; /* next mouse click */
-
- amigamouse(f, n)
- {
- if (!dottomouse()) /* sets newrow, newcol */
- return (FALSE);
- if ((newrow == oldrow) && (newcol == oldcol))
- setmark(FFRAND, 1); /* double-click */
- oldrow = newrow; /* save state */
- oldcol = newcol;
- return (TRUE);
- }
-
- /*
- * Recenter on selected line
- */
- mreposition(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (reposition(f, n));
- }
-
- /*
- * Delete word after selected char
- */
- mdelfword(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (delfword(f, n));
- }
-
- /*
- * Move to selection, kill line
- */
- mkillline(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (killline(f, n));
- }
-
- /*
- * Move to selection, kill word
- */
- mforwdel(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (forwdel(f, n));
- }
-
- /*
- * Move to selection, kill line
- */
- mdelwhite(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (justone(f, n));
- }
-
- /*
- * Set mark, move to selection, kill region.
- */
- mkillregion(f, n)
- {
- register struct LINE *p_old;
- register short o_old;
-
- p_old = curwp->w_markp; /* Save old mark */
- o_old = curwp->w_marko;
- isetmark(); /* and set current one */
- if (!dottomouse()) {
- curwp->w_markp = p_old; /* Oops - put mark back */
- curwp->w_marko = o_old;
- return (FALSE);
- }
- return (killregion(f, n));
- }
-
- /*
- * Move to selection, yank kill buffer
- */
- myank(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (yank(f, n));
- }
-
- /*
- * Select window pointed to by mouse, then scroll down
- */
-
- mforwpage(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (forwpage(f, n));
- }
-
- /*
- * Select buffer, scroll page down
- */
- mbackpage(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (backpage(f, n));
- }
-
- /*
- * Select the window, split it.
- */
- msplitwind(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (splitwind(f, n));
- }
-
- /*
- * Select the buffer, delete it.
- */
- mdelwind(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (delwind(f, n));
- }
-
- /*
- * Select window, goto beginning of buffer
- */
- mgotobob(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (gotobob(f, n));
- }
-
- /*
- * Select window, go to end of buffer
- */
- mgotoeob(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (gotoeob(f, n));
- }
-
- /*
- * Select window, enlarge it.
- */
- menlargewind(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (enlargewind(f, n));
- }
-
- /*
- * Select window, shrink it.
- */
- mshrinkwind(f, n)
- {
- if (!dottomouse())
- return (FALSE);
- return (shrinkwind(f, n));
- }
-
- /*
- * Utility routine to move dot to where the user clicked. If in
- * mode line, chooses that buffer as the one to work on.
- */
-
- static dottomouse()
- {
- register WINDOW *wp;
- register int dot;
- register int col;
- register int c;
- int getkey();
-
- #ifndef NO_MACRO
- if (inmacro)
- return FALSE; /* can't record mouse clicks */
- #endif
-
- /* read the next 2 characters to get the col, row info, using
- * getkey() to record them (or re-read them if in a macro).
- */
- newcol = getkey(FALSE) - M_X_ZERO;
- newrow = getkey(FALSE) - M_Y_ZERO;
-
- #ifndef NO_MACRO
- if (macrodef) { /* menu picks can't be practically recorded */
- ewprintf("Can't record mouse clicks");
- return (FALSE);
- }
- #endif
-
- /* find out which window was clicked in */
- for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
- if ((newrow >= wp->w_toprow) &&
- (newrow <= (wp->w_toprow + wp->w_ntrows)))
- break;
-
- if (wp == NULL) /* echo line */
- return (ABORT);
- else if (newrow == wp->w_toprow + wp->w_ntrows) {/* mode line */
- curwp = wp; /* just change buffer */
- curbp = wp->w_bufp;
- } else {
- /* move to selected window, move dot to top left */
- curwp = wp;
- curbp = wp->w_bufp;
- curwp->w_dotp = wp->w_linep;
- curwp->w_doto = 0;
-
- /* go forward the correct # of lines */
- forwline(FFRAND, newrow - curwp->w_toprow);
-
- /* go forward the correct # of characters */
- /* need to count them out because of tabs */
- col = dot = 0;
- while ((col < newcol) && (dot < llength(curwp->w_dotp))) {
- c = lgetc(curwp->w_dotp, dot++);
- if (c == CCHR('I'))
- col |= 0x07;
- else if (ISCTRL(c) != FALSE)
- ++col;
- ++col;
- }
- if (col > newcol) dot--; /* back up to tab/ctrl char */
- forwchar(FFRAND, dot);
- }
- return (TRUE);
- }
- SHAR_EOF
- cat << \SHAR_EOF > sys/amiga/varargs.h
- /*
- * Varargs, for use on AmigaDOS with the Lattice C compiler,
- * or (maybe?) the Manx compiler with 32-bit ints.
- * Blatantly lifted from 4.2BSD.
- */
-
- typedef char *va_list;
- #define va_dcl int va_alist;
- #define va_start(pv) pv = (char *) &va_alist
- #define va_end(pv) /* Naught to do... */
- #define va_arg(pv, t) ((t *) (pv += sizeof(t)))[-1]
- SHAR_EOF
- cat << \SHAR_EOF > sys/amiga/iconify/iconify.c
- /* :ts=8 bk=0
- *
- * iconify.c: You asked for it, you got it.
- *
- * Copyright 1987 by Leo L. Schwab.
- * Permission is hereby granted for use in any and all programs, both
- * Public Domain and commercial in nature, provided this Copyright notice
- * is left intact. Purveyors of programs, at their option, may wish observe
- * the following conditions (in the spirit of hackerdom):
- * 1: You send me a free, registered copy of the program that uses the
- * iconify feature,
- * 2: If you're feeling really nice, a mention in the program's
- * documentation of my name would be neat.
- *
- * 8712.10 (415) 456-3960
- */
- #include <exec/types.h>
- #include <devices/timer.h>
- #include <intuition/intuition.h>
- #include "iconify.h"
-
- /*
- * It is recommended that the tick rate not be made too rapid to avoid
- * bogging down the system.
- */
- #define TICKS_PER_SECOND 10
-
- /*
- * Some programmers may not wish to have the added functionality of the
- * ICON_FUNCTION feature. If you're such a programmer, you may comment out
- * the following #define, which will eliminate the code to handle function
- * calls, and make iconify() even smaller.
- */
- #define USE_FUNCTIONS
-
- /*
- * Jim Mackraz suggested making icons easily identifiable by outside
- * programs, so this constant gets stuffed into the UserData field.
- */
- #define ICON 0x49434f4eL /* 'ICON' */
-
-
- extern void *OpenWindow(), *GetMsg(), *CreatePort(), *CreateExtIO(),
- *CheckIO();
- extern long OpenDevice(), DoubleClick();
-
-
- static struct Gadget gadget = {
- NULL,
- 0, 0, 0, 0,
- NULL, /* Set later */
- GADGIMMEDIATE,
- WDRAGGING, /* Observe the Magic! */
- NULL, /* Set later */
- NULL, NULL, NULL, NULL,
- 0, 0
- };
-
- static struct NewWindow windef = {
- 0, 0, 0, 0, /* Set later */
- -1, -1,
- GADGETDOWN,
- BORDERLESS | SMART_REFRESH | NOCAREREFRESH,
- &gadget,
- NULL, NULL, NULL, NULL, /* Lotsa these */
- 0, 0, 0, 0,
- WBENCHSCREEN
- };
-
- static struct Window *win;
-
- #ifdef USE_FUNCTIONS
- static struct timerequest *tr;
- static struct MsgPort *reply;
- #endif
-
-
- iconify (left, top, width, height, screen, ptr, type)
- UWORD *left, *top, width, height;
- struct Screen *screen;
- APTR ptr;
- int type;
- {
- register struct IntuiMessage *msg;
- long secs = 0, mics = 0,
- cs, cm,
- class,
- sigmask;
-
- windef.LeftEdge = *left;
- windef.TopEdge = *top;
- windef.Width = width;
- windef.Height = height;
- windef.Type = (windef.Screen = screen) ? CUSTOMSCREEN : WBENCHSCREEN;
-
- gadget.Flags = GADGHCOMP | GRELWIDTH | GRELHEIGHT;
-
- switch (type & 3) {
- case ICON_IMAGE:
- gadget.Flags |= GADGIMAGE;
- case ICON_BORDER:
- gadget.GadgetRender = ptr;
- break;
-
- case ICON_FUNCTION:
- #ifdef USE_FUNCTIONS
- gadget.GadgetRender = NULL;
- #else
- return (0);
- #endif
- break;
-
- default:
- return (0);
- }
-
- if (!openstuff ())
- return (0);
- sigmask = 1L << win -> UserPort -> mp_SigBit;
-
- #ifdef USE_FUNCTIONS
- if (type == ICON_FUNCTION) {
- sigmask |= 1L << reply -> mp_SigBit;
- tr -> tr_node.io_Command= TR_ADDREQUEST;
- tr -> tr_time.tv_secs = 0;
- tr -> tr_time.tv_micro = (1000000L / TICKS_PER_SECOND);
- SendIO (tr);
- /*
- * Make initialization call to user's function.
- * Isn't typecasting wonderful? :-|
- */
- (* ((void (*)()) ptr)) (win, (WORD) 1);
- }
- #endif
-
- while (1) {
- Wait (sigmask);
-
- #ifdef USE_FUNCTIONS
- if (GetMsg (reply)) {
- /*
- * Call user's function to do something to the icon.
- */
- (* ((void (*)()) ptr)) (win, (WORD) 0);
- tr -> tr_time.tv_secs = 0;
- tr -> tr_time.tv_micro =
- (1000000L / TICKS_PER_SECOND);
- SendIO (tr);
- }
- #endif
-
- if (msg = GetMsg (win -> UserPort)) {
- class = msg -> Class;
- cs = msg -> Seconds;
- cm = msg -> Micros;
- ReplyMsg (msg);
-
- if (class == GADGETDOWN) {
- if (DoubleClick (secs, mics, cs, cm))
- break;
- secs = cs; mics = cm;
- }
- }
- }
-
- #ifdef USE_FUNCTIONS
- if (type == ICON_FUNCTION) {
- AbortIO (tr);
- WaitIO (tr);
- }
- #endif
-
- *left = win -> LeftEdge;
- *top = win -> TopEdge;
- closestuff ();
- return (1);
- }
-
- static
- openstuff ()
- {
- if (!(win = OpenWindow (&windef)))
- return (0);
- win -> UserData = (BYTE *) ICON;
-
- #ifdef USE_FUNCTIONS
- if (!(reply = CreatePort (NULL, NULL)) ||
- !(tr = CreateExtIO (reply, (long) sizeof (*tr))) ||
- OpenDevice (TIMERNAME, UNIT_VBLANK, tr, 0L)) {
- closestuff ();
- return (0);
- }
- #endif
-
- return (1);
- }
-
- static
- closestuff ()
- {
- #ifdef USE_FUNCTIONS
- if (tr) {
- if (tr -> tr_node.io_Device)
- CloseDevice (tr);
- DeleteExtIO (tr, (long) sizeof (*tr));
- }
- if (reply) DeletePort (reply);
- #endif
-
- if (win) CloseWindow (win);
- }
- SHAR_EOF
- cat << \SHAR_EOF > sys/amiga/iconify/iconify.h
- /* :ts=8 bk=0
- *
- * iconify.h: Should be used by all programs intending to use iconify.c.
- *
- * Copyright 1987 by Leo L. Schwab.
- * Permission is hereby granted for use in any and all programs, both
- * Public Domain and commercial in nature, provided this Copyright notice
- * is left intact. Purveyors of programs, at their option, may wish observe
- * the following conditions (in the spirit of hackerdom):
- * 1: You send me a free, registered copy of the program that uses the
- * iconify feature,
- * 2: If you're feeling really nice, a mention in the program's
- * documentation of my name would be neat.
- *
- * 8712.10 (415) 456-3960
- */
-
- #define ICON_IMAGE 0
- #define ICON_BORDER 1
- #define ICON_FUNCTION 2
-
- /* Suggested icon size for a standard (640 x 200) WorkBench screen. */
- #define ICONWIDTH ((UWORD) 50)
- #define ICONHEIGHT ((UWORD) 25)
- SHAR_EOF
- # End of shell archive
- exit 0
- -------
-