3 #define CONTINUE 2 /* as opposed to EXIT_SUCCESS and EXIT_FAILURE */
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))
12 * Options from the command line, to pass to each function that need some
25 * Line coming from stdin, wrapped in a header.
28 char *content
; /* sent as output and matched by input */
29 char *comment
; /* displayed at the right of the content */
31 int number
; /* set here as order will not change */
32 int matches
; /* whether it matches buffer's input */
33 int header
; /* whether the line is a header */
35 struct Line
*prev
; /* doubly linked list structure */
41 * Buffer containing a doubly linked list of headers
43 typedef struct Buffer
{
44 int total
; /* total number of line in buffer */
45 int matching
; /* number lines matching the input */
47 char input
[LINE_SIZE
]; /* string from user's keyboard */
48 char *prompt
; /* specified from the command line */
50 Line
*current
; /* selected line, highlighted */
51 Line
*first
; /* boundaries of the linked list */
63 Buffer
* fill_buffer(char *);
64 void free_buffer(Buffer
*);
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 match_line(Line
*, char **, size_t);
70 void filter_lines(Buffer
*, int);
75 void draw_screen(Buffer
*, int, Opt
*);
77 void draw_line(Line
*, int, int, Opt
*);
78 void draw_lines(Buffer
*, int, int, Opt
*);
79 void draw_prompt(Buffer
*, int, Opt
*);
84 int input_get(Buffer
*, int, Opt
*);
85 int input_key(FILE *, Buffer
*, Opt
*);
86 void action_jump(Buffer
*, int);
87 void action_print_selection(Buffer
*,int, int);
88 void action_remove_word_input(Buffer
*);
89 void action_add_character(Buffer
*, char);
94 void die(const char *);
95 struct termios
set_terminal(int);
96 char * expand_tabs(char *);