harmonize coding style and messages
This commit is contained in:
+41
-30
@@ -175,8 +175,8 @@ set_background_color (char * buf) {
|
||||
#define TOP_LEFT_X 7
|
||||
#define TOP_LEFT_Y 7
|
||||
|
||||
#define ValidX(x) { if ((x) > width || (x) < 1) { report(RPT_ERR, "curses_drv: Invalid X"); return; } }
|
||||
#define ValidY(y) { if ((y) > height || (y) < 1) { report(RPT_ERR, "curses_drv: Invalid Y"); return; } }
|
||||
#define ValidX(x) { if ((x) > width || (x) < 1) { report(RPT_ERR, "%s: Invalid X", drvthis->name); return; } }
|
||||
#define ValidY(y) { if ((y) > height || (y) < 1) { report(RPT_ERR, "%s: Invalid Y", drvthis->name); return; } }
|
||||
|
||||
static int current_color_pair, current_border_pair, curses_backlight_state = 0;
|
||||
static int width, height;
|
||||
@@ -193,6 +193,7 @@ MODULE_EXPORT int
|
||||
curses_drv_init (Driver *drvthis)
|
||||
{
|
||||
char buf[256];
|
||||
int tmp;
|
||||
|
||||
// Colors....
|
||||
chtype back_color = DEFAULT_BACKGROUND_COLOR,
|
||||
@@ -206,56 +207,64 @@ curses_drv_init (Driver *drvthis)
|
||||
/*Get settings from config file*/
|
||||
|
||||
/*Get color settings*/
|
||||
|
||||
/*foreground color*/
|
||||
strncpy(buf, drvthis->config_get_string ( drvthis->name , "foreground" , 0 , CONF_DEF_FOREGR),sizeof(buf));
|
||||
buf[sizeof(buf)-1]=0;
|
||||
strncpy(buf, drvthis->config_get_string(drvthis->name, "Foreground", 0, CONF_DEF_FOREGR), sizeof(buf));
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
fore_color = set_foreground_color(buf);
|
||||
debug( RPT_DEBUG, "CURSES: using foreground color: %s", buf);
|
||||
debug(RPT_DEBUG, "%s: using foreground color %s", drvthis->name, buf);
|
||||
|
||||
/*background color*/
|
||||
strncpy(buf, drvthis->config_get_string ( drvthis->name , "background" , 0 , CONF_DEF_BACKGR),sizeof(buf));
|
||||
buf[sizeof(buf)-1]=0;
|
||||
strncpy(buf, drvthis->config_get_string(drvthis->name, "Background", 0, CONF_DEF_BACKGR), sizeof(buf));
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
back_color = set_background_color(buf);
|
||||
debug( RPT_DEBUG, "CURSES: using background color: %s", buf);
|
||||
debug(RPT_DEBUG, "%s: using background color %s", drvthis->name, buf);
|
||||
|
||||
/*backlight color*/
|
||||
strncpy(buf, drvthis->config_get_string ( drvthis->name , "backlight" , 0 , CONF_DEF_BACKLIGHT), sizeof(buf));
|
||||
buf[sizeof(buf)-1]=0;
|
||||
strncpy(buf, drvthis->config_get_string(drvthis->name, "Backlight", 0, CONF_DEF_BACKLIGHT), sizeof(buf));
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
backlight_color = set_background_color(buf);
|
||||
debug( RPT_DEBUG, "CURSES: using backlight color: %s", buf);
|
||||
debug(RPT_DEBUG, "%s: using backlight color %s", drvthis->name, buf);
|
||||
|
||||
//TODO: Make it possible to configure the backlight's "off" color and its "on" color
|
||||
// Or maybe don't do so? - Rene Wagner
|
||||
|
||||
/* Get size settings */
|
||||
if( drvthis->request_display_width() > 0
|
||||
&& drvthis->request_display_height() > 0 ) {
|
||||
/* If this driver is secondairy driver, use size from primary driver */
|
||||
if ((drvthis->request_display_width() > 0)
|
||||
&& (drvthis->request_display_height() > 0)) {
|
||||
/* If this driver is secondary driver, use size from primary driver */
|
||||
width = drvthis->request_display_width();
|
||||
height = drvthis->request_display_height();
|
||||
}
|
||||
else {
|
||||
/* Use our own size from config file */
|
||||
strncpy(buf, drvthis->config_get_string ( drvthis->name , "size" , 0 , CONF_DEF_SIZE), sizeof(buf));
|
||||
buf[sizeof(buf)-1]=0;
|
||||
if( sscanf(buf , "%dx%d", &width, &height ) != 2
|
||||
|| (width <= 0)
|
||||
|| (height <= 0)) {
|
||||
report (RPT_WARNING, "CURSES: Cannot read size: %s. Using default value: %s\n", buf, CONF_DEF_SIZE);
|
||||
strncpy(buf, drvthis->config_get_string(drvthis->name, "Size", 0, CONF_DEF_SIZE), sizeof(buf));
|
||||
buf[sizeof(buf)-1] = '\0';
|
||||
if ((sscanf(buf , "%dx%d", &width, &height) != 2)
|
||||
|| (width <= 0) || (width > LCD_MAX_WIDTH)
|
||||
|| (height <= 0) || (height > LCD_MAX_HEIGHT)) {
|
||||
report(RPT_WARNING, "%s: cannot read Size: %s; using default %s",
|
||||
drvthis->name, buf, CONF_DEF_SIZE);
|
||||
sscanf(CONF_DEF_SIZE, "%dx%d", &width, &height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*Get position settings*/
|
||||
if (0<=drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) && drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X) <= 255) {
|
||||
screen_begx = drvthis->config_get_int ( drvthis->name , "topleftx" , 0 , CONF_DEF_TOP_LEFT_X);
|
||||
} else {
|
||||
report (RPT_WARNING, "CURSES: topleftx must be between 0 and 255. Using default value %d.\n",CONF_DEF_TOP_LEFT_X);
|
||||
tmp = drvthis->config_get_int(drvthis->name, "TopLeftX", 0, CONF_DEF_TOP_LEFT_X);
|
||||
if ((tmp < 0) || (tmp > 255)) {
|
||||
report(RPT_WARNING, "%s: TopLeftX must be between 0 and 255; using default %d",
|
||||
drvthis->name, CONF_DEF_TOP_LEFT_X);
|
||||
tmp = CONF_DEF_TOP_LEFT_X;
|
||||
}
|
||||
if (0<=drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) && drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y) <= 255) {
|
||||
screen_begy = drvthis->config_get_int ( drvthis->name , "toplefty" , 0 , CONF_DEF_TOP_LEFT_Y);
|
||||
} else {
|
||||
report (RPT_WARNING, "CURSES: toplefty must be between 0 and 255. Using default value %d.\n",CONF_DEF_TOP_LEFT_Y);
|
||||
screen_begx = tmp;
|
||||
|
||||
tmp = drvthis->config_get_int(drvthis->name, "TopLeftY", 0, CONF_DEF_TOP_LEFT_Y);
|
||||
if ((tmp < 0) || (tmp > 255)) {
|
||||
report(RPT_WARNING, "%s: TopLeftY must be between 0 and 255; using default %d",
|
||||
drvthis->name, CONF_DEF_TOP_LEFT_Y);
|
||||
tmp = CONF_DEF_TOP_LEFT_Y;
|
||||
}
|
||||
screen_begy = tmp;
|
||||
|
||||
//debug: sleep(1);
|
||||
|
||||
@@ -297,6 +306,8 @@ curses_drv_init (Driver *drvthis)
|
||||
// Change the character used for "..."
|
||||
ELLIPSIS = '~';
|
||||
|
||||
report(RPT_DEBUG, "%s: init() done", drvthis->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -613,7 +624,7 @@ curses_drv_get_key (Driver *drvthis)
|
||||
case 0x1B:
|
||||
return "Escape";
|
||||
default:
|
||||
report( RPT_INFO, "curses_drv: Unknown key 0x%4x", key );
|
||||
report(RPT_INFO, "%s: Unknown key 0x%02X", drvthis->name, key);
|
||||
ret_val[0] = (char) key & 0xFF;
|
||||
return (ret_val[0] != '\0') ? ret_val : NULL;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user