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