#
1.30 |
|
10-May-2023 |
rillig |
cgram: replace comments with code
No binary change.
|
Revision tags: netbsd-10-base
|
#
1.29 |
|
12-Jun-2022 |
rillig |
cgram: allow cursor navigation with KEY_BEG as well
|
#
1.28 |
|
14-May-2022 |
rillig |
cgram: clear bottom line of the screen at the end
Previously, the prompt line of the shell overwrote only part of the prompt of cgram, the rest was still visible.
|
#
1.27 |
|
28-Mar-2022 |
rillig |
cgram: define a word as a sequence of letters, not non-whitespace
Pressing Tab or Shift+Tab now advances to the next letter that could be substituted, it no longer stops at punctuation or digits. Since only letters are scrambled, these are most interesting to be edited.
|
#
1.26 |
|
29-Oct-2021 |
nia |
cgram(6): realloc(x * y) -> reallocarr
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
|
#
1.25 |
|
28-May-2021 |
dholland |
I don't see any code I wrote left in here.
|
#
1.24 |
|
28-May-2021 |
dholland |
Restore return value of main, arbitrarily thrown away in -r1.4.
|
Revision tags: cjep_staticlib_x-base
|
#
1.23 |
|
01-May-2021 |
rillig |
branches: 1.23.2; cgram: rename local functions
The word 'cleanup' should have been named clean_up all along, but 'done' is even shorter.
No functional change.
|
#
1.22 |
|
29-Apr-2021 |
rillig |
cgram: in hinting mode, show all correct characters in bold face
For almost solved cryptograms, this makes the punctuation stand out less, helping to focus on the missing letters.
|
#
1.21 |
|
25-Apr-2021 |
rillig |
cgram: use ASCII-only implementation of <ctype.h> functions
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.
|
#
1.20 |
|
25-Apr-2021 |
rillig |
cgram: provide usage on incorrect invocation
|
#
1.19 |
|
25-Apr-2021 |
rillig |
cgram: conform to lint's strict bool mode, KNF
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.29 |
|
12-Jun-2022 |
rillig |
cgram: allow cursor navigation with KEY_BEG as well
|
#
1.28 |
|
14-May-2022 |
rillig |
cgram: clear bottom line of the screen at the end
Previously, the prompt line of the shell overwrote only part of the prompt of cgram, the rest was still visible.
|
#
1.27 |
|
28-Mar-2022 |
rillig |
cgram: define a word as a sequence of letters, not non-whitespace
Pressing Tab or Shift+Tab now advances to the next letter that could be substituted, it no longer stops at punctuation or digits. Since only letters are scrambled, these are most interesting to be edited.
|
#
1.26 |
|
29-Oct-2021 |
nia |
cgram(6): realloc(x * y) -> reallocarr
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
|
#
1.25 |
|
28-May-2021 |
dholland |
I don't see any code I wrote left in here.
|
#
1.24 |
|
28-May-2021 |
dholland |
Restore return value of main, arbitrarily thrown away in -r1.4.
|
Revision tags: cjep_staticlib_x-base
|
#
1.23 |
|
01-May-2021 |
rillig |
branches: 1.23.2; cgram: rename local functions
The word 'cleanup' should have been named clean_up all along, but 'done' is even shorter.
No functional change.
|
#
1.22 |
|
29-Apr-2021 |
rillig |
cgram: in hinting mode, show all correct characters in bold face
For almost solved cryptograms, this makes the punctuation stand out less, helping to focus on the missing letters.
|
#
1.21 |
|
25-Apr-2021 |
rillig |
cgram: use ASCII-only implementation of <ctype.h> functions
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.
|
#
1.20 |
|
25-Apr-2021 |
rillig |
cgram: provide usage on incorrect invocation
|
#
1.19 |
|
25-Apr-2021 |
rillig |
cgram: conform to lint's strict bool mode, KNF
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.28 |
|
14-May-2022 |
rillig |
cgram: clear bottom line of the screen at the end
Previously, the prompt line of the shell overwrote only part of the prompt of cgram, the rest was still visible.
|
#
1.27 |
|
28-Mar-2022 |
rillig |
cgram: define a word as a sequence of letters, not non-whitespace
Pressing Tab or Shift+Tab now advances to the next letter that could be substituted, it no longer stops at punctuation or digits. Since only letters are scrambled, these are most interesting to be edited.
|
#
1.26 |
|
29-Oct-2021 |
nia |
cgram(6): realloc(x * y) -> reallocarr
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
|
#
1.25 |
|
28-May-2021 |
dholland |
I don't see any code I wrote left in here.
|
#
1.24 |
|
28-May-2021 |
dholland |
Restore return value of main, arbitrarily thrown away in -r1.4.
|
Revision tags: cjep_staticlib_x-base
|
#
1.23 |
|
01-May-2021 |
rillig |
branches: 1.23.2; cgram: rename local functions
The word 'cleanup' should have been named clean_up all along, but 'done' is even shorter.
No functional change.
|
#
1.22 |
|
29-Apr-2021 |
rillig |
cgram: in hinting mode, show all correct characters in bold face
For almost solved cryptograms, this makes the punctuation stand out less, helping to focus on the missing letters.
|
#
1.21 |
|
25-Apr-2021 |
rillig |
cgram: use ASCII-only implementation of <ctype.h> functions
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.
|
#
1.20 |
|
25-Apr-2021 |
rillig |
cgram: provide usage on incorrect invocation
|
#
1.19 |
|
25-Apr-2021 |
rillig |
cgram: conform to lint's strict bool mode, KNF
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.27 |
|
28-Mar-2022 |
rillig |
cgram: define a word as a sequence of letters, not non-whitespace
Pressing Tab or Shift+Tab now advances to the next letter that could be substituted, it no longer stops at punctuation or digits. Since only letters are scrambled, these are most interesting to be edited.
|
#
1.26 |
|
29-Oct-2021 |
nia |
cgram(6): realloc(x * y) -> reallocarr
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
|
#
1.25 |
|
28-May-2021 |
dholland |
I don't see any code I wrote left in here.
|
#
1.24 |
|
28-May-2021 |
dholland |
Restore return value of main, arbitrarily thrown away in -r1.4.
|
Revision tags: cjep_staticlib_x-base
|
#
1.23 |
|
01-May-2021 |
rillig |
branches: 1.23.2; cgram: rename local functions
The word 'cleanup' should have been named clean_up all along, but 'done' is even shorter.
No functional change.
|
#
1.22 |
|
29-Apr-2021 |
rillig |
cgram: in hinting mode, show all correct characters in bold face
For almost solved cryptograms, this makes the punctuation stand out less, helping to focus on the missing letters.
|
#
1.21 |
|
25-Apr-2021 |
rillig |
cgram: use ASCII-only implementation of <ctype.h> functions
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.
|
#
1.20 |
|
25-Apr-2021 |
rillig |
cgram: provide usage on incorrect invocation
|
#
1.19 |
|
25-Apr-2021 |
rillig |
cgram: conform to lint's strict bool mode, KNF
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.26 |
|
29-Oct-2021 |
nia |
cgram(6): realloc(x * y) -> reallocarr
|
Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
|
#
1.25 |
|
28-May-2021 |
dholland |
I don't see any code I wrote left in here.
|
#
1.24 |
|
28-May-2021 |
dholland |
Restore return value of main, arbitrarily thrown away in -r1.4.
|
Revision tags: cjep_staticlib_x-base
|
#
1.23 |
|
01-May-2021 |
rillig |
branches: 1.23.2; cgram: rename local functions
The word 'cleanup' should have been named clean_up all along, but 'done' is even shorter.
No functional change.
|
#
1.22 |
|
29-Apr-2021 |
rillig |
cgram: in hinting mode, show all correct characters in bold face
For almost solved cryptograms, this makes the punctuation stand out less, helping to focus on the missing letters.
|
#
1.21 |
|
25-Apr-2021 |
rillig |
cgram: use ASCII-only implementation of <ctype.h> functions
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.
|
#
1.20 |
|
25-Apr-2021 |
rillig |
cgram: provide usage on incorrect invocation
|
#
1.19 |
|
25-Apr-2021 |
rillig |
cgram: conform to lint's strict bool mode, KNF
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.25 |
|
28-May-2021 |
dholland |
I don't see any code I wrote left in here.
|
#
1.24 |
|
28-May-2021 |
dholland |
Restore return value of main, arbitrarily thrown away in -r1.4.
|
Revision tags: cjep_staticlib_x-base
|
#
1.23 |
|
01-May-2021 |
rillig |
cgram: rename local functions
The word 'cleanup' should have been named clean_up all along, but 'done' is even shorter.
No functional change.
|
#
1.22 |
|
29-Apr-2021 |
rillig |
cgram: in hinting mode, show all correct characters in bold face
For almost solved cryptograms, this makes the punctuation stand out less, helping to focus on the missing letters.
|
#
1.21 |
|
25-Apr-2021 |
rillig |
cgram: use ASCII-only implementation of <ctype.h> functions
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.
|
#
1.20 |
|
25-Apr-2021 |
rillig |
cgram: provide usage on incorrect invocation
|
#
1.19 |
|
25-Apr-2021 |
rillig |
cgram: conform to lint's strict bool mode, KNF
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.23 |
|
01-May-2021 |
rillig |
cgram: rename local functions
The word 'cleanup' should have been named clean_up all along, but 'done' is even shorter.
No functional change.
|
#
1.22 |
|
29-Apr-2021 |
rillig |
cgram: in hinting mode, show all correct characters in bold face
For almost solved cryptograms, this makes the punctuation stand out less, helping to focus on the missing letters.
|
#
1.21 |
|
25-Apr-2021 |
rillig |
cgram: use ASCII-only implementation of <ctype.h> functions
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.
|
#
1.20 |
|
25-Apr-2021 |
rillig |
cgram: provide usage on incorrect invocation
|
#
1.19 |
|
25-Apr-2021 |
rillig |
cgram: conform to lint's strict bool mode, KNF
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.22 |
|
29-Apr-2021 |
rillig |
cgram: in hinting mode, show all correct characters in bold face
For almost solved cryptograms, this makes the punctuation stand out less, helping to focus on the missing letters.
|
#
1.21 |
|
25-Apr-2021 |
rillig |
cgram: use ASCII-only implementation of <ctype.h> functions
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.
|
#
1.20 |
|
25-Apr-2021 |
rillig |
cgram: provide usage on incorrect invocation
|
#
1.19 |
|
25-Apr-2021 |
rillig |
cgram: conform to lint's strict bool mode, KNF
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.21 |
|
25-Apr-2021 |
rillig |
cgram: use ASCII-only implementation of <ctype.h> functions
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.
|
#
1.20 |
|
25-Apr-2021 |
rillig |
cgram: provide usage on incorrect invocation
|
#
1.19 |
|
25-Apr-2021 |
rillig |
cgram: conform to lint's strict bool mode, KNF
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.18 |
|
22-Apr-2021 |
wiz |
cgram: allow providing an input file instead of the random fortune
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|
#
1.17 |
|
26-Feb-2021 |
rillig |
cgram: don't beep if the window is resized
|
#
1.16 |
|
26-Feb-2021 |
rillig |
cgram: place the 'solved' marker nearer to the text
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.
|
#
1.15 |
|
26-Feb-2021 |
rillig |
cgram: make the 'solved' stand out more
Suggested by Weitian LI via [1].
[1] https://github.com/NetBSD/src/commit/efec6410b2b5a736
|
#
1.14 |
|
22-Feb-2021 |
rillig |
cgram: fix assertion when substituting at the end of the longest line
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
|
#
1.13 |
|
22-Feb-2021 |
rillig |
cgram: add advanced cursor movement with tab, shift+tab, return
|
#
1.12 |
|
22-Feb-2021 |
rillig |
cgram: properly handle input errors
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.
|
#
1.11 |
|
21-Feb-2021 |
rillig |
cgram: allow navigation with KEY_PPAGE and KEY_NPAGE
|
#
1.10 |
|
21-Feb-2021 |
rillig |
cgram: rewrite completely, fixing bugs and style
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.
|
#
1.9 |
|
21-Feb-2021 |
rillig |
cgram: WARNS=6, use int for all coordinates
Eliminate some frequently occurring subexpressions during substitution.
No functional change, assuming that fortune(6) always spits out less than 2 gigacharacters of text.
|
#
1.8 |
|
21-Feb-2021 |
rillig |
cgram: consistently use char for characters
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.
|
#
1.7 |
|
21-Feb-2021 |
rillig |
cgram: fix undefined behavior when pressing function keys
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.
|
#
1.6 |
|
21-Feb-2021 |
rillig |
cgram: adjust style to survive lint's strict bool mode
The biggest change is the return type of substitute(). Before, 0 meant success, now false means failure.
No functional change.
|
#
1.5 |
|
21-Feb-2021 |
rillig |
cgram: sort includes
|
#
1.4 |
|
21-Feb-2021 |
rillig |
cgram: indent
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.
|
#
1.3 |
|
21-Feb-2021 |
rillig |
cgram: fix Home key for cursor navigation
Reported by liweitianux via GitHub.
|
#
1.2 |
|
02-Jul-2020 |
rillig |
cgram(6): use standard cursor keys, use standard shuffle algorithm
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.
|
Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 netbsd-7-2-RELEASE pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 netbsd-7-1-2-RELEASE pgoyette-compat-base netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 tls-maxphys-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
|
#
1.1 |
|
04-Aug-2013 |
dholland |
branches: 1.1.4; 1.1.8; Add a curses gizmo for solving Sunday-paper-type cryptograms based on 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...
|