home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / DEMO / RIM22 / MACROS / BRIEF.RM < prev    next >
Text File  |  1994-01-06  |  13KB  |  346 lines

  1. /*
  2. ** Macro module: brief.c - Brief(R) keyboard map
  3. **
  4. ** Brief is a registered trademark of Borland International
  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 Brief keyboard mapping.
  29.     ** To have the editor use this - copy or rename brief.obm
  30.     ** to keyboard.obm  This mapping is the default key map for
  31.     ** the RimStar Programmer's editor.
  32.     */
  33.  
  34. void
  35. _init(void) {
  36.     LibAutoload("kbd",        "KbdBindAsciiKeys");
  37.     LibAutoload("misc",         "quote", "next_word", "prev_word",
  38.                                     "delete_next_word", "delete_prev_word",
  39.                                     "open_line", "toupper", "tolower" );
  40.     LibAutoload("c_smart",    "find_matching_delim");
  41. } /* end _init() */
  42.  
  43.  
  44. void
  45. KbdBindDefault() {
  46.     char  *self_insert = "SelfInsert";
  47.     char  *p;
  48.  
  49.     KbdBindAsciiKeys();    /* Binds all the typable keys & system menu bindings */
  50.  
  51.     KbdBind("Alt+A",                "MarkExclusive");
  52.     KbdBind("Alt+B",                "DlgBufferList");
  53.     KbdBind("Alt+C",                "MarkColumn");
  54.     KbdBind("Alt+D",                "BufDeleteLine");
  55.     KbdBind("Alt+E",                "DlgOpenFile");
  56.     KbdBind("Alt+G",                "DlgGotoLine");
  57.     KbdBind("Alt+H",                "HelpQueryInfHelp");
  58.     /*
  59.     ** NOTE: To use QueryInfHelp you must add the following environment variable
  60.     **         to your config.sys:
  61.     **     SET RSE_INF=GUIREF20.INF+PMFUN.INF+PMGPI.INF+PMHOK.INF+PMMSG.INF+PMREL.INF+PMWIN.INF+PMWKP.INF
  62.     ** The setting is taken from the combination of the  PROGREF20 and PMREF environment variables
  63.     ** You may add additional .INF files or remove some.
  64.     */
  65.   #if 0
  66.     KbdBind("Alt+H",                "HelpQueryQuickHelp");    /* invokes Microsoft Quick Help program */
  67.   #endif
  68.     KbdBind("Alt+I",                "ToggleInsert");
  69.  
  70.     KbdBind("Alt+J+1",            "BookmarkGoto 1");
  71.     KbdBind("Alt+J+2",            "BookmarkGoto 2");
  72.     KbdBind("Alt+J+3",            "BookmarkGoto 3");
  73.     KbdBind("Alt+J+4",            "BookmarkGoto 4");
  74.     KbdBind("Alt+J+5",            "BookmarkGoto 5");
  75.     KbdBind("Alt+J+6",            "BookmarkGoto 6");
  76.     KbdBind("Alt+J+7",            "BookmarkGoto 7");
  77.     KbdBind("Alt+J+8",            "BookmarkGoto 8");
  78.     KbdBind("Alt+J+9",            "BookmarkGoto 9");
  79.     KbdBind("Alt+J+0",            "BookmarkGoto 10");
  80.  
  81.     KbdBind("Alt+K",                 "BufDeleteToEOL");
  82.     KbdBind("Alt+L",                 "MarkLine");
  83.     KbdBind("Alt+M",                 "MarkNormal");
  84.     KbdBind("Alt+N",                 "BufNextBuffer");
  85.     KbdBind("Alt+O",                 "DlgRenameBuffer");
  86.     KbdBind("Alt+P",                 "Print");
  87.  
  88.     KbdBind("Alt+Q",                 "quote");        /* in misc.rm */
  89.  
  90.     KbdBind("Alt+R",                 "BufInsertFile");
  91.  
  92.  
  93.     KbdBind("Alt+T",                 "ToggleTabs");
  94.     KbdBind("Alt+U",                 "Undo");
  95.     KbdBind("Alt+V",                 "DlgVersion");
  96.     KbdBind("Alt+W",                 "SaveBuffer");
  97.     KbdBind("Alt+X",                 "ExitEditor");
  98.     KbdBind("Alt+Y",                 "Redo");
  99.   #if 0
  100.     KbdBind("Alt+Z",                 "");  /* Start windowed command interpreter. Use Alt+ESC to start one. */
  101.   #endif
  102.     KbdBind("Alt+-",                 "BufPrevBuffer");
  103.     KbdBind("Alt+|",                 "BufDeleteWhitespace");
  104.     KbdBind("Alt+]",                 "find_matching_delim");    /* in c_smart.rm */
  105.  
  106.     KbdBind("Alt+1",                 "BookmarkSet 1");
  107.     KbdBind("Alt+2",                 "BookmarkSet 2");
  108.     KbdBind("Alt+3",                 "BookmarkSet 3");
  109.     KbdBind("Alt+4",                 "BookmarkSet 4");
  110.     KbdBind("Alt+5",                 "BookmarkSet 5");
  111.     KbdBind("Alt+6",                 "BookmarkSet 6");
  112.     KbdBind("Alt+7",                 "BookmarkSet 7");
  113.     KbdBind("Alt+8",                 "BookmarkSet 8");
  114.     KbdBind("Alt+9",                 "BookmarkSet 9");
  115.     KbdBind("Alt+0",                 "BookmarkSet 10");
  116.  
  117.     /*
  118.     **  All supported special key names follow, even those not assigned
  119.     **  just so you know what every key is named.
  120.     **
  121.     **  KP stands for the Key Pad keys.
  122.     **
  123.     **  Alt+ESCAPE, Alt+TAB and Ctrl+ESCAPE are reserved for OS/2 PM's use
  124.     **  do not define these as they will be ignored.
  125.     */
  126.     KbdBind("BACKSPACE",                  "BufBackspace");
  127.     KbdBind("Shift+BACKSPACE",        "BufBackspace");
  128.     KbdBind("Alt+BACKSPACE",          "delete_next_word");    /* in misc.rm */
  129.     KbdBind("Ctrl+BACKSPACE",          "delete_prev_word");    /* in misc.rm */
  130.     KbdBind("Shift+TAB",                  "MovPrevTabPos");
  131.     KbdBind("Ctrl+Enter",            p="open_line");
  132.     KbdBind("Ctrl+Kp_Enter",        p);
  133.     KbdBind("KP_STAR",                  "UndoModification");
  134.     KbdBind("Shift+KP_STAR",          "RedoModification");
  135.     KbdBind("Shift+Ctrl+KP_STAR",    "UndoAll");
  136.     KbdBind("Shift+Alt +KP_STAR",    "RedoAll");
  137.  
  138.     KbdBind("F1",                          "WinNextWindow");
  139.     KbdBind("Shift+F1",                "WinPrevWindow");
  140.     KbdBind("F2",                        "WinTileWindows");
  141.     KbdBind("Shift+F2",                "WinCascade");
  142.     KbdBind("F3",                        "WinNewWindow");
  143.     KbdBind("F4",                        "WinDeleteCurrentWindow");
  144.     KbdBind("F5",                        "SearchForward");
  145.     KbdBind("Alt+F5",                    "SearchBackward");
  146.     KbdBind("Shift + F5",            "SearchAgain");
  147.     KbdBind("F6",                        "ReplaceForward");
  148.     KbdBind("Alt+F6",                    "ReplaceBackward");
  149.     KbdBind("Shift+F6",                "ReplaceAgain");
  150.     KbdBind("F7",                        "KbdMacroRecord");      /* starts/stops keystroke macro recording */
  151.     KbdBind("Alt+F7",                    "KbdMacroLoad");      /* load keystroke macro from disk */
  152.     KbdBind("Shift+F7",                "KbdMacroPause");        /* pause keystroke macro playback */
  153.     KbdBind("F8",                        "KbdMacroPlay");        /* plays a recorded keystroke macro */
  154.     KbdBind("Alt+F8",                    "KbdMacroSave");          /* saves last recorded macro to disk */
  155.     KbdBind("F9",                        "LibLoadMacro");  
  156.     KbdBind("F10",                        "LibExecFunction");
  157.     KbdBind("Alt+F10",                "ExecAssoc");
  158.     /*
  159.     ** For use in error output buffer - place cursor on error line
  160.     ** ALT+F9 jumps to file & line in error, loading the file if needed
  161.     */
  162.     KbdBind("Alt+F9",                "ErrJumpToError");
  163.     /*
  164.     ** NOTE:  Consecutive requests of the Home builtin command and the End builtin
  165.     **          command support BRIEF's convention. A key assigned to the Home or End
  166.     **          builtin command will perform three different actions when invoked
  167.     **          consecutively:
  168.     **
  169.     **          For the Home builtin command:
  170.     **
  171.     **          1st time command invoked      - move to the beginning of the current line
  172.     **          2nd (consecutive) invocation - move to the beginning of the top line in window
  173.     **          3rd (consecutive) invocation - move to the beginning of the buffer (file)
  174.     **
  175.     **          For the End builtin command:
  176.     **
  177.     **          1st time command invoked - move to end of current line
  178.     **          2nd (consecutive) invocation - move to end of last line in window
  179.     **          3rd (consecutive) invocation - move to end of the buffer (file)
  180.     **
  181.     **
  182.     **          So if the Home builtin command is assigned to the HOME key:
  183.     **
  184.     **          HOME              moves to the beginning of the current line
  185.     **          HOME+HOME        moves to the beginning of the top line in window
  186.     **          HOME+HOME+HOME moves to the beginning of the file
  187.     **
  188.     **          and if the End builtin command is assigned to the END key:
  189.     **
  190.     **          END                moves to the end of the current line
  191.     **          END+END          moves to the end of the last line in window
  192.     **          END+END+END     moves to the end of the file
  193.     **
  194.     **          Any other commands invoked in between will reset the counters.
  195.     **
  196.     **  If you don't want this behavior you can use MovSOL and MovEOL
  197.     **  these commands do only the single action.
  198.     */
  199.     KbdBind("HOME",                "MovStartBrief");
  200.     KbdBind("KP_HOME",            "MovStartBrief");
  201.     KbdBind("Ctrl+HOME",            "MovTopWin");
  202.     KbdBind("Ctrl+KP_HOME",        "MovTopWin");
  203.     KbdBind("END",                    "MovEndBrief");
  204.     KbdBind("KP_END",                "MovEndBrief");
  205.     KbdBind("Ctrl+KP_END",        "MovBottomWin");
  206.     KbdBind("Ctrl+END",            "MovBottomWin");
  207.     KbdBind("PGUP",                "MovPageUp");
  208.     KbdBind("KP_PGUP",            "MovPageUp");
  209.     KbdBind("Ctrl+PGUP",            "MovSOF");
  210.     KbdBind("Ctrl+KP_PGUP",        "MovSOF");
  211.     KbdBind("PGDN",                "MovPageDown");
  212.     KbdBind("KP_PGDN",            "MovPageDown");
  213.     KbdBind("Ctrl+PGDN",            "MovEOF");
  214.     KbdBind("Ctrl+KP_PGDN",        "MovEOF");
  215.     KbdBind("UP",                    "MovUp");
  216.     KbdBind("KP_UP",                "MovUp");
  217.     KbdBind("DOWN",                "MovDown");
  218.     KbdBind("KP_DOWN",            "MovDown");
  219.     KbdBind("KP_LEFT",            "MovLeft");
  220.     KbdBind("LEFT",                "MovLeft");
  221.     KbdBind("Shift+LEFT",        "MovPrevChar");
  222.     KbdBind("Ctrl+LEFT",            "prev_word");    /* in misc.rm */
  223.     KbdBind("Ctrl+KP_LEFT",        "prev_word");
  224.     KbdBind("RIGHT",                "MovRight");
  225.     KbdBind("Shift+RIGHT",        "MovNextChar");
  226.     KbdBind("KP_RIGHT",            "MovRight");
  227.     KbdBind("Ctrl+RIGHT",        "next_word");    /* in misc.rm */
  228.     KbdBind("Ctrl+KP_RIGHT",    "next_word");
  229.   #if 0
  230.     KbdBind("KP_5", "");
  231.   #endif
  232.     KbdBind("KP_MINUS",            "CutToScrap");
  233.     KbdBind("KP_PLUS",            "CopyToScrap");
  234.     KbdBind("Shift+KP_MINUS",    "CutAppendToScrap");        /* append to current scrap */
  235.     KbdBind("Shift+KP_PLUS",    "CopyAppendToScrap");    /* append to current scrap */
  236.     KbdBind("INSERT",                "BufPasteScrap");
  237.     KbdBind("KP_INSERT",            "BufPasteScrap");
  238.     KbdBind("Shift+INSERT",        "ImportClipboard");
  239.     KbdBind("Ctrl+INSERT",        "ExportClipboard");
  240.     KbdBind("DELETE",                "BufDeleteCharOrSelection");
  241.     KbdBind("KP_DELETE",            "BufDeleteCharOrSelection");
  242.  
  243.     KbdBind("Ctrl+-",                  "BufDeleteCurrentBuffer");
  244.     KbdBind("Shift+Ctrl+-",          "WinDeleteWindowAndBuffer");
  245.     KbdBind("Ctrl+A",                  "MarkSwapSel");
  246.     KbdBind("Ctrl+B",                  "WinScrollBottom");
  247.     KbdBind("Ctrl+C",                  "WinScrollCenter");
  248.     KbdBind("Ctrl+D",                  "WinScrollDown");
  249.     KbdBind("Ctrl+K",                  "ExecKillProcess");        /* Kills a program executed on buffer */
  250.     KbdBind("Ctrl+N",                  "ErrNextError");
  251.     KbdBind("Ctrl+P",                  "ErrPrevError");
  252.     KbdBind("Ctrl+T",                  "WinScrollTop");
  253.     KbdBind("Ctrl+U",                  "WinScrollUp");
  254.     KbdBind("Ctrl+W",                  "ToggleBackups");
  255.     KbdBind("Ctrl+X",                  "SysSaveAndExit");
  256.  
  257.     /* Source browser bindings */
  258.     KbdBind("Ctrl+Alt+F12",        p="SbJumpBack");
  259.     KbdBind("Alt+J+B",            p);
  260.  
  261.     KbdBind("Alt+S+Alt+S",        p="SbBrowseSymbolAtCursor");
  262.     KbdBind("Alt+S+S",              p);
  263.     KbdBind("F11",                    p);
  264.     
  265.     KbdBind("Alt+S+Alt+D",         p="SbBrowseDefs");
  266.     KbdBind("Alt+S+D",              p);
  267.     KbdBind("Shift+F11",            p);
  268.  
  269.     KbdBind("Alt+S+Alt+M",         p="SbBrowseSymbolsDefinedInModule");
  270.     KbdBind("Alt+S+M",              p);
  271.     KbdBind("Alt+F11",            p);
  272.     KbdBind("Ctrl+G",                p); /* Brief's `routines' assignment */
  273.  
  274.     KbdBind("Alt+S+Alt+R",         p="SbBrowseRefs");
  275.     KbdBind("Alt+S+R",              p);
  276.     KbdBind("Ctrl+F11",            p);
  277.  
  278.     KbdBind("Alt+S+Alt+F",         p="SbFindNext");
  279.     KbdBind("Alt+S+F",              p);
  280.     KbdBind("F12",                    p);
  281.  
  282.     KbdBind("Alt+S+Alt+B",         p="SbFindPrev");
  283.     KbdBind("Alt+S+B",              p);
  284.     KbdBind("Shift+F12",            p);
  285.  
  286.     KbdBind("Alt+F12",            "SbGotoDef");
  287.  
  288.     /*
  289.      ╔════════════════════════════════════╗
  290.      ║    Double line box drawing characters ║
  291.      ╚════════════════════════════════════╝
  292.      */
  293.     KbdBind("Shift+KP_Home",    "BufInsertChar 201"); /* Upper-left corner ╠ */
  294.     KbdBind("Shift+KP_Up",        "BufInsertChar 203"); /* Top tee ╦ */
  295.     KbdBind("Shift+KP_PgUp",    "BufInsertChar 187"); /* Upper-right corner ╗ */
  296.     KbdBind("Shift+KP_Left",    "BufInsertChar 204"); /* Left tee ╠ */
  297.     KbdBind("Shift+KP_5",        "BufInsertChar 205"); /* Horiz double line ═ */
  298.     KbdBind("Shift+KP_Right",    "BufInsertChar 185"); /* Right tee ╣ */
  299.     KbdBind("Shift+KP_End",        "BufInsertChar 200"); /* Lower-left corner ╚ */
  300.     KbdBind("Shift+KP_Down",    "BufInsertChar 202"); /* Bottom tee ╩ */
  301.     KbdBind("Shift+KP_PgDn",    "BufInsertChar 188"); /* Lower-right corner ╝ */
  302.     KbdBind("Shift+KP_Slash",    "BufInsertChar 186"); /* Vertical double line ║ */
  303.  
  304. } /* end KbdBindDefault() - Brief key map */
  305.  
  306.  
  307. void
  308. BookmarkSet(USHORT number) {
  309.     HMARK        hMark;
  310.     USHORT    reply;
  311.     char        szTitle[32];
  312.  
  313.     hMark = MarkQueryGlobalFromID(number);
  314.     if ( !hMark )
  315.         hMark = MarkAllocGlobal(number);
  316.     else {
  317.         sprintf(szTitle, "Set bookmark %d", number);
  318.         reply = PopupMsgBox(    "This bookmark is already set. Overwrite?", szTitle,
  319.                                     MB_YESNO | MB_ICONQUESTION |
  320.                                     MB_MOVEABLE | MB_APPLMODAL);
  321.         if ( reply == MBID_YES )
  322.             MarkResetMark(hMark);
  323.     }
  324. } /* end BookmarkSet() */
  325.  
  326.  
  327. void
  328. BookmarkGoto(USHORT number) {
  329.     HMARK    hMark;
  330.     char    szTitle[32];
  331.  
  332.     hMark = MarkQueryGlobalFromID(number);
  333.     if ( hMark )
  334.         MarkGoto(hMark);
  335.     else {
  336.         sprintf(szTitle, "Jump to bookmark %d", number);
  337.         PopupMsg("That bookmark is not set", szTitle);
  338.     }
  339. } /* end BookmarkGoto() */
  340.  
  341.  
  342.  
  343. /*
  344. ** End module: brief.c
  345. */
  346.