commit 9ffce97a2ea6c4d04852820ea2eecd55be1bbf5f
parent e928a7598de0d9834c37d105d4072233d1f25c3d
Author: Kyle Milz <kmilz@ucalgary.ca>
Date: Sat, 13 Oct 2012 20:50:58 -0600
remove old key mapping functions
Diffstat:
2 files changed, 0 insertions(+), 298 deletions(-)
diff --git a/src/utilities.c b/src/utilities.c
@@ -204,296 +204,6 @@ process_line_arg(const Arg *arg, void *data) {
return process_line(arg->s, wd);
}
-#if 0
-Eina_Bool
-changemapping(Key *search_key, int maprecord, char *cmd) {
- KeyList *current, *newkey;
- Arg a = { .s = cmd };
-
- /* sanity check */
- if (maprecord < 0 && cmd == NULL) {
- /* possible states:
- * - maprecord >= 0 && cmd == NULL: mapping to internal symbol
- * - maprecord < 0 && cmd != NULL: mapping to command line
- * - maprecord >= 0 && cmd != NULL: cmd will be ignored, treated as mapping to internal symbol
- * - anything else (gets in here): an error, hence we return FALSE */
- return FALSE;
- }
-
- // current = keylistroot;
- current = NULL;
-
- if (current)
- while (current->next != NULL) {
- if (
- current->Element.mask == search_key->mask &&
- current->Element.modkey == search_key->modkey &&
- current->Element.key == search_key->key
- ) {
- if (maprecord >= 0) {
- /* mapping to an internal signal */
- current->Element.func = commands[maprecord].func;
- current->Element.arg = commands[maprecord].arg;
- } else {
- /* mapping to a command line */
- current->Element.func = process_line_arg;
- current->Element.arg = a;
- }
- return TRUE;
- }
- current = current->next;
- }
- newkey = malloc(sizeof(KeyList));
- if (newkey == NULL) {
- printf("Not enough memory\n");
- exit (-1);
- }
- newkey->Element.mask = search_key->mask;
- newkey->Element.modkey = search_key->modkey;
- newkey->Element.key = search_key->key;
- if (maprecord >= 0) {
- /* mapping to an internal signal */
- newkey->Element.func = commands[maprecord].func;
- newkey->Element.arg = commands[maprecord].arg;
- } else {
- /* mapping to a command line */
- newkey->Element.func = process_line_arg;
- newkey->Element.arg = a;
- }
- add_modkeys(newkey->Element.modkey);
-
- newkey->next = NULL;
-
- // if (keylistroot == NULL) keylistroot = newkey;
-
- if (current != NULL) current->next = newkey;
-
- return TRUE;
-}
-
-void add_modkeys(char key)
-{
- unsigned int k, len;
- extern char *modkeys;
- len = strlen( modkeys );
- while (k < len )
- {
- if ( modkeys[k] == key ) return;
- k++;
- }
- modkeys = realloc(modkeys, len + 1);
- modkeys[len++] = key;
- modkeys[len] = '\0';
-}
-#endif
-
-Eina_Bool
-mappings(const Arg *arg, void *data) {
- char line[255];
-
- if (!arg->s) {
- set_error("Missing argument.", data);
- return FALSE;
- }
- strncpy(line, arg->s, 254);
- if (process_map_line(line))
- return TRUE;
- else {
- set_error("Invalid mapping.", data);
- return FALSE;
- }
-}
-
-int
-get_modkey(char key) {
- /*
- switch (key) {
- case '1':
- return GDK_MOD1_MASK;
- case '2':
- return GDK_MOD2_MASK;
- case '3':
- return GDK_MOD3_MASK;
- case '4':
- return GDK_MOD4_MASK;
- case '5':
- return GDK_MOD5_MASK;
- default:
- return FALSE;
- }
- */
- return 0;
-}
-
-Eina_Bool
-process_mapping(char *keystring, int maprecord, char *cmd) {
-#if 0
- Key search_key;
-
- search_key.mask = 0;
- search_key.modkey = 0;
- search_key.key = 0;
-
- if (strlen(keystring) == 1) {
- search_key.key = keystring[0];
- }
-
- if (strlen(keystring) == 2) {
- search_key.modkey= keystring[0];
- search_key.key = keystring[1];
- }
-
- /* process stuff like <S-v> for Shift-v or <C-v> for Ctrl-v (strlen == 5),
- stuff like <S-v>a for Shift-v,a or <C-v>a for Ctrl-v,a (strlen == 6 && keystring[4] == '>')
- stuff like <M1-v> for Mod1-v (strlen == 6 && keystring[5] == '>')
- or stuff like <M1-v>a for Mod1-v,a (strlen = 7)
- */
- if (
- ((strlen(keystring) == 5 || strlen(keystring) == 6) && keystring[0] == '<' && keystring[4] == '>') ||
- ((strlen(keystring) == 6 || strlen(keystring) == 7) && keystring[0] == '<' && keystring[5] == '>')
- ) {
- switch (toupper(keystring[1])) {
- case 'S':
- search_key.mask = "Shift";
- if (strlen(keystring) == 5) {
- keystring[3] = toupper(keystring[3]);
- } else {
- keystring[3] = tolower(keystring[3]);
- keystring[5] = toupper(keystring[5]);
- }
- break;
- case 'C':
- search_key.mask = "Control";
- break;
- case 'M':
- // search_key.mask = get_modkey(keystring[2]);
- break;
- }
- if (!search_key.mask)
- return FALSE;
- if (strlen(keystring) == 5) {
- search_key.key = keystring[3];
- } else if (strlen(keystring) == 7) {
- search_key.modkey = keystring[4];
- search_key.key = keystring[6];
- } else {
- if (!strcmp(search_key.mask, "Shift") || !strcmp(search_key.mask, "Control")) {
- search_key.modkey = keystring[3];
- search_key.key = keystring[5];
- } else {
- search_key.key = keystring[4];
- }
- }
- }
-
- /* process stuff like a<S-v> for a,Shift-v or a<C-v> for a,Ctrl-v (strlen == 6)
- or stuff like a<M1-v> for a,Mod1-v (strlen == 7)
- */
- if (
- (strlen(keystring) == 6 && keystring[1] == '<' && keystring[5] == '>') ||
- (strlen(keystring) == 7 && keystring[1] == '<' && keystring[6] == '>')
- ) {
- switch (toupper(keystring[2])) {
- case 'S':
- search_key.mask = "Shift";
- keystring[4] = toupper(keystring[4]);
- break;
- case 'C':
- search_key.mask = "Control";
- break;
- case 'M':
- // search_key.mask = get_modkey(keystring[3]);
- break;
- }
- if (!search_key.mask)
- return FALSE;
- search_key.modkey= keystring[0];
- if (strlen(keystring) == 6) {
- search_key.key = keystring[4];
- } else {
- search_key.key = keystring[5];
- }
- }
- // return (changemapping(&search_key, maprecord, cmd));
-#endif
- return EINA_TRUE;
-}
-
-Eina_Bool
-process_map_line(char *line) {
- int listlen, i;
- char *c, *cmd;
- my_pair.line = line;
- c = search_word(0);
-
- if (!strlen(my_pair.what))
- return FALSE;
- while (isspace(*c) && *c)
- c++;
-
- if (*c == ':' || *c == '=')
- c++;
- my_pair.line = c;
- c = search_word(1);
- if (!strlen(my_pair.value))
- return FALSE;
- listlen = LENGTH(commands);
- for (i = 0; i < listlen; i++) {
- /* commands is fixed size */
- if (commands[i].cmd == NULL)
- break;
- if (strlen(commands[i].cmd) == strlen(my_pair.value) && strncmp(commands[i].cmd, my_pair.value, strlen(my_pair.value)) == 0) {
- /* map to an internal symbol */
- return process_mapping(my_pair.what, i, NULL);
- }
- }
- /* if this is reached, the mapping is not for one of the internal symbol - test for command line structure */
- if (strlen(my_pair.value) > 1 && strncmp(my_pair.value, ":", 1) == 0) {
- /* The string begins with a colon, like a command line, but it's not _just_ a colon,
- * i.e. increasing the pointer by one will not go 'out of bounds'.
- * We don't actually check that the command line after the = is valid.
- * This is user responsibility, the worst case is the new mapping simply doing nothing.
- * Since we will pass the command to the same function which also handles the config file lines,
- * we have to strip the colon itself (a colon counts as a commented line there - like in vim).
- * Last, but not least, the second argument being < 0 signifies to the function that this is a
- * command line mapping, not a mapping to an existing internal symbol. */
- cmd = (char *)malloc(sizeof(char) * strlen(my_pair.value));
- memset(cmd, 0, strlen(my_pair.value));
- strncpy(cmd, (my_pair.value + 1), strlen(my_pair.value) - 1);
- return process_mapping(my_pair.what, -1, cmd);
- }
- return FALSE;
-}
-
-Eina_Bool
-build_taglist(const Arg *arg, FILE *f) {
- int k = 0, in_tag = 0;
- int t = 0, marker = 0;
- char foundtab[MAXTAGSIZE+1];
- while (arg->s[k]) {
- if (!isspace(arg->s[k]) && !in_tag) {
- in_tag = 1;
- marker = k;
- }
- if (isspace(arg->s[k]) && in_tag) {
- /* found a tag */
- t = 0;
- while (marker < k && t < MAXTAGSIZE) foundtab[t++] = arg->s[marker++];
- foundtab[t] = '\0';
- fprintf(f, " [%s]", foundtab);
- in_tag = 0;
- }
- k++;
- }
- if (in_tag) {
- t = 0;
- while (marker < strlen(arg->s) && t < MAXTAGSIZE) foundtab[t++] = arg->s[marker++];
- foundtab[t] = '\0';
- fprintf(f, " [%s]", foundtab );
- }
- return TRUE;
-}
-
void
set_error(const char *error, void *data)
{
diff --git a/src/utilities.h b/src/utilities.h
@@ -11,18 +11,12 @@
#define COMMANDHISTSIZE 50
char *strdup_printf(const char *, ...);
-enum ConfigFileError read_rcfile(const char *config, void *);
void save_command_history(const char*, Window_Data*);
// Eina_Bool process_save_qmark(const char *bm, WebKitWebView *webview);
KeyList *make_keyslist(void);
Eina_Bool parse_colour(char *color);
-Eina_Bool mappings(const Arg *, void *);
-Eina_Bool process_mapping(char *keystring, int maprecord, char *cmd);
-Eina_Bool process_map_line(char *line);
-Eina_Bool changemapping(Key *search_key, int maprecord, char *cmd);
Eina_Bool process_line(const char *line, Window_Data*);
Eina_Bool process_line_arg(const Arg *, void *);
-Eina_Bool build_taglist(const Arg *arg, FILE *f);
void set_error(const char *error, void *);
void give_feedback(const char *feedback, void *);
Listelement * complete_list(const char *, const int, Listelement *, void *);
@@ -42,10 +36,8 @@ void buffer_current_set(Buffer_Data *td);
char* status_flags(void *data);
Eina_Bool enable_proxy(Buffer_Data *bd);
-
char *find_uri_for_searchengine(const char *handle);
void make_searchengines_list(Searchengine *searchengines, int length);
void make_uri_handlers_list(URIHandler *uri_handlers, int length);
Eina_Bool open_handler(char *uri);
-