-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainFrame.hpp
36 lines (27 loc) · 906 Bytes
/
MainFrame.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include "NcWindow.hpp"
#include <span>
#include <vector>
namespace jess {
class MainFrame {
jess::NcWindow &m_rootWindow;
jess::NcWindow m_mainWindow{m_rootWindow.height() - 1, m_rootWindow.width(), 0, 0};
public:
explicit MainFrame(jess::NcWindow &rootWindow) : m_rootWindow(rootWindow) {}
void drawLines(auto lines) {
auto it = std::begin(lines);
auto end = std::end(lines);
size_t windowHeight = m_mainWindow.height();
m_mainWindow.move(0, 0);
for (size_t i = 0; i < windowHeight && it != end; ++i, ++it) {
m_mainWindow.move(i, 0);
m_mainWindow.printw("%s ", it->realtimeUtc().c_str());
m_mainWindow.printw("%s", it->message().c_str());
m_mainWindow.clearToEol();
}
m_mainWindow.clearToBot();
m_mainWindow.refresh();
}
[[nodiscard]] size_t height() const { return m_mainWindow.height(); }
};
} // namespace jess