about summary refs log tree commit diff stats
path: root/main.c
Commit message (Expand)AuthorAgeFilesLines
* applied Gottox patchesarg@mig292006-11-211-2/+3
* applied Gottox' windowarea patcharg@mig292006-11-161-1/+6
* code polishing, removed unnecessary newlinesAnselm R. Garbe2006-10-061-21/+9
* removed the stack position stuffAnselm R. Garbe2006-10-051-4/+1
* keep master ratio on resizecol -> arrangeAnselm R. Garbe2006-10-051-3/+3
* added symbols for different modesAnselm R. Garbe2006-09-291-2/+5
* removed useless updatemasterAnselm R. Garbe2006-09-291-1/+1
* added the new dotile as described on mlAnselm R. Garbe2006-09-291-1/+1
* first step to a more flexible dotile() algorithmAnselm R. Garbe2006-09-291-2/+2
* applied Jukkas patcharg@mmvi2006-09-251-3/+3
* implemented the maximization as I described on the mailinglist, this feels be...arg@mmvi2006-09-221-1/+0
* removed a bunch of lines through making function signatures more consistent w...Anselm R. Garbe2006-09-121-19/+11
* applied Christof Musik's multihead patch for a pathologic cornercaseAnselm R. Garbe2006-09-121-1/+2
* fixed some other comments, now also the code side seems to be at a level to b...Anselm R. Garbe2006-09-111-2/+2
* using a global stack for focus recovery on arrange() - seems to work greatAnselm R. Garbe2006-09-071-0/+1
* small fixAnselm R. Garbe2006-09-061-0/+1
* applied Sanders max_and_focus.patchAnselm R. Garbe2006-09-041-0/+1
* trying a different configurationAnselm R. Garbe2006-08-251-3/+3
* fixed typoAnselm R. Garbe2006-08-251-1/+1
* removed a bunch of lines, made mode symbols configurableAnselm R. Garbe2006-08-251-1/+1
* new color stuff/new rendering stuffAnselm R. Garbe2006-08-251-5/+9
* back to 3 colorsAnselm R. Garbe2006-08-251-4/+3
* 3->4 colorsAnselm R. Garbe2006-08-241-3/+4
* changing tag indicator through underlineAnselm R. Garbe2006-08-241-0/+1
* removed a blank lineAnselm R. Garbe2006-08-231-1/+0
* separated setup stuff into main.c:setup() - this makes main() more readableAnselm R. Garbe2006-08-231-86/+95
* rearranged getprotoAnselm R. Garbe2006-08-221-6/+5
* removed winprop (merged into getproto)Anselm R. Garbe2006-08-221-27/+7
* removed DEFTAGAnselm R. Garbe2006-08-221-1/+1
* small renamings of two static functionsAnselm R.Garbe2006-08-211-2/+2
* small changes to dwm.1, rearranged order within main event loopAnselm R.Garbe2006-08-211-4/+4
* corrected order of cleanup code Anselm R.Garbe2006-08-161-1/+1
* we close stdin as wellAnselm R.Garbe2006-08-161-3/+4
* extended cleanupAnselm R.Garbe2006-08-151-0/+7
* applied jk_to_tab patchAnselm R.Garbe2006-08-151-2/+1
* changed main event loopAnselm R.Garbe2006-08-151-10/+7
* removed NUMLOCKMASK, added dynamically calculated numlockmask insteadAnselm R.Garbe2006-08-141-7/+19
* changed order of selecting input at root windowAnselm R.Garbe2006-08-141-4/+4
* removed unneecessary crapAnselm R.Garbe2006-08-141-1/+0
* some other small fixesAnselm R.Garbe2006-08-141-8/+8
* removed ungrabkeys again (because of sander's mail)Anselm R.Garbe2006-08-141-1/+0
* implemented ungrabkeys() which is called in cleanup()Anselm R.Garbe2006-08-141-0/+1
* supplying NULL args in selectAnselm R.Garbe2006-08-141-1/+1
* reducing ConnectionNumber calls to a bare minimumAnselm R.Garbe2006-08-141-4/+5
* implemented viewextend and added M-S-C-n shortcuts for extending the current ...Anselm R.Garbe2006-08-111-3/+3
* implement multi-tag selection through button3 click on the specific tagAnselm R.Garbe2006-08-111-1/+3
* prepared 0.8 0.8Anselm R.Garbe2006-08-101-0/+1
* readded border color, this sucks leastAnselm R.Garbe2006-08-101-0/+1
* removed unnecessary border colorAnselm R.Garbe2006-08-101-1/+0
* removed NET_ACTIVE_WINDOW handlingAnselm R.Garbe2006-08-081-1/+0
ss="p">; gchar *search_str; }; static gchar * _search_from(Autocomplete ac, GSList *curr); Autocomplete autocomplete_new(void) { Autocomplete new = malloc(sizeof(struct autocomplete_t)); new->items = NULL; new->last_found = NULL; new->search_str = NULL; return new; } void autocomplete_clear(Autocomplete ac) { g_slist_free_full(ac->items, free); ac->items = NULL; autocomplete_reset(ac); } void autocomplete_reset(Autocomplete ac) { ac->last_found = NULL; if (ac->search_str != NULL) { free(ac->search_str); ac->search_str = NULL; } } void autocomplete_free(Autocomplete ac) { autocomplete_clear(ac); free(ac); } gint autocomplete_length(Autocomplete ac) { if (ac == NULL) { return 0; } else if (ac->items == NULL) { return 0; } else { return g_slist_length(ac->items); } } gboolean autocomplete_add(Autocomplete ac, void *item) { if (ac->items == NULL) { ac->items = g_slist_append(ac->items, item); return TRUE; } else { GSList *curr = ac->items; while(curr) { // insert if (g_strcmp0(curr->data, item) > 0) { ac->items = g_slist_insert_before(ac->items, curr, item); return TRUE; // update } else if (g_strcmp0(curr->data, item) == 0) { // only update if data different if (strcmp(curr->data, item) != 0) { free(curr->data); curr->data = item; return TRUE; } else { return FALSE; } } curr = g_slist_next(curr); } // hit end, append ac->items = g_slist_append(ac->items, item); return TRUE; } } gboolean autocomplete_remove(Autocomplete ac, const char * const item) { // reset last found if it points to the item to be removed if (ac->last_found != NULL) if (g_strcmp0(ac->last_found->data, item) == 0) ac->last_found = NULL; if (!ac->items) { return FALSE; } else { GSList *curr = ac->items; while(curr) { if (g_strcmp0(curr->data, item) == 0) { void *current_item = curr->data; ac->items = g_slist_remove(ac->items, curr->data); free(current_item); return TRUE; } curr = g_slist_next(curr); } return FALSE; } } GSList * autocomplete_get_list(Autocomplete ac) { GSList *copy = NULL; GSList *curr = ac->items; while(curr) { copy = g_slist_append(copy, strdup(curr->data)); curr = g_slist_next(curr); } return copy; } gchar * autocomplete_complete(Autocomplete ac, gchar *search_str) { gchar *found = NULL; // no items to search if (!ac->items) return NULL; // first search attempt if (ac->last_found == NULL) { ac->search_str = (gchar *) malloc((strlen(search_str) + 1) * sizeof(gchar)); strcpy(ac->search_str, search_str); found = _search_from(ac, ac->items); return found; // subsequent search attempt } else { // search from here+1 tp end found = _search_from(ac, g_slist_next(ac->last_found)); if (found != NULL) return found; // search from beginning found = _search_from(ac, ac->items); if (found != NULL) return found; // we found nothing, reset search autocomplete_reset(ac); return NULL; } } char * autocomplete_param_with_func(char *input, int *size, char *command, autocomplete_func func) { char *found = NULL; char *auto_msg = NULL; char inp_cpy[*size]; int i; char *command_cpy = malloc(strlen(command) + 2); sprintf(command_cpy, "%s ", command); int len = strlen(command_cpy); if ((strncmp(input, command_cpy, len) == 0) && (*size > len)) { for(i = len; i < *size; i++) { inp_cpy[i-len] = input[i]; } inp_cpy[(*size) - len] = '\0'; found = func(inp_cpy); if (found != NULL) { auto_msg = (char *) malloc((len + (strlen(found) + 1)) * sizeof(char)); strcpy(auto_msg, command_cpy); strcat(auto_msg, found); free(found); } } free(command_cpy); return auto_msg; } char * autocomplete_param_with_ac(char *input, int *size, char *command, Autocomplete ac) { char *found = NULL; char *auto_msg = NULL; char inp_cpy[*size]; int i; char *command_cpy = malloc(strlen(command) + 2); sprintf(command_cpy, "%s ", command); int len = strlen(command_cpy); if ((strncmp(input, command_cpy, len) == 0) && (*size > len)) { for(i = len; i < *size; i++) { inp_cpy[i-len] = input[i]; } inp_cpy[(*size) - len] = '\0'; found = autocomplete_complete(ac, inp_cpy); if (found != NULL) { auto_msg = (char *) malloc((len + (strlen(found) + 1)) * sizeof(char)); strcpy(auto_msg, command_cpy); strcat(auto_msg, found); free(found); } } free(command_cpy); return auto_msg; } char * autocomplete_param_no_with_func(char *input, int *size, char *command, int arg_number, autocomplete_func func) { char *result = NULL; if (strncmp(input, command, strlen(command)) == 0 && (*size > strlen(command))) { int i = 0; char *found = NULL; GString *result_str = NULL; // copy and null terminate input gchar inp_cpy[*size]; for (i = 0; i < *size; i++) { inp_cpy[i] = input[i]; } inp_cpy[i] = '\0'; g_strstrip(inp_cpy); // count tokens properly int num_tokens = count_tokens(inp_cpy); // if correct number of tokens, then candidate for autocompletion of last param if (num_tokens == arg_number) { gchar *start_str = get_start(inp_cpy, arg_number); gchar *comp_str = g_strdup(&inp_cpy[strlen(start_str)]); // autocomplete param if (comp_str != NULL) { found = func(comp_str); if (found != NULL) { result_str = g_string_new(""); g_string_append(result_str, start_str); g_string_append(result_str, found); result = result_str->str; g_string_free(result_str, FALSE); return result; } } } } return NULL; } static gchar * _search_from(Autocomplete ac, GSList *curr) { while(curr) { // match found if (strncmp(curr->data, ac->search_str, strlen(ac->search_str)) == 0) { // set pointer to last found ac->last_found = curr; // if contains space, quote before returning if (g_strrstr(curr->data, " ")) { GString *quoted = g_string_new("\""); g_string_append(quoted, curr->data); g_string_append(quoted, "\""); gchar *result = quoted->str; g_string_free(quoted, FALSE); return result; // otherwise just return the string } else { return strdup(curr->data); } } curr = g_slist_next(curr); } return NULL; }