File src/hstr.c changed (mode: 100644) (index 0588c24..fc115af) |
... |
... |
int print_prompt() |
137 |
137 |
color_attr_on(COLOR_PAIR(HH_COLOR_PROMPT)); |
color_attr_on(COLOR_PAIR(HH_COLOR_PROMPT)); |
138 |
138 |
color_attr_on(A_BOLD); |
color_attr_on(A_BOLD); |
139 |
139 |
} |
} |
140 |
|
mvprintw(Y_OFFSET_PROMPT, xoffset, "%s@%s$ ", user, hostname); |
|
|
140 |
|
mvprintw(Y_OFFSET_PROMPT, xoffset, "%s@%s$ ", (user?user:"me"), (hostname?hostname:"localhost")); |
141 |
141 |
if(hicolor) { |
if(hicolor) { |
142 |
142 |
color_attr_off(A_BOLD); |
color_attr_off(A_BOLD); |
143 |
143 |
color_attr_off(COLOR_PAIR(HH_COLOR_PROMPT)); |
color_attr_off(COLOR_PAIR(HH_COLOR_PROMPT)); |
|
... |
... |
void print_history_label(HistoryItems *history) |
195 |
195 |
refresh(); |
refresh(); |
196 |
196 |
} |
} |
197 |
197 |
|
|
198 |
|
void print_pattern(char *pattern, int y, int x) |
|
|
198 |
|
void print_prefix(char *pattern, int y, int x) |
199 |
199 |
{ |
{ |
200 |
200 |
color_attr_on(A_BOLD); |
color_attr_on(A_BOLD); |
201 |
201 |
mvprintw(y, x, "%s", pattern); |
mvprintw(y, x, "%s", pattern); |
|
... |
... |
unsigned make_selection(char *prefix, HistoryItems *history, int maxSelectionCou |
233 |
233 |
char **source=(defaultOrder?history->raw:history->items); |
char **source=(defaultOrder?history->raw:history->items); |
234 |
234 |
unsigned count=(defaultOrder?history->rawCount:history->count); |
unsigned count=(defaultOrder?history->rawCount:history->count); |
235 |
235 |
|
|
236 |
|
if(prefix && !strlen(prefix)) { |
|
237 |
|
prefix=NULL; |
|
238 |
|
} |
|
239 |
|
|
|
240 |
236 |
for(i=0; i<count && selectionCount<maxSelectionCount; i++) { |
for(i=0; i<count && selectionCount<maxSelectionCount; i++) { |
241 |
237 |
if(source[i]) { |
if(source[i]) { |
242 |
|
if(!prefix) { |
|
|
238 |
|
if(!prefix || !strlen(prefix)) { |
243 |
239 |
selection[selectionCount++]=source[i]; |
selection[selectionCount++]=source[i]; |
244 |
240 |
} else { |
} else { |
245 |
241 |
if(caseSensitive) { |
if(caseSensitive) { |
|
... |
... |
void loop_to_select(HistoryItems *history) |
428 |
424 |
if(!skip) { |
if(!skip) { |
429 |
425 |
c = wgetch(stdscr); |
c = wgetch(stdscr); |
430 |
426 |
} else { |
} else { |
431 |
|
if(strlen(pattern)>0) { |
|
|
427 |
|
if(strlen(pattern)) { |
432 |
428 |
color_attr_on(A_BOLD); |
color_attr_on(A_BOLD); |
433 |
429 |
mvprintw(y, basex, "%s", pattern); |
mvprintw(y, basex, "%s", pattern); |
434 |
430 |
color_attr_off(A_BOLD); |
color_attr_off(A_BOLD); |
|
... |
... |
void loop_to_select(HistoryItems *history) |
475 |
471 |
break; |
break; |
476 |
472 |
case KEY_RESIZE: |
case KEY_RESIZE: |
477 |
473 |
print_history_label(history); |
print_history_label(history); |
|
474 |
|
result=print_selection(maxHistoryItems, pattern, history); |
|
475 |
|
print_history_label(history); |
|
476 |
|
selectionCursorPosition=0; |
478 |
477 |
move(y, basex+strlen(pattern)); |
move(y, basex+strlen(pattern)); |
479 |
478 |
break; |
break; |
480 |
479 |
case K_CTRL_U: |
case K_CTRL_U: |
481 |
480 |
case K_CTRL_W: // TODO supposed to delete just one word backward |
case K_CTRL_W: // TODO supposed to delete just one word backward |
482 |
481 |
pattern[0]=0; |
pattern[0]=0; |
483 |
|
print_pattern(pattern, y, basex); |
|
|
482 |
|
print_prefix(pattern, y, basex); |
484 |
483 |
break; |
break; |
485 |
484 |
case K_CTRL_L: |
case K_CTRL_L: |
486 |
485 |
toggle_case(pattern, lowercase); |
toggle_case(pattern, lowercase); |
487 |
486 |
lowercase=!lowercase; |
lowercase=!lowercase; |
488 |
|
print_pattern(pattern, y, basex); |
|
|
487 |
|
print_prefix(pattern, y, basex); |
489 |
488 |
selectionCursorPosition=0; |
selectionCursorPosition=0; |
490 |
489 |
break; |
break; |
491 |
490 |
case K_CTRL_H: |
case K_CTRL_H: |
|
... |
... |
void loop_to_select(HistoryItems *history) |
494 |
493 |
if(strlen(pattern)>0) { |
if(strlen(pattern)>0) { |
495 |
494 |
pattern[strlen(pattern)-1]=0; |
pattern[strlen(pattern)-1]=0; |
496 |
495 |
x--; |
x--; |
497 |
|
print_pattern(pattern, y, basex); |
|
|
496 |
|
print_prefix(pattern, y, basex); |
498 |
497 |
} |
} |
499 |
498 |
|
|
500 |
499 |
if(strlen(pattern)>0) { |
if(strlen(pattern)>0) { |
|
... |
... |
void loop_to_select(HistoryItems *history) |
563 |
562 |
|
|
564 |
563 |
if(strlen(pattern)<(width-basex-1)) { |
if(strlen(pattern)<(width-basex-1)) { |
565 |
564 |
strcat(pattern, (char*)(&c)); |
strcat(pattern, (char*)(&c)); |
566 |
|
print_pattern(pattern, y, basex); |
|
|
565 |
|
print_prefix(pattern, y, basex); |
567 |
566 |
cursorX=getcurx(stdscr); |
cursorX=getcurx(stdscr); |
568 |
567 |
cursorY=getcury(stdscr); |
cursorY=getcury(stdscr); |
569 |
568 |
} |
} |