4 #define LENGTH(x) (sizeof(x) / sizeof(*x))
5 #define CONTROL(char) (char ^ 0x40)
6 #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
7 #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
10 enum { FALSE
= 0, TRUE
, EXIT
};
11 enum { PREV
= 0, NEXT
, ANY
};
15 * Options from the command line, to pass to each function that need some
29 * Line coming from stdin, wrapped in a header.
32 char *content
; /* sent as output and matched by input */
33 char *comment
; /* displayed at the right of the content */
35 int number
; /* set here as order will not change */
36 int matches
; /* whether it matches buffer's input */
37 int header
; /* whether the line is a header */
39 struct Line
*prev
; /* doubly linked list structure */
45 * Buffer containing a doubly linked list of headers
47 typedef struct Buffer
{
48 int total
; /* total number of line in buffer */
49 int matching
; /* number lines matching the input */
51 char input
[LINE_SIZE
]; /* string from user's keyboard */
52 char *prompt
; /* specified from the command line */
54 Line
*current
; /* selected line, highlighted */
55 Line
*first
; /* boundaries of the linked list */
67 Buffer
* fill_buffer(char *);
68 void free_buffer(Buffer
*);
69 void free_line(Line
*);
70 Line
* add_line(Buffer
*, int, char *, char *, Line
*);
71 Line
* parse_line(char *, char *);
72 Line
* matching_next(Line
*);
73 Line
* matching_prev(Line
*);
74 int line_match_input(Line
*, char *, Opt
*);
75 void filter_lines(Buffer
*, Opt
*);
80 void draw_screen(Buffer
*, int, Opt
*);
82 void draw_line(Line
*, int, int, Opt
*);
83 void draw_lines(Buffer
*, int, int, Opt
*);
84 void draw_prompt(Buffer
*, int, Opt
*);
89 void input_get(Buffer
*, int, Opt
*);
90 int input_key(char, Buffer
*, Opt
*);
91 void action_jump(Buffer
*, int);
92 void action_print_selection(Buffer
*, Opt
*);
93 void action_remove_word_input(Buffer
*);
94 void action_add_character(Buffer
*, char, Opt
*);
99 void die(const char *);
100 struct termios
set_terminal(int);
101 char * expand_tabs(char *);