home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / DEMO / RIM22 / MACROS / STARTUP.RM < prev   
Text File  |  1993-11-12  |  4KB  |  118 lines

  1. /*
  2. ** Macro module: startup.rm - startup macros for RimStar Programmer's Editor
  3. **
  4. ** Copyright (C) 1993 Brian L. Smith
  5. ** Copyright (C) 1993 RimStar Technology, Inc.
  6. ** All rights reserved internationally.
  7. ** Unlicensed use is a violation of applicable laws.
  8. **
  9. ** This source code is provided to licensed users of RimStar's products
  10. ** for the purpose of allowing the user to customize and/or enhance RimStar's
  11. ** products. The source code remains the property of the copyright holders
  12. ** with all rights reserved internationally.
  13. ** Any modifications to the source code are considered derivative works and
  14. ** all rights thereto are reserved to the copyright holders except
  15. ** that the purchaser may use the derivitive work in the same manner
  16. ** as permitted by the license governing the unmodified product.
  17. ** Distribution in any manner of any part of the original source code,
  18. ** whether in source or object form, is expressly prohibited without the
  19. ** express written permission of the copyright holders.
  20. **
  21. */
  22.  
  23. #define INCL_EVENT
  24. #include "macro.h"
  25.  
  26.  
  27.  
  28. HKEYBOARD    hkDefault;
  29.  
  30. int cxChar;    /* width of font in pixels */
  31. int cyChar;    /* height of font (descender + ascender) */
  32. int cyDesc; /* descender height */
  33.  
  34.  
  35. void
  36. _init(void) {
  37.     LibAutoload("keyboard",    "KbdBindDefault");
  38.     LibAutoload("menu",        "MnuSetMenuAccel", "MnuCommandHandler",
  39.                                     "MnuInitHandler", "ToolbarCommandHandler");
  40.     LibAutoload("mouse",        "MouEvent");
  41.     LibAutoload("buffer",    "ReadOnlyBuffer");
  42.     LibAutoload("lang",        "LangInit");
  43. } /* end _init() */
  44.  
  45.  
  46. /*
  47. ** Handler for EVENT_FONT_CHANGED
  48. ** Keeps the global variables correctly
  49. ** set for the size of the current font
  50. */
  51. int
  52. FontEvent(USHORT event, PFONTATTRIB pfAttr) {
  53.     cxChar = pfAttr->cxChar;
  54.     cyChar = pfAttr->cyChar;
  55.     cyDesc = pfAttr->cyDesc;
  56.     return 0;
  57. } /* end FontEvent() */
  58.  
  59.  
  60. void
  61. _startup(void) {
  62.     char            *pathname;
  63.     PFONTATTRIB pfAttr;
  64.  
  65.     /* Get current font attributes */
  66.     pfAttr = SysQueryFontSize();
  67.     cxChar = pfAttr->cxChar;
  68.     cyChar = pfAttr->cyChar;
  69.     cyDesc = pfAttr->cyDesc;
  70.  
  71.     /* Register font chage event handler */
  72.     EventRegisterEvent(EVENT_FONT_CHANGED, EVENT_NORMAL, "FontEvent");
  73.  
  74.     /* Register mouse handling function */
  75.     EventRegisterEvent(EVENT_MOUSE, EVENT_NORMAL, "MouEvent");
  76.  
  77.     /* Register read-only buffer handling function */
  78.     EventRegisterEvent(EVENT_EDIT_READ_ONLY, EVENT_NORMAL, "ReadOnlyBuffer");
  79.  
  80.     /* Register language handling function */
  81.     EventRegisterEvent(EVENT_BUFFER_CREATED, EVENT_NORMAL, "LangInit");
  82.  
  83.     /*
  84.     ** Setup keyboard mapping.
  85.     ** Your default keyboard mapping function should
  86.     ** be named `KbdBindDefault'. Each supplied keyboard
  87.     ** map uses the same name so that all you need to do
  88.     ** is copy or rename the desired compiled keyboard file
  89.     ** to "KEYBOARD.OBM" and startup will find and load it.
  90.     */
  91.     KbdBindDefault();
  92.  
  93.     /* Place on keyboard stack - so other push/pops work correctly */
  94.     hkDefault = KbdQueryCurrentKeyboard();
  95.     if ( hkDefault )
  96.         KbdPush(hkDefault);
  97.  
  98.     /* Set all short-cut key helps for the main menu */
  99.     MnuSetMenuAccel();    /* see menu.rm */
  100.  
  101.     /* load default source browser database */
  102.     /* See if environment variable set */
  103.     pathname = getenv("RSE_SBD");
  104.  
  105.     if ( !pathname )
  106.         pathname = "sbd.sbd";    /* try current directory */
  107.     SbLoadDatabase(pathname, 1);
  108.  
  109.     if ( LibQueryFunction("Startup") )
  110.         Startup();    /* Place for your customizations */
  111. } /* end _startup() */
  112.  
  113.  
  114.  
  115. /*
  116. ** End macro: startup.rm
  117. */
  118.