5 #define LENGTH(x) (sizeof(x) / sizeof(*x))
6 #define CONTROL(char) (char ^ 0x40)
7 #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
8 #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
11 enum { PREV
= 0, NEXT
, ANY
};
15 * 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
*current
; /* selected line, highlighted */
54 Line
*first
; /* boundaries of the linked list */
66 Buffer
* fill_buffer(char *);
67 void free_buffer(Buffer
*);
68 void free_line(Line
*);
69 Line
* add_line(Buffer
*, int, char *, char *, Line
*);
70 Line
* parse_line(char *, char *);
71 Line
* matching_next(Line
*);
72 Line
* matching_prev(Line
*);
73 int match_line(Line
*, char *[], int);
74 void filter_lines(Buffer
*, int);
79 void draw_screen(Buffer
*, int, Opt
*);
81 void draw_line(Line
*, int, int, Opt
*);
82 void draw_lines(Buffer
*, int, int, Opt
*);
83 void draw_prompt(Buffer
*, int, Opt
*);
88 int input_get(Buffer
*, int, Opt
*);
89 int input_key(FILE *, Buffer
*, Opt
*);
90 void action_jump(Buffer
*, int);
91 void action_print_selection(Buffer
*,int, int);
92 void action_remove_word_input(Buffer
*);
93 void action_add_character(Buffer
*, char);
98 void die(const char *);
99 struct termios
set_terminal(int);
100 char * expand_tabs(char *);