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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
/* */
/* P†l Hedne 1990 */
/* */
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
_init (...)
{
int match_key,goto;
global match_key,goto;
match_key=0;
/* if (!inq_macro("latex")) load_macro ("latex");*/
load_macro ("latex");
/* if (!inq_macro("latexh")) load_macro ("latexh");*/
load_macro ("latexh");
assign_to_key ("<Ctrl-F4>", "find_match");
assign_to_key ("<Shift-F4>", "disp_match");
}
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
extern gen_help,
_reg_exp, // Regular expressions on/off.
_block_search; // Block search on/off.
find_match (...)
{
int line,col,line1,col1,match,ind,length,maxlength,
buf_key,nwrite,dum,key_save,key_next;
string text,label,pattern,fname,ext,bname,sdum;
/* pause_on_error (1); */
maxlength=30;
pattern="";
sprintf (text, "Global search %sfor: ", _reg_exp ? "" : "(RE off) ");
if (get_parm (0, pattern, text, NULL,pattern))
{
key_save=inq_buffer();
inq_names(fname,ext,bname);
bname=upper(bname);
do
{
sprintf (text,"%s: Search for %s ",bname,pattern);
message(text);
inq_position (line, col);
top_of_buffer();
sprintf (text,"Buffer %s",bname);
match_key=create_buffer(text,NULL,1);
nwrite=0;
match=1;
while (match > 0)
{
match=search_fwd(pattern,_reg_exp,NULL,_block_search);
if (match > 0)
{
buf_key=inq_buffer();
inq_position(line1,col1);
move_abs(line1,1);
text = read();
text=trim(text);
length=strlen(text);
label=text;
while ((ind=search_string(";",text,dum,0,0)) > 0)
text=substr(label,1,ind-1)+":"+substr(label,ind+1,length);
if (length>maxlength) maxlength=length;
while (strlen(text)<maxlength) text=text+" ";
set_buffer(match_key);
insert("Line %d: %s ;go_to_line %c%d%c%d%c\n",line1,text,34,line1,34,col1,34);
set_buffer(buf_key);
++nwrite;
move_abs(line1+1,1);
}
}
if (nwrite>0)
{
message(" ");
label=" ";
text=gen_help(label,match_key);
if (goto == 1)
{
attach_buffer(buf_key);
break;
}
}
/* else
{
text="No matches in file. Press return.";
get_parm (0, sdum, text);
}*/
text="Continue with next buffer ? (Y/N)";
get_parm (0, sdum, text, 1);
sdum=upper(sdum);
if (substr(sdum,1,1) != "Y")
{
key_next=key_save;
set_buffer(key_next);
move_abs (line, col);
}
else
{
key_next=next_buffer();
set_buffer(key_next);
inq_names(fname,ext,bname);
delete_buffer(match_key);
if (key_next == key_save) message("No more buffers.");
}
/* pause_on_error (0); */
}
while (key_next != key_save);
}
}
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
go_to_line(...)
{
int line,col;
if (get_parm(0,line) && get_parm(1,col))
{
goto=1;
move_abs(line,col);
}
else
goto=0;
}
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
disp_match (...)
{
string fname;
fname=" ";
if (match_key>0) fname=gen_help(fname,match_key);
}
|