[Lcdproc] curses driver. configurable border.
bruno schwander
bruno.schwander@gmail.com
Sun Oct 7 07:58:01 2007
Hi,
The border drawn by the curses driver is a waste of space for very
small terminals, like the 4x40 lcd terminal I have. Here is a diff to
allow choosing wether the border is drawn or not by specifying
# draw Border [default: yes]
DrawBorder=no
in the [curses] driver section.
I hope this will be deemed useful and be folded in lcdproc.
Thanks
Bruno
*** curses_drv.c.bak Sat Oct 6 23:25:38 2007
--- curses_drv.c Sun Oct 7 00:53:09 2007
***************
*** 125,132 ****
--- 125,134 ----
int xoffs;
int yoffs;
int useACS;
+
+ int drawBorder;
} PrivateData;
// Vars for the server core
***************
*** 213,220 ****
--- 215,223 ----
p->xoffs = CONF_DEF_TOP_LEFT_X,
p->yoffs = CONF_DEF_TOP_LEFT_Y;
p->cellwidth = LCD_DEFAULT_CELLWIDTH;
p->cellheight = LCD_DEFAULT_CELLHEIGHT;
+ p->drawBorder = 1;
/* Get settings from config file */
***************
*** 241,248 ****
--- 244,255 ----
/* use ACS characters? */
p->useACS = drvthis->config_get_bool(drvthis->name, "UseACS", 0, 0);
debug(RPT_DEBUG, "%s: using ACS %s", drvthis->name, (p->useACS) ?
"ON" : "OFF");
+ /* draw border ? */
+ p->drawBorder = drvthis->config_get_bool(drvthis->name, "DrawBorder", 0, 1);
+ debug(RPT_DEBUG, "%s: drawing Border %s", drvthis->name,
(p->drawBorder) ? "ON" : "OFF");
+
/* Get size settings */
if ((drvthis->request_display_width() > 0)
&& (drvthis->request_display_height() > 0)) {
/* If this driver is secondary driver, use size from primary driver */
***************
*** 290,301 ****
nodelay(stdscr, TRUE);
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
! p->win = newwin(p->height + 2, /* +2 for the border */
! p->width + 2, /* +2 for the border */
! p->yoffs,
! p->xoffs);
//nodelay(p->win, TRUE);
//intrflush(p->win, FALSE);
//keypad(p->win, TRUE);
--- 297,315 ----
nodelay(stdscr, TRUE);
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
! if(p->drawBorder){
! p->win = newwin(p->height + 2, /* +2 for the border */
! p->width + 2, /* +2 for the border */
! p->yoffs,
! p->xoffs);
! }else{
! p->win = newwin(p->height,
! p->width,
! p->yoffs,
! p->xoffs);
! }
//nodelay(p->win, TRUE);
//intrflush(p->win, FALSE);
//keypad(p->win, TRUE);
***************
*** 395,403 ****
{
PrivateData *p = drvthis->private_data;
wbkgdset(p->win, COLOR_PAIR(p->current_color_pair) | ' ');
! curses_wborder(drvthis);
werase(p->win);
}
MODULE_EXPORT void
--- 409,420 ----
{
PrivateData *p = drvthis->private_data;
wbkgdset(p->win, COLOR_PAIR(p->current_color_pair) | ' ');
!
! if(p->drawBorder)
! curses_wborder(drvthis);
!
werase(p->win);
}
MODULE_EXPORT void
***************
*** 436,443 ****
--- 453,464 ----
if ((x <= 0) || (y <= 0) || (x > p->width) || (y > p->height))
return;
+ if(!p->drawBorder){
+ x--; y--;
+ }
+
mvwaddstr(p->win, y, x, string);
}
/////////////////////////////////////////////////////////////////
***************
*** 451,459 ****
if ((x <= 0) || (y <= 0) || (x > p->width) || (y > p->height))
return;
! mvwaddch(p->win, y, x, c);
}
/////////////////////////////////////////////////////////////////
// Draws a vertical bar; erases entire column onscreen.
--- 472,485 ----
if ((x <= 0) || (y <= 0) || (x > p->width) || (y > p->height))
return;
! if(!p->drawBorder){
! x--; y--;
! }
!
! mvwaddch(p->win, y, x, c);
!
}
/////////////////////////////////////////////////////////////////
// Draws a vertical bar; erases entire column onscreen.
***************
*** 479,486 ****
--- 505,517 ----
* len is the number of characters that the bar is long at 100%
* promille is the number of promilles (0..1000) that the bar
should be filled.
*/
+ if(!p->drawBorder){
+ x--; y--;
+ }
+
+
for (pos = 0; pos < len; pos++) {
if (y - pos <= 0)
return;
***************
*** 521,528 ****
--- 552,563 ----
* len is the number of characters that the bar is long at 100%
* promille is the number of promilles (0..1000) that the bar
should be filled.
*/
+ if(!p->drawBorder){
+ x--; y--;
+ }
+
for (pos = 0; pos < len; pos++) {
if (x + pos > p->width)
return;
***************
*** 600,608 ****
curses_restore_screen(drvthis);
ungetch(c);
}
! curses_wborder(drvthis);
wrefresh(p->win);
}
--- 635,645 ----
curses_restore_screen(drvthis);
ungetch(c);
}
! if(p->drawBorder)
! curses_wborder(drvthis);
!
wrefresh(p->win);
}