Changeset d31c3ea in mainline for uspace/lib/vt/src/vt100.c


Ignore:
Timestamp:
2024-10-01T11:13:28Z (10 days ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
6907f26
Parents:
357d9dd
git-author:
Jiri Svoboda <jiri@…> (2024-09-30 19:13:18)
git-committer:
Jiri Svoboda <jiri@…> (2024-10-01 11:13:28)
Message:

Group vt callbacks into a callback structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/vt/src/vt100.c

    r357d9dd rd31c3ea  
    5151void vt100_cls(vt100_t *state)
    5252{
    53         state->control_puts(state->arg, "\033[2J");
     53        state->cb->control_puts(state->arg, "\033[2J");
    5454}
    5555
     
    6060
    6161        snprintf(control, MAX_CONTROL, "\033[%um", mode);
    62         state->control_puts(state->arg, control);
     62        state->cb->control_puts(state->arg, control);
    6363}
    6464
     
    7171        snprintf(control, MAX_CONTROL, "\033[%u;%u;%u;%u;%um",
    7272            a1, a2, a3, a4, a5);
    73         state->control_puts(state->arg, control);
     73        state->cb->control_puts(state->arg, control);
    7474}
    7575
     
    8080        snprintf(control, MAX_CONTROL, "\033[%" PRIun ";%" PRIun "f",
    8181            row + 1, col + 1);
    82         state->control_puts(state->arg, control);
     82        state->cb->control_puts(state->arg, control);
    8383}
    8484
     
    147147}
    148148
    149 vt100_t *vt100_create(void *arg, sysarg_t cols, sysarg_t rows,
    150     vt100_putuchar_t putuchar_fn, vt100_control_puts_t control_puts_fn,
    151     vt100_flush_t flush_fn)
     149vt100_t *vt100_create(void *arg, sysarg_t cols, sysarg_t rows, vt100_cb_t *cb)
    152150{
    153151        vt100_t *state = malloc(sizeof(vt100_t));
     
    155153                return NULL;
    156154
     155        state->cb = cb;
    157156        state->arg = arg;
    158         state->putuchar = putuchar_fn;
    159         state->control_puts = control_puts_fn;
    160         state->flush = flush_fn;
    161157
    162158        state->cols = cols;
     
    217213{
    218214        if (visible)
    219                 state->control_puts(state->arg, "\033[?25h");
     215                state->cb->control_puts(state->arg, "\033[?25h");
    220216        else
    221                 state->control_puts(state->arg, "\033[?25l");
     217                state->cb->control_puts(state->arg, "\033[?25l");
    222218}
    223219
    224220void vt100_putuchar(vt100_t *state, char32_t ch)
    225221{
    226         state->putuchar(state->arg, ch == 0 ? ' ' : ch);
     222        state->cb->putuchar(state->arg, ch == 0 ? ' ' : ch);
    227223        state->cur_col++;
    228224
     
    235231void vt100_flush(vt100_t *state)
    236232{
    237         state->flush(state->arg);
     233        state->cb->flush(state->arg);
    238234}
    239235
Note: See TracChangeset for help on using the changeset viewer.