summaryrefslogtreecommitdiffstats
path: root/src/wins.c
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright ranges for 2022Lukas Fleischer2022-03-111-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fixed sidebar config sometime not increasing widthMorgan Seltzer2021-08-071-1/+1
| | | | | | | | | | | | | | The sidebar has a numerical mimumum width that is statically defined, and users may set the width of the sidebar in config by incrementing the percentage of the screen between this minimum and a maximum value of 50%. However, internally the mimimum percentage could be set as low as zero, and while that did not decrease the sidebar size below the numerical minimum width, did mean that between 0 and the mimimum width increasing the percentage had no visual effect to indicate change. Now the mimimum percent is not decremented below the mimimum width. Signed-off-by: Morgan Seltzer <MorganSeltzer000@gmail.com> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add generic-prev-view key bindingAurora2021-04-111-0/+12
| | | | | | | This can be used to cycle backwards through windows (similarly to generic-change-view). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Call setsid() for hook/notification commandsLukas Fleischer2021-04-041-1/+1
| | | | | | | | | We do not want hook or notification commands to interact with the terminal in any way. Create a new session for them. Addresses GitHub issue #326. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add parameter to redirect stderr to shell_exec()Lukas Fleischer2021-04-041-2/+2
| | | | | | | Add a function parameter to allows redirecting stderr in addition to stdin and stdout. The parameter will be used with a follow-up change. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* docs: fix simple typo, mulitple -> multipleTim Gates2020-12-191-1/+1
| | | | | | | | There is a small typo in src/wins.c. Should read `multiple` rather than `mulitple`. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Revert "Interrupt periodic save when launching process"Lars Henriksen2020-07-261-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 0f3d198 (Interrupt periodic save when launching process, 2017-09-08). Stopping and starting periodic save when external/hook programs are run causes deadlocks. The periodic save thread cannot be stopped/started at will, but should be started once and run uninterrupted as long as calcurse runs. Only if the configuration parameter is changed, must the thread be stopped and possibly restarted. The reasons are - the start routine unconditionally starts a thread. - the mechanism used to detect whether a thread is running or not, is designed to be used by the main calcurse thread only and with only one running thread of each kind (the thread ID of each running thread is kept in a variable; if the thread is not running, the variable has the main thread ID as value). Any load hook will be run at the initial dataload, and the stop/start calls will start a perodic save thread (this is true for the notify thread as well). Later when threads are started, a second periodic save thread is started (for the notify thread, a running thread is stopped before restart). When hooks are run by the periodic save thread, the stop call breaks down, leading to two running save threads (if not the case already) and subsequently to a deadlock when one thread tries to stop the other. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2020-01-301-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Refactor listbox codeLars Henriksen2019-05-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | The changes are related to the selected item and the visible lines in the scroll window viewport. In particular, the function listbox_fix_visible_region() has been eliminated, and functions previously only called by it have been removed. It performed several tasks that are now elsewhere. One was removed in an earlier commit (scroll window pad improvement). The task of making a multi-line item visible has been moved to listbox_item_in_view(). The task of making a caption line above a text line visible is listbox specific (for the ap_list) and will be moved to ui_day_sel_move(), where it is needed. Boundary checks for the listbox selection have been moved to listbox_fix_sel(). For future use listbox_sel_move() returns success or failure. The function wins_scrollwin_ensure_visible() has been renamed wins_scrollwin_in_view(). Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Improve scroll window padLars Henriksen2019-05-221-14/+13
| | | | | | | | | | | | | | | | | | | A scroll window consists of a pad to write on, and a window through which to view the pad, the viewport. The pad may change in size when new contents are loaded into the scroll window. If so, the pad size is set with wins_scrollwin_set_linecount(). But the offset into the pad (the top line to be displayed in the viewport) is not adjusted, although it may not be appropriate for the new pad size. The same is the case when a scroll window is resized and the viewport changes size. This is probably the cause of the problem solved by commit 0b46ad4, Avoid blank space after the last list box item, and the fix has been removed. The wins_scrollwin_set_linecount() has been renamed wins_scrollwin_set_pad() and sets size as well as offset. The offset is only changed if necessary. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix window update after hook executionLars Henriksen2018-10-211-1/+0
| | | | | | | | | | | | | | | | | | | | The introduction of hooks raised a problem with window updates. The diagnosis in commit feb059e8 (Fix segmentation fault on reload with pre-load hook) was right, the cure was wrong. The problem is wins_update(), not the listbox contents. The wins_update() call does not belong in wins_unprepare_external() (or in io_reload_data()), but at a higher level. It should be called _after_ reload, as indeed it is in key_generic_reload() when the listbox contents have been updated (todo as well as appointments). The call was introduced in commit 8ae75f3 without comment. The todo updates in io_reload_data() also belong in key_generic_reload() where they were before commit 7f06c252. When saving data, all panels must be updated in case a hook was executed. Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Scrollbar and right window border (corrected)Lars Henriksen2018-05-261-4/+4
| | | | | | | | | | | | | | | | | 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>
* Fix no-colour themeLars Henriksen2017-12-101-2/+2
| | | | | | | | | | | | | In colour customization, pressing cancel ('ESC' by default) will deselect all colours and put calcurse in no-color mode. For this to work, all colour changes must be performed with the routines custom_apply_attr()/custom_remove_attr(). Fixed for the getstring cursor, the scroll window border and the week number. In addition, the week number is unconditionally coloured as the rest of the calendar contents whether CAL is selected or not. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Scrollbar and right window borderLars Henriksen2017-12-101-14/+21
| | | | | | | | | | | | | | | | | | | 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 itself is always highlighted: - when APP or TOD is deselected - in configuration windows where borders otherwise are not The patch moves the scrollbar parameters from arguments of draw_scrollbar() to the function itself. The highlight argument to draw_scrollbar() was always 1. Instead call circumstances are figured out and highlight set accordingly. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Remove unused argument from wins_other_status_pageLars Henriksen2017-11-031-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix multiple popup windowsLars Henriksen2017-10-291-0/+11
| | | | | | | | | | 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>
* Interrupt periodic save when launching processLukas Fleischer2017-09-081-0/+4
| | | | | | | | To avoid interactions between the periodic save thread and external processes, stop the periodic save thread before launching an external program and restart the thread as soon as the program is terminated. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2017-01-121-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Fix key binding paginationLukas Fleischer2016-09-271-5/+18
| | | | | | | | | | Do not create an empty key bindings page if the number of bindings is a multiple of the number of slots per page. Also, add comments to explain the computation. Reported-by: Kevin Wang <kevin.wang2004@hotmail.com> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2016-01-301-1/+1
| | | | Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add a "hide completed" view to the todo panelLukas Fleischer2016-01-181-0/+1
| | | | | | Add a second view to the todo panel that hides all completed items. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2015-02-071-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Rework key binding context switchingLukas Fleischer2014-07-171-68/+46
| | | | | | | Store key binding contexts using another data structure to optimize space usage and execution time. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Split out code to set bindingsLukas Fleischer2014-07-171-16/+26
| | | | | | | | 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>
* wins.c: Drop NB_*_CMDSLukas Fleischer2014-07-171-28/+11
| | | | | | | 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>
* Refactor wins_launch_external()Lukas Fleischer2014-07-161-18/+1
| | | | | | | | 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>
* Allow for merging data files when reloadingLukas Fleischer2014-07-161-0/+16
| | | | | | | | 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>
* Add a key binding to reload appointments and todosLukas Fleischer2014-07-161-24/+18
| | | | | | | This allows for reloading the appointment and todo item files without having to restart calcurse. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Avoid blank space after the last list box itemLukas Fleischer2014-05-191-0/+12
| | | | | | | 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>
* Resize panels properlyLukas Fleischer2014-05-191-13/+19
| | | | | | | 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/+4
| | | | | | | 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>
* Remove unused functions border_{,no}color()Lukas Fleischer2014-05-181-41/+0
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* ui-day: Large-scale refactoringLukas Fleischer2014-05-181-19/+9
| | | | | | | | | | 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>
* ui-calendar: Use scroll window implementationLukas Fleischer2014-05-181-11/+8
| | | | | | | | | 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>
* ui-todo: Large-scale refactoringLukas Fleischer2014-05-181-12/+8
| | | | | | | 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>
* Add support for drawing highlighted decorationLukas Fleischer2014-05-181-2/+9
| | | | | | | This allows for drawing selected scroll windows and list boxes with a highlighted border. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Reduce flicker when resizing in option menusLukas Fleischer2014-05-181-1/+7
| | | | | | | 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>
* Rework scroll window implementationLukas Fleischer2014-05-181-31/+84
| | | | | | | | | | 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>
* Pass date parameter to ui_day_update_panel()Lukas Fleischer2014-05-131-1/+1
| | | | | | | This allows for drawing appointment panels for days other than the current day. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add command promptLukas Fleischer2013-07-171-3/+4
| | | | | | | | | | 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>
* Fix a couple of translatable stringsLukas Fleischer2013-05-141-1/+1
| | | | | | | | * 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>
* Use a macro to determine the size of arraysLukas Fleischer2013-05-041-6/+3
| | | | | | | | 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-377/+402
| | | | | | | | | | | 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-2/+2
| | | | | | | | | | 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-1/+1
| | | | | | | | | 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>
* todo.c: Split out UI-related functionsLukas Fleischer2013-02-141-1/+1
| | | | | | | * Move UI-related functions to "ui-todo.c". * Rename UI-related functions to ui_todo_*(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* apoint.c: Split out UI-related functionsLukas Fleischer2013-02-141-1/+1
| | | | | | | * Move UI-related functions to "ui-day.c". * Rename UI-related functions to ui_day_*(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* 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>
* Add hidden key handler windowLukas Fleischer2012-12-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* wins_show(): Fix size of the slave window arrayLukas Fleischer2012-12-061-1/+1
| | | | | | | | | | | 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>