[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] [PATCH] screen: when using positionlog, show as much of the
From: |
Benno Schulenberg |
Subject: |
[Nano-devel] [PATCH] screen: when using positionlog, show as much of the file as possible |
Date: |
Sat, 7 May 2016 20:58:03 +0200 |
When opening a file that was edited before, and the remembered position
is near the end of the file, then don't center the target line but show
the last line of the file on the bottom line of the screen, thus showing
as much of the file content as possible.
This fixes https://savannah.gnu.org/bugs/?46243.
---
src/search.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/search.c b/src/search.c
index 910b3da..5ed7e0f 100644
--- a/src/search.c
+++ b/src/search.c
@@ -951,13 +951,22 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool
use_answer,
openfile->current_x = actual_x(openfile->current->data, column - 1);
openfile->placewewant = column - 1;
- /* Put the top line of the edit window in range of the current line. */
- edit_update(CENTERING);
-
- /* When in interactive mode, update the screen. */
+ /* When the position was manually given, center the target line. */
if (interactive) {
+ edit_update(CENTERING);
edit_refresh();
display_main_list();
+ } else {
+ /* If the target line is close to the tail of the file, put the last
+ * line of the file on the bottom line of the screen; otherwise, just
+ * center the target line. */
+ if (openfile->filebot->lineno - openfile->current->lineno <
+ editwinrows / 2) {
+ openfile->current_y = editwinrows - openfile->filebot->lineno +
+ openfile->current->lineno - 1;
+ edit_update(STATIONARY);
+ } else
+ edit_update(CENTERING);
}
}
--
2.8.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nano-devel] [PATCH] screen: when using positionlog, show as much of the file as possible,
Benno Schulenberg <=