void vb_echo_force(const MessageType type, gboolean hide, const char *error, ...)
{
- char message[BUF_SIZE];
- va_list arg_list;
+ char *buffer;
+ va_list args;
- va_start(arg_list, error);
- vsnprintf(message, BUF_SIZE, error, arg_list);
- va_end(arg_list);
+ va_start(args, error);
+ buffer = g_strdup_vprintf(error, args);
+ va_end(args);
- input_print(true, type, hide, message);
+ input_print(true, type, hide, buffer);
+ g_free(buffer);
}
void vb_echo(const MessageType type, gboolean hide, const char *error, ...)
{
- char message[BUF_SIZE];
- va_list arg_list;
+ char *buffer;
+ va_list args;
- va_start(arg_list, error);
- vsnprintf(message, BUF_SIZE, error, arg_list);
- va_end(arg_list);
+ va_start(args, error);
+ buffer = g_strdup_vprintf(error, args);
+ va_end(args);
- input_print(false, type, hide, message);
+ input_print(false, type, hide, buffer);
+ g_free(buffer);
+}
+
+static void input_print(gboolean force, const MessageType type, gboolean hide,
+ const char *message)
+{
+ /* don't print message if the input is focussed */
+ if (!force && gtk_widget_is_focus(GTK_WIDGET(vb.gui.input))) {
+ return;
+ }
+
+ /* apply input style only if the message type was changed */
+ if (type != vb.state.input_type) {
+ vb.state.input_type = type;
+ vb_update_input_style();
+ }
+ vb_set_input_text(message);
+ if (hide) {
+ g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)hide_message, NULL);
+ }
}
/**
}
}
-static void input_print(gboolean force, const MessageType type, gboolean hide, const char *message)
-{
- /* don't print message if the input is focussed */
- if (!force && gtk_widget_is_focus(GTK_WIDGET(vb.gui.input))) {
- return;
- }
-
- /* apply input style only if the message type was changed */
- if (type != vb.state.input_type) {
- vb.state.input_type = type;
- vb_update_input_style();
- }
- vb_set_input_text(message);
- if (hide) {
- g_timeout_add_seconds(MESSAGE_TIMEOUT, (GSourceFunc)hide_message, NULL);
- }
-}
-
static void run_user_script(WebKitWebFrame *frame)
{
char *js = NULL, *value = NULL;
if (strchr("ot", info->cmd)) {
vb_set_input_text(info->cmd == 't' ? ":tabopen " : ":open ");
} else {
- /* use vb_set_input_text because this is not restricted to BUF_SIZE
- * wich could be to small for some uri */
- char *str = g_strconcat(
- info->cmd == 'T' ? ":tabopen " : ":open ",
- GET_URI(),
- NULL
- );
- vb_set_input_text(str);
- g_free(str);
+ vb_echo(VB_MSG_NORMAL, false, ":%s %s", info->cmd == 'T' ? "open" : "tabopen", GET_URI());
}
/* switch mode after setting the input text to not trigger the
* commands modes input change handler */