[go: up one dir, main page]

File: tbox.h

package info (click to toggle)
s390-tools 2.3.0-2~deb10u1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 6,188 kB
  • sloc: ansic: 87,755; sh: 8,398; cpp: 8,384; perl: 3,783; makefile: 1,476; asm: 654
file content (54 lines) | stat: -rw-r--r-- 1,169 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 * hyptop - Show hypervisor performance data on System z
 *
 * Text box: Provide scrollable text window under curses.
 *
 * Copyright IBM Corp. 2010, 2017
 *
 * s390-tools is free software; you can redistribute it and/or modify
 * it under the terms of the MIT license. See LICENSE for details.
 */

#ifndef TBOX_H
#define TBOX_H

#include "lib/util_list.h"

#define TBOX_MAX_STR	120

struct tbox_line {
	struct util_list_node	list;
	char			*str;
};

struct tbox {
	struct util_list	line_list;
	int			line_cnt;
	int			line_start;
	int			tbox_ready;
	struct tbox_line	*last_line;
};

enum tbox_scroll_unit {
	TBOX_SCROLL_LINE,
	TBOX_SCROLL_PAGE,
	TBOX_SCROLL_LAST,
};

struct tbox *tbox_new(void);
void tbox_line_del_all(struct tbox *tb);
void tbox_line_add(struct tbox *tb, const char *str);
void tbox_finish(struct tbox *tb);
void tbox_scroll_down(struct tbox *tb, enum tbox_scroll_unit);
void tbox_scroll_up(struct tbox *tb, enum tbox_scroll_unit);
void tbox_term_resize(struct tbox *tb);
void tbox_print(struct tbox *tb);

#define tbox_printf(tb, x...) \
{ \
	char line[TBOX_MAX_STR + 1]; \
	sprintf(line, x); \
	tbox_line_add(tb, line); \
}

#endif /* TBOX_H */