C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
Field Editor

File mapping, user input, command processing, and display logic. More...

Functions

int field_editor (Form *form)
 Accept input for a field.
int form_display_field (Form *form)
 Display current field.
int form_display_field_n (Form *form, int n)
 Display field n.
int form_fmt_field (Form *form, char *s)
 Format field according to its format type.
int form_validate_field (Form *form)
 Validate current field based on flags.
bool is_valid_date (int yyyy, int mm, int dd)
 Check if a given date is valid, including leap years.
bool is_valid_time (int hh, int mm, int ss)
 Check if a given time is valid.
void left_justify (char *s)
 Left justify string by removing leading spaces.
void mk_filler (char *s, int fl)
 Create filler string for field.
void numeric (char *d, char *s)
 Extract numeric characters from source string to destination string.
void right_justify (char *s, int fl)
 Right justify string by removing trailing spaces and adding leadingspaces.

Detailed Description

File mapping, user input, command processing, and display logic.

Main loop for field editing and entry

This function handles the main loop for field editing and entry. It processes user input, including character input, navigation keys, and mouse events, to allow the user to edit the content of a field. The function validates input based on the field's specified format and updates the display accordingly. It returns the key code of the action taken, such as accepting the field, tabbing to the next field, or breaking out of the input loop.

Function Documentation

◆ field_editor()

int field_editor ( Form * form)

Accept input for a field.

Parameters
formPointer to Form structure
Returns
int Key code of action taken

Handles character input, navigation keys, and mouse events for field editing. Validates input based on field format and updates display. Returns key code of action taken (e.g., accept field, tab to next field, break out of input loop).

KEY_F(10) is the default key for accepting the field and moving to the next field

KEY_F(9) Cancels the current operation

KEY_UP, KEY_BTAB moves to the previous field

KEY_DOWN, TAB moves to the next field

KEY_END moves cursor to end of field

< Enter accepts the field and moves to the next field if form->f_erase_remainder is set, it will clear the remaining characters above and after the current cursor location

KEY_IC toggles insert mode

KEY_DC deletes character at cursor

KEY_HOME moves cursor to start of field

KEY_BACKSPACE deletes character before cursor

KEY_LEFT moves cursor left one character

KEY_RIGHT moves cursor right one character

Handles mouse events for field editing

Validates fields based on format

FF_STRING accepts all printable characters and spaces

FF_DECIMAL_INT accepts digits 0 through 9 and decimal point ('.')

FF_HEX_INT accepts digits 0 through 9 and letters A through F (case-insensitive)

FF_FLOAT accepts digits 0 through 9 and decimal point ('.') and negative operator ('-') at the start of the field

FF_DOUBLE accepts digits 0 through 9 and decimal point ('.') and negative operator ('-') at the start of the field

FF_CURRENCY accepts digits 0 through 9 and decimal point ('.') and negative operator ('-') at the start of the field

FF_YYYYMMDD accepts digits 0 through 9

FF_HHMMSS accepts digits 0 through 9

FF_APR accepts digits 0 through 9 and decimal point ('.')

Definition at line 55 of file fields.c.

