14 main(int argc
, char *argv
[])
17 Buffer
*buffer
= NULL
;
18 int tty_fd
= open("/dev/tty", O_RDWR
);
19 Opt
*opt
= malloc(sizeof(Opt
));
21 opt
->line_numbers
= FALSE
;
22 opt
->complete
= FALSE
;
23 opt
->print_numbers
= FALSE
;
24 opt
->validate_key
= CONTROL('M');
25 opt
->separator
= NULL
;
29 /* command line arguments */
30 for (i
= 0; i
< argc
; i
++) {
31 if (argv
[i
][0] == '-') {
34 opt
->line_numbers
= TRUE
;
40 opt
->print_numbers
= TRUE
;
41 opt
->line_numbers
= TRUE
;
44 opt
->validate_key
= (argv
[i
++][0] == '^') ?
49 opt
->separator
= argv
[++i
];
52 if (sscanf(argv
[++i
], "%d", &opt
->lines
) <= 0)
53 die("Wrong number format after -l.");
56 opt
->prompt
= argv
[++i
];
62 /* command line arguments */
63 buffer
= fill_buffer(opt
->separator
);
65 /* set the interface */
66 filter_lines(buffer
, opt
);
67 draw_screen(buffer
, tty_fd
, opt
);
69 /* listen and interact to input */
70 input_get(buffer
, tty_fd
, opt
);
72 draw_clear(opt
->lines
);
74 /* close files descriptors and pointers, and free memory */