home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 10
/
Fresh_Fish_10_2352.bin
/
useful
/
util
/
edit
/
mg
/
src.lzh
/
amiga
/
ttymenu.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-23
|
20KB
|
764 lines
/*
* 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 "do_menu.h"
#ifdef DO_MENU
#include <exec/types.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
#include <intuition/intuition.h>
#ifdef LATTICE
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/exec.h>
#else
#include <functions.h>
#endif
#undef MANX
#undef LATTICE
#undef AZTEC
#include "compiler.h"
#include "no_macro.h"
#include "no_dired.h"
#include "gosmacs.h"
#include "browser.h"
#include "change_font.h"
#include "menu.h"
#undef TRUE
#undef FALSE
#include "def.h"
#ifdef BROWSER
#include "buffer.h"
#endif
#include "window.h"
#ifdef BROWSER
static int Add_Dir PROTO((char *dir, char *name));
static void Add_Devices PROTO((ULONG devtype));
#endif
extern struct Menu *AutoMenu;
extern struct Window *EmW;
#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 ANSI
#include <string.h>
#include <stdlib.h>
# 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
#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 GOSMACS
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 GOSMACS
{"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[] = {
#ifndef NO_MACRO
{"Start Kbd Macro C-x (", definemacro},
{"End Kbd Macro C-x )", finishmacro},
{"Call Kbd Macro C-x e", executemacro},
#endif
{"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(WordItem