diff --git a/cgi.d b/cgi.d index 6496fd8..c265791 100644 --- a/cgi.d +++ b/cgi.d @@ -26,6 +26,9 @@ * have data presentation magic * do the skeleton stuff like 1.0 * auto-cache generated stuff in files (at least if pure?) + + + https://linux.die.net/man/3/posix_spawn */ /++ diff --git a/dom.d b/dom.d index 96be8d7..988b089 100644 --- a/dom.d +++ b/dom.d @@ -2028,7 +2028,36 @@ class Element { @property Element lastChild() { return children.length ? children[$ - 1] : null; } + + /// UNTESTED + /// the next element you would encounter if you were reading it in the source + Element nextInSource() { + auto n = firstChild; + if(n is null) + n = nextSibling(); + if(n is null) { + auto p = this.parentNode; + while(p !is null && n is null) { + n = p.nextSibling; + } + } + return n; + } + + /// UNTESTED + /// ditto + Element previousInSource() { + auto p = previousSibling; + if(p is null) { + auto par = parentNode; + if(par) + p = par.lastChild; + if(p is null) + p = par; + } + return p; + } ///. @property Element previousSibling(string tagName = null) { @@ -4895,6 +4924,12 @@ class Table : Element { foreach(ele; e) a.appendChild(ele); row.appendChild(a); + } else static if(is(typeof(e) == string[])) { + foreach(ele; e) { + Element a = Element.make(innerType); + a.innerText = to!string(ele); + row.appendChild(a); + } } else { Element a = Element.make(innerType); a.innerText = to!string(e); diff --git a/jsvar.d b/jsvar.d index bff2691..ad13b21 100644 --- a/jsvar.d +++ b/jsvar.d @@ -1162,8 +1162,13 @@ struct var { } public ref var opIndexAssign(T)(T t, string name, string file = __FILE__, size_t line = __LINE__) { - if(name.length && name[0] >= '0' && name[0] <= '9') - return opIndexAssign(t, to!size_t(name), file, line); + if(name.appearsNumeric()) { + try { + auto i = to!size_t(name); + return opIndexAssign(t, i, file, line); + } catch(Exception) + {} // ignore bad index, use it as a string instead lol + } _requireType(Type.Object); // FIXME? if(_payload._object is null) throw new DynamicTypeException(var(null), Type.Object, file, line); @@ -1793,6 +1798,16 @@ bool isScriptableOpaque(T)() { return false; } +bool appearsNumeric(string n) { + if(n.length == 0) + return false; + foreach(c; n) { + if(c < '0' || c > '9') + return false; + } + return true; +} + /// Wraps a struct by reference. The pointer is stored - be sure the struct doesn't get freed or go out of scope! /// diff --git a/minigui.d b/minigui.d index 876ec20..8ceaa71 100644 --- a/minigui.d +++ b/minigui.d @@ -1,5 +1,7 @@ // http://msdn.microsoft.com/en-us/library/windows/desktop/bb775498%28v=vs.85%29.aspx +// need a viewer widget that works like a web page - arrows scroll down consistently + // FIXME: the menus should be a bit more discoverable, at least a single click to open the others instead of two. // and help info about menu items. // and search in menus? diff --git a/ttf.d b/ttf.d index e983f22..2484841 100644 --- a/ttf.d +++ b/ttf.d @@ -31,7 +31,7 @@ struct TtfFont { throw new Exception("load font problem"); } - /// + /// Note that you must stbtt_FreeBitmap(returnValue.ptr, null); this thing or it will leak!!!! ubyte[] renderCharacter(dchar c, int size, out int width, out int height, float shift_x = 0.0, float shift_y = 0.0) { auto ptr = stbtt_GetCodepointBitmapSubpixel(&font, 0.0,stbtt_ScaleForPixelHeight(&font, size), shift_x, shift_y, c, &width, &height, null,null); diff --git a/web.d b/web.d index 4574172..7eba3ee 100644 --- a/web.d +++ b/web.d @@ -211,6 +211,13 @@ struct Text { alias content this; } +/// +struct URL { + string url; /// + string title; /// + alias url this; +} + /// This is the JSON envelope format struct Envelope { bool success; /// did the call succeed? false if it threw an exception @@ -3977,7 +3984,16 @@ Table structToTable(T)(Document document, T arr, string[] fieldsToSkip = null) i foreach(s; arr) { auto tr = tbody.addChild("tr"); foreach(member; s.tupleof) { - tr.addChild("td", to!string(member)); + static if(is(typeof(member) == URL[])) { + auto td = tr.addChild("td"); + foreach(i, link; member) { + td.addChild("a", link.title.length ? link.title : to!string(i), link.url); + td.appendText(" "); + } + + } else { + tr.addChild("td", to!string(member)); + } } if(odd)