17 main(int argc
, char *argv
[])
20 Buffer
*buffer
= NULL
;
22 int tty_fd
= open("/dev/tty", O_RDWR
);
23 Opt
*opt
= malloc(sizeof(Opt
));
25 opt
->line_numbers
= FALSE
;
26 opt
->complete
= FALSE
;
27 opt
->print_numbers
= FALSE
;
28 opt
->validate_key
= CONTROL('M');
29 opt
->separator
= NULL
;
33 /* command line arguments */
34 for (i
= 0; i
< argc
; i
++) {
35 if (argv
[i
][0] == '-') {
38 opt
->line_numbers
= TRUE
;
44 opt
->print_numbers
= TRUE
;
45 opt
->line_numbers
= TRUE
;
48 opt
->validate_key
= (argv
[i
++][0] == '^') ?
53 opt
->separator
= argv
[++i
];
56 if (sscanf(argv
[++i
], "%d", &opt
->lines
) <= 0)
57 die("Wrong number format after -l.");
60 opt
->prompt
= argv
[++i
];
66 /* command line arguments */
67 buffer
= fill_buffer(opt
->separator
);
69 /* set the interface */
70 filter_lines(buffer
, opt
);
71 draw_screen(buffer
, offset
, tty_fd
, opt
);
73 /* listen and interact to input */
74 input_get(buffer
, offset
, tty_fd
, opt
);
76 draw_clear(opt
->lines
);
78 /* close files descriptors and pointers, and free memory */