3 #define LENGTH(x) (sizeof(x) / sizeof(*x))
4 #define CONTROL(char) (char ^ 0x40)
5 #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
6 #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
9 enum { FALSE
= 0, TRUE
= 1, EXIT
= 2 };
10 enum { NEXT
= 0, PREV
= 1, BOTH
= 2 };
14 * Options from the command line, to pass to each function that need some
28 * Line coming from stdin, wrapped in a header.
31 char *content
; /* sent as output and matched by input */
32 char *comment
; /* displayed at the right of the content */
34 int number
; /* set here as order will not change */
35 int matches
; /* whether it matches buffer's input */
36 int header
; /* whether the line is a header */
38 struct Line
*prev
; /* doubly linked list structure */
44 * Buffer containing a doubly linked list of headers
46 typedef struct Buffer
{
47 int total
; /* total number of line in buffer */
48 int matching
; /* number lines matching the input */
50 char input
[LINE_SIZE
]; /* string from user's keyboard */
51 char *prompt
; /* specified from the command line */
53 Line
*empty
; /* empty line, for when needed */
54 Line
*current
; /* selected line, highlighted */
55 Line
*first
; /* boundaries of the linked list */
62 Buffer
* fill_buffer(char *);
63 void free_buffer(Buffer
*);
64 void free_line(Line
*);
65 Line
* add_line(Buffer
*, int, char *, char *, Line
*);
66 Line
* parse_line(char *, char *);
67 Line
* matching_next(Line
*);
68 Line
* matching_prev(Line
*);
69 int line_match_input(Line
*, char *, Opt
*);
70 void filter_lines(Buffer
*, Opt
*);
75 void draw_screen(Buffer
*, int, int, Opt
*);
77 void draw_line(Line
*, int, int, Opt
*);
78 void draw_lines(Buffer
*, int, int, int, Opt
*);
79 void draw_prompt(Buffer
*, int, Opt
*);
84 void input_get(Buffer
*, int, int, Opt
*);
85 int input_key(char, Buffer
*, Opt
*);
86 void action_jump(Buffer
*, int, Opt
*);
87 void action_print_selection(Buffer
*, Opt
*);
88 void action_remove_word_input(Buffer
*);
89 void action_add_character(Buffer
*, char, Opt
*);
94 void die(const char *);
95 struct termios
set_terminal(int);
96 char * expand_tabs(char *);