source: branches/fscctrl_safety_limits/src/RemoteControl.cc@ 19166

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