| ... | ... |
@@ -225,9 +225,10 @@ void run(tty_t *tty){
|
| 225 | 225 |
} |
| 226 | 226 |
|
| 227 | 227 |
static const char *usage_str = "" |
| 228 |
-"USAGE: fzy [OPTION]...\n" |
|
| 229 |
-" -l, --lines=LINES Specify how many lines of results to show\n" |
|
| 228 |
+"Usage: fzy [OPTION]...\n" |
|
| 229 |
+" -l, --lines=LINES Specify how many lines of results to show (default 10)\n" |
|
| 230 | 230 |
" -e, --show-matches=QUERY output the sorted matches of QUERY\n" |
| 231 |
+" -t, --tty=TTY Specify file to use as TTY device (default /dev/tty)\n" |
|
| 231 | 232 |
" -s, --show-scores show the scores of each match\n" |
| 232 | 233 |
" -h, --help display this help and exit\n" |
| 233 | 234 |
" -v, --version output version information and exit\n"; |
| ... | ... |
@@ -239,6 +240,7 @@ void usage(const char *argv0){
|
| 239 | 240 |
static struct option longopts[] = {
|
| 240 | 241 |
{ "show-matches", required_argument, NULL, 'e' },
|
| 241 | 242 |
{ "lines", required_argument, NULL, 'l' },
|
| 243 |
+ { "tty", required_argument, NULL, 't' },
|
|
| 242 | 244 |
{ "show-scores", no_argument, NULL, 's' },
|
| 243 | 245 |
{ "version", no_argument, NULL, 'v' },
|
| 244 | 246 |
{ "benchmark", no_argument, NULL, 'b' },
|
| ... | ... |
@@ -249,8 +251,9 @@ static struct option longopts[] = {
|
| 249 | 251 |
int main(int argc, char *argv[]){
|
| 250 | 252 |
int benchmark = 0; |
| 251 | 253 |
char *initial_query = NULL; |
| 254 |
+ char *tty_filename = "/dev/tty"; |
|
| 252 | 255 |
char c; |
| 253 |
- while((c = getopt_long(argc, argv, "vhse:l:", longopts, NULL)) != -1){
|
|
| 256 |
+ while((c = getopt_long(argc, argv, "vhse:l:t:", longopts, NULL)) != -1){
|
|
| 254 | 257 |
switch(c){
|
| 255 | 258 |
case 'v': |
| 256 | 259 |
printf("%s " VERSION " (c) 2014 John Hawthorn\n", argv[0]);
|
| ... | ... |
@@ -264,6 +267,9 @@ int main(int argc, char *argv[]){
|
| 264 | 267 |
case 'b': |
| 265 | 268 |
benchmark = 1; |
| 266 | 269 |
break; |
| 270 |
+ case 't': |
|
| 271 |
+ tty_filename = optarg; |
|
| 272 |
+ break; |
|
| 267 | 273 |
case 'l': |
| 268 | 274 |
{
|
| 269 | 275 |
int l; |
| ... | ... |
@@ -308,7 +314,7 @@ int main(int argc, char *argv[]){
|
| 308 | 314 |
}else{
|
| 309 | 315 |
/* interactive */ |
| 310 | 316 |
tty_t tty; |
| 311 |
- tty_init(&tty); |
|
| 317 |
+ tty_init(&tty, tty_filename); |
|
| 312 | 318 |
|
| 313 | 319 |
run(&tty); |
| 314 | 320 |
} |
| ... | ... |
@@ -10,9 +10,9 @@ void tty_reset(tty_t *tty){
|
| 10 | 10 |
tcsetattr(tty->fdin, TCSANOW, &tty->original_termios); |
| 11 | 11 |
} |
| 12 | 12 |
|
| 13 |
-void tty_init(tty_t *tty){
|
|
| 14 |
- tty->fdin = open("/dev/tty", O_RDONLY);
|
|
| 15 |
- tty->fout = fopen("/dev/tty", "w");
|
|
| 13 |
+void tty_init(tty_t *tty, const char *tty_filename){
|
|
| 14 |
+ tty->fdin = open(tty_filename, O_RDONLY); |
|
| 15 |
+ tty->fout = fopen(tty_filename, "w"); |
|
| 16 | 16 |
setvbuf(tty->fout, NULL, _IOFBF, 4096); |
| 17 | 17 |
|
| 18 | 18 |
tcgetattr(tty->fdin, &tty->original_termios); |