iPXE
jumpscroll.h
Go to the documentation of this file.
1#ifndef _IPXE_JUMPSCROLL_H
2#define _IPXE_JUMPSCROLL_H
3
4/** @file
5 *
6 * Jump scrolling
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <stdint.h>
14
15/** A jump scroller */
17 /** Maximum number of visible rows */
18 unsigned int rows;
19 /** Total number of items */
20 unsigned int count;
21 /** Currently selected item */
22 unsigned int current;
23 /** First visible item */
24 unsigned int first;
25};
26
27/**
28 * Construct scroll movement
29 *
30 * @v delta Change in scroller position
31 * @ret move Scroll movement
32 */
33#define SCROLL( delta ) ( ( unsigned int ) ( uint16_t ) ( int16_t ) (delta) )
34
35/**
36 * Extract change in scroller position
37 *
38 * @v move Scroll movement
39 * @ret delta Change in scroller position
40 */
41#define SCROLL_DELTA( scroll ) ( ( int16_t ) ( (scroll) & 0x0000ffffUL ) )
42
43/** Scroll movement flags */
44#define SCROLL_FLAGS 0xffff0000UL
45#define SCROLL_WRAP 0x80000000UL /**< Wrap around scrolling */
46
47/** Do not scroll */
48#define SCROLL_NONE SCROLL ( 0 )
49
50/** Scroll up by one line */
51#define SCROLL_UP SCROLL ( -1 )
52
53/** Scroll down by one line */
54#define SCROLL_DOWN SCROLL ( +1 )
55
56/**
57 * Check if jump scroller is currently on first page
58 *
59 * @v scroll Jump scroller
60 * @ret is_first Scroller is currently on first page
61 */
62static inline int jump_scroll_is_first ( struct jump_scroller *scroll ) {
63
64 return ( scroll->first == 0 );
65}
66
67/**
68 * Check if jump scroller is currently on last page
69 *
70 * @v scroll Jump scroller
71 * @ret is_last Scroller is currently on last page
72 */
73static inline int jump_scroll_is_last ( struct jump_scroller *scroll ) {
74
75 return ( ( scroll->first + scroll->rows ) >= scroll->count );
76}
77
78extern unsigned int jump_scroll_key ( struct jump_scroller *scroll, int key );
79extern unsigned int jump_scroll_move ( struct jump_scroller *scroll,
80 unsigned int move );
81extern int jump_scroll ( struct jump_scroller *scroll );
82
83#endif /* _IPXE_JUMPSCROLL_H */
union @162305117151260234136356364136041353210355154177 key
Sense key.
Definition scsi.h:3
static int move(int y, int x)
Definition curses.h:594
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
unsigned int jump_scroll_move(struct jump_scroller *scroll, unsigned int move)
Move scroller.
Definition jumpscroll.c:93
static int jump_scroll_is_first(struct jump_scroller *scroll)
Check if jump scroller is currently on first page.
Definition jumpscroll.h:62
unsigned int jump_scroll_key(struct jump_scroller *scroll, int key)
Jump scrolling.
Definition jumpscroll.c:43
static int jump_scroll_is_last(struct jump_scroller *scroll)
Check if jump scroller is currently on last page.
Definition jumpscroll.h:73
int jump_scroll(struct jump_scroller *scroll)
Jump scroll to new page (if applicable)
Definition jumpscroll.c:141
A jump scroller.
Definition jumpscroll.h:16
unsigned int count
Total number of items.
Definition jumpscroll.h:20
unsigned int first
First visible item.
Definition jumpscroll.h:24
unsigned int rows
Maximum number of visible rows.
Definition jumpscroll.h:18
unsigned int current
Currently selected item.
Definition jumpscroll.h:22