aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tedit/display/curses/mvword.x
blob: 6a606e0dda25d38fbeb1a177e33f35e909ad0f55 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# MVWORD -- Move one word over in a string
#
# B.Simon	20-Mar-91	Original

procedure mvword_next (str, ic, jc)

char	str[ARB]	# i: String containing words
int	ic		# i: Starting character (0 to strlen(str))
int	jc		# o: Character before start of next word
#--
int	nc
int	strlen()

begin
	# Find next blank

	nc = strlen (str)
	for (jc = min (ic+1, nc); jc < nc; jc = jc + 1) {
	    if (str[jc] <= ' ')
		break
	}

	# Find first non-blank character after blank

	for ( ; jc < nc; jc = jc + 1) {
	    if (str[jc] > ' ') {
		jc = jc - 1	# back up to previous blank
		break
	    }
	}

end

procedure mvword_prev (str, ic, jc)

char	str[ARB]	# i: String containing words
int	ic		# i: Starting character (0 to strlen(str))
int	jc		# o: Character before start of next word
#--

begin
	# Find previous nonblank character

	for (jc = max (ic-1, 0); jc > 0; jc = jc - 1) {
	    if (str[jc] > ' ')
		break
	}

	# Find blank preceding non-blank character

	for ( ; jc > 0; jc = jc - 1) {
	    if (str[jc] <= ' ')
		break
	}

end