Lines Matching full:item
87 int sel; /* selected item in pritem, can be -1 */
88 bool hasbottomdesc; /* some item has bottomdesc */
99 struct privateitem *item;
105 RETURN_FMTERROR("item %u [0-%u] fieldlen = 0",
108 RETURN_FMTERROR("item %u [0-%u] maxvaluelen = 0",
134 item = &f->pritems[i];
135 item->label = CHECK_STR(items[i].label);
136 item->ylabel = items[i].ylabel;
137 item->xlabel = items[i].xlabel;
138 item->yfield = items[i].yfield;
139 item->xfield = items[i].xfield;
140 item->secure = items[i].flags & BSDDIALOG_FIELDHIDDEN;
141 item->readonly = items[i].flags & BSDDIALOG_FIELDREADONLY;
142 item->fieldnocolor = items[i].flags & BSDDIALOG_FIELDNOCOLOR;
143 item->extendfield = items[i].flags & BSDDIALOG_FIELDEXTEND;
144 item->fieldonebyte = items[i].flags &
146 item->cursorend = items[i].flags & BSDDIALOG_FIELDCURSOREND;
147 item->bottomdesc = CHECK_STR(items[i].bottomdesc);
150 if (item->readonly || (item->secure && !insecurecursor))
151 item->cursor = false;
153 item->cursor = true;
155 item->maxletters = items[i].maxvaluelen;
156 item->privwbuf = calloc(item->maxletters + 1, sizeof(wchar_t));
157 if (item->privwbuf == NULL)
158 RETURN_ERROR("Cannot allocate item private buffer");
159 memset(item->privwbuf, 0, item->maxletters + 1);
160 item->pubwbuf = calloc(item->maxletters + 1, sizeof(wchar_t));
161 if (item->pubwbuf == NULL)
162 RETURN_ERROR("Cannot allocate item private buffer");
163 memset(item->pubwbuf, 0, item->maxletters + 1);
166 RETURN_ERROR("Cannot allocate item.init in wchar_t*");
167 wcsncpy(item->privwbuf, winit, item->maxletters);
168 wcsncpy(item->pubwbuf, winit, item->maxletters);
170 item->nletters = wcslen(item->pubwbuf);
171 if (item->secure) {
172 for (j = 0; j < item->nletters; j++)
173 item->pubwbuf[j] = f->securewch;
176 item->fieldcols = items[i].fieldlen;
177 item->xposdraw = 0;
178 item->xcursor = 0;
179 item->pos = 0;
182 f->h = MAX(f->h, item->ylabel);
183 f->h = MAX(f->h, item->yfield);
184 f->w = MAX(f->w, item->xlabel + strcols(item->label));
185 f->w = MAX(f->w, item->xfield + item->fieldcols);
187 itemybeg = MIN(item->ylabel, item->yfield);
188 itemxbeg = MIN(item->xlabel, item->xfield);
190 tmp = MIN(item->ylabel, item->yfield);
192 tmp = MIN(item->xlabel, item->xfield);
195 tmp = abs((int)item->ylabel - (int)item->yfield);
214 static bool fieldctl(struct privateitem *item, enum field_action act)
223 if (item->pos == 0 && item->xcursor == 0)
227 item->pos = 0;
228 item->xcursor = 0;
229 item->xposdraw = 0;
232 while (fieldctl(item, MOVE_CURSOR_RIGHT))
236 if (item->pos == 0)
238 /* check redundant by item->pos == 0 because of 'while' below */
239 if (item->xcursor == 0 && item->xposdraw == 0)
243 item->pos -= 1;
244 width = wcwidth(item->pubwbuf[item->pos]);
245 if (((int)item->xcursor) - width < 0) {
246 item->xcursor = 0;
247 item->xposdraw -= 1;
249 item->xcursor -= width;
252 if (item->xposdraw == 0)
254 if (item->xcursor >= item->fieldcols / 2)
256 if (wcwidth(item->pubwbuf[item->xposdraw - 1]) +
257 item->xcursor + width > item->fieldcols)
260 item->xposdraw -= 1;
261 item->xcursor +=
262 wcwidth(item->pubwbuf[item->xposdraw]);
266 if (item->nletters == 0)
268 if (item->pos == item->nletters)
272 for (i = item->pos; i < item->nletters; i++) {
273 item->privwbuf[i] = item->privwbuf[i+1];
274 item->pubwbuf[i] = item->pubwbuf[i+1];
276 item->nletters -= 1;
277 item->privwbuf[i] = L'\0';
278 item->pubwbuf[i] = L'\0';
281 if (item->pos + 1 == item->maxletters)
283 if (item->pos == item->nletters)
287 oldwidth = wcwidth(item->pubwbuf[item->pos]);
288 item->pos += 1;
289 if (item->pos == item->nletters) { /* empty column */
292 nextwidth = wcwidth(item->pubwbuf[item->pos]);
294 if (item->xcursor + oldwidth + nextwidth - 1 >= item->fieldcols) {
296 item->xposdraw = item->pos;
297 while (item->xposdraw != 0) {
298 cols += wcwidth(item->pubwbuf[item->xposdraw - 1]);
299 if (cols > (int)item->fieldcols)
301 item->xposdraw -= 1;
303 item->xcursor = 0;
304 for (i = item->xposdraw; i < item->pos ; i++)
305 item->xcursor += wcwidth(item->pubwbuf[i]);
308 item->xcursor += oldwidth;
317 static bool insertch(struct privateitem *item, wchar_t wch, wchar_t securewch)
321 if (item->nletters >= item->maxletters)
324 for (i = (int)item->nletters - 1; i >= (int)item->pos; i--) {
325 item->privwbuf[i+1] = item->privwbuf[i];
326 item->pubwbuf[i+1] = item->pubwbuf[i];
329 item->privwbuf[item->pos] = wch;
330 item->pubwbuf[item->pos] = item->secure ? securewch : wch;
331 item->nletters += 1;
332 item->privwbuf[item->nletters] = L'\0';
333 item->pubwbuf[item->nletters] = L'\0';
371 "Cannot allocate memory for item[%d].value", i);
465 struct privateitem *item;
467 item = &f->pritems[idx];
471 mvwaddstr(f->pad, item->ylabel, item->xlabel, item->label);
475 if (item->readonly)
477 else if (item->fieldnocolor)
482 mvwhline(f->pad, item->yfield, item->xfield, ' ', item->fieldcols);
484 cols = wcwidth(item->pubwbuf[item->xposdraw]);
485 while (cols <= item->fieldcols &&
486 item->xposdraw + n < wcslen(item->pubwbuf)) {
488 cols += wcwidth(item->pubwbuf[item->xposdraw + n]);
491 mvwaddnwstr(f->pad, item->yfield, item->xfield,
492 &item->pubwbuf[item->xposdraw], n);
499 if (item->bottomdesc != NULL && focus) {
501 addstr(item->bottomdesc);
508 curs_set((focus && item->cursor) ? 1 : 0);
509 wmove(f->pad, item->yfield, item->xfield + item->xcursor);
513 * Trick: draw 2 times an item switching focus.
546 static void curriteminview(struct privateform *f, struct privateitem *item)
550 yup = MIN(item->ylabel, item->yfield);
551 ydown = MAX(item->ylabel, item->yfield);
553 /* selected item in view */
649 if (f->sel != -1) { /* at least 1 writable item */
664 } else { /* no item */
681 struct privateitem *item;
703 item = &form.pritems[form.sel];
705 item = NULL;
751 if (fieldctl(item, MOVE_CURSOR_LEFT))
763 if (fieldctl(item, MOVE_CURSOR_RIGHT))
811 if (fieldctl(item, MOVE_CURSOR_LEFT))
812 if (fieldctl(item, DEL_LETTER))
818 if (fieldctl(item, DEL_LETTER))
824 if (fieldctl(item, MOVE_CURSOR_BEGIN))
830 if (fieldctl(item, MOVE_CURSOR_END))
854 if (item->fieldonebyte && wctob(input) == EOF)
861 if (insertch(item, input, form.securewch)) {
862 fieldctl(item, MOVE_CURSOR_RIGHT);
894 item = &form.pritems[form.sel];
895 curriteminview(&form, item);