xaizek / hstr (License: Apachev2) (since 2018-12-07)
Bash and Zsh shell history suggest box - easily view, navigate, search and manage your command history.
Commit aae195b845bc6ce4bb44fdada68524cb80b11685

added suport for further special keys
* pageUp and pageDown will now jump 10 entries up/down
* added case for home and end keys to avoid printing of wild chars in search prompt
Author: Norman Köster
Author date (UTC): 2015-05-08 14:45
Committer name: Norman Köster
Committer date (UTC): 2015-05-08 14:45
Parent(s): e3938d53c79d25886bb2718a5206e85accb42d13
Signing key:
Tree: 56434b384a72a80f25b3c457104a5e9d15cd09be
File Lines added Lines deleted
src/hstr.c 34 0
File src/hstr.c changed (mode: 100644) (index 6f1e864..9c19d24)
49 49 #define Y_OFFSET_HISTORY 2 #define Y_OFFSET_HISTORY 2
50 50 #define Y_OFFSET_ITEMS 3 #define Y_OFFSET_ITEMS 3
51 51
52 #define PG_JUMP_SIZE 10
53
52 54 #define K_CTRL_A 1 #define K_CTRL_A 1
53 55 #define K_CTRL_E 5 #define K_CTRL_E 5
54 56 #define K_CTRL_F 6 #define K_CTRL_F 6
 
... ... void loop_to_select(Hstr *hstr)
861 863 } }
862 864
863 865 switch (c) { switch (c) {
866 case KEY_HOME:
867 // TODO implement in pattern cursor jump to beginning
868 break;
869 case KEY_END:
870 // TODO implement in pattern cursor jump to end
871 break;
864 872 case KEY_DC: // DEL case KEY_DC: // DEL
865 873 if(selectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) { if(selectionCursorPosition!=SELECTION_CURSOR_IN_PROMPT) {
866 874 delete=hstr->selection[selectionCursorPosition]; delete=hstr->selection[selectionCursorPosition];
 
... ... void loop_to_select(Hstr *hstr)
988 996 highlight_selection(selectionCursorPosition, previousSelectionCursorPosition, pattern, hstr); highlight_selection(selectionCursorPosition, previousSelectionCursorPosition, pattern, hstr);
989 997 move(y, basex+strlen(pattern)); move(y, basex+strlen(pattern));
990 998 break; break;
999 case KEY_PPAGE:
1000 previousSelectionCursorPosition=selectionCursorPosition;
1001 if(selectionCursorPosition>=PG_JUMP_SIZE) {
1002 selectionCursorPosition=selectionCursorPosition-PG_JUMP_SIZE;
1003 } else {
1004 selectionCursorPosition=0;
1005 }
1006 highlight_selection(selectionCursorPosition, previousSelectionCursorPosition, pattern, hstr);
1007 move(y, basex+strlen(pattern));
1008 break;
991 1009 case K_CTRL_R: case K_CTRL_R:
992 1010 case KEY_DOWN: case KEY_DOWN:
993 1011 case K_CTRL_N: case K_CTRL_N:
 
... ... void loop_to_select(Hstr *hstr)
1006 1024 } }
1007 1025 move(y, basex+strlen(pattern)); move(y, basex+strlen(pattern));
1008 1026 break; break;
1027 case KEY_NPAGE:
1028 if(selectionCursorPosition==SELECTION_CURSOR_IN_PROMPT) {
1029 selectionCursorPosition=previousSelectionCursorPosition=0;
1030 } else {
1031 previousSelectionCursorPosition=selectionCursorPosition;
1032 if((selectionCursorPosition+PG_JUMP_SIZE)<hstr->selectionSize) {
1033 selectionCursorPosition = selectionCursorPosition+PG_JUMP_SIZE;
1034 } else {
1035 selectionCursorPosition=hstr->selectionSize-1;
1036 }
1037 }
1038 if(hstr->selectionSize) {
1039 highlight_selection(selectionCursorPosition, previousSelectionCursorPosition, pattern, hstr);
1040 }
1041 move(y, basex+strlen(pattern));
1042 break;
1009 1043 case K_ENTER: case K_ENTER:
1010 1044 case KEY_ENTER: case KEY_ENTER:
1011 1045 executeResult=TRUE; executeResult=TRUE;
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/hstr

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/hstr

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master