-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientViewNcurses.h
More file actions
45 lines (33 loc) · 866 Bytes
/
Copy pathClientViewNcurses.h
File metadata and controls
45 lines (33 loc) · 866 Bytes
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
37
38
39
40
41
42
43
44
45
#ifndef _CLIENTVIEWNCURSES_GUARD
#define _CLIENTVIEWNCURSES_GUARD
#include "ClientView.h"
#include <thread>
#include <atomic>
#include <mutex>
#include <ncurses.h>
#include <iostream>
class ClientViewNcurses : public ClientView, public std::streambuf {
public:
ClientViewNcurses(ClientThread& clientThread);
~ClientViewNcurses();
void init(int id, int N);
virtual int overflow(int c);
virtual int sync();
// Update the view
int update(const char* state, size_t size);
private:
// The size of the game
int N;
// The windows
WINDOW *main_win, *game_win, *dbg_win;
// The main thread
std::thread loop_th;
std::atomic<bool> running;
std::mutex ncurses_mtx;
// Old buf
std::streambuf * old_stdout_buf;
std::streambuf * old_stderr_buf;
// The main loop
void loop();
};
#endif