194 Commits

Author SHA1 Message Date
Lukas Fleischer
ef961f4927 Remove unused function mystrtol()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-01-30 15:39:58 +01:00
Lukas Fleischer
e492ac6f95 Add hidden key handler window
After BUG#6 had apparently been closed with the screen locks introduced
in commit a80f8dcf2c6eb3b54658218bc081ee9694204dd5, some people still
had problems with random characters appearing in the notification bar.
This was obviously caused by wgetch() refreshing the screen if the
status panel was changed. From wgetch(3):

    If the window is not a pad, and it has been moved or modified since
    the last call to wrefresh, wrefresh will be called before another
    character is read.

Since the wgetch(3) isn't thread-safe, there were race conditions
between the notification bar thread drawing to the notification bar and
wgetch() updating the screen. Introduce a (hidden) window that handles
all key presses and never gets changed in order to avoid this.

Also, call wins_wrefresh() explicitly in status_mesg(), since we can no
longer rely on wgetch() updating windows automatically.

Fixes reopened BUG#6. Note that this is a hotfix -- FR#26 has been
opened to ensure we fix this properly in the next major release.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-16 02:27:36 +01:00
Lukas Fleischer
a91fd72641 Merge branch 'maint' 2012-11-29 11:34:00 +01:00
Lukas Fleischer
8ae75f3ca7 Ignore signals during command execution
Disable signal handlers in wins_prepare_external() and reactivate them
in wins_unprepare_external().

Before, it was possible that resizing the window during editor/pager
mode resulted in the calcurse main screen appearing on top.

Addresses BUG#9.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-28 21:49:02 +01:00
Lukas Fleischer
9a6b875b1d io_check_*()/io_file_exist(): Fix signatures
This was broken in commit 87fb8cfec0d8e8fc901746095458bd316314b6ee. Fix
function signatures and update all invocations accordingly.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-26 01:49:04 +01:00
Lukas Fleischer
4d0c095947 Add compact panels support
Add a configuration option that allows for switching to compact panel
mode. In this mode, all window labels are hidden, so that there's more
space for actual information.

This patch doesn't add a configuration menu entry and doesn't add any
documentation.

Implements FR#7.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-25 18:33:29 +01:00
Lukas Fleischer
660eef88e4 Add configuration option to set a default panel
This allows for customizing the panel that is selected by default when
calcurse is started.

Note that this patch doesn't add any documentation. Also, this
configuration option currently cannot be configured using the
configuration menu.

Implements FR#19.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-25 18:13:37 +01:00
Lukas Fleischer
69b5293c87 Remove wins_slctd_init()
We only call this once. Remove the wrapper and directly call the wrapped
function instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-25 18:07:40 +01:00
Lukas Fleischer
1f0f05ecc1 Merge branch 'maint'
Conflicts:
	src/day.c
	src/recur.c
2012-11-23 19:03:57 +01:00
Lukas Fleischer
0ea23c24bf Release screen mutex if thread dies
We did not setup a thread cleanup procedure which resulted in calcurse
freezing if a thread tried to draw on the screen after another thread
was canceled while locking the screen.

Note that this kind of cleanup handlers should be added to other mutexes
as well. This patch just removes the most common case of triggering a
deadlock.

Also note that we cannot move pthread_cleanup_push() and
pthread_cleanup_pop() into the locking/unlocking functions since both
pthread_cleanup_push() and pthread_cleanup_pop() may be implemented as
macros that must be used in pairs within the same lexical scope.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-23 11:12:08 +01:00
Lukas Fleischer
a80f8dcf2c Lock screen when drawing on the calendar/notification panel
Lock the screen if either the calendar panel or the notification bar is
updated to avoid race conditions.

Addresses BUG#6.

