Re: gnome-terminal 2.5.experiences long pauses on solaris 8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This was exactly the problem!  The final workaround (which
breaks the VTE interface) did the trick for me (after a
little bashing to make the patch work against CVS).  Thanks
very very much!

I was not really affected at first by the selection issue
and so I just didn't search properly in Bugzilla - my first
major symptom was that it took minutes to select a menu
option if the display had scrolled at all.

I am pasting the patch, as I used it, into the end of this
email in case a person reading this needs quick access to
something that works against recent CVS versions of vte.c.

This is great because I can now get back the feature that
makes the general slowness and memory consumption of
gnome-terminal worth accepting: tabbed windows.

Cheers and thanks again,

Tim



--- vte.c.orig	2003-09-15 19:51:29.000000000 +0100
+++ vte.c	2004-01-02 14:22:23.182152000 +0000
@@ -1559,6 +1559,81 @@
 	gdk_cursor_unref(cursor);
 }
 
+static gboolean find_url(const char *data, int cursor, int
*start, int *end)
+{
+	const char *allowed = "-_$.+!*(),;:@&=/?~#%";
+	const char *trim = ".),";
+	const char *starts[] = { "news://";, "telnet://";,
"nttp://", "file://",
+				 "http://";, "ftp://";, "https://";,
+				 "www", "ftp" };
+	const int nstarts = sizeof(starts) / sizeof(*starts);
+	gboolean dot;
+	int i, j;
+
+	/* Back up to just after the most recent non-URL
character. */
+	for (i = cursor; i > 0; i--) {
+		if (!isalnum(data[i - 1]) && !strchr(allowed, data[i -
1]))
+			break;
+	}
+
+	/* Find an appropriate beginning. */
+	for (; i <= cursor; i++) {
+		if (!strchr("fhntw", data[i]))
+			continue;
+		for (j = 0; j < nstarts; j++) {
+		  	if (strncmp(data + i, starts[j],
+				    strlen(starts[j])) == 0)
+				break;
+		}
+		if (j < nstarts)
+			break;
+	}
+	if (i > cursor)
+		return FALSE;
+	*start = i;
+	i += strlen(starts[j]);
+
+	/* Find end of domain part.  We must see at least one dot
if
+	 * our beginning wasn't a real URL scheme. */
+	dot = FALSE;
+	for (; data[i]; i++) {
+		if (data[i] == '.')
+			dot = TRUE;
+		else if (!isalnum(data[i]) && data[i] != '-')
+			break;
+	}
+	if (!dot && !strchr(starts[j], ':'))
+		return FALSE;
+
+	if (data[i] == ':')
+	  {
+	    i++;
+	    while (isdigit(data[i]))
+	      i++;
+	  }
+
+	/* If we've passed the cursor, then we only want this
part. */
+	if (i > cursor) {
+		*end = i;
+		return TRUE;
+	}
+
+	if (data[i++] != '/')
+		return FALSE;
+
+	/* Find the end of the URL. */
+	for (; data[i]; i++) {
+		if (!isalnum(data[i]) && !strchr(allowed, data[i]))
+			break;
+	}
+	if (i <= cursor)
+		return FALSE;
+
+	/* If the last character looks like ending punctuation,
trim it. */
+	*end = (strchr(trim, data[i - 1]) != NULL) ? i - 1 : i;
+	return TRUE;
+}
+
 /* Check if a given cell on the screen contains part of a
matched string.  If
  * it does, return the string, and store the match tag in
the optional tag
  * argument. */
@@ -1567,7 +1642,7 @@
 				  long column, glong row,
 				  int *tag, int *start, int *end)
 {
-	int i, j, ret, offset;
+	int i, j, ret, offset, st, en;
 	struct vte_match_regex *regex = NULL;
 	struct _VteCharAttributes *attr = NULL;
 	gssize coffset;
@@ -1632,97 +1707,18 @@
 		return NULL;
 	}
 
