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 3458c9ea9d70a3ad10da4353032182e3613ccfd7

Source code polishing.
Author: Martin Dvorak
Author date (UTC): 2014-05-18 03:32
Committer name: Martin Dvorak
Committer date (UTC): 2014-05-18 03:32
Parent(s): f530fe0dba2703936760015cf429f9ea8b2d3591
Signing key:
Tree: d4b5641ee52564dd1f8cc4c946169ae4c14ff8cd
File Lines added Lines deleted
src/hashset.c 18 17
src/hstr.c 7 0
src/hstr_favorites.c 1 1
File src/hashset.c changed (mode: 100644) (index bf32eec..b73f8fd)
... ... void *hashset_get(const HashSet * hs, const char *key)
37 37 int listNum = hashmap_hash( key ); int listNum = hashmap_hash( key );
38 38 struct HashSetNode *ptr = hs->lists[ listNum ]; struct HashSetNode *ptr = hs->lists[ listNum ];
39 39
40 while( ptr != NULL && strcmp( ptr->key, key ) != 0 )
40 while(ptr != NULL && strcmp(ptr->key, key)!= 0) {
41 41 ptr = ptr->next; ptr = ptr->next;
42 }
42 43
43 return (ptr != NULL? ptr->value : NULL);
44 return (ptr!=NULL?ptr->value:NULL);
44 45 } }
45 46
46 47 int hashset_contains(const HashSet * hs, const char *key) int hashset_contains(const HashSet * hs, const char *key)
 
... ... int hashset_put(HashSet *hs, const char *key, void *value)
52 53 { {
53 54 if(hashset_get(hs, key)) { if(hashset_get(hs, key)) {
54 55 return 0; return 0;
55 }
56
57 int listNum = hashmap_hash( key );
58 struct HashSetNode *newNode=(struct HashSetNode *)malloc(sizeof(struct HashSetNode));
59 if(newNode == NULL) {
60 fprintf(stderr,"Unable to allocate hashset entry!");
61 return 0;
62 }
56 } else {
57 int listNum = hashmap_hash( key );
58 struct HashSetNode *newNode=(struct HashSetNode *)malloc(sizeof(struct HashSetNode));
59 if(newNode == NULL) {
60 fprintf(stderr,"Unable to allocate hashset entry!");
61 return 0;
62 }
63 63
64 newNode->key=malloc(strlen(key)+1);
65 strcpy(newNode->key, key);
66 newNode->value=value;
67 newNode->next=hs->lists[listNum];
68 hs->lists[listNum]=newNode;
69 hs->currentSize++;
64 newNode->key=malloc(strlen(key)+1);
65 strcpy(newNode->key, key);
66 newNode->value=value;
67 newNode->next=hs->lists[listNum];
68 hs->lists[listNum]=newNode;
69 hs->currentSize++;
70 70
71 return 1;
71 return 1;
72 }
72 73 } }
73 74
74 75 int hashset_add(HashSet * hs, const char *key) int hashset_add(HashSet * hs, const char *key)
File src/hstr.c changed (mode: 100644) (index 6e1a46d..e938e09)
... ... void loop_to_select(Hstr *hstr)
782 782 hstr_next_view(hstr); hstr_next_view(hstr);
783 783 result=hstr_print_selection(maxHistoryItems, pattern, hstr); result=hstr_print_selection(maxHistoryItems, pattern, hstr);
784 784 print_history_label(hstr); print_history_label(hstr);
785 // TODO function
785 786 selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT;
786 787 if(strlen(pattern)<(width-basex-1)) { if(strlen(pattern)<(width-basex-1)) {
787 788 print_prefix(pattern, y, basex); print_prefix(pattern, y, basex);
 
... ... void loop_to_select(Hstr *hstr)
802 803 } }
803 804 result=hstr_print_selection(maxHistoryItems, pattern, hstr); result=hstr_print_selection(maxHistoryItems, pattern, hstr);
804 805 selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT; selectionCursorPosition=SELECTION_CURSOR_IN_PROMPT;
806 // TODO code review
807 if(strlen(pattern)<(width-basex-1)) {
808 print_prefix(pattern, y, basex);
809 cursorX=getcurx(stdscr);
810 cursorY=getcury(stdscr);
811 }
805 812 } }
806 813 break; break;
807 814 case KEY_RESIZE: case KEY_RESIZE:
File src/hstr_favorites.c changed (mode: 100644) (index 0526ce6..77055c7)
... ... void favorites_destroy(FavoriteItems *favorites)
191 191 for(i=0; i<favorites->count; i++) { for(i=0; i<favorites->count; i++) {
192 192 free(favorites->items[i]); free(favorites->items[i]);
193 193 } }
194 hashset_destroy(&favorites->set, false);
194 hashset_destroy(favorites->set, false);
195 195 free(favorites); free(favorites);
196 196 } }
197 197 } }
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