inputbox.c (0a0fc0ddbe732779366ab6b1b879f62195e65967) | inputbox.c (98e5a1579e7d34fe3803240750a1c48efcd9cb15) |
---|---|
1/* 2 * inputbox.c -- implements the input box 3 * 4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) 5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 44 unchanged lines hidden (view full) --- 53 x = (COLS - width) / 2; 54 y = (LINES - height) / 2; 55 56 draw_shadow(stdscr, y, x, height, width); 57 58 dialog = newwin(height, width, y, x); 59 keypad(dialog, TRUE); 60 | 1/* 2 * inputbox.c -- implements the input box 3 * 4 * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) 5 * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 44 unchanged lines hidden (view full) --- 53 x = (COLS - width) / 2; 54 y = (LINES - height) / 2; 55 56 draw_shadow(stdscr, y, x, height, width); 57 58 dialog = newwin(height, width, y, x); 59 keypad(dialog, TRUE); 60 |
61 draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); 62 wattrset(dialog, border_attr); | 61 draw_box(dialog, 0, 0, height, width, 62 dlg.dialog.atr, dlg.border.atr); 63 wattrset(dialog, dlg.border.atr); |
63 mvwaddch(dialog, height - 3, 0, ACS_LTEE); 64 for (i = 0; i < width - 2; i++) 65 waddch(dialog, ACS_HLINE); | 64 mvwaddch(dialog, height - 3, 0, ACS_LTEE); 65 for (i = 0; i < width - 2; i++) 66 waddch(dialog, ACS_HLINE); |
66 wattrset(dialog, dialog_attr); | 67 wattrset(dialog, dlg.dialog.atr); |
67 waddch(dialog, ACS_RTEE); 68 69 print_title(dialog, title, width); 70 | 68 waddch(dialog, ACS_RTEE); 69 70 print_title(dialog, title, width); 71 |
71 wattrset(dialog, dialog_attr); | 72 wattrset(dialog, dlg.dialog.atr); |
72 print_autowrap(dialog, prompt, width - 2, 1, 3); 73 74 /* Draw the input field box */ 75 box_width = width - 6; 76 getyx(dialog, y, x); 77 box_y = y + 2; 78 box_x = (width - box_width) / 2; | 73 print_autowrap(dialog, prompt, width - 2, 1, 3); 74 75 /* Draw the input field box */ 76 box_width = width - 6; 77 getyx(dialog, y, x); 78 box_y = y + 2; 79 box_x = (width - box_width) / 2; |
79 draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr); | 80 draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, 81 dlg.border.atr, dlg.dialog.atr); |
80 81 print_buttons(dialog, height, width, 0); 82 83 /* Set up the initial value */ 84 wmove(dialog, box_y, box_x); | 82 83 print_buttons(dialog, height, width, 0); 84 85 /* Set up the initial value */ 86 wmove(dialog, box_y, box_x); |
85 wattrset(dialog, inputbox_attr); | 87 wattrset(dialog, dlg.inputbox.atr); |
86 87 if (!init) 88 instr[0] = '\0'; 89 else 90 strcpy(instr, init); 91 92 input_x = strlen(instr); 93 --- 21 unchanged lines hidden (view full) --- 115 break; 116 case KEY_LEFT: 117 continue; 118 case KEY_RIGHT: 119 continue; 120 case KEY_BACKSPACE: 121 case 127: 122 if (input_x || scroll) { | 88 89 if (!init) 90 instr[0] = '\0'; 91 else 92 strcpy(instr, init); 93 94 input_x = strlen(instr); 95 --- 21 unchanged lines hidden (view full) --- 117 break; 118 case KEY_LEFT: 119 continue; 120 case KEY_RIGHT: 121 continue; 122 case KEY_BACKSPACE: 123 case 127: 124 if (input_x || scroll) { |
123 wattrset(dialog, inputbox_attr); | 125 wattrset(dialog, dlg.inputbox.atr); |
124 if (!input_x) { 125 scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); 126 wmove(dialog, box_y, box_x); 127 for (i = 0; i < box_width; i++) 128 waddch(dialog, 129 instr[scroll + input_x + i] ? 130 instr[scroll + input_x + i] : ' '); 131 input_x = strlen(instr) - scroll; 132 } else 133 input_x--; 134 instr[scroll + input_x] = '\0'; 135 mvwaddch(dialog, box_y, input_x + box_x, ' '); 136 wmove(dialog, box_y, input_x + box_x); 137 wrefresh(dialog); 138 } 139 continue; 140 default: 141 if (key < 0x100 && isprint(key)) { 142 if (scroll + input_x < MAX_LEN) { | 126 if (!input_x) { 127 scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); 128 wmove(dialog, box_y, box_x); 129 for (i = 0; i < box_width; i++) 130 waddch(dialog, 131 instr[scroll + input_x + i] ? 132 instr[scroll + input_x + i] : ' '); 133 input_x = strlen(instr) - scroll; 134 } else 135 input_x--; 136 instr[scroll + input_x] = '\0'; 137 mvwaddch(dialog, box_y, input_x + box_x, ' '); 138 wmove(dialog, box_y, input_x + box_x); 139 wrefresh(dialog); 140 } 141 continue; 142 default: 143 if (key < 0x100 && isprint(key)) { 144 if (scroll + input_x < MAX_LEN) { |
143 wattrset(dialog, inputbox_attr); | 145 wattrset(dialog, dlg.inputbox.atr); |
144 instr[scroll + input_x] = key; 145 instr[scroll + input_x + 1] = '\0'; 146 if (input_x == box_width - 1) { 147 scroll++; 148 wmove(dialog, box_y, box_x); 149 for (i = 0; i < box_width - 1; i++) 150 waddch(dialog, instr [scroll + i]); 151 } else { --- 73 unchanged lines hidden --- | 146 instr[scroll + input_x] = key; 147 instr[scroll + input_x + 1] = '\0'; 148 if (input_x == box_width - 1) { 149 scroll++; 150 wmove(dialog, box_y, box_x); 151 for (i = 0; i < box_width - 1; i++) 152 waddch(dialog, instr [scroll + i]); 153 } else { --- 73 unchanged lines hidden --- |