5 li = s.rsplit(old, occurrence)
10 std::vector<std::string> _TTabComHook(const char* pattern){
11 static auto ttc = new TTabCom;
12 int pLoc = strlen(pattern);
13 std::ostringstream oss;
14 ttc->Hook((char* )pattern, &pLoc, oss);
15 std::stringstream ss(oss.str());
16 std::istream_iterator<std::string> vbegin(ss), vend;
17 return std::vector<std::string> (vbegin, vend);
23 Completer which interfaces to the TTabCom of ROOT. It is activated
24 (deactivated) upon the load(unload) of the load of the extension.
26 >>> comp = CppCompleter()
28 >>> for suggestion in comp._completeImpl("TH1"):
37 >>> for suggestion in comp._completeImpl("TH2"):
48 >>> garbage = ROOT.gInterpreter.ProcessLine("TH1F* h")
49 >>> for suggestion in comp._completeImpl("h->GetA"):
55 >>> for suggestion in comp._completeImpl("TROOT::Is"):
73 >>> for suggestion in comp._completeImpl("TG"):
86 utils.declareCppCode(
'#include "dlfcn.h"')
87 dlOpenRint =
'dlopen("libRint.so",RTLD_NOW);'
88 utils.processCppCode(dlOpenRint)
89 utils.declareCppCode(_TTabComHookCode)
90 self.
hook = ROOT._TTabComHook
98 return self.
hook(line)
104 tmpAccessorPos = line.rfind(accessor)
105 if accessorPos < tmpAccessorPos:
106 accessorPos = tmpAccessorPos+len(accessor)
if accessor!=
"::" else 0
110 line=line.split()[-1]
112 if not suggestions:
return []
114 suggestions = sorted(suggestions)
116 suggestions = [line[:accessorPos]+sugg
for sugg
in suggestions]
121 Autocomplete interfacing to TTabCom. If an accessor of a scope is
122 present in the line, the suggestions are prepended with the line.
123 That's how completers work. For example:
124 myGraph.Set<tab> will return "myGraph.Set+suggestion in the list of
133 _cppCompleter.activate()
134 ipython.set_hook(
'complete_command', _cppCompleter.complete, re_key=
r"[(.*)[\.,::,\->](.*)]|(.*)")
137 _cppCompleter.deactivate()
def _getSuggestions(self, line)
def _completeImpl(self, line)
def rreplace(s, old, new, occurrence)
def load_ipython_extension(ipython)
def complete(self, ip, event)
def unload_ipython_extension(ipython)
def _getLastAccessorPos(self, line)