r7178 - software/ui/src
Peter De Wachter
pdewacht-guest at alioth.debian.org
Sat May 24 22:49:49 UTC 2008
Author: pdewacht-guest
Date: 2008-05-24 22:49:48 +0000 (Sat, 24 May 2008)
New Revision: 7178
Modified:
software/ui/src/pkgbrowser.cpp
Log:
word wrap long URLs
Modified: software/ui/src/pkgbrowser.cpp
===================================================================
--- software/ui/src/pkgbrowser.cpp 2008-05-24 10:17:24 UTC (rev 7177)
+++ software/ui/src/pkgbrowser.cpp 2008-05-24 22:49:48 UTC (rev 7178)
@@ -69,7 +69,6 @@
using namespace ept::textsearch;
static const char legalchars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz at _?+-,.~/%&=:*#";
-#define SIZE_URI 256
PackageBrowser::PackageBrowser(int x, int y, int w, int h, const char *l)
: VersatileBrowser(x, y, w, h, l), num_bar_images(2)
@@ -106,16 +105,23 @@
if (!strncasecmp("http:", src, 5) || !strncasecmp("mailto:", src, 7) ||
!strncasecmp("ftp:", src, 4) || !strncasecmp("https:", src, 6))
{
- char uri[SIZE_URI];
- int i;
- for (i = 0; *src && (strchr(legalchars, *src) || (*src & 128)) && i < SIZE_URI-1; i++)
- uri[i] = *src++;
- if (strchr(".?!", uri[i-1])) { --i; --src; } // Probably the end of a sentence
- uri[i] = 0;
+ std::string uri, uri_text;
+ for (; *src && (strchr(legalchars, *src) || (*src & 128)); src++)
+ {
+ uri += *src;
+ uri_text += *src;
+ if (*src == '/')
+ uri_text += "<wbr>";
+ }
+ if (strchr(".?!", src[-1])) { // Probably the end of a sentence
+ --src;
+ uri.resize(uri.size() - 1);
+ uri_text.resize(uri_text.size() - 1);
+ }
out_html += "<a href=\"";
out_html += uri;
out_html += "\">";
- out_html += uri;
+ out_html += uri_text;
out_html += "</a>";
}
else if (!strncasecmp(" .\n", src, 3))
More information about the Pkg-games-commits
mailing list