Note that we currently always use a screen-level lock, even if only one
window is affected. This is to be changed in the future.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-23 11:12:08 +01:00
Lukas Fleischer
e16ac0a8a8 Do not display a mark when files are auto-saved
This is kind of useless since users are not able to react to an
auto-save notification. It also causes all kinds of problems if the
status bar is in a non-standard mode (message, prompt, ...) and is prone
to race conditions if the status bar is updated by another thread at the
same time.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-23 11:12:04 +01:00
Lukas Fleischer
7733d52f32 Use status_ask_choice() for the export dialog
Remove the export bar and use a simple status_ask_choice() dialog
instead. This reduces code complexity and replaces another unnecessary
menu by the well-tested dialog feature that is used everywhere else.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-18 22:57:09 +01:00
Lukas Fleischer
0f20693b07 Remove the erase flag and legacy deletion code
This is no longer needed. Note removal, as well as exception handling,
have been moved to separate functions and the cut feature has been
merged into the deletion function.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-07 21:40:56 +02:00
Lukas Fleischer
13c21ac280 Merge cut/delete
Remove the cut function and merge it into the del-item command. This
allows for vim-style cutting/pasting.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-07 21:39:35 +02:00
Lukas Fleischer
88588ad704 Refactor exception handling
Remove the exception handling code from recur_*_erase() and move it to
separate functions recur_*_add_exc(). Create a wrapper function
day_item_add_exc() that can be used to add an exception to generic
items.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-07 21:36:38 +02:00
Lukas Fleischer
7fb25a84d4 Refactor note removal
Remove the note removal code from *_delete()/*_erase() and create a new
wrapper function called day_item_erase_note() that is be used to drop
the note being associated to an item.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-07 21:35:02 +02:00
Lukas Fleischer
69345edd77 Add support for copy/paste registers
This adds support for vim-style copy/paste registers which allows
cutting and copying multiple items without having to overwrite the
copy/paste buffer. Registers can be specified using the quote key ('"').
To access a register, type '"x' before a command where "x" is the name
of a register. If you want to copy the currently selected item into
register 1, type '"1c'.

Valid registers are 0-9, a-z, "-" and "_". Note that the latter is the
so-called black hole register, which works similar to the black hole
register in vim.

The register prefix key is currently hardcoded and cannot be configured.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-07 21:27:01 +02:00
Lukas Fleischer
dd059ca812 Add a key binding for generic-copy
This finally adds full copy-paste support. Implements FR#15.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-06 01:59:24 +02:00
Lukas Fleischer
a3cf63b374 Add interact_day_item_copy()
This can be used to copy an item, so that it can be pasted somewhere
else later.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-06 01:59:01 +02:00
Lukas Fleischer
3b259b5620 Add day_item_fork()
Add a new function that can be used to copy one day item into another,
cloning the actual item that is linked.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-06 01:55:40 +02:00
Lukas Fleischer
a1394e9833 Refactor *_dup()
* Actually duplicate an item instead of copying data only.
* Properly clone an item without a note.
* Mark *_dup() public.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-06 01:54:09 +02:00
Lukas Fleischer
1c53c9d8c3 Revise todo_delete_note_bynum()
Pass an item instead of passing a list item index (analogous to commit
02c90ba53a658686bad5cb5f88c555d9eef06399).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-04 08:46:41 +02:00
Lukas Fleischer
3f1359cdeb Remove unused function day_item_nb()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-04 08:46:41 +02:00
Lukas Fleischer
7a75415a61 Implement a cache for the monthly view
Add a very simple cache, which is used to store the days that contain an
event or an appointment. This makes redrawing and browsing the calendar
panel much faster.

The cache has a size of 31 integers (which is equivalent to 124 bytes on
a 32 bit system and 248 bytes on a 64 bit system) and invalidates itself
if the current month has changed. If an item is added/changed/removed,
the cache needs to be invalidated manually by calling
calendar_monthly_view_cache_set_invalid(). Note that this will always
invalidate the whole cache, even if only one item at the last day of the
month was removed. This is a trade-off between simplicity and
efficiency.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:36 +02:00
Lukas Fleischer
81d97315c7 Remove unneeded parameter/return value
The item type parameter/return value no longer needs to be
passed/returned to interact_day_item_{paste,cut}(), since the type
descriptor is saved when cutting an item now.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:36 +02:00
Lukas Fleischer
6907ae73e7 Revise cut/pasting
Instead of calling type-specific duplication handlers and inserting
clones of the original items when pasting, save the generic day item and
remove the actual item from the linked list, so that it can be inserted
anywhere else later.

The cut/paste buffer is moved to the interaction unit, item-specific cut
operations are changed to remove the item from the linked list only
instead of copying and freeing it. An item is only freed if another item
is cut before the current cut/paste buffer is pasted. All paste
operations are changed and reinsert the actual item instead of creating
a clone.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:36 +02:00
Lukas Fleischer
b230e2949e Make *_free() public
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:36 +02:00
Lukas Fleischer
47d5fe2d45 Move apoint_{cut,paste}() to interaction unit
These functions get the current selection, call day_*_item() and fix the
current selection on the appointment panel, so move them where they
belong.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:36 +02:00
Lukas Fleischer
44d3c96828 Remove "appt_pos" member from day items
This is no longer used and removing it saves a few bytes per item.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:36 +02:00
Lukas Fleischer
954e3fd8ee Add an item parameter to various todo_*() functions
These functions operate on arbitrary items. Pull out the code that gets
the currently selected item, get the current selection when one of the
functions is called and pass it as a parameter.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:36 +02:00
Lukas Fleischer
318e685ffe Add an item parameter to various day_*() functions
These functions operate on arbitrary items. Pull out the code that gets
the currently selected item, get the current selection when one of the
functions is called and pass it as a parameter.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:35 +02:00
Lukas Fleischer
02c90ba53a Revise *_delete{,_bynum}()
Always pass an item instead of passing a date and a index. This makes
use of the NULL callback that was added with one of the previous
patches.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:35 +02:00
Lukas Fleischer
b8b6830dfd Allow passing more complex data to list callbacks
Change the data type of the "data" parameter from "long" to "void *" in
llist_find_*() signatures to allow for passing more complex objects.
Change all llist_find_*() invocations and callbacks accordingly.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:35 +02:00
Lukas Fleischer
8a85aaafa5 Rename interaction functions
Rename all interaction functions for the sake of consistency and add a
"interact_" prefix. Also, mark day_erase_item() static since it is not
used anywhere else.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:35 +02:00
Lukas Fleischer
9ed7494f5e Move interaction functions to a separate file
This is a first step to clean up several compilation units and separate
the front end from back-end operations. All functions that require user
interaction are moved to a new compilation unit "interaction.c". Also,
following things are adjusted to the new layout:

* Make day_item_get_*() and a few other functions public, so that it can
  be accessed from the new compilation unit.

* Use apoint_hilt(), todo_hilt(), etc. instead of directly accessing
  static variables.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:35 +02:00
Lukas Fleischer
ba28426fc0 Remove unused functions
Remove apoint_get(), event_get(), recur_get_apoint() and
recur_get_event(), since they are no longer used.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:35 +02:00
Lukas Fleischer
0504875219 Simplify apoint_switch_notify()
Pull out code from apoint_switch_notify() -- especially the fallback
routine that calls recur_apoint_switch_notify() if the currently
selected item is a recurrent item -- and move it to a wrapper function
day_item_switch_notify().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:35 +02:00
Lukas Fleischer
3763aa1ebf src/day.c: Add day_write_stdout()
This function allows for writing stored items to stdout in a fashion
similar to day_write_pad(). This will be used as a convenience wrapper
when switching to day_store_items() in non-interactive mode and also
allows for easily implementing a "pipe-day" feature.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:34 +02:00
Lukas Fleischer
244b6c927d Make day_store_items() public
Remove the "static" keyword from day_store_items(), so that it is
accessible from other compilation units. Also, allow for discarding the
event/appointment counters by passing NULL pointers and move the
"regex.h" header inclusion to "calcurse.h".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:34 +02:00
Lukas Fleischer
80e24954c2 Simplify recur_apoint_switch_notify()
Pass the recurrent appointment itself instead of passing a date and an
item number. This is quite simple as we can just pass the pointer that
is contained in the generic item structure and don't have to
LLIST_TS_FIND_*() the item first any more.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:33 +02:00
Lukas Fleischer
52bfc54333 Rework generic item container
Instead of copying all members of the individual item structures to a
generic structure containing all fields, create compulsory fields only
and set up a pointer to the actual item. This results in lower memory
footprint and lets us clean up some code.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 14:34:33 +02:00
Lukas Fleischer
82d86ad7c7 Fix compilation with NLS disabled
* src/utils.c: Only call setlocale() if NLS is enabled.
* src/calcurse.h: Define a fallback macro ngettext() if NLS is disabled.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-30 12:34:54 +02:00
Lukas Fleischer
cabc22e032 Add key bindings to go to the previous/next month/year
In addition to generic key bindings for moving one day (week)
forward/backward, define similar bindings for moving a month or a year.
Of course, count prefixes are allowed here as well.

Also add status bar hints and help texts.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-13 00:12:32 +02:00
Lukas Fleischer
42c486d30d Rename displacement enumeration elements
* Rename "LEFT" to "DAY_PREV", "RIGHT" to "DAY_NEXT", "UP" to
  "WEEK_PREV" and "DOWN" to "WEEK_NEXT" to reflect the semantics of
  these operations. Remove the unneeded "MOVES" element.

* Reorder code to improve consistency.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-13 00:12:27 +02:00
Baptiste Jonglez
2c5235cca7 Make appearance.calendarview more explicit in config file
Instead of using 0 or 1 as a value for `appearance.calendarview`,
introduce the more explicit "monthly" and "weekly".

Also update `scripts/calcurse-upgrade.sh` to reflect the change.

Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-31 20:45:42 +02:00
Baptiste Jonglez
9adacec623 Provide an array of available date input formats
This will allow to fix the current hardcoding of strings describing
date input formats in multiple places.

Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-31 20:42:23 +02:00
Baptiste Jonglez
9e1185f526 Give a meaning to DATE_FORMATS
It's a bit weird to consider DATE_FORMATS as part of the date input
format enum, all the more so as it does not even represent the number
of available formats (since those are numbered from 1).

Turn DATE_FORMATS into the number of available date input formats.

Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-31 20:42:15 +02:00
Lukas Fleischer
cfd8ede2b3 Switch to Linux kernel coding style
Convert our code base to adhere to Linux kernel coding style using
Lindent, with the following exceptions:

* Use spaces, instead of tabs, for indentation.
* Use 2-character indentations (instead of 8 characters).

Rationale: We currently have too much levels of indentation. Using
8-character tabs would make huge code parts unreadable. These need to be
cleaned up before we can switch to 8 characters.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-21 10:13:05 +02:00
Lukas Fleischer
ce13b70c5a Allow passing additional parameters to shell_exec()
This allows for specifying multiple command line parameters to be passed
on to the command in a way similar to fork_exec(). This is useful if we
want to wrap editor or pager invocations in a shell.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-16 19:31:47 +02:00