10f66f451Sopenharmony_ci/* 20f66f451Sopenharmony_ci * textbox.c -- implements the text box 30f66f451Sopenharmony_ci * 40f66f451Sopenharmony_ci * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) 50f66f451Sopenharmony_ci * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) 60f66f451Sopenharmony_ci * 70f66f451Sopenharmony_ci * This program is free software; you can redistribute it and/or 80f66f451Sopenharmony_ci * modify it under the terms of the GNU General Public License 90f66f451Sopenharmony_ci * as published by the Free Software Foundation; either version 2 100f66f451Sopenharmony_ci * of the License, or (at your option) any later version. 110f66f451Sopenharmony_ci * 120f66f451Sopenharmony_ci * This program is distributed in the hope that it will be useful, 130f66f451Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 140f66f451Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 150f66f451Sopenharmony_ci * GNU General Public License for more details. 160f66f451Sopenharmony_ci * 170f66f451Sopenharmony_ci * You should have received a copy of the GNU General Public License 180f66f451Sopenharmony_ci * along with this program; if not, write to the Free Software 190f66f451Sopenharmony_ci * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 200f66f451Sopenharmony_ci */ 210f66f451Sopenharmony_ci 220f66f451Sopenharmony_ci#include "dialog.h" 230f66f451Sopenharmony_ci 240f66f451Sopenharmony_cistatic void back_lines(int n); 250f66f451Sopenharmony_cistatic void print_page(WINDOW * win, int height, int width); 260f66f451Sopenharmony_cistatic void print_line(WINDOW * win, int row, int width); 270f66f451Sopenharmony_cistatic char *get_line(void); 280f66f451Sopenharmony_cistatic void print_position(WINDOW * win); 290f66f451Sopenharmony_ci 300f66f451Sopenharmony_cistatic int hscroll; 310f66f451Sopenharmony_cistatic int begin_reached, end_reached, page_length; 320f66f451Sopenharmony_cistatic const char *buf; 330f66f451Sopenharmony_cistatic const char *page; 340f66f451Sopenharmony_ci 350f66f451Sopenharmony_ci/* 360f66f451Sopenharmony_ci * refresh window content 370f66f451Sopenharmony_ci */ 380f66f451Sopenharmony_cistatic void refresh_text_box(WINDOW *dialog, WINDOW *box, int boxh, int boxw, 390f66f451Sopenharmony_ci int cur_y, int cur_x) 400f66f451Sopenharmony_ci{ 410f66f451Sopenharmony_ci print_page(box, boxh, boxw); 420f66f451Sopenharmony_ci print_position(dialog); 430f66f451Sopenharmony_ci wmove(dialog, cur_y, cur_x); /* Restore cursor position */ 440f66f451Sopenharmony_ci wrefresh(dialog); 450f66f451Sopenharmony_ci} 460f66f451Sopenharmony_ci 470f66f451Sopenharmony_ci 480f66f451Sopenharmony_ci/* 490f66f451Sopenharmony_ci * Display text from a file in a dialog box. 500f66f451Sopenharmony_ci */ 510f66f451Sopenharmony_ciint dialog_textbox(const char *title, const char *tbuf, 520f66f451Sopenharmony_ci int initial_height, int initial_width) 530f66f451Sopenharmony_ci{ 540f66f451Sopenharmony_ci int i, x, y, cur_x, cur_y, key = 0; 550f66f451Sopenharmony_ci int height, width, boxh, boxw; 560f66f451Sopenharmony_ci int passed_end; 570f66f451Sopenharmony_ci WINDOW *dialog, *box; 580f66f451Sopenharmony_ci 590f66f451Sopenharmony_ci begin_reached = 1; 600f66f451Sopenharmony_ci end_reached = 0; 610f66f451Sopenharmony_ci page_length = 0; 620f66f451Sopenharmony_ci hscroll = 0; 630f66f451Sopenharmony_ci buf = tbuf; 640f66f451Sopenharmony_ci page = buf; /* page is pointer to start of page to be displayed */ 650f66f451Sopenharmony_ci 660f66f451Sopenharmony_cido_resize: 670f66f451Sopenharmony_ci getmaxyx(stdscr, height, width); 680f66f451Sopenharmony_ci if (height < 8 || width < 8) 690f66f451Sopenharmony_ci return -ERRDISPLAYTOOSMALL; 700f66f451Sopenharmony_ci if (initial_height != 0) 710f66f451Sopenharmony_ci height = initial_height; 720f66f451Sopenharmony_ci else 730f66f451Sopenharmony_ci if (height > 4) 740f66f451Sopenharmony_ci height -= 4; 750f66f451Sopenharmony_ci else 760f66f451Sopenharmony_ci height = 0; 770f66f451Sopenharmony_ci if (initial_width != 0) 780f66f451Sopenharmony_ci width = initial_width; 790f66f451Sopenharmony_ci else 800f66f451Sopenharmony_ci if (width > 5) 810f66f451Sopenharmony_ci width -= 5; 820f66f451Sopenharmony_ci else 830f66f451Sopenharmony_ci width = 0; 840f66f451Sopenharmony_ci 850f66f451Sopenharmony_ci /* center dialog box on screen */ 860f66f451Sopenharmony_ci x = (COLS - width) / 2; 870f66f451Sopenharmony_ci y = (LINES - height) / 2; 880f66f451Sopenharmony_ci 890f66f451Sopenharmony_ci draw_shadow(stdscr, y, x, height, width); 900f66f451Sopenharmony_ci 910f66f451Sopenharmony_ci dialog = newwin(height, width, y, x); 920f66f451Sopenharmony_ci keypad(dialog, TRUE); 930f66f451Sopenharmony_ci 940f66f451Sopenharmony_ci /* Create window for box region, used for scrolling text */ 950f66f451Sopenharmony_ci boxh = height - 4; 960f66f451Sopenharmony_ci boxw = width - 2; 970f66f451Sopenharmony_ci box = subwin(dialog, boxh, boxw, y + 1, x + 1); 980f66f451Sopenharmony_ci wattrset(box, dlg.dialog.atr); 990f66f451Sopenharmony_ci wbkgdset(box, dlg.dialog.atr & A_COLOR); 1000f66f451Sopenharmony_ci 1010f66f451Sopenharmony_ci keypad(box, TRUE); 1020f66f451Sopenharmony_ci 1030f66f451Sopenharmony_ci /* register the new window, along with its borders */ 1040f66f451Sopenharmony_ci draw_box(dialog, 0, 0, height, width, 1050f66f451Sopenharmony_ci dlg.dialog.atr, dlg.border.atr); 1060f66f451Sopenharmony_ci 1070f66f451Sopenharmony_ci wattrset(dialog, dlg.border.atr); 1080f66f451Sopenharmony_ci mvwaddch(dialog, height - 3, 0, ACS_LTEE); 1090f66f451Sopenharmony_ci for (i = 0; i < width - 2; i++) 1100f66f451Sopenharmony_ci waddch(dialog, ACS_HLINE); 1110f66f451Sopenharmony_ci wattrset(dialog, dlg.dialog.atr); 1120f66f451Sopenharmony_ci wbkgdset(dialog, dlg.dialog.atr & A_COLOR); 1130f66f451Sopenharmony_ci waddch(dialog, ACS_RTEE); 1140f66f451Sopenharmony_ci 1150f66f451Sopenharmony_ci print_title(dialog, title, width); 1160f66f451Sopenharmony_ci 1170f66f451Sopenharmony_ci print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE); 1180f66f451Sopenharmony_ci wnoutrefresh(dialog); 1190f66f451Sopenharmony_ci getyx(dialog, cur_y, cur_x); /* Save cursor position */ 1200f66f451Sopenharmony_ci 1210f66f451Sopenharmony_ci /* Print first page of text */ 1220f66f451Sopenharmony_ci attr_clear(box, boxh, boxw, dlg.dialog.atr); 1230f66f451Sopenharmony_ci refresh_text_box(dialog, box, boxh, boxw, cur_y, cur_x); 1240f66f451Sopenharmony_ci 1250f66f451Sopenharmony_ci while ((key != KEY_ESC) && (key != '\n')) { 1260f66f451Sopenharmony_ci key = wgetch(dialog); 1270f66f451Sopenharmony_ci switch (key) { 1280f66f451Sopenharmony_ci case 'E': /* Exit */ 1290f66f451Sopenharmony_ci case 'e': 1300f66f451Sopenharmony_ci case 'X': 1310f66f451Sopenharmony_ci case 'x': 1320f66f451Sopenharmony_ci delwin(box); 1330f66f451Sopenharmony_ci delwin(dialog); 1340f66f451Sopenharmony_ci return 0; 1350f66f451Sopenharmony_ci case 'g': /* First page */ 1360f66f451Sopenharmony_ci case KEY_HOME: 1370f66f451Sopenharmony_ci if (!begin_reached) { 1380f66f451Sopenharmony_ci begin_reached = 1; 1390f66f451Sopenharmony_ci page = buf; 1400f66f451Sopenharmony_ci refresh_text_box(dialog, box, boxh, boxw, 1410f66f451Sopenharmony_ci cur_y, cur_x); 1420f66f451Sopenharmony_ci } 1430f66f451Sopenharmony_ci break; 1440f66f451Sopenharmony_ci case 'G': /* Last page */ 1450f66f451Sopenharmony_ci case KEY_END: 1460f66f451Sopenharmony_ci 1470f66f451Sopenharmony_ci end_reached = 1; 1480f66f451Sopenharmony_ci /* point to last char in buf */ 1490f66f451Sopenharmony_ci page = buf + strlen(buf); 1500f66f451Sopenharmony_ci back_lines(boxh); 1510f66f451Sopenharmony_ci refresh_text_box(dialog, box, boxh, boxw, 1520f66f451Sopenharmony_ci cur_y, cur_x); 1530f66f451Sopenharmony_ci break; 1540f66f451Sopenharmony_ci case 'K': /* Previous line */ 1550f66f451Sopenharmony_ci case 'k': 1560f66f451Sopenharmony_ci case KEY_UP: 1570f66f451Sopenharmony_ci if (!begin_reached) { 1580f66f451Sopenharmony_ci back_lines(page_length + 1); 1590f66f451Sopenharmony_ci 1600f66f451Sopenharmony_ci /* We don't call print_page() here but use 1610f66f451Sopenharmony_ci * scrolling to ensure faster screen update. 1620f66f451Sopenharmony_ci * However, 'end_reached' and 'page_length' 1630f66f451Sopenharmony_ci * should still be updated, and 'page' should 1640f66f451Sopenharmony_ci * point to start of next page. This is done 1650f66f451Sopenharmony_ci * by calling get_line() in the following 1660f66f451Sopenharmony_ci * 'for' loop. */ 1670f66f451Sopenharmony_ci scrollok(box, TRUE); 1680f66f451Sopenharmony_ci wscrl(box, -1); /* Scroll box region down one line */ 1690f66f451Sopenharmony_ci scrollok(box, FALSE); 1700f66f451Sopenharmony_ci page_length = 0; 1710f66f451Sopenharmony_ci passed_end = 0; 1720f66f451Sopenharmony_ci for (i = 0; i < boxh; i++) { 1730f66f451Sopenharmony_ci if (!i) { 1740f66f451Sopenharmony_ci /* print first line of page */ 1750f66f451Sopenharmony_ci print_line(box, 0, boxw); 1760f66f451Sopenharmony_ci wnoutrefresh(box); 1770f66f451Sopenharmony_ci } else 1780f66f451Sopenharmony_ci /* Called to update 'end_reached' and 'page' */ 1790f66f451Sopenharmony_ci get_line(); 1800f66f451Sopenharmony_ci if (!passed_end) 1810f66f451Sopenharmony_ci page_length++; 1820f66f451Sopenharmony_ci if (end_reached && !passed_end) 1830f66f451Sopenharmony_ci passed_end = 1; 1840f66f451Sopenharmony_ci } 1850f66f451Sopenharmony_ci 1860f66f451Sopenharmony_ci print_position(dialog); 1870f66f451Sopenharmony_ci wmove(dialog, cur_y, cur_x); /* Restore cursor position */ 1880f66f451Sopenharmony_ci wrefresh(dialog); 1890f66f451Sopenharmony_ci } 1900f66f451Sopenharmony_ci break; 1910f66f451Sopenharmony_ci case 'B': /* Previous page */ 1920f66f451Sopenharmony_ci case 'b': 1930f66f451Sopenharmony_ci case KEY_PPAGE: 1940f66f451Sopenharmony_ci if (begin_reached) 1950f66f451Sopenharmony_ci break; 1960f66f451Sopenharmony_ci back_lines(page_length + boxh); 1970f66f451Sopenharmony_ci refresh_text_box(dialog, box, boxh, boxw, 1980f66f451Sopenharmony_ci cur_y, cur_x); 1990f66f451Sopenharmony_ci break; 2000f66f451Sopenharmony_ci case 'J': /* Next line */ 2010f66f451Sopenharmony_ci case 'j': 2020f66f451Sopenharmony_ci case KEY_DOWN: 2030f66f451Sopenharmony_ci if (!end_reached) { 2040f66f451Sopenharmony_ci begin_reached = 0; 2050f66f451Sopenharmony_ci scrollok(box, TRUE); 2060f66f451Sopenharmony_ci scroll(box); /* Scroll box region up one line */ 2070f66f451Sopenharmony_ci scrollok(box, FALSE); 2080f66f451Sopenharmony_ci print_line(box, boxh - 1, boxw); 2090f66f451Sopenharmony_ci wnoutrefresh(box); 2100f66f451Sopenharmony_ci print_position(dialog); 2110f66f451Sopenharmony_ci wmove(dialog, cur_y, cur_x); /* Restore cursor position */ 2120f66f451Sopenharmony_ci wrefresh(dialog); 2130f66f451Sopenharmony_ci } 2140f66f451Sopenharmony_ci break; 2150f66f451Sopenharmony_ci case KEY_NPAGE: /* Next page */ 2160f66f451Sopenharmony_ci case ' ': 2170f66f451Sopenharmony_ci if (end_reached) 2180f66f451Sopenharmony_ci break; 2190f66f451Sopenharmony_ci 2200f66f451Sopenharmony_ci begin_reached = 0; 2210f66f451Sopenharmony_ci refresh_text_box(dialog, box, boxh, boxw, 2220f66f451Sopenharmony_ci cur_y, cur_x); 2230f66f451Sopenharmony_ci break; 2240f66f451Sopenharmony_ci case '0': /* Beginning of line */ 2250f66f451Sopenharmony_ci case 'H': /* Scroll left */ 2260f66f451Sopenharmony_ci case 'h': 2270f66f451Sopenharmony_ci case KEY_LEFT: 2280f66f451Sopenharmony_ci if (hscroll <= 0) 2290f66f451Sopenharmony_ci break; 2300f66f451Sopenharmony_ci 2310f66f451Sopenharmony_ci if (key == '0') 2320f66f451Sopenharmony_ci hscroll = 0; 2330f66f451Sopenharmony_ci else 2340f66f451Sopenharmony_ci hscroll--; 2350f66f451Sopenharmony_ci /* Reprint current page to scroll horizontally */ 2360f66f451Sopenharmony_ci back_lines(page_length); 2370f66f451Sopenharmony_ci refresh_text_box(dialog, box, boxh, boxw, 2380f66f451Sopenharmony_ci cur_y, cur_x); 2390f66f451Sopenharmony_ci break; 2400f66f451Sopenharmony_ci case 'L': /* Scroll right */ 2410f66f451Sopenharmony_ci case 'l': 2420f66f451Sopenharmony_ci case KEY_RIGHT: 2430f66f451Sopenharmony_ci if (hscroll >= MAX_LEN) 2440f66f451Sopenharmony_ci break; 2450f66f451Sopenharmony_ci hscroll++; 2460f66f451Sopenharmony_ci /* Reprint current page to scroll horizontally */ 2470f66f451Sopenharmony_ci back_lines(page_length); 2480f66f451Sopenharmony_ci refresh_text_box(dialog, box, boxh, boxw, 2490f66f451Sopenharmony_ci cur_y, cur_x); 2500f66f451Sopenharmony_ci break; 2510f66f451Sopenharmony_ci case KEY_ESC: 2520f66f451Sopenharmony_ci key = on_key_esc(dialog); 2530f66f451Sopenharmony_ci break; 2540f66f451Sopenharmony_ci case KEY_RESIZE: 2550f66f451Sopenharmony_ci back_lines(height); 2560f66f451Sopenharmony_ci delwin(box); 2570f66f451Sopenharmony_ci delwin(dialog); 2580f66f451Sopenharmony_ci on_key_resize(); 2590f66f451Sopenharmony_ci goto do_resize; 2600f66f451Sopenharmony_ci } 2610f66f451Sopenharmony_ci } 2620f66f451Sopenharmony_ci delwin(box); 2630f66f451Sopenharmony_ci delwin(dialog); 2640f66f451Sopenharmony_ci return key; /* ESC pressed */ 2650f66f451Sopenharmony_ci} 2660f66f451Sopenharmony_ci 2670f66f451Sopenharmony_ci/* 2680f66f451Sopenharmony_ci * Go back 'n' lines in text. Called by dialog_textbox(). 2690f66f451Sopenharmony_ci * 'page' will be updated to point to the desired line in 'buf'. 2700f66f451Sopenharmony_ci */ 2710f66f451Sopenharmony_cistatic void back_lines(int n) 2720f66f451Sopenharmony_ci{ 2730f66f451Sopenharmony_ci int i; 2740f66f451Sopenharmony_ci 2750f66f451Sopenharmony_ci begin_reached = 0; 2760f66f451Sopenharmony_ci /* Go back 'n' lines */ 2770f66f451Sopenharmony_ci for (i = 0; i < n; i++) { 2780f66f451Sopenharmony_ci if (*page == '\0') { 2790f66f451Sopenharmony_ci if (end_reached) { 2800f66f451Sopenharmony_ci end_reached = 0; 2810f66f451Sopenharmony_ci continue; 2820f66f451Sopenharmony_ci } 2830f66f451Sopenharmony_ci } 2840f66f451Sopenharmony_ci if (page == buf) { 2850f66f451Sopenharmony_ci begin_reached = 1; 2860f66f451Sopenharmony_ci return; 2870f66f451Sopenharmony_ci } 2880f66f451Sopenharmony_ci page--; 2890f66f451Sopenharmony_ci do { 2900f66f451Sopenharmony_ci if (page == buf) { 2910f66f451Sopenharmony_ci begin_reached = 1; 2920f66f451Sopenharmony_ci return; 2930f66f451Sopenharmony_ci } 2940f66f451Sopenharmony_ci page--; 2950f66f451Sopenharmony_ci } while (*page != '\n'); 2960f66f451Sopenharmony_ci page++; 2970f66f451Sopenharmony_ci } 2980f66f451Sopenharmony_ci} 2990f66f451Sopenharmony_ci 3000f66f451Sopenharmony_ci/* 3010f66f451Sopenharmony_ci * Print a new page of text. Called by dialog_textbox(). 3020f66f451Sopenharmony_ci */ 3030f66f451Sopenharmony_cistatic void print_page(WINDOW * win, int height, int width) 3040f66f451Sopenharmony_ci{ 3050f66f451Sopenharmony_ci int i, passed_end = 0; 3060f66f451Sopenharmony_ci 3070f66f451Sopenharmony_ci page_length = 0; 3080f66f451Sopenharmony_ci for (i = 0; i < height; i++) { 3090f66f451Sopenharmony_ci print_line(win, i, width); 3100f66f451Sopenharmony_ci if (!passed_end) 3110f66f451Sopenharmony_ci page_length++; 3120f66f451Sopenharmony_ci if (end_reached && !passed_end) 3130f66f451Sopenharmony_ci passed_end = 1; 3140f66f451Sopenharmony_ci } 3150f66f451Sopenharmony_ci wnoutrefresh(win); 3160f66f451Sopenharmony_ci} 3170f66f451Sopenharmony_ci 3180f66f451Sopenharmony_ci/* 3190f66f451Sopenharmony_ci * Print a new line of text. Called by dialog_textbox() and print_page(). 3200f66f451Sopenharmony_ci */ 3210f66f451Sopenharmony_cistatic void print_line(WINDOW * win, int row, int width) 3220f66f451Sopenharmony_ci{ 3230f66f451Sopenharmony_ci int y, x; 3240f66f451Sopenharmony_ci char *line; 3250f66f451Sopenharmony_ci 3260f66f451Sopenharmony_ci line = get_line(); 3270f66f451Sopenharmony_ci line += MIN(strlen(line), hscroll); /* Scroll horizontally */ 3280f66f451Sopenharmony_ci wmove(win, row, 0); /* move cursor to correct line */ 3290f66f451Sopenharmony_ci waddch(win, ' '); 3300f66f451Sopenharmony_ci waddnstr(win, line, MIN(strlen(line), width - 2)); 3310f66f451Sopenharmony_ci 3320f66f451Sopenharmony_ci getyx(win, y, x); 3330f66f451Sopenharmony_ci /* Clear 'residue' of previous line */ 3340f66f451Sopenharmony_ci#if OLD_NCURSES 3350f66f451Sopenharmony_ci { 3360f66f451Sopenharmony_ci int i; 3370f66f451Sopenharmony_ci for (i = 0; i < width - x; i++) 3380f66f451Sopenharmony_ci waddch(win, ' '); 3390f66f451Sopenharmony_ci } 3400f66f451Sopenharmony_ci#else 3410f66f451Sopenharmony_ci wclrtoeol(win); 3420f66f451Sopenharmony_ci#endif 3430f66f451Sopenharmony_ci} 3440f66f451Sopenharmony_ci 3450f66f451Sopenharmony_ci/* 3460f66f451Sopenharmony_ci * Return current line of text. Called by dialog_textbox() and print_line(). 3470f66f451Sopenharmony_ci * 'page' should point to start of current line before calling, and will be 3480f66f451Sopenharmony_ci * updated to point to start of next line. 3490f66f451Sopenharmony_ci */ 3500f66f451Sopenharmony_cistatic char *get_line(void) 3510f66f451Sopenharmony_ci{ 3520f66f451Sopenharmony_ci int i = 0; 3530f66f451Sopenharmony_ci static char line[MAX_LEN + 1]; 3540f66f451Sopenharmony_ci 3550f66f451Sopenharmony_ci end_reached = 0; 3560f66f451Sopenharmony_ci while (*page != '\n') { 3570f66f451Sopenharmony_ci if (*page == '\0') { 3580f66f451Sopenharmony_ci if (!end_reached) { 3590f66f451Sopenharmony_ci end_reached = 1; 3600f66f451Sopenharmony_ci break; 3610f66f451Sopenharmony_ci } 3620f66f451Sopenharmony_ci } else if (i < MAX_LEN) 3630f66f451Sopenharmony_ci line[i++] = *(page++); 3640f66f451Sopenharmony_ci else { 3650f66f451Sopenharmony_ci /* Truncate lines longer than MAX_LEN characters */ 3660f66f451Sopenharmony_ci if (i == MAX_LEN) 3670f66f451Sopenharmony_ci line[i++] = '\0'; 3680f66f451Sopenharmony_ci page++; 3690f66f451Sopenharmony_ci } 3700f66f451Sopenharmony_ci } 3710f66f451Sopenharmony_ci if (i <= MAX_LEN) 3720f66f451Sopenharmony_ci line[i] = '\0'; 3730f66f451Sopenharmony_ci if (!end_reached) 3740f66f451Sopenharmony_ci page++; /* move pass '\n' */ 3750f66f451Sopenharmony_ci 3760f66f451Sopenharmony_ci return line; 3770f66f451Sopenharmony_ci} 3780f66f451Sopenharmony_ci 3790f66f451Sopenharmony_ci/* 3800f66f451Sopenharmony_ci * Print current position 3810f66f451Sopenharmony_ci */ 3820f66f451Sopenharmony_cistatic void print_position(WINDOW * win) 3830f66f451Sopenharmony_ci{ 3840f66f451Sopenharmony_ci int percent; 3850f66f451Sopenharmony_ci 3860f66f451Sopenharmony_ci wattrset(win, dlg.position_indicator.atr); 3870f66f451Sopenharmony_ci wbkgdset(win, dlg.position_indicator.atr & A_COLOR); 3880f66f451Sopenharmony_ci percent = (page - buf) * 100 / strlen(buf); 3890f66f451Sopenharmony_ci wmove(win, getmaxy(win) - 3, getmaxx(win) - 9); 3900f66f451Sopenharmony_ci wprintw(win, "(%3d%%)", percent); 3910f66f451Sopenharmony_ci} 392