| ... | ... |
@@ -8,6 +8,8 @@ |
| 8 | 8 |
#include "fzy.h" |
| 9 | 9 |
#include "tty.h" |
| 10 | 10 |
|
| 11 |
+int flag_show_scores = 0; |
|
| 12 |
+ |
|
| 11 | 13 |
#define INITIAL_CAPACITY 1 |
| 12 | 14 |
int choices_capacity = 0; |
| 13 | 15 |
int choices_n = 0; |
| ... | ... |
@@ -136,7 +138,10 @@ void draw(tty_t *tty){
|
| 136 | 138 |
tty_newline(tty); |
| 137 | 139 |
for(size_t i = start; i < start + NUMLINES; i++){
|
| 138 | 140 |
if(i < choices_available){
|
| 139 |
- draw_match(tty, choices[choices_sorted[i]], i == current_selection); |
|
| 141 |
+ size_t choice_idx = choices_sorted[i]; |
|
| 142 |
+ if(flag_show_scores) |
|
| 143 |
+ tty_printf(tty, "(%5.2f) ", choices_score[choice_idx]); |
|
| 144 |
+ draw_match(tty, choices[choice_idx], i == current_selection); |
|
| 140 | 145 |
}else{
|
| 141 | 146 |
tty_newline(tty); |
| 142 | 147 |
} |
| ... | ... |
@@ -218,6 +223,7 @@ void run(tty_t *tty){
|
| 218 | 223 |
|
| 219 | 224 |
static const char *usage_str = "" |
| 220 | 225 |
"USAGE: fzy [OPTION]...\n" |
| 226 |
+" -s, --show-scores show the scores of each match\n" |
|
| 221 | 227 |
" -h, --help display this help and exit\n" |
| 222 | 228 |
" -v, --version output version information and exit\n"; |
| 223 | 229 |
|
| ... | ... |
@@ -227,6 +233,7 @@ void usage(const char *argv0){
|
| 227 | 233 |
} |
| 228 | 234 |
|
| 229 | 235 |
static struct option longopts[] = {
|
| 236 |
+ { "show-scores", no_argument, NULL, 's' },
|
|
| 230 | 237 |
{ "version", no_argument, NULL, 'v' },
|
| 231 | 238 |
{ "help", no_argument, NULL, 'h' },
|
| 232 | 239 |
{ NULL, 0, NULL, 0 }
|
| ... | ... |
@@ -235,11 +242,14 @@ static struct option longopts[] = {
|
| 235 | 242 |
|
| 236 | 243 |
int main(int argc, char *argv[]){
|
| 237 | 244 |
char c; |
| 238 |
- while((c = getopt_long(argc, argv, "vh", longopts, NULL)) != -1){
|
|
| 245 |
+ while((c = getopt_long(argc, argv, "vhs", longopts, NULL)) != -1){
|
|
| 239 | 246 |
switch(c){
|
| 240 | 247 |
case 'v': |
| 241 | 248 |
printf("%s " VERSION " (c) 2014 John Hawthorn\n", argv[0]);
|
| 242 | 249 |
exit(EXIT_SUCCESS); |
| 250 |
+ case 's': |
|
| 251 |
+ flag_show_scores = 1; |
|
| 252 |
+ break; |
|
| 243 | 253 |
case 'h': |
| 244 | 254 |
default: |
| 245 | 255 |
usage(argv[0]); |