Changeset ebb1489 in mainline for uspace/lib/termui/src/history.h
- Timestamp:
- 2024-10-13T08:23:40Z (8 weeks ago)
- 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)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/termui/src/history.h
r2a0c827c rebb1489 1 1 /* 2 * Copyright (c) 20 11 Martin Decky2 * Copyright (c) 2024 Jiří Zárevúcky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup output 30 * @{ 31 */ 29 #include <termui.h> 30 #include <stdbool.h> 32 31 33 #ifndef OUTPUT_PROTO_VT100_H_ 34 #define OUTPUT_PROTO_VT100_H_ 32 #define INTERNAL __attribute__((visibility("internal"))) 35 33 36 #include <io/charfield.h> 34 static 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 } 37 39 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); 40 struct cell_buffer { 41 termui_cell_t *buf; 41 42 42 typedef struct { 43 sysarg_t cols; 44 sysarg_t rows; 43 size_t head_offset; 44 size_t head_top; 45 45 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; 49 48 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 }; 54 52 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 *); 53 struct history_line { 54 size_t idx; 55 size_t len; 56 }; 58 57 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 *); 58 struct line_buffer { 59 struct history_line *buf; 62 60 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; 68 63 69 #endif 64 size_t buf_len; 65 size_t max_len; 66 }; 70 67 71 /** @} 72 */ 68 struct 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 80 INTERNAL bool _scrollback_active(const struct history *history); 81 INTERNAL void _history_append_row(struct history *history, const termui_cell_t *b, bool last); 82 INTERNAL int _history_viewport_rows(const struct history *history, size_t max); 83 INTERNAL int _history_iter_rows(const struct history *history, int row, int count, termui_update_cb_t cb, void *udata); 84 INTERNAL int _history_scroll(struct history *history, int delta); 85 INTERNAL 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.