source: trunk/FACT++/src/RemoteControl.cc@ 11308

Last change on this file since 11308 was 10493, checked in by tbretz, 14 years ago
Allow server names to end with a slash.
File size: 2.8 KB
Line 
1#include "RemoteControl.h"
2
3// ==========================================================================
4
5bool RemoteControlImp::ProcessCommand(const std::string &str)
6{
7 if (fCurrentServer.empty())
8 {
9 const size_t p1 = str.find_first_of(' ');
10 const size_t p2 = str.find_first_of('/');
11
12 string s = str;
13 if (p2!=string::npos && p1>p2)
14 s = str.substr(0, p2);
15
16 if (p2<p1 && p2!=str.length()-1)
17 {
18 const string c = str.substr(p2+1);
19 return !SendDimCommand(lout, s, c);
20 }
21
22 if (HasServer(s))
23 {
24 fCurrentServer = s;
25 return false;
26 }
27 lout << kRed << "Unkown server '" << s << "'" << endl;
28 return true;
29 }
30
31 if (!fCurrentServer.empty() && str=="..")
32 {
33 fCurrentServer = "";
34 return false;
35 }
36
37 return !SendDimCommand(lout, fCurrentServer, str);
38}
39
40// ==========================================================================
41
42#include "tools.h"
43
44string RemoteConsole::GetUpdatePrompt() const
45{
46 // If we are continously flushing the buffer omit the buffer size
47 // If we are buffering show the buffer size
48 const string beg = '\n' + GetLinePrompt();
49
50 // If we have not cd'ed to a server show only the line start
51 if (fCurrentServer.empty())
52 return beg + "> ";
53
54 // Check if we have cd'ed to a valid server
55 const ClientList::const_iterator l = fClientList.find(fCurrentServer);
56 if (l==fClientList.end())
57 return beg + "> ";
58
59 const State state = GetState(fCurrentServer, l->second->GetState());
60
61 // The server
62 const string serv = "\033[34m\033[1m"+fCurrentServer+"\033[0m";
63
64 // If no match found or something wrong found just output the server
65 if (state.index<-1)
66 return beg + " " + serv + "> ";
67
68 // If everything found add the state to the server
69 return beg + " " + serv + ":\033[32m\033[1m" + state.name + "\033[0m> ";
70}
71
72string RemoteShell::GetUpdatePrompt() const
73{
74 // If we are continously flushing the buffer omit the buffer size
75 // If we are buffering show the buffer size
76 const string beg = GetLinePrompt();
77
78 // If we have not cd'ed to a server show only the line start
79 if (fCurrentServer.empty())
80 return beg + "> ";
81
82 // Check if we have cd'ed to a valid server
83 const ClientList::const_iterator l = fClientList.find(fCurrentServer);
84 if (l==fClientList.end())
85 return beg + "> ";//Form("\n[%d] \033[34m\033[1m%s\033[0m> ", GetLine(), fCurrentServer.c_str());
86
87 const State state = GetState(fCurrentServer, l->second->GetState());
88
89 // If no match found or something wrong found just output the server
90 if (state.index<-1)
91 return beg + " " + fCurrentServer + "> ";
92
93 // If everything found add the state to the server
94 return beg + " " + fCurrentServer + ":" + state.name + "> ";
95}
Note: See TracBrowser for help on using the repository browser.