| ... | ... |
@@ -1,3 +1,4 @@ |
| 1 |
+#define _GNU_SOURCE |
|
| 1 | 2 |
#include <stdio.h> |
| 2 | 3 |
#include <string.h> |
| 3 | 4 |
#include <stdlib.h> |
| ... | ... |
@@ -16,7 +17,7 @@ int choices_n = 0; |
| 16 | 17 |
const char **choices = NULL; |
| 17 | 18 |
double *choices_score = NULL; |
| 18 | 19 |
size_t *choices_sorted = NULL; |
| 19 |
-int current_selection = 0; |
|
| 20 |
+size_t current_selection = 0; |
|
| 20 | 21 |
|
| 21 | 22 |
void resize_choices(int new_capacity){
|
| 22 | 23 |
choices = realloc(choices, new_capacity * sizeof(const char *)); |
| ... | ... |
@@ -137,11 +138,10 @@ void clear(){
|
| 137 | 138 |
|
| 138 | 139 |
void draw(){
|
| 139 | 140 |
int line = 0; |
| 140 |
- int i; |
|
| 141 | 141 |
const char *prompt = "> "; |
| 142 | 142 |
clear(); |
| 143 | 143 |
fprintf(ttyout, "%s%s\n", prompt, search); |
| 144 |
- for(i = 0; line < 10 && i < choices_available; i++){
|
|
| 144 |
+ for(size_t i = 0; line < 10 && i < choices_available; i++){
|
|
| 145 | 145 |
if(i == current_selection) |
| 146 | 146 |
fprintf(ttyout, "%c%c7m", 0x1b, '['); |
| 147 | 147 |
else |
| ... | ... |
@@ -150,7 +150,7 @@ void draw(){
|
| 150 | 150 |
line++; |
| 151 | 151 |
} |
| 152 | 152 |
fprintf(ttyout, "%c%c%iA", 0x1b, '[', line + 1); |
| 153 |
- fprintf(ttyout, "%c%c%iG", 0x1b, '[', strlen(prompt) + strlen(search) + 1); |
|
| 153 |
+ fprintf(ttyout, "%c%c%ziG", 0x1b, '[', strlen(prompt) + strlen(search) + 1); |
|
| 154 | 154 |
fflush(ttyout); |
| 155 | 155 |
} |
| 156 | 156 |
|