55 {
56 bool f_insert = FALSE;
57 int in_key;
58 char *s, *d;
59 WINDOW *win = form->win;
60
61 int flin = form->field[form->fidx]->line;
62 int fcol = form->field[form->fidx]->col;
63 int flen = form->field[form->fidx]->len;
64 int ff = form->field[form->fidx]->ff;
65 char *accept_s = form->field[form->fidx]->accept_s;
66 char *filler_s = form->field[form->fidx]->filler_s;
67 form_fmt_field(form, accept_s);
68 click_x = click_y = -1;
69 char *fstart = accept_s;
70 char *fend = fstart + flen;
71 int x = fcol;
72 char *p = fstart = accept_s;
73 char *str_end = p + strlen(p);
74 in_key = 0;
75 if (f_insert)
76 set_chyron_key_cp(form->chyron, 18, "INS", KEY_IC, cp_nt_hl_rev);
77 else
78 set_chyron_key_cp(form->chyron, 18, "INS", KEY_IC, cp_nt_rev);
79 compile_chyron(form->chyron);
80 display_chyron(form->win, form->chyron, form->lines - 1, form->chyron->l);
81
82 while (1) {
83 if (in_key == 0) {
84 mvwaddstr(win, flin, fcol, filler_s);
85 mvwaddstr(win, flin, fcol, accept_s);
86 wmove(win, flin, x);
87 tcflush(0, TCIFLUSH);
88 wrefresh(form->box);
89 in_key = xwgetch(win, form->chyron, -1);
90 }
91 switch (in_key) {
94 case KEY_F(10):
95 form_fmt_field(form, accept_s);
97 if (form_validate_field(form) != 0)
98 continue;
99 return (in_key);
101 case KEY_BREAK:
102 case KEY_F(9):
104 in_key = KEY_F(9);
105 return (in_key);
107 case 'H':
108 case KEY_F(1):
109 return (in_key);
110 case KEY_BTAB:
111 case KEY_UP:
112 form_fmt_field(form, accept_s);
114 in_key = KEY_UP;
115 return (in_key);
117 case '\t':
118 case KEY_DOWN:
119 form_fmt_field(form, accept_s);
121 in_key = KEY_DOWN;
122 return (in_key);
124 case KEY_END:
125 case Ctrl('e'):
126 while (*p != '\0')
127 p++;
128 x = fcol + (p - fstart);
129 in_key = 0;
130 continue;
134 case '\n':
135 case KEY_ENTER:
136 if (form->f_erase_remainder)
137 *p = '\0';
138 form_fmt_field(form, accept_s);
140 in_key = KEY_ENTER;
141 return (in_key);
143 case KEY_IC:
144 if (f_insert) {
145 f_insert = FALSE;
146 set_chyron_key_cp(form->chyron, 18, "INS", KEY_IC, cp_nt_rev);
147 } else {
148 f_insert = TRUE;
149 set_chyron_key_cp(form->chyron, 18, "INS", KEY_IC,
151 }
152 compile_chyron(form->chyron);
153 display_chyron(form->win, form->chyron, form->lines - 1,
154 form->chyron->l);
155 in_key = 0;
156 continue;
158 case KEY_DC:
159 s = p + 1;
160 d = p;
161 while (*s != '\0')
162 *d++ = *s++;
163 *d = '\0';
164 str_end = d;
165 f_insert = FALSE;
166 in_key = 0;
167 continue;
169 case KEY_HOME:
170 case Ctrl('a'):
171 p = fstart;
172 x = fcol;
173 in_key = 0;
174 continue;
176 case KEY_BACKSPACE:
177 if (p > fstart) {
178 p--;
179 x--;
180 }
181 s = p + 1;
182 d = p;
183 while (*s != '\0')
184 *d++ = *s++;
185 *d = '\0';
186 str_end = d;
187 in_key = 0;
188 continue;
190 case KEY_LEFT:
191 if (p > fstart) {
192 p--;
193 x--;
194 }
195 in_key = 0;
196 continue;
198 case KEY_RIGHT:
199 if (p < fend && p < str_end) {
200 p++;
201 x++;
202 }
203 in_key = 0;
204 continue;
206 case KEY_MOUSE:
208 x = click_x;
209 flin = click_y;
210 flen = form->field[form->fidx]->len;
211 ff = form->field[form->fidx]->ff; /* ff - field forat */
212 accept_s = form->field[form->fidx]->accept_s;
213 filler_s = form->field[form->fidx]->filler_s;
214 form_fmt_field(form, accept_s);
215 fstart = accept_s;
216 fend = fstart + flen;
217 str_end = fstart + strlen(fstart);
218 p = fstart + (x - form->field[form->fidx]->col);
219 if (p > str_end)
220 x -= p - str_end;
221 p = min(p, str_end);
222 in_key = 0;
223 continue;
224 default:
225 if (p >= fend) {
226 in_key = 0;
227 continue;
228 }
230 switch (ff) {
232 case FF_STRING:
233 break;
236 case FF_DECIMAL_INT:
237 if ((in_key >= '0' && in_key <= '9') || in_key == '.')
238 break;
239 beep();
240 in_key = 0;
241 continue;
244 case FF_HEX_INT:
245 if ((in_key >= '0' && in_key <= '9') ||
246 (in_key >= 'A' && in_key <= 'F') ||
247 (in_key >= 'a' && in_key <= 'f'))
248 break;
249 beep();
250 in_key = 0;
251 continue;
254 case FF_FLOAT:
255 if ((in_key >= '0' && in_key <= '9') || in_key == '.' ||
256 (in_key == '-' && p == fstart))
257 break;
258 beep();
259 in_key = 0;
260 continue;
263 case FF_DOUBLE:
264 if ((in_key >= '0' && in_key <= '9') || in_key == '.' ||
265 (in_key == '-' && p == fstart))
266 break;
267 beep();
268 in_key = 0;
269 continue;
273 case FF_CURRENCY:
274 if ((in_key >= '0' && in_key <= '9') || in_key == '.' ||
275 (in_key == '-' && p == fstart))
276 break;
277 beep();
278 in_key = 0;
279 continue;
281 case FF_YYYYMMDD:
282 if (in_key >= '0' && in_key <= '9')
283 break;
284 beep();
285 in_key = 0;
286 continue;
288 case FF_HHMMSS:
289 if (in_key >= '0' && in_key <= '9')
290 break;
291 beep();
292 in_key = 0;
293 continue;
295 case FF_APR:
296 if ((in_key >= '0' && in_key <= '9') || in_key == '.')
297 break;
298 beep();
299 in_key = 0;
300 continue;
301 default:
302 Perror("field_editor() invalid format");
303 break;
304 }
305 if (in_key < ' ' || in_key > '~') {
306 in_key = 0;
307 continue;
308 }
309 if (f_insert) {
310 if (str_end < fend) {
311 s = str_end - 1;
312 d = str_end;
313 while (s >= p)
314 *d-- = *s--;
315 *p++ = in_key;
316 str_end++;
317 x++;
318 }
319 } else {
320 if (p < fend) {
321 if (p < str_end) {
322 *p++ = in_key;
323 x++;
324 } else if (p == str_end) {
325 *p++ = in_key;
326 *p = '\0';
327 str_end = p;
328 x++;
329 }
330 }
331 }
332 in_key = 0;
333 continue;
334 }
335 }
336}
int form_yx_to_fidx(Form *, int, int)
@ FF_DECIMAL_INT
Definition form.h:51
@ FF_STRING
Definition form.h:49
@ FF_HEX_INT
Definition form.h:53
@ FF_YYYYMMDD
Definition form.h:62
@ FF_HHMMSS
Definition form.h:64
@ FF_CURRENCY
Definition form.h:59
@ FF_FLOAT
Definition form.h:55
@ FF_DOUBLE
Definition form.h:57
@ FF_APR
Definition form.h:66
Form * form
Definition mem.c:47
#define min(x, y)
min macro evaluates two expressions, returning least result
Definition cm.h:56
#define Ctrl(c)
Definition cm.h:34
#define TRUE
Definition iloan.c:19
#define FALSE
Definition iloan.c:18
WINDOW * win
Definition dwin.c:121
int click_x
Definition dwin.c:49
int cp_nt_hl_rev
Definition dwin.c:151
int click_y
Definition dwin.c:48
int cp_nt_rev
Definition dwin.c:149
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
Definition dwin.c:1651
int Perror(char *)
Display a simple error message window or print to stderr.
Definition dwin.c:1162
void display_chyron(WINDOW *win, Chyron *chyron, int line, int col)
Display chyron on window.
Definition dwin.c:1476
void set_chyron_key_cp(Chyron *, int, char *, int, int)
Set chyron key with color pair (cp).
Definition dwin.c:1388
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
Definition dwin.c:1436
int form_fmt_field(Form *, char *)
Format field according to its format type.
Definition fields.c:417
int form_display_field(Form *)
Display current field.
Definition fields.c:366
int form_validate_field(Form *)
Validate current field based on flags.
Definition fields.c:522

References Field::accept_s, Form::box, Form::chyron, click_x, click_y, Field::col, compile_chyron(), cp_nt_hl_rev, cp_nt_rev, display_chyron(), Form::f_erase_remainder, Field::ff, FF_APR, FF_CURRENCY, FF_DECIMAL_INT, FF_DOUBLE, FF_FLOAT, FF_HEX_INT, FF_HHMMSS, FF_STRING, FF_YYYYMMDD, Form::fidx, Form::field, Field::filler_s, form_display_field(), form_fmt_field(), form_validate_field(), form_yx_to_fidx(), Chyron::l, Field::len, Field::line, Form::lines, Perror(), set_chyron_key_cp(), Form::win, and xwgetch().

Referenced by field_navigator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ form_display_field()

int form_display_field ( Form * form)

Display current field.

Parameters
formPointer to Form structure
Returns
0 on success, non-zero on error

This function displays the current field based on the form's current field index (fidx). It retrieves the line and column information for the current field, displays any brackets if set, and then displays the field's content using the display_s string. The function ensures that the field is displayed correctly within the form's window and refreshes the display to show the updated field content.

Definition at line 366 of file fields.c.

366 {
367 int flin = form->field[form->fidx]->line;
368 int fcol = form->field[form->fidx]->col;
369 mvwaddstr(form->win, flin, fcol, form->field[form->fidx]->filler_s);
370 mvwaddstr(form->win, flin, fcol, form->field[form->fidx]->display_s);
371 return 0;
372}

References Field::col, Field::display_s, Form::fidx, Form::field, Field::filler_s, Field::line, and Form::win.

Referenced by field_editor(), and form_display_field_n().

Here is the caller graph for this function:

◆ form_display_field_n()

int form_display_field_n ( Form * form,
int n )

Display field n.

Parameters
formPointer to Form structure
nField index to display
Returns
0 on success, non-zero on error

This function temporarily sets the form's current field index (fidx) to n, calls form_display_field() to display that field, and then restores the original fidx value. This allows for displaying a specific field without permanently changing the form's current field index.

Definition at line 348 of file fields.c.

348 {
349 int fidx = form->fidx;
350 form->fidx = n;
352 form->fidx = fidx;
353 return 0;
354}

References Form::fidx, and form_display_field().

Here is the call graph for this function:

◆ form_fmt_field()

int form_fmt_field ( Form * form,
char * s )

Format field according to its format type.

Parameters
formPointer to Form structure
sInput string to format
Returns
0 on success, non-zero on error

takes the input string for the current field and formats it according to the field's specified format type (ff). It updates the accept_s and display_s strings for the field based on the formatted value. Handles various format types, including strings, decimal integers, hexadecimal integers, floating-point numbers, currency, dates, and times. Uses helper functions for validation and formatting, such as is_valid_date(), is_valid_time(), numeric(), right_justify(), left_justify(), and strnzcpy(). The function ensures that the formatted output fits within the field's length and creates a filler string for the field as needed. The function also handles error cases, such as invalid formats, and provides feedback through error messages. It is designed to be extensible, allowing for additional format types to be added in the future as needed. Assumes that the input string is well-formed and does not contain malicious content. Input validation and sanitization should be performed at a higher level in the application to ensure security and robustness. The function currently does not handle localization or internationalization of number formats, such as different decimal separators or currency symbols. Future enhancements may include support for locale-specific formatting. Error handling is basic; future versions may include more detailed error reporting and logging mechanisms. Performance optimizations may be considered for handling large volumes of data or high-frequency updates in real-time applications. The following variables and structures are used in this function:

char field_s[FIELD_MAXLEN];
int decimal_int_n = 0;
int hex_int_n = 0;
float float_n = 0.0;
double double_n = 0.0;
double currency_n = 0.0;
struct Date { int yyyy; int mm; int dd; };
struct Time { int hh; int mm; int ss; };
#define FIELD_MAXLEN
Definition form.h:18

Definition at line 417 of file fields.c.

417 {
418 strnz__cpy(form->field[form->fidx]->input_s, s, FIELD_MAXLEN - 1);
419 char *input_s = form->field[form->fidx]->input_s;
420 char *accept_s = form->field[form->fidx]->accept_s;
421 char *display_s = form->field[form->fidx]->display_s;
422 char *filler_s = form->field[form->fidx]->filler_s;
423 int ff = form->field[form->fidx]->ff;
424 int fl = form->field[form->fidx]->len;
425
426 char field_s[FIELD_MAXLEN];
427 int decimal_int_n = 0;
428 int hex_int_n = 0;
429 float float_n = 0.0;
430 double double_n = 0.0;
431 double currency_n = 0.0;
432
433 struct {
434 int yyyy;
435 int mm;
436 int dd;
437 } Date;
438 Date.yyyy = Date.mm = Date.dd = 0;
439 struct {
440 int hh;
441 int mm;
442 int ss;
443 } Time;
444 Time.hh = Time.mm = Time.ss = 0;
445 strnz(accept_s, fl);
446 switch (ff) {
447 case FF_STRING:
448 left_justify(s);
449 trim(s);
450 strnz__cpy(input_s, s, FIELD_MAXLEN - 1);
451 strnz__cpy(accept_s, s, FIELD_MAXLEN - 1);
452 strnz__cpy(display_s, s, FIELD_MAXLEN - 1);
453 break;
454 case FF_DECIMAL_INT:
455 sscanf(input_s, "%d", &decimal_int_n);
456 sprintf(accept_s, "%d", decimal_int_n);
457 sprintf(display_s, "%d", decimal_int_n);
458 right_justify(display_s, fl);
459 break;
460 case FF_HEX_INT:
461 sscanf(input_s, "%x", &hex_int_n);
462 sprintf(accept_s, "%d", hex_int_n);
463 sprintf(display_s, "%x", hex_int_n);
464 right_justify(display_s, fl);
465 break;
466 case FF_FLOAT:
467 sscanf(input_s, "%f", &float_n);
468 sprintf(accept_s, "%f", float_n);
469 sprintf(display_s, "%f", float_n);
470 right_justify(display_s, fl);
471 break;
472 case FF_DOUBLE:
473 sscanf(input_s, "%lf", &double_n);
474 sprintf(accept_s, "%lf", double_n);
475 sprintf(display_s, "%lf", double_n);
476 right_justify(display_s, fl);
477 break;
478 case FF_CURRENCY:
479 numeric(field_s, input_s);
480 sscanf(field_s, "%lf", &currency_n);
481 sprintf(accept_s, "%.2lf", currency_n);
482 sprintf(display_s, "%'.2lf", currency_n);
483 right_justify(display_s, fl);
484 break;
485 case FF_YYYYMMDD:
486 Date.yyyy = Date.mm = Date.dd = 0;
487 strnz__cpy(field_s, input_s, FIELD_MAXLEN - 1);
488 sscanf(field_s, "%4d%2d%2d", &Date.yyyy, &Date.mm, &Date.dd);
489 sprintf(accept_s, "%04d%02d%02d", Date.yyyy, Date.mm, Date.dd);
490 if (is_valid_date(Date.yyyy, Date.mm, Date.dd))
491 sprintf(display_s, "%04d-%02d-%02d", Date.yyyy, Date.mm, Date.dd);
492 break;
493 case FF_HHMMSS:
494 Time.hh = Time.mm = Time.ss = 0;
495 strnz__cpy(field_s, input_s, FIELD_MAXLEN - 1);
496 sscanf(field_s, "%2d%2d%2d", &Time.hh, &Time.mm, &Time.ss);
497 sprintf(accept_s, "%02d%02d%02d", Time.hh, Time.mm, Time.ss);
498 if (is_valid_time(Time.hh, Time.mm, Time.ss))
499 sprintf(display_s, "%02d:%02d:%02d", Time.hh, Time.mm, Time.ss);
500 break;
501 case FF_APR:
502 sscanf(input_s, "%lf", &double_n);
503 sprintf(accept_s, "%lf", double_n);
504 sprintf(display_s, "%0.3lf", double_n);
505 right_justify(display_s, fl);
506 break;
507 default:
508 Perror("form_fmt_field() invalid format");
509 break;
510 }
511 strnz(accept_s, fl);
512 left_justify(accept_s);
513 mk_filler(filler_s, fl);
514 return 0;
515}
void numeric(char *, char *)
Extract numeric characters from source string to destination string.
Definition fields.c:643
void right_justify(char *, int)
Right justify string by removing trailing spaces and adding leadingspaces.
Definition fields.c:580
bool is_valid_date(int, int, int)
Check if a given date is valid, including leap years.
Definition fields.c:606
void left_justify(char *)
Left justify string by removing leading spaces.
Definition fields.c:568
bool is_valid_time(int, int, int)
Check if a given time is valid.
Definition fields.c:627
void mk_filler(char *, int)
Create filler string for field.
Definition fields.c:551
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
Definition futil.c:435
size_t trim(char *)
Trims leading and trailing spaces from string s in place.
Definition futil.c:282
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
Definition futil.c:506

References Field::accept_s, Field::display_s, Field::ff, FF_APR, FF_CURRENCY, FF_DECIMAL_INT, FF_DOUBLE, FF_FLOAT, FF_HEX_INT, FF_HHMMSS, FF_STRING, FF_YYYYMMDD, Form::fidx, Form::field, Field::filler_s, Field::input_s, is_valid_date(), is_valid_time(), left_justify(), Field::len, mk_filler(), numeric(), Perror(), right_justify(), strnz(), strnz__cpy(), and trim().

Referenced by field_editor(), and form_read_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ form_validate_field()

int form_validate_field ( Form * form)

Validate current field based on flags.

Parameters
formPointer to Form structure
Returns
0 if valid, 1 if invalid

Very underdeveloped - only checks F_NOTBLANK and F_NOMETAS

Definition at line 522 of file fields.c.

522 {
523 int n = form->fidx;
524 char *p = form->field[n]->accept_s;
525 if (form->field[n]->ff & F_NOTBLANK) {
526 char *s = form->field[n]->accept_s;
527 while (*s++ == ' ')
528 ;
529 if (*s == '\0') {
530 Perror("blank field not allowed");
531 return (1);
532 }
533 }
534 if (form->field[n]->ff & F_NOMETAS) {
535 if (strpbrk(p, "*?[]") != 0) {
536 Perror("metacharacters not allowed");
537 return (1);
538 }
539 }
540 return (0);
541}
#define F_NOTBLANK
Definition form.h:21
#define F_NOMETAS
Definition form.h:20

References Field::accept_s, Field::ff, Form::fidx, Form::field, and Perror().

Referenced by field_editor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_valid_date()

bool is_valid_date ( int yyyy,
int mm,
int dd )

Check if a given date is valid, including leap years.

Parameters
yyyyYear
mmMonth
ddDay
Returns
true if the date is valid, false otherwise

This function checks if the provided year, month, and day constitute a valid date. It accounts for leap years when determining the number of days in February. The function returns true if the date is valid and false if it is not.

Definition at line 606 of file fields.c.

606 {
607 if (yyyy < 1 || mm < 1 || mm > 12 || dd < 1)
608 return false;
609 int days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
610 if ((yyyy % 4 == 0 && yyyy % 100 != 0) || (yyyy % 400 == 0))
611 days_in_month[2] = 29;
612 if (dd > days_in_month[mm])
613 return false;
614 return true;
615}

Referenced by form_fmt_field().

Here is the caller graph for this function:

◆ is_valid_time()

bool is_valid_time ( int hh,
int mm,
int ss )

Check if a given time is valid.

Parameters
hhHour
mmMinute
ssSecond
Returns
true if the time is valid, false otherwise

This function checks if the provided hour, minute, and second constitute a valid time. It ensures that hours are between 0 and 23, minutes and seconds are between 0 and 59. The function returns true if the time is valid and false if it is not.

Definition at line 627 of file fields.c.

627 {
628 if (hh < 0 || hh > 23 || mm < 0 || mm > 59 || ss < 0 || ss > 59)
629 return false;
630 return true;
631}

Referenced by form_fmt_field().

Here is the caller graph for this function:

◆ left_justify()

void left_justify ( char * s)

Left justify string by removing leading spaces.

Parameters
sString to left justify

This function takes a string s and removes any leading spaces, effectively left-justifying the text. It does this by finding the first non-space character and shifting the string to the left, overwriting the leading spaces. The resulting string is null-terminated.

Definition at line 568 of file fields.c.

568{ trim(s); }

References trim().

Referenced by form_fmt_field().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mk_filler()

void mk_filler ( char * s,
int fl )

Create filler string for field.

Parameters
sFiller string to create
flField length

Fills the string s with the fill character specified in the form's fill_char array, repeated for the length of the field (fl). The resulting string is null-terminated. This filler string can be used to display empty fields or to clear the field area before displaying new content.

Definition at line 551 of file fields.c.

551 {
552 char *e = s + fl;
553 unsigned char c;
554
555 c = form->fill_char[0];
556 while (s != e)
557 *s++ = c;
558 *s = '\0';
559}

References Form::fill_char, and form.

Referenced by form_fmt_field().

Here is the caller graph for this function:

◆ numeric()

void numeric ( char * d,
char * s )

Extract numeric characters from source string to destination string.

Parameters
dDestination string
sSource string

This function takes a source string s and extracts only the numeric characters (digits 0-9), as well as dashes ('-') and periods ('.'), copying them into the destination string d. The resulting string in d is null-terminated. This is useful for processing input that may contain non-numeric characters, allowing the application to focus on the numeric content for further processing or validation.

Definition at line 643 of file fields.c.

643 {
644 while (*s != '\0') {
645 if (*s == '-' || *s == '.' || (*s >= '0' && *s <= '9'))
646 *d++ = *s++;
647 else
648 s++;
649 }
650 *d = '\0';
651}

Referenced by form_fmt_field().

Here is the caller graph for this function:

◆ right_justify()

void right_justify ( char * s,
int fl )

Right justify string by removing trailing spaces and adding leadingspaces.

Parameters
sString to right justify
flField length

This function takes a string s and right-justifies it within a field of length fl. It first removes any trailing spaces from the string, then shifts the characters to the right end of the field, filling the left side with spaces. The resulting string is null-terminated and fits within the specified field length.

Definition at line 580 of file fields.c.

580 {
581 char *p = s;
582 char *d = s + fl;
583 trim(s);
584 *d = '\0';
585 while (*s != '\0') {
586 s++;
587 }
588 while (s != p) {
589 *(--d) = *(--s);
590 }
591 while (d != p) {
592 *(--d) = ' ';
593 }
594}

References trim().

Referenced by form_fmt_field().

Here is the call graph for this function:
Here is the caller graph for this function: