diff options
author | 2010-08-11 23:02:54 +0300 | |
---|---|---|
committer | 2010-08-11 23:02:54 +0300 | |
commit | 1c012ed4604ec7cb4476eba447751fd5314a9fcb (patch) | |
tree | cf8c1808df6879c2a925585f97e4ad89eb58e193 | |
parent | Fix warnings: unused return value. (diff) | |
download | idfetch-1c012ed4604ec7cb4476eba447751fd5314a9fcb.tar.gz idfetch-1c012ed4604ec7cb4476eba447751fd5314a9fcb.tar.bz2 idfetch-1c012ed4604ec7cb4476eba447751fd5314a9fcb.zip |
Add [colors] section to tuiclient.conf file
[colors]
Define color scheme for tuiclient.
Avaible colors are:
COLOR_BLACK
COLOR_RED
COLOR_GREEN
COLOR_YELLOW
COLOR_BLUE
COLOR_MAGENTA
COLOR_CYAN
COLOR_WHITE
Defaults:
when tuiclient connected to seggetd:
color_distfile_added_connected_fg=COLOR_WHITE
color_distfile_added_connected_bg=COLOR_BLACK
color_distfile_waiting_connected_fg=COLOR_BLUE
color_distfile_waiting_connected_bg=COLOR_BLACK
color_distfile_script_rejected_connected_fg=COLOR_YELLOW
color_distfile_script_rejected_connected_bg=COLOR_BLACK
color_distfile_downloading_connected_fg=COLOR_CYAN
color_distfile_downloading_connected_bg=COLOR_BLACK
color_distfile_downloaded_connected_fg=COLOR_GREEN
color_distfile_downloaded_connected_bg=COLOR_BLACK
color_distfile_failed_connected_fg=COLOR_RED
color_distfile_failed_connected_bg=COLOR_BLACK
color_distfiles_window_connected_fg=COLOR_WHITE
color_distfiles_window_connected_bg=COLOR_BLACK
color_scroll_window_connected_fg=COLOR_GREEN
color_scroll_window_connected_bg=COLOR_BLACK
color_downloads_connected_fg=COLOR_WHITE
color_downloads_connected_bg=COLOR_BLACK
color_info_connected_fg=COLOR_BLACK
color_info_connected_bg=COLOR_CYAN
color_status_connected_fg=COLOR_GREEN
color_status_connected_bg=COLOR_BLACK
when tuiclient disconnected from seggetd:
color_distfile_added_disconnected_fg=COLOR_WHITE
color_distfile_added_disconnected_bg=COLOR_BLACK
color_distfile_waiting_disconnected_fg=COLOR_WHITE
color_distfile_waiting_disconnected_bg=COLOR_BLACK
color_distfile_script_rejected_disconnected_fg=COLOR_WHITE
color_distfile_script_rejected_disconnected_bg=COLOR_BLACK
color_distfile_downloading_disconnected_fg=COLOR_WHITE
color_distfile_downloading_disconnected_bg=COLOR_BLACK
color_distfile_downloaded_disconnected_fg=COLOR_WHITE
color_distfile_downloaded_disconnected_bg=COLOR_BLACK
color_distfile_failed_disconnected_fg=COLOR_WHITE
color_distfile_failed_disconnected_bg=COLOR_BLACK
color_distfiles_window_disconnected_fg=COLOR_WHITE
color_distfiles_window_disconnected_bg=COLOR_BLACK
color_scroll_window_disconnected_fg=COLOR_WHITE
color_scroll_window_disconnected_bg=COLOR_BLACK
color_downloads_disconnected_fg=COLOR_BLACK
color_downloads_disconnected_bg=COLOR_WHITE
color_info_disconnected_fg=COLOR_WHITE
color_info_disconnected_bg=COLOR_BLACK
color_status_disconnected_fg=COLOR_BLACK
color_status_disconnected_bg=COLOR_RED
-rw-r--r-- | segget/Makefile | 2 | ||||
-rw-r--r-- | segget/distfile.cpp | 2 | ||||
-rw-r--r-- | segget/log.cpp | 4 | ||||
-rw-r--r-- | segget/segment.cpp | 2 | ||||
-rw-r--r-- | tuiclient/colors.cpp | 63 | ||||
-rw-r--r-- | tuiclient/config.cpp | 39 | ||||
-rw-r--r-- | tuiclient/config.h | 2 | ||||
-rw-r--r-- | tuiclient/settings.cpp | 57 | ||||
-rw-r--r-- | tuiclient/settings.h | 112 | ||||
-rw-r--r-- | tuiclient/str.cpp | 16 | ||||
-rw-r--r-- | tuiclient/str.h | 2 | ||||
-rw-r--r-- | tuiclient/tuiclient.conf | 60 | ||||
-rw-r--r-- | tuiclient/tuiclient.cpp | 2 |
13 files changed, 327 insertions, 36 deletions
diff --git a/segget/Makefile b/segget/Makefile index e00327d..5a069f2 100644 --- a/segget/Makefile +++ b/segget/Makefile @@ -13,7 +13,7 @@ LIBS = $(LIBS_PKGCONFIG) #MIBS = -lncurses CXXFLAGS = $(CXXFLAGS_PKGCONFIG) -lncurses $(CXXFLAGS_WARNINGS) $(CXXFLAGS_OPT) -all: clean $(BINS) +all: $(BINS) %.o: %.cxx $(CXX) -c -o $@ $(CXXFLAGS) $^ diff --git a/segget/distfile.cpp b/segget/distfile.cpp index b48e50d..883532a 100644 --- a/segget/distfile.cpp +++ b/segget/distfile.cpp @@ -865,7 +865,7 @@ int Tdistfile::combine_segments(){ string distfile_path=settings.distfiles_dir+"/"+name; try{ distfile_file.open(distfile_path.c_str(),ofstream::binary|ios::trunc); - if (distfile_file==0){ + if (! distfile_file.is_open()){ error_log("Error: distfile.cpp: combine_segments(): opening distfile "+distfile_path+" for writing"); error_log("....Check if folder "+settings.distfiles_dir+" exists and seggetd has permissions to write into it."); } diff --git a/segget/log.cpp b/segget/log.cpp index d19876d..a2df826 100644 --- a/segget/log.cpp +++ b/segget/log.cpp @@ -55,7 +55,7 @@ void log_no_msg(string log_msg_text){ file.exceptions (ofstream::failbit | ofstream::badbit); try{ file.open((settings.logs_dir+"/"+settings.general_log_file).c_str(), ios::app); - if (file==0){ + if (! file.is_open()){ error_log("Error opening "+settings.logs_dir+"/"+settings.general_log_file+" for writing."); error_log("....Check if folder "+settings.logs_dir+" exists and seggetd has rights to write into it."); return; @@ -117,7 +117,7 @@ void debug_no_msg(string debug_msg_text){ file.exceptions (ofstream::failbit | ofstream::badbit); try{ file.open((settings.logs_dir+"/"+settings.debug_log_file).c_str(), ios::app); - if (file==0){ + if (! file.is_open()){ error_log("Error opening "+settings.logs_dir+"/"+settings.debug_log_file+" for writing."); error_log("....Check if folder "+settings.logs_dir+" exists and seggetd has permissions to write into it."); return; diff --git a/segget/segment.cpp b/segget/segment.cpp index cc4e2f2..b771948 100644 --- a/segget/segment.cpp +++ b/segget/segment.cpp @@ -109,7 +109,7 @@ uint Tsegment::add_easy_handle_to_multi(CURLM *cm, uint network_num){ try{ segment_file.exceptions (ofstream::badbit); segment_file.open((settings.segments_dir+"/"+file_name).c_str(), ios::trunc|ios::binary ); - if (segment_file==0){ + if (! segment_file.is_open()){ error_log("Can't open for writing segment file "+settings.segments_dir+"/"+file_name); error_log("....Check if folder "+settings.segments_dir+" exists and seggetd has permisions to write into it"); return ERROR_WHILE_OPENING_SEGMENT_FOR_WRITING; diff --git a/tuiclient/colors.cpp b/tuiclient/colors.cpp index 939a006..2bfa699 100644 --- a/tuiclient/colors.cpp +++ b/tuiclient/colors.cpp @@ -25,32 +25,33 @@ */ #include "colors.h" +#include "settings.h" void color_distfile_added(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ - wattron(window, COLOR_PAIR(4)); + wattron(window, COLOR_PAIR(1)); } } void color_distfile_waiting(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ - wattron(window, COLOR_PAIR(8)); + wattron(window, COLOR_PAIR(2)); } } void color_distfile_script_rejected(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ - wattron(window, COLOR_PAIR(9)); + wattron(window, COLOR_PAIR(3)); } } void color_distfile_downloading(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ - wattron(window, COLOR_PAIR(6)); + wattron(window, COLOR_PAIR(4)); } } @@ -64,22 +65,22 @@ void color_distfile_downloaded(WINDOW * window){ void color_distfile_failed(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ - wattron(window, COLOR_PAIR(7)); + wattron(window, COLOR_PAIR(6)); } } void color_distfiles_window(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ - wattron(window, COLOR_PAIR(4)); + wattron(window, COLOR_PAIR(7)); } } void color_scroll_window(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ - wbkgd(window, COLOR_PAIR(5)); - wattron(window, COLOR_PAIR(5)); + wbkgd(window, COLOR_PAIR(8)); + wattron(window, COLOR_PAIR(8)); } } @@ -87,7 +88,7 @@ void color_downloads(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ // wbkgd(window, COLOR_PAIR(1)); - wattron(window, COLOR_PAIR(1)); + wattron(window, COLOR_PAIR(9)); } } @@ -95,7 +96,7 @@ void color_info(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ // wbkgd(window, COLOR_PAIR(2)); - wattron(window,COLOR_PAIR(2)); + wattron(window,COLOR_PAIR(10)); } } @@ -103,7 +104,7 @@ void color_status(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ // wbkgd(window, COLOR_PAIR(3)); - wattron(window,COLOR_PAIR(3)); + wattron(window,COLOR_PAIR(11)); } } @@ -111,15 +112,17 @@ void colors_connected(){ if(has_colors()){ start_color(); /* Start color */ init_color(COLOR_BLUE, 300, 300, 300); - init_pair(1, COLOR_WHITE, COLOR_BLUE); - init_pair(2, COLOR_BLACK, COLOR_CYAN); - init_pair(3, COLOR_GREEN, COLOR_BLUE); - init_pair(4, COLOR_WHITE, COLOR_BLACK); - init_pair(5, COLOR_GREEN, COLOR_BLACK); - init_pair(6, COLOR_CYAN, COLOR_BLACK); - init_pair(7, COLOR_RED, COLOR_BLACK); - init_pair(8, COLOR_BLUE, COLOR_BLACK); - init_pair(9, COLOR_YELLOW, COLOR_BLACK); + init_pair(1, settings.color_distfile_added_connected_fg, settings.color_distfile_added_connected_bg); + init_pair(2, settings.color_distfile_waiting_connected_fg, settings.color_distfile_waiting_connected_bg); + init_pair(3, settings.color_distfile_script_rejected_connected_fg, settings.color_distfile_script_rejected_connected_bg); + init_pair(4, settings.color_distfile_downloading_connected_fg, settings.color_distfile_downloading_connected_bg); + init_pair(5, settings.color_distfile_downloaded_connected_fg, settings.color_distfile_downloaded_connected_bg); + init_pair(6, settings.color_distfile_failed_connected_fg, settings.color_distfile_failed_connected_bg); + init_pair(7, settings.color_distfiles_window_connected_fg, settings.color_distfiles_window_connected_bg); + init_pair(8, settings.color_scroll_window_connected_fg, settings.color_scroll_window_connected_bg); + init_pair(9, settings.color_downloads_connected_fg, settings.color_downloads_connected_bg); + init_pair(10, settings.color_info_connected_fg, settings.color_info_connected_bg); + init_pair(11, settings.color_status_connected_fg, settings.color_status_connected_bg); // init_pair(4, COLOR_BLACK, COLOR_WHITE); // attrset(A_REVERSE); attrset(A_DIM); @@ -130,15 +133,17 @@ void colors_disconnected(){ if(has_colors()){ start_color(); /* Start color */ init_color(COLOR_BLUE, 400, 400, 400); - init_pair(1, COLOR_BLACK, COLOR_WHITE); - init_pair(2, COLOR_WHITE, COLOR_BLACK); - init_pair(3, COLOR_BLACK, COLOR_RED); - init_pair(4, COLOR_WHITE, COLOR_BLACK); - init_pair(5, COLOR_WHITE, COLOR_BLACK); - init_pair(6, COLOR_WHITE, COLOR_BLACK); - init_pair(7, COLOR_WHITE, COLOR_BLACK); - init_pair(8, COLOR_WHITE, COLOR_BLACK); - init_pair(9, COLOR_WHITE, COLOR_BLACK); + init_pair(1, settings.color_distfile_added_disconnected_fg, settings.color_distfile_added_disconnected_bg); + init_pair(2, settings.color_distfile_waiting_disconnected_fg, settings.color_distfile_waiting_disconnected_bg); + init_pair(3, settings.color_distfile_script_rejected_disconnected_fg, settings.color_distfile_script_rejected_disconnected_bg); + init_pair(4, settings.color_distfile_downloading_disconnected_fg, settings.color_distfile_downloading_disconnected_bg); + init_pair(5, settings.color_distfile_downloaded_disconnected_fg, settings.color_distfile_downloaded_disconnected_bg); + init_pair(6, settings.color_distfile_failed_disconnected_fg, settings.color_distfile_failed_disconnected_bg); + init_pair(7, settings.color_distfiles_window_disconnected_fg, settings.color_distfiles_window_disconnected_bg); + init_pair(8, settings.color_scroll_window_disconnected_fg, settings.color_scroll_window_disconnected_bg); + init_pair(9, settings.color_downloads_disconnected_fg, settings.color_downloads_disconnected_bg); + init_pair(10, settings.color_info_disconnected_fg, settings.color_info_disconnected_bg); + init_pair(11, settings.color_status_disconnected_fg, settings.color_status_disconnected_bg); /// attrset(A_BOLD); // attrset(A_REVERSE); } diff --git a/tuiclient/config.cpp b/tuiclient/config.cpp index 6c926df..295c207 100644 --- a/tuiclient/config.cpp +++ b/tuiclient/config.cpp @@ -168,6 +168,45 @@ int Tconfig::set(string const& section, string const& entry, bool &dst) const { } } +int Tconfig::set_color(string const& section, string const& entry, int &dst) const { + try{ + map<string,string>::const_iterator ci = content_.find(section + '/' + entry); + if (ci == content_.end()){ + log("! Settings in file:"+config_file_name+" ["+section+"]."+entry+" has not been set."); + log("! Settings in file:"+config_file_name+" ["+section+"]."+entry+"="+colorToString(dst)+". Default value forced."); + return 1; + } + else{ + if (ci->second.find("color_black")!=ci->second.npos){ + dst=COLOR_BLACK; + }else if (ci->second.find("color_red")!=ci->second.npos){ + dst=COLOR_RED; + }else if (ci->second.find("color_green")!=ci->second.npos){ + dst=COLOR_GREEN; + }else if (ci->second.find("color_yellow")!=ci->second.npos){ + dst=COLOR_YELLOW; + }else if (ci->second.find("color_blue")!=ci->second.npos){ + dst=COLOR_BLUE; + }else if (ci->second.find("color_magenta")!=ci->second.npos){ + dst=COLOR_MAGENTA; + }else if (ci->second.find("color_cyan")!=ci->second.npos){ + dst=COLOR_CYAN; + }else if (ci->second.find("color_white")!=ci->second.npos){ + dst=COLOR_WHITE; + }else{ + log("! Settings in file:"+config_file_name+" ["+section+"]."+entry+" has wrong value:"+ci->second); + log("! Settings in file:"+config_file_name+" ["+section+"]."+entry+"="+colorToString(dst)+". Default value forced."); + return 1; + } + log("Settings in file:"+config_file_name+" ["+section+"]."+entry+"="+colorToString(dst)); + return 0; + } + }catch(...){ + error_log("Error in config.cpp: set(string &dst, string const& section, string const& entry)"); + return 1; + } +} + void Tconfig::clear(){ try{ content_.clear(); diff --git a/tuiclient/config.h b/tuiclient/config.h index 1816aa1..866bb0f 100644 --- a/tuiclient/config.h +++ b/tuiclient/config.h @@ -30,6 +30,7 @@ #include <string> #include <map> #include <fstream> +#include <ncurses.h> #include "str.h" //#include "log.h" using namespace std; @@ -47,6 +48,7 @@ class Tconfig { int set(string const& section, string const& entry, string &dst) const; int set(string const& section, string const& entry, ulong &dst, uint const& min_limit, uint const& max_limit) const; int set(string const& section, string const& entry, bool &dst) const; + int set_color(string const& section, string const& entry, int &dst) const; void clear(); }; diff --git a/tuiclient/settings.cpp b/tuiclient/settings.cpp index 5ec2453..07fa20f 100644 --- a/tuiclient/settings.cpp +++ b/tuiclient/settings.cpp @@ -30,12 +30,67 @@ Tsettings settings; void Tsettings::init(){ try{ - Tconfig conf("tuiclient.conf"); + Tconfig conf("/etc/seggetd/tuiclient.conf"); conf.set("logs","general_log_file",general_log_file); conf.set("logs","logs_dir",logs_dir); conf.set("logs","error_log_file",error_log_file); conf.set("logs","debug_log_file",debug_log_file); + conf.set_color("colors","color_distfile_added_connected_fg",color_distfile_added_connected_fg); + conf.set_color("colors","color_distfile_added_connected_bg",color_distfile_added_connected_bg); + conf.set_color("colors","color_distfile_added_disconnected_fg",color_distfile_added_disconnected_fg); + conf.set_color("colors","color_distfile_added_disconnected_bg",color_distfile_added_disconnected_bg); + + conf.set_color("colors","color_distfile_waiting_connected_fg",color_distfile_waiting_connected_fg); + conf.set_color("colors","color_distfile_waiting_connected_bg",color_distfile_waiting_connected_bg); + conf.set_color("colors","color_distfile_waiting_disconnected_fg",color_distfile_waiting_disconnected_fg); + conf.set_color("colors","color_distfile_waiting_disconnected_bg",color_distfile_waiting_disconnected_bg); + + conf.set_color("colors","color_distfile_script_rejected_connected_fg",color_distfile_script_rejected_connected_fg); + conf.set_color("colors","color_distfile_script_rejected_connected_bg",color_distfile_script_rejected_connected_bg); + conf.set_color("colors","color_distfile_script_rejected_disconnected_fg",color_distfile_script_rejected_disconnected_fg); + conf.set_color("colors","color_distfile_script_rejected_disconnected_bg",color_distfile_script_rejected_disconnected_bg); + + conf.set_color("colors","color_distfile_downloading_connected_fg",color_distfile_downloading_connected_fg); + conf.set_color("colors","color_distfile_downloading_connected_bg",color_distfile_downloading_connected_bg); + conf.set_color("colors","color_distfile_downloading_disconnected_fg",color_distfile_downloading_disconnected_fg); + conf.set_color("colors","color_distfile_downloading_disconnected_bg",color_distfile_downloading_disconnected_bg); + + conf.set_color("colors","color_distfile_downloaded_connected_fg",color_distfile_downloaded_connected_fg); + conf.set_color("colors","color_distfile_downloaded_connected_bg",color_distfile_downloaded_connected_bg); + conf.set_color("colors","color_distfile_downloaded_disconnected_fg",color_distfile_downloaded_disconnected_fg); + conf.set_color("colors","color_distfile_downloaded_disconnected_bg",color_distfile_downloaded_disconnected_bg); + + conf.set_color("colors","color_distfile_failed_connected_fg",color_distfile_failed_connected_fg); + conf.set_color("colors","color_distfile_failed_connected_bg",color_distfile_failed_connected_bg); + conf.set_color("colors","color_distfile_failed_disconnected_fg",color_distfile_failed_disconnected_fg); + conf.set_color("colors","color_distfile_failed_disconnected_bg",color_distfile_failed_disconnected_bg); + + conf.set_color("colors","color_distfiles_window_connected_fg",color_distfiles_window_connected_fg); + conf.set_color("colors","color_distfiles_window_connected_bg",color_distfiles_window_connected_bg); + conf.set_color("colors","color_distfiles_window_disconnected_fg",color_distfiles_window_disconnected_fg); + conf.set_color("colors","color_distfiles_window_disconnected_bg",color_distfiles_window_disconnected_bg); + + conf.set_color("colors","color_scroll_window_connected_fg",color_scroll_window_connected_fg); + conf.set_color("colors","color_scroll_window_connected_bg",color_scroll_window_connected_bg); + conf.set_color("colors","color_scroll_window_disconnected_fg",color_scroll_window_disconnected_fg); + conf.set_color("colors","color_scroll_window_disconnected_bg",color_scroll_window_disconnected_bg); + + conf.set_color("colors","color_downloads_connected_fg",color_downloads_connected_fg); + conf.set_color("colors","color_downloads_connected_bg",color_downloads_connected_bg); + conf.set_color("colors","color_downloads_disconnected_fg",color_downloads_disconnected_fg); + conf.set_color("colors","color_downloads_disconnected_bg",color_downloads_disconnected_bg); + + conf.set_color("colors","color_info_connected_fg",color_info_connected_fg); + conf.set_color("colors","color_info_connected_bg",color_info_connected_bg); + conf.set_color("colors","color_info_disconnected_fg",color_info_disconnected_fg); + conf.set_color("colors","color_info_disconnected_bg",color_info_disconnected_bg); + + conf.set_color("colors","color_status_connected_fg",color_status_connected_fg); + conf.set_color("colors","color_status_connected_bg",color_status_connected_bg); + conf.set_color("colors","color_status_disconnected_fg",color_status_disconnected_fg); + conf.set_color("colors","color_status_disconnected_bg",color_status_disconnected_bg); + conf.set("ui_server","ui_ip",ui_ip); conf.set("ui_server","ui_port",ui_port,1,65535); diff --git a/tuiclient/settings.h b/tuiclient/settings.h index 8395156..4d05f65 100644 --- a/tuiclient/settings.h +++ b/tuiclient/settings.h @@ -29,6 +29,7 @@ #include <string> #include "config.h" + //#include "tui.cpp" using namespace std; @@ -42,6 +43,61 @@ class Tsettings{ //ui_server string ui_ip; ulong ui_port; + //colors + int color_distfile_added_connected_fg; + int color_distfile_added_connected_bg; + int color_distfile_added_disconnected_fg; + int color_distfile_added_disconnected_bg; + + int color_distfile_waiting_connected_fg; + int color_distfile_waiting_connected_bg; + int color_distfile_waiting_disconnected_fg; + int color_distfile_waiting_disconnected_bg; + + int color_distfile_script_rejected_connected_fg; + int color_distfile_script_rejected_connected_bg; + int color_distfile_script_rejected_disconnected_fg; + int color_distfile_script_rejected_disconnected_bg; + + int color_distfile_downloading_connected_fg; + int color_distfile_downloading_connected_bg; + int color_distfile_downloading_disconnected_fg; + int color_distfile_downloading_disconnected_bg; + + int color_distfile_downloaded_connected_fg; + int color_distfile_downloaded_connected_bg; + int color_distfile_downloaded_disconnected_fg; + int color_distfile_downloaded_disconnected_bg; + + int color_distfile_failed_connected_fg; + int color_distfile_failed_connected_bg; + int color_distfile_failed_disconnected_fg; + int color_distfile_failed_disconnected_bg; + + int color_distfiles_window_connected_fg; + int color_distfiles_window_connected_bg; + int color_distfiles_window_disconnected_fg; + int color_distfiles_window_disconnected_bg; + + int color_scroll_window_connected_fg; + int color_scroll_window_connected_bg; + int color_scroll_window_disconnected_fg; + int color_scroll_window_disconnected_bg; + + int color_downloads_connected_fg; + int color_downloads_connected_bg; + int color_downloads_disconnected_fg; + int color_downloads_disconnected_bg; + + int color_info_connected_fg; + int color_info_connected_bg; + int color_info_disconnected_fg; + int color_info_disconnected_bg; + + int color_status_connected_fg; + int color_status_connected_bg; + int color_status_disconnected_fg; + int color_status_disconnected_bg; //logs string logs_dir; string general_log_file; @@ -55,6 +111,62 @@ class Tsettings{ //ui_server ui_ip("127.0.0.1"), ui_port(9999), + //colors + color_distfile_added_connected_fg(COLOR_WHITE), + color_distfile_added_connected_bg(COLOR_BLACK), + color_distfile_added_disconnected_fg(COLOR_WHITE), + color_distfile_added_disconnected_bg(COLOR_BLACK), + + color_distfile_waiting_connected_fg(COLOR_BLUE), + color_distfile_waiting_connected_bg(COLOR_BLACK), + color_distfile_waiting_disconnected_fg(COLOR_WHITE), + color_distfile_waiting_disconnected_bg(COLOR_BLACK), + + color_distfile_script_rejected_connected_fg(COLOR_YELLOW), + color_distfile_script_rejected_connected_bg(COLOR_BLACK), + color_distfile_script_rejected_disconnected_fg(COLOR_WHITE), + color_distfile_script_rejected_disconnected_bg(COLOR_BLACK), + + color_distfile_downloading_connected_fg(COLOR_CYAN), + color_distfile_downloading_connected_bg(COLOR_BLACK), + color_distfile_downloading_disconnected_fg(COLOR_WHITE), + color_distfile_downloading_disconnected_bg(COLOR_BLACK), + + color_distfile_downloaded_connected_fg(COLOR_GREEN), + color_distfile_downloaded_connected_bg(COLOR_BLACK), + color_distfile_downloaded_disconnected_fg(COLOR_WHITE), + color_distfile_downloaded_disconnected_bg(COLOR_BLACK), + + color_distfile_failed_connected_fg(COLOR_RED), + color_distfile_failed_connected_bg(COLOR_BLACK), + color_distfile_failed_disconnected_fg(COLOR_WHITE), + color_distfile_failed_disconnected_bg(COLOR_BLACK), + + color_distfiles_window_connected_fg(COLOR_WHITE), + color_distfiles_window_connected_bg(COLOR_BLACK), + color_distfiles_window_disconnected_fg(COLOR_WHITE), + color_distfiles_window_disconnected_bg(COLOR_BLACK), + + color_scroll_window_connected_fg(COLOR_GREEN), + color_scroll_window_connected_bg(COLOR_BLACK), + color_scroll_window_disconnected_fg(COLOR_WHITE), + color_scroll_window_disconnected_bg(COLOR_BLACK), + + color_downloads_connected_fg(COLOR_WHITE), + color_downloads_connected_bg(COLOR_BLACK), + color_downloads_disconnected_fg(COLOR_BLACK), + color_downloads_disconnected_bg(COLOR_WHITE), + + color_info_connected_fg(COLOR_BLACK), + color_info_connected_bg(COLOR_CYAN), + color_info_disconnected_fg(COLOR_WHITE), + color_info_disconnected_bg(COLOR_BLACK), + + color_status_connected_fg(COLOR_GREEN), + color_status_connected_bg(COLOR_BLACK), + color_status_disconnected_fg(COLOR_BLACK), + color_status_disconnected_bg(COLOR_RED), + //logs logs_dir("./logs"), general_log_file("tuiclient.log"), diff --git a/tuiclient/str.cpp b/tuiclient/str.cpp index 0436778..351b2e5 100644 --- a/tuiclient/str.cpp +++ b/tuiclient/str.cpp @@ -25,6 +25,8 @@ */ #include "str.h" +#include <ncurses.h> + using namespace std; int atoi(string num_str){ @@ -64,6 +66,20 @@ template<typename T> string toString(T t){ } */ +string colorToString(uint a_color){ + switch (a_color){ + case COLOR_BLACK: return "COLOR_BLACK"; + case COLOR_RED: return "COLOR_RED"; + case COLOR_GREEN: return "COLOR_GREEN"; + case COLOR_YELLOW: return "COLOR_YELLOW"; + case COLOR_BLUE: return "COLOR_BLUE"; + case COLOR_MAGENTA: return "COLOR_MAGENTA"; + case COLOR_CYAN: return "COLOR_CYAN"; + case COLOR_WHITE: return "COLOR_WHITE"; + default: return "UNKNOWN COLOR"; + } +} + string toString(uint t){ stringstream s; s << t; diff --git a/tuiclient/str.h b/tuiclient/str.h index d0e16a9..cb539ce 100644 --- a/tuiclient/str.h +++ b/tuiclient/str.h @@ -47,6 +47,8 @@ int atoi(string num_str); long atol(string num_str); //template<typename T> string toString(T t); +string colorToString(uint a_color); + string toString(uint t); string toString(int t); string toString(ulong t); diff --git a/tuiclient/tuiclient.conf b/tuiclient/tuiclient.conf index 8add865..81e3480 100644 --- a/tuiclient/tuiclient.conf +++ b/tuiclient/tuiclient.conf @@ -18,6 +18,66 @@ ui_ip=127.0.0.1 # ui_port=9999 ui_port=9999 +[colors] +# Define color scheme for tuiclient. +# Avaible colors are: +# COLOR_BLACK +# COLOR_RED +# COLOR_GREEN +# COLOR_YELLOW +# COLOR_BLUE +# COLOR_MAGENTA +# COLOR_CYAN +# COLOR_WHITE +# Defaults: +# when tuiclient connected to seggetd +color_distfile_added_connected_fg=COLOR_WHITE +color_distfile_added_connected_bg=COLOR_BLACK +color_distfile_waiting_connected_fg=COLOR_BLUE +color_distfile_waiting_connected_bg=COLOR_BLACK +color_distfile_script_rejected_connected_fg=COLOR_YELLOW +color_distfile_script_rejected_connected_bg=COLOR_BLACK +color_distfile_downloading_connected_fg=COLOR_CYAN +color_distfile_downloading_connected_bg=COLOR_BLACK +color_distfile_downloaded_connected_fg=COLOR_GREEN +color_distfile_downloaded_connected_bg=COLOR_BLACK +color_distfile_failed_connected_fg=COLOR_RED +color_distfile_failed_connected_bg=COLOR_BLACK +color_distfiles_window_connected_fg=COLOR_WHITE +color_distfiles_window_connected_bg=COLOR_BLACK +color_scroll_window_connected_fg=COLOR_GREEN +color_scroll_window_connected_bg=COLOR_BLACK +color_downloads_connected_fg=COLOR_WHITE +color_downloads_connected_bg=COLOR_BLACK +color_info_connected_fg=COLOR_BLACK +color_info_connected_bg=COLOR_CYAN +color_status_connected_fg=COLOR_GREEN +color_status_connected_bg=COLOR_BLACK + +# when tuiclient disconnected from seggetd +color_distfile_added_disconnected_fg=COLOR_WHITE +color_distfile_added_disconnected_bg=COLOR_BLACK +color_distfile_waiting_disconnected_fg=COLOR_WHITE +color_distfile_waiting_disconnected_bg=COLOR_BLACK +color_distfile_script_rejected_disconnected_fg=COLOR_WHITE +color_distfile_script_rejected_disconnected_bg=COLOR_BLACK +color_distfile_downloading_disconnected_fg=COLOR_WHITE +color_distfile_downloading_disconnected_bg=COLOR_BLACK +color_distfile_downloaded_disconnected_fg=COLOR_WHITE +color_distfile_downloaded_disconnected_bg=COLOR_BLACK +color_distfile_failed_disconnected_fg=COLOR_WHITE +color_distfile_failed_disconnected_bg=COLOR_BLACK +color_distfiles_window_disconnected_fg=COLOR_WHITE +color_distfiles_window_disconnected_bg=COLOR_BLACK +color_scroll_window_disconnected_fg=COLOR_WHITE +color_scroll_window_disconnected_bg=COLOR_BLACK +color_downloads_disconnected_fg=COLOR_BLACK +color_downloads_disconnected_bg=COLOR_WHITE +color_info_disconnected_fg=COLOR_WHITE +color_info_disconnected_bg=COLOR_BLACK +color_status_disconnected_fg=COLOR_BLACK +color_status_disconnected_bg=COLOR_RED + [logs] # LOGS_DIR # Define a dir to store log files. diff --git a/tuiclient/tuiclient.cpp b/tuiclient/tuiclient.cpp index 7331321..838f702 100644 --- a/tuiclient/tuiclient.cpp +++ b/tuiclient/tuiclient.cpp @@ -148,7 +148,7 @@ void * watch_keyboard_thread_function(void *){ case 'L':mainwindow.log_win.toggle(); mainwindow.show();break; case 'e': case 'E':mainwindow.error_log_win.toggle(); mainwindow.show();break; - default: mainwindow.set_line(25,toString((int)key)); +// default: mainwindow.set_line(25,toString((int)key)); } } // pthread_exit((void*)watch_keyboard_thread_status); |