Work on sidebar width user-customization.
This commit is contained in:
parent
a8cb1c92ef
commit
ec36b96848
@ -1,6 +1,15 @@
|
|||||||
2010-03-20 Frederic Culot <frederic@culot.org>
|
2010-03-20 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
* src/calcurse.h: new header to gather all existing ones
|
* src/calcurse.h: new header to gather all existing ones
|
||||||
|
|
||||||
|
* src/calcurse.c
|
||||||
|
* src/calendar.c
|
||||||
|
* src/wins.c
|
||||||
|
* src/custom.c (custom_sidebar_config): sidebar configuration
|
||||||
|
added, allowing to change sidebar's width
|
||||||
|
|
||||||
|
* src/wins.c (wins_update_border, wins_update_panels): new
|
||||||
|
functions extracted from wins_update()
|
||||||
|
|
||||||
2010-03-19 Frederic Culot <frederic@culot.org>
|
2010-03-19 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: calcurse.c,v 1.87 2010/03/20 10:54:42 culot Exp $ */
|
/* $calcurse: calcurse.c,v 1.88 2010/03/20 13:29:47 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -279,6 +279,10 @@ main (int argc, char **argv)
|
|||||||
case 'k':
|
case 'k':
|
||||||
custom_keys_config ();
|
custom_keys_config ();
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
case 'S':
|
||||||
|
custom_sidebar_config ();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
wins_reset ();
|
wins_reset ();
|
||||||
wins_update ();
|
wins_update ();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: calcurse.h,v 1.1 2010/03/20 10:54:42 culot Exp $ */
|
/* $Id: calcurse.h,v 1.2 2010/03/20 13:29:47 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -144,7 +144,6 @@
|
|||||||
|
|
||||||
/* Calendar window. */
|
/* Calendar window. */
|
||||||
#define CALHEIGHT 12
|
#define CALHEIGHT 12
|
||||||
#define CALWIDTH 30
|
|
||||||
|
|
||||||
/* Key definitions. */
|
/* Key definitions. */
|
||||||
#define CTRLVAL 0x1F
|
#define CTRLVAL 0x1F
|
||||||
@ -637,6 +636,7 @@ void custom_remove_attr (WINDOW *, int);
|
|||||||
void custom_load_conf (struct conf *, int);
|
void custom_load_conf (struct conf *, int);
|
||||||
void custom_config_bar (void);
|
void custom_config_bar (void);
|
||||||
void custom_layout_config (void);
|
void custom_layout_config (void);
|
||||||
|
void custom_sidebar_config (void);
|
||||||
void custom_color_config (void);
|
void custom_color_config (void);
|
||||||
void custom_color_theme_name (char *);
|
void custom_color_theme_name (char *);
|
||||||
void custom_confwin_init (struct window *, char *);
|
void custom_confwin_init (struct window *, char *);
|
||||||
@ -893,6 +893,7 @@ void vars_init (struct conf *);
|
|||||||
|
|
||||||
/* wins.c */
|
/* wins.c */
|
||||||
extern struct window win[NBWINS];
|
extern struct window win[NBWINS];
|
||||||
|
extern unsigned sbarwidth;
|
||||||
int wins_layout (void);
|
int wins_layout (void);
|
||||||
void wins_set_layout (int);
|
void wins_set_layout (int);
|
||||||
void wins_slctd_init (void);
|
void wins_slctd_init (void);
|
||||||
@ -908,6 +909,8 @@ void wins_scrollwin_down (struct scrollwin *, int);
|
|||||||
void wins_reinit (void);
|
void wins_reinit (void);
|
||||||
void wins_show (WINDOW *, char *);
|
void wins_show (WINDOW *, char *);
|
||||||
void wins_get_config (void);
|
void wins_get_config (void);
|
||||||
|
void wins_update_border (void);
|
||||||
|
void wins_update_panels (void);
|
||||||
void wins_update (void);
|
void wins_update (void);
|
||||||
void wins_reset (void);
|
void wins_reset (void);
|
||||||
void wins_launch_external (const char *, const char *);
|
void wins_launch_external (const char *, const char *);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: calendar.c,v 1.33 2010/03/20 10:54:43 culot Exp $ */
|
/* $calcurse: calendar.c,v 1.34 2010/03/20 13:29:48 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -302,8 +302,11 @@ date_change (struct tm *date, int delta_month, int delta_day)
|
|||||||
|
|
||||||
/* Draw the monthly view inside calendar panel. */
|
/* Draw the monthly view inside calendar panel. */
|
||||||
static void
|
static void
|
||||||
draw_monthly_view (struct window *cwin, struct date *current_day, unsigned sunday_first)
|
draw_monthly_view (struct window *cwin, struct date *current_day,
|
||||||
|
unsigned sunday_first)
|
||||||
{
|
{
|
||||||
|
const int OFFY = 2 + (CALHEIGHT - 9) / 2;
|
||||||
|
const int OFFX = (sbarwidth - 27) / 2;
|
||||||
struct date check_day;
|
struct date check_day;
|
||||||
int c_day, c_day_1, day_1_sav, numdays, j;
|
int c_day, c_day_1, day_1_sav, numdays, j;
|
||||||
unsigned yr, mo;
|
unsigned yr, mo;
|
||||||
@ -314,8 +317,8 @@ draw_monthly_view (struct window *cwin, struct date *current_day, unsigned sunda
|
|||||||
yr = slctd_day.yyyy;
|
yr = slctd_day.yyyy;
|
||||||
|
|
||||||
/* offset for centering calendar in window */
|
/* offset for centering calendar in window */
|
||||||
ofs_y = 2 + (CALHEIGHT - 9) / 2;
|
ofs_y = OFFY;
|
||||||
ofs_x = (CALWIDTH - 27) / 2;
|
ofs_x = OFFX;
|
||||||
|
|
||||||
/* checking the number of days in february */
|
/* checking the number of days in february */
|
||||||
numdays = days[mo - 1];
|
numdays = days[mo - 1];
|
||||||
@ -330,7 +333,8 @@ draw_monthly_view (struct window *cwin, struct date *current_day, unsigned sunda
|
|||||||
|
|
||||||
/* Write the current month and year on top of the calendar */
|
/* Write the current month and year on top of the calendar */
|
||||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||||
mvwprintw (cwin->p, ofs_y, (CALWIDTH - (strlen (_(monthnames[mo - 1])) + 5)) / 2,
|
mvwprintw (cwin->p, ofs_y,
|
||||||
|
(sbarwidth - (strlen (_(monthnames[mo - 1])) + 5)) / 2,
|
||||||
"%s %d", _(monthnames[mo - 1]), slctd_day.yyyy);
|
"%s %d", _(monthnames[mo - 1]), slctd_day.yyyy);
|
||||||
custom_remove_attr (cwin->p, ATTR_HIGHEST);
|
custom_remove_attr (cwin->p, ATTR_HIGHEST);
|
||||||
++ofs_y;
|
++ofs_y;
|
||||||
@ -358,8 +362,8 @@ draw_monthly_view (struct window *cwin, struct date *current_day, unsigned sunda
|
|||||||
/* Go to next line, the week is over. */
|
/* Go to next line, the week is over. */
|
||||||
if (!c_day_1 && 1 != c_day)
|
if (!c_day_1 && 1 != c_day)
|
||||||
{
|
{
|
||||||
++ofs_y;
|
ofs_y++;
|
||||||
ofs_x = 2 - day_1_sav - 4 * c_day - 1;
|
ofs_x = OFFX - day_1_sav - 4 * c_day;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is today, so print it in yellow. */
|
/* This is today, so print it in yellow. */
|
||||||
@ -369,28 +373,31 @@ draw_monthly_view (struct window *cwin, struct date *current_day, unsigned sunda
|
|||||||
&& current_day->dd != slctd_day.dd)
|
&& current_day->dd != slctd_day.dd)
|
||||||
{
|
{
|
||||||
custom_apply_attr (cwin->p, ATTR_LOWEST);
|
custom_apply_attr (cwin->p, ATTR_LOWEST);
|
||||||
mvwprintw (cwin->p, ofs_y + 1,
|
mvwprintw (cwin->p, ofs_y + 1,
|
||||||
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
ofs_x + day_1_sav + 4 * c_day + 1, "%2d", c_day);
|
||||||
custom_remove_attr (cwin->p, ATTR_LOWEST);
|
custom_remove_attr (cwin->p, ATTR_LOWEST);
|
||||||
}
|
}
|
||||||
else if (c_day == slctd_day.dd)
|
else if (c_day == slctd_day.dd)
|
||||||
{
|
{
|
||||||
/* This is the selected day, print it according to user's theme. */
|
/* This is the selected day, print it according to user's theme. */
|
||||||
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
custom_apply_attr (cwin->p, ATTR_HIGHEST);
|
||||||
mvwprintw (cwin->p, ofs_y + 1, ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
mvwprintw (cwin->p, ofs_y + 1,
|
||||||
|
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||||
c_day);
|
c_day);
|
||||||
custom_remove_attr (cwin->p, ATTR_HIGHEST);
|
custom_remove_attr (cwin->p, ATTR_HIGHEST);
|
||||||
}
|
}
|
||||||
else if (item_this_day)
|
else if (item_this_day)
|
||||||
{
|
{
|
||||||
custom_apply_attr (cwin->p, ATTR_LOW);
|
custom_apply_attr (cwin->p, ATTR_LOW);
|
||||||
mvwprintw (cwin->p, ofs_y + 1, ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
mvwprintw (cwin->p, ofs_y + 1,
|
||||||
|
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||||
c_day);
|
c_day);
|
||||||
custom_remove_attr (cwin->p, ATTR_LOW);
|
custom_remove_attr (cwin->p, ATTR_LOW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
/* otherwise, print normal days in black */
|
/* otherwise, print normal days in black */
|
||||||
mvwprintw (cwin->p, ofs_y + 1, ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
mvwprintw (cwin->p, ofs_y + 1,
|
||||||
|
ofs_x + day_1_sav + 4 * c_day + 1, "%2d",
|
||||||
c_day);
|
c_day);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
78
src/custom.c
78
src/custom.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: custom.c,v 1.46 2010/03/20 10:54:43 culot Exp $ */
|
/* $calcurse: custom.c,v 1.47 2010/03/20 13:29:48 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -402,26 +402,26 @@ custom_load_conf (struct conf *conf, int background)
|
|||||||
void
|
void
|
||||||
custom_config_bar (void)
|
custom_config_bar (void)
|
||||||
{
|
{
|
||||||
int smlspc, spc;
|
const int SMLSPC = 2;
|
||||||
|
const int SPC = 15;
|
||||||
smlspc = 2;
|
|
||||||
spc = 15;
|
|
||||||
|
|
||||||
custom_apply_attr (win[STA].p, ATTR_HIGHEST);
|
custom_apply_attr (win[STA].p, ATTR_HIGHEST);
|
||||||
mvwprintw (win[STA].p, 0, 2, "Q");
|
mvwprintw (win[STA].p, 0, 2, "Q");
|
||||||
mvwprintw (win[STA].p, 1, 2, "G");
|
mvwprintw (win[STA].p, 1, 2, "G");
|
||||||
mvwprintw (win[STA].p, 0, 2 + spc, "L");
|
mvwprintw (win[STA].p, 0, 2 + SPC, "L");
|
||||||
mvwprintw (win[STA].p, 1, 2 + spc, "C");
|
mvwprintw (win[STA].p, 1, 2 + SPC, "S");
|
||||||
mvwprintw (win[STA].p, 0, 2 + 2 * spc, "N");
|
mvwprintw (win[STA].p, 0, 2 + 2 * SPC, "C");
|
||||||
mvwprintw (win[STA].p, 1, 2 + 2 * spc, "K");
|
mvwprintw (win[STA].p, 1, 2 + 2 * SPC, "N");
|
||||||
|
mvwprintw (win[STA].p, 0, 2 + 3 * SPC, "K");
|
||||||
custom_remove_attr (win[STA].p, ATTR_HIGHEST);
|
custom_remove_attr (win[STA].p, ATTR_HIGHEST);
|
||||||
|
|
||||||
mvwprintw (win[STA].p, 0, 2 + smlspc, _("Exit"));
|
mvwprintw (win[STA].p, 0, 2 + SMLSPC, _("Exit"));
|
||||||
mvwprintw (win[STA].p, 1, 2 + smlspc, _("General"));
|
mvwprintw (win[STA].p, 1, 2 + SMLSPC, _("General"));
|
||||||
mvwprintw (win[STA].p, 0, 2 + spc + smlspc, _("Layout"));
|
mvwprintw (win[STA].p, 0, 2 + SPC + SMLSPC, _("Layout"));
|
||||||
mvwprintw (win[STA].p, 1, 2 + spc + smlspc, _("Color"));
|
mvwprintw (win[STA].p, 1, 2 + SPC + SMLSPC, _("Sidebar"));
|
||||||
mvwprintw (win[STA].p, 0, 2 + 2 * spc + smlspc, _("Notify"));
|
mvwprintw (win[STA].p, 0, 2 + 2 * SPC + SMLSPC, _("Color"));
|
||||||
mvwprintw (win[STA].p, 1, 2 + 2 * spc + smlspc, _("Keys"));
|
mvwprintw (win[STA].p, 1, 2 + 2 * SPC + SMLSPC, _("Notify"));
|
||||||
|
mvwprintw (win[STA].p, 0, 2 + 3 * SPC + SMLSPC, _("Keys"));
|
||||||
|
|
||||||
wnoutrefresh (win[STA].p);
|
wnoutrefresh (win[STA].p);
|
||||||
wmove (win[STA].p, 0, 0);
|
wmove (win[STA].p, 0, 0);
|
||||||
@ -591,6 +591,54 @@ custom_layout_config (void)
|
|||||||
#undef NBLAYOUTS
|
#undef NBLAYOUTS
|
||||||
#undef LAYOUTSPERCOL
|
#undef LAYOUTSPERCOL
|
||||||
|
|
||||||
|
/* Sidebar configuration screen. */
|
||||||
|
void
|
||||||
|
custom_sidebar_config (void)
|
||||||
|
{
|
||||||
|
struct binding inc = {_("Width +"), KEY_MOVE_UP};
|
||||||
|
struct binding dec = {_("Width -"), KEY_MOVE_DOWN};
|
||||||
|
struct binding help = {_("Help"), KEY_GENERIC_HELP};
|
||||||
|
struct binding *binding[] = {&inc, &dec, &help};
|
||||||
|
int ch, binding_size;
|
||||||
|
|
||||||
|
binding_size = sizeof (binding) / sizeof (binding[0]);
|
||||||
|
|
||||||
|
keys_display_bindings_bar (win[STA].p, binding, 0, binding_size);
|
||||||
|
doupdate ();
|
||||||
|
while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
|
||||||
|
{
|
||||||
|
unsigned need_update;
|
||||||
|
|
||||||
|
need_update = 0;
|
||||||
|
switch (ch)
|
||||||
|
{
|
||||||
|
case KEY_MOVE_UP:
|
||||||
|
sbarwidth++;
|
||||||
|
need_update = 1;
|
||||||
|
break;
|
||||||
|
case KEY_MOVE_DOWN:
|
||||||
|
sbarwidth--;
|
||||||
|
need_update = 1;
|
||||||
|
break;
|
||||||
|
case KEY_GENERIC_HELP:
|
||||||
|
/* XXX
|
||||||
|
Add help screen for sidebar configuration
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (need_update)
|
||||||
|
{
|
||||||
|
wins_reinit ();
|
||||||
|
wins_update_border ();
|
||||||
|
wins_update_panels ();
|
||||||
|
keys_display_bindings_bar (win[STA].p, binding, 0, binding_size);
|
||||||
|
doupdate ();
|
||||||
|
need_update = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_confwin_attr (struct window *cwin)
|
set_confwin_attr (struct window *cwin)
|
||||||
{
|
{
|
||||||
|
30
src/wins.c
30
src/wins.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: wins.c,v 1.29 2010/03/20 10:54:49 culot Exp $ */
|
/* $calcurse: wins.c,v 1.30 2010/03/20 13:29:48 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -45,6 +45,9 @@
|
|||||||
/* Variables to handle calcurse windows. */
|
/* Variables to handle calcurse windows. */
|
||||||
struct window win[NBWINS];
|
struct window win[NBWINS];
|
||||||
|
|
||||||
|
/* User-configurable side bar width. */
|
||||||
|
unsigned sbarwidth = 30;
|
||||||
|
|
||||||
static enum win slctd_win;
|
static enum win slctd_win;
|
||||||
static int layout;
|
static int layout;
|
||||||
|
|
||||||
@ -103,7 +106,7 @@ wins_init (void)
|
|||||||
* Create the three main windows plus the status bar and the pad used to
|
* Create the three main windows plus the status bar and the pad used to
|
||||||
* display appointments and event.
|
* display appointments and event.
|
||||||
*/
|
*/
|
||||||
win[CAL].p = newwin (CALHEIGHT, CALWIDTH, win[CAL].y, win[CAL].x);
|
win[CAL].p = newwin (CALHEIGHT, sbarwidth, win[CAL].y, win[CAL].x);
|
||||||
(void)snprintf (label, BUFSIZ, _("Calendar"));
|
(void)snprintf (label, BUFSIZ, _("Calendar"));
|
||||||
wins_show (win[CAL].p, label);
|
wins_show (win[CAL].p, label);
|
||||||
|
|
||||||
@ -257,7 +260,7 @@ wins_get_config (void)
|
|||||||
win[NOT].x = 0;
|
win[NOT].x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
win[CAL].w = CALWIDTH;
|
win[CAL].w = sbarwidth;
|
||||||
win[CAL].h = CALHEIGHT;
|
win[CAL].h = CALHEIGHT;
|
||||||
|
|
||||||
if (layout <= 4)
|
if (layout <= 4)
|
||||||
@ -400,12 +403,8 @@ border_nocolor (WINDOW *window)
|
|||||||
wnoutrefresh (window);
|
wnoutrefresh (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Update all of the three windows and put a border around the
|
|
||||||
* selected window.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
wins_update (void)
|
wins_update_border (void)
|
||||||
{
|
{
|
||||||
switch (slctd_win)
|
switch (slctd_win)
|
||||||
{
|
{
|
||||||
@ -428,10 +427,25 @@ wins_update (void)
|
|||||||
EXIT (_("no window selected"));
|
EXIT (_("no window selected"));
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
wins_update_panels (void)
|
||||||
|
{
|
||||||
apoint_update_panel (slctd_win);
|
apoint_update_panel (slctd_win);
|
||||||
todo_update_panel (slctd_win);
|
todo_update_panel (slctd_win);
|
||||||
calendar_update_panel (&win[CAL]);
|
calendar_update_panel (&win[CAL]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update all of the three windows and put a border around the
|
||||||
|
* selected window.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
wins_update (void)
|
||||||
|
{
|
||||||
|
wins_update_border ();
|
||||||
|
wins_update_panels ();
|
||||||
wins_status_bar ();
|
wins_status_bar ();
|
||||||
if (notify_bar ())
|
if (notify_bar ())
|
||||||
notify_update_bar ();
|
notify_update_bar ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user