home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_144 / 5.ddi / CLIBSRC2.ZIP / WHEREXY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.5 KB  |  93 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.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #include <_video.h>
  19. #include <conio.h>
  20.  
  21. /*---------------------------------------------------------------------*
  22.  
  23. Name            _wherexy - returns the horizontal and vertical cursor
  24.                            position
  25.  
  26. Usage           unsigned _wherexy(void);
  27.  
  28. Prototype in    _video.h
  29.  
  30. Return value    an unsigned integer holding the horizontal coordinate
  31.                 in the lower byte and the vertical coordinate in the
  32.                 upper byte
  33.  
  34. *---------------------------------------------------------------------*/
  35. unsigned near _wherexy(void)
  36. {
  37.         _AH = 3;
  38.         _BH = 0;
  39.         _VideoInt();
  40.         return (_DX);
  41. }
  42.  
  43.  
  44. /*---------------------------------------------------------------------*
  45.  
  46. Name            wherex - returns the horizontal position within window
  47.  
  48. Usage           int wherex(void);
  49.  
  50. Related
  51. functions usage int wherey(void);
  52.  
  53. Prototype in    conio.h
  54.  
  55. Description     wherex returns the x-coordinate of the current cursor
  56.                 position (within the current text window). wherey
  57.                 returns the y-coordinate of the current cursor position
  58.                 (within the current text window).
  59.  
  60. Return value    integer in the range 1 to 80
  61.  
  62. *---------------------------------------------------------------------*/
  63. int wherex(void)
  64. {
  65.         return (_wherex() - _video.windowx1 + 1);
  66. }
  67.  
  68.  
  69. /*---------------------------------------------------------------------*
  70.  
  71. Name            wherey - returns the vertical position within window
  72.  
  73. Usage           int wherey(void);
  74.  
  75. Related
  76. functions usage int wherex(void);
  77.  
  78. Prototype in    conio.h
  79.  
  80. Description     wherex returns the x-coordinate of the current cursor
  81.                 position (within the current text window). wherey
  82.                 returns the y-coordinate of the current cursor position
  83.                 (within the current text window).
  84.  
  85. Return value    integer in the range 1 to 80
  86.  
  87. *---------------------------------------------------------------------*/
  88.  
  89. int wherey(void)
  90. {
  91.         return (_wherey() - _video.windowy1 + 1);
  92. }
  93.