new layout configuration menu
This commit is contained in:
parent
d59b0e15ab
commit
d54dd2ee73
@ -1,3 +1,10 @@
|
|||||||
|
2008-12-20 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
|
* TODO: update for 2.4
|
||||||
|
|
||||||
|
* src/custom.c (custom_layout_config, display_layout_config)
|
||||||
|
(layout_selection_bar): new functions
|
||||||
|
|
||||||
2008-12-18 Frederic Culot <frederic@culot.org>
|
2008-12-18 Frederic Culot <frederic@culot.org>
|
||||||
|
|
||||||
* src/notify.c (notify_check_next_app): create thread detached to
|
* src/notify.c (notify_check_next_app): create thread detached to
|
||||||
|
3
TODO
3
TODO
@ -11,8 +11,8 @@ this list.
|
|||||||
|
|
||||||
High
|
High
|
||||||
----
|
----
|
||||||
o Add a week view in the calendar panel
|
|
||||||
o Add support for UTF-8
|
o Add support for UTF-8
|
||||||
|
o Allow events and appointments to be moved from one date to another
|
||||||
|
|
||||||
|
|
||||||
Average
|
Average
|
||||||
@ -23,6 +23,7 @@ Average
|
|||||||
o Add an auto-save function
|
o Add an auto-save function
|
||||||
o Add support for CalDAV protocol (rfc4791)
|
o Add support for CalDAV protocol (rfc4791)
|
||||||
o Implement categories to classify appointments and tasks
|
o Implement categories to classify appointments and tasks
|
||||||
|
o Add a week view in the calendar panel
|
||||||
|
|
||||||
|
|
||||||
Low
|
Low
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: calcurse.c,v 1.72 2008/12/07 09:20:38 culot Exp $ */
|
/* $calcurse: calcurse.c,v 1.73 2008/12/20 19:27:31 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -262,7 +262,7 @@ main (int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
case 'l':
|
case 'l':
|
||||||
layout_config ();
|
custom_layout_config ();
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
case 'g':
|
case 'g':
|
||||||
|
181
src/custom.c
181
src/custom.c
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: custom.c,v 1.30 2008/12/14 15:54:51 culot Exp $ */
|
/* $calcurse: custom.c,v 1.31 2008/12/20 19:27:31 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -34,6 +34,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "apoint.h"
|
#include "apoint.h"
|
||||||
|
#include "help.h"
|
||||||
|
|
||||||
static struct attribute_s attr;
|
static struct attribute_s attr;
|
||||||
|
|
||||||
@ -365,35 +366,171 @@ custom_config_bar (void)
|
|||||||
doupdate ();
|
doupdate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
layout_selection_bar (void)
|
||||||
|
{
|
||||||
|
binding_t quit = {_("Exit"), KEY_GENERIC_QUIT};
|
||||||
|
binding_t select = {_("Select"), KEY_GENERIC_SELECT};
|
||||||
|
binding_t up = {_("Up"), KEY_MOVE_UP};
|
||||||
|
binding_t down = {_("Down"), KEY_MOVE_DOWN};
|
||||||
|
binding_t left = {_("Left"), KEY_MOVE_LEFT};
|
||||||
|
binding_t right = {_("Right"), KEY_MOVE_RIGHT};
|
||||||
|
binding_t help = {_("Help"), KEY_GENERIC_HELP};
|
||||||
|
|
||||||
|
binding_t *binding[] = {&quit, &select, &up, &down, &left, &right, &help};
|
||||||
|
int binding_size = sizeof (binding) / sizeof (binding[0]);
|
||||||
|
|
||||||
|
keys_display_bindings_bar (win[STA].p, binding, 0, binding_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NBLAYOUTS 8
|
||||||
|
#define LAYOUTSPERCOL 2
|
||||||
|
|
||||||
|
/* Used to display available layouts in layout configuration menu. */
|
||||||
|
static void
|
||||||
|
display_layout_config (window_t *lwin, int mark, int cursor, int need_reset)
|
||||||
|
{
|
||||||
|
#define CURSOR (32 | A_REVERSE)
|
||||||
|
#define MARK 88
|
||||||
|
#define LAYOUTH 5
|
||||||
|
#define LAYOUTW 9
|
||||||
|
char *box = "[ ]";
|
||||||
|
const int BOXSIZ = strlen (box);
|
||||||
|
const int NBCOLS = NBLAYOUTS / LAYOUTSPERCOL;
|
||||||
|
const int COLSIZ = LAYOUTW + BOXSIZ + 1;
|
||||||
|
const int XSPC = (col - NBCOLS * COLSIZ) / (NBCOLS + 1);
|
||||||
|
const int XOFST = (col - NBCOLS * (XSPC + COLSIZ)) / 2;
|
||||||
|
const int YSPC = (row - 8 - LAYOUTSPERCOL * LAYOUTH) / (LAYOUTSPERCOL + 1);
|
||||||
|
const int YOFST = (row - LAYOUTSPERCOL * (YSPC + LAYOUTH)) / 2;
|
||||||
|
enum {YPOS, XPOS, NBPOS};
|
||||||
|
int pos[NBLAYOUTS][NBPOS];
|
||||||
|
char *layouts[LAYOUTH][NBLAYOUTS] = {
|
||||||
|
{"+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+"},
|
||||||
|
{"| | c |", "| | t |", "| c | |", "| t | |", "| | c |", "| | a |", "| c | |", "| a | |"},
|
||||||
|
{"| a +---+", "| a +---+", "+---+ a |", "|---+ a |", "| t +---+", "| t +---+", "+---+ t |", "+---+ t |"},
|
||||||
|
{"| | t |", "| | c |", "| t | |", "| c | |", "| | a |", "| | c |", "| a | |", "| c | |"},
|
||||||
|
{"+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+", "+---+---+"}
|
||||||
|
};
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < NBLAYOUTS; i++)
|
||||||
|
{
|
||||||
|
pos[i][YPOS] = YOFST + (i % LAYOUTSPERCOL) * (YSPC + LAYOUTH);
|
||||||
|
pos[i][XPOS] = XOFST + (i / LAYOUTSPERCOL) * (XSPC + COLSIZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (need_reset)
|
||||||
|
{
|
||||||
|
char label[BUFSIZ];
|
||||||
|
|
||||||
|
if (lwin->p != NULL)
|
||||||
|
delwin (lwin->p);
|
||||||
|
snprintf (label, BUFSIZ, _("CalCurse %s | layout configuration"),
|
||||||
|
VERSION);
|
||||||
|
custom_confwin_init (lwin, label);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < NBLAYOUTS; i++)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
|
mvwprintw (lwin->p, pos[i][YPOS] + 2, pos[i][XPOS], box);
|
||||||
|
if (i == mark)
|
||||||
|
custom_apply_attr (lwin->p, ATTR_HIGHEST);
|
||||||
|
for (j = 0; j < LAYOUTH; j++)
|
||||||
|
{
|
||||||
|
mvwprintw (lwin->p, pos[i][YPOS] + j, pos[i][XPOS] + BOXSIZ + 1,
|
||||||
|
layouts[j][i]);
|
||||||
|
}
|
||||||
|
if (i == mark)
|
||||||
|
custom_remove_attr (lwin->p, ATTR_HIGHEST);
|
||||||
|
}
|
||||||
|
mvwaddch (lwin->p, pos[mark][YPOS] + 2, pos[mark][XPOS] + 1, MARK);
|
||||||
|
mvwaddch (lwin->p, pos[cursor][YPOS] + 2, pos[cursor][XPOS] + 1, CURSOR);
|
||||||
|
|
||||||
|
layout_selection_bar ();
|
||||||
|
wnoutrefresh (win[STA].p);
|
||||||
|
wnoutrefresh (lwin->p);
|
||||||
|
doupdate ();
|
||||||
|
if (notify_bar ())
|
||||||
|
notify_update_bar ();
|
||||||
|
}
|
||||||
|
|
||||||
/* Choose the layout */
|
/* Choose the layout */
|
||||||
void
|
void
|
||||||
layout_config (void)
|
custom_layout_config (void)
|
||||||
{
|
{
|
||||||
int ch;
|
scrollwin_t hwin;
|
||||||
char *layout_mesg =
|
window_t conf_win;
|
||||||
_("Pick the desired layout on next screen [press ENTER]");
|
int ch, mark, cursor, need_reset;
|
||||||
char *choice_mesg =
|
char *help_text =
|
||||||
_("('A'= Appointment panel, 'C'= calendar panel, 'T'= todo panel)");
|
_("With this configuration menu, one can choose where panels will be\n"
|
||||||
char *layout_up_mesg =
|
"displayed inside calcurse screen. \n"
|
||||||
_(" AC AT CA TA TC TA CT AT");
|
"It is possible to choose between eight different configurations.\n"
|
||||||
char *layout_down_mesg =
|
"\nIn the configuration representations, letters correspond to:\n\n"
|
||||||
_(" [1]AT [2]AC [3]TA [4]CA [5]TA [6]TC [7]AT [8]CT");
|
" 'c' -> calendar panel\n\n"
|
||||||
|
" 'a' -> appointment panel\n\n"
|
||||||
|
" 't' -> todo panel\n\n");
|
||||||
|
|
||||||
status_mesg (layout_mesg, choice_mesg);
|
need_reset = 1;
|
||||||
(void)wgetch (win[STA].p);
|
conf_win.p = (WINDOW *)0;
|
||||||
status_mesg (layout_up_mesg, layout_down_mesg);
|
cursor = mark = wins_layout () - 1;
|
||||||
wnoutrefresh (win[STA].p);
|
clear ();
|
||||||
doupdate ();
|
display_layout_config (&conf_win, mark, cursor, need_reset);
|
||||||
while ((ch = wgetch (win[STA].p)) != 'q')
|
|
||||||
|
while ((ch = keys_getch (win[STA].p)) != KEY_GENERIC_QUIT)
|
||||||
{
|
{
|
||||||
if (ch <= '8' && ch >= '1')
|
need_reset = 0;
|
||||||
|
switch (ch)
|
||||||
{
|
{
|
||||||
wins_set_layout (ch - '0');
|
case KEY_RESIZE:
|
||||||
return;
|
endwin ();
|
||||||
|
refresh ();
|
||||||
|
curs_set (0);
|
||||||
|
need_reset = 1;
|
||||||
|
break;
|
||||||
|
case KEY_GENERIC_HELP:
|
||||||
|
help_wins_init (&hwin, 0, 0,
|
||||||
|
(notify_bar ()) ? row - 3 : row - 2, col);
|
||||||
|
mvwprintw (hwin.pad.p, 1, 0, "%s", help_text);
|
||||||
|
hwin.total_lines = 7;
|
||||||
|
wins_scrollwin_display (&hwin);
|
||||||
|
wgetch (hwin.win.p);
|
||||||
|
wins_scrollwin_delete (&hwin);
|
||||||
|
need_reset = 1;
|
||||||
|
break;
|
||||||
|
case KEY_GENERIC_SELECT:
|
||||||
|
mark = cursor;
|
||||||
|
break;
|
||||||
|
case KEY_MOVE_DOWN:
|
||||||
|
if (cursor % LAYOUTSPERCOL < LAYOUTSPERCOL - 1)
|
||||||
|
cursor++;
|
||||||
|
break;
|
||||||
|
case KEY_MOVE_UP:
|
||||||
|
if (cursor % LAYOUTSPERCOL > 0)
|
||||||
|
cursor--;
|
||||||
|
break;
|
||||||
|
case KEY_MOVE_LEFT:
|
||||||
|
if (cursor >= LAYOUTSPERCOL)
|
||||||
|
cursor -= LAYOUTSPERCOL;
|
||||||
|
break;
|
||||||
|
case KEY_MOVE_RIGHT:
|
||||||
|
if (cursor < NBLAYOUTS - LAYOUTSPERCOL)
|
||||||
|
cursor += LAYOUTSPERCOL;
|
||||||
|
break;
|
||||||
|
case KEY_GENERIC_CANCEL:
|
||||||
|
need_reset = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
display_layout_config (&conf_win, mark, cursor, need_reset);
|
||||||
}
|
}
|
||||||
|
wins_set_layout (mark + 1);
|
||||||
|
delwin (conf_win.p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef NBLAYOUTS
|
||||||
|
#undef LAYOUTSPERCOL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a configuration window and initialize status and notification bar
|
* Create a configuration window and initialize status and notification bar
|
||||||
* (useful in case of window resize).
|
* (useful in case of window resize).
|
||||||
@ -417,7 +554,7 @@ custom_confwin_init (window_t *confwin, char *label)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
custom_color_config_bar (void)
|
color_selection_bar (void)
|
||||||
{
|
{
|
||||||
binding_t quit = {_("Exit"), KEY_GENERIC_QUIT};
|
binding_t quit = {_("Exit"), KEY_GENERIC_QUIT};
|
||||||
binding_t select = {_("Select"), KEY_GENERIC_SELECT};
|
binding_t select = {_("Select"), KEY_GENERIC_SELECT};
|
||||||
@ -559,7 +696,7 @@ display_color_config (window_t *cwin, int *mark_fore, int *mark_back,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mvwaddch (cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1, CURSOR);
|
mvwaddch (cwin->p, pos[cursor][YPOS], pos[cursor][XPOS] + 1, CURSOR);
|
||||||
custom_color_config_bar ();
|
color_selection_bar ();
|
||||||
wnoutrefresh (win[STA].p);
|
wnoutrefresh (win[STA].p);
|
||||||
wnoutrefresh (cwin->p);
|
wnoutrefresh (cwin->p);
|
||||||
doupdate ();
|
doupdate ();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: custom.h,v 1.13 2008/11/23 20:38:56 culot Exp $ */
|
/* $calcurse: custom.h,v 1.14 2008/12/20 19:27:31 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -77,7 +77,7 @@ void custom_apply_attr (WINDOW *, int);
|
|||||||
void custom_remove_attr (WINDOW *, int);
|
void custom_remove_attr (WINDOW *, int);
|
||||||
void custom_load_conf (conf_t *, int);
|
void custom_load_conf (conf_t *, int);
|
||||||
void custom_config_bar (void);
|
void custom_config_bar (void);
|
||||||
void layout_config (void);
|
void custom_layout_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 (window_t *, char *);
|
void custom_confwin_init (window_t *, char *);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: help.c,v 1.34 2008/12/03 19:31:03 culot Exp $ */
|
/* $calcurse: help.c,v 1.35 2008/12/20 19:27:31 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -130,7 +130,7 @@ help_write_pad (window_t *win, char *title, char *text, keys_e action)
|
|||||||
* Create and init help screen and its pad, which is used to make the scrolling
|
* Create and init help screen and its pad, which is used to make the scrolling
|
||||||
* faster.
|
* faster.
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
help_wins_init (scrollwin_t *hwin, int x, int y, int h, int w)
|
help_wins_init (scrollwin_t *hwin, int x, int y, int h, int w)
|
||||||
{
|
{
|
||||||
const int PADOFFSET = 4;
|
const int PADOFFSET = 4;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: help.h,v 1.8 2008/12/03 19:31:03 culot Exp $ */
|
/* $calcurse: help.h,v 1.9 2008/12/20 19:27:31 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -36,6 +36,7 @@ typedef struct {
|
|||||||
char text[HELPTEXTSIZ];
|
char text[HELPTEXTSIZ];
|
||||||
} help_page_t;
|
} help_page_t;
|
||||||
|
|
||||||
|
void help_wins_init (scrollwin_t *, int, int, int, int);
|
||||||
void help_screen (void);
|
void help_screen (void);
|
||||||
|
|
||||||
#endif /* CALCURSE_HELP_H */
|
#endif /* CALCURSE_HELP_H */
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $calcurse: utils.c,v 1.60 2008/12/15 20:02:00 culot Exp $ */
|
/* $calcurse: utils.c,v 1.61 2008/12/20 19:27:31 culot Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calcurse - text-based organizer
|
* Calcurse - text-based organizer
|
||||||
@ -136,12 +136,12 @@ popup (int pop_row, int pop_col, int pop_y, int pop_x, char *title, char *msg,
|
|||||||
|
|
||||||
popup_win = newwin (pop_row, pop_col, pop_y, pop_x);
|
popup_win = newwin (pop_row, pop_col, pop_y, pop_x);
|
||||||
keypad (popup_win, TRUE);
|
keypad (popup_win, TRUE);
|
||||||
|
if (msg)
|
||||||
|
mvwprintw (popup_win, MSGXPOS, (pop_col - strlen (msg)) / 2, "%s", msg);
|
||||||
custom_apply_attr (popup_win, ATTR_HIGHEST);
|
custom_apply_attr (popup_win, ATTR_HIGHEST);
|
||||||
box (popup_win, 0, 0);
|
box (popup_win, 0, 0);
|
||||||
snprintf (label, BUFSIZ, "%s", title);
|
snprintf (label, BUFSIZ, "%s", title);
|
||||||
wins_show (popup_win, label);
|
wins_show (popup_win, label);
|
||||||
if (msg)
|
|
||||||
mvwprintw (popup_win, MSGXPOS, (pop_col - strlen (msg)) / 2, "%s", msg);
|
|
||||||
if (hint)
|
if (hint)
|
||||||
mvwprintw (popup_win, pop_row - 2, pop_col - (strlen (any_key) + 1), "%s",
|
mvwprintw (popup_win, pop_row - 2, pop_col - (strlen (any_key) + 1), "%s",
|
||||||
any_key);
|
any_key);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user