summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/dwb-js.749
-rw-r--r--api/jsapi.7.txt23
-rw-r--r--api/jsapi.txt28
-rw-r--r--src/commands.c4
-rw-r--r--src/commands.h2
-rw-r--r--src/completion.c2
-rw-r--r--src/dwb.c131
-rw-r--r--src/util.c9
8 files changed, 176 insertions, 72 deletions
diff --git a/api/dwb-js.7 b/api/dwb-js.7
index 5e0e6959..f801c0d8 100644
--- a/api/dwb-js.7
+++ b/api/dwb-js.7
@@ -2,12 +2,12 @@
.\" Title: dwb-js
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
.\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/>
-.\" Date: 01/28/2013
+.\" Date: 02/01/2013
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "DWB\-JS" "7" "01/28/2013" "\ \&" "\ \&"
+.TH "DWB\-JS" "7" "02/01/2013" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -3510,6 +3510,51 @@ Whether to notify about blocked request, default
.nr an-break-flag 1
.br
.ps +1
+\fBunique_tabs\fR
+.RS 4
+.sp
+Extension that allows to remove duplicate tabs or avoids duplicate tabs automatically\&.
+.PP
+\fIConfiguration options\fR
+.RS 4
+.PP
+\fIshortcutRemoveDuplicates\fR
+.RS 4
+Shortcut that removes duplicate tabs, default
+\fBnull\fR
+.RE
+.PP
+\fIcommandRemoveDuplicates\fR
+.RS 4
+Command that remove s duplicate tabs, default
+\fBut_remove_duplicates\fR
+.RE
+.PP
+\fIautoFocus\fR
+.RS 4
+Autofocus a tab if an url is already opened, if the url would be loaded in a new tab the new tab is closed\&. Setting this to true makes commandRemoveDuplicates and shortcutRemoveDuplicates obsolete because there will be no duplicate tabs\&. Default value:
+\fBtrue\fR
+.RE
+.PP
+\fIshortcutToggleAutoFocus\fR
+.RS 4
+Shortcut that enables/disables autofocus, default
+\fBnull\fR
+.RE
+.PP
+\fIcommandToggleAutoFocus\fR
+.RS 4
+Command that enables/disables autofocus, default
+\fBut_toggle_autofocus\fR
+.RE
+.RE
+.RE
+.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br
+.ps +1
\fBuserscripts\fR
.RS 4
.sp
diff --git a/api/jsapi.7.txt b/api/jsapi.7.txt
index 8a0dce57..65c55b41 100644
--- a/api/jsapi.7.txt
+++ b/api/jsapi.7.txt
@@ -1814,6 +1814,29 @@ _autoreload_;; Whether to automatically reload the website after the
_notify_;; Whether to notify about blocked request, default *false*
+==== unique_tabs
+
+Extension that allows to remove duplicate tabs or avoids duplicate tabs
+automatically.
+
+_Configuration options_::
+
+_shortcutRemoveDuplicates_;; Shortcut that removes duplicate tabs, default *null*
+
+_commandRemoveDuplicates_;; Command that remove s duplicate tabs, default
+*ut_remove_duplicates*
+
+_autoFocus_;; Autofocus a tab if an url is already opened, if the url would be loaded in a
+new tab the new tab is closed. Setting this to true makes commandRemoveDuplicates and
+shortcutRemoveDuplicates obsolete because there will be no duplicate tabs.
+Default value: *true*
+
+_shortcutToggleAutoFocus_;; Shortcut that enables/disables autofocus, default
+*null*
+
+_commandToggleAutoFocus_;; Command that enables/disables autofocus, default
+*ut_toggle_autofocus*
+
==== userscripts
diff --git a/api/jsapi.txt b/api/jsapi.txt
index cefefed5..15d3ad80 100644
--- a/api/jsapi.txt
+++ b/api/jsapi.txt
@@ -35,7 +35,6 @@ properties on the global object, see also <<Globaldata,global data>> for details
:caption:
-
== Global ==
=== Properties ===
@@ -3055,6 +3054,29 @@ _autoreload_;; Whether to automatically reload the website after the
_notify_;; Whether to notify about blocked request, default *false*
+==== unique_tabs
+
+Extension that allows to remove duplicate tabs or avoids duplicate tabs
+automatically.
+
+_Configuration options_::
+
+_shortcutRemoveDuplicates_;; Shortcut that removes duplicate tabs, default *null*
+
+_commandRemoveDuplicates_;; Command that remove s duplicate tabs, default
+*ut_remove_duplicates*
+
+_autoFocus_;; Autofocus a tab if an url is already opened, if the url would be loaded in a
+new tab the new tab is closed. Setting this to true makes commandRemoveDuplicates and
+shortcutRemoveDuplicates obsolete because there will be no duplicate tabs.
+Default value: *true*
+
+_shortcutToggleAutoFocus_;; Shortcut that enables/disables autofocus, default
+*null*
+
+_commandToggleAutoFocus_;; Command that enables/disables autofocus, default
+*ut_toggle_autofocus*
+
==== userscripts
Extension that loads userscripts and injects them into websites, this
@@ -3440,5 +3462,9 @@ return {
--------
====
+== Snippets ==
+
+Some example snippets can be found link:../snippets/snippets.html[here].
+
// vim: set ft=asciidoc:
diff --git a/src/commands.c b/src/commands.c
index 4b885fd3..3d052168 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -44,7 +44,7 @@ modulo(int x, int y) {
/* commands.h {{{*/
/* commands_simple_command(keyMap *km) {{{*/
DwbStatus
-commands_simple_command(KeyMap *km)
+commands_simple_command(KeyMap *km, const char *argument)
{
int ret;
gboolean (*func)(void *, void *) = km->map->func;
@@ -60,7 +60,7 @@ commands_simple_command(KeyMap *km)
{
char *json = util_create_json(3,
CHAR, "command", km->map->n.first,
- CHAR, "argument", arg->p,
+ CHAR, "argument", argument,
INTEGER, "nummod", dwb.state.nummod);
ScriptSignal sig = { NULL, SCRIPTS_SIG_META(json, EXECUTE_COMMAND, 0) } ;
diff --git a/src/commands.h b/src/commands.h
index 19804d9e..741d5f48 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -20,7 +20,7 @@
#define COMMANDS_H
-DwbStatus commands_simple_command(KeyMap *km);
+DwbStatus commands_simple_command(KeyMap *km, const char *);
DwbStatus commands_add_view(KeyMap *, Arg *);
DwbStatus commands_add_search_field(KeyMap *, Arg *);
DwbStatus commands_allow_cookie(KeyMap *, Arg *);
diff --git a/src/completion.c b/src/completion.c
index 432a4d4f..9074d3c8 100644
--- a/src/completion.c
+++ b/src/completion.c
@@ -700,7 +700,7 @@ completion_eval_autocompletion()
Completion *c = dwb.comps.active_auto_c->data;
KeyMap *m = c->data;
dwb_change_mode(NORMAL_MODE, true);
- commands_simple_command(m);
+ commands_simple_command(m, NULL);
}/*}}}*/
/* dwb_set_autcompletion{{{*/
diff --git a/src/dwb.c b/src/dwb.c
index b03e4671..0d8aeff9 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -2688,88 +2688,89 @@ dwb_eval_key(GdkEventKey *e)
KeyMap *km = l->data;
if (IS_NUMMOD(km->mod)) {
//if ((km->mod & DWB_NUMMOD_MASK) && (km->mod & ~DWB_NUMMOD_MASK) == mod_mask) {
- commands_simple_command(km);
+ commands_simple_command(km, NULL);
break;
}
- }
-#undef IS_NUMMOD
}
- g_free(key);
- return true;
- }
- g_string_append(dwb.state.buffer, key);
- if (ALPHA(e) || DIGIT(e)) {
- dwb_set_status_bar_text(dwb.gui.lstatus, dwb.state.buffer->str, &dwb.color.active_fg, dwb.font.fd_active, false);
+#undef IS_NUMMOD
}
+ g_free(key);
+ return true;
+ }
+ g_string_append(dwb.state.buffer, key);
+ if (ALPHA(e) || DIGIT(e))
+ {
+ dwb_set_status_bar_text(dwb.gui.lstatus, dwb.state.buffer->str, &dwb.color.active_fg, dwb.font.fd_active, false);
+ }
- buf = dwb.state.buffer->str;
- longest = 0;
+ buf = dwb.state.buffer->str;
+ longest = 0;
- for (GSList *l = dwb.custom_commands; l; l=l->next)
+ for (GSList *l = dwb.custom_commands; l; l=l->next)
+ {
+ CustomCommand *c = l->data;
+ if (c->key->num == dwb.state.nummod && c->key->mod == mod_mask)
{
- CustomCommand *c = l->data;
- if (c->key->num == dwb.state.nummod && c->key->mod == mod_mask)
+ if (!g_strcmp0(c->key->str, buf))
{
- if (!g_strcmp0(c->key->str, buf))
+ for (int i=0; c->commands[i]; i++)
{
- for (int i=0; c->commands[i]; i++)
- {
- if (dwb_parse_command_line(c->commands[i]) == STATUS_END)
- return true;
- }
- return true;
+ if (dwb_parse_command_line(c->commands[i]) == STATUS_END)
+ return true;
}
- else if (g_str_has_prefix(c->key->str, buf))
- longest = 1;
+ return true;
}
+ else if (g_str_has_prefix(c->key->str, buf))
+ longest = 1;
}
+ }
- for (GList *l = dwb.keymap; l; l=l->next)
- {
- KeyMap *km = l->data;
- if (km->map->prop & CP_OVERRIDE_ENTRY || km->key == NULL)
- continue;
+ for (GList *l = dwb.keymap; l; l=l->next)
+ {
+ KeyMap *km = l->data;
+ if (km->map->prop & CP_OVERRIDE_ENTRY || km->key == NULL)
+ continue;
- gsize kl = strlen(km->key);
- if (!km->key || !kl )
- continue;
+ gsize kl = strlen(km->key);
+ if (!km->key || !kl )
+ continue;
- if (g_str_has_prefix(km->key, buf) && (mod_mask == km->mod) )
+ if (g_str_has_prefix(km->key, buf) && (mod_mask == km->mod) )
+ {
+ if (!longest || kl > longest)
{
- if (!longest || kl > longest)
- {
- longest = kl;
- tmp = km;
- }
- if (dwb.comps.autocompletion)
- {
- coms = g_list_append(coms, km);
- }
+ longest = kl;
+ tmp = km;
+ }
+ if (dwb.comps.autocompletion)
+ {
+ coms = g_list_append(coms, km);
}
}
- /* autocompletion */
- if (dwb.state.mode & AUTO_COMPLETE)
- completion_clean_autocompletion();
+ }
+ /* autocompletion */
+ if (dwb.state.mode & AUTO_COMPLETE)
+ completion_clean_autocompletion();
- if (coms && g_list_length(coms) > 0)
- completion_autocomplete(coms, NULL);
-
- if (tmp && dwb.state.buffer->len == longest)
- {
- commands_simple_command(tmp);
- ret = true;
- }
- else if (e->state & GDK_CONTROL_MASK || !isprint)
- ret = false;
-
- if (longest == 0)
- {
- dwb_clean_key_buffer();
- CLEAR_COMMAND_TEXT();
- }
- g_free(key);
- return ret;
- }/*}}}*/
+ if (coms && g_list_length(coms) > 0)
+ completion_autocomplete(coms, NULL);
+
+ if (tmp && dwb.state.buffer->len == longest)
+ {
+ commands_simple_command(tmp, NULL);
+ ret = true;
+ }
+ else if (e->state & GDK_CONTROL_MASK || !isprint)
+ ret = false;
+
+ if (longest == 0)
+ {
+ dwb_clean_key_buffer();
+ CLEAR_COMMAND_TEXT();
+ }
+ g_free(key);
+ return ret;
+}/*}}}*/
/* dwb_eval_override_key {{{*/
gboolean
@@ -4421,6 +4422,7 @@ dwb_parse_command_line(const char *line)
KeyMap *m = NULL;
gboolean found;
gboolean has_arg = false;
+ const char *argument = NULL;
if (!token[0])
return STATUS_OK;
@@ -4456,11 +4458,12 @@ dwb_parse_command_line(const char *line)
{
g_strstrip(token[1]);
m->map->arg.p = token[1];
+ argument = token[1];
}
if (gtk_widget_has_focus(dwb.gui.entry) && (m->map->prop & CP_OVERRIDE_ENTRY))
m->map->func(&m, &m->map->arg);
else
- ret = commands_simple_command(m);
+ ret = commands_simple_command(m, argument);
break;
}
diff --git a/src/util.c b/src/util.c
index e2afe993..4335133d 100644
--- a/src/util.c
+++ b/src/util.c
@@ -773,7 +773,14 @@ util_create_json(int n, ...) {
else {
g_string_append_c(string, '"');
while (*cval) {
- if (*cval == '"')
+ if ( *cval == '"'
+ || *cval == '/'
+ || *cval == '\\'
+ || *cval == '\b'
+ || *cval == '\f'
+ || *cval == '\n'
+ || *cval == '\r'
+ || *cval == '\t')
g_string_append_c(string, '\\');
g_string_append_c(string, *cval);
cval++;