about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJosh Rickmar <jrick@devio.us>2012-08-02 15:35:54 -0400
committerJosh Rickmar <jrick@devio.us>2012-08-02 15:35:54 -0400
commit77bcb5bc538f12fcc223f2f584bbd8d0387f11a0 (patch)
tree57ae2eb87832e1b9ce9659ace87dc6cbb2bcb908
parent9ca900cd5e075fd66de3ac87948b15cae589663b (diff)
downloadxombrero-77bcb5bc538f12fcc223f2f584bbd8d0387f11a0.tar.gz
Prevent expanding tabs when using the P keybinding.
This change modifies the paste_uri function to change all newlines in
the uri with spaces.  This stops the new tab from expanding to twice
it's correct height when using the P command, if pasting a link that
contains any newlines (usually these would come from copying the
newline out of a terminal).
-rw-r--r--xombrero.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/xombrero.c b/xombrero.c
index 7b80c96..214b104 100644
--- a/xombrero.c
+++ b/xombrero.c
@@ -1502,6 +1502,7 @@ paste_uri(struct tab *t, struct karg *args)
 {
 	GtkClipboard		*clipboard, *primary;
 	gchar			*c = NULL, *p = NULL, *uri;
+	int			i;
 
 	clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
 	primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
@@ -1516,6 +1517,11 @@ paste_uri(struct tab *t, struct karg *args)
 		/* UNIX try primary first */
 		uri = p ? p : c;
 #endif
+		/* replace all newlines with spaces */
+		for (i = 0; uri[i] != '\0'; ++i)
+			if (uri[i] == '\n')
+				uri[i] = ' ';
+
 		while (*uri && isspace(*uri))
 			uri++;
 		if (strlen(uri) == 0) {