26 #include <boost/lexical_cast.hpp> 28 #include "chat_curses.h" 41 nodelay(stdscr, TRUE);
47 void ChatCurses::update_size()
49 getmaxyx(stdscr, ymax_, xmax_);
55 upper_win_ = newwin(ymax_ * UPPER_WIN_FRAC - 1, xmax_, 0, 0);
56 divider_win_ = newwin(1, xmax_, ymax_ * UPPER_WIN_FRAC - 1, 0);
57 lower_win_ = newwin(ymax_ * LOWER_WIN_FRAC, xmax_, ymax_ * UPPER_WIN_FRAC, 0);
59 scrollok(upper_win_,
true);
61 mvwhline(divider_win_, 0, 0, 0, xmax_);
62 wrefresh(divider_win_);
69 if (k == KEY_DC || k == KEY_BACKSPACE)
71 if (!line_buffer_.empty())
72 line_buffer_.resize(line_buffer_.size() - 1);
74 waddstr(lower_win_, line_buffer_.c_str());
76 else if ((k == KEY_ENTER || k ==
'\n') && !line_buffer_.empty())
83 else if (k == KEY_RESIZE)
87 else if (isprint(k) && line_buffer_.length() < MAX_LINE)
89 waddch(lower_win_, k);
100 std::stringstream ss;
101 ss <<
"[" <<
id <<
"]: " << line;
107 std::string line_plus_end = line +
"\n";
108 waddstr(upper_win_, line_plus_end.c_str());
109 wrefresh(upper_win_);
void run_input(std::string &line)
grab a character and if there's a line to return it will be returned in line
void startup()
start the display
void post_message(unsigned id, const std::string &line)
add a message to the upper window (the chat log)
void cleanup()
end the display