aboutsummaryrefslogtreecommitdiffstats
path: root/src/todo.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2013-02-14 11:03:10 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2013-02-14 11:08:03 +0100
commit971df8d215a0e10c87f67f3505345e15efcffb8e (patch)
tree23bcd368447b6f9580223acd563311f1393b4f77 /src/todo.c
parent601709b173d45394ded5027712959efce2fe862b (diff)
downloadcalcurse-971df8d215a0e10c87f67f3505345e15efcffb8e.tar.gz
calcurse-971df8d215a0e10c87f67f3505345e15efcffb8e.zip
todo.c: Split out UI-related functions
* Move UI-related functions to "ui-todo.c". * Rename UI-related functions to ui_todo_*(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/todo.c')
-rw-r--r--src/todo.c179
1 files changed, 0 insertions, 179 deletions
diff --git a/src/todo.c b/src/todo.c
index 015f43f..160e84a 100644
--- a/src/todo.c
+++ b/src/todo.c
@@ -41,10 +41,6 @@
#include "calcurse.h"
llist_t todolist;
-static int hilt = 0;
-static int todos = 0;
-static int first = 1;
-static char *msgsav;
/* Returns a structure containing the selected item. */
struct todo *todo_get_item(int item_number)
@@ -52,71 +48,6 @@ struct todo *todo_get_item(int item_number)
return LLIST_GET_DATA(LLIST_NTH(&todolist, item_number - 1));
}
-/* Sets which todo is highlighted. */
-void todo_hilt_set(int highlighted)
-{
- hilt = highlighted;
-}
-
-void todo_hilt_decrease(int n)
-{
- hilt -= n;
-}
-
-void todo_hilt_increase(int n)
-{
- hilt += n;
-}
-
-/* Return which todo is highlighted. */
-int todo_hilt(void)
-{
- return hilt;
-}
-
-/* Return the number of todos. */
-int todo_nb(void)
-{
- return todos;
-}
-
-/* Set the number of todos. */
-void todo_set_nb(int nb)
-{
- todos = nb;
-}
-
-/* Set which one is the first todo to be displayed. */
-void todo_set_first(int nb)
-{
- first = nb;
-}
-
-void todo_first_increase(int n)
-{
- first += n;
-}
-
-void todo_first_decrease(int n)
-{
- first -= n;
-}
-
-/*
- * Return the position of the hilghlighted item, relative to the first one
- * displayed.
- */
-int todo_hilt_pos(void)
-{
- return hilt - first;
-}
-
-/* Return the last visited todo. */
-char *todo_saved_mesg(void)
-{
- return msgsav;
-}
-
static int todo_cmp_id(struct todo *a, struct todo *b)
{
/*
@@ -207,116 +138,6 @@ static int todo_get_position(struct todo *needle)
return -1; /* avoid compiler warnings */
}
-/* Change an item priority by pressing '+' or '-' inside TODO panel. */
-void todo_chg_priority(struct todo *backup, int diff)
-{
- char backup_mesg[BUFSIZ];
- int backup_id;
- char backup_note[MAX_NOTESIZ + 1];
-
- strncpy(backup_mesg, backup->mesg, strlen(backup->mesg) + 1);
- backup_id = backup->id;
- if (backup->note)
- strncpy(backup_note, backup->note, MAX_NOTESIZ + 1);
- else
- backup_note[0] = '\0';
-
- backup_id += diff;
- if (backup_id < 1)
- backup_id = 1;
- else if (backup_id > 9)
- backup_id = 9;
-
- todo_delete(todo_get_item(hilt));
- backup = todo_add(backup_mesg, backup_id, backup_note);
- hilt = todo_get_position(backup);
-}
-
-/* Display todo items in the corresponding panel. */
-static void
-display_todo_item(int incolor, char *msg, int prio, int note, int width, int y,
- int x)
-{
- WINDOW *w;
- int ch_note;
- char buf[width * UTF8_MAXLEN], priostr[2];
- int i;
-
- w = win[TOD].p;
- ch_note = (note) ? '>' : '.';
- if (prio > 0)
- snprintf(priostr, sizeof priostr, "%d", prio);
- else
- strncpy(priostr, "X", sizeof priostr);
-
- if (incolor == 0)
- custom_apply_attr(w, ATTR_HIGHEST);
- if (utf8_strwidth(msg) < width)
- mvwprintw(w, y, x, "%s%c %s", priostr, ch_note, msg);
- else {
- for (i = 0; msg[i] && width > 0; i++) {
- if (!UTF8_ISCONT(msg[i]))
- width -= utf8_width(&msg[i]);
- buf[i] = msg[i];
- }
- if (i)
- buf[i - 1] = 0;
- else
- buf[0] = 0;
- mvwprintw(w, y, x, "%s%c %s...", priostr, ch_note, buf);
- }
- if (incolor == 0)
- custom_remove_attr(w, ATTR_HIGHEST);
-}
-
-/* Updates the ToDo panel. */
-void todo_update_panel(int which_pan)
-{
- llist_item_t *i;
- int len = win[TOD].w - 8;
- int num_todo = 0;
- int title_lines = conf.compact_panels ? 1 : 3;
- int y_offset = title_lines, x_offset = 1;
- int t_realpos = -1;
- int todo_lines = 1;
- int max_items = win[TOD].h - 4;
- int incolor = -1;
-
- if ((int)win[TOD].h < 4)
- return;
-
- /* Print todo item in the panel. */
- erase_window_part(win[TOD].p, 1, title_lines, win[TOD].w - 2, win[TOD].h - 2);
- LLIST_FOREACH(&todolist, i) {
- struct todo *todo = LLIST_TS_GET_DATA(i);
- num_todo++;
- t_realpos = num_todo - first;
- incolor = (which_pan == TOD) ? num_todo - hilt : num_todo;
- if (incolor == 0)
- msgsav = todo->mesg;
- if (t_realpos >= 0 && t_realpos < max_items) {
- display_todo_item(incolor, todo->mesg, todo->id,
- (todo->note != NULL) ? 1 : 0, len, y_offset, x_offset);
- y_offset = y_offset + todo_lines;
- }
- }
-
- /* Draw the scrollbar if necessary. */
- if (todos > max_items) {
- int sbar_length = max_items * (max_items + 1) / todos;
- int highend = max_items * first / todos;
- unsigned hilt_bar = (which_pan == TOD) ? 1 : 0;
- int sbar_top = highend + title_lines;
-
- if ((sbar_top + sbar_length) > win[TOD].h - 1)
- sbar_length = win[TOD].h - 1 - sbar_top;
- draw_scrollbar(win[TOD].p, sbar_top, win[TOD].w - 2,
- sbar_length, title_lines, win[TOD].h - 1, hilt_bar);
- }
-
- wnoutrefresh(win[TOD].p);
-}
-
/* Attach a note to a todo */
void todo_edit_note(struct todo *i, const char *editor)
{