3 #define CONTINUE 2 /* as opposed to EXIT_SUCCESS and EXIT_FAILURE */
5 #define CONTROL(char) (char ^ 0x40)
6 #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
7 #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
11 * 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 */
49 Line
*current
; /* selected line, highlighted */
50 Line
*first
; /* boundaries of the linked list */
62 Buffer
* fill_buffer(char *);
63 void free_buffer(Buffer
*);
64 Line
* add_line(Buffer
*, int, char *, char *, Line
*);
65 Line
* new_line(char *, char *);
66 Line
* matching_next(Line
*);
67 Line
* matching_prev(Line
*);
68 int match_line(Line
*, char **, size_t);
69 void filter_lines(Buffer
*, int);
74 void draw_screen(Buffer
*, int, Opt
*);
76 void draw_line(Line
*, int, int, Opt
*);
77 void draw_lines(Buffer
*, int, int, Opt
*);
78 void draw_prompt(Buffer
*, int, Opt
*);
83 int input_get(Buffer
*, int, Opt
*);
84 int input_key(FILE *, Buffer
*, Opt
*);
85 void action_jump(Buffer
*, int);
86 void action_print_selection(Buffer
*,int, Opt
*);
87 void action_remove_word_input(Buffer
*);
88 void action_add_character(Buffer
*, char);
93 void die(const char *);
94 struct termios
set_terminal(int);
95 char * expand_tabs(char *);