File src/hstr.c changed (mode: 100644) (index a6d2487..0a9af5e) |
10 |
10 |
#define _GNU_SOURCE |
#define _GNU_SOURCE |
11 |
11 |
|
|
12 |
12 |
#include <curses.h> |
#include <curses.h> |
|
13 |
|
#include <signal.h> |
13 |
14 |
#include <stdbool.h> |
#include <stdbool.h> |
14 |
15 |
#include <stddef.h> |
#include <stddef.h> |
15 |
16 |
#include <stdio.h> |
#include <stdio.h> |
|
... |
... |
void selection_remove(char *cmd, HistoryItems *history) |
305 |
306 |
} |
} |
306 |
307 |
} |
} |
307 |
308 |
|
|
|
309 |
|
void hstr_on_exit(char *command) { |
|
310 |
|
history_mgmt_close(); |
|
311 |
|
fill_terminal_input(command, true); |
|
312 |
|
free_prioritized_history(); |
|
313 |
|
} |
|
314 |
|
|
|
315 |
|
void signal_callback_handler_ctrl_c(int signum) |
|
316 |
|
{ |
|
317 |
|
hstr_on_exit(NULL); |
|
318 |
|
exit(signum); |
|
319 |
|
} |
|
320 |
|
|
308 |
321 |
char *selection_loop(HistoryItems *history) |
char *selection_loop(HistoryItems *history) |
309 |
322 |
{ |
{ |
|
323 |
|
//signal(SIGINT, signal_callback_handler_ctrl_c); |
|
324 |
|
|
310 |
325 |
initscr(); |
initscr(); |
311 |
326 |
color_start(); |
color_start(); |
312 |
327 |
|
|
|
... |
... |
void hstr() |
477 |
492 |
if(history) { |
if(history) { |
478 |
493 |
history_mgmt_open(); |
history_mgmt_open(); |
479 |
494 |
char *command = selection_loop(history); |
char *command = selection_loop(history); |
480 |
|
history_mgmt_close(); |
|
481 |
|
fill_terminal_input(command, true); |
|
482 |
|
free_prioritized_history(); |
|
|
495 |
|
hstr_on_exit(command); |
483 |
496 |
} else { |
} else { |
484 |
497 |
printf("Empty shell history - nothing to suggest...\n"); |
printf("Empty shell history - nothing to suggest...\n"); |
485 |
498 |
} |
} |