textbox.c (61ba55bcf70f2340f9c943c9571113b3fd8eda69) textbox.c (a6d8be451f62d425b71a4874f7d4e133b9fb393c)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2021-2023 Alfonso Sabato Siciliano
4 * Copyright (c) 2021-2024 Alfonso Sabato Siciliano
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the

--- 29 unchanged lines hidden (view full) ---

42 int hpad;
43 int wpad;
44 int margin; /* 2 with multicolumn char, 0 otherwise */
45 int printrows; /* d.h - BORDERS - HBUTTONS */
46};
47
48static void updateborders(struct dialog *d, struct scrolltext *st)
49{
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the

--- 29 unchanged lines hidden (view full) ---

42 int hpad;
43 int wpad;
44 int margin; /* 2 with multicolumn char, 0 otherwise */
45 int printrows; /* d.h - BORDERS - HBUTTONS */
46};
47
48static void updateborders(struct dialog *d, struct scrolltext *st)
49{
50 chtype arrowch, borderch;
50 chtype arrowch;
51 cchar_t borderch;
51
52 if (d->conf->no_lines)
52
53 if (d->conf->no_lines)
53 borderch = ' ';
54 setcchar(&borderch, L" ", 0, 0, NULL);
54 else if (d->conf->ascii_lines)
55 else if (d->conf->ascii_lines)
55 borderch = '|';
56 setcchar(&borderch, L"|", 0, 0, NULL);
56 else
57 else
57 borderch = ACS_VLINE;
58 borderch = *WACS_VLINE;
58
59 if (st->xpad > 0) {
59
60 if (st->xpad > 0) {
60 arrowch = d->conf->ascii_lines ? '<' : ACS_LARROW;
61 arrowch |= t.dialog.arrowcolor;
61 arrowch = LARROW(d->conf) | t.dialog.arrowcolor;
62 mvwvline(d->widget, (d->h / 2) - 2, 0, arrowch, 4);
62 } else {
63 } else {
63 arrowch = borderch;
64 arrowch |= t.dialog.lineraisecolor;
64 wattron(d->widget, t.dialog.lineraisecolor);
65 mvwvline_set(d->widget, (d->h / 2) - 2, 0, &borderch, 4);
66 wattroff(d->widget, t.dialog.lineraisecolor);
65 }
67 }
66 mvwvline(d->widget, (d->h / 2) - 2, 0, arrowch, 4);
67
68 if (st->xpad + d->w - 2 - st->margin < st->wpad) {
68
69 if (st->xpad + d->w - 2 - st->margin < st->wpad) {
69 arrowch = d->conf->ascii_lines ? '>' : ACS_RARROW;
70 arrowch |= t.dialog.arrowcolor;
70 arrowch = RARROW(d->conf) | t.dialog.arrowcolor;
71 mvwvline(d->widget, (d->h / 2) - 2, d->w - 1, arrowch, 4);
71 } else {
72 } else {
72 arrowch = borderch;
73 arrowch |= t.dialog.linelowercolor;
73 wattron(d->widget, t.dialog.linelowercolor);
74 mvwvline_set(d->widget, (d->h / 2) - 2, d->w - 1, &borderch, 4);
75 wattroff(d->widget, t.dialog.linelowercolor);
74 }
76 }
75 mvwvline(d->widget, (d->h / 2) - 2, d->w - 1, arrowch, 4);
76
77 if (st->hpad > d->h - 4) {
78 wattron(d->widget, t.dialog.arrowcolor);
79 mvwprintw(d->widget, d->h - 3, d->w - 6,
80 "%3d%%", 100 * (st->ypad + d->h - 4) / st->hpad);
81 wattroff(d->widget, t.dialog.arrowcolor);
82 }
83}

--- 92 unchanged lines hidden (view full) ---

176
177 if (textbox_draw(&d, &st) != 0)
178 return (BSDDIALOG_ERROR);
179
180 loop = true;
181 while (loop) {
182 updateborders(&d, &st);
183 /*
77
78 if (st->hpad > d->h - 4) {
79 wattron(d->widget, t.dialog.arrowcolor);
80 mvwprintw(d->widget, d->h - 3, d->w - 6,
81 "%3d%%", 100 * (st->ypad + d->h - 4) / st->hpad);
82 wattroff(d->widget, t.dialog.arrowcolor);
83 }
84}

--- 92 unchanged lines hidden (view full) ---

177
178 if (textbox_draw(&d, &st) != 0)
179 return (BSDDIALOG_ERROR);
180
181 loop = true;
182 while (loop) {
183 updateborders(&d, &st);
184 /*
184 * Overflow multicolumn charchter right border:
185 * Trick, overflow multicolumn charchter right border:
185 * wnoutrefresh(widget);
186 * pnoutrefresh(pad, ypad, xpad, ys, xs, ye, xe);
187 * doupdate();
188 */
189 wrefresh(d.widget);
190 prefresh(st.pad, st.ypad, st.xpad, st.ys, st.xs, st.ye, st.xe);
191 if (get_wch(&input) == ERR)
192 continue;

--- 58 unchanged lines hidden (view full) ---

251 if (conf->key.f1_file == NULL &&
252 conf->key.f1_message == NULL)
253 break;
254 if (f1help_dialog(conf) != 0)
255 return (BSDDIALOG_ERROR);
256 if (textbox_draw(&d, &st) != 0)
257 return (BSDDIALOG_ERROR);
258 break;
186 * wnoutrefresh(widget);
187 * pnoutrefresh(pad, ypad, xpad, ys, xs, ye, xe);
188 * doupdate();
189 */
190 wrefresh(d.widget);
191 prefresh(st.pad, st.ypad, st.xpad, st.ys, st.xs, st.ye, st.xe);
192 if (get_wch(&input) == ERR)
193 continue;

--- 58 unchanged lines hidden (view full) ---

252 if (conf->key.f1_file == NULL &&
253 conf->key.f1_message == NULL)
254 break;
255 if (f1help_dialog(conf) != 0)
256 return (BSDDIALOG_ERROR);
257 if (textbox_draw(&d, &st) != 0)
258 return (BSDDIALOG_ERROR);
259 break;
260 case KEY_CTRL('l'):
259 case KEY_RESIZE:
260 if (textbox_draw(&d, &st) != 0)
261 return (BSDDIALOG_ERROR);
262 break;
263 }
264 }
265
266 delwin(st.pad);
267 end_dialog(&d);
268
269 return (retval);
270}
261 case KEY_RESIZE:
262 if (textbox_draw(&d, &st) != 0)
263 return (BSDDIALOG_ERROR);
264 break;
265 }
266 }
267
268 delwin(st.pad);
269 end_dialog(&d);
270
271 return (retval);
272}