From 0c812bda42d53f0cbe550af6f8fe0e2022cef728 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Fri, 12 Aug 2011 10:15:27 +0400 Subject: [PATCH] Draw status line at the top of screen not at the top of editor widget. (cherry picked from commit 340dc69013c226717fd60098c12bea6521c32639) Signed-off-by: Andrew Borodin Signed-off-by: Slava Zanko --- src/editor/editdraw.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/editor/editdraw.c b/src/editor/editdraw.c index 636bee378..fcdf6fbca 100644 --- a/src/editor/editdraw.c +++ b/src/editor/editdraw.c @@ -81,6 +81,8 @@ int visible_tabs = 1, visible_tws = 1; #define key_pending(x) (!is_idle()) +#define EDITOR_MINIMUM_TERMINAL_WIDTH 30 + /*** file scope type declarations ****************************************************************/ @@ -766,13 +768,13 @@ edit_render (WEdit * edit, int page, int row_start, int col_start, int row_end, /*** public functions ****************************************************************************/ /* --------------------------------------------------------------------------------------------- */ -/** Draw the status line at the top of the widget. The size of the filename +/** Draw the status line at the top of the screen. The size of the filename * field varies depending on the width of the screen and the length of * the filename. */ void edit_status (WEdit * edit) { - const int w = edit->widget.cols; + const int w = edit->widget.owner->cols; const size_t status_size = w + 1; char *const status = g_malloc (status_size); int status_len; @@ -800,19 +802,18 @@ edit_status (WEdit * edit) fname = str_trunc (fname, fname_len); } - widget_move (edit, 0, 0); + dlg_move (edit->widget.owner, 0, 0); tty_setcolor (STATUSBAR_COLOR); printwstr (fname, fname_len + gap); printwstr (status, w - (fname_len + gap)); - if (simple_statusbar && edit->widget.cols > 30) + if (simple_statusbar && w > EDITOR_MINIMUM_TERMINAL_WIDTH) { - size_t percent; + size_t percent = 100; + if (edit->total_lines + 1 != 0) percent = (edit->curs_line + 1) * 100 / (edit->total_lines + 1); - else - percent = 100; - widget_move (edit, 0, edit->widget.cols - 5); + dlg_move (edit->widget.owner, 0, w - 5); tty_printf (" %3d%%", percent); } -- 2.11.4.GIT