aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robert Manea <gotmor@gmail.com>2009-09-14 10:55:47 +0200
committerGravatar Robert Manea <gotmor@gmail.com>2009-09-14 10:55:47 +0200
commit3af2a6d1f2eb011f75b3e146ad9d687f499ca9fc (patch)
tree17d31330a72176de5644ff6f5fda28e5fb0f5241
parentd0330cba2849f716be672da6183724786dfb3b9b (diff)
removed obsolete key binding code
-rw-r--r--uzbl-core.c161
-rw-r--r--uzbl-core.h25
2 files changed, 5 insertions, 181 deletions
diff --git a/uzbl-core.c b/uzbl-core.c
index 9a71c31..b7f3cca 100644
--- a/uzbl-core.c
+++ b/uzbl-core.c
@@ -117,7 +117,7 @@ const struct var_name_to_ptr_t {
{ "verbose", PTR_V_INT(uzbl.state.verbose, 1, NULL)},
{ "inject_html", PTR_V_STR(uzbl.behave.inject_html, 0, cmd_inject_html)},
{ "geometry", PTR_V_STR(uzbl.gui.geometry, 1, cmd_set_geometry)},
- { "keycmd", PTR_V_STR(uzbl.state.keycmd, 1, set_keycmd)},
+ { "keycmd", PTR_V_STR(uzbl.state.keycmd, 1, update_title)},
{ "status_message", PTR_V_STR(uzbl.gui.sbar.msg, 1, update_title)},
{ "show_status", PTR_V_INT(uzbl.behave.show_status, 1, cmd_set_status)},
{ "status_top", PTR_V_INT(uzbl.behave.status_top, 1, move_statusbar)},
@@ -584,17 +584,15 @@ setup_signal(int signr, sigfunc *shandler) {
void
clean_up(void) {
+ send_event(INSTANCE_EXIT, uzbl.info.pid_str, NULL);
+
if (uzbl.behave.fifo_dir)
unlink (uzbl.comm.fifo_path);
if (uzbl.behave.socket_dir)
unlink (uzbl.comm.socket_path);
g_free(uzbl.state.executable_path);
- g_free(uzbl.state.keycmd);
- g_hash_table_destroy(uzbl.bindings);
g_hash_table_destroy(uzbl.behave.commands);
-
- send_event(INSTANCE_EXIT, uzbl.info.pid_str, NULL);
}
/* --- SIGNAL HANDLER --- */
@@ -889,11 +887,6 @@ load_finish_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
send_event(LOAD_FINISH, webkit_web_frame_get_uri(frame), NULL);
}
-void clear_keycmd() {
- g_free(uzbl.state.keycmd);
- uzbl.state.keycmd = g_strdup("");
-}
-
void
load_start_cb (WebKitWebView* page, WebKitWebFrame* frame, gpointer data) {
(void) page;
@@ -986,13 +979,8 @@ struct {const char *key; CommandInfo value;} cmdlist[] =
{ "dehilight", {dehilight, 0} },
{ "toggle_insert_mode", {toggle_insert_mode, 0} },
{ "set", {set_var, TRUE} },
- //{ "get", {get_var, TRUE} },
- { "bind", {act_bind, TRUE} },
{ "dump_config", {act_dump_config, 0} },
{ "dump_config_as_events", {act_dump_config_as_events, 0} },
- { "keycmd", {keycmd, TRUE} },
- { "keycmd_nl", {keycmd_nl, TRUE} },
- { "keycmd_bs", {keycmd_bs, 0} },
{ "chain", {chain, 0} },
{ "print", {print, TRUE} },
{ "event", {event, 0} },
@@ -1089,17 +1077,6 @@ print(WebKitWebView *page, GArray *argv, GString *result) {
}
void
-act_bind(WebKitWebView *page, GArray *argv, GString *result) {
- (void) page; (void) result;
- gchar **split = g_strsplit(argv_idx(argv, 0), " = ", 2);
- gchar *value = parseenv(g_strdup(split[1] ? g_strchug(split[1]) : " "));
- add_binding(g_strstrip(split[0]), value);
- g_free(value);
- g_strfreev(split);
-}
-
-
-void
act_dump_config() {
dump_config();
}
@@ -1110,12 +1087,6 @@ act_dump_config_as_events() {
}
void
-set_keycmd() {
- run_keycmd(FALSE);
- update_title();
-}
-
-void
set_mode_indicator() {
uzbl.gui.sbar.mode_indicator = (uzbl.behave.insert_mode ?
uzbl.behave.insert_indicator : uzbl.behave.cmd_indicator);
@@ -1382,39 +1353,6 @@ chain (WebKitWebView *page, GArray *argv, GString *result) {
}
void
-keycmd (WebKitWebView *page, GArray *argv, GString *result) {
- (void)page;
- (void)argv;
- (void)result;
- uzbl.state.keycmd = g_strdup(argv_idx(argv, 0));
- run_keycmd(FALSE);
- update_title();
-}
-
-void
-keycmd_nl (WebKitWebView *page, GArray *argv, GString *result) {
- (void)page;
- (void)argv;
- (void)result;
- uzbl.state.keycmd = g_strdup(argv_idx(argv, 0));
- run_keycmd(TRUE);
- update_title();
-}
-
-void
-keycmd_bs (WebKitWebView *page, GArray *argv, GString *result) {
- gchar *prev;
- (void)page;
- (void)argv;
- (void)result;
- int len = strlen(uzbl.state.keycmd);
- prev = g_utf8_find_prev_char(uzbl.state.keycmd, uzbl.state.keycmd + len);
- if (prev)
- uzbl.state.keycmd[prev - uzbl.state.keycmd] = '\0';
- update_title();
-}
-
-void
close_uzbl (WebKitWebView *page, GArray *argv, GString *result) {
(void)page;
(void)argv;
@@ -2440,77 +2378,6 @@ key_release_cb (GtkWidget* window, GdkEventKey* event) {
}
void
-run_keycmd(const gboolean key_ret) {
-
- /* run the keycmd immediately if it isn't incremental and doesn't take args */
- Action *act;
- gchar *tmp;
-
- if ((act = g_hash_table_lookup(uzbl.bindings, uzbl.state.keycmd))) {
- clear_keycmd();
- parse_command(act->name, act->param, NULL);
-
- tmp = g_strdup_printf("%s %s", act->name, act->param?act->param:"");
- send_event(COMMAND_EXECUTED, tmp, NULL);
- g_free(tmp);
- return;
- }
-
- /* try if it's an incremental keycmd or one that takes args, and run it */
- GString* short_keys = g_string_new ("");
- GString* short_keys_inc = g_string_new ("");
- guint i;
- guint len = strlen(uzbl.state.keycmd);
- for (i=0; i<len; i++) {
- g_string_append_c(short_keys, uzbl.state.keycmd[i]);
- g_string_assign(short_keys_inc, short_keys->str);
- g_string_append_c(short_keys, '_');
- g_string_append_c(short_keys_inc, '*');
-
- if (key_ret && (act = g_hash_table_lookup(uzbl.bindings, short_keys->str))) {
- /* run normal cmds only if return was pressed */
- exec_paramcmd(act, i);
- clear_keycmd();
- tmp = g_strdup_printf("%s %s", act->name, act->param?act->param:"");
- send_event(COMMAND_EXECUTED, tmp, NULL);
- g_free(tmp);
- break;
- } else if ((act = g_hash_table_lookup(uzbl.bindings, short_keys_inc->str))) {
- if (key_ret) /* just quit the incremental command on return */
- clear_keycmd();
- else {
- exec_paramcmd(act, i); /* otherwise execute the incremental */
- tmp = g_strdup_printf("%s %s", act->name, act->param?act->param:"");
- send_event(COMMAND_EXECUTED, tmp, NULL);
- g_free(tmp);
- }
- break;
- }
-
- g_string_truncate(short_keys, short_keys->len - 1);
- }
- g_string_free (short_keys, TRUE);
- g_string_free (short_keys_inc, TRUE);
-}
-
-void
-exec_paramcmd(const Action *act, const guint i) {
- GString *parampart = g_string_new (uzbl.state.keycmd);
- GString *actionname = g_string_new ("");
- GString *actionparam = g_string_new ("");
- g_string_erase (parampart, 0, i+1);
- if (act->name)
- g_string_printf (actionname, act->name, parampart->str);
- if (act->param)
- g_string_printf (actionparam, act->param, parampart->str);
- parse_command(actionname->str, actionparam->str, NULL);
- g_string_free(actionname, TRUE);
- g_string_free(actionparam, TRUE);
- g_string_free(parampart, TRUE);
-}
-
-
-void
create_browser () {
GUI *g = &uzbl.gui;
@@ -2678,25 +2545,6 @@ run_handler (const gchar *act, const gchar *args) {
g_strfreev(parts);
}
-void
-add_binding (const gchar *key, const gchar *act) {
- char **parts = g_strsplit(act, " ", 2);
- Action *action;
-
- if (!parts)
- return;
-
- //Debug:
- if (uzbl.state.verbose)
- printf ("Binding %-10s : %s\n", key, act);
- action = new_action(parts[0], parts[1]);
-
- if (g_hash_table_remove (uzbl.bindings, key))
- g_warning ("Overwriting existing binding for \"%s\"", key);
- g_hash_table_replace(uzbl.bindings, g_strdup(key), action);
- g_strfreev(parts);
-}
-
/*@null@*/ gchar*
get_xdg_var (XDG_Var xdg) {
const gchar* actual_value = getenv (xdg.environmental);
@@ -3011,9 +2859,6 @@ initialize(int argc, char *argv[]) {
exit(EXIT_SUCCESS);
}
- /* initialize hash table */
- uzbl.bindings = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_action);
-
uzbl.net.soup_session = webkit_get_default_session();
uzbl.state.keycmd = g_strdup("");
diff --git a/uzbl-core.h b/uzbl-core.h
index 5b59c61..b88dd7e 100644
--- a/uzbl-core.h
+++ b/uzbl-core.h
@@ -141,6 +141,7 @@ typedef struct {
gboolean print_version;
/* command list: (key)name -> (value)Command */
+ /* command list: (key)name -> (value)Command */
GHashTable* commands;
/* event lookup: (key)event_id -> (value)event_name */
GHashTable *event_lookup;
@@ -174,9 +175,6 @@ typedef struct {
Info info;
Window xwin;
-
- /* group bindings: key -> action */
- GHashTable* bindings;
} UzblCore;
@@ -325,15 +323,6 @@ void
chain (WebKitWebView *page, GArray *argv, GString *result);
void
-keycmd (WebKitWebView *page, GArray *argv, GString *result);
-
-void
-keycmd_nl (WebKitWebView *page, GArray *argv, GString *result);
-
-void
-keycmd_bs (WebKitWebView *page, GArray *argv, GString *result);
-
-void
close_uzbl (WebKitWebView *page, GArray *argv, GString *result);
gboolean
@@ -401,9 +390,6 @@ void
run_keycmd(const gboolean key_ret);
void
-exec_paramcmd(const Action* act, const guint i);
-
-void
initialize (int argc, char *argv[]);
void
@@ -421,9 +407,6 @@ create_plug ();
void
run_handler (const gchar *act, const gchar *args);
-void
-add_binding (const gchar *key, const gchar *act);
-
/*@null@*/ gchar*
get_xdg_var (XDG_Var xdg);
@@ -458,16 +441,12 @@ void handle_cookies (SoupSession *session,
SoupMessage *msg,
gpointer user_data);
void
-save_cookies (SoupMessage *msg,
- gpointer user_data);
+save_cookies (SoupMessage *msg, gpointer user_data);
void
set_var(WebKitWebView *page, GArray *argv, GString *result);
void
-act_bind(WebKitWebView *page, GArray *argv, GString *result);
-
-void
act_dump_config();
void