MCPcopy Create free account
hub / github.com/Kitware/CMake / Field_Grown

Function Field_Grown

Source/CursesDialog/form/frm_driver.c:449–566  ·  view source on GitHub ↗

--------------------------------------------------------------------------- | Facility : libnform | Function : static bool Field_Grown( FIELD *field, int amount) | | Description : This function is called for growable dynamic fields | only. It has to increase the buffers and to allocate | a new window for this field. |

Source from the content-addressed store, hash-verified

447|
448| Return Values : TRUE - field successfully increased
449| FALSE - there was some error
450+--------------------------------------------------------------------------*/
451static bool Field_Grown(FIELD * field, int amount)
452{
453 bool result = FALSE;
454
455 if (field && Growable(field))
456 {
457 bool single_line_field = Single_Line_Field(field);
458 int old_buflen = Buffer_Length(field);
459 int new_buflen;
460 int old_dcols = field->dcols;
461 int old_drows = field->drows;
462 char *oldbuf = field->buf;
463 char *newbuf;
464
465 int growth;
466 FORM *form = field->form;
467 bool need_visual_update = ((form != (FORM *)0) &&
468 (form->status & _POSTED) &&
469 (form->current==field));
470
471 if (need_visual_update)
472 Synchronize_Buffer(form);
473
474 if (single_line_field)
475 {
476 growth = field->cols * amount;
477 if (field->maxgrow)
478 growth = Minimum(field->maxgrow - field->dcols,growth);
479 field->dcols += growth;
480 if (field->dcols == field->maxgrow)
481 field->status &= ~_MAY_GROW;
482 }
483 else
484 {
485 growth = (field->rows + field->nrow) * amount;
486 if (field->maxgrow)
487 growth = Minimum(field->maxgrow - field->drows,growth);
488 field->drows += growth;
489 if (field->drows == field->maxgrow)
490 field->status &= ~_MAY_GROW;
491 }
492 /* drows, dcols changed, so we get really the new buffer length */
493 new_buflen = Buffer_Length(field);
494 newbuf=(char *)malloc((size_t)Total_Buffer_Size(field));
495 if (!newbuf)
496 { /* restore to previous state */
497 field->dcols = old_dcols;
498 field->drows = old_drows;
499 if (( single_line_field && (field->dcols!=field->maxgrow)) ||
500 (!single_line_field && (field->drows!=field->maxgrow)))
501 field->status |= _MAY_GROW;
502 return FALSE;
503 }
504 else
505 { /* Copy all the buffers. This is the reason why we can't
506 just use realloc().

Callers 11

IFN_Next_CharacterFunction · 0.85
IFN_Next_LineFunction · 0.85
IFN_Right_CharacterFunction · 0.85
IFN_Down_CharacterFunction · 0.85
Insert_StringFunction · 0.85
FE_New_LineFunction · 0.85
FE_Insert_CharacterFunction · 0.85
FE_Insert_LineFunction · 0.85
Data_EntryFunction · 0.85
set_field_bufferFunction · 0.85

Calls 7

Synchronize_BufferFunction · 0.85
newpadFunction · 0.85
delwinFunction · 0.85
weraseFunction · 0.85
Buffer_To_WindowFunction · 0.85
untouchwinFunction · 0.85
wmoveFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…