aboutsummaryrefslogtreecommitdiffstats
path: root/src/wins.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/wins.c')
-rw-r--r--src/wins.c130
1 files changed, 37 insertions, 93 deletions
diff --git a/src/wins.c b/src/wins.c
index 249610c..78cbe07 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -216,12 +216,6 @@ void wins_sbar_wdec(void)
sbarwidth_perc--;
}
-/* Initialize the selected window in calcurse's interface. */
-void wins_slctd_init(void)
-{
- wins_slctd_set(CAL);
-}
-
/* Returns an enum which corresponds to the window which is selected. */
enum win wins_slctd(void)
{
@@ -245,7 +239,8 @@ void wins_slctd_next(void)
static void wins_init_panels(void)
{
- win[CAL].p = newwin(CALHEIGHT, wins_sbar_width(), win[CAL].y, win[CAL].x);
+ win[CAL].p = newwin(CALHEIGHT + (conf.compact_panels ? 2 : 4),
+ wins_sbar_width(), win[CAL].y, win[CAL].x);
wins_show(win[CAL].p, _("Calendar"));
win[APP].p = newwin(win[APP].h, win[APP].w, win[APP].y, win[APP].x);
@@ -301,9 +296,8 @@ void wins_scrollwin_display(struct scrollwin *sw)
const int visible_lines = sw->win.h - sw->pad.y - 1;
if (sw->total_lines > visible_lines) {
- float ratio = ((float)visible_lines) / ((float)sw->total_lines);
- int sbar_length = (int)(ratio * visible_lines);
- int highend = (int)(ratio * sw->first_visible_line);
+ int sbar_length = visible_lines * visible_lines / sw->total_lines;
+ int highend = visible_lines * sw->first_visible_line / sw->total_lines;
int sbar_top = highend + sw->pad.y + 1;
if ((sbar_top + sbar_length) > sw->win.h - 1)
@@ -363,11 +357,14 @@ void wins_show(WINDOW * win, const char *label)
int width = getmaxx(win);
box(win, 0, 0);
- mvwaddch(win, 2, 0, ACS_LTEE);
- mvwhline(win, 2, 1, ACS_HLINE, width - 2);
- mvwaddch(win, 2, width - 1, ACS_RTEE);
- print_in_middle(win, 1, 0, width, label);
+ if (!conf.compact_panels) {
+ mvwaddch(win, 2, 0, ACS_LTEE);
+ mvwhline(win, 2, 1, ACS_HLINE, width - 2);
+ mvwaddch(win, 2, width - 1, ACS_RTEE);
+
+ print_in_middle(win, 1, 0, width, label);
+ }
}
/*
@@ -375,6 +372,10 @@ void wins_show(WINDOW * win, const char *label)
*/
void wins_get_config(void)
{
+ enum win win_master;
+ enum win win_slave[1];
+ unsigned master_is_left;
+
/* Get the screen configuration */
getmaxyx(stdscr, row, col);
@@ -396,88 +397,31 @@ void wins_get_config(void)
win[NOT].x = 0;
}
- win[CAL].w = wins_sbar_width();
- win[CAL].h = CALHEIGHT;
+ win[CAL].h = CALHEIGHT + (conf.compact_panels ? 2 : 4);
- if (layout <= 4) { /* APPOINTMENT is the biggest panel */
- win[APP].w = col - win[CAL].w;
- win[APP].h = row - (win[STA].h + win[NOT].h);
- win[TOD].w = win[CAL].w;
+ if (layout <= 4) {
+ win_master = APP;
+ win_slave[0] = ((layout - 1) % 2 == 0) ? CAL : TOD;
+ win_slave[1] = ((layout - 1) % 2 == 1) ? CAL : TOD;
win[TOD].h = row - (win[CAL].h + win[STA].h + win[NOT].h);
- } else { /* TODO is the biggest panel */
- win[TOD].w = col - win[CAL].w;
- win[TOD].h = row - (win[STA].h + win[NOT].h);
- win[APP].w = win[CAL].w;
+ } else {
+ win_master = TOD;
+ win_slave[0] = ((layout - 1) % 2 == 0) ? CAL : APP;
+ win_slave[1] = ((layout - 1) % 2 == 1) ? CAL : APP;
win[APP].h = row - (win[CAL].h + win[STA].h + win[NOT].h);
}
+ master_is_left = ((layout - 1) % 4 < 2);
- /* defining the layout */
- switch (layout) {
- case 1:
- win[APP].y = 0;
- win[APP].x = 0;
- win[CAL].y = 0;
- win[TOD].x = win[APP].w;
- win[TOD].y = win[CAL].h;
- win[CAL].x = win[APP].w;
- break;
- case 2:
- win[APP].y = 0;
- win[APP].x = 0;
- win[TOD].y = 0;
- win[TOD].x = win[APP].w;
- win[CAL].x = win[APP].w;
- win[CAL].y = win[TOD].h;
- break;
- case 3:
- win[APP].y = 0;
- win[TOD].x = 0;
- win[CAL].x = 0;
- win[CAL].y = 0;
- win[APP].x = win[CAL].w;
- win[TOD].y = win[CAL].h;
- break;
- case 4:
- win[APP].y = 0;
- win[TOD].x = 0;
- win[TOD].y = 0;
- win[CAL].x = 0;
- win[APP].x = win[CAL].w;
- win[CAL].y = win[TOD].h;
- break;
- case 5:
- win[TOD].y = 0;
- win[TOD].x = 0;
- win[CAL].y = 0;
- win[APP].y = win[CAL].h;
- win[APP].x = win[TOD].w;
- win[CAL].x = win[TOD].w;
- break;
- case 6:
- win[TOD].y = 0;
- win[TOD].x = 0;
- win[APP].y = 0;
- win[APP].x = win[TOD].w;
- win[CAL].x = win[TOD].w;
- win[CAL].y = win[APP].h;
- break;
- case 7:
- win[TOD].y = 0;
- win[APP].x = 0;
- win[CAL].x = 0;
- win[CAL].y = 0;
- win[TOD].x = win[CAL].w;
- win[APP].y = win[CAL].h;
- break;
- case 8:
- win[TOD].y = 0;
- win[APP].x = 0;
- win[CAL].x = 0;
- win[APP].y = 0;
- win[TOD].x = win[CAL].w;
- win[CAL].y = win[APP].h;
- break;
- }
+ win[win_master].x = master_is_left ? 0 : wins_sbar_width();
+ win[win_master].y = 0;
+ win[win_master].w = col - wins_sbar_width();
+ win[win_master].h = row - (win[STA].h + win[NOT].h);
+
+ win[win_slave[0]].x = win[win_slave[1]].x =
+ master_is_left ? win[win_master].w : 0;
+ win[win_slave[0]].y = 0;
+ win[win_slave[1]].y = win[win_slave[0]].h;
+ win[win_slave[0]].w = win[win_slave[1]].w = wins_sbar_width();
}
/* draw panel border in color */
@@ -637,7 +581,7 @@ void wins_status_bar(void)
struct binding help = { _("Help"), KEY_GENERIC_HELP };
struct binding quit = { _("Quit"), KEY_GENERIC_QUIT };
struct binding save = { _("Save"), KEY_GENERIC_SAVE };
- struct binding cut = { _("Cut"), KEY_GENERIC_CUT };
+ struct binding copy = { _("Copy"), KEY_GENERIC_COPY };
struct binding paste = { _("Paste"), KEY_GENERIC_PASTE };
struct binding chgvu = { _("Chg Win"), KEY_GENERIC_CHANGE_VIEW };
struct binding import = { _("Import"), KEY_GENERIC_IMPORT };
@@ -688,7 +632,7 @@ void wins_status_bar(void)
&help, &quit, &save, &chgvu, &import, &export, &add, &del, &edit, &view,
&pipe, &draw, &rept, &flag, &enote, &vnote, &up, &down, &gpday, &gnday,
&gpweek, &gnweek, &gpmonth, &gnmonth, &gpyear, &gnyear, &togo, &today,
- &conf, &appt, &todo, &cut, &paste
+ &conf, &appt, &todo, &copy, &paste
};
struct binding *bindings_todo[] = {