merge in Damien Leones stuff
authorDieter Plaetinck <dieter@plaetinck.be>
Sat, 16 May 2009 14:40:33 +0000 (16:40 +0200)
committerDieter Plaetinck <dieter@plaetinck.be>
Sat, 16 May 2009 14:40:33 +0000 (16:40 +0200)
1  2 
uzbl.c
uzbl.h

diff --cc uzbl.c
--- 1/uzbl.c
--- 2/uzbl.c
+++ b/uzbl.c
@@@ -715,17 -710,31 +710,17 @@@ run_command (const char *command, cons
     //command <uzbl conf> <uzbl pid> <uzbl win id> <uzbl fifo file> <uzbl socket file> [args]
      GString* to_execute = g_string_new ("");
      gboolean result;
-     g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s' '%s'", 
+     g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s' '%s'",
 -                    command, uzbl.state.config_file, (int) getpid() ,
 -                    (int) uzbl.xwin, uzbl.comm.fifo_path, uzbl.comm.socket_path);
 +                     command, (uzbl.state.config_file ? uzbl.state.config_file : "(null)"),
 +                     (int) getpid(), (int) uzbl.xwin, uzbl.comm.fifo_path,
 +                     uzbl.comm.socket_path);
-     g_string_append_printf (to_execute, " '%s' '%s'", 
+     g_string_append_printf (to_execute, " '%s' '%s'",
                      uzbl.state.uri, uzbl.gui.main_title);
 -    if(args) {
 -        g_string_append_printf (to_execute, " %s", args);
 -    }
 -    result = g_spawn_command_line_async (to_execute->str, NULL);
 -    printf("Called %s.  Result: %s\n", to_execute->str, (result ? "TRUE" : "FALSE" ));
 -    g_string_free (to_execute, TRUE);
 -    return result;
 -}
 +    if(args) g_string_append_printf (to_execute, " %s", args);
  
 -static gboolean
 -run_command_sync(const char *command, const char *args, char **stdout) {
 -      //command <uzbl conf> <uzbl pid> <uzbl win id> <uzbl fifo file> <uzbl socket file> [args]
 -    GString* to_execute = g_string_new ("");
 -    gboolean result;
 -    g_string_printf (to_execute, "%s '%s' '%i' '%i' '%s' '%s'", command, uzbl.state.config_file, (int) getpid() , (int) uzbl.xwin, uzbl.comm.fifo_path, uzbl.comm.socket_path);
 -    g_string_append_printf (to_execute, " '%s' '%s'", uzbl.state.uri, uzbl.gui.main_title);
 -    if(args) {
 -        g_string_append_printf (to_execute, " %s", args);
 -    }
 -    result = g_spawn_command_line_sync (to_execute->str, stdout, NULL, NULL, NULL);
 +    if (sync) {
 +        result = g_spawn_command_line_sync (to_execute->str, stdout, NULL, NULL, NULL);
 +    } else result = g_spawn_command_line_async (to_execute->str, NULL);
      printf("Called %s.  Result: %s\n", to_execute->str, (result ? "TRUE" : "FALSE" ));
      g_string_free (to_execute, TRUE);
      return result;
@@@ -756,11 -765,9 +751,11 @@@ setup_regex() 
              G_REGEX_OPTIMIZE, 0, &err);
      uzbl.comm.set_regex  = g_regex_new("^[Ss][a-zA-Z]*\\s+([^ ]+)\\s*=\\s*([^\\n].*)$",
              G_REGEX_OPTIMIZE, 0, &err);
-     uzbl.comm.bind_regex = g_regex_new("^[Bb][a-zA-Z]*\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$", 
+     uzbl.comm.bind_regex = g_regex_new("^[Bb][a-zA-Z]*\\s+?(.*[^ ])\\s*?=\\s*([a-z][^\\n].+)$",
              G_REGEX_UNGREEDY|G_REGEX_OPTIMIZE, 0, &err);
 -    uzbl.comm.cmd_regex = g_regex_new("^[Cc][a-zA-Z]*\\s+([^ \\n]+)\\s*([^\\n]*)?$",
 +    uzbl.comm.act_regex = g_regex_new("^[Aa][a-zA-Z]*\\s+([^ \\n]+)\\s*([^\\n]*)?$",
 +            G_REGEX_OPTIMIZE, 0, &err);
 +    uzbl.comm.keycmd_regex = g_regex_new("^[Kk][a-zA-Z]*\\s+([^\\n]+)$",
              G_REGEX_OPTIMIZE, 0, &err);
  }
  
@@@ -950,12 -957,12 +945,12 @@@ parse_cmd_line(const char *ctl_line) 
              add_binding(tokens[1], tokens[2]);
              g_strfreev(tokens);
          }
-         else 
+         else
              printf("Error in command: %s\n", tokens[0]);
      }
 -    /* CMD command */
 -    else if(ctl_line[0] == 'C' || ctl_line[0] == 'c') {
 -        tokens = g_regex_split(uzbl.comm.cmd_regex, ctl_line, 0);
 +    /* ACT command */
 +    else if(ctl_line[0] == 'A' || ctl_line[0] == 'a') {
 +        tokens = g_regex_split(uzbl.comm.act_regex, ctl_line, 0);
          if(tokens[0][0] == 0) {
              parse_command(tokens[1], tokens[2]);
              g_strfreev(tokens);
@@@ -1292,10 -1288,10 +1287,10 @@@ key_press_cb (WebKitWebView* page, GdkE
          if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) {
              str = gtk_clipboard_wait_for_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY));
          } else {
-             str = gtk_clipboard_wait_for_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD)); 
+             str = gtk_clipboard_wait_for_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD));
          }
          if (str) {
 -            g_string_append_printf (uzbl.state.keycmd, "%s",  str);
 +            g_string_append (uzbl.state.keycmd, str);
              update_title ();
              free (str);
          }
@@@ -1337,15 -1321,15 +1332,15 @@@ run_keycmd(const gboolean key_ret) 
          g_string_assign(short_keys_inc, short_keys->str);
          g_string_append_c(short_keys, '_');
          g_string_append_c(short_keys_inc, '*');
-             
          gboolean exec_now = FALSE;
          if ((action = g_hash_table_lookup(uzbl.bindings, short_keys->str))) {
 -            if (key_ret) exec_now = TRUE; // run normal cmds only if return was pressed
 +            if (key_ret) exec_now = TRUE; /* run normal cmds only if return was pressed */
          } else if ((action = g_hash_table_lookup(uzbl.bindings, short_keys_inc->str))) {
 -            if (key_ret) { // just quit the incremental command on return
 +            if (key_ret) { /* just quit the incremental command on return */
                  g_string_truncate(uzbl.state.keycmd, 0);
                  break;
 -            } else exec_now = TRUE; // always exec inc. commands on keys other than return
 +            } else exec_now = TRUE; /* always exec incr. commands on keys other than return */
          }
  
          if (exec_now) {
diff --cc uzbl.h
--- 1/uzbl.h
--- 2/uzbl.h
+++ b/uzbl.h
@@@ -86,10 -86,9 +86,10 @@@ typedef struct 
      GHashTable     *proto_var;
      /* command parsing regexes */
      GRegex         *set_regex;
 -    GRegex         *cmd_regex;
 +    GRegex         *act_regex;
 +    GRegex         *keycmd_regex;
-     GRegex         *get_regex; 
-     GRegex         *bind_regex; 
+     GRegex         *get_regex;
+     GRegex         *bind_regex;
  } Communication;