//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;
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);
}
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);
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);
}
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) {