aboutsummaryrefslogtreecommitdiffstats
path: root/src/calcurse.h
Commit message (Collapse)AuthorAgeFilesLines
...
* Extract config file handlers into a separate fileLukas Fleischer2011-12-091-2/+5
| | | | | | | | We used custom_load_conf() to load the configuration file and io_save_conf() to save configuration. Move these functions, including all helpers, to a central location. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print todo items to stdoutLukas Fleischer2011-11-141-0/+1
| | | | | | | | | | | | This goes in line with the other commits adding print_*() support. Following format specifiers are allowed: * p: Print the priority of the item * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/apoint.c: Remove apoint_recur_s2apoint_s()Lukas Fleischer2011-11-141-1/+0
| | | | | | | This one is hackish, obsolete and no longer used by any other function. Drop it! Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print recurrent items to stdoutLukas Fleischer2011-11-141-0/+3
| | | | | | | | | Add print_recur_apoint() and print_recur_event() helper functions to print recurrent items to stdout and use them everywhere. Currently, these are only wrapper functions to print_apoint() and print_event() that create temporary, non-recurrent items. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print events to stdoutLukas Fleischer2011-11-141-0/+1
| | | | | | | | | | | | | Add a flexible helper function print_event() and use it whenever we print events to stdout. This reduces the number of copy-pasted code and eventually allows for specifying custom format strings. Following format specifiers are supported: * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print appointments to stdoutLukas Fleischer2011-11-141-0/+1
| | | | | | | | | | | | | | | | | | Add a flexible helper function print_apoint() and use it whenever we print appointments to stdout. This reduces the number of copy-pasted code and eventually allows for specifying custom format strings. Following format specifiers are supported: * s: Print the start time of the appointment as UNIX time stamp * S: Print the start time of the appointment using the "hh:mm" format * d: Print the duration of the appointment in seconds * e: Print the end time of the appointment as UNIX time stamp * E: Print the end time of the appointment using the "hh:mm" format * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Removed unused parameter from apoint_sec2str()Lukas Fleischer2011-11-141-1/+1
| | | | | | This is no longer needed as of commit 2d89d336. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a global configuration variableLukas Fleischer2011-11-141-14/+15
| | | | | | | This is one of the few valid use cases for a global variable. No need to make it pseudo-local and pass it from one function to another. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2011-11-111-0/+3
|\ | | | | | | | | | | Conflicts: src/calcurse.h src/io.c
| * Do not hardcode paths to the default editor/pagerLukas Fleischer2011-10-041-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use "vi" instead of "/usr/bin/vi" and "less" instead of "/usr/bin/less". Hardcoding absolute paths is a bad idea: $ uname -rsv Linux 3.0-ARCH #1 SMP PREEMPT Tue Aug 30 07:32:23 UTC 2011 $ which less /bin/less The "$PATH" environment variable will almost always have a better idea of where these binaries are located. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Do not cast unused return values to voidLukas Fleischer2011-11-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Avoid unnecessary start time calculationsLukas Fleischer2011-10-211-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Rename recur_*_inday() to recur_*_find_occurrence() and use the new functions whenever we actually care about the start time of an occurrence. Reintroduce recur_*_inday() as wrappers to recur_*_find_occurrence() and pass NULL as start time buffer (which means "skip start time calculation"). Keep using these when we only want to know if a recurrent item belongs to a specific day but do not care about the actual start time. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Pass item durations to recur_item_inday()Lukas Fleischer2011-10-211-1/+2
| | | | | | | | | | | | | | | | Having item's durations eventually allows for better parsing of recurrent appointments as we might be interested in how many days are covered by a multi-day appointment. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Remove check_time()Lukas Fleischer2011-10-061-1/+0
| | | | | | | | | | | | | | Now that parse_time() and parse_duration() do all the validation work, this isn't used (nor needed) any longer. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Introduce parse_{time,duration}()Lukas Fleischer2011-10-061-0/+2
| | | | | | | | | | | | | | | | | | These helpers can be used in a fashion similar to parse_date(). In addition to check_time(), parse_time() and parse_duration() support short forms such as "23:" (instead of "23:00") and ":45" (instead of "00:45"). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/calcurse.h: Rework date manipulation constantsLukas Fleischer2011-10-061-5/+13
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Mark input string of parse_date() constLukas Fleischer2011-10-061-1/+1
| | | | | | | | | | | | | | We don't mess about with the date string here, so it should be declared const. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add count buffer to keys_getch()Lukas Fleischer2011-10-061-1/+1
| | | | | | | | | | | | | | | | Key commands can be prefixed with a natural number - keys_getch() will store this number in the buffer pointed to by the second parameter. Set this parameter to NULL to disable count prefixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add count parameter to *_{in,de}crease()Lukas Fleischer2011-10-061-6/+6
| | | | | | | | | | | | | | | | | | This allows for moving more than one item up/down. This currently isn't used anywhere but will be bound to a key with one of the following patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/calendar.c: Add a count parameter to calendar_move()Lukas Fleischer2011-10-061-1/+1
| | | | | | | | | | | | | | | | | | Allows for moving more than one step forward/backward. This is not used anywhere yet but a key binding will likely be added in one of the following patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Avoid unnecessary window updatesLukas Fleischer2011-10-061-3/+10
| | | | | | | | | | | | | | | | Add a window bitmask to wins_update() and only update windows that might actually require an update in our main loop. This improves response times of the user interface a bit. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add configuration option to run the GC on exitLukas Fleischer2011-10-051-0/+1
| | | | | | | | | | | | | | | | If "auto_gc" is enabled, the garbage collector for note files will be run on every exit. As this is an experimental feature and may cause data loss, this is disabled by default. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add a garbage collector for note filesLukas Fleischer2011-10-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Now that we use hashes to identify notes, a garbage collector comes in handy. We search for note files that aren't referenced anywhere. Such files might come up if a note, that isn't connected with any other item, is edited. Huge parts of this code are very hackish due to our data structure layout and the way our hash table implementation works. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Do not unlink() note files on note removalLukas Fleischer2011-10-051-6/+5
| | | | | | | | | | | | | | | | | | | | Now that we use hash-based note file names, note files should never be unlinked as a note file might be shared. Also, remove the ERASE_FORCE_KEEP_NOTE flag that no longer makes any sense. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Accept variable length note namesLukas Fleischer2011-10-051-1/+2
| | | | | | | | | | | | | | | | Read up to the first blank in note_read() instead of assuming a fixed-width note file name. Accept everything up to 40 characters (which is the length of a SHA1 hash in hexadecimal representation). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor out note deserializationLukas Fleischer2011-10-051-0/+1
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add a copy file routineLukas Fleischer2011-10-051-0/+1
| | | | | | | | | | | | | | | | Add io_file_cp() which can be used to copy an existing source file to another location. We will need this for our new hash-based note file names. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add configuration option to notify all appointmentsLukas Fleischer2011-07-311-0/+1
| | | | | | | | | | | | | | | | If "notify-all" is enabled, all non-flagged appointments will be notified (instead of flagged ones). This is useful for users that want to be notified of everything. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-07-301-1/+1
|\|
| * Add "force" parameter to notify_check_next_app()Lukas Fleischer2011-07-291-1/+1
| | | | | | | | | | | | | | | | This allows to force notify_check_next_app() to update the notification appointment, even if start times are equal (e.g. if the item description was changed). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/calcurse.h: Whitespace cleanupLukas Fleischer2011-07-281-73/+70
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor out note functionsLukas Fleischer2011-07-211-1/+5
| | | | | | | | | | | | | | | | | | | | * Add new note_edit() and note_view() helper functions. Use these instead of copy-pasted code in *_note_edit(). * Move all note-related functions (note_edit(), note_view(), note_erase()) to a new source file "note.c". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Declare foreground and background variables globalLukas Fleischer2011-07-211-1/+2
| | | | | | | | | | | | Removes the need to pass the terminal's default background color round. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor conf_parse_bool()Lukas Fleischer2011-07-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * Increase size argument for strncmp() comparisons by one to include the terminating null-character (otherwise "yesfoo" would be parsed as "yes", "nobar" as "no"). * Pass destination address as an additional argument and return success/failure status to allow for better error handling. * Temporarily remove error handling (will be fixed later). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-07-101-0/+1
|\|
| * Honor "TMPDIR" environment variableLukas Fleischer2011-07-091-0/+1
| | | | | | | | | | | | | | | | | | Replace all hardcoded paths referring to "/tmp" with a new function that honors the "TMPDIR" environment variable as well as P_tmpdir and uses "/tmp" as a fallback. Thanks-to: Erik Saule <esaule@bmi.osu.edu> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add key binding for pipe-item commandLukas Fleischer2011-07-071-0/+1
| | | | | | | | | | | | | | This removes the need of reading the whole data file and find matching entries if we want to parse appointments in external programs. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add todo_pipe_item() functionLukas Fleischer2011-07-051-0/+1
| | | | | | | | | | | | | | Pipe a serialized todo item to an external process, similar to what day_pipe_item() does (cf. c3f532d814e555abf67efb136491956428f19965). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add day_pipe_item() functionLukas Fleischer2011-07-051-0/+1
| | | | | | | | | | | | | | | | Serializes an appointment or an event, prompts for a shell command and executes that command in a new process, piping serialized item data to its stdin. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add press_any_key() functionLukas Fleischer2011-07-051-0/+1
| | | | | | | | | | | | | | Displays "Press any key to continue..." in shell terminal mode and waits for a key stroke. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor wins_launch_external()Lukas Fleischer2011-07-021-1/+3
| | | | | | | | | | | | | | | | | | * Do window preparation and restoring in separate functions wins_prepare_external() and wins_unprepare_external(). * Use fork_exec() and child_wait() instead of system(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add shell_exec() functionLukas Fleischer2011-07-021-0/+1
| | | | | | | | | | | | Can be used to execute an external program in a shell. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add child_wait() functionLukas Fleischer2011-07-021-0/+1
| | | | | | | | | | | | Can be used to wait for the termination of a child process. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add fork_exec() functionLukas Fleischer2011-07-021-0/+1
| | | | | | | | | | | | | | Can be used to execute an external program. Provides the possibility to optionally create a pipe to the new process. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Make recur_*_write() publicLukas Fleischer2011-07-021-0/+2
| | | | | | | | | | | | | | This allows one to serialize and send recurrent items to arbitrary output streams. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Refactor out todo item serializationLukas Fleischer2011-07-021-0/+1
| | | | | | | | | | | | | | | | Add a todo_write() function that allows one to serialize todo items and write serialized data to an output stream in a fashion similar to apoint_write() and event_write(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use constant for maximum UTF-8 character sizeLukas Fleischer2011-07-021-0/+1
| | | | | | | | | | | | | | Introduce a UTF8_MAXLEN constant instead of using the literal value "6" at various places. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Split line editing functions into separate fileLukas Fleischer2011-06-291-2/+4
| | | | | | | | | | | | | | Move getstring() related stuff into a separate file as a first step on our way to UTF-8 support for line editing helpers. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add basic UTF-8 helper functionsLukas Fleischer2011-06-291-0/+4
| | | | | | | | | | | | | | | | | | | | Add utf8_width() and utf8_strwidth() which can be used to calculate the display width of a single character or a string, respectively. A lookup table is used to spot double width characters, as well as composing characters. There currently isn't any code to deal with ambigious characters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/calcurse.h: Add UTF-8 related macrosLukas Fleischer2011-06-291-0/+8
|/ | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>