-	/* Now iterate over each regex we need to match against.
*/
-	for (i = 0; i < terminal->pvt->match_regexes->len; i++) {
-		regex = &g_array_index(terminal->pvt->match_regexes,
-				       struct vte_match_regex,
-				       i);
-		/* Skip holes. */
-		if (regex->tag < 0) {
-			continue;
-		}
-		/* We'll only match the first item in the buffer which
-		 * matches, so we'll have to skip each match until we
-		 * stop getting matches. */
-		coffset = 0;
-		ret = _vte_regex_exec(regex->reg,
-				      terminal->pvt->match_contents + coffset,
-				      G_N_ELEMENTS(matches),
-				      matches);
-		while (ret == 0) {
-			for (j = 0;
-			     (j < G_N_ELEMENTS(matches)) &&
-			     (matches[j].rm_so != -1);
-			     j++) {
-				/* The offsets should be "sane". */
-				g_assert(matches[j].rm_so + coffset <
-					 terminal->pvt->match_attributes->len);
-				g_assert(matches[j].rm_eo + coffset <=
-					 terminal->pvt->match_attributes->len);
-#ifdef VTE_DEBUG
-				if (_vte_debug_on(VTE_DEBUG_MISC)) {
-					char *match;
-					struct _VteCharAttributes *sattr, *eattr;
-					match = g_strndup(terminal->pvt->match_contents +
matches[j].rm_so + coffset,
-							  matches[j].rm_eo - matches[j].rm_so);
-					sattr =
&g_array_index(terminal->pvt->match_attributes,
-							       struct _VteCharAttributes,
-							       matches[j].rm_so + coffset);
-					eattr =
&g_array_index(terminal->pvt->match_attributes,
-							       struct _VteCharAttributes,
-							       matches[j].rm_eo + coffset - 1);
-					fprintf(stderr, "Match %d `%s' from %d(%ld,%ld) to
%d(%ld,%ld) (%d).\n",
-						j, match,
-						matches[j].rm_so + coffset,
-						sattr->column,
-						sattr->row,
-						matches[j].rm_eo + coffset - 1,
-						eattr->column,
-						eattr->row,
-						offset);
-					g_free(match);
-
-				}
-#endif
-				/* Snip off any final newlines. */
-				while ((matches[j].rm_eo > matches[j].rm_so) &&
-				       (terminal->pvt->match_contents[coffset +
matches[j].rm_eo - 1] == '\n')) {
-					matches[j].rm_eo--;
-				}
-				/* If the pointer is in this substring,
-				 * then we're done. */
-				if ((offset >= (matches[j].rm_so + coffset)) &&
-				    (offset < (matches[j].rm_eo + coffset))) {
-					if (tag != NULL) {
-						*tag = regex->tag;
-					}
-					if (start != NULL) {
-						*start = coffset +
-							 matches[j].rm_so;
-					}
-					if (end != NULL) {
-						*end = coffset +
-						       matches[j].rm_eo - 1;
-					}
-					if (GTK_WIDGET_REALIZED(GTK_WIDGET(terminal))) {
-						gdk_window_set_cursor((GTK_WIDGET(terminal))->window,
-								      regex->cursor);
-					}
-					terminal->pvt->match_previous = regex->tag;
-					return g_strndup(terminal->pvt->match_contents +
coffset + matches[j].rm_so,
-							 matches[j].rm_eo - matches[j].rm_so);
-				}
-			}
-			/* Skip past the beginning of this match to
-			 * look for more. */
-			coffset += (matches[0].rm_so + 1);
-			ret = _vte_regex_exec(regex->reg,
-					      terminal->pvt->match_contents +
-					      coffset,
-					      G_N_ELEMENTS(matches),
-					      matches);
-		}
+	if (find_url(terminal->pvt->match_contents, offset, &st,
&en)) 
+	{
+		if (tag)
+		        *tag = 0;
+		if (start)
+		        *start = st;
+		if (end)
+		        *end = en - 1;
+		return g_strndup(terminal->pvt->match_contents + st, en
- st);
 	}
+
+
 	terminal->pvt->match_previous = -1;
 	return NULL;
 }


On Fri, 02 Jan 2004 11:19:28 +0000
 "padraig o'briain" <Padraig.Obriain@xxxxxxx> wrote:
> This may be bugzilla bug #93775. The corresponding Sun
> bug number is 4871054. This will be fixed in Solaris 10
> and has been fixed in Solaris 9 Update 6. It does not
> seem to be fixed in Solaris 8.
> 
> Padraig.
> 
> Timothy Murphy wrote:
> > 
> > Hi,
> > 
> > Thanks for your reply. I shall take your advice and now
> > that I have found out a few more details, I will be
> able to
> > file a better bug report.
> > 
> > For the record, gnome-terminal goes into some kind of
> loop
> > in which it repeatedly calls poll() when I try to
> select
> > text.  This carries on for up to 10 seconds and each
> time,
> > poll() returns the result that no activity has happened
> on
> > any of the filehandles that it's watching.  Amongst the
> > file handles are ones that relate to the connection to
> the
> > X server and one that refers to the current pty.
> > 
> > Immediately before the poll, gnome-term has been
> writing
> > data to the X server so I expect that it is waiting for
> > something back - which it never gets, perhaps.
> > 
> > Cheers, :-)
> > 
> > Tim
> > 
> > > On Mon, Dec 15, 2003 at 02:23:00PM +0200 or
> thereabouts,
> > Timothy Murphy wrote:
> > >> I have been experiencing a problem with
> gnome-terminal
> > >> 2.5.x (both 2.5.0 and CVS head after 2.5.1) and vte
> > 0.11.x
> > >>  (I have tried CVS head and 0.11.10).  I am running
> them
> > on
> > >> Solaris 8 (sparc) and everything was compiled with
> > >> gcc-3.3.2.
> > >>
> > >> I'm sorry, BTW, that I'm not subscribed but I can't
> > afford
> > >> to store the volume of messages in my webmail
> account.
> > >
> > > There is a handy "don't receive any mail from this
> list"
> > > option in mailman, but then I suppose you wouldn't
> see
> > > any replies, either. I presume you're reading from
> the
> > > web archives?
> > >
> > >> There are three problems:
> > >
> > > I have snipped this, because I really have no idea on
> any
> > > of it. Since there have been no other responses, I
> think
> > I
> > > would suggest you file it in bugzilla with all the
> detail
> > > you included in the original message.
> > >
> > >> I hope that this is useful to someone.  Perhaps I
> will
> > be
> > >> able to work out how to get gprof to produce some
> > profiling
> > >> information which will indicate the source of the
> > problem
> > >> more precisely.
> > >
> > > I think it is useful information: it's just that none
> of
> > > the gnome-terminal or vte people have spotted it in
> here
> > :/
> > >
> > > Definitely bugzilla it, though: they can't escape it
> > there :)
> > >
> > > Telsa
> > ___________________________________________
> >  Look Good, Feel Good www.healthiest.co.za
> > 
> > _______________________________________________
> > gnome-list mailing list
> > gnome-list@xxxxxxxxx
> > http://mail.gnome.org/mailman/listinfo/gnome-list

___________________________________________
 Look Good, Feel Good www.healthiest.co.za

_______________________________________________
gnome-list mailing list
gnome-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gnome-list

[Index of Archives]     [Fedora Desktop]     [Trinity Users]     [KDE]     [Gimp]     [Yosemite News]

  Powered by Linux