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

Last change on this file since 14450 was 14126, checked in by tbretz, 12 years ago
Removed the DimNetwork; implemented the JavaScript interpreter.
File size: 2.7 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 true;
26 }
27 lout << kRed << "Unkown server '" << s << "'" << endl;
28 return false;
29 }
30
31 if (!fCurrentServer.empty() && str=="..")
32 {
33 fCurrentServer = "";
34 return true;
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() || !fImp)
52 return beg + "> ";
53
54 // Check if we have cd'ed to a valid server
55 const pair<int32_t, string> state = fImp->GetServerState(fCurrentServer);
56 if (state.first==-256)
57 return beg + "> ";
58
59 // The server
60 const string serv = "\033[34m\033[1m"+fCurrentServer+"\033[0m";
61
62 // If no match found or something wrong found just output the server
63 if (state.first<-1)
64 return beg + " " + serv + "> ";
65
66 // If everything found add the state to the server
67 return beg + " " + serv + ":\033[32m\033[1m" + state.second + "\033[0m> ";
68}
69
70string RemoteShell::GetUpdatePrompt() const
71{
72 // If we are continously flushing the buffer omit the buffer size
73 // If we are buffering show the buffer size
74 const string beg = GetLinePrompt();
75
76 // If we have not cd'ed to a server show only the line start
77 if (fCurrentServer.empty() || !fImp)
78 return beg + "> ";
79
80 const pair<int32_t, string> state = fImp->GetServerState(fCurrentServer);
81 if (state.first==-256)
82 return beg + "> ";//Form("\n[%d] \033[34m\033[1m%s\033[0m> ", GetLine(), fCurrentServer.c_str());
83
84 // If no match found or something wrong found just output the server
85 if (state.first<-1)
86 return beg + " " + fCurrentServer + "> ";
87
88 // If everything found add the state to the server
89 return beg + " " + fCurrentServer + ":" + state.second + "> ";
90}
Note: See TracBrowser for help on using the repository browser.