home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mega Top 1
/
os2_top1.zip
/
os2_top1
/
DEMO
/
RIM22
/
MACROS
/
PWB.RM
< prev
next >
Wrap
Text File
|
1993-11-12
|
14KB
|
471 lines
/*
** Macro module: pwb.rm - Programmer's WorkBench(R) keyboard map
**
** Programmmer's WorkBench is a registered trademark of Microsoft Corporation
**
** 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.
**
*/
#include "macro.h"
/*
** This sets up the editor for a PWB keyboard mapping.
** To have the editor use this - copy or rename pwb.obm
** to keyboard.obm.
*/
void
_init(void) {
LibAutoload("misc", "quote", "next_word", "prev_word", "tospace",
"delete_next_word", "delete_prev_word", "toupper", "tolower");
LibAutoload("c_smart", "find_matching_delim");
LibAutoload("Search", "SearchSel");
LibAutoload("Buffer", "EditFile");
LibAutoload("KbdCUA", "KbdBindAsciiKeys", "CUACopy", "CUAMov", "CUAInsert",
"CUASel" );
} /* end _init() */
void
KbdBindDefault() {
char *self_insert = "SelfInsert";
char *p;
/* call function for cua mapping */
KbdBindAsciiKeys();
/*
** bookmarks
*/
KbdBind("Alt+1", "BookmarkSet 1");
KbdBind("Alt+2", "BookmarkSet 2");
KbdBind("Alt+3", "BookmarkSet 3");
KbdBind("Alt+4", "BookmarkSet 4");
KbdBind("Alt+5", "BookmarkSet 5");
KbdBind("Alt+6", "BookmarkSet 6");
KbdBind("Alt+7", "BookmarkSet 7");
KbdBind("Alt+8", "BookmarkSet 8");
KbdBind("Alt+9", "BookmarkSet 9");
KbdBind("Alt+0", "BookmarkSet 10");
KbdBind("Alt+J+1", "BookmarkGoto 1");
KbdBind("Alt+J+2", "BookmarkGoto 2");
KbdBind("Alt+J+3", "BookmarkGoto 3");
KbdBind("Alt+J+4", "BookmarkGoto 4");
KbdBind("Alt+J+5", "BookmarkGoto 5");
KbdBind("Alt+J+6", "BookmarkGoto 6");
KbdBind("Alt+J+7", "BookmarkGoto 7");
KbdBind("Alt+J+8", "BookmarkGoto 8");
KbdBind("Alt+J+9", "BookmarkGoto 9");
KbdBind("Alt+J+0", "BookmarkGoto 10");
/*
** help
*/
/*
** Deletions
*/
KbdBind("Alt+Y", "BufDeleteLine");
KbdBind("Shift+DELETE", p="BufDeleteToScrap");
KbdBind("Shift+KP_DELETE", p);
KbdBind("Shift+KP_MINUS", p);
KbdBind("Alt+K", "BufDeleteToEOL");
KbdBind("BACKSPACE", p="CUAMov BufDeletePrevChar");
KbdBind("Shift+BACKSPACE", p);
KbdBind("Ctrl+G", p);
KbdBind("Ctrl+Y", "DeleteLineOrSelection");
// KbdBind("Alt+BACKSPACE", "delete_next_word"); /* in misc.rm */
KbdBind("Ctrl+BACKSPACE", "delete_prev_word"); /* in misc.rm */
KbdBind("Alt+|", "BufDeleteWhitespace");
KbdBind("DELETE", p="BufDeleteCharOrSelection");
KbdBind("KP_DELETE", p);
KbdBind("Shift+KP_SLASH", p);
KbdBind("Ctrl+-", "BufDeleteCurrentBuffer");
/*
** Dialogs
*/
KbdBind("Alt+B", "DlgBufferList");
KbdBind("Alt+V", "DlgVersion");
KbdBind("Alt+O", "DlgRenameBuffer");
KbdBind("Alt+W", "SaveBuffer");
KbdBind("Alt+E", "DlgOpenFile");
KbdBind("Alt+G", "DlgGotoLine");
/* search & replace */
KbdBind("F3", "SearchSel 1");
KbdBind("F4", "SearchSel 0");
// KbdBind("Alt+F5", "SearchBackward");
// KbdBind("Shift + F5", "Search Again");
KbdBind("Ctrl+|", p="ReplaceForward");
KbdBind("Ctrl+L", p);
// KbdBind("Alt+F6", "ReplaceBackward");
// KbdBind("Shift+F6", "ReplaceAgain");
/*
** Keystroke macros
*/
KbdBind("Shift+Ctrl+R", "KbdMacroRecord"); /* starts/stops keystroke macro recording */
KbdBind("Alt+F7", "KbdMacroLoad"); /* load keystroke macro from disk */
// KbdBind("Shift+F7", "KbdMacroPause"); /* pause keystroke macro recording */
KbdBind("Shift+Ctrl+P", "KbdMacroPlay"); /* plays a recorded keystroke macro */
KbdBind("Alt+F8", "KbdMacroSave"); /* saves last recorded macro to disk */
/*
** cursor Movement
*/
KbdBind("Shift+ENTER", p="CUAMov MovNextline");
KbdBind("Shift+KP_ENTER", p);
KbdBind("PGUP", p="CUAMov MovPageUp");
KbdBind("Ctrl+R", p);
KbdBind("KP_PGUP", p);
KbdBind("Ctrl+HOME", p="CUAMov MovSOF");
KbdBind("Ctrl+KP_HOME", p);
KbdBind("HOME", p="CUAMov MovSOT");
KbdBind("KP_HOME", p);
KbdBind("Ctrl+C", p="CUAMov MovPageDown");
KbdBind("PGDN", p);
KbdBind("KP_PGDN", p);
KbdBind("Ctrl+END", p="CUAMov MovEOF");
KbdBind("Ctrl+KP_END", p);
KbdBind("END", p="CUAMov MovEOL");
KbdBind("KP_END", p);
KbdBind("UP", p="CUAMov MovUp");
KbdBind("KP_UP", p);
KbdBind("Ctrl+E", p);
KbdBind("DOWN", p="CUAMov MovDown");
KbdBind("KP_DOWN", p);
KbdBind("Ctrl+X", p);
KbdBind("KP_LEFT", p="CUAMov MovLeft");
KbdBind("LEFT", p);
KbdBind("Ctrl+S", p);
KbdBind("Ctrl+LEFT", p="CUAMov prev_word"); /* in misc.rm */
KbdBind("Ctrl+KP_LEFT", p);
KbdBind("Ctrl+A", p);
KbdBind("RIGHT", "MovRight");
KbdBind("KP_RIGHT", p="CUAMov MovRight");
KbdBind("RIGHT", p);
KbdBind("Ctrl+D", p);
KbdBind("Ctrl+F", p="CUAMov next_word"); /* in misc.rm */
KbdBind("Ctrl+RIGHT", p);
KbdBind("Ctrl+KP_RIGHT", p);
KbdBind("Shift+TAB", "CUAMov MovPrevTabPos");
KbdBind("Ctrl+Enter", "BufInsertNewline");
KbdBind("Ctrl+N", "PWBInsertNewline");
KbdBind("Enter", "PWB BufInsertNewline");
KbdBind("TAB", "PWBTab");
/*
** selection operations
*/
KbdBind("Alt+A", "MarkExclusive");
KbdBind("Alt+C", "MarkColumn");
KbdBind("Shift+HOME", p="CUASel MovSOT");
KbdBind("Shift+KP_HOME", p);
KbdBind("Shift+Ctrl+LEFT", p="CUASel MovWordLeft");
KbdBind("Shift+Ctrl+KP_LEFT", p);
KbdBind("Shift+Ctrl+RIGHT", p="CUASel MovWordRight");
KbdBind("Shift+Ctrl+KP_RIGHT",p);
KbdBind("Shift+END", p="CUASel MovEOL");
KbdBind("Shift+KP_END", p);
KbdBind("Shift+Ctrl+END", p="CUASel MovEOF");
KbdBind("Shift+Ctrl+KP_END", p);
KbdBind("Shift+Ctrl+HOME", p="CUASel MovSOF");
KbdBind("Shift+Ctrl+KP_HOME", p);
KbdBind("Shift+PGUP", p="CUASel MovPageUp");
KbdBind("Shift+KP_PGUP", p);
KbdBind("Shift+PGDN", p="CUASel MovPageDown");
KbdBind("Shift+KP_PGDN", p);
KbdBind("Shift+LEFT", p="CUASel MovLeft");
KbdBind("Shift+KP_LEFT", p);
KbdBind("Shift+RIGHT", p="CUASel MovRight");
KbdBind("Shift+KP_RIGHT", p);
KbdBind("Shift+UP", p="CUASel MovUp");
KbdBind("Shift+KP_UP", p);
KbdBind("Shift+DOWN", p="CUASel MovDown");
KbdBind("Shift+KP_DOWN", p);
KbdBind("Alt+L", "MarkLine");
KbdBind("Alt+M", "MarkNormal");
// KbdBind("Ctrl+A", "MarkSwapSel");
KbdBind("Alt+H", "HelpQueryInfHelp");
/*
** NOTE: To use QueryInfHelp you must add the following environment variable
** to your config.sys:
** SET RSE_INF=GUIREF20.INF+PMFUN.INF+PMGPI.INF+PMHOK.INF+PMMSG.INF+PMREL.INF+PMWIN.INF+PMWKP.INF
** The setting is taken from the combination of the PROGREF20 and PMREF environment variables
** You may add additional .INF files or remove some.
*/
#if 0
KbdBind("Alt+H", "HelpQueryQuickHelp"); /* invokes Microsoft Quick Help program */
#endif
/*
** toggles
*/
// KbdBind("Ctrl+W", "ToggleBackups");
KbdBind("Ctrl+V", p="CUAMov ToggleInsert");
KbdBind("INSERT", p);
KbdBind("KP_INSERT", p);
KbdBind("Alt+T", "ToggleTabs");
KbdBind("Alt+N", "BufNextBuffer");
KbdBind("Alt+P", "Print");
KbdBind("Ctrl+P", "quote"); /* in misc.rm */
KbdBind("Alt+R", "BufInsertFile");
KbdBind("Alt+-", "BufPrevBuffer");
/*
** undo & redo operations
*/
KbdBind("Alt+U", p="Undo");
KbdBind("Alt+BACKSPACE", p);
KbdBind("Shift+Ctrl+BACKSPACE", p);
KbdBind("KP_STAR", "UndoModification");
KbdBind("Alt+Y", "Redo");
KbdBind("Shift+KP_STAR", "RedoModification");
KbdBind("Shift+Ctrl+KP_STAR", "UndoAll");
KbdBind("Shift+Alt +KP_STAR", "RedoAll");
KbdBind("Ctrl+[", "find_matching_delim"); /* in c_smart.rm */
KbdBind("Alt+X", "ExitEditor");
/*
** KP stands for the Key Pad keys.
**
** Alt+ ESCAPE, Alt+TAB and Ctrl+ESCAPE are reserved for OS/2's use
** do not define these as they will be ignored.
*/
KbdBind("Shift+F7", "PWBRefresh");
KbdBind("Shift+F2", "BufWrite");
KbdBind("Ctrl+J", "tospace");
/*
** window operations
*/
KbdBind("Ctrl+F10", "WinMaximize");
KbdBind("F6", "WinNextWindow");
KbdBind("Shift+F6", "WinPrevWindow");
KbdBind("F2", "WinTileWindows");
// KbdBind("Shift+F2", "WinCascade");
// KbdBind("F3", "WinNewWindow");
KbdBind("Ctrl+F4", "WinDeleteCurrentWindow");
KbdBind("Ctrl+B", "WinScrollBottom");
KbdBind("Ctrl+C", "WinScrollCenter");
KbdBind("Ctrl+W", p="CUAMov WinScrollDown");
KbdBind("Ctrl+UP", p);
KbdBind("Ctrl+KP_UP", p);
KbdBind("Ctrl+Z", p="CUAMov WinScrollUp");
KbdBind("Ctrl+DOWN", p);
KbdBind("Ctrl+KP_Down", p);
KbdBind("Ctrl+T", "WinScrollTop");
/*
** macro operations
*/
KbdBind("F9", "LibLoadMacro");
KbdBind("F10", "LibExecFunction");
KbdBind("Ctrl+F3", "ExecAssoc");
/*
** For use in error output buffer - place cursor on error line
** ALT+F9 jumps to file & line in error, loading the file if needed
*/
KbdBind("Alt+F9", "ErrJumpToError");
KbdBind("Shift+F4", "ErrPrevError");
KbdBind("Shift+F3", "ErrNextError");
/*
** cut/copy/paste
*/
KbdBind("KP_MINUS", "BufCutToScrap");
KbdBind("Ctrl+INSERT", "CUACopy BufCopyToScrap");
KbdBind("Ctrl+KP_INSERT", "CUACopy BufCopyToScrap");
KbdBind("Shift+KP_STAR", "CUACopy BufCopyToScrap");
KbdBind("Shift+KP_MINUS", "BufCutToScrap 1"); /* append to current scrap */
// KbdBind("Shift+KP_PLUS", "BufCopyToScrap 1"); /* append to current scrap */
KbdBind("Shift+INSERT", "BufPasteScrap");
KbdBind("Shift+KP_INSERT", "BufPasteScrap");
KbdBind("Shift+KP_PLUS", "BufPasteScrap");
// KbdBind("Shift+INSERT", "ImportClipboard");
// KbdBind("Ctrl+INSERT", "ExportClipboard");
#if 0
KbdBind("KP_5", "");
#endif
KbdBind("Shift+Ctrl+-", "WinDeleteWindowAndBuffer");
KbdBind("Ctrl+K", "ExecKillProcess"); /* Kills a program executed on buffer */
KbdBind("F8", "SysSaveAndExit");
KbdBind("Alt+F4", "SysSaveAndExit");
/* Source browser bindings */
KbdBind("Ctrl+Alt+F12", p="SbJumpBack");
KbdBind("Alt+J+B", p);
KbdBind("Alt+S+Alt+S", p="SbBrowseSymbolAtCursor");
KbdBind("Alt+S+S", p);
KbdBind("F11", p);
KbdBind("Alt+S+Alt+D", p="SbBrowseDefs");
KbdBind("Alt+S+D", p);
KbdBind("Shift+F11", p);
KbdBind("Alt+S+Alt+M", p="SbBrowseSymbolsDefinedInModule");
KbdBind("Alt+S+M", p);
KbdBind("Alt+F11", p);
KbdBind("Alt+S+Alt+R", p="SbBrowseRefs");
KbdBind("Alt+S+R", p);
KbdBind("Ctrl+F11", p);
KbdBind("Alt+S+Alt+F", p="SbFindNext");
KbdBind("Alt+S+F", p);
KbdBind("F12", p);
KbdBind("Alt+S+Alt+B", p="SbFindPrev");
KbdBind("Alt+S+B", p);
KbdBind("Shift+F12", p);
KbdBind("Alt+F12", "SbGotoDef");
} /* end KbdBindDefault() - PWB keyboard map */
void
MarkToSOT(void) {
SELECTION sel;
LONG line, column;
LONG sot_line, sot_column;
BufQueryPosition( &line, &column);
PosSOT();
BufQueryPosition( &sot_line, &sot_column);
sel.type = SELECT_NORMAL;
sel.s_line = sel.e_line = line;
sel.s_column = sot_column;
sel.e_column = column;
MarkCreateSel(&sel);
} /* end MarkToSOT() */
void
BookmarkSet(USHORT number) {
HMARK hMark;
USHORT reply;
char szTitle[32];
hMark = MarkQueryGlobalFromID(number);
if ( !hMark )
hMark = MarkAllocGlobal(number);
else {
sprintf(szTitle, "Set bookmark %d", number);
reply = PopupMsgBox( "This bookmark is already set. Overwrite?", szTitle,
MB_YESNO | MB_ICONQUESTION |
MB_MOVEABLE | MB_APPLMODAL);
if ( reply == MBID_YES )
MarkResetMark(hMark);
}
} /* end BookmarkSet() */
void
BookmarkGoto(USHORT number) {
HMARK hMark;
char szTitle[32];
hMark = MarkQueryGlobalFromID(number);
if ( hMark )
MarkGoto(hMark);
else {
sprintf(szTitle, "Jump to bookmark %d", number);
PopupMsg("That bookmark is not set", szTitle);
}
} /* end BookmarkGoto() */
void
PWBInsertNewline() {
SELECTION sel;
if ( MarkQuerySel( &sel, 1) )
MovAbs( sel.s_line, sel.s_column );
MovSOL();
BufInsertNewline();
} /* end PWBInsertNewline() */
void
MovNextline( void ) {
MarkRemoveSel();
MovDown();
MovSOT();
} /* end MovNextline() */
void
DeleteLineOrSelection( void ) {
if ( !MarkQuerySelType() )
BufDeleteLine();
else
BufDeleteCharOrSelection();
} /* end DeleteLineOrSelection() */
void
PWB(char *func) {
SELECTION sel;
if ( !MarkQuerySelType() ) {
ExecFunction( func );
} else {
MarkQuerySel( &sel, 1);
MarkRemoveSel();
PosAbs( sel.s_line, sel.s_column );
}
} /* end PWB() */
void
BufDeleteToScrap( void ) {
if ( MarkQuerySelType() )
BufCutToScrap();
else if ( BufQueryChar() != '\n' )
BufDeleteChar();
} /* end PWBDelToScrap() */
void
PWBRefresh() {
EditFile( BufQueryFilename(), 0L );
} /* end PWBRefresh() */
void
PWBTab() {
MovAbs(0L, BufQueryNextTab(BufQueryColumn()));
} /* end PWBTab() */
/*
** End module: pwb.rm
*/