18d09f18 | 22-Feb-2021 |
Aaron LI <aly@aaronly.me> |
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 caus
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.
show more ...
|
564d7699 | 22-Feb-2021 |
Aaron LI <aly@aaronly.me> |
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
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.
show more ...
|
ffe1d30b | 21-Feb-2021 |
Aaron LI <aly@aaronly.me> |
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-righ
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
show more ...
|
6159ff08 | 21-Feb-2021 |
Aaron LI <aly@aaronly.me> |
grdc(6): Improve scrolling timestamp precisions
Use clock_gettime() to obtain the current time with higher precision, which is used to improve the scrolling timestamp, trying to make the scrolling e
grdc(6): Improve scrolling timestamp precisions
Use clock_gettime() to obtain the current time with higher precision, which is used to improve the scrolling timestamp, trying to make the scrolling end on the integral seconds.
Inspired by OpenBSD's implementation.
show more ...
|
8f2695f2 | 21-Feb-2021 |
Aaron LI <aly@aaronly.me> |
grdc(6): Allow 'q' to quit immediately
Add support to allow pressing 'q' to quit immediately.
Partially based on OpenBSD's implementation: https://github.com/openbsd/src/commit/8ca82b000914eb1e6f45
grdc(6): Allow 'q' to quit immediately
Add support to allow pressing 'q' to quit immediately.
Partially based on OpenBSD's implementation: https://github.com/openbsd/src/commit/8ca82b000914eb1e6f45d22092c9358df4233247
show more ...
|
9f62ef8c | 21-Feb-2021 |
Aaron LI <aly@aaronly.me> |
grdc(6): Improve handling of long scroll delays
Add the scroll delay to the current time, so that the finally showed time matches the real current time.
In addition, skip nanosleep() if the sleep i
grdc(6): Improve handling of long scroll delays
Add the scroll delay to the current time, so that the finally showed time matches the real current time.
In addition, skip nanosleep() if the sleep interval is negative.
show more ...
|
cf2f35f4 | 21-Feb-2021 |
Aaron LI <aly@aaronly.me> |
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
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.
show more ...
|
11c3b524 | 20-Feb-2021 |
Aaron LI <aly@aaronly.me> |
games: Bring in monop(6) from NetBSD
monop is reminiscent of the Parker Brother's game Monopoly, and monitors a game between 2 to 9 users. It is assumed that the rules of Monopoly are known. The g
games: Bring in monop(6) from NetBSD
monop is reminiscent of the Parker Brother's game Monopoly, and monitors a game between 2 to 9 users. It is assumed that the rules of Monopoly are known. The game follows the standard rules, with the exception that, if a property goes up for auction and there are only two solvent players, no auction is held and the property remains unowned.
show more ...
|