home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / s / snip1292.zip / SCRNPICK.C < prev    next >
C/C++ Source or Header  |  1992-12-26  |  1KB  |  56 lines

  1. /* program:    mousword.c
  2.  * programmer: Ray L. McVay
  3.  * date:       20 Oct 1988
  4.  *
  5.  * Demonstration of picking "words" off a text mode PC screen using a mouse.
  6.  * Submitted to the C_ECHO and placed in the public domain, 7 Jun 1992.
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include "mouse.h"
  12.  
  13. char word[80];
  14. int FAR *scrn = (int FAR *)0xb8000000L;   /* See VIO.H for a better way */
  15.  
  16. main()
  17. {
  18.       int done, b, x, y;
  19.  
  20.       mstatus(); /* reset */
  21.       mshow();
  22.       for (done = 0; !done; )
  23.       {
  24.             mpos(&b, &x, &y);
  25.             if (b == 1)
  26.             {
  27.                   mhide();
  28.                   getword(word, x/8, y/8);
  29.                   do
  30.                   {
  31.                         mpos(&b, &x, &y);
  32.                   } while (b);
  33.                   if (*word)
  34.                         printf("{%s}\n", word);
  35.                   mshow();
  36.             }
  37.             else if (b > 1)
  38.                   done = 1;
  39.       }
  40.       mstatus();
  41.       exit(0);
  42. }
  43.  
  44. getword(char *w, int x, int y)
  45. {
  46.       int txs, txe, ci;
  47.     
  48.       for (txs = x; (txs >= 0) && ((scrn[80 * y + txs] & 255) != 32); txs--)
  49.             scrn[80 * y + txs] = (scrn[80 * y + txs] & 255) | 0x7000;
  50.       for (txe = x; (txe < 80) && ((scrn[80 * y + txe] & 255) != 32); txe++)
  51.             scrn[80 * y + txe] = (scrn[80 * y + txe] & 255) | 0x7000;
  52.       for (ci = txs + 1; ci < txe; ci++)
  53.             *w++ = scrn[80 * y + ci];
  54.       *w = 0;
  55. }
  56.