mirror of https://github.com/adamdruppe/arsd.git
ketmar patch
This commit is contained in:
parent
2846def4db
commit
272467c421
14
dom.d
14
dom.d
|
@ -69,6 +69,18 @@ bool isConvenientAttribute(string name) {
|
||||||
|
|
||||||
/// The main document interface, including a html parser.
|
/// The main document interface, including a html parser.
|
||||||
class Document : FileResource {
|
class Document : FileResource {
|
||||||
|
/// Convenience method for web scraping. Requires [arsd.http2] to be
|
||||||
|
/// included in the build.
|
||||||
|
static Document fromUrl()(string url) {
|
||||||
|
import arsd.http2;
|
||||||
|
auto client = new HttpClient();
|
||||||
|
|
||||||
|
auto req = client.navigateTo(Uri(url), HttpVerb.GET);
|
||||||
|
auto res = req.waitForCompletion();
|
||||||
|
|
||||||
|
return new Document(cast(string) res.content);
|
||||||
|
}
|
||||||
|
|
||||||
///.
|
///.
|
||||||
this(string data, bool caseSensitive = false, bool strict = false) {
|
this(string data, bool caseSensitive = false, bool strict = false) {
|
||||||
parseUtf8(data, caseSensitive, strict);
|
parseUtf8(data, caseSensitive, strict);
|
||||||
|
@ -2924,7 +2936,7 @@ class Element {
|
||||||
/**
|
/**
|
||||||
Same result as innerText; the tag with all inner tags stripped out
|
Same result as innerText; the tag with all inner tags stripped out
|
||||||
*/
|
*/
|
||||||
string outerText() const {
|
@property string outerText() const {
|
||||||
return innerText;
|
return innerText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -886,6 +886,15 @@ class SimpleWindow : CapableOfHandlingNativeEvent {
|
||||||
if (!_closed) impl.showCursor();
|
if (!_closed) impl.showCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Move window.
|
||||||
|
void move (int x, int y) { if (!_closed) impl.move(x, y); }
|
||||||
|
|
||||||
|
/// Resize window.
|
||||||
|
void resize (int w, int h) { if (!_closed) impl.resize(w, h); }
|
||||||
|
|
||||||
|
// Move and resize window (this can be faster and more visually pleasant than doing it separately).
|
||||||
|
void moveResize (int x, int y, int w, int h) { if (!_closed) impl.moveResize(x, y, w, h); }
|
||||||
|
|
||||||
private bool _hidden;
|
private bool _hidden;
|
||||||
|
|
||||||
/// Returns true if the window is hidden.
|
/// Returns true if the window is hidden.
|
||||||
|
@ -3632,6 +3641,33 @@ version(Windows) {
|
||||||
SetWindowTextA(hwnd, toStringz(title));
|
SetWindowTextA(hwnd, toStringz(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void move (int x, int y) {
|
||||||
|
// TODO
|
||||||
|
//MoveWindow(hwnd, x, y, oops...);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resize (int w, int h) {
|
||||||
|
// TODO
|
||||||
|
/*
|
||||||
|
if (w < 1) w = 1;
|
||||||
|
if (h < 1) h = 1;
|
||||||
|
XResizeWindow(display, window, w, h);
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
if (windowResized !is null) windowResized(w, h);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void moveResize (int x, int y, int w, int h) {
|
||||||
|
// TODO
|
||||||
|
/*
|
||||||
|
if (w < 1) w = 1;
|
||||||
|
if (h < 1) h = 1;
|
||||||
|
XMoveResizeWindow(display, window, x, y, w, h);
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
if (windowResized !is null) windowResized(w, h);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
version(without_opengl) {} else {
|
version(without_opengl) {} else {
|
||||||
HGLRC ghRC;
|
HGLRC ghRC;
|
||||||
HDC ghDC;
|
HDC ghDC;
|
||||||
|
@ -4773,6 +4809,26 @@ version(X11) {
|
||||||
return ScreenPainter(this, window);
|
return ScreenPainter(this, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void move (int x, int y) {
|
||||||
|
XMoveWindow(display, window, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resize (int w, int h) {
|
||||||
|
if (w < 1) w = 1;
|
||||||
|
if (h < 1) h = 1;
|
||||||
|
XResizeWindow(display, window, w, h);
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
if (windowResized !is null) windowResized(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
|
void moveResize (int x, int y, int w, int h) {
|
||||||
|
if (w < 1) w = 1;
|
||||||
|
if (h < 1) h = 1;
|
||||||
|
XMoveResizeWindow(display, window, x, y, w, h);
|
||||||
|
glViewport(0, 0, w, h);
|
||||||
|
if (windowResized !is null) windowResized(w, h);
|
||||||
|
}
|
||||||
|
|
||||||
void hideCursor () {
|
void hideCursor () {
|
||||||
if (curHidden++ == 0) {
|
if (curHidden++ == 0) {
|
||||||
if (!blankCurPtr) {
|
if (!blankCurPtr) {
|
||||||
|
@ -4791,13 +4847,21 @@ version(X11) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTitle(string title) {
|
void setTitle(string title) {
|
||||||
|
if (title.ptr is null) title = "";
|
||||||
|
auto XA_UTF8 = XInternAtom(display, "UTF8_STRING".ptr, false);
|
||||||
|
auto XA_NETWM_NAME = XInternAtom(display, "_NET_WM_NAME".ptr, false);
|
||||||
XTextProperty windowName;
|
XTextProperty windowName;
|
||||||
windowName.value = title.ptr;
|
windowName.value = title.ptr;
|
||||||
windowName.encoding = XA_STRING;
|
windowName.encoding = XA_UTF8; //XA_STRING;
|
||||||
windowName.format = 8;
|
windowName.format = 8;
|
||||||
windowName.nitems = cast(uint) title.length;
|
windowName.nitems = cast(uint)title.length;
|
||||||
|
|
||||||
XSetWMName(display, window, &windowName);
|
XSetWMName(display, window, &windowName);
|
||||||
|
char[1024] namebuf = 0;
|
||||||
|
auto maxlen = namebuf.length-1;
|
||||||
|
if (maxlen > title.length) maxlen = title.length;
|
||||||
|
namebuf[0..maxlen] = title[0..maxlen];
|
||||||
|
XStoreName(display, window, namebuf.ptr);
|
||||||
|
XChangeProperty(display, window, XA_NETWM_NAME, XA_UTF8, 8, PropModeReplace, title.ptr, cast(uint)title.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createWindow(int width, int height, string title, in OpenGlOptions opengl, SimpleWindow parent) {
|
void createWindow(int width, int height, string title, in OpenGlOptions opengl, SimpleWindow parent) {
|
||||||
|
@ -6134,6 +6198,7 @@ int XReparentWindow(Display*, Window, Window, int, int);
|
||||||
int XClearWindow(Display*, Window);
|
int XClearWindow(Display*, Window);
|
||||||
int XMoveResizeWindow(Display*, Window, int, int, uint, uint);
|
int XMoveResizeWindow(Display*, Window, int, int, uint, uint);
|
||||||
int XMoveWindow(Display*, Window, int, int);
|
int XMoveWindow(Display*, Window, int, int);
|
||||||
|
int XResizeWindow(Display *display, Window w, uint width, uint height);
|
||||||
|
|
||||||
Colormap XCreateColormap(Display *display, Window w, Visual *visual, int alloc);
|
Colormap XCreateColormap(Display *display, Window w, Visual *visual, int alloc);
|
||||||
|
|
||||||
|
@ -6915,6 +6980,7 @@ alias void* GLXContext;
|
||||||
void glXWaitX();
|
void glXWaitX();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum AllocNone = 0;
|
enum AllocNone = 0;
|
||||||
struct XVisualInfo {
|
struct XVisualInfo {
|
||||||
Visual *visual;
|
Visual *visual;
|
||||||
|
@ -7171,6 +7237,7 @@ struct Visual
|
||||||
}
|
}
|
||||||
|
|
||||||
void XSetWMName(Display*, Window, XTextProperty*);
|
void XSetWMName(Display*, Window, XTextProperty*);
|
||||||
|
int XStoreName(Display* display, Window w, const(char)* window_name);
|
||||||
|
|
||||||
enum ClipByChildren = 0;
|
enum ClipByChildren = 0;
|
||||||
enum IncludeInferiors = 1;
|
enum IncludeInferiors = 1;
|
||||||
|
|
Loading…
Reference in New Issue