aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/stdgraph/stgscur.x
blob: e40d4a3dea1d64fae61b91fc3f03c38904e48401 (plain) (blame)
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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	"stdgraph.h"

# STG_SETCURSOR -- Set the position of a cursor.

procedure stg_setcursor (x, y, cursor)

int	x, y			# new position of cursor
int	cursor			# cursor to be set
int	mx, my, cur
include	"stdgraph.com"

begin
	# If cursor=0, write the cursor last referenced.
	if (cursor > 0) {
	    SG_CURSOR(g_sg) = cursor
	    cur = cursor
	} else
	    cur = max (1, SG_CURSOR(g_sg))

	# If the user has locked the logical cursor override runtime selection.
	if (g_cursor > 0)
	    cur = g_cursor

	# Restore the software cursor position before reading?
	if (SG_UPDCURSOR(g_sg) == YES) {
	    SG_CURSOR_X(g_sg) = x
	    SG_CURSOR_Y(g_sg) = y
	}

	mx = max(g_x1, min(g_x2, nint (x * g_dx) + g_x1))
	my = max(g_y1, min(g_y2, nint (y * g_dy) + g_y1))

	call stg_ctrl3 ("WC", mx, my, cur)
end