47 const auto& logs =
logs_->logs();
51 printEntry(i, logs[entry.index], entry.line, i);
56 for (
size_t i = 0; i <
height_; i++) {
58 printEntry(i, logs[entry.index], entry.line, i + start_idx);
70 int64_t start_idx = cursor;
78 const auto& logs =
logs_->logs();
81 printEntry(i, logs[entry.index], entry.line, i + start_idx);
97 if (key ==
ctrl(
'a')) {
112 if (event.bstate & BUTTON1_PRESSED) {
118 else if (
mouse_down_ && (event.bstate & REPORT_MOUSE_POSITION)) {
123 else if (event.bstate & BUTTON1_RELEASED) {
128 else if (!
mouse_down_ && (event.bstate & BUTTON3_PRESSED)) {
154 if (select_start >=0 && select_end >= 0) {
155 int start = std::min(select_start, select_end);
156 int end = std::max(select_start, select_end);
157 const auto& logs =
logs_->logs();
161 std::string prefix =
getPrefix(logs[entry.index], entry.line);
162 data += prefix + logs[entry.index].text[entry.line] +
"\n";
204 if (entry.
level == rosgraph_msgs::Log::DEBUG) {
207 else if (entry.
level == rosgraph_msgs::Log::INFO) {
210 else if (entry.
level == rosgraph_msgs::Log::WARN) {
213 else if (entry.
level == rosgraph_msgs::Log::ERROR) {
216 else if (entry.
level == rosgraph_msgs::Log::FATAL) {
220 text += std::to_string(entry.
level);
224 text = std::string(text.size(),
' ');
231 bool selected =
false;
234 if (select_start != -1) {
235 int start = std::min(select_start, select_end);
236 int end = std::max(select_start, select_end);
237 selected = idx >= start && idx <= end;
244 if (entry.
level == rosgraph_msgs::Log::DEBUG) {
247 else if (entry.
level == rosgraph_msgs::Log::ERROR) {
250 else if (entry.
level == rosgraph_msgs::Log::FATAL) {
254 else if (entry.
level == rosgraph_msgs::Log::WARN) {
259 std::string prefix =
getPrefix(entry, line);
260 std::string text = prefix + entry.
text[line];
264 size_t match_size = match.size();
265 std::vector<size_t> match_indices;
266 bool matched =
false;
267 if (!match.empty()) {
268 match_indices =
find(entry.
text[line], match,
true);
269 matched = !match_indices.empty();
272 if (
shift_ >= text.size()) {
278 if (text.size() >
width_) {
282 mvwprintw(
window_, row, 0, text.c_str());
288 mvwprintw(
window_, row, 0,
" ");
291 for (
const auto& match_index: match_indices) {
292 int64_t start_idx = match_index + prefix.length() -
shift_;
293 int64_t end_idx = start_idx + match_size;
295 start_idx = std::min(static_cast<int64_t>(text.size()) - 2, std::max(static_cast<int64_t>(0), start_idx));
296 end_idx = std::min(static_cast<int64_t>(text.size()) - 2, std::max(static_cast<int64_t>(0), end_idx));
298 int64_t substr_len = std::max(static_cast<int64_t>(1), end_idx - start_idx);
300 mvwprintw(
window_, row, start_idx, text.substr(start_idx, substr_len).c_str());
306 if (entry.
level == rosgraph_msgs::Log::DEBUG) {
309 else if (entry.
level == rosgraph_msgs::Log::ERROR) {
312 if (entry.
level == rosgraph_msgs::Log::FATAL) {
316 else if (entry.
level == rosgraph_msgs::Log::WARN) {
virtual void resize(int height, int width, int y, int x)
virtual void forceRefresh()
virtual int getContentHeight() const
virtual bool encloses(int y, int x)
virtual size_t getContentSize() const
virtual bool handleKey(int key)
virtual int width() const
virtual void resize(int height, int width, int y, int x)
void printEntry(size_t row, const LogEntry &entry, size_t line, size_t index)
std::vector< size_t > find(const std::string &text, const std::string &substr, bool case_insensitive)
virtual int getContentWidth() const
virtual void endSelect(int row)
const std::deque< LogLine > & indices() const
virtual void startSelect(int row)
std::string toString(double val, int precision)
size_t last_content_size_
virtual bool hidden() const
void setSelectStart(int64_t index)
std::string getPrefix(const LogEntry &entry, size_t line) const
void setCursorOffset(int64_t offset)
void toClipboard(const std::string &text)
std::string getSearch() const
virtual int64_t getCursor() const
virtual void copyToClipboard()
std::vector< std::string > text
void setSelectEnd(int64_t index)
virtual bool handleMouse(const MEVENT &event)
virtual int height() const
virtual void drawScrollBar(size_t count, int height, int y, int x)
virtual void follow(bool enable)