/*********************************************************************/
-void inject_into_tty_buffer(char *string) {
+void inject_into_tty_buffer(char *string, int add_control_qs) {
struct termios oldtio, newtio;
const char *k;
const char control_q = '\021';
}
}
+/*********************************************************************/
+
/* A quick and dirty hash table */
-/* The table itself stores indexes of the strings taken in a char
- **table. When a string is added, if it was already in the table,
- **the new index replaces the previous one. */
+/* The table itself stores indexes of the strings taken in a char**
+ table. When a string is added, if it was already in the table, the
+ new index replaces the previous one. */
-typedef struct {
+struct hash_table_t {
int size;
int *entries;
-} hash_table_t;
+};
-hash_table_t *new_hash_table(int size) {
+struct hash_table_t *new_hash_table(int size) {
int k;
- hash_table_t *hash_table;
+ struct hash_table_t *hash_table;
- hash_table = (hash_table_t *) malloc(sizeof(hash_table_t));
+ hash_table = (struct hash_table_t *) malloc(sizeof(struct hash_table_t));
hash_table->size = size;
hash_table->entries = (int *) malloc(hash_table->size * sizeof(int));
return hash_table;
}
-void free_hash_table(hash_table_t *hash_table) {
+void free_hash_table(struct hash_table_t *hash_table) {
free(hash_table->entries);
free(hash_table);
}
string was not already in the table, returns -1. Otherwise, returns
the previous index it had. */
-int add_and_get_previous_index(hash_table_t *hash_table,
+int add_and_get_previous_index(struct hash_table_t *hash_table,
const char *new_string, int new_index,
char **strings) {
/*********************************************************************/
-void store_line(hash_table_t *hash_table,
+void store_line(struct hash_table_t *hash_table,
const char *new_line,
int *nb_lines, char **lines) {
int dup;
(*nb_lines)++;
}
-void read_file(hash_table_t *hash_table,
+void read_file(struct hash_table_t *hash_table,
const char *input_filename,
int nb_lines_max, int *nb_lines, char **lines) {
char **lines, **labels;
int nb_lines;
- hash_table_t *hash_table;
+ struct hash_table_t *hash_table;
if(!ttyname(STDIN_FILENO)) {
fprintf(stderr, "Selector: The standard input is not a tty.\n");
initscr();
cbreak();
noecho();
- /* nonl(); */
intrflush(stdscr, FALSE);
/* So that the arrow keys work */
}
else if(key == '\014') { /* ^L */
- /* I suspect that we may sometime mess up the display */
+ /* I suspect that we may sometime mess up the display, so ^L is
+ here to force a full refresh */
clear();
}
}
if(output_to_vt_buffer && t) {
- inject_into_tty_buffer(t);
+ inject_into_tty_buffer(t, add_control_qs);
}
if(output_filename[0]) {