97 Commits

Author SHA1 Message Date
Lukas Fleischer
6792a2e204 Split out code to set bindings
Split wins_status_bar() into wins_set_bindings(), wins_update_bindings()
and wins_status_bar(). This allows for using wins_set_bindings() to set
custom key bindings to be displayed.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 08:49:16 +02:00
Lukas Fleischer
33414c6fa1 wins.c: Drop NB_*_CMDS
Store the current number of commands in a static variable and drop the
NB_*_CMDS variables which we outdated anyway.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 08:41:36 +02:00
Lukas Fleischer
71234ec0bd Refactor wins_launch_external()
Allow for passing an arbitrary number of arguments. This also allows us
to remove wins_launch_external2() and use wins_launch_external() at all
call sites instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 23:53:30 +02:00
Lukas Fleischer
5aec540895 Allow for merging data files when reloading
This allows for merging the (unsaved) items with the items from the data
files when invoking the reload operation. To this end, an external merge
tool (defaults to vimdiff) is used.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 23:31:31 +02:00
Lukas Fleischer
6550591b08 Add a key binding to reload appointments and todos
This allows for reloading the appointment and todo item files without
having to restart calcurse.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-16 16:03:26 +02:00
Lukas Fleischer
0b46ad4faa Avoid blank space after the last list box item
Automatically scroll down the list box when resizing creates some blank
space below the list of items.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-19 21:43:27 +02:00
Lukas Fleischer
990897b2f0 Resize panels properly
Rewrite the panel resize code and remove the code that reinitializes the
caption and the selected item when the window is resized.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-19 10:54:50 +02:00
Lukas Fleischer
2a15531bb9 Add support for caption rows in list boxes
This adds support for rows that cannot be selected. Such rows can be
used for section headings and the like.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:07:27 +02:00
Lukas Fleischer
a5f3e53ce3 Remove unused functions border_{,no}color()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:07:27 +02:00
Lukas Fleischer
35314dfdeb ui-day: Large-scale refactoring
Use the generic list box implementation for the appointments panel. This
results in some major changes to how the items are printed.

Note that this temporarily removes the heading showing the POM and the
date as well as the separating line between events and appointments.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:06:43 +02:00
Lukas Fleischer
cf1565648b ui-calendar: Use scroll window implementation
Make use of the generic scroll window implementation for the calendar
view. Note that this is useful despite the panel not needing a scroll
bar, since the scroll window functions can be used to draw the panel
border and take care of relative positions.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:03:13 +02:00
Lukas Fleischer
655218b7df ui-todo: Large-scale refactoring
This is a complete overhaul of the TODO list user interface. The new
implementation uses the generic list box panel.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:03:10 +02:00
Lukas Fleischer
4210fdd38a Add support for drawing highlighted decoration
This allows for drawing selected scroll windows and list boxes with a
highlighted border.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:03:03 +02:00
Lukas Fleischer
05ba450c3b Reduce flicker when resizing in option menus
Do not update the main windows when resizing the terminal in the general
options menu or in the notification options menu.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:02:56 +02:00
Lukas Fleischer
7184da0fa3 Rework scroll window implementation
This complete rewrite of the scroll window implementation decouples
scroll windows from every other window abstraction layer we use. Note
that this leads to some code duplication. The long-term purpose of this
rewrite, however, is to eventually make every panel use scroll windows.
This makes for a huge cleanup of the UI code.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:02:32 +02:00
Lukas Fleischer
ca83e65696 Pass date parameter to ui_day_update_panel()
This allows for drawing appointment panels for days other than the
current day.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-13 15:10:47 +02:00
Lukas Fleischer
c4dae80dd2 Add command prompt
This adds support for vim-style command mode. The command mode can be
entered with pressing ":" (by default, the key binding is configurable).

Currently, no command is supported. Support for various commands will be
added later.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-07-17 14:03:53 +02:00
Lukas Fleischer
a3d43ead87 Fix a couple of translatable strings
* Remove space before punctuation.
* Use "TODO" instead of "ToDo".
* Strip some formats to make sure lines are <=80 characters wide.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-05-14 12:03:04 +02:00
Lukas Fleischer
ce93fa8adb Use a macro to determine the size of arrays
Use following macro instead of "sizeof(x) / sizeof(x[0])" everywhere:

    #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-05-04 20:32:26 +02:00
Lukas Fleischer
694d28eb78 Use tabs instead of spaces for indentation
This completes our switch to the Linux kernel coding style. Note that we
still use deeply nested constructs at some places which need to be fixed
up later.

