summaryrefslogtreecommitdiffstats
path: root/src/custom.c
Commit message (Collapse)AuthorAgeFilesLines
* Key bindings for UTF-8 encoded charactersLars Henriksen2018-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Internally characters (keys) have two representations: integers and key names. Key names are characters strings, usually the name of the character; e.g., the character A has the representations 65 and "A", and the tab character the representations 9 and "TAB". The function keys_int2str() turns the integer representation of a key/character into the key name. For display purposes the key names are usually confined to have display width at most three. Some curses pseudo-keys have longer key names; e.g., the back-tab character is "KEY_BTAB". A long key name makes a character difficult to recognize in the status bar menu. The key name of a multibyte, UTF-8 encoded character is the conventional Unicode name of the code point; e.g., the character ü has key name "U+00FC" because ü is the code point 0xFC. Most of these look alike in the status bar menu. The patch makes the key name of a multibyte character look like that of a singlebyte character: the character itself, i.e. the key name of the character ü is "ü". The main tool is implementation of a utf8_encode() routine. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Properly NUL-terminate the day heading after editingLukas Fleischer2018-05-261-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Scrollbar and right window border (corrected)Lars Henriksen2018-05-261-5/+5
| | | | | | | | | | | | | | | | | When a scrollbar is on display in APP or TOD windows, the right vertical border (outside the scrollbar) is not highlighted when the window is selected. The scrollbar is always highlighted: - when APP or TOD is deselected - in configuration windows where borders otherwise are not The patch moves the scrollbar parameters (except highlight) from arguments of draw_scrollbar() to the function itself. The highlight argument was 1; instead it is set higher in the call hierarchy (wins_update_panels()) and passed on down. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Transparent cursor fixLars Henriksen2018-05-261-6/+5
| | | | | | | | | | | | | Commit f8e6e0d (Fix no-colour theme, 2017-12-10) partly destroyed the cursor in getstring() by turning it into a solid block. The fix reintroduces wchgat() which requires a color pair argument. When no colors are wanted, color pair 0 is used. A similar problem exists in the layout and colour customization windows and is fixed in the same way: move to the position and apply the reverse video attribute. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Use dummy variables to ignore return values of pair_content()Lukas Fleischer2018-05-101-2/+2
| | | | | | | | 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>
* Default colour as foreground colourLars Henriksen2017-12-101-3/+12
| | | | | | | | | | | | | 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>
* Function cleanup in custom.cLars Henriksen2017-11-231-39/+39
| | | | | | | 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>
* Fix multiple popup windowsLars Henriksen2017-10-291-11/+7
| | | | | | | | | | 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>
* Remove recognized keys checkLars Henriksen2017-10-261-36/+12
| | | | | | | 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>
* Updates for UTF-8 key bindingsLars Henriksen2017-10-231-6/+12
| | | | | | | | | | | | | | | | | | | | | 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>
* Make the day heading position configurableLars Henriksen2017-09-081-1/+23
| | | | | | | | | 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>
* Replace remaining uses of wgetch() by keys_wgetch()Lukas Fleischer2017-09-031-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add a function to wait for any key pressLukas Fleischer2017-09-031-1/+1
| | | | | | | 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>
* Improve default selection when editing key bindingsLukas Fleischer2017-09-031-4/+4
| | | | | | | | 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>
* Use strncpy() properly in general_option_edit()Lukas Fleischer2017-09-031-6/+8
| | | | | | | 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>
* Add support for UTF-8 key bindingsLukas Fleischer2017-08-301-2/+2
| | | | | | | | | | | | | | | | 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>
* Rename keys_getch() to keys_get()Lukas Fleischer2017-08-301-27/+22
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Remove some leftovers from the pastLars Henriksen2017-08-281-7/+0
| | | | | Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Make heading in appointments panel configurableLars Henriksen2017-08-281-1/+19
| | | | | | | | 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>
* Make the selected day in the calendar stand outLars Henriksen2017-08-281-1/+1
| | | | | Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix segmentation fault when changing colorsLukas Fleischer2017-07-281-3/+3
| | | | | | | | | | | | | | | | 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>
* Update copyright rangesLukas Fleischer2017-01-121-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Always use memory management wrappersLukas Fleischer2016-10-131-1/+1
| | | | | | | Use mem_*() wrappers instead of directly accessing libc functions when allocating/deallocating memory. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2016-01-301-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* custom.c: Display missing optionsLukas Fleischer2016-01-071-2/+2
| | | | | | | | 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>
* Support resize in all configuration menusLukas Fleischer2015-02-231-0/+25
| | | | | | | Add missing resize support in the configuration main menu and in the key bindings menu. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright rangesLukas Fleischer2015-02-071-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Make compact mode and default panel configurableLukas Fleischer2014-08-031-33/+68
| | | | | | | | | 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>
* Replace several uses of snprintf() by asprintf()Lukas Fleischer2014-07-221-2/+3
| | | | | | | | 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>
* Small code cleanupsLukas Fleischer2014-07-181-2/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use wins_set_bindings() for the configuration menuLukas Fleischer2014-07-181-34/+25
| | | | | | | Make use of the general key binding context switching implementation for the configuration main menu. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Initialize prompt buffers in the configuration menusLukas Fleischer2014-07-181-1/+4
| | | | | | | | 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>
* Rework key binding context switchingLukas Fleischer2014-07-171-50/+20
| | | | | | | Store key binding contexts using another data structure to optimize space usage and execution time. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Reintroduce key bindings in configuration menusLukas Fleischer2014-07-171-2/+14
| | | | | | | | | | 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>
* Resize panels properlyLukas Fleischer2014-05-191-1/+1
| | | | | | | 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>
* Add support for caption rows in list boxesLukas Fleischer2014-05-181-2/+7
| | | | | | | 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>
* Add support for drawing highlighted decorationLukas Fleischer2014-05-181-3/+3
| | | | | | | This allows for drawing selected scroll windows and list boxes with a highlighted border. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* custom.c: Simplify codeLukas Fleischer2014-05-181-10/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove numbers and whitespace from option menusLukas Fleischer2014-05-181-20/+20
| | | | | | | These are no longer needed since items are no longer accessed via numeric keys. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Reduce flicker when resizing in option menusLukas Fleischer2014-05-181-1/+1
| | | | | | | 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>
* Use generic list box for general optionsLukas Fleischer2014-05-181-156/+187
| | | | | | | | | 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>
* Rework scroll window implementationLukas Fleischer2014-05-181-41/+19
| | | | | | | | | | 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>
* Drop legacy online help systemLukas Fleischer2013-07-171-39/+0
| | | | | | | | | | 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>
* Use a macro to determine the size of arraysLukas Fleischer2013-05-041-4/+4
| | | | | | | | 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>
* Use tabs instead of spaces for indentationLukas Fleischer2013-04-141-908/+961
| | | | | | | | | | | 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>
* Fix braces in if-else statementsLukas Fleischer2013-02-171-7/+10
| | | | | | | | | | 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>
* calendar.c: Rename to "ui-calendar.c"Lukas Fleischer2013-02-141-2/+2
| | | | | | | | | 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>
* Merge branch 'maint'Lukas Fleischer2013-02-041-1/+7
|\
| * Update copyright rangesLukas Fleischer2013-02-041-1/+1
| | | | | | | | | | | | | | 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>
| * Close key binding window when reassigning the same keyMichael Smith2013-02-041-0/+6
| | | | | | | | | | | | | | | | | | | | 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>