summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <none@none>2013-01-11 18:08:48 +0100
committerportix <none@none>2013-01-11 18:08:48 +0100
commit316df269e03372433698eb843c6a881cd4249665 (patch)
tree1118bc3d8c322efef35aacd6457741d6c5944efd
parent5120a25141eae3fadeeeb2eca54f9f902c9056ed (diff)
downloaddwb-316df269e03372433698eb843c6a881cd4249665.zip
Clear textentry when calling io_prompt
-rw-r--r--src/dwb.c12
-rw-r--r--src/dwb.h2
-rw-r--r--src/scripts.c8
3 files changed, 16 insertions, 6 deletions
diff --git a/src/dwb.c b/src/dwb.c
index 43e7d2c6..e4923608 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -596,7 +596,7 @@ dwb_set_normal_message(GList *gl, gboolean hide, const char *text, ...)
if (gl != dwb.state.fview)
return;
- char message[STRING_LENGTH];
+ char message[STRING_LENGTH] = {0};
va_list arg_list;
va_start(arg_list, text);
@@ -2320,9 +2320,10 @@ dwb_confirm(GList *gl, char *prompt, ...)
}/*}}}*/
/* dwb_prompt {{{*/
-const char *
+char *
dwb_prompt(gboolean visibility, char *prompt, ...)
{
+ char *result = NULL;
dwb.state.mode |= CONFIRM;
va_list arg_list;
char message[STRING_LENGTH];
@@ -2351,8 +2352,13 @@ dwb_prompt(gboolean visibility, char *prompt, ...)
dwb_focus_scroll(dwb.state.fview);
CLEAR_COMMAND_TEXT();
+
+ if (state == 0)
+ result = g_strdup(GET_TEXT());
+
+ gtk_editable_delete_text(GTK_EDITABLE(dwb.gui.entry), 0, -1);
gtk_entry_set_visibility(GTK_ENTRY(dwb.gui.entry), true);
- return state == 0 ? GET_TEXT() : NULL;
+ return result;
}/*}}}*/
/* dwb_save_quickmark(const char *key) {{{*/
diff --git a/src/dwb.h b/src/dwb.h
index 07b2d7e1..1e90d4ed 100644
--- a/src/dwb.h
+++ b/src/dwb.h
@@ -968,7 +968,7 @@ void dwb_init_vars(void);
void dwb_parse_commands(const char *line);
DwbStatus dwb_scheme_handler(GList *gl, WebKitNetworkRequest *request);
GList *dwb_get_simple_list(GList *, const char *filename);
-const char * dwb_prompt(gboolean visibility, char *prompt, ...);
+char * dwb_prompt(gboolean visibility, char *prompt, ...);
gboolean dwb_dom_remove_from_parent(WebKitDOMNode *node, GError **error);
char * dwb_get_raw_data(GList *gl);
diff --git a/src/scripts.c b/src/scripts.c
index 1d009110..9071634a 100644
--- a/src/scripts.c
+++ b/src/scripts.c
@@ -1716,13 +1716,17 @@ io_prompt(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t
if (argc > 1 && JSValueIsBoolean(ctx, argv[1]))
visibility = JSValueToBoolean(ctx, argv[1]);
- const char *response = dwb_prompt(visibility, prompt);
+ char *response = dwb_prompt(visibility, prompt);
g_free(prompt);
if (response == NULL)
return NIL;
- return js_char_to_value(ctx, response);
+ JSValueRef result = js_char_to_value(ctx, response);
+
+ memset(response, 0, strlen(response));
+ g_free(response);
+ return result;
}/*}}}*/
/* io_read {{{*/