mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-13 12:46:18 +00:00
Moved inlined functions out of class declaration.
This commit is contained in:
+208
-148
@@ -16,105 +16,26 @@ public:
|
|||||||
typedef std::unordered_map<int, int> attributes_map;
|
typedef std::unordered_map<int, int> attributes_map;
|
||||||
|
|
||||||
Canvas(int x = 0, int y = 0, int width = 0, int height = 0);
|
Canvas(int x = 0, int y = 0, int width = 0, int height = 0);
|
||||||
~Canvas() {
|
~Canvas();
|
||||||
if (!m_isDaemon) {
|
|
||||||
delwin(m_window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void refresh() {
|
void refresh();
|
||||||
if (!m_isDaemon) {
|
void redraw();
|
||||||
wnoutrefresh(m_window);
|
void resize(int w, int h);
|
||||||
}
|
void resize(int x, int y, int w, int h);
|
||||||
}
|
|
||||||
static void refresh_std() {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
wnoutrefresh(stdscr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void redraw() {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
redrawwin(m_window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void redraw_std() {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
redrawwin(stdscr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void resize(int w, int h) {
|
static void refresh_std();
|
||||||
if (!m_isDaemon) {
|
static void redraw_std();
|
||||||
wresize(m_window, h, w);
|
static void resize_term(int x, int y);
|
||||||
}
|
static void resize_term(std::pair<int, int> dim);
|
||||||
}
|
|
||||||
void resize(int x, int y, int w, int h);
|
|
||||||
|
|
||||||
static void resize_term(int x, int y) {
|
unsigned int get_x();
|
||||||
if (!m_isDaemon) {
|
unsigned int get_y();
|
||||||
resizeterm(y, x);
|
unsigned int width();
|
||||||
}
|
unsigned int height();
|
||||||
}
|
|
||||||
static void resize_term(std::pair<int, int> dim) {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
resizeterm(dim.second, dim.first);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int get_x() {
|
void move(unsigned int x, unsigned int y);
|
||||||
int x, __UNUSED y;
|
void erase();
|
||||||
if (!m_isDaemon) {
|
static void erase_std();
|
||||||
getyx(m_window, y, x);
|
|
||||||
} else {
|
|
||||||
x = 1;
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
unsigned int get_y() {
|
|
||||||
int x, y;
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
getyx(m_window, y, x);
|
|
||||||
} else {
|
|
||||||
y = 1;
|
|
||||||
}
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int width() {
|
|
||||||
int x, __UNUSED y;
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
getmaxyx(m_window, y, x);
|
|
||||||
} else {
|
|
||||||
x = 80;
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
unsigned int height() {
|
|
||||||
int x, y;
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
getmaxyx(m_window, y, x);
|
|
||||||
} else {
|
|
||||||
y = 24;
|
|
||||||
}
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void move(unsigned int x, unsigned int y) {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
wmove(m_window, y, x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void erase() {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
werase(m_window);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void erase_std() {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
werase(stdscr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The format string is non-const, but that will not be a problem
|
// The format string is non-const, but that will not be a problem
|
||||||
// since the string shall always be a C string choosen at
|
// since the string shall always be a C string choosen at
|
||||||
@@ -122,72 +43,27 @@ public:
|
|||||||
|
|
||||||
void print(const char* str, ...);
|
void print(const char* str, ...);
|
||||||
void print(unsigned int x, unsigned int y, const char* str, ...);
|
void print(unsigned int x, unsigned int y, const char* str, ...);
|
||||||
|
|
||||||
void print_attributes(unsigned int x, unsigned int y, const char* first, const char* last, const attributes_list* attributes);
|
void print_attributes(unsigned int x, unsigned int y, const char* first, const char* last, const attributes_list* attributes);
|
||||||
|
void print_char(const chtype ch);
|
||||||
|
void print_char(unsigned int x, unsigned int y, const chtype ch);
|
||||||
|
|
||||||
void print_char(const chtype ch) {
|
void set_attr(unsigned int x, unsigned int y, unsigned int n, int attr, int color);
|
||||||
if (!m_isDaemon) {
|
void set_attr(unsigned int x, unsigned int y, unsigned int n, ColorKind k);
|
||||||
waddch(m_window, ch);
|
void set_default_attributes(int attr);
|
||||||
}
|
|
||||||
}
|
|
||||||
void print_char(unsigned int x, unsigned int y, const chtype ch) {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
mvwaddch(m_window, y, x, ch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_attr(unsigned int x, unsigned int y, unsigned int n, int attr, int color) {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
mvwchgat(m_window, y, x, n, attr, color, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_attr(unsigned int x, unsigned int y, unsigned int n, ColorKind k) {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
mvwchgat(m_window, y, x, n, m_attr_map[k], k, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_default_attributes(int attr) {
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
(void)wattrset(m_window, attr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize stdscr.
|
// Initialize stdscr.
|
||||||
static void initialize();
|
static void initialize();
|
||||||
static void build_colors();
|
static void build_colors();
|
||||||
static void cleanup();
|
static void cleanup();
|
||||||
|
|
||||||
static int get_screen_width() {
|
static int get_screen_width();
|
||||||
int x, __UNUSED y;
|
static int get_screen_height();
|
||||||
if (!m_isDaemon) {
|
|
||||||
getmaxyx(stdscr, y, x);
|
|
||||||
} else {
|
|
||||||
x = 80;
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
static int get_screen_height() {
|
|
||||||
int x, y;
|
|
||||||
if (!m_isDaemon) {
|
|
||||||
getmaxyx(stdscr, y, x);
|
|
||||||
} else {
|
|
||||||
y = 24;
|
|
||||||
}
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::pair<int, int> term_size();
|
static std::pair<int, int> term_size();
|
||||||
|
|
||||||
static void do_update() {
|
static void do_update();
|
||||||
if (!m_isDaemon) {
|
|
||||||
doupdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool daemon() { return m_isDaemon; }
|
static bool daemon() { return m_isDaemon; }
|
||||||
|
|
||||||
static const attributes_map& attr_map() { return m_attr_map; }
|
static const attributes_map& attr_map() { return m_attr_map; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -203,6 +79,126 @@ private:
|
|||||||
WINDOW* m_window;
|
WINDOW* m_window;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline Canvas::~Canvas() {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
delwin(m_window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::refresh() {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
wnoutrefresh(m_window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::refresh_std() {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
wnoutrefresh(stdscr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::redraw() {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
redrawwin(m_window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::redraw_std() {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
redrawwin(stdscr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::resize(int w, int h) {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
wresize(m_window, h, w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::resize_term(int x, int y) {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
resizeterm(y, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::resize_term(std::pair<int, int> dim) {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
resizeterm(dim.second, dim.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned int
|
||||||
|
Canvas::get_x() {
|
||||||
|
int x, __UNUSED y;
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
getyx(m_window, y, x);
|
||||||
|
} else {
|
||||||
|
x = 1;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned int
|
||||||
|
Canvas::get_y() {
|
||||||
|
int x, y;
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
getyx(m_window, y, x);
|
||||||
|
} else {
|
||||||
|
y = 1;
|
||||||
|
}
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned int
|
||||||
|
Canvas::width() {
|
||||||
|
int x, __UNUSED y;
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
getmaxyx(m_window, y, x);
|
||||||
|
} else {
|
||||||
|
x = 80;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned int
|
||||||
|
Canvas::height() {
|
||||||
|
int x, y;
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
getmaxyx(m_window, y, x);
|
||||||
|
} else {
|
||||||
|
y = 24;
|
||||||
|
}
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::move(unsigned int x, unsigned int y) {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
wmove(m_window, y, x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::erase() {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
werase(m_window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::erase_std() {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
werase(stdscr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
Canvas::print(const char* str, ...) {
|
Canvas::print(const char* str, ...) {
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
@@ -226,6 +222,70 @@ Canvas::print(unsigned int x, unsigned int y, const char* str, ...) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::print_char(const chtype ch) {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
waddch(m_window, ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::print_char(unsigned int x, unsigned int y, const chtype ch) {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
mvwaddch(m_window, y, x, ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::set_attr(unsigned int x, unsigned int y, unsigned int n, int attr, int color) {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
mvwchgat(m_window, y, x, n, attr, color, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::set_attr(unsigned int x, unsigned int y, unsigned int n, ColorKind k) {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
mvwchgat(m_window, y, x, n, m_attr_map[k], k, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::set_default_attributes(int attr) {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
(void)wattrset(m_window, attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int
|
||||||
|
Canvas::get_screen_width() {
|
||||||
|
int x, __UNUSED y;
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
getmaxyx(stdscr, y, x);
|
||||||
|
} else {
|
||||||
|
x = 80;
|
||||||
|
}
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int
|
||||||
|
Canvas::get_screen_height() {
|
||||||
|
int x, y;
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
getmaxyx(stdscr, y, x);
|
||||||
|
} else {
|
||||||
|
y = 24;
|
||||||
|
}
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
Canvas::do_update() {
|
||||||
|
if (!m_isDaemon) {
|
||||||
|
doupdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace display
|
} // namespace display
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user