File configure.ac changed (mode: 100644) (index 0d3261f..ea00353) |
... |
... |
AC_CONFIG_SRCDIR([src/hstr.c]) |
17 |
17 |
AC_PROG_CC |
AC_PROG_CC |
18 |
18 |
|
|
19 |
19 |
# Checks for libraries. |
# Checks for libraries. |
20 |
|
AC_CHECK_LIB(ncurses, initscr) |
|
21 |
|
AC_CHECK_LIB(m,cos) |
|
22 |
|
AC_CHECK_LIB(readline, using_history) |
|
|
20 |
|
AC_CHECK_LIB(ncurses, initscr, [], [AC_MSG_ERROR([Could not find Curses library])]) |
|
21 |
|
AC_CHECK_LIB(m, cos, [], [AC_MSG_ERROR([Could not find Math library])]) |
|
22 |
|
AC_CHECK_LIB(readline, using_history, [], [AC_MSG_ERROR([Could not find Readline library])]) |
23 |
23 |
|
|
24 |
24 |
# Checks for header files. |
# Checks for header files. |
25 |
25 |
AC_CHECK_HEADER(assert.h) |
AC_CHECK_HEADER(assert.h) |
|
26 |
|
AC_CHECK_HEADER(ctype.h) |
26 |
27 |
AC_CHECK_HEADER(curses.h) |
AC_CHECK_HEADER(curses.h) |
27 |
28 |
AC_CHECK_HEADER(fcntl.h) |
AC_CHECK_HEADER(fcntl.h) |
28 |
29 |
AC_CHECK_HEADER(math.h) |
AC_CHECK_HEADER(math.h) |
File src/hstr.c changed (mode: 100644) (index 05691c4..f1766aa) |
21 |
21 |
#include <readline/chardefs.h> |
#include <readline/chardefs.h> |
22 |
22 |
|
|
23 |
23 |
#include "include/hashset.h" |
#include "include/hashset.h" |
24 |
|
#include "include/hstr_utils.h" |
|
|
24 |
|
#include "include/hstr_curses.h" |
25 |
25 |
#include "include/hstr_history.h" |
#include "include/hstr_history.h" |
|
26 |
|
#include "include/hstr_utils.h" |
26 |
27 |
|
|
27 |
|
#define FILE_BASHRC ".bashrc" |
|
28 |
28 |
#define SELECTION_CURSOR_IN_PROMPT -1 |
#define SELECTION_CURSOR_IN_PROMPT -1 |
29 |
29 |
#define SELECTION_PREFIX_MAX_LNG 500 |
#define SELECTION_PREFIX_MAX_LNG 500 |
30 |
30 |
#define CMDLINE_LNG 250 |
#define CMDLINE_LNG 250 |
|
53 |
53 |
#define K_BACKSPACE 127 |
#define K_BACKSPACE 127 |
54 |
54 |
#define K_ENTER 10 |
#define K_ENTER 10 |
55 |
55 |
|
|
56 |
|
#define color_attr_on(C) if(terminalHasColors) { attron(C); } |
|
57 |
|
#define color_attr_off(C) if(terminalHasColors) { attroff(C); } |
|
58 |
|
#define color_init_pair(X, Y, Z) if(terminalHasColors) { init_pair(X, Y, Z); } |
|
59 |
|
|
|
60 |
56 |
#ifdef DEBUG_KEYS |
#ifdef DEBUG_KEYS |
61 |
57 |
#define LOGKEYS(Y,KEY) mvprintw(Y, 0, "Key: '%3d' / Char: '%c'", KEY, KEY); clrtoeol() |
#define LOGKEYS(Y,KEY) mvprintw(Y, 0, "Key: '%3d' / Char: '%c'", KEY, KEY); clrtoeol() |
62 |
58 |
#else |
#else |
|
... |
... |
static const char *LABEL_HELP= |
84 |
80 |
|
|
85 |
81 |
static char **selection=NULL; |
static char **selection=NULL; |
86 |
82 |
static unsigned selectionSize=0; |
static unsigned selectionSize=0; |
87 |
|
static bool terminalHasColors=FALSE; |
|
88 |
83 |
static bool caseSensitive=FALSE; |
static bool caseSensitive=FALSE; |
89 |
84 |
static bool defaultOrder=FALSE; |
static bool defaultOrder=FALSE; |
90 |
85 |
static char screenLine[1000]; |
static char screenLine[1000]; |
|
... |
... |
void print_cmd_deleted_label(char *cmd, int occurences) |
117 |
112 |
refresh(); |
refresh(); |
118 |
113 |
} |
} |
119 |
114 |
|
|
120 |
|
// make this status row |
|
121 |
115 |
void print_history_label(HistoryItems *history) |
void print_history_label(HistoryItems *history) |
122 |
116 |
{ |
{ |
123 |
117 |
sprintf(screenLine, "- HISTORY - case:%s (C-t) - order:%s (C-/) - %d/%d ", |
sprintf(screenLine, "- HISTORY - case:%s (C-t) - order:%s (C-/) - %d/%d ", |
|
... |
... |
void print_selection_row(char *text, int y, int width, char *prefix) { |
232 |
226 |
} |
} |
233 |
227 |
color_attr_off(A_BOLD); |
color_attr_off(A_BOLD); |
234 |
228 |
} |
} |
235 |
|
|
|
236 |
229 |
} |
} |
237 |
230 |
|
|
238 |
231 |
void print_highlighted_selection_row(char *text, int y, int width) { |
void print_highlighted_selection_row(char *text, int y, int width) { |
239 |
232 |
color_attr_on(A_REVERSE); |
color_attr_on(A_REVERSE); |
240 |
233 |
color_attr_on(A_BOLD); |
color_attr_on(A_BOLD); |
241 |
|
snprintf(screenLine, getmaxx(stdscr), "%s%s", (terminalHasColors?" ":">"), text); |
|
|
234 |
|
snprintf(screenLine, getmaxx(stdscr), "%s%s", (terminal_has_colors()?" ":">"), text); |
242 |
235 |
mvprintw(y, 0, "%s", screenLine); |
mvprintw(y, 0, "%s", screenLine); |
243 |
236 |
color_attr_off(A_BOLD); |
color_attr_off(A_BOLD); |
244 |
237 |
color_attr_off(A_REVERSE); |
color_attr_off(A_REVERSE); |
|
... |
... |
void highlight_selection(int selectionCursorPosition, int previousSelectionCurso |
289 |
282 |
} |
} |
290 |
283 |
} |
} |
291 |
284 |
|
|
292 |
|
void color_start() |
|
293 |
|
{ |
|
294 |
|
terminalHasColors=has_colors(); |
|
295 |
|
if(terminalHasColors) { |
|
296 |
|
start_color(); |
|
297 |
|
} |
|
298 |
|
} |
|
299 |
285 |
|
|
300 |
286 |
void selection_remove(char *cmd, HistoryItems *history) |
void selection_remove(char *cmd, HistoryItems *history) |
301 |
287 |
{ |
{ |
|
... |
... |
int main(int argc, char *argv[]) |
548 |
534 |
if(argc>0) { |
if(argc>0) { |
549 |
535 |
if(argc==2 && strstr(argv[1], "--show-configuration")) { |
if(argc==2 && strstr(argv[1], "--show-configuration")) { |
550 |
536 |
install_show(); |
install_show(); |
|
537 |
|
// TODO --help (tr --help) |
551 |
538 |
} else { |
} else { |
552 |
539 |
assemble_cmdline(argc, argv); |
assemble_cmdline(argc, argv); |
553 |
540 |
hstr(); |
hstr(); |