home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / DEMO / RIM22 / MACROS / MULTIED.RM < prev    next >
Text File  |  1993-11-05  |  15KB  |  451 lines

  1. /*
  2. ** Macro module: multied.rm - MultiEdit(R) keyboard map
  3. **
  4. ** Multi-Edit is a registered trademark of American Cybernetics, Inc.
  5. **
  6. ** Copyright (C) 1993 Brian L. Smith
  7. ** Copyright (C) 1993 RimStar Technology, Inc.
  8. ** All rights reserved internationally.
  9. ** Unlicensed use is a violation of applicable laws.
  10. **
  11. ** This source code is provided to licensed users of RimStar's products
  12. ** for the purpose of allowing the user to customize and/or enhance RimStar's
  13. ** products. The source code remains the property of the copyright holders
  14. ** with all rights reserved internationally.
  15. ** Any modifications to the source code are considered derivative works and
  16. ** all rights thereto are reserved to the copyright holders except
  17. ** that the purchaser may use the derivitive work in the same manner
  18. ** as permitted by the license governing the unmodified product.
  19. ** Distribution in any manner of any part of the original source code,
  20. ** whether in source or object form, is expressly prohibited without the
  21. ** express written permission of the copyright holders.
  22. **
  23. */
  24.  
  25. #include "macro.h"
  26.  
  27.     /*
  28.     ** This sets up the editor for a Multi-Edit keyboard mapping.
  29.     ** The following keys assignments are not supported in this
  30.     ** version of the editor,    alternatives are provided in ():
  31.     **        F8 - Copy Block (Use Ctrl+Ins & Shift+Ins)
  32.     **        Shift+F8 - Move Block (Use Shift+Del & Shift+Ins)
  33.     **        F10 - Menu (press and release Alt key instead)
  34.     **        Shift+F3 - File Manager
  35.     **        Shift+F8 - Move Block
  36.     **        Shift+F1 - Previous Help Topic
  37.     **        Ctrl+F1 - Language Extension Help
  38.     **        Shift+F4 - Condensed Display
  39.     **        Ctrl+F5 - Repeat last Search & Replace    (Use SearchAgain & ReplaceAgain) 
  40.     **        Alt+A    - ASCII Table
  41.     **        Alt+J    - Right Justify
  42.     **        Alt+K    - Display Key-Codes (use KbdQueryFunction)
  43.     **        Alt+P    - Phone/Address List
  44.     **        Alt+Ins    - Cut & Paste from Help (use copy from help & 
  45.     **                       import clipboard & paste)    
  46.     **        Alt+S    - Spell feature
  47.     **
  48.     **    There are over 300 functions available to you in the editor.
  49.     ** Some of them have key strokes assigned to them in this file and 
  50.     ** some are commented out leaving the choice of key stroke assignment
  51.     ** to you.
  52.     **
  53.     ** To have the editor use this keyboard mapping - copy or rename multiedt.obm
  54.     ** to keyboard.obm. Brief.obm is the default key map for
  55.     ** the RimStar Programmer's editor.
  56.     */
  57.  
  58. void
  59. _init(void) {
  60.     LibAutoload("misc",         "quote", "next_word", "prev_word", "toupper", "tolower",
  61.                                     "delete_next_word", "delete_prev_word");
  62.     LibAutoload("c_smart",    "find_matching_delim" );
  63.     LibAutoload( "c_indent", "_c_expand" );
  64.     LibAutoload( "kbd", "KbdBindAsciiKeys");
  65. } /* end _init() */
  66.  
  67.  
  68. void
  69. KbdBindDefault() {
  70.     char  *self_insert = "SelfInsert";
  71.     char  *p;
  72.  
  73.     /*
  74.     **  ascii mapping
  75.     */
  76.     KbdBindAsciiKeys();
  77.  
  78.     /*
  79.     **    Help
  80.     */
  81.     KbdBind("Alt+H",                    "HelpQueryInfHelp");
  82.     KbdBind("Shift+F1",                "HelpIndex");
  83.     KbdBind("F1",                        "HelpForHelp");
  84.     /*
  85.     ** NOTE: To use QueryInfHelp you must add the following environment variable
  86.     **         to your config.sys:
  87.     **     SET RSE_INF=GUIREF20.INF+PMFUN.INF+PMGPI.INF+PMHOK.INF+PMMSG.INF+PMREL.INF+PMWIN.INF+PMWKP.INF
  88.     ** The setting is taken from the combination of the  PROGREF20 and PMREF environment variables
  89.     ** You may add additional .INF files or remove some.
  90.     */
  91.   #if 0
  92.     KbdBind("Alt+H",                "HelpQueryQuickHelp");    /* invokes Microsoft Quick Help program */
  93.   #endif
  94.  
  95.     /*
  96.     **    bookmarks
  97.     */
  98.     KbdBind("Alt+J+1",            "BookmarkGoto 1");
  99.     KbdBind("Alt+J+2",            "BookmarkGoto 2");
  100.     KbdBind("Alt+J+3",            "BookmarkGoto 3");
  101.     KbdBind("Alt+J+4",            "BookmarkGoto 4");
  102.     KbdBind("Alt+J+5",            "BookmarkGoto 5");
  103.     KbdBind("Alt+J+6",            "BookmarkGoto 6");
  104.     KbdBind("Alt+J+7",            "BookmarkGoto 7");
  105.     KbdBind("Alt+J+8",            "BookmarkGoto 8");
  106.     KbdBind("Alt+J+9",            "BookmarkGoto 9");
  107.     KbdBind("Alt+J+0",            "BookmarkGoto 10");
  108.  
  109.     KbdBind("Alt+1",                 "BookmarkSet 1");
  110.     KbdBind("Alt+2",                 "BookmarkSet 2");
  111.     KbdBind("Alt+3",                 "BookmarkSet 3");
  112.     KbdBind("Alt+4",                 "BookmarkSet 4");
  113.     KbdBind("Alt+5",                 "BookmarkSet 5");
  114.     KbdBind("Alt+6",                 "BookmarkSet 6");
  115.     KbdBind("Alt+7",                 "BookmarkSet 7");
  116.     KbdBind("Alt+8",                 "BookmarkSet 8");
  117.     KbdBind("Alt+9",                 "BookmarkSet 9");
  118.     KbdBind("Alt+0",                 "BookmarkSet 10");
  119.  
  120.     /*
  121.     ** Deletions
  122.     */
  123.     KbdBind("Ctrl+Shift+DELETE",        p="BufDeleteToEOL");
  124.     KbdBind("Ctrl+Shift+KP_DELETE",    p);
  125.     KbdBind("Ctrl+Shift+BACKSPACE",    "BufDeleteToSOL");
  126.     KbdBind("Alt+|",                         "BufDeleteWhitespace");
  127.     KbdBind("BACKSPACE",                      p="BufBackspace");
  128.     KbdBind("Shift+BACKSPACE",            p);
  129.     KbdBind("Ctrl+DELETE",                  "delete_next_word");    /* in misc.rm */
  130.     KbdBind("Ctrl+BACKSPACE",              "delete_prev_word");    /* in misc.rm */
  131.     KbdBind("Alt+BACKSPACE",             "Undo");
  132.     KbdBind("KP_STAR",                      "UndoModification");
  133.     KbdBind("Shift+Ctrl+KP_STAR",        "UndoAll");
  134.  
  135.     KbdBind("Alt+N",                 "BufNextBuffer");
  136.     KbdBind("Ctrl+F2",             "DlgRenameBuffer");
  137.     KbdBind("Alt+P",                 "Print");
  138.  
  139.     KbdBind("Alt+Q+T",              "quote");        /* in misc.rm */
  140.  
  141.     KbdBind("Alt+R",                 "BufInsertFile");
  142.  
  143.  
  144.     KbdBind("Alt+I",                "ToggleInsert");
  145.     KbdBind("Alt+T",                 "ToggleTabs");
  146.   #if 0
  147.     KbdBind("Alt+Z",                 "");  /* Start windowed command interpreter. Use Alt+ESC to start one. */
  148.   #endif
  149.     KbdBind("Alt+-",                 "BufPrevBuffer");
  150.  
  151.     /*
  152.     **    Dialogs
  153.     */
  154.     KbdBind("Ctrl+F6",             "DlgBufferList");
  155.     KbdBind("Alt+E",                "DlgOpenFile");
  156.     KbdBind("Alt+V",                 "DlgVersion");
  157.     KbdBind("F2",                     "SaveBuffer");
  158.     KbdBind("F3",                     "BufNewFile");
  159.     /*
  160.     **  All supported special key names follow, even those not assigned
  161.     **  just so you know what every key is named.
  162.     **
  163.     **  KP stands for the Key Pad keys.
  164.     **
  165.     **  Alt+ESCAPE, Alt+TAB and Ctrl+ESCAPE are reserved for OS/2 PM's use
  166.     **  do not define these as they will be ignored.
  167.     */
  168.     KbdBind("Shift+TAB",                  "MovPrevTabPos");
  169.     KbdBind("Ctrl+Enter",            "BufInsertNewline");
  170.     KbdBind("F8",                        "BufCopyToScrap");
  171.  
  172.     KbdBind("F6",                          "WinNextWindow");
  173.     KbdBind("Shift+F6",                "WinPrevWindow");
  174. //    KbdBind("F2",                        "WinTileWindows");
  175. //    KbdBind("Shift+F2",                "WinCascade");
  176. //    KbdBind("F3",                        "WinNewWindow");
  177. //    KbdBind("F4",                        "WinDeleteCurrentWindow");
  178.  
  179.     /*
  180.     **    Search &  Replace Operations
  181.     */
  182.     KbdBind("F5",                        "SearchForward");
  183. //    KbdBind("F5",                        "SearchBackward");
  184. //    KbdBind("F5",                        "SearchAgain");
  185.     KbdBind("Shift+F5",                 "ReplaceForward");
  186. //    KbdBind("Shitf+F5",                 "ReplaceBackward");
  187. //    KbdBind("Shift+F6",                "ReplaceAgain");
  188.  
  189.     /*
  190.     **    Keystroke Macros
  191.     */
  192.     KbdBind("Alt+F10",                 "KbdMacroRecord");      /* starts/stops keystroke macro recording */
  193.     KbdBind("Alt+Shift+F10",        "KbdMacroLoad");      /* load keystroke macro from disk */
  194. //    KbdBind("Shift+F7",                "KbdMacroPause");        /* pause keystroke macro playback */
  195.     KbdBind("F10",                        "KbdMacroPlay");        /* plays a recorded keystroke macro */
  196.     KbdBind("Ctrl+F10",                 "KbdMacroSave");          /* saves last recorded macro to disk */
  197.  
  198.     KbdBind("Ctrl+Shift+F10",        "LibLoadMacro");
  199.     KbdBind("Shift+F10",                "LibExecFunction");
  200.     KbdBind("F9",                        "ExecAssoc");
  201.     KbdBind("Ctrl+K",                      "ExecKillProcess");        /* Kills a program executed on buffer */
  202.     /*
  203.     ** For use in error output buffer - place cursor on error line
  204.     ** ALT+F9 jumps to file & line in error, loading the file if needed
  205.     */
  206. //    KbdBind("Alt+F9",                "ErrJumpToError");
  207.     KbdBind("Shift+F9",              "ErrNextError");
  208.     KbdBind("Ctrl+P",                  "ErrPrevError");
  209.     /*
  210.     ** NOTE:  Consecutive requests of the Home builtin command and the End builtin
  211.     **          command support BRIEF's convention. A key assigned to the Home or End
  212.     **          builtin command will perform three different actions when invoked
  213.     **          consecutively:
  214.     **
  215.     **          For the Home builtin command:
  216.     **
  217.     **          1st time command invoked      - move to the beginning of the current line
  218.     **          2nd (consecutive) invocation - move to the beginning of the top line in window
  219.     **          3rd (consecutive) invocation - move to the beginning of the buffer (file)
  220.     **
  221.     **          For the End builtin command:
  222.     **
  223.     **          1st time command invoked - move to end of current line
  224.     **          2nd (consecutive) invocation - move to end of last line in window
  225.     **          3rd (consecutive) invocation - move to end of the buffer (file)
  226.     **
  227.     **
  228.     **          So if the Home builtin command is assigned to the HOME key:
  229.     **
  230.     **          HOME              moves to the beginning of the current line
  231.     **          HOME+HOME        moves to the beginning of the top line in window
  232.     **          HOME+HOME+HOME moves to the beginning of the file
  233.     **
  234.     **          and if the End builtin command is assigned to the END key:
  235.     **
  236.     **          END                moves to the end of the current line
  237.     **          END+END          moves to the end of the last line in window
  238.     **          END+END+END     moves to the end of the file
  239.     **
  240.     **          Any other commands invoked in between will reset the counters.
  241.     **
  242.     **  If you don't want this behavior you can use LineStart and LineEnd
  243.     **  these commands do only the single action.
  244.     */
  245.     /*
  246.     **    cursor movement
  247.     */
  248.     KbdBind("KP_LEFT",            p="MovLeft");
  249.     KbdBind("LEFT",                p);
  250.     KbdBind("RIGHT",                p="MovRight");
  251.     KbdBind("KP_RIGHT",            p);
  252.     KbdBind("UP",                    p="MovUp");
  253.     KbdBind("KP_UP",                p);
  254.     KbdBind("DOWN",                p="MovDown");
  255.     KbdBind("KP_DOWN",            p);
  256.     KbdBind("Ctrl+LEFT",            p="prev_word");    /* in misc.rm */
  257.     KbdBind("Ctrl+KP_LEFT",        p);
  258.     KbdBind("Ctrl+RIGHT",        p="next_word");    /* in misc.rm */
  259.     KbdBind("Ctrl+KP_RIGHT",    p);
  260.     KbdBind("Ctrl+E",               "StartOfBlock");
  261.     KbdBind("Ctrl+C",               "EndOfBlock");
  262.     KbdBind("Alt+F5",                  "DlgGotoLine");
  263.     KbdBind("HOME",                 p="MovSOL");
  264.     KbdBind("KP_HOME",            "MovSOL");
  265.     KbdBind("END",                    p="MovEOL");
  266.     KbdBind("KP_END",                p);
  267.     KbdBind("Ctrl+HOME",            "MovSOF");
  268.     KbdBind("Ctrl+END",            "MovEOF");
  269.     KbdBind("Ctrl+T",                "MovTopWin");
  270.     KbdBind("Ctrl+B",                "MovBottomWin");
  271.     KbdBind("PGUP",                p="MovPageUp");
  272.     KbdBind("KP_PGUP",             p);
  273.     KbdBind("PGDN",                p="MovPageDown");
  274.     KbdBind("KP_PGDN",             p);
  275. //    KbdBind("Ctrl+T",                  "WinScrollTop");
  276.     KbdBind("Ctrl+UP",              p="WinScrollDown");
  277.     KbdBind("Ctrl+KP_UP",            p);
  278. //    KbdBind("Ctrl+B",                  "WinScrollBottom");
  279.     KbdBind("Ctrl+DOWN",              p="WinScrollUp");
  280.     KbdBind("Ctrl+KP_DOWN",          p);
  281.     KbdBind("Ctrl+I",                "SelfInsert");
  282.     KbdBind("Ctrl+U",                "MovPrevTabPos");
  283.     KbdBind("F4",                      "MarkPushPos");
  284.     KbdBind("Shift+F4",              "MarkPopPos");
  285.     KbdBind("Shift+LEFT",        "MovPrevChar");
  286.     KbdBind("Shift+RIGHT",        "MovNextChar");
  287.   #if 0
  288.     KbdBind("KP_5", "");
  289.   #endif
  290.     /*
  291.     **    Block Operations
  292.     */
  293.     KbdBind("F7",                     "MarkLineOrEndMark");
  294.     KbdBind("Shift+F7",            "MarkColumn");
  295.     KbdBind("Alt+A",                "MarkExclusive");
  296.     KbdBind("Ctrl+F7",             "MarkNormal");
  297. //    KbdBind("F7",                     "MarkEndSel");
  298.     KbdBind("Alt+B+F",              "MarkRemoveSel");
  299.     KbdBind("Alt+F3",                "slide_in");
  300.     KbdBind("Alt+F2",                "slide_out");
  301.     KbdBind("Ctrl+F8",             p="BufDeleteCharOrSelection");
  302.     KbdBind("DELETE",                p);
  303.     KbdBind("KP_DELETE",            p);
  304.     KbdBind("Ctrl+INSERT",         p="BufCopyToScrap");
  305.     KbdBind("Ctrl+KP_INSERT",    p);
  306.     KbdBind("Shift+DELETE",        p="BufCutToScrap");
  307.     KbdBind("Shift+KP_DELETE",    p);
  308.     KbdBind("Ctrl+KP_PLUS",        "CopyAppendToScrap");    /* append to current scrap */
  309.     KbdBind("Shift+INSERT",        p="BufPasteScrap");
  310.     KbdBind("Shift+KP_INSERT",    p);
  311.     KbdBind("Ctrl+KP_MINUS",    "CutAppendToScrap");        /* append to current scrap */
  312.     KbdBind("Alt+Shift+BACKSPACE","BufDeleteLine");
  313.     KbdBind("Shift+F2",             "SaveBuffer");
  314.     KbdBind("Ctrl+A",                  "MarkSwapSel");
  315.  
  316. //    KbdBind("Shift+INSERT",        "ImportClipboard");
  317. //    KbdBind("Ctrl+INSERT",        "ExportClipboard");
  318.  
  319.     KbdBind("Ctrl+-",                  "BufDeleteCurrentBuffer");
  320.     KbdBind("Shift+Ctrl+-",          "WinDeleteWindowAndBuffer");
  321.     KbdBind("Ctrl+W",                  "ToggleBackups");
  322.                     
  323.     /*
  324.     **    Default  Key Assignments
  325.     */
  326.     KbdBind("Alt+Q",                      "SysSaveAndExit");
  327.     KbdBind("Alt+X",                     "ExitEditor");
  328.     KbdBind("Alt+F9",                    "_c_expand");
  329.     KbdBind("Alt+Enter",                "Redo");
  330.     KbdBind("Shift+KP_STAR",          "RedoModification");
  331.     KbdBind("Shift+Alt +KP_STAR",    "RedoAll");
  332.     KbdBind("Ctrl+F9",                 "find_matching_delim");    /* in c_smart.rm */
  333.  
  334.     /* Source browser bindings */
  335.     KbdBind("Ctrl+Alt+F12",        p="SbJumpBack");
  336.     KbdBind("Alt+J+B",            p);
  337.  
  338.     KbdBind("Alt+S+Alt+S",        p="SbBrowseSymbolAtCursor");
  339.     KbdBind("Alt+S+S",              p);
  340.     KbdBind("F11",                    p);
  341.     
  342.     KbdBind("Alt+S+Alt+D",         p="SbBrowseDefs");
  343.     KbdBind("Alt+S+D",              p);
  344.     KbdBind("Shift+F11",            p);
  345.  
  346.     KbdBind("Alt+S+Alt+M",         p="SbBrowseSymbolsDefinedInModule");
  347.     KbdBind("Alt+S+M",              p);
  348.     KbdBind("Alt+F11",            p);
  349.     KbdBind("Ctrl+G",                p); /* Brief's `routines' assignment */
  350.  
  351.     KbdBind("Alt+S+Alt+R",         p="SbBrowseRefs");
  352.     KbdBind("Alt+S+R",              p);
  353.     KbdBind("Ctrl+F11",            p);
  354.  
  355.     KbdBind("Alt+S+Alt+F",         p="SbFindNext");
  356.     KbdBind("Alt+S+F",              p);
  357.     KbdBind("F12",                    p);
  358.  
  359.     KbdBind("Alt+S+Alt+B",         p="SbFindPrev");
  360.     KbdBind("Alt+S+B",              p);
  361.     KbdBind("Shift+F12",            p);
  362.  
  363.     KbdBind("Alt+F12",            "SbGotoDef");
  364.     KbdBind("Alt+F12",            "SbGotoDef");
  365.  
  366. } /* end KbdBindDefault() - Multi-edit key map */
  367.  
  368.  
  369. void
  370. MarkLineOrEndMark( void ) {
  371.     SHORT rc;
  372.  
  373.     rc = MarkQuerySelType();
  374.     if ( rc )
  375.         MarkEndSel();
  376.     else
  377.         MarkLine();
  378.  
  379. } /* end MarkLineOrEndMark */
  380.  
  381. void
  382. CopyAppendToScrap(void) { 
  383.     
  384.     BufCopyToScrap(1);
  385. } /* end CopyAppendToScrap */
  386.  
  387. void
  388. CutAppendToScrap(void) {
  389.  
  390.     BufCutToScrap(1);
  391.  
  392. } /* end CutAppendToScrap */
  393.  
  394. void 
  395. StartOfBlock(void) {
  396.     SELECTION p;
  397.  
  398.     MarkQuerySel( &p );
  399.     MovAbs( p.s_line, p.s_column );
  400.  
  401. } /* end StartOfBlock */
  402.  
  403. void 
  404. EndOfBlock(void) {
  405.     SELECTION p;
  406.  
  407.     MarkQuerySel( &p );
  408.     MovAbs( p.e_line, p.e_column );
  409.  
  410. } /* end EndOfBlock */
  411.  
  412. void
  413. BookmarkSet(USHORT number) {
  414.     HMARK        hMark;
  415.     USHORT    reply;
  416.     char        szTitle[32];
  417.  
  418.     hMark = MarkQueryGlobalFromID(number);
  419.     if ( !hMark )
  420.         hMark = MarkAllocGlobal(number);
  421.     else {
  422.         sprintf(szTitle, "Set bookmark %d", number);
  423.         reply = PopupMsgBox(    "This bookmark is already set. Overwrite?", szTitle,
  424.                                     MB_YESNO | MB_ICONQUESTION |
  425.                                     MB_MOVEABLE | MB_APPLMODAL);
  426.         if ( reply == MBID_YES )
  427.             MarkResetMark(hMark);
  428.     }
  429. } /* end BookmarkSet() */
  430.  
  431.  
  432. void
  433. BookmarkGoto(USHORT number) {
  434.     HMARK    hMark;
  435.     char    szTitle[32];
  436.  
  437.     hMark = MarkQueryGlobalFromID(number);
  438.     if ( hMark )
  439.         MarkGoto(hMark);
  440.     else {
  441.         sprintf(szTitle, "Jump to bookmark %d", number);
  442.         PopupMsg("That bookmark is not set", szTitle);
  443.     }
  444. } /* end BookmarkGoto() */
  445.  
  446.  
  447.  
  448. /*
  449. ** End module: multied.rm
  450. */
  451.