"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gb.gtk/src/gtools.cpp" between
gambas-3.16.2.tar.bz2 and gambas-3.16.3.tar.bz2

About: Gambas is a graphical development environment based on a Basic interpreter with object extensions, a bit like Visual Basic (requires Qt).

gtools.cpp  (gambas-3.16.2.tar.bz2):gtools.cpp  (gambas-3.16.3.tar.bz2)
skipping to change at line 822 skipping to change at line 822
char c; char c;
if (str->len == 0) if (str->len == 0)
return; return;
c = str->str[str->len - 1]; c = str->str[str->len - 1];
if (c != ' ' && c != '\n') if (c != ' ' && c != '\n')
g_string_append_c(str, ' '); g_string_append_c(str, ' ');
} }
static void add_paragraph_break(GString *str)
{
int i;
char c;
bool markup = false;
int nl = 0;
for (i = str->len - 1; i >= 0; i--)
{
c = str->str[i];
if (markup)
{
if (c == '<')
markup = false;
continue;
}
if (c == '>')
{
markup = true;
continue;
}
if (c != '\n')
break;
nl++;
if (nl >= 2)
break;
}
if (nl == 2 || i < 0)
return;
while (nl < 2)
{
g_string_append_c(str, '\n');
nl++;
}
}
static void add_attr(GString *pango, const char *attr, const char *value) static void add_attr(GString *pango, const char *attr, const char *value)
{ {
bool add_quote = *value != '"' && *value !='\''; bool add_quote = *value != '"' && *value !='\'';
g_string_append_c(pango, ' '); g_string_append_c(pango, ' ');
g_string_append(pango, attr); g_string_append(pango, attr);
g_string_append_c(pango, '='); g_string_append_c(pango, '=');
if (add_quote) g_string_append_c(pango, '"'); if (add_quote) g_string_append_c(pango, '"');
g_string_append(pango, value); g_string_append(pango, value);
if (add_quote) g_string_append_c(pango, '"'); if (add_quote) g_string_append_c(pango, '"');
skipping to change at line 868 skipping to change at line 906
char **attr; char **attr;
int attr_count; int attr_count;
const char *pp; const char *pp;
gsize len; gsize len;
bool start_token = false; bool start_token = false;
bool end_token = false; bool end_token = false;
const char **pt; const char **pt;
int size = 3; // medium int size = 3; // medium
char size_stack[size_stack_len]; char size_stack[size_stack_len];
int size_stack_ptr = 0; int size_stack_ptr = 0;
bool newline = true;
bool inside_par = false;
int i; int i;
int mode_pre = 0;
//fprintf(stderr, "gt_html_to_pango_string: %.*s\n", len_html, html); //fprintf(stderr, "gt_html_to_pango_string: %.*s\n", len_html, html);
p_end = &html[len_html < 0 ? strlen(html) : len_html]; p_end = &html[len_html < 0 ? strlen(html) : len_html];
p_markup = NULL; p_markup = NULL;
if (len_html == 0) if (len_html == 0)
goto RETURN_STRING; goto RETURN_STRING;
#if PANGO_VERSION_CHECK(1, 41, 0) #if PANGO_VERSION_CHECK(1, 41, 0)
skipping to change at line 915 skipping to change at line 952
end_token = false; end_token = false;
} }
continue; continue;
} }
if (c == '>') if (c == '>')
{ {
if (!p_markup) if (!p_markup)
{ {
g_string_append(pango, "&gt;"); g_string_append(pango, "&gt;");
newline = false;
continue; continue;
} }
len = p - p_markup; len = p - p_markup;
if (p[-1] == '/') if (p[-1] == '/')
{ {
if (len > 0) if (len > 0)
len--; len--;
end_token = true; end_token = true;
skipping to change at line 961 skipping to change at line 997
} }
if (!token) if (!token)
goto __FOUND_TOKEN; goto __FOUND_TOKEN;
for (pt = title; *pt; pt += 2) for (pt = title; *pt; pt += 2)
{ {
if (!strcasecmp(*pt, token)) if (!strcasecmp(*pt, token))
{ {
if (start_token && !end_token) if (start_token && !end_token)
{
add_paragraph_break(pango);
g_string_append_printf(pango, "<s pan %s><b>", pt[1]); g_string_append_printf(pango, "<s pan %s><b>", pt[1]);
}
else if (end_token && !start_token) else if (end_token && !start_token)
{ {
g_string_append_printf(pango, "</ g_string_append_printf(pango, "</
b></span>\n"); b></span>");
g_string_append(pango, "<span siz add_paragraph_break(pango);
e=\"smaller\">\n</span>"); //g_string_append(pango, "<span s
newline = true; ize=\"smaller\">\n</span>");
} }
goto __FOUND_TOKEN; goto __FOUND_TOKEN;
} }
} }
for (pt = accept; *pt; pt++) for (pt = accept; *pt; pt++)
{ {
if (!strcasecmp(*pt, token)) if (!strcasecmp(*pt, token))
{ {
if (start_token != end_token) if (start_token != end_token)
g_string_append_printf(pango, "<% s%s>", end_token ? "/" : "", *pt); g_string_append_printf(pango, "<% s%s>", end_token ? "/" : "", *pt);
goto __FOUND_TOKEN; goto __FOUND_TOKEN;
} }
} }
if (!strcasecmp(token, "br") || !strcasecmp(token, "hr")) if (!strcasecmp(token, "br") || !strcasecmp(token, "hr"))
{ {
if (start_token) if (start_token)
{ {
g_string_append_c(pango, '\n'); g_string_append_c(pango, '\n');
newline = true;
} }
goto __FOUND_TOKEN; goto __FOUND_TOKEN;
} }
if (!strcasecmp(token, "p")) if (!strcasecmp(token, "p"))
{ {
if ((end_token || inside_par) && p[1]) add_paragraph_break(pango);
{
g_string_append_c(pango, '\n');
newline = true;
}
inside_par = start_token;
goto __FOUND_TOKEN; goto __FOUND_TOKEN;
} }
if (!strcasecmp(token, "font")) if (!strcasecmp(token, "font"))
{ {
if (end_token && !start_token) if (end_token && !start_token)
{ {
if (size_stack_ptr > 0) if (size_stack_ptr > 0)
{ {
size_stack_ptr--; size_stack_ptr--;
skipping to change at line 1087 skipping to change at line 1120
if (!strcasecmp(token, "code")) if (!strcasecmp(token, "code"))
{ {
if (start_token && !end_token) if (start_token && !end_token)
g_string_append(pango, "<tt>"); g_string_append(pango, "<tt>");
else if (end_token && !start_token) else if (end_token && !start_token)
g_string_append(pango, "</tt>"); g_string_append(pango, "</tt>");
goto __FOUND_TOKEN; goto __FOUND_TOKEN;
} }
if (!strcasecmp(token, "pre"))
{
if (start_token && !end_token)
{
add_paragraph_break(pango);
g_string_append(pango, "<tt>");
mode_pre++;
}
else if (end_token && !start_token)
{
mode_pre--;
g_string_append(pango, "</tt>");
add_paragraph_break(pango);
}
goto __FOUND_TOKEN;
}
g_string_append(pango, "&lt;"); g_string_append(pango, "&lt;");
if (end_token) g_string_append(pango, "/"); if (end_token) g_string_append(pango, "/");
while (p_markup < p) while (p_markup < p)
{ {
g_string_append(pango, html_entity(*p_markup)); g_string_append(pango, html_entity(*p_markup));
p_markup++; p_markup++;
} }
g_string_append(pango, "&gt;"); g_string_append(pango, "&gt;");
newline = false;
__FOUND_TOKEN: __FOUND_TOKEN:
GB.Unref(POINTER(&attr_array)); GB.Unref(POINTER(&attr_array));
p_markup = NULL; p_markup = NULL;
continue; continue;
} }
if (c == '\n' && !newline_are_break)
{
if (!newline)
add_space(pango);
continue;
}
if (c == '\r')
{
add_space(pango);
continue;
}
if (c == '&') if (c == '&')
{ {
const char *entity_start = ++p; const char *entity_start = ++p;
int entity_len; int entity_len;
int entity_unicode; int entity_unicode;
char *endptr; char *endptr;
// if ((p_end - p) >= 6 && !strncasecmp(p, "&nbsp;", 6)) // if ((p_end - p) >= 6 && !strncasecmp(p, "&nbsp;", 6))
// { // {
// g_string_append(pango, " "); // g_string_append(pango, " ");
skipping to change at line 1183 skipping to change at line 1219
if (entity_unicode >= 0) if (entity_unicode >= 0)
{ {
g_string_append_unichar(pango, en tity_unicode); g_string_append_unichar(pango, en tity_unicode);
continue; continue;
} }
} }
} }
g_string_append(pango, "&amp;"); g_string_append(pango, "&amp;");
p = entity_start - 1; p = entity_start - 1;
newline = false;
continue; continue;
} }
if (!p_markup) if (!p_markup)
{ {
if (c == '\n' && !newline_are_break && mode_pre == 0)
{
add_space(pango);
continue;
}
if (c == '\r')
{
add_space(pango);
continue;
}
if (c == ' ') if (c == ' ')
{ {
if (!newline) if (mode_pre)
g_string_append_unichar(pango, 160);
else
add_space(pango); add_space(pango);
continue; continue;
} }
g_string_append(pango, html_entity(*p)); g_string_append(pango, html_entity(*p));
newline = false;
} }
} }
RETURN_STRING: RETURN_STRING:
p = g_string_free(pango, false); p = g_string_free(pango, false);
//fprintf(stderr, "==> '%s'\n", p); //fprintf(stderr, "==> '%s'\n", p);
return (char *)p; return (char *)p;
} }
 End of changes. 16 change blocks. 
32 lines changed or deleted 80 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)