Goby v2
chat_curses.h
1 // Copyright 2009-2018 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 //
5 //
6 // This file is part of the Goby Underwater Autonomy Project Binaries
7 // ("The Goby Binaries").
8 //
9 // The Goby Binaries are free software: you can redistribute them and/or modify
10 // them under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // The Goby Binaries are distributed in the hope that they will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
21 
22 #include <ncurses.h>
23 
24 const float UPPER_WIN_FRAC = 0.75;
25 const float LOWER_WIN_FRAC = 1 - UPPER_WIN_FRAC;
26 const unsigned MAX_LINE = 26; // fixed in chat.xml
27 
30 {
31  public:
33 
34  ChatCurses() {}
35  ~ChatCurses() { cleanup(); }
37 
39  void set_modem_id(unsigned id) { id_ = id; }
40 
42  void startup();
44  void run_input(std::string& line);
45 
47  void cleanup();
48 
50  void post_message(unsigned id, const std::string& line);
51  void post_message(const std::string& line);
52 
53  private:
54  void update_size();
55 
56  private:
57  int xmax_;
58  int ymax_;
59 
60  unsigned id_;
61 
62  WINDOW* upper_win_;
63  WINDOW* lower_win_;
64  WINDOW* divider_win_;
65 
66  std::string line_buffer_;
67 };
void run_input(std::string &line)
grab a character and if there&#39;s a line to return it will be returned in line
Definition: chat_curses.cpp:65
provides a terminal GUI for a chat window (lower box to type and upper box to receive messages)...
Definition: chat_curses.h:29
void startup()
start the display
Definition: chat_curses.cpp:30
void post_message(unsigned id, const std::string &line)
add a message to the upper window (the chat log)
Definition: chat_curses.cpp:98
void cleanup()
end the display
Definition: chat_curses.cpp:96
void set_modem_id(unsigned id)
give the modem_id so we know how to label our messages
Definition: chat_curses.h:39