forked from kodamail/gscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tbox.gs
89 lines (74 loc) · 1.71 KB
/
tbox.gs
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
*
* Help is in the end of this script
*
function tbox( args )
_version = '0.01b2'
rc = gsfallow( 'on' )
if( args = '' )
help()
return
endif
sw = subwrd( args, 1 )
********** start **********
if( sw = 'start' )
xstart = subwrd( args, 2 )
ystart = subwrd( args, 3 )
* start position
rc = setstr( gstboxxstart, xstart )
rc = setstr( gstboxystart, ystart )
* current position
x = xstart
y = ystart
rc = setstr( gstboxx, x )
rc = setstr( gstboxy, y )
endif
********** draw **********
if( sw = 'draw' )
* str = subwrd( args, 2 )
len = math_strlen( args )
str = substr( args, 6, len-5 )
* say '"' % args % '"'
* say '"' % str % '"'
x = getstr( gstboxx )
y = getstr( gstboxy )
'draw string 'x' 'y' 'str
'q string 'str
width = subwrd( result, 4 )
x = x + width
rc = setstr( gstboxx, x )
endif
********** enter **********
if( sw = 'enter' )
yint = subwrd( args, 2 )
xstart = getstr( gstboxxstart )
y = getstr( gstboxy )
x = xstart
y = y - yint
rc = setstr( gstboxx, x )
rc = setstr( gstboxy, y )
endif
return
*
* help
*
function help()
say ' Name:'
say ' tbox '_version' - draw string using text-box'
say ' '
say ' Usage 1 (create text-box):'
say ' tbox start xpos ypos '
say ' '
say ' Usage 2: (draw string)'
say ' tbox draw string'
say ' '
say ' Usage 3: (return)'
say ' tbox enter yint'
say ''
say ' xpos, ypos : starting position'
say ' string : string to draw'
say ' yint : vertical interval'
say ''
say ' Copyright (C) 2010 Chihiro Kodama'
say ' Distributed under GNU GPL (http://www.gnu.org/licenses/gpl.html)'
say ''
return