home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
DEMO
/
RIM22
/
MACROS
/
MENU.RM
< prev
next >
Wrap
Text File
|
1993-12-17
|
12KB
|
382 lines
/*
** Macro module: menu.c - Menu & toolbar support macros
**
** Copyright (C) 1993 Brian L. Smith
** Copyright (C) 1993 RimStar Technology, Inc.
** All rights reserved internationally.
** Unlicensed use is a violation of applicable laws.
**
** This source code is provided to licensed users of RimStar's products
** for the purpose of allowing the user to customize and/or enhance RimStar's
** products. The source code remains the property of the copyright holders
** with all rights reserved internationally.
** Any modifications to the source code are considered derivative works and
** all rights thereto are reserved to the copyright holders except
** that the purchaser may use the derivitive work in the same manner
** as permitted by the license governing the unmodified product.
** Distribution in any manner of any part of the original source code,
** whether in source or object form, is expressly prohibited without the
** express written permission of the copyright holders.
**
*/
#define INCL_MENU
#include "macro.h"
#define IDM_CUTAPPEND (IDM_EDIT_LAST+1)
#define IDM_COPYAPPEND (IDM_EDIT_LAST+2)
#define IDM_GOTOLINE (IDM_SB_LAST+1)
void
_init(void) {
LibAutoload("buffer", "EditFile",
"SaveBuffer",
"CopyToScrap",
"CutToScrap",
"CutAppendToScrap",
"CopyAppendToScrap"
);
LibAutoload("slide", "slide_in", "slide_out");
} /* end _init() */
char *
GetShortcut(char *function) {
PBINDING pBind;
pBind = KbdQueryBinding(function, NULL);
if ( !pBind )
return NULL;
return KbdKeysToString(pBind->key, pBind->cKeys);
} /* end GetShortcut() */
void
CustomizeMenu(void) {
#if 0
#define IDM_RUN (IDM_LASTACTION + 100)
#define IDM_RUNGREP (IDM_RUN + 1)
/* Add a pulldown menu to the action-bar */
MnuInsertSubMenu(NULL, NULL, 7, IDM_RUN, "~Run", "");
/* Add an item to the pulldown just created */
MnuInsertItem(NULL, IDM_RUN, MIT_END, 0, IDM_RUNGREP, "~Grep", NULL);
#endif
/* Add extra items to Edit pulldown */
MnuInsertItem(NULL, IDM_EDIT, 7, 0, IDM_CUTAPPEND , "Cut(append)" , NULL);
MnuSetItemText(IDM_CUTAPPEND, NULL, GetShortcut("CutAppendToScrap"));
MnuInsertItem(NULL, IDM_EDIT, 8, 0, IDM_COPYAPPEND, "Copy(append)", NULL);
MnuSetItemText(IDM_COPYAPPEND, NULL, GetShortcut("CopyAppendToScrap"));
/* Add extra items to Browse pulldown */
MnuInsertItem(NULL, IDM_BROWSE, MIT_END, 0, 0xffff, NULL, NULL); /* create separator line */
MnuInsertItem(NULL, IDM_BROWSE, MIT_END, 0, IDM_GOTOLINE, "Goto line" , NULL);
MnuSetItemText(IDM_GOTOLINE, NULL, GetShortcut("DlgGotoLine"));
} /* end CustomizeMenu() */
/*
** MnuSetMenuAccel - Sets hot-keys for all pulldown menu items
** according to current keyboard mapping
*/
MnuSetMenuAccel(void) {
CustomizeMenu();
MnuSetItemText(IDM_NEW , NULL, GetShortcut("BufNewFile"));
MnuSetItemText(IDM_OPEN , NULL, GetShortcut("DlgOpenFile"));
MnuSetItemText(IDM_CLOSE , NULL, GetShortcut("BufDeleteCurrentBuffer"));
MnuSetItemText(IDM_SAVE , NULL, GetShortcut("SaveBuffer"));
MnuSetItemText(IDM_SAVEAS , NULL, GetShortcut("DlgRenameBuffer"));
MnuSetItemText(IDM_PRINT , NULL, GetShortcut("PrintSetup"));
MnuSetItemText(IDM_PRINT , NULL, GetShortcut("Print"));
MnuSetItemText(IDM_LOAD_MACROFILE , NULL, GetShortcut("LibLoadMacro"));
MnuSetItemText(IDM_EXIT , NULL, GetShortcut("ExitEditor"));
MnuSetItemText(IDM_UNDO , NULL, GetShortcut("UndoModification"));
MnuSetItemText(IDM_REDO , NULL, GetShortcut("RedoModification"));
MnuSetItemText(IDM_CUT , NULL, GetShortcut("CutToScrap"));
MnuSetItemText(IDM_COPY , NULL, GetShortcut("CopyToScrap"));
MnuSetItemText(IDM_PASTE , NULL, GetShortcut("BufPasteScrap"));
MnuSetItemText(IDM_DELETE , NULL, GetShortcut("BufDeleteCharOrSelection"));
MnuSetItemText(IDM_INSERTFILE , NULL, GetShortcut("BufInsertFile"));
MnuSetItemText(IDM_IMPORTCLIP , NULL, GetShortcut("ImportClipboard"));
MnuSetItemText(IDM_EXPORTCLIP , NULL, GetShortcut("ExportClipboard"));
MnuSetItemText(IDM_SEARCH_FORWARD , NULL, GetShortcut("SearchForward"));
MnuSetItemText(IDM_SEARCH_BACKWARD , NULL, GetShortcut("SearchBackward"));
MnuSetItemText(IDM_SEARCH_AGAIN , NULL, GetShortcut("SearchAgain"));
MnuSetItemText(IDM_REPLACE_FORWARD , NULL, GetShortcut("ReplaceForward"));
MnuSetItemText(IDM_REPLACE_BACKWARD , NULL, GetShortcut("ReplaceBackward"));
MnuSetItemText(IDM_REPLACE_AGAIN , NULL, GetShortcut("ReplaceAgain"));
MnuSetItemText(IDM_SEARCH_NEXTERR , NULL, GetShortcut("ErrNextError"));
MnuSetItemText(IDM_SEARCH_PREVERR , NULL, GetShortcut("ErrPrevError"));
MnuSetItemText(IDM_SB_GOTODEF , NULL, GetShortcut("SbGotoDef"));
MnuSetItemText(IDM_SB_SYMBOL , NULL, GetShortcut("SbBrowseSymbolAtCursor"));
MnuSetItemText(IDM_SB_DEF , NULL, GetShortcut("SbBrowseDefs"));
MnuSetItemText(IDM_SB_REF , NULL, GetShortcut("SbBrowseRefs"));
MnuSetItemText(IDM_SB_MOD , NULL, GetShortcut("SbBrowseSymbolsDefinedInModule"));
MnuSetItemText(IDM_SB_NEXT , NULL, GetShortcut("SbFindNext"));
MnuSetItemText(IDM_SB_PREV , NULL, GetShortcut("SbFindPrev"));
MnuSetItemText(IDM_BUFFER_NEXT , NULL, GetShortcut("BufNextBuffer"));
MnuSetItemText(IDM_BUFFER_PREV , NULL, GetShortcut("BufPrevBuffer"));
MnuSetItemText(IDM_BUFFER_EXECUTE , NULL, GetShortcut("ExecAssoc"));
MnuSetItemText(IDM_BUFFER_CLOSE , NULL, GetShortcut("BufDeleteCurrentBuffer"));
MnuSetItemText(IDM_BUFFER_LIST , NULL, GetShortcut("DlgBufferList"));
MnuSetItemText(IDM_WINDOW_CASCADE , NULL, GetShortcut("WinCascade"));
MnuSetItemText(IDM_WINDOW_TILE_WIDE , NULL, GetShortcut("WinTileAcross"));
MnuSetItemText(IDM_WINDOW_TILE_TALL , NULL, GetShortcut("WinTileDown"));
MnuSetItemText(IDM_WINDOW_KEEP_TILED , NULL, GetShortcut("ToggleKeepTiled"));
MnuSetItemText(IDM_WINDOW_KEEP_CASCADED, NULL, GetShortcut("ToggleKeepCascaded"));
MnuSetItemText(IDM_WINDOW_NEXT , NULL, GetShortcut("WinNextWindow"));
MnuSetItemText(IDM_WINDOW_PREV , NULL, GetShortcut("WinPrevWindow"));
MnuSetItemText(IDM_WINDOW_CREATE , NULL, GetShortcut("WinNewWindow"));
MnuSetItemText(IDM_WINDOW_DELETE , NULL, GetShortcut("WinDeleteCurrentWindow"));
MnuSetItemText(IDM_CONFIG , NULL, GetShortcut("DlgConfigGlobals"));
MnuSetItemText(IDM_CONFIGFONT , NULL, GetShortcut("DlgConfigFonts"));
MnuSetItemText(IDM_CONFIGCOLORS , NULL, GetShortcut("DlgConfigColors"));
MnuSetItemText(IDM_CONFIGCURSOR , NULL, GetShortcut("DlgConfigCursors"));
MnuSetItemText(IDM_CONFIGASSOC , NULL, GetShortcut("DlgConfigAssoc"));
MnuSetItemText(IDM_KEYS_PLAY , NULL, GetShortcut("KbdMacroPlay"));
MnuSetItemText(IDM_KEYS_RECORD , NULL, GetShortcut("KbdMacroRecord"));
MnuSetItemText(IDM_KEYS_SAVEKBDMACRO, NULL, GetShortcut("KbdMacroSave"));
MnuSetItemText(IDM_KEYS_LOADKBDMACRO, NULL, GetShortcut("KbdMacroLoad"));
MnuSetItemText(IDM_HELP_FOR_HELP , NULL, GetShortcut("HelpForHelp"));
MnuSetItemText(IDM_ABOUT , NULL, GetShortcut("DlgVersion"));
} /* end MnuSetMenuAccel() */
/* MnuCommandHandler
** Handles WM_COMMAND messages generated by menus
*/
int
MnuCommandHandler(USHORT cmd) {
if ( cmd >= IDM_START_WINDOW_LIST ) {
/* Selecting a different window to be currently active window */
WinSetWindowFromID(cmd);
return 0;
}
if ( cmd >= IDM_START_BUFFER_LIST ) {
/* Selecting a different buffer for currently active window */
BufSetBufferFromID(cmd);
return 0;
}
switch ( cmd ) {
case IDM_NEW:
BufNewFile(); break;
case IDM_OPEN:
DlgOpenFile(); break;
case IDM_CLOSE:
case IDM_BUFFER_CLOSE:
BufDeleteCurrentBuffer(); break;
case IDM_SAVE:
SaveBuffer(); break;
case IDM_SAVEAS:
DlgRenameBuffer(); break;
case IDM_PRINTER_SETUP:
PrinterSetup(); break;
case IDM_PRINT:
Print(); break;
case IDM_LOAD_MACROFILE:
LibLoadMacro(); break;
case IDM_EXIT:
ExitEditor(); break;
case IDM_UNDO:
UndoModification(); break;
case IDM_REDO:
RedoModification(); break;
case IDM_CUT:
CutToScrap(); break; /* defined in buffer.rm */
case IDM_COPY:
CopyToScrap(); break; /* defined in buffer.rm */
case IDM_PASTE:
BufPasteScrap(); break;
case IDM_DELETE:
BufDeleteSelection(); break;
case IDM_INSERTFILE:
BufInsertFile(); break;
case IDM_IMPORTCLIP:
ImportClipboard(); break;
case IDM_EXPORTCLIP:
ExportClipboard(); break;
case IDM_CUTAPPEND:
CutAppendToScrap(); break;
case IDM_COPYAPPEND:
CopyAppendToScrap(); break;
case IDM_SEARCH_FORWARD:
SearchForward(); break;
case IDM_SEARCH_BACKWARD:
SearchBackward(); break;
case IDM_SEARCH_AGAIN:
SearchAgain(); break;
case IDM_REPLACE_FORWARD:
ReplaceForward(); break;
case IDM_REPLACE_BACKWARD:
ReplaceBackward(); break;
case IDM_REPLACE_AGAIN:
ReplaceAgain(); break;
case IDM_SEARCH_NEXTERR:
ErrNextError(); break;
case IDM_SEARCH_PREVERR:
ErrPrevError(); break;
case IDM_SB_GOTODEF:
SbGotoDef(); break;
case IDM_SB_SYMBOL:
SbBrowseSymbolAtCursor(); break;
case IDM_SB_DEF:
SbBrowseDefs(); break;
case IDM_SB_REF:
SbBrowseRefs(); break;
case IDM_SB_MOD:
SbBrowseSymbolsDefinedInModule(); break;
case IDM_SB_LOAD:
SbLoadDatabase(NULL, 0); break;
case IDM_SB_CLEAR:
SbUnloadDatabase(); break;
case IDM_SB_NEXT:
SbFindNext(); break;
case IDM_SB_PREV:
SbFindPrev(); break;
case IDM_GOTOLINE:
DlgGotoLine(); break;
case IDM_BUFFER_NEXT:
BufNextBuffer(); break;
case IDM_BUFFER_PREV:
BufPrevBuffer(); break;
case IDM_BUFFER_EXECUTE:
ExecAssoc(); break;
case IDM_BUFFER_LIST:
DlgBufferList(); break;
case IDM_WINDOW_CASCADE:
WinCascade(); break;
case IDM_WINDOW_TILE_WIDE:
WinTileAcross(); break;
case IDM_WINDOW_TILE_TALL:
WinTileDown(); break;
case IDM_WINDOW_KEEP_CASCADED:
ToggleKeepCascaded(); break;
case IDM_WINDOW_KEEP_TILED:
ToggleKeepTiled(); break;
case IDM_WINDOW_NEXT:
WinNextWindow(); break;
case IDM_WINDOW_PREV:
WinPrevWindow(); break;
case IDM_WINDOW_CREATE:
WinNewWindow(); break;
case IDM_WINDOW_DELETE:
WinDeleteCurrentWindow(); break;
case IDM_KEYS_PLAY:
KbdMacroPlay(); break;
case IDM_KEYS_RECORD:
KbdMacroRecord(); break;
case IDM_KEYS_SAVEKBDMACRO:
KbdMacroSave(); break;
case IDM_KEYS_LOADKBDMACRO:
KbdMacroLoad(); break;
case IDM_CONFIG:
DlgConfigGlobals(); break;
case IDM_CONFIGCOLORS:
DlgConfigColors(); break;
case IDM_CONFIGFONT:
DlgConfigFonts(); break;
case IDM_CONFIGCURSOR:
DlgConfigCursors(); break;
case IDM_CONFIGASSOC:
DlgConfigAssoc(); break;
case IDM_HELP_FOR_HELP:
HelpForHelp(); break;
case IDM_ABOUT:
DlgVersion(); break;
default:
return 1;
} /* end switch on cmd */
return 0;
} /* end MnuCommandHandler() */
int
MnuInitHandler(HWND hwnd, USHORT id) {
#if 0
switch ( id ) {
case IDM_FILE:
case IDM_EDIT:
case IDM_SEARCH:
case IDM_BROWSE:
case IDM_BUFFER:
case IDM_WINDOW:
case IDM_OPTIONS:
case IDM_HELP:
} /* end switch */
#endif
return 0;
} /* end MnuInitMenu() */
void
ToolbarCommandHandler(USHORT cmd) {
switch ( cmd ) {
case IDM_NEW:
BufNewFile(); break;
case IDM_OPEN:
DlgOpenFile(); break;
case IDM_BUFFER_NEXT:
BufNextBuffer(); break;
case IDM_BUFFER_PREV:
BufPrevBuffer(); break;
case IDM_SAVE:
BufWrite(); break;
case IDM_BUFFER_EXECUTE:
ExecAssoc(); break;
case IDM_PRINT:
Print(); break;
case IDM_UNDO:
UndoModification(); break;
case IDM_REDO:
RedoModification(); break;
case IDM_CUT:
CutToScrap(); break;
case IDM_COPY:
CopyToScrap(); break;
case IDM_PASTE:
BufPasteScrap(); break;
case IDM_INDENT:
slide_in(); break;
case IDM_OUTDENT:
slide_out(); break;
case IDM_SEARCH_FORWARD:
SearchForward(); break;
case IDM_SEARCH_AGAIN:
SearchAgain(); break;
case IDM_REPLACE_FORWARD:
ReplaceForward(); break;
} /* end switch */
} /* end ToolbarCommandHandler() */
/*
** End module: menu.c
*/