added scrolling to client list, started work on z-buffer override
parent
5fce1272e5
commit
ea78bb4134
|
@ -23,6 +23,13 @@ void Buffer::set_id(std::string _id)
|
|||
id = _id;
|
||||
}
|
||||
|
||||
void Buffer::set_selected(bool _selected)
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex_);
|
||||
selected = _selected;
|
||||
}
|
||||
|
||||
|
||||
frame_t Buffer::get()
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex_);
|
||||
|
@ -34,3 +41,9 @@ std::string Buffer::get_id()
|
|||
Glib::Mutex::Lock lock(mutex_);
|
||||
return id;
|
||||
}
|
||||
|
||||
bool Buffer::get_selected()
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex_);
|
||||
return selected;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
/* This is a threadsafe wrapper around the "frame_t" struct
|
||||
which automates locking during get and set. */
|
||||
|
||||
/* TODO: add forced z value to buffer object so that we can override the
|
||||
* senders buffer
|
||||
*/
|
||||
|
||||
class Buffer : public sigc::trackable
|
||||
{
|
||||
public:
|
||||
|
@ -19,9 +23,14 @@ class Buffer : public sigc::trackable
|
|||
std::string get_id();
|
||||
void set_id(std::string id);
|
||||
|
||||
bool get_selected();
|
||||
void set_selected(bool);
|
||||
|
||||
private:
|
||||
std::string id;
|
||||
frame_t frame;
|
||||
|
||||
bool selected;
|
||||
|
||||
Glib::Mutex mutex_;
|
||||
};
|
||||
|
|
|
@ -30,11 +30,15 @@ class Buffers : public sigc::trackable
|
|||
void add();
|
||||
void remove(std::string);
|
||||
|
||||
void set_selected_buffer(std::string);
|
||||
std::string get_selected_buffer();
|
||||
|
||||
Buffer* get(int);
|
||||
|
||||
private:
|
||||
vector<Buffer*> buffers;
|
||||
std::string id;
|
||||
Glib::Mutex mutex_;
|
||||
std::string selected_buffer;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#include "Server.h"
|
||||
|
||||
/* TODO: add ability to force z-value
|
||||
* add display of chosen and forced z-value (maybe with differring colours
|
||||
* so as to use less space!
|
||||
* //*/
|
||||
|
||||
Server::Server(int _port )
|
||||
{
|
||||
port = _port;
|
||||
|
@ -7,6 +12,7 @@ Server::Server(int _port )
|
|||
packetcounter = 0;
|
||||
consoleinit = false;
|
||||
mode = FRAME;
|
||||
selected_buffer=0;
|
||||
//test();
|
||||
}
|
||||
|
||||
|
@ -266,10 +272,19 @@ void Server::console()
|
|||
keypad(stdscr,TRUE);
|
||||
cbreak();
|
||||
noecho();
|
||||
start_color();
|
||||
|
||||
if(has_colors() == FALSE)
|
||||
{ endwin();
|
||||
printf("Your terminal does not support color\n");
|
||||
// not sure what happens here because of threads!
|
||||
exit(1);
|
||||
}
|
||||
start_color(); /* Start color */
|
||||
|
||||
init_pair(1,COLOR_RED,COLOR_BLACK);
|
||||
init_pair(2,COLOR_GREEN,COLOR_BLACK);
|
||||
init_pair(3,COLOR_BLUE,COLOR_BLACK);
|
||||
init_pair(4,COLOR_BLACK,COLOR_WHITE);
|
||||
{
|
||||
Glib::Mutex::Lock lock(mutex_);
|
||||
consoleinit = true;
|
||||
|
@ -279,7 +294,7 @@ void Server::console()
|
|||
while(1)
|
||||
{
|
||||
{
|
||||
// we'll be accessing some data to provide statistics, lock the Server
|
||||
// we'll be accessing some data to provide statistics, lock the Server!!!
|
||||
Glib::Mutex::Lock lock(mutex_);
|
||||
mvprintw(0,0,"Clients %d | F2 Frame | F3 Values | F4 Clients | F5 Stats | input: %d ", buffers.size(),console_input );
|
||||
switch(mode)
|
||||
|
@ -306,14 +321,15 @@ void Server::console()
|
|||
void Server::input()
|
||||
{
|
||||
int c;
|
||||
|
||||
// get the number of buffers in a threadsafe manner (see Server::get_size() )
|
||||
int size = get_size();
|
||||
|
||||
while(consoleinit)
|
||||
{
|
||||
// getch will wait for input, so loop will not lock up cpu
|
||||
c = getch();
|
||||
|
||||
// now we need to lock data structure because we're going to use shared objects
|
||||
{
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case KEY_F(2):
|
||||
|
@ -328,6 +344,15 @@ void Server::input()
|
|||
mode = CLIENTS;
|
||||
clear();
|
||||
break;
|
||||
case KEY_DOWN:
|
||||
// get the number of buffers in a threadsafe manner (see Server::get_size() )
|
||||
if( mode == CLIENTS && selected_buffer+1 < get_size() )
|
||||
selected_buffer++;
|
||||
break;
|
||||
case KEY_UP:
|
||||
if( mode == CLIENTS && selected_buffer-1 >= 0 )
|
||||
selected_buffer--;
|
||||
break;
|
||||
case '0':
|
||||
default:
|
||||
{
|
||||
|
@ -449,9 +474,19 @@ void Server::console_printclients()
|
|||
{
|
||||
// rows-2 because there is a header
|
||||
if(i > 0 && i%(rows-2)==0)
|
||||
offset += 27;
|
||||
if( offset + 27 < cols )
|
||||
mvprintw(i%(rows-2)+2,offset,"(%3d) %s\n", i,buffers[i]->get_id().c_str() );
|
||||
offset += 32;
|
||||
if( offset + 32 < cols )
|
||||
{
|
||||
//set black on white if the current buffer is selected in the screenview
|
||||
|
||||
if( i == selected_buffer )
|
||||
attron(COLOR_PAIR(4));
|
||||
|
||||
mvprintw(i%(rows-2)+2,offset,"(%3d)[%3d] %s\n", i,buffers[i]->get().z,buffers[i]->get_id().c_str() );
|
||||
|
||||
if( i == selected_buffer )
|
||||
attroff(COLOR_PAIR(4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ private:
|
|||
frame_t frame;
|
||||
|
||||
int port;
|
||||
int selected_buffer;
|
||||
char mode;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
processes=80
|
||||
processes=30
|
||||
i=0
|
||||
|
||||
while [ "$i" -lt "$processes" ]
|
||||
|
|
Loading…
Reference in New Issue