Diff of /plugins/filtertable.py [17c6bf] .. [82ddff] Maximize Restore

  Switch to unified view

a/plugins/filtertable.py b/plugins/filtertable.py
1
1
2
import wx
2
import wx
3
from findinfiles import FoundTable
3
from findinfiles import FoundTable
4
import mylistmix
4
import mylistmix
5
import todo
5
import todo
6
import codetree
6
import __main__
7
import __main__
7
8
8
columns = (
9
columns = (
9
    (0, "Lines", 50, wx.LIST_FORMAT_RIGHT),
10
    (0, "Lines", 50, wx.LIST_FORMAT_RIGHT),
10
    (1, "Definition", 20, 0),
11
    (1, "Definition", 20, 0),
...
...
14
options = None
15
options = None
15
16
16
17
17
#colors
18
#colors
18
if 1:
19
if 1:
19
    blue = wx.Colour(0, 0, 200)
20
    D = {}
20
    red = wx.Colour(200, 0, 0)
21
    green = wx.Colour(0, 200, 0)
22
    D = {'cl':blue,
23
         'de':red,
24
         'cd':green,
25
         '\\l':red,
26
         '\\s':blue}
27
    
28
    for i,j in D.items():
21
    for i,j in codetree.D.items():
29
        k = wx.ListItemAttr()
22
        k = wx.ListItemAttr()
30
        k.SetTextColour(j)
23
        k.SetTextColour(j)
31
        D[i] = k
24
        D[i] = k
32
    
25
    
33
    default = D['de']
26
    default = D['de']
34
    
27
    
35
    del i, j, k, blue, red, green
28
    del i, j, k
36
29
37
def lcsseq(x, y):
30
def lcsseq(x, y):
38
    _enum = enumerate
31
    _enum = enumerate
39
    _max = max
32
    _max = max
40
    z = {}
33
    z = {}
...
...
101
    if rch and str.endswith(rch):
94
    if rch and str.endswith(rch):
102
        return str[:-len(rch)]
95
        return str[:-len(rch)]
103
    return str
96
    return str
104
97
105
def get_line_counts(h, lang):
98
def get_line_counts(h, lang):
106
    if lang != 'python':
99
    if lang not in ('python', 'cpp'):
107
        return {}
100
        return {}
108
    #need implementation for C/C++, but only after parser for C/C++ is done
101
    #need implementation for C/C++, but only after parser for C/C++ is done
109
    
102
    
110
    counts = {}
103
    counts = {}
111
    stk = [h[::-1]]
104
    stk = [h[::-1]]
...
...
118
            _ = nstk.pop()
111
            _ = nstk.pop()
119
            continue
112
            continue
120
        
113
        
121
        while cur:
114
        while cur:
122
            name, line_no, leading, children = cur.pop()
115
            name, line_no, leading, children = cur.pop()
116
            if lang == 'python':
123
            pre, shortname1 = name.split(None, 1)
117
                pre, shortname1 = name.split(None, 1)
124
            shortname = partition(partition(shortname1, ':')[0], '(')[0]
118
                shortname = partition(partition(shortname1, ':')[0], '(')[0]
125
            key = '%s%s%s'%('.'.join(nstk), '.'[:bool(nstk)], shortname)
119
                key = '%s%s%s'%('.'.join(nstk), '.'[:bool(nstk)], shortname)
120
            
121
            elif lang == 'cpp':
122
                key, shortname = name, line_no[2]
126
            
123
            
127
            if lastn:
124
            if lastn:
128
                counts.setdefault(lastn, []).append(line_no[1]-lastl)
125
                counts.setdefault(lastn, []).append(line_no[1]-lastl)
129
            
126
            
130
            lastn = key
127
            lastn = key
131
            lastl = line_no[1]
128
            lastl = line_no[1]
132
            
129
                
133
            if children:
130
            if children:
134
                stk.append(cur)
131
                stk.append(cur)
135
                nstk.append(shortname)
132
                nstk.append(shortname)
136
                stk.append(None)
133
                stk.append(None)
137
                cur = children[::-1]
134
                cur = children[::-1]
...
...
209
        options = self.cs.GetValue(), self.lcs.GetValue(), self.context.GetValue(), self.how.GetValue()
206
        options = self.cs.GetValue(), self.lcs.GetValue(), self.context.GetValue(), self.how.GetValue()
210
    
207
    
211
    def new_hierarchy(self, hier):
208
    def new_hierarchy(self, hier):
212
        #parse the hierarchy, set the data
209
        #parse the hierarchy, set the data
213
        lang = self.stc.style()
210
        lang = self.stc.style()
214
        if lang not in ('python', 'tex'):
211
        if lang not in ('python', 'tex', 'cpp'):
215
            return
212
            return
216
        names = []
213
        names = []
217
        stk = [hier[::-1]]
214
        stk = [hier[::-1]]
218
        nstk = []
215
        nstk = []
219
        nstk2 = []
216
        nstk2 = []
...
...
249
                                  '%s{%s}'%(head, x),
246
                                  '%s{%s}'%(head, x),
250
                                  ' '.join(nstk2+[name]),
247
                                  ' '.join(nstk2+[name]),
251
                                  0
248
                                  0
252
                                  ))
249
                                  ))
253
                
250
                
254
                else:
251
                elif lang == 'cpp':
255
                    #need implementation for C/C++, but only after parser for C/C++ is done
252
                    shortname = line_no[2]
256
                    continue
253
                    shortname2 = name
254
                    x = '.'.join(nstk+[shortname])
255
                    y = name.find(line_no[2])
256
                    names.append((name, line_no, x,
257
                                  "%s %s%s%s"%(name[:y].strip(), '.'.join(nstk), '.'[:bool(nstk)], name[y:].strip()),
258
                                  ' '.join(nstk2+[name]),
259
                                  (counts.get(name) or [0]).pop(0)))
257
                
260
                
258
                if children:
261
                if children:
259
                    stk.append(cur)
262
                    stk.append(cur)
260
                    nstk.append(shortname)
263
                    nstk.append(shortname)
261
                    nstk2.append(shortname2)
264
                    nstk2.append(shortname2)