Changeset ebb1489 in mainline for uspace/lib/termui/src/history.h


Ignore:
Timestamp:
2024-10-13T08:23:40Z (8 weeks ago)
Author:
GitHub <noreply@…>
Children:
0472cf17
Parents:
2a0c827c (diff), b3b79981 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
boba-buba <120932204+boba-buba@…> (2024-10-13 08:23:40)
git-committer:
GitHub <noreply@…> (2024-10-13 08:23:40)
Message:

Merge branch 'HelenOS:master' into topic/packet-capture

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/termui/src/history.h

    r2a0c827c rebb1489  
    11/*
    2  * Copyright (c) 2011 Martin Decky
     2 * Copyright (c) 2024 Jiří Zárevúcky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup output
    30  * @{
    31  */
     29#include <termui.h>
     30#include <stdbool.h>
    3231
    33 #ifndef OUTPUT_PROTO_VT100_H_
    34 #define OUTPUT_PROTO_VT100_H_
     32#define INTERNAL __attribute__((visibility("internal")))
    3533
    36 #include <io/charfield.h>
     34static bool _cell_is_empty(const termui_cell_t cell)
     35{
     36        return cell.glyph_idx == 0 && cell.bgcolor == 0 && cell.fgcolor == 0 &&
     37            cell.padding == 0;
     38}
    3739
    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);
     40struct cell_buffer {
     41        termui_cell_t *buf;
    4142
    42 typedef struct {
    43         sysarg_t cols;
    44         sysarg_t rows;
     43        size_t head_offset;
     44        size_t head_top;
    4545
    46         sysarg_t cur_col;
    47         sysarg_t cur_row;
    48         char_attrs_t cur_attrs;
     46        /* Tail offset is implicitly zero. */
     47        size_t tail_top;
    4948
    50         vt100_putuchar_t putuchar;
    51         vt100_control_puts_t control_puts;
    52         vt100_flush_t flush;
    53 } vt100_state_t;
     49        size_t buf_len;
     50        size_t max_len;
     51};
    5452
    55 extern vt100_state_t *vt100_state_create(sysarg_t, sysarg_t, vt100_putuchar_t,
    56     vt100_control_puts_t, vt100_flush_t);
    57 extern void vt100_state_destroy(vt100_state_t *);
     53struct history_line {
     54        size_t idx;
     55        size_t len;
     56};
    5857
    59 extern errno_t vt100_yield(vt100_state_t *);
    60 extern errno_t vt100_claim(vt100_state_t *);
    61 extern void vt100_get_dimensions(vt100_state_t *, sysarg_t *, sysarg_t *);
     58struct line_buffer {
     59        struct history_line *buf;
    6260
    63 extern void vt100_goto(vt100_state_t *, sysarg_t, sysarg_t);
    64 extern void vt100_set_attr(vt100_state_t *, char_attrs_t);
    65 extern void vt100_cursor_visibility(vt100_state_t *, bool);
    66 extern void vt100_putuchar(vt100_state_t *, char32_t);
    67 extern void vt100_flush(vt100_state_t *);
     61        size_t head;
     62        size_t tail;
    6863
    69 #endif
     64        size_t buf_len;
     65        size_t max_len;
     66};
    7067
    71 /** @}
    72  */
     68struct history {
     69        size_t viewport_top;
     70        size_t row_delta;
     71
     72        size_t cols;
     73
     74        struct cell_buffer cells;
     75        struct line_buffer lines;
     76
     77        bool append;
     78};
     79
     80INTERNAL bool _scrollback_active(const struct history *history);
     81INTERNAL void _history_append_row(struct history *history, const termui_cell_t *b, bool last);
     82INTERNAL int _history_viewport_rows(const struct history *history, size_t max);
     83INTERNAL int _history_iter_rows(const struct history *history, int row, int count, termui_update_cb_t cb, void *udata);
     84INTERNAL int _history_scroll(struct history *history, int delta);
     85INTERNAL const termui_cell_t *_history_reflow(struct history *history, size_t new_cols, size_t *recouped);
Note: See TracChangeset for help on using the changeset viewer.