home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / DEMO / RIM22 / MACROS / LANG.RM < prev    next >
Text File  |  1994-02-01  |  3KB  |  89 lines

  1. /*
  2. ** Macro module: lang.c - Basic language specific editing functions
  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. #include "macro.h"
  24.  
  25.  
  26. void
  27. _init(void) {
  28.  
  29.     LibAutoload("c_indent", "_c_init","_h_init","_cpp_init","_hpp_init",
  30.                                     "_cxx_init","_hxx_init", "_inl_init",
  31.                                     "_rm_init","_asm_init");
  32. } /* end _init() */
  33.  
  34.  
  35. /* DefaultExtensionInit        V2.0.55 - New
  36. ** When no special extension macro has been defined
  37. ** LangInit() will call this function, which by default
  38. ** does nothing.
  39. */
  40. void
  41. DefaultExtensionInit() {
  42.   #if 0
  43.     _c_init();
  44.   #endif
  45. } /* end DefaultExtensionInit() */
  46.  
  47.  
  48. /* LangInit
  49. ** This is an event handler that is called whenever
  50. ** a buffer is created. It sets up for language (extension)
  51. ** specific custom editing routines like smart indenting &
  52. ** template editing.
  53. */
  54. SHORT
  55. LangInit(short event, HBUFFER hb) {
  56.     char  *pathname;
  57.     char  *func;
  58.     HBUFFER  origBuffer;
  59.     char  ext[_MAX_EXT];
  60.  
  61.     /* Determine file extension of current buffer */
  62.     pathname = BufQueryFilename(hb);
  63.     if ( !pathname && (BufQueryFlags(hb) & BUFFER_TYPE) == BUFTYPE_NORMAL ) {
  64.         /* an untitled buffer */
  65.         DefaultExtensionInit();
  66.         return 0;
  67.     }
  68.     /* Build function name from file extension */
  69.     splitpath(pathname, NULL, NULL, NULL, ext);
  70.     func = malloc(32);
  71.     ext[0] = '_';
  72.     strcpy(func, ext);
  73.     strlwr(func);
  74.     strcat(func, "_init");
  75.     origBuffer = BufSwitchBuffer(hb);
  76.     if ( LibQueryFunction(func) )
  77.         ExecFunction(func);
  78.     else
  79.         DefaultExtensionInit();
  80.     BufSwitchBuffer(origBuffer);
  81.     free(func);
  82.     return 0;
  83. } /* end LangInit() */
  84.  
  85.  
  86. /*
  87. ** End module: lang.c
  88. */
  89.