summaryrefslogtreecommitdiffstats
path: root/smenu.c
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2021-01-02 00:19:04 +0100
committerpgen <p.gen.progs@gmail.com>2021-01-02 12:08:16 +0100
commit6c9590720ef85776397e9ea057f2387d92b75782 (patch)
treea3958a7e6bd4a60f5d3213bcb94398efa89776d3 /smenu.c
parentacb2c4e4a4b899d5459fea0d1b0f2faf7c126ee8 (diff)
Fix a display problem in a very specific case
The display is corrupted when the height of the title is greater than or equal to the height of the screen. Fix the problem by truncating the title from the bottom.
Diffstat (limited to 'smenu.c')
-rw-r--r--smenu.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/smenu.c b/smenu.c
index 8e45c1c..7948823 100644
--- a/smenu.c
+++ b/smenu.c
@@ -93,6 +93,7 @@ char * sbar_down = "\xe2\x94\x98"; /* box_drawings_light_up_and_left */
char * sbar_curs = "\xe2\x95\x91"; /* box_drawings_double_vertical */
char * sbar_arr_up = "\xe2\x96\xb2"; /* black_up_pointing_triangle */
char * sbar_arr_down = "\xe2\x96\xbc"; /* black_down_pointing_triangle */
+char * msg_arr_down = "\xe2\x96\xbc"; /* black_down_pointing_triangle */
/* Variables used to manage the direct access entries. */
/* """"""""""""""""""""""""""""""""""""""""""""""""""" */
@@ -3415,7 +3416,8 @@ disp_word(long pos, search_mode_t search_mode, search_data_t * search_data,
/* ======================================== */
void
disp_message(ll_t * message_lines_list, long message_max_width,
- long message_max_len, term_t * term, win_t * win)
+ long message_max_len, term_t * term, win_t * win,
+ langinfo_t * langinfo)
{
ll_node_t * node;
char * line;
@@ -3447,7 +3449,7 @@ disp_message(ll_t * message_lines_list, long message_max_width,
/* Follow the message lines list and display each line. */
/* """""""""""""""""""""""""""""""""""""""""""""""""""" */
- while (node != NULL)
+ while (node != NULL && win->message_lines < term->nlines - 2)
{
long i;
@@ -3479,7 +3481,15 @@ disp_message(ll_t * message_lines_list, long message_max_width,
/* Print the line without the ending \n. */
/* ''''''''''''''''''''''''''''''''''''' */
- printf("%s", buf);
+ if (win->message_lines >= term->nlines - 3)
+ {
+ if (langinfo->utf8)
+ fputs(msg_arr_down, stdout);
+ else
+ fputc('v', stdout);
+ }
+ else
+ printf("%s", buf);
/* Complete the short line with spaces until it reach the */
/* message max size. */
@@ -3493,8 +3503,11 @@ disp_message(ll_t * message_lines_list, long message_max_width,
/* Drop the attributes and print a \n. */
/* ''''''''''''''''''''''''''''''''''' */
- tputs(TPARM1(exit_attribute_mode), 1, outch);
- puts("");
+ if (term->nlines > 2)
+ {
+ tputs(TPARM1(exit_attribute_mode), 1, outch);
+ puts("");
+ }
node = node->next;
win->message_lines++;
@@ -7205,7 +7218,10 @@ main(int argc, char * argv[])
/* Force the maximum number of window's line if -n is used. */
/* """""""""""""""""""""""""""""""""""""""""""""""""""""""" */
if (term.nlines <= win.message_lines)
- win.max_lines = 0;
+ {
+ win.message_lines = term.nlines - 1;
+ win.max_lines = 1;
+ }
else if (win.asked_max_lines >= 0)
{
if (win.asked_max_lines == 0)
@@ -7218,7 +7234,7 @@ main(int argc, char * argv[])
win.max_lines = win.asked_max_lines;
}
}
- else
+ else /* -n was not used. Set win.asked_max_lines to its default value. */
win.asked_max_lines = win.max_lines;
/* Allocate the memory for our words structures. */
@@ -8992,7 +9008,7 @@ main(int argc, char * argv[])
/* Display the words window and its title for the first time. */
/* """""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
disp_message(message_lines_list, message_max_width, message_max_len, &term,
- &win);
+ &win, &langinfo);
/* Before displaying the word windows for the first time when ins */
/* column or line mode, we need to ensure that the word under the */
@@ -9180,7 +9196,10 @@ main(int argc, char * argv[])
/* Reset the number of lines if the terminal has enough lines. */
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
if (term.nlines <= win.message_lines)
- win.max_lines = 0;
+ {
+ win.message_lines = term.nlines - 1;
+ win.max_lines = 1;
+ }
else if (win.max_lines < term.nlines - win.message_lines)
{
if (win.asked_max_lines == 0)
@@ -9248,7 +9267,7 @@ main(int argc, char * argv[])
}
disp_message(message_lines_list, message_max_width, message_max_len,
- &term, &win);
+ &term, &win, &langinfo);
nl = disp_lines(&win, &toggles, current, count, search_mode, &search_data,
&term, last_line, tmp_word, &langinfo);
@@ -9311,7 +9330,7 @@ main(int argc, char * argv[])
/* Display the words window and its title for the first time. */
/* """""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
disp_message(message_lines_list, message_max_width, message_max_len,
- &term, &win);
+ &term, &win, &langinfo);
}
/* The timeout has expired. */
/* """""""""""""""""""""""" */
@@ -9370,7 +9389,7 @@ main(int argc, char * argv[])
/* Display the words window and its title for the first time. */
/* """""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
disp_message(message_lines_list, message_max_width, message_max_len,
- &term, &win);
+ &term, &win, &langinfo);
}
setitimer(ITIMER_REAL, &periodic_itv, NULL);