nb token
This commit is contained in:
parent
6ab2bc8106
commit
071b2c0003
|
@ -1671,14 +1671,14 @@ static int is_delim(int c)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int word_img(const char *p, char **eptr)
|
static int process_word_token(const char *p, char **eptr, char ch)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
if (eptr)
|
if (eptr)
|
||||||
*eptr = (char*)p;
|
*eptr = (char*)p;
|
||||||
if (!p)
|
if (!p)
|
||||||
return 0;
|
return 0;
|
||||||
if (p[0] != '<' || p[1] != 'g' || p[2] != ':')
|
if (p[0] != '<' || p[1] != ch || p[2] != ':')
|
||||||
return 0;
|
return 0;
|
||||||
p += 3;
|
p += 3;
|
||||||
len = strcspn(p, ">");
|
len = strcspn(p, ">");
|
||||||
|
@ -1689,6 +1689,16 @@ static int word_img(const char *p, char **eptr)
|
||||||
return len + 1;
|
return len + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int word_img(const char *p, char **eptr)
|
||||||
|
{
|
||||||
|
return process_word_token(p, eptr, 'g');
|
||||||
|
}
|
||||||
|
|
||||||
|
static int word_token(const char *p, char **eptr)
|
||||||
|
{
|
||||||
|
return process_word_token(p, eptr, 'w');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *lookup_token_or_sp(const char *ptr)
|
static const char *lookup_token_or_sp(const char *ptr)
|
||||||
{
|
{
|
||||||
|
@ -1709,6 +1719,10 @@ static const char *lookup_token_or_sp(const char *ptr)
|
||||||
if (p == ptr) /* first one */
|
if (p == ptr) /* first one */
|
||||||
p = eptr;
|
p = eptr;
|
||||||
return p;
|
return p;
|
||||||
|
} else if (word_token(p, &eptr)) {
|
||||||
|
if (p == ptr) /* first one */
|
||||||
|
p = eptr;
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
p ++;
|
p ++;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1745,6 +1759,9 @@ static char *get_word(const char *ptr, char **eptr, int *sp)
|
||||||
o[sz] = 0;
|
o[sz] = 0;
|
||||||
|
|
||||||
sz = word_img(ptr, eptr);
|
sz = word_img(ptr, eptr);
|
||||||
|
if (sz)
|
||||||
|
return o;
|
||||||
|
sz = word_token(ptr, eptr);
|
||||||
if (sz)
|
if (sz)
|
||||||
return o;
|
return o;
|
||||||
*eptr = (char*)ep;
|
*eptr = (char*)ep;
|
||||||
|
@ -2215,7 +2232,6 @@ void txt_layout_update_links(layout_t layout, int x, int y, clear_fn clear)
|
||||||
// gfx_noclip();
|
// gfx_noclip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
img_t get_img(struct layout *layout, char *p)
|
img_t get_img(struct layout *layout, char *p)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
@ -2251,6 +2267,19 @@ out:
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *get_word_token(char *p)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char *r;
|
||||||
|
len = word_token(p, NULL);
|
||||||
|
if (!len)
|
||||||
|
return p;
|
||||||
|
p[len - 1 + 3] = 0;
|
||||||
|
r = strdup((p + 3));
|
||||||
|
free(p);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
char *process_token(char *ptr, struct layout *layout, struct line *line, struct xref **xref, int *sp)
|
char *process_token(char *ptr, struct layout *layout, struct line *line, struct xref **xref, int *sp)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2337,7 +2366,7 @@ int get_unbrakable_len(struct layout *layout, const char *ptr)
|
||||||
if (!p)
|
if (!p)
|
||||||
return w;
|
return w;
|
||||||
|
|
||||||
if (sp || !*p || word_img(p, NULL)) {
|
if (sp || !*p || word_img(p, NULL) || word_token(p, NULL)) {
|
||||||
free(p);
|
free(p);
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
@ -2435,6 +2464,7 @@ void _txt_layout_add(layout_t lay, char *txt)
|
||||||
w = gfx_img_w(img);
|
w = gfx_img_w(img);
|
||||||
h = gfx_img_h(img);
|
h = gfx_img_h(img);
|
||||||
} else {
|
} else {
|
||||||
|
p = get_word_token(p);
|
||||||
TTF_SizeUTF8((TTF_Font *)(layout->fn), p, &w, &h);
|
TTF_SizeUTF8((TTF_Font *)(layout->fn), p, &w, &h);
|
||||||
if (!*p && line->h)
|
if (!*p && line->h)
|
||||||
h = 0;
|
h = 0;
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
game.hinting = true;
|
game.hinting = true;
|
||||||
game.showlast = true;
|
game.showlast = true;
|
||||||
|
|
||||||
iface.img = function(self, str)
|
|
||||||
return "<g:"..str..">";
|
|
||||||
end;
|
|
||||||
|
|
||||||
iface.xref = function(self, str, obj)
|
iface.xref = function(self, str, obj)
|
||||||
local o = ref(obj);
|
local o = ref(obj);
|
||||||
local cmd=''
|
local cmd=''
|
||||||
|
@ -28,6 +24,16 @@ iface.title = function(self, str)
|
||||||
return nil
|
return nil
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
iface.img = function(self, str)
|
||||||
|
if str == nil then return nil; end;
|
||||||
|
return "<g:"..str..">";
|
||||||
|
end;
|
||||||
|
|
||||||
|
iface.nb = function(self, str)
|
||||||
|
if str == nil then return nil; end;
|
||||||
|
return "<w:"..str..">";
|
||||||
|
end;
|
||||||
|
|
||||||
iface.under = function(self, str)
|
iface.under = function(self, str)
|
||||||
if str == nil then return nil; end;
|
if str == nil then return nil; end;
|
||||||
return cat('<u>',str,'</u>');
|
return cat('<u>',str,'</u>');
|
||||||
|
|
|
@ -131,6 +131,11 @@ function cat(v,...)
|
||||||
return res;
|
return res;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function txtnb(v)
|
||||||
|
if type(v) ~= 'string' then return nil; end
|
||||||
|
return iface:nb(v);
|
||||||
|
end
|
||||||
|
|
||||||
function img(v)
|
function img(v)
|
||||||
if type(v) ~= 'string' then return nil; end;
|
if type(v) ~= 'string' then return nil; end;
|
||||||
return iface:img(v);
|
return iface:img(v);
|
||||||
|
@ -1529,6 +1534,9 @@ iface = {
|
||||||
img = function(self, str)
|
img = function(self, str)
|
||||||
return '';
|
return '';
|
||||||
end,
|
end,
|
||||||
|
nb = function(self, str)
|
||||||
|
return str;
|
||||||
|
end,
|
||||||
em = function(self, str)
|
em = function(self, str)
|
||||||
return str;
|
return str;
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in a new issue