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