10 #include <fmt/format.h> 38 , m_fdWatcher(fdWatcher)
65 fdWatcher->registerFD(STDIN_FILENO, boost::bind(&
UI::handleInput,
this));
78 for(
int i = 0; i < n; ++i)
80 float hue = i * 360 / n;
92 std::min(255, std::max<int>(0, r))
93 | (std::min(255, std::max<int>(0, g)) << 8)
94 | (std::min(255, std::max<int>(0, b)) << 16);
102 const int NODE_WIDTH = 13;
104 unsigned int lines = 2;
110 std::string muteOption =
isMuted(selectedNode->name()) ?
"u: unmute" :
"m: mute";
112 fmt::print(
"Actions: s: start, k: stop, d: debug, {}", muteOption);
116 fmt::print(
"Global shortcuts: <node key>: show node menu, F9: mute all, F10: unmute all ");
121 fmt::print(
"! Caution: Nodes muted !");
138 uint32_t keyBackgroundColor256 = 0xC8C8C8;
144 keyBackgroundColor256 = 0x0000A5;
154 fmt::print(
"{:c}", key);
156 switch(node->state())
172 std::string label = node->name().substr(0, NODE_WIDTH);
174 fmt::print(
"[{:^{}}]", label, NODE_WIDTH);
176 fmt::print(
" {:^{}} ", label, NODE_WIDTH);
180 const int BLOCK_WIDTH = NODE_WIDTH + 3;
193 else if(col + 1 + BLOCK_WIDTH >
m_columns)
215 g_statusLines = std::max(lines, g_statusLines);
218 void UI::log(
const std::string& channel,
const std::string& str)
223 std::string
clean = str;
240 fmt::print(
"{:>20}:", channel);
245 unsigned int len = clean.length();
246 while(len != 0 && (clean[len-1] ==
'\n' || clean[len-1] ==
'\r'))
251 it->second.parser.apply(&
m_term);
252 it->second.parser.parse(clean);
255 fwrite(clean.c_str(), 1, len, stdout);
310 if(c >=
'a' && c <=
'z')
312 else if(c >=
'A' && c <=
'Z')
313 nodeIndex = 26 + c -
'A';
314 else if(c >=
'0' && c <=
'9')
315 nodeIndex = 26 + 26 + c -
'0';
317 if(nodeIndex < 0 || (
size_t)nodeIndex >=
m_monitor->
nodes().size())
335 node->launchDebugger();
const std::vector< NodeMonitor::Ptr > & nodes() const
std::map< std::string, ChannelInfo > m_nodeColorMap
SimpleColor
Simple colors.
bool getSize(int *columns, int *rows)
Get current window size.
void setSimpleBackground(SimpleColor color)
void moveCursorToStartOfLine()
Move cursor to start of the line.
FDWatcher::Ptr m_fdWatcher
void setBackgroundColor(uint32_t color)
Set 24-bit background color.
UI(monitor::Monitor *monitor, const FDWatcher::Ptr &fdWatcher)
ROSCPP_DECL std::string clean(const std::string &name)
monitor::Monitor * m_monitor
void mute(const std::string &s)
void setSimplePair(SimpleColor fg, SimpleColor bg)
boost::signals2::signal< void(std::string, std::string)> logMessageSignal
ros::WallTimer m_sizeTimer
Idle (e.g. exited with code 0)
void log(const std::string &channel, const std::string &str)
void HUSLtoRGB(float *r, float *g, float *b, float h, float s, float l)
void clearToEndOfLine()
Clear characters from cursor to end of line.
static std::string g_windowTitle
void setStandardColors()
Reset fg + bg to standard terminal colors.
Waiting for automatic restart after crash.
bool isMuted(const std::string &s)
void unmute(const std::string &s)
static unsigned int g_statusLines
void setCursorVisible()
restore cursor
void setSimpleForeground(SimpleColor color)
Encapsulates terminal control.
void moveCursorUp(int numLines)
Move cursor up by numLines.
bool has256Colors() const
void setWindowTitle(const std::string &title)
void setCursorInvisible()
hide cursor
Crashed (i.e. exited with code != 0)
launch::LaunchConfig::ConstPtr config() const
void clearWindowTitle(const std::string &backup)