cgram(6): Sync with NetBSD * Properly handle input errors from child fortune(6) process. * Add advanced cursor movement with tab, shift+tab, return. * Fix the assertion issue in another way as in commit 18d09f18cf4c93d9a07b8129fed0bdc0d0b967a7. * Make the '*solved*' marker stand out more (suggested by me). * Place the '*solved*' marker nearer to the text. * Don't beep if the window is resized.
cgram(6): Don't move over the last char and fix an assertion The maximum value of cursor_x was the text length and thus also *equaled* to extent_x, which broke the assertion in substitute() and caused crashes. In addition, the cursor could move just beyond the last character on a line, which didn't make much sense. So only allow the cursor move to the last char but not over it. This also properly fix the above assertion issue.
cgram(6): Sync the rewritten version from NetBSD Fixes: * Do not consider the puzzle solved if all letters in the visible area are substituted correctly. To be properly solved, the whole puzzle must be solved, even those parts that are currently off-screen. * Never place the cursor at the very right edge of the screen since that does not work well with some terminals. The maximum valid x coordinate is COLS - 1. * Add horizontal scrolling. Make all coordinate handling symmetric in regard to the horizontal and vertical axes. Previously, lines longer than 80 characters could not be seen on the screen. * Fix undefined behavior when pressing function keys, which was resulting parts of the screen being cleaned. Improvements: * Remove the arbitrary limit of 128 characters per line. Even if fortune(6) may never generate such long lines, the code is easy enough to adapt to other sources. * Properly clean up the allocated memory. Previously, only the string arrays were freed but not the strings themselves. * Allow navigation with page up/down keys. * Consistently use char for characters, avoiding converting back and forth between char, unsigned char and int.
grdc(6): Add '-t' option to show time in 12-hour format Partially based on FreeBSD's implementation (revision 112749). But I moved the AM/PM mark to the upper-left corner instead of the bottom-right corner as in FreeBSD, because the mark in the bottom-right corner would be flushed by scrolling. In addition, improve the determination of AM/PM mark, including: 00:mm -> 12:mm AM 12:mm -> 12:mm PM
grdc(6): Fix 100% CPU usage and make timeout work again grdc(6) was passing a timespec with tv_nsec = 1000000*1000, which is invalid. So every nanosleep() call just returns with EINVAL error. This causes grdc(6) to loop hard and uses 100% CPU. It also brreaks the optional timeout argument; grdc(6) just exits immediately. Fix the above issue by correctly setting the timespec argument. This fix also makes the optional timeout argument work again.