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
|
/***************************************************************************
tcl_parser.cpp - description
-------------------
begin : Apr 2 2003
author : 2003 Massimo Callegari
email : massimocallegari@yahoo.it
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "plugin_katesymbolviewer.h"
void KatePluginSymbolViewerView::parseTclSymbols(void)
{
if (!win->viewManager()->activeView())
return;
TQString currline, prevline;
bool prevComment = false;
TQString varStr("set ");
TQString procStr("proc");
TQString stripped;
uint i, j, args_par = 0, graph = 0;
char block = 0, parse_func = 0;
TQListViewItem *node = NULL;
TQListViewItem *mcrNode = NULL, *clsNode = NULL;
TQListViewItem *lastMcrNode = NULL, *lastClsNode = NULL;
TQPixmap mcr( ( const char** ) macro_xpm );
TQPixmap cls( ( const char** ) class_xpm );
if(treeMode)
{
clsNode = new TQListViewItem(symbols, symbols->lastItem(), i18n("Functions"));
mcrNode = new TQListViewItem(symbols, symbols->lastItem(), i18n("Globals"));
lastMcrNode = mcrNode;
lastClsNode = clsNode;
if (expanded_on)
{
clsNode->setOpen(TRUE);
mcrNode->setOpen(TRUE);
}
symbols->setRootIsDecorated(1);
}
else
symbols->setRootIsDecorated(0);
Kate::Document *kDoc = win->viewManager()->activeView()->getDoc();
//positions.resize(kDoc->numLines() + 3); // Maximum symbols number o.O
//positions.fill(0);
for (i = 0; i<kDoc->numLines(); i++)
{
currline = kDoc->textLine(i);
currline = currline.stripWhiteSpace();
bool comment = false;
kdDebug(13000)<<currline<<endl;
if(currline.at(0) == '#') comment = true;
if(i > 0)
{
prevline = kDoc->textLine(i-1);
if(prevline.endsWith("\\") && prevComment) comment = true;
}
prevComment = comment;
if(!comment)
{
if(currline.startsWith(varStr) && block == 0)
{
if (macro_on == true) // not really a macro, but a variable
{
stripped = currline.right(currline.length() - 3);
stripped = stripped.simplifyWhiteSpace();
int fnd = stripped.find(' ');
//fnd = stripped.find(";");
if(fnd > 0) stripped = stripped.left(fnd);
if (treeMode)
{
node = new TQListViewItem(mcrNode, lastMcrNode, stripped);
lastMcrNode = node;
}
else
node = new TQListViewItem(symbols, symbols->lastItem(), stripped);
node->setPixmap(0, (const TQPixmap &)mcr);
node->setText(1, TQString::number( i, 10));
stripped = "";
}//macro
} // starts with "set"
else if(currline.startsWith(procStr)) { parse_func = 1; }
if (parse_func == 1)
{
for (j = 0; j < currline.length(); j++)
{
if (block == 1)
{
if(currline.at(j)=='{') graph++;
if(currline.at(j)=='}')
{
graph--;
if (graph == 0) { block = 0; parse_func = 0; continue; }
}
}
if (block == 0)
{
stripped += currline.at(j);
if(currline.at(j) == '{') args_par++;
if(currline.at(j) == '}')
{
args_par--;
if (args_par == 0)
{
//stripped = stripped.simplifyWhiteSpace();
if(func_on == true)
{
if (treeMode)
{
node = new TQListViewItem(clsNode, lastClsNode, stripped);
lastClsNode = node;
}
else
node = new TQListViewItem(symbols, symbols->lastItem(), stripped);
node->setPixmap(0, (const TQPixmap &)cls);
node->setText(1, TQString::number( i, 10));
}
stripped = "";
block = 1;
}
}
} // block = 0
} // for j loop
}//func_on
} // not a comment
} //for i loop
//positions.resize(symbols->itemIndex(node) + 1);
}
|