aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/tedit/display/screen/khelp.x
blob: 4b075f8aacb0f94cc558c2744fa9a4d93d3119ed (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
57
58
59
60
61
include	<fset.h>

# K_HELP -- Retrieve help text for function key sequences

procedure k_help (text)

pointer	text		# o: Help text
#--
include	"screen.com"

begin
	text = htext
end

procedure k_eseq (name, eseq, maxch)

char	name[ARB]	# i: Name bound to escape sequence
char	eseq[ARB]	# o: String representation of escape sequence
int	maxch		# i: Maximum length of escape sequence
#--
include "screen.com"

bool	match, in_name
int	ic
pointer	ch

begin
	ic = 1
	match = true
	in_name = true

	for (ch = htext; Memc[ch] != EOS; ch = ch + 1) {
	    if (in_name) {
		if (Memc[ch] == '=') {
		    match = match && name[ic] == EOS
		    in_name = false
		    ic = 1
		} else if (match) {
		    if (Memc[ch] == name[ic]) {	
			ic = ic + 1
		    } else {
			match = false
		    }
		}

	    } else {
		if (Memc[ch] == '\n') {
		    if (match) 
			break
		    ic = 1
		    match = true
		    in_name = true
		} else if (match && ic <= maxch) {
		    eseq[ic] = Memc[ch]
		    ic = ic + 1
		}
	    }
	}
	eseq[ic] = EOS

end