aboutsummaryrefslogtreecommitdiffstats
path: root/src/io.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Add --list-imported command line optionLukas Fleischer2016-01-131-2/+2
| | | | | | | When this option is used together with -i/--import, the object identifiers of imported objects are printed to stdout. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add command line option to suppress dialogsLukas Fleischer2016-01-131-4/+4
| | | | | | | Implement a -q/--quiet command line option to disable system dialogs temporarily. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add an option to filter by object hashLukas Fleischer2016-01-131-2/+14
| | | | | | | | | Implement a new --filter-hash option to filter by object identifiers. Each object having an identifier that has the specified pattern as a prefix is matched. Patterns starting with an exclamation mark (!) are interpreted as negative patterns. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add pre-load and post-load hooksLukas Fleischer2016-01-101-0/+2
| | | | | | Potential use case: Synchronize data with some server before loading. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Add pre-save and post-save hooksLukas Fleischer2016-01-071-0/+4
| | | | | | | | | | | | | This adds support for hooks which are executed before/after saving calcurse data. Hooks can be placed under hooks/pre-save and hooks/post-save in the data directory and need to be executable. Potential use cases include: * Automatically commit any changes to the data files using a VCS. * Automatically sync with some sever component on data file changes. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
* Update copyright rangesLukas Fleischer2015-02-071-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Factor out item reload codeLukas Fleischer2014-10-101-0/+95
| | | | | | | Adds a new function io_reload_data() which can be used to reload all appointments and TODO items. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add io_load_data() wrapperLukas Fleischer2014-10-101-0/+7
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Retain comments in descriptions and config valuesLukas Fleischer2014-08-181-1/+1
| | | | | | | | | Comments should only be stripped if they start at the beginning of a line. We do not want to chop off an TODO item description or a configuration value. Reported-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add a grep modeLukas Fleischer2014-08-071-10/+22
| | | | | | | This allows for printing a subset of the items in the data files by using filters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io.c: Error out on non-existent calendar fileLukas Fleischer2014-08-061-38/+3
| | | | | | | | Show an error message and die if the user specified a non-existent custom calendar file. This fixes some random hangs when calcurse is used in non-interactive mode within scripts. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Allow for filtering TODO itemsLukas Fleischer2014-08-061-1/+17
| | | | | | | | | | | The item filters now apply to both appointments and TODO items. Also, add a new type mask "todo" and the following new filter options: * --filter-priority * --filter-completed * --filter-uncompleted Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add item filtersLukas Fleischer2014-08-061-5/+6
| | | | | | | | | | | | | | | | | This adds the following filter options that allow for restricting the set of items that are read from the appointments file: * --filter-type * --filter-start-from * --filter-start-to * --filter-start-after * --filter-start-before * --filter-end-from * --filter-end-to * --filter-end-after * --filter-end-before Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io.c: Remove superfluous space from messageLukas Fleischer2014-07-281-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Refactor new_tempfile()Lukas Fleischer2014-07-221-13/+20
| | | | | | | | Avoid preallocating buffers on the stack, use dynamic memory allocation instead. Also, change the semantics of new_tempfile() so that it returns the full name of the temporary file and fix all call sites. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Replace several uses of snprintf() by asprintf()Lukas Fleischer2014-07-221-35/+36
| | | | | | | | 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-18/+15
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not display dialog on periodic saveLukas Fleischer2014-07-181-1/+2
| | | | | | | | When periodic save is enabled, do not print the "The data files were successfully saved" dialog every time io_save_cal() is called. Reported-by: Håkan Jerning <jerning@home.se> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Only run the merge tool on files with differencesLukas Fleischer2014-07-171-0/+26
| | | | | | | If the backup file and the data file are equal, there is no need to run the merge tool. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Refactor wins_launch_external()Lukas Fleischer2014-07-161-2/+4
| | | | | | | | 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>
* Avoid cancelling the save thread during savingLukas Fleischer2014-07-161-4/+8
| | | | | | | Ensure that we never cancel the periodic save thread when it currently saves the configuration and data files. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Allow for merging data files when reloadingLukas Fleischer2014-07-161-6/+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>
* Warn when reloading with unsaved modificationsLukas Fleischer2014-07-161-0/+19
| | | | | | | Since the reload operation overwrites all changes, warn before reloading if there are unsaved modifications. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* ui-todo: Large-scale refactoringLukas Fleischer2014-05-181-4/+0
| | | | | | | 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>
* Display translated help pagesLukas Fleischer2013-08-271-0/+7
| | | | | | | Use an algorithm similar to gettext's locale resolution to find an appropriate translation to display. Fall back to the English version. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Rename io_file_exist{,s}()Lukas Fleischer2013-07-171-2/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix a couple of translatable stringsLukas Fleischer2013-05-141-3/+3
| | | | | | | | * 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 tabs instead of spaces for indentationLukas Fleischer2013-04-141-939/+1000
| | | | | | | | | | | 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-12/+17
| | | | | | | | | | 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>
* todo.c: Split out UI-related functionsLukas Fleischer2013-02-141-2/+2
| | | | | | | * Move UI-related functions to "ui-todo.c". * Rename UI-related functions to ui_todo_*(). 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>
* Properly skip spaces after exception listLukas Fleischer2013-02-011-2/+4
| | | | | | | Skip whitespace after obtaining the list of exceptions instead of skipping the next character unconditionally. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Display correct startup messagesLukas Fleischer2012-12-161-2/+2
| | | | | | | These messages have been swapped accidentally during refactoring. Regression introduced in 691f8a6015bafcf6ed4f99a3649d428fb7a8e915. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add hidden key handler windowLukas Fleischer2012-12-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix two enumeration types in function signaturesLukas Fleischer2012-12-061-1/+1
| | | | | | Spotted with clang and "-Wconversion". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io_load_keys(): Skip legacy entryLukas Fleischer2012-12-051-0/+5
| | | | | | | This binding was used pre-3.1.0. Simply ignore it and avoid showing a needlessly complicated error message. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io_check_*()/io_file_exist(): Fix signaturesLukas Fleischer2012-11-261-3/+3
| | | | | | | This was broken in commit 87fb8cfec0d8e8fc901746095458bd316314b6ee. Fix function signatures and update all invocations accordingly. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io.c: Several minor simplificationsLukas Fleischer2012-11-251-43/+31
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io_load_*(): Add line numbers to error messagesLukas Fleischer2012-11-231-12/+26
| | | | | | | | Currently, error messages for (syntax) errors do not contain any line number information. Add the file name and line number to allow users for easily locating any errors in the corresponding data files. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2012-11-231-25/+5
|\ | | | | | | | | | | Conflicts: src/day.c src/recur.c
| * Do not display a mark when files are auto-savedLukas Fleischer2012-11-231-22/+2
| | | | | | | | | | | | | | | | | | | | 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>
| * Replace localtime() with localtime_r()Lukas Fleischer2012-11-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Since the result of localtime() is stored in a statically allocated structure, data was overwritten when a context switch occurred during (or shortly after) the execution of localtime(), potentially resulting in critical data corruption. BUG#7 and BUG#8 are likely related. This patch converts all usages of localtime() with localtime_r(), which is thread-safe. Reported-by: Baptiste Jonglez <baptiste@jonglez.org> Reported-by: Erik Saule <esaule@bmi.osu.edu> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use status_ask_choice() for the export dialogLukas Fleischer2012-11-181-23/+0
| | | | | | | | | | | | | | | | 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>
* | Allow passing both "-D" and "-c"Lukas Fleischer2012-06-301-33/+37
|/ | | | | | | | | | This is particularly useful if one wants to use configuration and key bindings from a specific directory, while using an appointment file from somewhere else. "-c" has precedence over "-D". Also update the usage message, man page and documentation. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use mvwaddstr() instead of mvwprintw()Baptiste Jonglez2012-05-311-10/+10
| | | | | | | | | | | | | When we only want to display a string at a specific place of the screen, there's no need to use the more complex mvwprintw(), use mvwaddstr() instead. This should be slightly more efficient, and, above all, it prevents weird things to happen if our string contains a '%', being interpreted as an unwanted format string. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Switch to Linux kernel coding styleLukas Fleischer2012-05-211-864/+709
| | | | | | | | | | | | | | 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>
* Factorize boolean user prompting.Baptiste Jonglez2012-05-141-10/+2
| | | | | | | | | | | Introduce a new `status_ask_bool()` function, and use it where applicable. This greatly reduces code duplication, and will allow handling special events (resize, user escape) much more uniformely. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Declare several parameters/variables constantLukas Fleischer2012-05-081-13/+14
| | | | | | | | | | | | 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>
* Add prototypes for hash table functionsLukas Fleischer2012-04-211-0/+1
| | | | | | These can be generated dynamically using the HTABLE_PROTOTYPE macro. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Mark several functions staticLukas Fleischer2012-04-201-1/+1
| | | | | | | These are not needed outside of the corresponding compilation units. Spotted with "-Wmissing-prototypes". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>