153 Commits

Author SHA1 Message Date
Lukas Fleischer
1418e40793 Use dummy variables to ignore return values of pair_content()
This prevents from segmentation faults with recent ncurses
implementations. See commit 5722d2e (Fix segmentation fault when
changing colors, 2017-07-28) for details.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2018-05-10 14:05:43 +02:00
Lars Henriksen
e733d09ea0 Default colour as foreground colour
In the default colour setup (white on black), white could only
with great difficulty be used as customized foreground colour,
because the colour pair COLR_CUSTOM then was identical to
COLR_DEFAULT (default on default). This made it impossible to
distinguish the selected element in lists.

The patch turns on the video attribute bold when default is chosen
as foreground colour.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-12-10 14:33:31 +01:00
Lars Henriksen
97c3e7f957 Function cleanup in custom.c
Remove two remnants: custom_color_theme_name() and custom_set_swsiz().
Make static and rename custom_confwin_init() into confwin_init().

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-11-23 08:56:06 +01:00
Lars Henriksen
012a0e6670 Fix multiple popup windows
The window was not deleted if an "already in use"-key was detected,
and a new one was created as the loop was reentered.

Create/delete of the popup are moved outside the loop.
A redrawwin() call is needed to have the window displayed again.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-10-29 08:42:03 +01:00
Lars Henriksen
2b8d4e983f Remove recognized keys check
All keys known by ncurses can be bound. Thus the check for not
recognized keys in custom_keys_config() becomes superfluous.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-10-26 08:35:18 +02:00
Lars Henriksen
dd5af2f7f4 Updates for UTF-8 key bindings
Code point mapping adjusted for multibyte characters to avoid the
ncurses range 0-KEY_MAX.

This includes three fixes:

1) test sequence in keys_assign_binding(),
2) reassemble multi-byte character in keys_wgetch(),
3) check for already in use in keys_assign_binding().

Rearrangement of code. The introduction of allocated memory in
keys_int2str() has as a consequence that check for recognized ncurses
pseudo characters now are in two places: keys_str2int() and
custom_keys_config(). The latter was moved from keys_wgetch() to improve
user information.

More informative warning messages in custom_keys_config().

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-10-23 08:39:11 +02:00
Lars Henriksen
d20f9a5d2e Make the day heading position configurable
The date at the top of the appointments list may be positioned either to
the left, in the middle or to the right. Default is to the right. Can be
configured from the general options menu.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-08 21:08:53 +02:00
Lukas Fleischer
2e584f03e6 Replace remaining uses of wgetch() by keys_wgetch()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-03 16:37:35 +02:00
Lukas Fleischer
53f0f1d2e3 Add a function to wait for any key press
Introduce a new function keys_wait_for_any_key() and use it instead of
wgetch() whenever the return value is discarded.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-03 16:37:35 +02:00
Lukas Fleischer
8373ecfe51 Improve default selection when editing key bindings
When adding a new key binding, automatically select the new binding.
When removing a key binding, keep the selection index (unless the last
binding of a row is removed).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-03 15:51:01 +02:00
Lukas Fleischer
6521d8cc0a Use strncpy() properly in general_option_edit()
Always use strncpy() to copy strings between fixed-size buffers and pass
the buffer size as maximal length parameter.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-09-03 09:31:33 +02:00
Lukas Fleischer
578091f051 Add support for UTF-8 key bindings
A new function keys_wgetch() reads full UTF-8 characters instead of
single ASCII characters only.

Key bindings for regular ASCII characters are stored in a hash map while
the actions of keys with higher code points are stored in a linked list
for space efficiency.

The key serialization methods are updated to handle UTF-8 characters as
well; extended UTF-8 characters (characters not in the ASCII range) are
serialized by using the hexadecimal representation of the corresponding
code points (e.g. "U+00E4").

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-30 16:39:23 +02:00
Lukas Fleischer
8544e4a570 Rename keys_getch() to keys_get()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-30 16:26:10 +02:00
Lars Henriksen
e12875b420 Remove some leftovers from the past
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lars Henriksen
d56cc7acfe Make heading in appointments panel configurable
Add a new configuration variable format.dayheading to set the format of
the date displayed at the top of the event and appointment list.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lars Henriksen
0c63b4661f Make the selected day in the calendar stand out
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-08-28 07:30:38 +02:00
Lukas Fleischer
5722d2ea4c Fix segmentation fault when changing colors
The pair_content() function can be used to retrieve a color pair. The
foreground and the background color numbers are written to addresses
specified by the second and third parameters. While both parameters were
optional in older ncurses implementations (making it possible to pass
NULL pointers if the one does not care about either foreground or
background color), recent implementations seem to assume that both
parameters are valid pointers. Thus, instead of passing NULL, we need to
pass a pointer to a dummy variable when we do not care about the
background color.

