Changeset 1472 for trunk/peppy/plugins/project.py
- Timestamp:
- 07/08/08 12:21:02 (5 months ago)
- Files:
-
- 1 modified
-
trunk/peppy/plugins/project.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/peppy/plugins/project.py
r1454 r1472 20 20 from peppy.yapsy.plugins import * 21 21 from peppy.actions import * 22 from peppy.actions.minibuffer import * 22 23 from peppy.lib.userparams import * 23 24 from peppy.lib.processmanager import * … … 25 26 26 27 class CTAGS(InstancePrefs): 28 # lookup table for kinds of ctags 29 kind_of_tag = { 30 'c': 'class name', 31 'd': 'define', 32 'e': 'enumerator', 33 'f': 'function', 34 'F': 'file name', 35 'g': 'enumeration name', 36 'm': 'member', 37 'p': 'function prototype', 38 's': 'structure name', 39 't': 'typedef', 40 'u': 'union name', 41 'v': 'variable', 42 } 43 44 special_tags = { 45 'file:': '(static scope)', 46 } 47 27 48 default_prefs = ( 28 49 StrParam('ctags_extra_args', '', 'extra arguments for the ctags command', fullwidth=True), … … 97 118 def getTag(self, tag): 98 119 return self.tags.get(tag, None) 120 121 def getTagInfo(self, tag): 122 """Get a text description of all the tags associated with the given 123 keyword. 124 125 Returns a string of text suitable to be used in a grep-style output 126 reporter; that is, a bunch of lines starting with the string 127 'filename:line number:' followed by descriptive text about each tag. 128 """ 129 tags = self.getTag(tag) 130 refs = [] 131 for t in tags: 132 info = "%s:%s: %s " % (t[0], t[1], tag) 133 fields = t[2].split('\t') 134 for field in fields: 135 if ':' in field: 136 if field in self.special_tags: 137 info += self.special_tags[field] 138 else: 139 info += field + " " 140 elif field in self.kind_of_tag: 141 info += "kind:" + self.kind_of_tag[field] + " " 142 refs.append(info) 143 if refs: 144 text = os.linesep.join(refs) + os.linesep 145 else: 146 text = '' 147 return text 148 149 def getSortedTagList(self): 150 tags = self.tags.keys() 151 tags.sort() 152 return tags 99 153 100 154 … … 202 256 203 257 258 class LookupCtag(SelectAction): 259 """Display all references given a tag name""" 260 name = "Lookup Tag" 261 default_menu = ("Project", -400) 262 key_bindings = {'emacs': "C-c C-t"} 263 264 def action(self, index=-1, multiplier=1): 265 tags = self.mode.project_info.getSortedTagList() 266 minibuffer = StaticListCompletionMinibuffer(self.mode, self, _("Lookup Tag:"), list=tags) 267 self.mode.setMinibuffer(minibuffer) 268 269 def processMinibuffer(self, minibuffer, mode, name): 270 text = self.mode.project_info.getTagInfo(name) 271 if not text: 272 text = "No information about %s" % name 273 Publisher().sendMessage('peppy.log.info', text) 274 275 204 276 class RebuildCtags(SelectAction): 205 277 """Rebuild tag file""" 206 278 name = "Rebuild Tag File" 207 default_menu = ("Project", -500)279 default_menu = ("Project", 499) 208 280 209 281 def action(self, index=-1, multiplier=1): … … 371 443 default_classprefs = ( 372 444 StrParam('project_directory', '.peppy-project', 'Directory used within projects to store peppy specific information'), 373 StrParam('project_file', 'project. ini', 'File within project directory used to store per-project information'),445 StrParam('project_file', 'project.cfg', 'File within project directory used to store per-project information'), 374 446 StrParam('template_directory', 'templates', 'Directory used to store template files for given major modes'), 375 447 PathParam('ctags_command', 'exuberant-ctags', 'Path to ctags command', fullwidth=True), … … 539 611 actions.append(SaveGlobalTemplate) 540 612 if mode.buffer.url in self.known_project_dirs: 541 actions.extend([SaveProjectTemplate, BuildProject, RunProject, RebuildCtags]) 613 actions.extend([SaveProjectTemplate, BuildProject, RunProject, 614 615 RebuildCtags, LookupCtag]) 542 616 actions.extend([CreateProject, CreateProjectFromExisting, ShowProjectSettings]) 543 617 return actions
