-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOutputBarList.cpp
338 lines (291 loc) · 9.85 KB
/
OutputBarList.cpp
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
/*******************************************************************************
Copyright (c) 1999-2010 by Text Analysis International, Inc.
All rights reserved.
*******************************************************************************/
// OutputBarList.cpp : implementation file
//
#include "stdafx.h"
#include "kb.h"
#include "Utils.h"
#include "MainFrm.h"
#include "TreeViewAnalyzer.h"
#include "TreeViewGrammar.h"
#include "OutputBarList.h"
#include ".\outputbarlist.h"
extern CVisualTextApp theApp;
extern CString appStrLocation;
// COutputBarList
IMPLEMENT_DYNAMIC(COutputBarList, CListCtrl)
COutputBarList::COutputBarList()
{
}
COutputBarList::~COutputBarList()
{
}
BEGIN_MESSAGE_MAP(COutputBarList, CListCtrl)
// ON_WM_LBUTTONDBLCLK()
ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclk)
ON_COMMAND(ID_FINDMENU_CLEAR, OnFindmenuClear)
ON_COMMAND(ID_FINDMENU_OPEN, OnFindmenuOpen)
ON_WM_CONTEXTMENU()
END_MESSAGE_MAP()
// COutputBarList message handlers
void COutputBarList::FindInFindTab()
{
CMainFrame *wnd = (CMainFrame *)AfxGetMainWnd();
CString fileStr;
CString dirPathStr;
CString findStr;
CString fileOriginStr;
int intVal,intVal2;
DEBUG_TYPE type = GetSelectedFile(fileStr,findStr,fileOriginStr,intVal,intVal2);
intVal--;
if (type == DEBUG_NOOP) {
return;
}
else if (type == DEBUG_FIND) {
CString lowerFileStr = fileStr;
CString lowerAppStrLocation = appStrLocation;
lowerFileStr.MakeLower();
lowerAppStrLocation.MakeLower();
if (lowerFileStr.Find(lowerAppStrLocation) != 0)
dirPathStr = AppPath(fileStr);
else
dirPathStr = fileStr;
CDocument *doc;
if (FileExists(dirPathStr)) {
//if (!(doc = theApp.IsVisualTextDocumentOpen("VisualText",dirPathStr)))
// IF PASS FILE, MOVE TO ANALYZER TAB AND SELECT PASS
if (EndsWith(fileStr,_T("pat"))) {
theApp.m_pMainFrame->m_wndAnalyzerView.EditRulesFile(dirPathStr); // SRP 010606, for Pass File Number in Doc Title Bar
}
doc = AfxGetApp()->OpenDocumentFile(dirPathStr);
CVisualTextView *view = (CVisualTextView *)GetFirstView(doc);
CRichEditCtrl &ed = view->GetRichEditCtrl();
// Calling GetLineCount() must somehow force edit control to take stock of number of lines.
// On certain machines (e.g. 450 MHz), LineIndex(intval) wrongly returned -1
int lineCount = ed.GetLineCount();
int lineIndex = ed.LineIndex(intVal);
long start = lineIndex + intVal2;
long end = start + findStr.GetLength();
ed.SetSel(start, end);
RECT rect;
view->GetClientRect(&rect);
int numVisibleLines = (rect.bottom - rect.top) / 16;
int firstVisibleLine = ed.GetFirstVisibleLine();
int selectionLine = ed.LineFromChar(start);
int scrollIt = selectionLine - firstVisibleLine - numVisibleLines / 2;
view->Scroll(scrollIt);
}
}
else if (type == DEBUG_ERROR) {
theApp.m_pMainFrame->m_wndAnalyzerView.ViewPassLog(intVal);
wnd->SelectTab(WORKSPACE_ANALYZER);
}
}
void COutputBarList::FindInAnalyzerTab()
{
CMainFrame *wnd = (CMainFrame *)AfxGetMainWnd();
CString fileStr;
CString dirPathStr;
CString findStr;
CString fileOriginStr;
int intVal1, intVal2;
DEBUG_TYPE type = GetSelectedFile1(fileStr,findStr,fileOriginStr,intVal1,intVal2);
if (type != DEBUG_PASS_LINE)
intVal1--;
if (type == DEBUG_NOOP) {
return;
}
else if (type == DEBUG_PASS_LINE) {
// SRP 010606, for Pass File Number in Doc Title Bar
CString fileNameStr = StripPath(fileStr,0);
ClipRight(fileNameStr,4);
int pass = theApp.m_pMainFrame->m_wndAnalyzerView.PassFromFile(fileNameStr);
wnd->SelectPass(pass,true);
theApp.m_pMainFrame->m_wndAnalyzerView.SendMessage(WM_COMMAND,ID_SEQUENCEMENU_EDITRULES);
CDocument *doc = AfxGetApp()->OpenDocumentFile(fileStr);
CVisualTextView *view = (CVisualTextView *)GetFirstView(doc);
CRichEditCtrl &ed = view->GetRichEditCtrl();
int start = ed.LineIndex(--intVal2);
view->SetFocus();
ed.SetSel(start,start);
}
#if 0 // All find stuff is now in FindListCtrl.cpp // SRP 010606
else if (type == DEBUG_FIND) {
if (EndsWith(fileStr,_T("log"))) {
if (fileOriginStr != _T("")) {
dirPathStr = fileOriginStr;
if (EndsWith(fileOriginStr,_T(".txt")))
dirPathStr += _T("_log\\") + fileStr;
}
else
dirPathStr = wnd->GetProcessTextFile(fileStr);
}
else if (EndsWith(fileStr,_T(".pat")))
dirPathStr = RulesPath(fileStr,true);
else if (EndsWith(fileStr,_T(".txt")))
dirPathStr = InputPath(fileStr);
else if (EndsWith(fileStr,_T(".smp")))
dirPathStr = GramPath(fileStr);
else
return;
CDocument *doc = AfxGetApp()->OpenDocumentFile(dirPathStr);
CVisualTextView *view = (CVisualTextView *)GetFirstView(doc);
CRichEditCtrl &ed = view->GetRichEditCtrl();
_TCHAR buff[1001];
int count = ed.GetLineCount(); // THIS JUST INITIALIZES THE ED! :-(
long start = ed.LineIndex(intVal1);
long len = ed.GetLine(intVal1,buff,1000);
buff[len] = '\0';
CString buffStr = buff;
start += buffStr.Find(findStr);
long end = start + findStr.GetLength();
view->SetFocus();
ed.SetSel(start, end);
}
#endif
else if (type == DEBUG_ERROR) {
//wnd->ViewLogFile(InputPath(fileStr),intVal);
theApp.m_pMainFrame->m_wndAnalyzerView.ViewPassLog(intVal1);
wnd->SelectTab(WORKSPACE_ANALYZER);
}
else if (type == DEBUG_RULE) {
//wnd->ViewLogFile(InputPath(fileStr),intVal);
CString fileNameStr = theApp.m_pMainFrame->m_wndAnalyzerView.CleanPassNameFromPass(intVal1);
// SRP 010606, for Pass File Number in Doc Title Bar
int pass = intVal1;
wnd->SelectPass(pass,true);
theApp.m_pMainFrame->m_wndAnalyzerView.SendMessage(WM_COMMAND,ID_SEQUENCEMENU_EDITRULES);
wnd->SelectTab(WORKSPACE_GRAMMAR);
theApp.m_pMainFrame->m_wndGrammarView.SetSelection(fileNameStr);
}
}
void COutputBarList::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)
{
switch (pNMHDR->idFrom) {
case IDC_SHEET1:
case IDC_SHEET2: // FIX. // 02/19/05 DD.
FindInAnalyzerTab();
break;
case IDC_SHEET3:
case IDC_SHEET4:
FindInFindTab();
break;
}
// TODO: Add your control notification handler code here
*pResult = 0;
}
DEBUG_TYPE COutputBarList::GetSelectedFile(CString &fileStr, CString &findStr,
CString &fileOriginStr, int &intVal, int &intVal2)
{
CMainFrame *wnd = (CMainFrame *)AfxGetMainWnd();
_TCHAR buff[1001];
int line = GetSelectionMark();
GetItemText(line,0,buff,1000);
CString nameStr = buff;
GetItemText(line,1,buff,1000);
CString viewStr = buff;
findStr = _T("");
fileOriginStr = _T("");
DEBUG_TYPE type = DEBUG_NOOP;
intVal = -1;
CStringList parseList;
if ((ParseLine(parseList,nameStr,_T("File: %a[%d %d]:")))) {
fileStr = NthStringListItem(parseList,0);
fileStr.TrimRight(_T(" "));
intVal = _ttoi((const _TCHAR *)NthStringListItem(parseList,1));
intVal2 = _ttoi((const _TCHAR *)NthStringListItem(parseList,2));
// Get search word
GetItemText(0,1,buff,1000);
findStr = buff;
// Get search origin file
GetItemText(1,1,buff,1000);
fileOriginStr = buff;
type = DEBUG_FIND;
}
else if ((ParseLine(parseList,nameStr,_T("Concept: %w")))) {
TokensBySeparator(parseList,viewStr, '/');
wnd->SelectTab(WORKSPACE_GRAMMAR);
theApp.m_pMainFrame->m_wndGrammarView.SelectFromStringList(parseList);
}
else if (nameStr.Find(_T("Spidering level")) == 0) {
wnd->BrowserNavigate(viewStr);
}
return type;
}
DEBUG_TYPE COutputBarList::GetSelectedFile1(CString &fileStr, CString &findStr,
CString &fileOriginStr, int &intVal1, int &intVal2)
{
_TCHAR buff[1001];
int line = GetSelectionMark();
GetItemText(line,0,buff,1000);
CString nameStr = buff;
GetItemText(line,1,buff,1000);
CString viewStr = buff;
findStr = _T("");
fileOriginStr = _T("");
DEBUG_TYPE type = DEBUG_NOOP;
intVal1 = -1;
intVal2 = -1;
CStringList parseList;
if ((ParseLine(parseList,viewStr,_T("%d %d [")))) {
intVal1 = _ttoi((const _TCHAR *)NthStringListItem(parseList,0));
intVal2 = _ttoi((const _TCHAR *)NthStringListItem(parseList,1));
if (intVal1 > 0) { // SRP 010607 // if intVal == 0, the currently selected pass in the Ana Tab is opened.
fileStr = theApp.m_pMainFrame->m_wndAnalyzerView.PassFileFromNumber(intVal1);
if (FileExists(fileStr)) // SRP 010607 // Prevent trying to open system passes (like tokenize, that have no associated file)
type = DEBUG_PASS_LINE;
}
}
else if ((ParseLine(parseList,nameStr,_T("Log file: %w:")))) {
fileStr = NthStringListItem(parseList,0);
if ((ParseLine(parseList,viewStr,_T("[Pass %d")))) {
intVal1 = _ttoi((const _TCHAR *)NthStringListItem(parseList,0));
type = DEBUG_ERROR;
}
}
else if (nameStr.CompareNoCase(_T("Processing pass:")) == 0) {
if ((ParseLine(parseList,viewStr,_T("%d %w %w")))) {
intVal1 = _ttoi((const _TCHAR *)NthStringListItem(parseList,0));
type = DEBUG_ERROR;
}
}
else if (nameStr.CompareNoCase(_T("Generating rules:")) == 0) {
if ((ParseLine(parseList,viewStr,_T("%d %w %w")))) {
intVal1 = _ttoi((const _TCHAR *)NthStringListItem(parseList,0));
type = DEBUG_RULE;
}
}
return type;
}
void COutputBarList::OnContextMenu(CWnd* pWnd, CPoint point)
{
if (GetItemCount() == 0)
return;
UINT disables[100];
for (int i=0; i<100; i++)
disables[i] = 0;
CMainFrame *wnd = (CMainFrame *)AfxGetMainWnd();
//int tab = wnd->m_wndOutputBar.m_flatTabCtrl.GetCurSel();
// 02/19/05 DD.
PopupContextMenu(this,IDR_FIND,point,disables);
}
void COutputBarList::OnFindmenuClear()
{
StartWaitCursor();
SetRedraw(false);
DeleteAllItems();
SetRedraw(true);
StopWaitCursor();
}
void COutputBarList::OnFindmenuOpen()
{
CMainFrame *wnd = (CMainFrame *)AfxGetMainWnd();
int tab = 0;
//tab = wnd->m_wndOutputBar.m_flatTabCtrl.GetCurSel();
if (tab == 0)
FindInAnalyzerTab();
else if (tab >= 2 && tab <=3)
FindInFindTab();
}