Partly fixes GitHub issue #31.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-07-28 16:02:46 +02:00
Lukas Fleischer
9f6678bc49 Update copyright ranges
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2017-01-12 08:40:30 +01:00
Lukas Fleischer
9ef5fe2191 Always use memory management wrappers
Use mem_*() wrappers instead of directly accessing libc functions when
allocating/deallocating memory.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-10-13 19:51:43 +02:00
Lukas Fleischer
978d24a9d2 Update copyright ranges
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-30 11:21:53 +01:00
Lukas Fleischer
ddfe49d9fe custom.c: Display missing options
Also, determine the number of displayed options on the general
configuration screen automatically (statically) instead of hard-coding
the value to prevent from future fallouts.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2016-01-07 18:42:33 +01:00
Lukas Fleischer
dca7a32557 Support resize in all configuration menus
Add missing resize support in the configuration main menu and in the key
bindings menu.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-23 14:02:52 +01:00
Lukas Fleischer
9ef427693b Update copyright ranges
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2015-02-07 11:42:20 +01:00
Lukas Fleischer
c093fcdfbf Make compact mode and default panel configurable
Create configuration entries for these (currently undocumented) options
which were added in 4d0c095 (Add compact panels support, 2012-11-25) and
in 660eef8 (Add configuration option to set a default panel,
2012-11-24).

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-08-03 23:51:08 +02:00
Lukas Fleischer
21fc7a4b74 Replace several uses of snprintf() by asprintf()
Use asprintf() in some cold code paths. While allocating memory on the
heap is a bit slower, using asprintf() is a bit more memory efficient
and less prone to buffer overflow errors.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-22 11:47:14 +02:00
Lukas Fleischer
9d8d0c18b0 Small code cleanups
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 17:19:37 +02:00
Lukas Fleischer
919a40f561 Use wins_set_bindings() for the configuration menu
Make use of the general key binding context switching implementation for
the configuration main menu.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 10:26:36 +02:00
Lukas Fleischer
d0916ced78 Initialize prompt buffers in the configuration menus
malloc() does not make sure that the buffer is initialized to contain
all zeros. Initialize the buffer with the empty string.

Reported-by: Håkan Jerning <jerning@home.se>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-18 08:38:15 +02:00
Lukas Fleischer
76563c9b90 Rework key binding context switching
Store key binding contexts using another data structure to optimize
space usage and execution time.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 21:08:55 +02:00
Lukas Fleischer
7920e761c9 Reintroduce key bindings in configuration menus
The key bindings display in the status bar was removed from the general
options menu in bd182fb (Use generic list box for general options,
2014-05-13) and from the notification options menu in 5eea05a (Use
generic list box for notification options, 2014-05-13). Display the new
key bindings to use for navigation.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-07-17 09:08:46 +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
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
fbd0651615 custom.c: Simplify code
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:03:01 +02:00
Lukas Fleischer
7cf42c1083 Remove numbers and whitespace from option menus
These are no longer needed since items are no longer accessed via
numeric keys.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:02:59 +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
bd182fbb5e Use generic list box for general options
This changes the general options menu to use the new generic list box
implementation. The only user-visible change is that items are now
accessed via the arrow and edit key bindings instead of digits. This
also allows for easily adding more than 10 options to the menu.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2014-05-18 11:02:47 +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
20709b7a7e Drop legacy online help system
Remove the old online help system and change the generic help key to do
the same thing as ":help".

This also removes some context-sensitive help. We should think about
re-adding support for this later.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-07-17 14:03:53 +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
b30ccc6319 Merge branch 'maint' 2013-02-04 20:11:58 +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
Michael Smith
ce22b13a4d Close key binding window when reassigning the same key
This allows for canceling a key reassignment. We cannot use a static key
here since every key could potentially be used in a binding. Instead,
just cancel if we are trying to reassign a key that has already been
used for that action before.

Signed-off-by: Michael Smith <crazedpsyc@mail4us.net>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-04 20:06:09 +01:00
Lukas Fleischer
efa3589f78 custom.c: Fix sidebar configuration help text
* Use a format string instead of the TOSTRING() macro.
* Remove "xgettext:no-c-format" hack and use "%%" instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-01-30 15:38:13 +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
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
6139235488 src/custom.c: Mark sidebar help string "no-c-format"
This one was incorrectly detected as C format string due to the literal
percent sign ("%") contained in the message. Add a comment that
explicitly marks it as non-format string to avoid translation issues.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-06-01 00:03:58 +02:00