Changeset d3109ff in mainline for uspace/lib/vt/include


Ignore:
Timestamp:
2024-09-24T17:59:36Z (16 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
6a753a9c
Parents:
3fcea34
Message:

Cursor and color control in remote console + RGB

Move vt100 module from output server into separate vt library
Add cursor and color control to remcons using libvt
Add RGB color control to serial console and remote console

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/vt/include/vt/vt100.h

    r3fcea34 rd3109ff  
    11/*
     2 * Copyright (c) 2024 Jiri Svoboda
    23 * Copyright (c) 2011 Martin Decky
    34 * All rights reserved.
     
    2728 */
    2829
    29 /** @addtogroup output
     30/** @addtogroup libvt
    3031 * @{
    3132 */
    3233
    33 #ifndef OUTPUT_PROTO_VT100_H_
    34 #define OUTPUT_PROTO_VT100_H_
     34#ifndef LIBVT_VT100_H_
     35#define LIBVT_VT100_H_
    3536
    3637#include <io/charfield.h>
     38#include <ipc/common.h>
     39#include <uchar.h>
    3740
    38 typedef void (*vt100_putuchar_t)(char32_t ch);
    39 typedef void (*vt100_control_puts_t)(const char *str);
    40 typedef void (*vt100_flush_t)(void);
     41/** Buffer size when creating actual VT100 commands.
     42 *
     43 * This is absurdly large but since we accept numbers via sysarg_t,
     44 * we make it big enough for the largest value to be on the safe side
     45 * (and to silence compiler too).
     46 *
     47 * TODO: find out if VT100 has some hard limits or perhaps simply cut-out
     48 * values larger than 16 bits or something.
     49 */
     50#define MAX_CONTROL 64
     51
     52typedef enum {
     53        CI_BLACK   = 0,
     54        CI_RED     = 1,
     55        CI_GREEN   = 2,
     56        CI_BROWN   = 3,
     57        CI_BLUE    = 4,
     58        CI_MAGENTA = 5,
     59        CI_CYAN    = 6,
     60        CI_WHITE   = 7
     61} sgr_color_index_t;
     62
     63typedef enum {
     64        SGR_RESET       = 0,
     65        SGR_BOLD        = 1,
     66        SGR_UNDERLINE   = 4,
     67        SGR_BLINK       = 5,
     68        SGR_REVERSE     = 7,
     69        SGR_FGCOLOR     = 30,
     70        SGR_BGCOLOR     = 40
     71} sgr_command_t;
     72
     73typedef void (*vt100_putuchar_t)(void *, char32_t ch);
     74typedef void (*vt100_control_puts_t)(void *, const char *str);
     75typedef void (*vt100_flush_t)(void *);
    4176
    4277typedef struct {
     
    4883        char_attrs_t cur_attrs;
    4984
     85        bool enable_rgb;
     86
     87        void *arg;
    5088        vt100_putuchar_t putuchar;
    5189        vt100_control_puts_t control_puts;
     
    5391} vt100_state_t;
    5492
    55 extern vt100_state_t *vt100_state_create(sysarg_t, sysarg_t, vt100_putuchar_t,
    56     vt100_control_puts_t, vt100_flush_t);
     93extern sgr_color_index_t color_map[];
     94
     95extern vt100_state_t *vt100_state_create(void *, sysarg_t, sysarg_t,
     96    vt100_putuchar_t, vt100_control_puts_t, vt100_flush_t);
    5797extern void vt100_state_destroy(vt100_state_t *);
    5898
     
    61101extern void vt100_get_dimensions(vt100_state_t *, sysarg_t *, sysarg_t *);
    62102
     103extern void vt100_cls(vt100_state_t *);
     104extern void vt100_set_pos(vt100_state_t *, sysarg_t, sysarg_t);
    63105extern void vt100_goto(vt100_state_t *, sysarg_t, sysarg_t);
     106extern void vt100_set_sgr(vt100_state_t *, char_attrs_t);
    64107extern void vt100_set_attr(vt100_state_t *, char_attrs_t);
    65108extern void vt100_cursor_visibility(vt100_state_t *, bool);
Note: See TracChangeset for help on using the changeset viewer.