[PATCH 2/3] feedback: change the appearance of anchors when they will be saved
Benno Schulenberg <[email protected]> Mon, 12 May 2025 16:52:51 +0200
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <[email protected]> |
When an anchor is present on the first line of the buffer, make any
anchors appear as little blocks (■) instead of the usual diamonds (⬥).
This different appearance lets the user know whether a placed anchor
anywhere in the file will be saved or not -- when line numbers are
active. (In an 8-bit locale an = replaces the usual +).
---
src/search.c | 5 ++++-
src/winio.c | 6 ++++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/search.c b/src/search.c
index 63e46e05..677b4061 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1003,7 +1003,10 @@ void put_or_lift_anchor(void)
{
openfile->current->has_anchor = !openfile->current->has_anchor;
- update_line(openfile->current, openfile->current_x);
+ if (openfile->current != openfile->filetop)
+ update_line(openfile->current, openfile->current_x);
+ else
+ refresh_needed = TRUE;
if (openfile->current->has_anchor)
statusline(REMARK, _("Placed anchor"));
diff --git a/src/winio.c b/src/winio.c
index 3f05dc11..fd7f27b2 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2558,10 +2558,12 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
if (line->has_anchor && (from_col == 0 || !ISSET(SOFTWRAP)))
#ifdef ENABLE_UTF8
if (using_utf8())
- wprintw(midwin, "\xE2\xAC\xA5"); /* black medium diamond */
+ wprintw(midwin, openfile->filetop->has_anchor ?
+ "\xEF\xBF\xAD" : /* halfwidth black square */
+ "\xE2\xAC\xA5"); /* black medium diamond */
else
#endif
- wprintw(midwin, "+");
+ wprintw(midwin, openfile->filetop->has_anchor ? "=" : "+");
else
#endif
wprintw(midwin, " ");
--
2.48.1