Converted using the `Lindent` script from the Linux kernel code base,
along with some manual fixes.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-04-14 00:19:01 +02:00
Lukas Fleischer
a363cb9b91 Fix braces in if-else statements
From the Linux kernel coding guidelines:

    Do not unnecessarily use braces where a single statement will do.
    [...] This does not apply if one branch of a conditional statement
    is a single statement. Use braces in both branches.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-17 09:19:04 +01:00
Lukas Fleischer
806673dd9b calendar.c: Rename to "ui-calendar.c"
This unit belongs to the presentation layer -- rename the file
accordingly.

Also, rename calendar_*() to ui_calendar_*().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 11:08:03 +01:00
Lukas Fleischer
971df8d215 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>
2013-02-14 11:08:03 +01:00
Lukas Fleischer
601709b173 apoint.c: Split out UI-related functions
* Move UI-related functions to "ui-day.c".
* Rename UI-related functions to ui_day_*().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 10:43:40 +01:00
Lukas Fleischer
a7944d335e Update copyright ranges
Add 2013 to the copyright range for all source and documentation files.

Reported-by: Frederic Culot <frederic@culot.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-04 20:10:14 +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
599b01b06d wins_show(): Fix size of the slave window array
The slave window array was just big enough to hold a single element,
whereas two elements are written/accessed. Fix this off-by-one error in
the array declaration.

Note that this messed up the panel layout when using clang as a
compiler.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-06 20:20:30 +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
69d79b1c63 Replace switch block in layout calculation
Remove the huge layout switch block and use simple calculations instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-11-25 18:39:01 +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
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
8375e9a51b Use integers rather than floats everywhere
We don't need floating point precision if results are casted back to
integer. Instead, rearrange operations and do the integer division after
the multiplication.

Version numbers are terminating decimals anyway and can be stored using
two integers without losing any information.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-07-10 11:58:15 +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
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
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
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
49d6e19a6b src/wins.c: Run editor and pager in a shell
This allows for specifying an editor or a pager with additional command
line parameters, such as "vim -e". Instead of interpreting "vim -e" as
an executable file, we leave it to the shell to tokenize and parse the
editor command now.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-16 19:31:48 +02:00
Lukas Fleischer
6da787a5cc Declare several parameters/variables constant
Add the "const" keyword to parameters and variables that are never
modified. Most of these were spotted by "-Wwrite-strings".

We cast the second parameter to execvp() explicitly as it expects a
"char *const[]" where it should expect a "const char *const[]"
(according to the documentation, this is due to compatibility reasons).
This should be changed once we come up with a better solution.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-08 21:50:05 +02:00
Baptiste Jonglez
6f80d84d5e Various code cleanup
Remove obsolete bits of code that weren't thrown away by b5c1981;
simplify some others areas of the code.

Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-02 17:11:19 +02:00
Lukas Fleischer
c65ccb0e77 Use percentage-based width for the sidebar
Use percentage-based widths internally. This slightly impairs (user)
feedback but brings the sidebar configuration menu closer to the actual
configuration format (the user now configures percentage-based widths,
not absolute width values). As a bonus, the sidebar is now resized
automatically on each window resize (based on the percentage values).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-12 23:11:33 +02:00
Lukas Fleischer
c9aff6d213 Update copyright ranges
Add 2012 to the copyright range for all source and documentation files.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-26 14:38:16 +02:00
Lukas Fleischer
481cb5524f Do not strncpy() strings returned by gettext()
Translated strings returned by gettext() are statically allocated.
There's no need to copy them to a buffer, we can use the pointers
returned by gettext() instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-12 20:36:22 +01:00
Lukas Fleischer
b5c1981842 Revamp key bindings display
Refactor the logic inside keys_display_bindings_bar() and remove the
need to place the "show next page" key binding at the right positions.

This used to be a pain to maintain, since we always had to move key
bindings around when introducing a new key. Fix this by passing the
actual key bindings in an array and using a separate parameter for the
"show next page" key binding (which is automatically inserted at the
right places from now on).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-02 09:43:04 +01:00
Lukas Fleischer
6f01c7af97 Remove parentheses from return statements
No reason to use "return (x);" here. Refer to the GNU coding guidelines
for details. Created using following semantic patch:

    @@
    expression expr;
    @@

    - return (expr);
    + return expr;

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-02 19:38:38 +01:00
Lukas Fleischer
7cc6305588 Do not cast unused return values to void
A small style fix that removes all remaining "(void)" casts. Using these
isn't encouraged in GNU coding guidelines and doesn't serve a certain
purpose, except for satisfying a few static code analysis tools. We
already nuked some of these in previous patches, but this semantic patch
should fix what's left:

    @@
    identifier func;
    @@

    - (void)func (
    + func (
    ...);

Long lines were re-formatted manually.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-11-02 18:32:17 +01:00