/* This file is part of SLC. Copyright (C) 2008 Sebastien LUTTRINGER SLC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. SLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SLC; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef SCREEN_HH # define SCREEN_HH_ # include # include # include #define KEY_RETURN 10 #define KEY_EOF 4 typedef std::stringstream sstream; class Screen { public: typedef std::deque t_lines; public: Screen(); void init(); void login(); void dialog(); void eventsloop(); void msg_println(const string &s); void msg_println(int i); void msg_print(const string &s); void msg_print(int i); void socket_reader(); private: void create_windows(); void cmd_draw(); void msg_draw(); void msg_add(const string &s); void msg_load(const string &filename); void msg_save(const string &filename) const; const string &msg_get(size_t i) const; size_t msg_size() const; bool add_char(char c, char *string, ssize_t offset, size_t buf_len); bool del_char(char *string, ssize_t offset, size_t buf_len); private: // msg window WINDOW *msg_; t_lines msg_table_; sstream msg_buffer_; char *msg_win_buffer_; // cmd window WINDOW *cmd_; char cmd_buffer_[MAX_LINE_SIZE]; char cmd_history_buffer_[MAX_LINE_SIZE]; size_t cmd_buf_off_; size_t cmd_win_off_; size_t cmd_history_off_; }; Screen &operator<< (Screen &, const string &s); Screen &operator<< (Screen &, int i); // exec commands namespace cmd { void exec(const char *); void login(); void logout(); void user(const char *); void pass(const char *); void help(); } #endif