vg4->input->textbuffer()
Set a text buffer for text input.
SYNTAX
void
vg4->input->textbuffer(char *text,
size_t tsize,
const char *ch_acc,
const char *ch_rej)
FUNCTION PARAMETERS
text | Text buffer or NULL = no buffer (deactivate text-input) |
tsize | Size of text buffer |
ch_acc | Allowed characters for text, or NULL = all |
ch_rej | Not allowed characters for text, or NULL = none |
DESCRIPTION
Set a text buffer for text input.
If a text buffer is set, key strokes will be set into this buffer,
even for keyboard keys which are not inserted with vg4->input->key_insert().
The buffer must be a character array of fixed size.
With vg4->input->update() it will be filled according to the key strokes,
and is always null-terminated.
To restrict the input to allowed characters
the parameters ch_acc and ch_rej can be set as following:
- single UTF-8 characters: allow or inhibit this character
- character groups:
- %d = digits
- %a = letters
- %b = blanks
- %p = special characters:
any printable character which is not a space or an alphanumeric character
Single characters take precedence over character-groups.
Example:
- ch_acc = %d%a.:
allow digits and letters and period and colon
- ch_acc = %d%a%p
ch_rej = /
allow digits and letters and special characters except slash (/)
EXAMPLE
char tbuf[32]; size_t tlen; /* set text buffer to tbuf[] * allow digits and letters and special characters except slash (/) */ vg4->input->textbuffer(tbuf, sizeof(tbuf), "%d%a%p", "/"); tlen = 0; for (;;) { if (!vg4->input->update(VG_TRUE)) { break; } /* if previous length of text buffer is unequal to actual length, print text buffer */ if (tlen != strlen(tbuf)) { tlen = strlen(tbuf); printf("Buffer with length %d: \"%s\"\n", (int)tlen, tbuf); } vg4->window->flush(); vg4->misc->wait_time(100); } /* deactivate text-input */ vg4->input->textbuffer(NULL, 0, NULL, NULL);