]> Pileus Git - lackey/commitdiff
Improve ical forms
authorAndy Spencer <andy753421@gmail.com>
Tue, 27 Jan 2015 03:07:56 +0000 (03:07 +0000)
committerAndy Spencer <andy753421@gmail.com>
Mon, 5 Dec 2016 08:28:53 +0000 (08:28 +0000)
cals/ical.c
src/form.c
src/form.h

index 8b3db546223314c97b2cd65c31911edbd4083d10..3ed4b724fedbed4f0ad3b93eee19991f2d2e4149 100644 (file)
@@ -53,49 +53,58 @@ static ical_t *calendars;
 static form_text_t   ff_name   = TEXT('t');
 static form_text_t   ff_desc   = TEXT('d');
 static form_text_t   ff_loc    = TEXT('o');
-static form_list_t   ff_cat    = LIST('g');
+static form_text_t   ff_cat    = TEXT('g');
 static form_date_t   ff_start  = DATE('s');
 static form_date_t   ff_end    = DATE('e');
 static form_number_t ff_status = NUMBER('p', .f.after="%");
 static form_date_t   ff_due    = DATE('u');
 static form_list_t   ff_cal    = LIST('c');
 static form_list_t   ff_recur  = LIST('r');
-static form_number_t ff_freq   = NUMBER(0);
+static form_number_t ff_freq   = NUMBER('v');
 static form_button_t ff_wdays  = BUTTONS("Su Mo Tu We Th Fr Sa");
 
 /* Edit event form */
 static form_t form_cal = { 1, 2, {
-       { LABEL("_Title: "),     &ff_name.f                                    },
+       { HEAD("Basics")                         },
+       { TAB, LABEL("_Title"),     &ff_name.f   },
 } };
 
 /* Edit event form */
-static form_t form_event = { 11, 4, {
-       { LABEL("_Title: "),     &ff_name.f                                      },
-       { LABEL("L_ocation: "),  &ff_loc.f                                       },
-       {                                                                        },
-       { LABEL("_Start: "),     &ff_start.f, LABEL("  _End: "),      &ff_end.f  },
-       { LABEL("_Calendar: "),  &ff_cal.f,   LABEL("  Cate_gory: "), &ff_cat.f  },
-       {                                                                        },
-       { LABEL("_Repeat: "),    &ff_recur.f, LABEL("  Every: "),     &ff_freq.f },
-       {                                                                        },
-       { NULL,                  &ff_wdays.f                                     },
-       {                                                                        },
-       { LABEL("_Details: "),   &ff_desc.f                                      },
+static form_t form_event = { 12, 6, {
+       { HEAD("Basics")                         },
+       { TAB, LABEL("_Title"),     &ff_name.f   },
+       { TAB, LABEL("L_ocation"),  &ff_loc.f    },
+       { TAB, LABEL("_Start"),     &ff_start.f,
+         TAB, LABEL("_End"),       &ff_end.f    },
+       { TAB, LABEL("_Calendar"),  &ff_cal.f,
+         TAB, LABEL("Cate_gory"),  &ff_cat.f    },
+       {                                        },
+       { HEAD("Recurrence")                     },
+       { TAB, LABEL("_Repeat"),    &ff_recur.f,
+         TAB, LABEL("E_very"),     &ff_freq.f   },
+       { TAB, TAB,                 &ff_wdays.f  },
+       {                                        },
+       { HEAD("_Details")                       },
+       { TAB, &ff_desc.f                        },
 } };
 
 /* Edit todo form */
-static form_t form_todo = { 11, 4, {
-       { LABEL("_Title: "),     &ff_name.f                                      },
-       { LABEL("Com_pleted: "), &ff_status.f                                    },
-       {                                                                        },
-       { LABEL("_Start:    "),  &ff_start.f, LABEL("  D_ue Date: "), &ff_due.f  },
-       { LABEL("_Calendar: "),  &ff_cal.f,   LABEL("  Cate_gory: "), &ff_cat.f  },
-       {                                                                        },
-       { LABEL("_Repeat: "),    &ff_recur.f, LABEL("  Every: "),     &ff_freq.f },
-       {                                                                        },
-       { NULL,                  &ff_wdays.f                                     },
-       {                                                                        },
-       { LABEL("_Details: "),   &ff_desc.f                                      },
+static form_t form_todo = { 12, 6, {
+       { HEAD("Basics")                         },
+       { TAB, LABEL("_Title"),     &ff_name.f   },
+       { TAB, LABEL("Com_pleted"), &ff_status.f },
+       { TAB, LABEL("_Start"),     &ff_start.f,
+         TAB, LABEL("D_ue Date"),  &ff_due.f    },
+       { TAB, LABEL("_Calendar"),  &ff_cal.f,
+         TAB, LABEL("Cate_gory"),  &ff_cat.f    },
+       {                                        },
+       { HEAD("Recurrence")                     },
+       { TAB, LABEL("_Repeat"),    &ff_recur.f,
+         TAB, LABEL("E_very"),     &ff_freq.f   },
+       { TAB, TAB,                 &ff_wdays.f  },
+       {                                        },
+       { HEAD("_Details")                       },
+       { TAB, &ff_desc.f                        },
 } };
 
 /* Helper functions */
@@ -395,25 +404,23 @@ void ical_edit(edit_t mode)
                        form_show(&form_cal);
                        break;
                case EDIT_EVENT:
-                       ff_name.text   = strcopy(EVENT->name);
-                       ff_desc.text   = strcopy(EVENT->desc);
-                       ff_loc.text    = strcopy(EVENT->loc);
-                       //ff_cat.text    = strcopy(EVENT->cat);
-                       ff_start.date  = EVENT->start;
-                       ff_end.date    = EVENT->end;
-                       //ff_recur.text = strcopy(EVENT->recur);
-                       debug("ical_edit - event");
+                       ff_name.text     = strcopy(EVENT->name);
+                       ff_desc.text     = strcopy(EVENT->desc);
+                       ff_loc.text      = strcopy(EVENT->loc);
+                       ff_cat.text      = strcopy(EVENT->cat);
+                       ff_start.date    = EVENT->start;
+                       ff_end.date      = EVENT->end;
+                       //ff_recur.text   = strcopy(EVENT->recur);
                        form_show(&form_event);
                        break;
                case EDIT_TODO:
-                       ff_name.text   = strcopy(TODO->name);
-                       ff_desc.text   = strcopy(TODO->desc);
+                       ff_name.text     = strcopy(TODO->name);
+                       ff_desc.text     = strcopy(TODO->desc);
                        ff_status.number = TODO->status;
-                       //ff_cat.text    = strcopy(TODO->cat);
-                       ff_start.date  = TODO->start;
-                       ff_due.date    = TODO->due;
-                       //ff_recur.text = strcopy(TODO->recur);
-                       debug("ical_edit - todo");
+                       ff_cat.text      = strcopy(TODO->cat);
+                       ff_start.date    = TODO->start;
+                       ff_due.date      = TODO->due;
+                       //ff_recur.text   = strcopy(TODO->recur);
                        form_show(&form_todo);
                        break;
        }
index cb2a75add7348591239164ea7598f18a810c0e37..4284eafd3be4908a2cd7019f4ee4ae037cd79f67 100644 (file)
 #include <ncurses.h>
 
 #include "date.h"
+#include "cal.h"
+#include "view.h"
 #include "form.h"
 
 /* Constants */
-#define TEXT_WIDTH   (20)
-#define NUMBER_WIDTH (10)
 #define DATE_WIDTH   (4+1+2+1+2 +1+ 2+1+2)
+#define TEXT_WIDTH   (DATE_WIDTH)
+#define NUMBER_WIDTH (10)
 
 /* Widget accessors */
 #define FF_TEXT(f)   (((form_text_t  *)f)->text)
@@ -124,11 +126,13 @@ static void field_draw(form_field_t *field, int width, int hover)
 
        int boxed    = field->type == FORM_TEXT ||
                       field->type == FORM_NUMBER;
+       int bold     = field->attr.bold;
        int under    = 0;
 
        int begin    = getcurx(win);
        int maxstr   = width - strlen(before) - strlen(after);
 
+       if (bold)   wattron(win, A_BOLD);
        if (hover)  wattron(win, A_REVERSE);
        if (under)  wattron(win, A_UNDERLINE);
        if (boxed)  waddch(win, '[');
@@ -172,6 +176,7 @@ static void field_draw(form_field_t *field, int width, int hover)
        if (boxed)  waddch(win, ']');
        if (under)  wattroff(win, A_UNDERLINE);
        if (hover)  wattroff(win, A_REVERSE);
+       if (bold)   wattroff(win, A_BOLD);
 }
 
 static int is_active(form_t *form, int r, int c)
index de292a72052bdf74c67d5154cf5493f0ed115f8c..bfcf641ef6d4752c26e3104971d42956f34a28d0 100644 (file)
@@ -23,7 +23,8 @@
 #define LIST(k,...)    {.f.type=FORM_LIST,   .f.hotkey=k, __VA_ARGS__}
 
 #define HEAD(t,...)    &(form_field_t){.type=FORM_LABEL, .label=t, .attr.bold=1}
-#define LABEL(t,...)   &(form_field_t){.type=FORM_LABEL, .label=t}
+#define LABEL(t,...)   &(form_field_t){.type=FORM_LABEL, .label=t, .after="  "}
+#define TAB            &(form_field_t){.type=FORM_LABEL, .label="    "}
 
 #define CHECK(t,...)   {.f.type=FORM_BUTTON, .f.label=t}
 #define TOGGLE(t,...)  {.f.type=FORM_BUTTON, .f.label=t}