summaryrefslogtreecommitdiffstats
path: root/cgram
Commit message (Collapse)AuthorAgeFilesLines
* cgram: rename local functionsrillig2021-05-051-7/+7
| | | | | | | The word 'cleanup' should have been named clean_up all along, but 'done' is even shorter. No functional change.
* cgram: in hinting mode, show all correct characters in bold facerillig2021-05-052-7/+6
| | | | | For almost solved cryptograms, this makes the punctuation stand out less, helping to focus on the missing letters.
* cgram: use ASCII-only implementation of <ctype.h> functionsrillig2021-04-281-19/+18
| | | | | | | The function 'encode' already assumes that all letter characters are contiguous and that there are only 26 letters of each case. At the moment, cgram cannot handle UTF-8 anyway since it reads the input byte-wise, assuming that each byte is exacty one character.
* cgram: provide usage on incorrect invocationrillig2021-04-281-3/+15
|
* cgram: conform to lint's strict bool mode, KNFrillig2021-04-281-5/+7
|
* cgram: allow providing an input file instead of the random fortunewiz2021-04-282-19/+44
|
* cgram: don't beep if the window is resizedrillig2021-04-131-2/+4
|
* cgram: place the 'solved' marker nearer to the textrillig2021-04-131-4/+8
| | | | | | This way, it cannot be overlooked as easily as before. It also doesn't change the position of the keyboard help text anymore. Only if there is not enough space, the 'solved' marker is put into the bottom line.
* cgram: make the 'solved' stand out morerillig2021-04-131-4/+8
| | | | | | Suggested by Weitian LI via [1]. [1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
* cgram: fix assertion when substituting at the end of the longest linerillig2021-04-131-39/+30
| | | | | | | | | | | | | | | | | | | Reported by Weitian LI via GitHub. Contrary to the patch suggested in [1], still allow the cursor to be placed to the very right of the text in a line since that is the usual behavior of text editors. Split the function substitute() into two parts: one that handles the curses-specific part of checking whether a substitution is possible at the current cursor position, and one that performs the actual substitution. Only the latter is kept in the code section for the string manipulation functions, the other is moved to the section for curses code. Having all the curses code in one place reduces the places that call beep(). Previously, as well as now, there is a single beep per invalid key before, but that was not obvious from the previous code. [1]: https://github.com/DragonFlyBSD/DragonFlyBSD/commit/18d09f18cf4c
* cgram: add advanced cursor movement with tab, shift+tab, returnrillig2021-04-131-49/+117
|
* cgram: properly handle input errorsrillig2021-04-131-3/+4
| | | | | | | | | On both NetBSD and Cygwin, a missing /usr/bin/fortune would previously continue since popen does not return an error (as /bin/sh is found and can be executed), so the next chance to catch an error is pclose. At that point, the shell has already printed an informative error message about what happened (or what didn't happen), so that cgram does not need to print an error by itself.
* cgram: allow navigation with KEY_PPAGE and KEY_NPAGErillig2021-04-131-8/+12
|
* cgram: rewrite completely, fixing bugs and stylerillig2021-04-131-179/+286
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed bugs: 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. 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. Stylistic: Add RCS ID. Fix ctype functions in lint's strict bool mode. Avoid excessive calls to strlen whenever the cursor moves. Given that the whole screen is redrawn every time a key is pressed, this is an unnecessary optimization, but the code smelled nevertheless.
* cgram: WARNS=6, use int for all coordinatesrillig2021-04-131-47/+44
| | | | | | | Eliminate some frequently occurring subexpressions during substitution. No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
* cgram: consistently use char for charactersrillig2021-04-131-12/+41
| | | | | | | | Having to convert back and forth between char, unsigned char and int is confusing. Just stay with char, until the support for wide characters is added. No functional change.
* cgram: fix undefined behavior when pressing function keysrillig2021-04-131-1/+1
| | | | | | The key codes for function keys are outside of the "range representable by an unsigned char". This resulted in parts of the screen being cleaned.
* cgram: adjust style to survive lint's strict bool moderillig2021-04-131-16/+17
| | | | | | | The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure. No functional change.
* cgram: sort includesrillig2021-04-131-5/+6
|
* cgram: indentrillig2021-04-131-262/+286
| | | | | | | | | | | | | | With manual corrections afterwards: - indent removes empty lines between statement and declaration. This had been a syntax error in C90, since C99 this is common style and should be accepted by indent. - indent didn't format the first line of main for whatever reason, did that manually. - indent removed the empty line above the '/////' separators. It should have left these empty lines as-is.
* cgram: fix Home key for cursor navigationrillig2021-04-131-1/+1
| | | | Reported by liweitianux via GitHub.
* Use PREFIX nowCameron Katri2021-03-282-4/+6
|
* Get all the games compiling for iOSCameron Katri2021-02-221-4/+14
|
* cgram(6): use standard cursor keys, use standard shuffle algorithmrillig2020-07-021-9/+13
| | | | | | | The previous shuffle algorithm asked for 100 random numbers, on average. The new algorithm asks exactly for 26 random numbers. Curses predefines numeric constants for keys, and there is no apparent reason not to use these standard keys for cursor movement.
* Add RCS Id.wiz2013-08-041-0/+1
|
* Add a curses gizmo for solving Sunday-paper-type cryptograms based ondholland2013-08-044-0/+448
substitution ciphers. It gets the cleartext from fortune. I wrote this some years ago for my own amusement; a couple people have suggested that I should import it. Approved only by groo, so I'm going to wait a couple days to hook it to the build in case anyone demands it be removed again...