diff options
author | 2021-02-22 19:34:07 +0000 | |
---|---|---|
committer | 2021-04-13 15:28:34 -0400 | |
commit | 7aac7a7e5d525d103439a884f659f2b5070ee394 (patch) | |
tree | a2599f861a6bccdebc198b0db245b15335a25e66 /sail/dr_5.c | |
parent | b651ad4a8509e0f72f9c8f416dc02f3669672b35 (diff) | |
download | bsdgames-darwin-7aac7a7e5d525d103439a884f659f2b5070ee394.tar.gz bsdgames-darwin-7aac7a7e5d525d103439a884f659f2b5070ee394.tar.zst bsdgames-darwin-7aac7a7e5d525d103439a884f659f2b5070ee394.zip |
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
Diffstat (limited to 'sail/dr_5.c')
0 files changed, 0 insertions, 0 deletions