Changeset 10341
- Timestamp:
- 04/10/11 10:12:56 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/RemoteControl.cc
r10307 r10341 72 72 if (fCurrentServer.empty()) 73 73 { 74 if(fServiceList.HasServer(str)) 74 const size_t p1 = str.find_first_of(' '); 75 const size_t p2 = str.find_first_of('/'); 76 77 string s = str; 78 if (p2!=string::npos && p1>p2) 79 s = str.substr(0, p2); 80 81 if (p2<p1) 75 82 { 76 fCurrentServer = str; 83 const string c = str.substr(p2+1); 84 return !fCommandList.SendDimCommand(lout, s, c); 85 } 86 87 if(fServiceList.HasServer(s)) 88 { 89 fCurrentServer = s; 77 90 return false; 78 91 } 79 lout << kRed << "Unkown server '" << s tr<< "'" << endl;92 lout << kRed << "Unkown server '" << s << "'" << endl; 80 93 return true; 81 94 } -
trunk/FACT++/src/RemoteControl.h
r10312 r10341 104 104 #include "WindowLog.h" 105 105 #include "ReadlineColor.h" 106 #include "tools.h" 106 107 107 108 template <class T> … … 110 111 private: 111 112 std::ostream &lout; /// Output stream for local synchrounous output 113 114 static void append(std::string &str) 115 { 116 str.append("/"); 117 } 112 118 113 119 // This funtion defines which generator should be called. … … 117 123 { 118 124 // Get the whole buffer before the tab-position 119 const string s = string(T::GetBuffer(), 0, start); 120 const string l = T::TrimSpaces(s.c_str()); 125 const string b = string(T::GetBuffer()); 126 const string s = b.substr(0, start); 127 const string l = Trim(s.c_str()); 121 128 if (l.empty()) 122 129 { 123 130 if (fCurrentServer.empty()) 124 return T::Complete(fCommandList.GetServerList(), text); 131 { 132 const size_t p1 = b.find_first_of(' '); 133 const size_t p2 = b.find_first_of('/'); 134 135 if (p1==string::npos && p2!=string::npos) 136 return T::Complete(fCommandList.GetServiceList(), text); 137 138 std::vector<std::string> v = fCommandList.GetServerList(); 139 for_each(v.begin(), v.end(), RemoteControl::append); 140 return T::Complete(v, text); 141 } 125 142 else 126 143 return T::Complete(fCommandList.GetServiceList(fCurrentServer), text); … … 152 169 T::PrintGeneralHelp(); 153 170 lout << " " << kUnderline << "Specific commands:" << endl; 171 lout << kBold << " h,help <arg> " << kReset << "List help text for given server or command." << endl; 154 172 lout << kBold << " s,servers " << kReset << "List all servers which are connected." << endl; 155 173 lout << kBold << " svc,services " << kReset << "List all services in the network." << endl; … … 168 186 bool Process(const std::string &str) 169 187 { 188 if (str.substr(0, 2)=="h " || str.substr(0, 5)=="help ") 189 { 190 const size_t p1 = str.find_first_of(' '); 191 const string svc = str.substr(p1+1); 192 193 const size_t p3 = svc.find_first_of('/'); 194 const string s = svc.substr(0, p3); 195 const string c = p3==string::npos?"":svc.substr(p3+1); 196 197 lout << endl; 198 if (!fCurrentServer.empty()) 199 { 200 if (fCommandList.PrintDescription(lout, fCurrentServer, svc)==0) 201 lout << " " << svc << ": <not found>" << endl; 202 } 203 else 204 { 205 if (fCommandList.PrintDescription(lout, s, c)==0) 206 lout << " <no matches found>" <<endl; 207 } 208 209 return true; 210 } 211 170 212 if (ReadlineColor::Process(lout, str)) 171 213 return true;
Note:
See TracChangeset
for help on using the changeset viewer.