summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2013-05-27 19:41:09 +0200
committerportix <portix@gmx.net>2013-05-27 19:41:09 +0200
commit74ee3dfc7cbb42c96a626836832e2eb7adf7dc12 (patch)
tree753b9f8f71f42bba037b45135d48c192fa18dfd6
parenta3c5d7cb962543f9997b2c7ac85313576abc511d (diff)
downloaddwb-74ee3dfc7cbb42c96a626836832e2eb7adf7dc12.zip
Allow entering numbers with hint-style number, lowercase letters with hintstyle letter
-rw-r--r--scripts/base.js16
-rw-r--r--src/dwb.c6
-rw-r--r--src/scripts.c1
3 files changed, 19 insertions, 4 deletions
diff --git a/scripts/base.js b/scripts/base.js
index 626effd2..fdfa86f6 100644
--- a/scripts/base.js
+++ b/scripts/base.js
@@ -9,6 +9,8 @@ Object.freeze((function () {
};
var globals = {
active : null,
+ matchHint : -1,
+ escapeChar : "\\",
activeArr : [],
activeInput : null,
elements : [],
@@ -216,7 +218,7 @@ Object.freeze((function () {
var inArr = input.split(" ");
for (i=0; i<inArr.length; i++)
{
- if (!this.element.textContent.toUpperCase().match(inArr[i]))
+ if (!this.element.textContent.toUpperCase().match(inArr[i].toUpperCase()))
return false;
}
return true;
@@ -506,7 +508,16 @@ Object.freeze((function () {
globals.lastInput = input;
if (input)
{
- if (globals.style == "number")
+ if (input[input.length-1] == globals.escapeChar && globals.matchHint == -1)
+ {
+ globals.matchHint = input.indexOf(globals.escapeChar) + 1;
+ return null;
+ }
+ if (globals.matchHint != -1)
+ {
+ input = input.substring(globals.matchHint);
+ }
+ else if (globals.style == "number")
{
if (input[input.length-1].isInt())
{
@@ -602,6 +613,7 @@ Object.freeze((function () {
globals.lastPosition = 0;
globals.lastInput = null;
globals.positions = [];
+ globals.matchHint = -1;
if (globals.notify && globals.notify.parentNode)
{
globals.notify.parentNode.removeChild(globals.notify);
diff --git a/src/dwb.c b/src/dwb.c
index c923ac03..ae04139d 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -2161,6 +2161,8 @@ dwb_update_hints(GdkEventKey *e)
char *val;
gboolean ret = false;
char json[BUFFER_LENGTH] = {0};
+ const char *text;
+ char *escaped;
if (IS_RETURN_KEY(e))
{
@@ -2183,9 +2185,11 @@ dwb_update_hints(GdkEventKey *e)
else
{
val = util_keyval_to_char(e->keyval, true);
- snprintf(json, sizeof(json), "{ \"input\" : \"%s%s\", \"type\" : %d }", GET_TEXT(), val ? val : "", hint_map[dwb.state.hint_type].arg);
+ escaped = g_strescape(GET_TEXT(), NULL);
+ snprintf(json, sizeof(json), "{ \"input\" : \"%s%s\", \"type\" : %d }", escaped, val ? (*val == '\\' ? "\\\\" : val) : "", hint_map[dwb.state.hint_type].arg);
com = "updateHints";
g_free(val);
+ g_free(escaped);
}
if (com)
{
diff --git a/src/scripts.c b/src/scripts.c
index 3bc33488..efbd75cf 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -5702,7 +5702,6 @@ scripts_reapply()
gboolean
scripts_init(gboolean force)
{
- puts(SCRIPT_TEMPLATE_XINCLUDE);
dwb.misc.script_signals = 0;
if (s_global_context == NULL)
{