| File src/hstr.c changed (mode: 100644) (index 36252b1..a61d072) |
| 49 |
49 |
#define K_ENTER 10 |
#define K_ENTER 10 |
| 50 |
50 |
#define K_ESC 27 |
#define K_ESC 27 |
| 51 |
51 |
|
|
|
52 |
|
#define color_attr_on(C) if(terminalHasColors) { attron(C); } |
|
53 |
|
#define color_attr_off(C) if(terminalHasColors) { attroff(C); } |
|
54 |
|
#define color_init_pair(X, Y, Z) if(terminalHasColors) { init_pair(X, Y, Z); } |
|
55 |
|
|
| 52 |
56 |
#ifdef DEBUG_KEYS |
#ifdef DEBUG_KEYS |
| 53 |
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() |
| 54 |
58 |
#else |
#else |
| |
| ... |
... |
int print_prompt() |
| 88 |
92 |
char *user = getenv(ENV_VAR_USER); |
char *user = getenv(ENV_VAR_USER); |
| 89 |
93 |
int xoffset = 1; |
int xoffset = 1; |
| 90 |
94 |
|
|
| 91 |
|
mvwprintw(stdscr, xoffset, Y_OFFSET_PROMPT, "%s@%s$ ", user, hostname); |
|
|
95 |
|
mvprintw(xoffset, Y_OFFSET_PROMPT, "%s@%s$ ", user, hostname); |
| 92 |
96 |
refresh(); |
refresh(); |
| 93 |
97 |
|
|
| 94 |
98 |
return xoffset+strlen(user)+1+strlen(hostname)+1; |
return xoffset+strlen(user)+1+strlen(hostname)+1; |
| |
| ... |
... |
int print_prompt() |
| 97 |
101 |
void print_help_label() |
void print_help_label() |
| 98 |
102 |
{ |
{ |
| 99 |
103 |
snprintf(screenLine, getmaxx(stdscr), "%s", LABEL_HELP); |
snprintf(screenLine, getmaxx(stdscr), "%s", LABEL_HELP); |
| 100 |
|
mvwprintw(stdscr, Y_OFFSET_HELP, 0, screenLine); |
|
|
104 |
|
mvprintw(Y_OFFSET_HELP, 0, screenLine); |
| 101 |
105 |
refresh(); |
refresh(); |
| 102 |
106 |
} |
} |
| 103 |
107 |
|
|
| 104 |
108 |
void print_cmd_deleted_label(char *cmd, int occurences) |
void print_cmd_deleted_label(char *cmd, int occurences) |
| 105 |
109 |
{ |
{ |
| 106 |
110 |
snprintf(screenLine, getmaxx(stdscr), "History item '%s' deleted (%d occurrence%s)", cmd, occurences, (occurences==1?"":"s")); |
snprintf(screenLine, getmaxx(stdscr), "History item '%s' deleted (%d occurrence%s)", cmd, occurences, (occurences==1?"":"s")); |
| 107 |
|
mvwprintw(stdscr, Y_OFFSET_HELP, 0, screenLine); |
|
|
111 |
|
mvprintw(Y_OFFSET_HELP, 0, screenLine); |
| 108 |
112 |
clrtoeol(); |
clrtoeol(); |
| 109 |
113 |
refresh(); |
refresh(); |
| 110 |
114 |
} |
} |
| |
| ... |
... |
void print_history_label(HistoryItems *history) |
| 127 |
131 |
for (i=0; i < width; i++) { |
for (i=0; i < width; i++) { |
| 128 |
132 |
strcat(screenLine, "-"); |
strcat(screenLine, "-"); |
| 129 |
133 |
} |
} |
| 130 |
|
wattron(stdscr, A_REVERSE); |
|
| 131 |
|
mvwprintw(stdscr, Y_OFFSET_HISTORY, 0, screenLine); |
|
| 132 |
|
wattroff(stdscr, A_REVERSE); |
|
|
134 |
|
color_attr_on(A_REVERSE); |
|
135 |
|
mvprintw(Y_OFFSET_HISTORY, 0, screenLine); |
|
136 |
|
color_attr_off(A_REVERSE); |
| 133 |
137 |
refresh(); |
refresh(); |
| 134 |
138 |
} |
} |
| 135 |
139 |
|
|
| |
| ... |
... |
unsigned make_selection(char *prefix, HistoryItems *history, int maxSelectionCou |
| 196 |
200 |
return selectionCount; |
return selectionCount; |
| 197 |
201 |
} |
} |
| 198 |
202 |
|
|
| 199 |
|
void color_init_pair(short int x, short int y, short int z) |
|
| 200 |
|
{ |
|
| 201 |
|
if(terminalHasColors) { |
|
| 202 |
|
init_pair(x, y, z); |
|
| 203 |
|
} |
|
| 204 |
|
} |
|
| 205 |
|
|
|
| 206 |
|
void color_attr_on(int c) |
|
| 207 |
|
{ |
|
| 208 |
|
if(terminalHasColors) { |
|
| 209 |
|
attron(c); |
|
| 210 |
|
} |
|
| 211 |
|
} |
|
| 212 |
|
|
|
| 213 |
203 |
void print_selection_row(char *text, int y, int width, char *prefix) { |
void print_selection_row(char *text, int y, int width, char *prefix) { |
| 214 |
204 |
snprintf(screenLine, width, " %s", text); |
snprintf(screenLine, width, " %s", text); |
| 215 |
|
mvwprintw(stdscr, y, 0, screenLine); |
|
|
205 |
|
mvprintw(y, 0, screenLine); |
| 216 |
206 |
if(prefix!=NULL && strlen(prefix)>0) { |
if(prefix!=NULL && strlen(prefix)>0) { |
| 217 |
|
wattron(stdscr,A_BOLD); |
|
|
207 |
|
color_attr_on(A_BOLD); |
| 218 |
208 |
char *p; |
char *p; |
| 219 |
209 |
if(caseSensitive) { |
if(caseSensitive) { |
| 220 |
210 |
p=strstr(text, prefix); |
p=strstr(text, prefix); |
| 221 |
|
mvwprintw(stdscr, y, 1+(p-text), "%s", prefix); |
|
|
211 |
|
mvprintw(y, 1+(p-text), "%s", prefix); |
| 222 |
212 |
} else { |
} else { |
| 223 |
213 |
p=strcasestr(text, prefix); |
p=strcasestr(text, prefix); |
| 224 |
214 |
snprintf(screenLine, strlen(prefix)+1, "%s", p); |
snprintf(screenLine, strlen(prefix)+1, "%s", p); |
| 225 |
|
mvwprintw(stdscr, y, 1+(p-text), "%s", screenLine); |
|
|
215 |
|
mvprintw(y, 1+(p-text), "%s", screenLine); |
| 226 |
216 |
} |
} |
| 227 |
|
wattroff(stdscr,A_BOLD); |
|
|
217 |
|
color_attr_off(A_BOLD); |
| 228 |
218 |
} |
} |
| 229 |
219 |
|
|
| 230 |
220 |
} |
} |
| 231 |
221 |
|
|
| 232 |
222 |
void print_highlighted_selection_row(char *text, int y, int width) { |
void print_highlighted_selection_row(char *text, int y, int width) { |
| 233 |
|
wattron(stdscr, A_REVERSE); |
|
| 234 |
|
wattron(stdscr, A_BOLD); |
|
|
223 |
|
color_attr_on(A_REVERSE); |
|
224 |
|
color_attr_on(A_BOLD); |
| 235 |
225 |
snprintf(screenLine, getmaxx(stdscr), "%s%s", (terminalHasColors?" ":">"), text); |
snprintf(screenLine, getmaxx(stdscr), "%s%s", (terminalHasColors?" ":">"), text); |
| 236 |
226 |
mvprintw(y, 0, "%s", screenLine); |
mvprintw(y, 0, "%s", screenLine); |
| 237 |
|
wattroff(stdscr, A_BOLD); |
|
| 238 |
|
wattroff(stdscr, A_REVERSE); |
|
|
227 |
|
color_attr_off(A_BOLD); |
|
228 |
|
color_attr_off(A_REVERSE); |
| 239 |
229 |
} |
} |
| 240 |
230 |
|
|
| 241 |
231 |
char *print_selection(unsigned maxHistoryItems, char *prefix, HistoryItems *history) |
char *print_selection(unsigned maxHistoryItems, char *prefix, HistoryItems *history) |
| |
| ... |
... |
char *print_selection(unsigned maxHistoryItems, char *prefix, HistoryItems *hist |
| 252 |
242 |
int y=Y_OFFSET_ITEMS; |
int y=Y_OFFSET_ITEMS; |
| 253 |
243 |
|
|
| 254 |
244 |
move(Y_OFFSET_ITEMS, 0); |
move(Y_OFFSET_ITEMS, 0); |
| 255 |
|
wclrtobot(stdscr); |
|
|
245 |
|
clrtobot(); |
| 256 |
246 |
|
|
| 257 |
247 |
for (i = 0; i<height; ++i) { |
for (i = 0; i<height; ++i) { |
| 258 |
248 |
if(i<selectionSize) { |
if(i<selectionSize) { |
| 259 |
249 |
print_selection_row(selection[i], y++, width, prefix); |
print_selection_row(selection[i], y++, width, prefix); |
| 260 |
250 |
} else { |
} else { |
| 261 |
|
mvwprintw(stdscr, y++, 0, " "); |
|
|
251 |
|
mvprintw(y++, 0, " "); |
| 262 |
252 |
} |
} |
| 263 |
253 |
} |
} |
| 264 |
254 |
refresh(); |
refresh(); |
| |
| ... |
... |
void color_start() |
| 291 |
281 |
} |
} |
| 292 |
282 |
} |
} |
| 293 |
283 |
|
|
| 294 |
|
void color_attr_off(int c) |
|
| 295 |
|
{ |
|
| 296 |
|
if(terminalHasColors) { |
|
| 297 |
|
attroff(c); |
|
| 298 |
|
} |
|
| 299 |
|
} |
|
| 300 |
|
|
|
| 301 |
284 |
void selection_remove(char *cmd, HistoryItems *history) |
void selection_remove(char *cmd, HistoryItems *history) |
| 302 |
285 |
{ |
{ |
| 303 |
286 |
if(history->count) { |
if(history->count) { |
| |
| ... |
... |
char *selection_loop(HistoryItems *history) |
| 413 |
396 |
if(strlen(prefix)>0) { |
if(strlen(prefix)>0) { |
| 414 |
397 |
prefix[strlen(prefix)-1]=0; |
prefix[strlen(prefix)-1]=0; |
| 415 |
398 |
x--; |
x--; |
| 416 |
|
wattron(stdscr,A_BOLD); |
|
|
399 |
|
color_attr_on(A_BOLD); |
| 417 |
400 |
mvprintw(y, basex, "%s", prefix); |
mvprintw(y, basex, "%s", prefix); |
| 418 |
|
wattroff(stdscr,A_BOLD); |
|
|
401 |
|
color_attr_off(A_BOLD); |
| 419 |
402 |
clrtoeol(); |
clrtoeol(); |
| 420 |
403 |
} |
} |
| 421 |
404 |
|
|
| |
| ... |
... |
char *selection_loop(HistoryItems *history) |
| 478 |
461 |
|
|
| 479 |
462 |
if(strlen(prefix)<(width-basex-1)) { |
if(strlen(prefix)<(width-basex-1)) { |
| 480 |
463 |
strcat(prefix, (char*)(&c)); |
strcat(prefix, (char*)(&c)); |
| 481 |
|
wattron(stdscr,A_BOLD); |
|
|
464 |
|
color_attr_on(A_BOLD); |
| 482 |
465 |
mvprintw(y, basex, "%s", prefix); |
mvprintw(y, basex, "%s", prefix); |
| 483 |
466 |
cursorX=getcurx(stdscr); |
cursorX=getcurx(stdscr); |
| 484 |
467 |
cursorY=getcury(stdscr); |
cursorY=getcury(stdscr); |
| 485 |
|
wattroff(stdscr,A_BOLD); |
|
|
468 |
|
color_attr_off(A_BOLD); |
| 486 |
469 |
clrtoeol(); |
clrtoeol(); |
| 487 |
470 |
} |
} |
| 488 |
471 |
|
|