-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfltdjsearch.cpp
More file actions
168 lines (147 loc) · 4.71 KB
/
fltdjsearch.cpp
File metadata and controls
168 lines (147 loc) · 4.71 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/***************************************************************************
fltdjsearch.cpp
---------------
begin : Thu Dec 12 2002, 2003
copyright : (C) Kartik Patel
email : letapk@gmail.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
//Last modified 28 Mar 2004
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#include <FL/Fl.H>
#include "fltdj.h"
extern void shownote (void);
extern void getdayname (int i);
//text typed in find box of note or contact window
char findtext[50];
//index of note, appointment and contact where text was last found
int notehit = 0;
int appthit = 0;
int conhit = 0;
extern int daybutton[];
extern int attach[];
extern char *noting[];
extern int date, offset, searchappointments;
extern char commontext[];
extern char grepfilename[];
extern char notefilename[];
extern FILE *grepfile;
//these are declared and defined in fltdjappt.cpp
extern char appointment[32][25][4][20];
extern int appt[];
extern int maxapptindex;
extern int apptindex;
//these are declared and defined in fltdjcontact.cpp
extern int contactindex, maxcontacts;
extern char *contact[];
extern int currentdaybuttonindex;
//numerical representation of month
extern int month;
//numerical representation of year
extern int year;
//numerical date of the month associated with the selected daybutton
extern int date;
void find_text (void)
{
int i, j;
char *texthit1 = NULL, *texthit2 = NULL, *texthit3 = NULL, *texthit4 = NULL;
Fl_Widget *tab;
tab = basetab->value();
save_data ();
strcpy (findtext, "\0");
strcpy (findtext, findtextbox->value());
if (!strlen (findtext))//nothing to search
return;
if (tab == searchtab){
unlink (grepfilename);
find_text_in_all_months ();
}
if (tab == contab){//check contacts
if (!maxcontacts)
return;//nothing to search
for (i = conhit + 1; i <= maxcontacts; i++) {
if (i >= maxcontacts) {
//i = 0;
conhit = 0;
}
texthit4 = strstr (contact[i], findtext);
if (texthit4) {
conhit = i;
contactindex = i;
if (conhit >= maxcontacts)
conhit = 0;
display_contact (contactindex);
display_contactnum (contactindex);
return;
}
}
}//if contab
if (tab == journaltab){//check notes
for (i = notehit + 1; i <= 31; i++) {//scan all the days
if (i == 31)//end of the month
notehit = 0;
if (attach[i]) {//note exists for this day
//check it; this is non-zero if text is found
texthit1 = strstr (noting[i], findtext);
if (texthit1) {//string found
notehit = i;
date = i;
if (notehit >= 31)
notehit = 0;
//find the index of the button for this date
for (j = 1; j <= 37; j++) {//scan the calendar button array
if (date == daybutton[j]) {
currentdaybuttonindex = j;//set the button index
break;
}
}
shownote ();
datebutton ((Fl_Widget *)day[i+offset], NULL);
return;
}//texthit1
}//attach
}//for i
}//if journaltab
if (tab == apptab){//check appts
for (i = appthit + 1; i <= 31; i++) {//scan all the days
if (i == 31)//end of the month
appthit = 0;
if (appt[i] > 0) {//appointments exist for this day
for (j = 1; j <= appt[i]; j++) {//scan all appts for this day
//check the two fields of appts; non-zero if text is found
texthit2 = strstr (appointment[i][j][0], findtext);
texthit3 = strstr (appointment[i][j][1], findtext);
if (texthit2 || texthit3) {//string found
appthit = i;
date = i;
if (appthit >= 31)
appthit = 0;
//find the index of the button for this date
for (j = 1; j <= 37; j++) {//scan the calendar button array
if (date == daybutton[j]) {
currentdaybuttonindex = j;//set the button index
break;
}
}
shownote ();
datebutton ((Fl_Widget *)day[i+offset], NULL);
return;
}//texthit
}//for j
}//appt[i]
}//for i
}//if apptab
}
//end find_text
//end file