Home | History | Annotate | Download | only in libform

Lines Matching refs:row

85 /* used in add_char for initial memory allocation for string in row */
97 _formi_hscroll_back(FIELD *field, _FORMI_FIELD_LINES *row, unsigned int amt);
99 _formi_hscroll_fwd(FIELD *field, _FORMI_FIELD_LINES *row, unsigned int amt);
114 add_tab(FORM *form, _FORMI_FIELD_LINES *row, unsigned int i, char c);
116 tab_size(_FORMI_FIELD_LINES *row, unsigned int i);
118 tab_fit_len(_FORMI_FIELD_LINES *row, unsigned int len);
126 copy_row(_FORMI_FIELD_LINES *row);
131 * Calculate the cursor y position to make the given row appear on the
167 * Delete the given row and add it to the free list of the given field.
213 * Duplicate the given row, return the pointer to the new copy or
217 copy_row(_FORMI_FIELD_LINES *row)
226 memcpy(new, row, sizeof(*new));
228 /* nuke the pointers from the source row so we don't get confused */
238 memcpy(new->string, row->string, (size_t) row->length + 1);
240 if (row->tabs != NULL) {
241 tp = row->tabs;
248 memcpy(new->tabs, row->tabs, sizeof(*new->tabs));
282 * Initialise the row offset for a field, depending on the type of
340 * one row means the max applies to the number of columns otherwise it
341 * applies to the number of rows. If the row/column count is less
470 _FORMI_FIELD_LINES *temp, *row;
473 row = start;
474 while (row != NULL) {
475 if (row->tabs != NULL) {
477 tp = row->tabs;
485 if (row->string != NULL)
486 free(row->string);
488 temp = row->next;
489 free(row);
490 row = temp;
496 * If the wrap is successful, that is, the row count nor the buffer
506 _FORMI_FIELD_LINES *saved_row, *row, *row_backup, *saved_cur_line;
533 row = loc;
536 * row because we may be able to merge the current row into
539 if (row->prev != NULL)
540 row = row->prev;
542 saved_row = row;
552 if ((row_backup = copy_row(row)) == NULL)
556 row = row->next;
561 while (row != NULL) {
562 if ((temp->next = copy_row(row)) == NULL) {
563 /* a row copy failed... free up allocations */
571 if (row == field->start_line)
573 if (row == field->cur_line)
576 row = row->next;
579 row = saved_row;
580 while (row != NULL) {
581 pos = row->length - 1;
582 if (row->expanded < width) {
584 if ((row->hard_ret == TRUE) && (row->next != NULL)) {
590 row = row->next;
594 if (row->next == NULL) {
602 if (_formi_join_line(field, &row,
607 } else if (row->expanded > width) {
615 if (row->tabs == NULL) {
617 if (pos >= row->expanded)
618 pos = row->expanded - 1;
620 pos = tab_fit_len(row, field->cols);
623 if ((!isblank((unsigned char)row->string[pos])) &&
625 if (!isblank((unsigned char)row->string[pos - 1]))
627 &row);
634 || (!isblank((unsigned char)row->string[pos - 1]))) {
643 if ((row->next == NULL) && (pos == row->length - 1) &&
644 (isblank((unsigned char)row->string[pos])) &&
645 row->expanded <= field->cols)
654 if ((isblank((unsigned char)row->string[pos])) &&
655 (pos != row->length - 1))
658 if (split_line(field, FALSE, pos, &row) != E_OK) {
664 row = row->next;
711 _FORMI_FIELD_LINES *row = *rowp;
713 _formi_dbg_printf("%s: working on row %p, row_count = %d\n",
714 __func__, row, field->row_count);
722 if ((row->next == NULL) || (row->hard_ret == TRUE)) {
728 __func__, row->length, row->expanded);
730 " :: next row length = %d, expanded = %d\n",
731 row->length, row->expanded);
733 if (row->allocated < (row->length + row->next->length + 1)) {
734 if ((newp = realloc(row->string, (size_t)(row->length +
735 row->next->length
738 row->string = newp;
739 row->allocated = row->length + row->next->length + 1;
742 strcat(row->string, row->next->string);
743 old_len = row->length;
744 row->length += row->next->length;
745 if (row->length > 0)
746 row->expanded =
747 _formi_tab_expanded_length(row->string, 0,
748 row->length - 1);
750 row->expanded = 0;
752 _formi_calculate_tabs(row);
753 row->hard_ret = row->next->hard_ret;
755 /* adjust current line if it is on the row being eaten */
756 if (field->cur_line == row->next) {
757 field->cur_line = row;
760 _formi_tab_expanded_length(row->string, 0,
774 /* remove joined line record from the row list */
775 add_to_free(field, row->next);
779 __func__, row->length, row->expanded);
781 if (row->prev == NULL) {
785 saved = row->prev;
797 __func__, row->length, row->expanded);
799 " :: prev row length = %d, expanded = %d\n",
802 if (saved->allocated < (row->length + saved->length + 1)) {
804 (size_t) (row->length +
809 saved->allocated = row->length + saved->length + 1;
812 strcat(saved->string, row->string);
814 saved->length += row->length;
822 saved->hard_ret = row->hard_ret;
824 /* adjust current line if it was on the row being eaten */
825 if (field->cur_line == row) {
835 add_to_free(field, row);
840 row = saved;
847 * the field until we hit the row we just worked on.
852 if (saved == row)
864 *rowp = row;
868 if (_formi_wrap_field(field, row) != E_OK) {
887 _FORMI_FIELD_LINES *row = *rowp;
918 row->length, row->expanded);
920 assert((row->length < INT_MAX) && (row->expanded < INT_MAX));
923 /* add new line to the row list */
924 new_line->next = row->next;
925 new_line->prev = row;
926 row->next = new_line;
930 new_line->length = row->length - pos;
939 strcpy(new_line->string, &row->string[pos]);
941 row->length = pos;
942 row->string[pos] = '\0';
944 if (row->length != 0)
945 row->expanded = _formi_tab_expanded_length(row->string, 0,
946 row->length - 1);
948 row->expanded = 0;
949 _formi_calculate_tabs(row);
961 * If the given row was the current line then adjust the
964 if ((field->cur_line == row) && (field->row_xpos >= pos)) {
989 if (row->hard_ret == TRUE) {
991 row->hard_ret = FALSE;
996 * row must have a hard return on it too...
999 row->hard_ret = TRUE;
1002 assert(((row->expanded < INT_MAX) &&
1004 (row->length < INT_MAX) &&
1008 _formi_dbg_printf("row.length = %d, row.expanded = %d, ",
1009 row->length, row->expanded);
1040 * Skip the blanks in the string associated with the given row, pass back
1041 * the row and the offset at which the first non-blank is found. If no
1050 _FORMI_FIELD_LINES *row, *last = NULL;
1052 row = *rowp;
1056 i = _formi_skip_blanks(&row->string[i], i);
1057 if (!isblank((unsigned char)row->string[i])) {
1058 last = row;
1059 row = row->next;
1064 if (row != NULL)
1069 while (row != NULL);
1072 * If we hit the end of the row list then point at the last row
1073 * otherwise we return the row we found the blank on.
1075 if (row == NULL)
1078 *rowp = row;
1089 /* lower row numbers always win here.... */
1114 /* check the rows first, biggest row wins */
1143 _FORMI_FIELD_LINES *row;
1145 row = *rowp;
1150 while ((row->string[start] != '\0')
1151 && !isblank((unsigned char)row->string[start]))
1155 if (row->string[start] == '\0') {
1157 if (row->next == NULL)
1160 if (_formi_join_line(cur, &row, JOIN_NEXT_NW)
1165 if (row->next == NULL) {
1166 *rowp = row;
1169 row = row->next;
1172 } while (row->length == 0);
1175 } while (!isblank((unsigned char)row->string[start]));
1179 while ((row->string[start] != '\0')
1180 && isblank((unsigned char)row->string[start]))
1183 if (row->string[start] == '\0') {
1185 if (row->next == NULL)
1188 if (_formi_join_line(cur, &row, JOIN_NEXT_NW)
1193 if (row->next == NULL) {
1194 *rowp = row;
1197 row = row->next;
1200 } while (row->length == 0);
1203 } while (isblank((unsigned char)row->string[start]));
1205 *rowp = row;
1218 _FORMI_FIELD_LINES *row;
1220 row = *rowp;
1221 str = row->string;
1240 if (row->prev == NULL) {
1241 *rowp = row;
1245 row = row->prev;
1246 str = row->string;
1247 if (row->length > 0)
1248 start = row->length - 1;
1252 } while (row->length == 0);
1254 } while (isblank((unsigned char)row->string[start]));
1258 *rowp = row;
1270 if (row->prev == NULL) {
1271 *rowp = row;
1275 row = row->prev;
1276 str = row->string;
1277 if (row->length > 0)
1278 start = row->length - 1;
1282 } while (row->length == 0);
1288 if (start >= row->length) {
1289 if (row->next != NULL) {
1291 row = row->next;
1293 start = row->length - 1;
1301 *rowp = row;
1354 * Backward scroll is easy, follow row struct chain backward until
1368 _formi_hscroll_fwd(FIELD *field, _FORMI_FIELD_LINES *row, int unsigned amt)
1374 if ((row->tabs == NULL) || (row->tabs->in_use == FALSE)) {
1378 if (end > row->length) {
1379 end = row->length;
1391 if (end >= row->length)
1392 end = row->length - 1;
1395 row->string,
1398 ts = row->tabs;
1405 && (end < row->length)) {
1406 if (row->string[end] == '\t') {
1435 _formi_tab_expanded_length(row->string,
1446 _formi_hscroll_back(FIELD *field, _FORMI_FIELD_LINES *row, unsigned int amt)
1450 _formi_tab_expanded_length(row->string, field->start_char,
1507 _FORMI_FIELD_LINES *row;
1518 for (row = cur->start_line; ((row != NULL) && (line < cur->rows));
1519 row = row->next, line++) {
1523 if ((cur->cols + cur->start_char) >= row->length)
1524 len = row->length;
1527 if (row->string != NULL)
1529 row->string, cur->start_char, len);
1537 slen = row->expanded;
1609 str = &row->string[cur->start_char];
1617 if (row->expanded != 0) {
1646 tab = add_tab(form, row, cpos,
1655 tab = add_tab(form, row, cpos, ' ');
1660 tab = add_tab(form, row, cpos, ' ');
1705 add_tab(FORM *form, _FORMI_FIELD_LINES *row, unsigned int i, char c)
1708 _formi_tab_t *ts = row->tabs;
1753 _FORMI_FIELD_LINES *row, *temp, *next_temp;
1755 row = field->cur_line;
1761 if (row->string == NULL) {
1762 if ((row->string = malloc((size_t)INITIAL_LINE_ALLOC)) == NULL)
1764 row->string[0] = '\0';
1765 row->allocated = INITIAL_LINE_ALLOC;
1766 row->length = 0;
1767 row->expanded = 0;
1785 row->expanded, row->length, row->allocated);
1786 _formi_dbg_printf("%s: %s\n", __func__, row->string);
1791 row = field->alines;
1792 if (row->next != NULL) {
1794 temp = row->next;
1802 row->length = 0;
1803 row->string[0] = '\0';
1806 field->start_line = row;
1807 field->cur_line = row;
1811 row->expanded = 0;
1812 row->length = 0;
1818 || ((field->overlay == 1) && (pos >= row->length))) {
1823 if (row->length + 2
1824 >= row->allocated) {
1825 new_size = row->allocated + 16 - (row->allocated % 16);
1826 if ((new = realloc(row->string,
1829 row->allocated = new_size;
1830 row->string = new;
1834 if ((field->overlay == 0) && (row->length > pos)) {
1835 memmove(&row->string[pos + 1], &row->string[pos],
1836 (size_t) (row->length - pos + 1));
1839 old_c = row->string[pos];
1840 row->string[pos] = c;
1841 if (pos >= row->length) {
1846 row->string[pos + 1] = '\0';
1853 || ((field->overlay == 1) && (pos >= row->length))) {
1854 row->length++;
1857 _formi_calculate_tabs(row);
1858 row->expanded = _formi_tab_expanded_length(row->string, 0,
1859 row->length - 1);
1862 status = _formi_wrap_field(field, row);
1864 row = field->cur_line;
1870 * and the row count is increased past the set limit.
1875 && (pos >= (row->length - 1) /*XXXX- append check???*/))) {
1880 memmove(&row->string[pos], &row->string[pos + 1],
1881 (size_t) (row->length - pos));
1882 row->length--;
1887 row->string[pos] = old_c;
1890 _formi_calculate_tabs(row);
1892 _formi_wrap_field(field, row);
1909 row->string, 0, field->row_xpos - 1);
1932 row->expanded, row->length, row->allocated);
1935 _formi_dbg_printf("%s: %s\n", __func__, row->string);
1943 * Set the position of the cursor on the screen in the row depending on
1946 * to single row, static fields.
2062 _FORMI_FIELD_LINES *row, *rs;
2087 row = cur->cur_line;
2116 (cur->row_xpos + cur->start_char + 1) > row->length)
2123 if (cur->cursor_xpos >= (row->expanded - 1)) {
2124 if ((row->next == NULL) ||
2139 if (row->string[cur->row_xpos] == '\t')
2140 cur->cursor_xpos += tab_size(row,
2146 >= row->expanded) {
2147 if ((row->next == NULL) ||
2199 if (row->string[pos] == '\t') {
2200 size = tab_size(row, pos);
2219 row = cur->cur_line;
2220 if (row->expanded > 0) {
2221 cur->cursor_xpos = row->expanded - 1;
2226 if (row->length > 0)
2227 cur->row_xpos = row->length - 1;
2250 if ((row->next == NULL) || (cur->cur_line->next == NULL))
2258 row = cur->cur_line;
2260 if (row->length == 0) {
2264 if (cur->cursor_xpos > (row->expanded - 1))
2265 cur->cursor_xpos = row->expanded - 1;
2267 cur->row_xpos = tab_fit_len(row, cur->cursor_xpos + 1);
2273 row->string, 0, cur->row_xpos);
2304 row = cur->cur_line;
2306 if (row->length == 0) {
2310 if (cur->cursor_xpos > (row->expanded - 1))
2311 cur->cursor_xpos = row->expanded - 1;
2313 cur->row_xpos = tab_fit_len(row, cur->cursor_xpos + 1);
2315 _formi_tab_expanded_length(row->string,
2324 str = row->string;
2326 wb = find_eow(cur, start, FALSE, &row);
2349 cur->cur_line = row;
2350 adjust_ypos(cur, row);
2355 row->string, 0, cur->row_xpos) - 1;
2364 if ((start == 0) && (row->prev == NULL))
2368 row = row->prev;
2369 if (row->length > 0)
2370 start = row->length - 1;
2375 str = row->string;
2377 start = find_sow(start, &row);
2393 cur->cur_line = row;
2394 adjust_ypos(cur, row);
2398 row->string, 0,
2437 * correct row, now we need to get to the end of the
2443 row = cur->cur_line;
2446 if (row->expanded > cur->cols - 1) {
2449 cur, row->length,
2451 cur->row_xpos = row->length
2458 cur->row_xpos = row->length + 1;
2463 cur->row_xpos = row->length - 1;
2464 cur->cursor_xpos = row->expanded - 1;
2465 if (row->next == NULL) {
2474 if ((status = split_line(cur, TRUE, start, &row)) != E_OK)
2489 if ((status = split_line(cur, TRUE, 0, &row)) != E_OK)
2495 row = cur->cur_line;
2497 end = row->length - 1;
2498 if ((start >= row->length) && (row->next == NULL))
2501 if ((start == row->length - 1) || (row->length == 0)) {
2512 if (row->hard_ret == TRUE) {
2513 row->hard_ret = FALSE;
2514 if (_formi_join_line(cur, &row,
2517 row->hard_ret = TRUE;
2525 * If we have more than one row, join the
2526 * next row to make things easier unless
2532 if (row->next != NULL) {
2533 if (_formi_join_line(cur, &row,
2542 saved = row->string[start];
2543 memmove(&row->string[start], &row->string[start + 1],
2545 row->string[end] = '\0';
2546 row->length--;
2547 if (row->length > 0)
2548 row->expanded = _formi_tab_expanded_length(
2549 row->string, 0, row->length - 1);
2551 row->expanded = 0;
2558 _formi_calculate_tabs(row);
2563 if (start == row->length) {
2564 if (row->length > 1) {
2577 if (row->next != NULL) {
2579 cur, &row,
2594 row->string,
2597 && (start != (row->expanded - 1)))
2610 if (_formi_wrap_field(cur, row) != E_OK) {
2611 memmove(&row->string[start + 1],
2612 &row->string[start],
2614 row->length++;
2615 row->string[start] = saved;
2616 _formi_wrap_field(cur, row);
2628 row = cur->cur_line;
2630 end = row->length - 1;
2634 if (row->prev == NULL)
2643 if (row->prev->hard_ret == TRUE) {
2644 row->prev->hard_ret = FALSE;
2645 if (_formi_join_line(cur, &row,
2647 row->prev->hard_ret = TRUE;
2653 start = row->prev->length;
2658 if (_formi_join_line(cur, &row,
2662 end = row->length - 1;
2673 saved = row->string[start - 1];
2674 memmove(&row->string[start - 1], &row->string[start],
2676 row->length--;
2677 row->string[row->length] = '\0';
2678 row->expanded = _formi_tab_expanded_length(
2679 row->string, 0, row->length - 1);
2683 _formi_calculate_tabs(row);
2699 row->string, 0,
2705 if ((_formi_wrap_field(cur, row) != E_OK)) {
2706 memmove(&row->string[start],
2707 &row->string[start - 1],
2709 row->length++;
2710 row->string[start - 1] = saved;
2711 row->string[row->length] = '\0';
2712 _formi_wrap_field(cur, row);
2722 row->length = 0;
2723 row->expanded = row->length = 0;
2735 row->expanded = row->length = 0;
2740 add_to_free(cur, row);
2742 if (row->next == NULL) {
2754 if (cur->cursor_xpos > row->expanded) {
2755 cur->cursor_xpos = row->expanded - 1;
2756 cur->row_xpos = row->length - 1;
2762 while (rs != row) {
2776 str = row->string;
2778 wb = find_eow(cur, start, TRUE, &row);
2793 start = find_sow(start, &row);
2794 str = row->string;
2797 (size_t) (row->length - end + 1));
2799 row->length -= len;
2802 row = cur->start_line + cur->cursor_ypos;
2803 if (row->next != NULL) {
2805 * if not on the last row we need to
2806 * join on the next row so the line
2809 _formi_join_line(cur, &row, JOIN_NEXT_NW);
2811 _formi_wrap_field(cur, row);
2814 row->string, 0, cur->row_xpos);
2818 _formi_calculate_tabs(row);
2827 row->string[cur->row_xpos + 1] = '\0';
2828 row->length = cur->row_xpos + 1;
2829 row->expanded = cur->cursor_xpos + 1;
2833 row = cur->cur_line->next;
2834 while (row != NULL) {
2835 rs = row->next;
2836 add_to_free(cur, row);
2837 row = rs;
2843 row = cur->alines->next;
2847 while (row != NULL) {
2848 rs = row->next;
2849 add_to_free(cur, row);
2850 row = rs;
2896 _formi_hscroll_fwd(cur, row, 1);
2900 _formi_hscroll_back(cur, row, 1);
2904 _formi_hscroll_fwd(cur, row, cur->cols);
2908 _formi_hscroll_back(cur, row, cur->cols);
2912 _formi_hscroll_fwd(cur, row, cur->cols / 2);
2916 _formi_hscroll_back(cur, row, cur->cols / 2);
3224 /* find the first field on the next row if any */
3369 _formi_calculate_tabs(_FORMI_FIELD_LINES *row)
3371 _formi_tab_t *ts = row->tabs, *old_ts = NULL, **tsp;
3383 * Now look for tabs in the row and record the info...
3385 tsp = &row->tabs;
3386 for (i = 0, j = 0; i < row->length; i++, j++) {
3387 if (row->string[i] == '\t') {
3411 tab_size(_FORMI_FIELD_LINES *row, unsigned int i)
3415 ts = row->tabs;
3430 * results - it is really only required for a single row field.
3487 * given width after tabs have been expanded for a given row of a given
3491 tab_fit_len(_FORMI_FIELD_LINES *row, unsigned int width)
3496 ts = row->tabs;
3504 while ((len < width) && (pos < row->length)) {
3505 if (row->string[pos] == '\t') {