ROOT logo
ROOT » CORE » RINT » TTabCom

class TTabCom


TTabCom

This class performs basic tab completion.
You should be able to hit [TAB] to complete a partially typed:

username
environment variable
preprocessor directive
pragma
filename (with a context-sensitive path)
public member function or data member (including base classes)
global variable, function, or class name

Also, something like

someObject->Func([TAB]
someObject.Func([TAB]
someClass::Func([TAB]
someClass var([TAB]
new someClass([TAB]

will print a list of prototypes for the indicated
method or constructor.

Current limitations and bugs:

1. you can only use one member access operator at a time.
eg, this will work: gROOT->GetListOfG[TAB]
but this will not:  gROOT->GetListOfGlobals()->Conta[TAB]

2. nothing is guaranteed to work on windows or VMS
(for one thing, /bin/env and /etc/passwd are hardcoded)

3. CINT shortcut #2 is deliberately not supported.
(using "operator.()" instead of "operator->()")

4. most identifiers (including C++ identifiers, usernames,
environment variables, etc)
are restriceted to this character set: [_a-zA-Z0-9]
therefore, you won't be able to complete things like

operator new
operator+
etc

5. ~whatever[TAB] always tries to complete a username.
use whitespace (~ whatever[TAB]) if you want to complete a global
identifier.

6. CINT shortcut #3 is not supported when trying to complete
the name of a global object.  (it is supported when trying to
complete a member of a global object)

7. the list of #pragma's is hardcoded
(ie not obtained from the interpreter at runtime)
==> user-defined #pragma's will not be recognized

8. the system include directories are also hardcoded
because i don't know how to get them from the interpreter.
fons, maybe they should be #ifdef'd for the different sytems?

9. the TabCom.FileIgnore resource is always applied, even if you
are not trying to complete a filename.

10. anything in quotes is assumed to be a filename
so (among other things) you can't complete a quoted class name:
     eg, TClass class1( "TDict[TAB]                                     //
this won't work... looks for a file in pwd starting with TDict

11. the prototypes tend to omit the word "const" a lot.
this is a problem with ROOT or CINT.

12. when listing ambiguous matches, only one column is used,
even if there are many completions.

13. anonymous objects are not currently identified
so, for example,

root> printf( TString([TAB

gives an error message instead of listing TString's constructors.
(this could be fixed)

14. the routine that adds the "appendage" isn't smart enough to know
if it's already there:

root> TCanvas::Update()
press [TAB] here ^
root> TCanvas::Update()()
(this could be fixed)

15. the appendage is only applied if there is exactly 1 match.
eg, this

root> G__at[TAB]
root> G__ateval

happens instead of this

root> G__at[TAB]
root> G__ateval(

because there are several overloaded versions of G__ateval().
(this could be fixed)


Function Members (Methods)

public:
TTabCom()
virtual~TTabCom()
static Char_tAllAgreeOnChar(int i, const TSeqCollection* pList, Int_t& nGoodStrings)
static voidAppendListOfFilesInDirectory(const char* dirName, TSeqCollection* pList)
static TClass*Class()
voidClearAll()
voidClearClasses()
voidClearCppDirectives()
voidClearEnvVars()
voidClearFiles()
voidClearGlobalFunctions()
voidClearGlobals()
voidClearPragmas()
voidClearSysIncFiles()
voidClearUsers()
static TStringDetermineClass(const char* varName)
static Bool_tExcludedByFignore(TString s)
const TSeqCollection*GetListOfClasses()
const TSeqCollection*GetListOfCppDirectives()
const TSeqCollection*GetListOfEnvVars()
const TSeqCollection*GetListOfFilesInPath(const char* path)
const TSeqCollection*GetListOfGlobalFunctions()
const TSeqCollection*GetListOfGlobals()
const TSeqCollection*GetListOfPragmas()
const TSeqCollection*GetListOfSysIncFiles()
const TSeqCollection*GetListOfUsers()
static TStringGetSysIncludePath()
Int_tHook(char* buf, int* pLoc)
virtual TClass*IsA() const
static Bool_tIsDirectory(const char* fileName)
static TSeqCollection*NewListOfFilesInPath(const char* path)
static voidNoMsg(Int_t errorLevel)
static Bool_tPathIsSpecifiedInFileName(const TString& fileName)
voidRehashAll()
voidRehashClasses()
voidRehashCppDirectives()
voidRehashEnvVars()
voidRehashFiles()
voidRehashGlobalFunctions()
voidRehashGlobals()
voidRehashPragmas()
voidRehashSysIncFiles()
voidRehashUsers()
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
private:
TTabCom(const TTabCom&)
Int_tComplete(const TRegexp& re, const TSeqCollection* pListOfCandidates, const char* appendage, TString::ECaseCompare cmp = TString::kExact)
voidCopyMatch(char* dest, const char* localName, const char* appendage = 0, const char* fullName = 0) const
TTabCom::EContext_tDetermineContext() const
TStringDeterminePath(const TString& fileName, const char* defaultPath) const
TStringExtendPath(const char* originalPath, TString newBase) const
voidInitPatterns()
TClass*MakeClassFromClassName(const char* className) const
TClass*MakeClassFromVarName(const char* varName, TTabCom::EContext_t& context, int iter = 0)
TTabCom&operator=(const TTabCom&)
intParseReverse(const char* var_str, int start)
voidSetPattern(TTabCom::EContext_t handle, const char* regexp)
TClass*TryMakeClassFromClassName(const char* className) const

Data Members

public:
enum { kDebug
};
enum EContext_t { kUNKNOWN_CONTEXT
kSYS_UserName
kSYS_EnvVar
kCINT_stdout
kCINT_stderr
kCINT_stdin
kCINT_Edit
kCINT_Load
kCINT_Exec
kCINT_EXec
kCINT_pragma
kCINT_includeSYS
kCINT_includePWD
kCINT_cpp
kROOT_Load
kSYS_FileName
kCXX_NewProto
kCXX_ConstructorProto
kCXX_ScopeProto
kCXX_DirectProto
kCXX_IndirectProto
kCXX_ScopeMember
kCXX_DirectMember
kCXX_IndirectMember
kCXX_Global
kCXX_GlobalProto
kNUM_PAT
};
private:
char*fBufinitialized by Hook()
Int_tfLastIterfrodo: iteration counter for recursive MakeClassFromVarName
unsigned shortfPat[25][1024]array of patterns
const char*fRegExp[25]corresponding regular expression plain text
Bool_tfVarIsPointerfrodo: pointer or not flag
TSeqCollection*fpClasses
TSeqCollection*fpDirectives
TSeqCollection*fpEnvVars
TSeqCollection*fpFiles
TSeqCollection*fpGlobalFuncs
TSeqCollection*fpGlobals
int*fpLocinitialized by Hook()
TSeqCollection*fpNamespacesContains the names of namespaces registered in CINT.
TSeqCollection*fpPragmas
TSeqCollection*fpSysIncFiles
TSeqCollection*fpUsers

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TTabCom()
 Default constructor.
~TTabCom()
 Destructor.
void ClearClasses()
 Clear classes and namespace collections.
void ClearCppDirectives()
 Forget all Cpp directives seen so far.
void ClearEnvVars()
 Forget all environment variables seen so far.
void ClearFiles()
 Close all files.
void ClearGlobalFunctions()
 Forget all global functions seen so far.
void ClearGlobals()
 Forget all global variables seen so far.
void ClearPragmas()
 Forget all pragmas seen so far.
void ClearSysIncFiles()
 Close system files.
void ClearUsers()
 Forget all user seen so far.
void ClearAll()
 clears all lists
 except for user names and system include files.
void RehashClasses()
 Do the class rehash.
void RehashCppDirectives()
 Cpp rehashing.
void RehashEnvVars()
 Environemnt variables rehashing.
void RehashFiles()
 Close files.
void RehashGlobalFunctions()
 Reload global functions.
void RehashGlobals()
 Reload globals.
void RehashPragmas()
 Reload pragmas.
void RehashSysIncFiles()
 Reload system include files.
void RehashUsers()
 Reload users.
void RehashAll()
 clears and then rebuilds all lists
 except for user names and system include files.
const TSeqCollection * GetListOfClasses()
 Return the list of classes.
const TSeqCollection * GetListOfCppDirectives()
 Return the list of CPP directives.
const TSeqCollection * GetListOfFilesInPath(const char* path)
 "path" should be initialized with a colon separated list of
 system directories
const TSeqCollection * GetListOfEnvVars()
 Uses "env" (Unix) or "set" (Windows) to get list of environment variables.
const TSeqCollection * GetListOfGlobals()
 Return the list of globals.
const TSeqCollection * GetListOfGlobalFunctions()
 Return the list of global functions.
const TSeqCollection * GetListOfPragmas()
 Return the list of pragmas
const TSeqCollection * GetListOfSysIncFiles()
 Return the list of system include files.
const TSeqCollection * GetListOfUsers()
 reads from "/etc/passwd"
Char_t AllAgreeOnChar(int i, const TSeqCollection* pList, Int_t& nGoodStrings)
[static utility function]

  if all the strings in "*pList" have the same ith character,
  that character is returned.
  otherwise 0 is returned.

  any string "s" for which "ExcludedByFignore(s)" is true
  will be ignored unless All the strings in "*pList"
  are "ExcludedByFignore()"

  in addition, the number of strings which were not
  "ExcludedByFignore()" is returned in "nGoodStrings".


void AppendListOfFilesInDirectory(const char* dirName, TSeqCollection* pList)
[static utility function]

  adds a TObjString to "*pList"
  for each entry found in the system directory "dirName"

  directories that do not exist are silently ignored.


TString DetermineClass(const char* varName)
[static utility function]

  returns empty string on failure.
  otherwise returns something like this: "TROOT*".
  fails for non-class types (ie, int, char, etc).
  fails for pointers to functions.


Bool_t ExcludedByFignore(TString s)
[static utility function]

  returns true iff "s" ends with one of
  the strings listed in the "TabCom.FileIgnore" resource.


TString GetSysIncludePath()
[static utility function]

  returns a colon-separated string of directories
  that CINT will search when you call #include<...>

  returns empty string on failure.


Bool_t IsDirectory(const char* fileName)
[static utility function]

  calls TSystem::GetPathInfo() to see if "fileName"
  is a system directory.


TSeqCollection * NewListOfFilesInPath(const char* path)
[static utility function]

  creates a list containing the full path name for each file
  in the (colon separated) string "path1"

  memory is allocated with "new", so
  whoever calls this function takes responsibility for deleting it.


Bool_t PathIsSpecifiedInFileName(const TString& fileName)
[static utility function]

  true if "fileName"
  1. is an absolute path ("/tmp/a")
  2. is a relative path  ("../whatever", "./test")
  3. starts with user name ("~/mail")
  4. starts with an environment variable ("$ROOTSYS/bin")


void NoMsg(Int_t errorLevel)
[static utility function]

  calling "NoMsg( errorLevel )",
  sets "gErrorIgnoreLevel" to "errorLevel+1" so that
  all errors with "level < errorLevel" will be ignored.

  calling the function with a negative argument
  (e.g., "NoMsg( -1 )")
  resets gErrorIgnoreLevel to its previous value.


Int_t Complete(const TRegexp& re, const TSeqCollection* pListOfCandidates, const char* appendage, TString::ECaseCompare cmp = TString::kExact)
 [private]
void CopyMatch(char* dest, const char* localName, const char* appendage = 0, const char* fullName = 0) const
 [private]
TString DeterminePath(const TString& fileName, const char* defaultPath) const
 [private]
TString ExtendPath(const char* originalPath, TString newBase) const
 [private]
Int_t Hook(char* buf, int* pLoc)
 [private]
void InitPatterns()
 [private]
TClass * MakeClassFromClassName(const char* className) const
 [private]
   (does some specific error handling that makes the function unsuitable for general use.)
   returns a new'd TClass given the name of a class.
   user must delete.
   returns 0 in case of error.
TClass * TryMakeClassFromClassName(const char* className) const
 Same as above but does not print the error message.
TClass * MakeClassFromVarName(const char* varName, TTabCom::EContext_t& context, int iter = 0)
 [private]
   (does some specific error handling that makes the function unsuitable for general use.)
   returns a new'd TClass given the name of a variable.
   user must delete.
   returns 0 in case of error.
   if user has operator.() or operator->() backwards, will modify: context, *fpLoc and fBuf.
   context sensitive behavior.
void SetPattern(TTabCom::EContext_t handle, const char* regexp)
 [private]
int ParseReverse(const char* var_str, int start)
 Returns the place in the string where to put the \0, starting the search
 from "start"

TTabCom()
TTabCom& operator=(const TTabCom& )
EContext_t DetermineContext() const