home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / WHEREXY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  3.0 KB  |  94 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - wherexy.c
  3.  *
  4.  * function(s)
  5.  *        wherex - gives horizontal cursor position within window
  6.  *        wherey - gives vertical cursor position within window
  7.  *-----------------------------------------------------------------------*/
  8.  
  9. /*[]------------------------------------------------------------[]*/
  10. /*|                                                              |*/
  11. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  12. /*|                                                              |*/
  13. /*|                                                              |*/
  14. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  15. /*|     All Rights Reserved.                                     |*/
  16. /*|                                                              |*/
  17. /*[]------------------------------------------------------------[]*/
  18.  
  19. #include <_video.h>
  20. #include <conio.h>
  21.  
  22. /*---------------------------------------------------------------------*
  23.  
  24. Name            _wherexy - returns the horizontal and vertical cursor
  25.                            position
  26.  
  27. Usage           unsigned _wherexy(void);
  28.  
  29. Prototype in    _video.h
  30.  
  31. Return value    an unsigned integer holding the horizontal coordinate
  32.                 in the lower byte and the vertical coordinate in the
  33.                 upper byte
  34.  
  35. *---------------------------------------------------------------------*/
  36. unsigned near _wherexy(void)
  37. {
  38.         _AH = 3;
  39.         _BH = 0;
  40.         _VideoInt();
  41.         return (_DX);
  42. }
  43.  
  44.  
  45. /*---------------------------------------------------------------------*
  46.  
  47. Name            wherex - returns the horizontal position within window
  48.  
  49. Usage           int wherex(void);
  50.  
  51. Related
  52. functions usage int wherey(void);
  53.  
  54. Prototype in    conio.h
  55.  
  56. Description     wherex returns the x-coordinate of the current cursor
  57.                 position (within the current text window). wherey
  58.                 returns the y-coordinate of the current cursor position
  59.                 (within the current text window).
  60.  
  61. Return value    integer in the range 1 to 80
  62.  
  63. *---------------------------------------------------------------------*/
  64. int wherex(void)
  65. {
  66.         return (_wherex() - _video.windowx1 + 1);
  67. }
  68.  
  69.  
  70. /*---------------------------------------------------------------------*
  71.  
  72. Name            wherey - returns the vertical position within window
  73.  
  74. Usage           int wherey(void);
  75.  
  76. Related
  77. functions usage int wherex(void);
  78.  
  79. Prototype in    conio.h
  80.  
  81. Description     wherex returns the x-coordinate of the current cursor
  82.                 position (within the current text window). wherey
  83.                 returns the y-coordinate of the current cursor position
  84.                 (within the current text window).
  85.  
  86. Return value    integer in the range 1 to 80
  87.  
  88. *---------------------------------------------------------------------*/
  89.  
  90. int wherey(void)
  91. {
  92.         return (_wherey() - _video.windowy1 + 1);
  93. }
  94.