diff --git a/simpledisplay.d b/simpledisplay.d index 229bfee..1e9086b 100644 --- a/simpledisplay.d +++ b/simpledisplay.d @@ -148,7 +148,7 @@ void displayImage(Image image, SimpleWindow win = null) { auto p = win.draw; p.drawImage(Point(0, 0), image); } - return win.eventLoop(0, + win.eventLoop(0, (int) { win.close(); } ); @@ -700,8 +700,8 @@ version(Windows) { case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: mouse.type = 0; - mouse.x = GET_X_LPARAM(lParam); - mouse.y = GET_Y_LPARAM(lParam); + mouse.x = LOWORD(lParam); + mouse.y = HIWORD(lParam); mouse.buttonFlags = wParam; if(handleMouseEvent) @@ -883,7 +883,7 @@ version(X11) { foregroundIsNotTransparent = true; - XSetForeground(display, gc, + XSetForeground(display, gc, cast(uint) c.r << 16 | cast(uint) c.g << 8 | cast(uint) c.b); @@ -898,11 +898,11 @@ version(X11) { backgroundIsNotTransparent = true; - XSetBackground(display, gc, + XSetBackground(display, gc, cast(uint) c.r << 16 | cast(uint) c.g << 8 | cast(uint) c.b); - + } void swapColors() { @@ -968,7 +968,7 @@ version(X11) { points[i].x = cast(short) p.x; points[i].y = cast(short) p.y; } - + if(backgroundIsNotTransparent) { swapColors(); XFillPolygon(display, d, gc, points.ptr, cast(int) points.length, PolygonShape.Complex, CoordMode.CoordModeOrigin); @@ -1051,7 +1051,7 @@ version(X11) { void createWindow(int width, int height, string title) { display = XDisplayConnection.get(); auto screen = DefaultScreen(display); - + window = XCreateSimpleWindow( display, RootWindow(display, screen), @@ -1329,7 +1329,7 @@ enum NotifyModes:int NotifyWhileGrabbed =3 } const int NotifyHint =1; /* for MotionNotify events */ - + /* Notify detail */ enum NotifyDetail:int { @@ -1384,18 +1384,23 @@ enum ColorMapNotification:int struct _XPrivate {} struct _XrmHashBucketRec {} - typedef void* XPointer; - typedef void* XExtData; + + alias void* XPointer; + alias void* XExtData; + alias uint XID; - typedef XID Window; - typedef XID Drawable; - typedef XID Pixmap; + + alias XID Window; + alias XID Drawable; + alias XID Pixmap; + alias uint Atom; alias bool Bool; alias Display XDisplay; - typedef int ByteOrder; - typedef uint Time; - typedef void ScreenFormat; + + alias int ByteOrder; + alias uint Time; + alias void ScreenFormat; struct XImage { int width, height; /* size of image */ @@ -1454,8 +1459,8 @@ struct XKeyEvent uint keycode; /* detail */ Bool same_screen; /* same screen flag */ } -typedef XKeyEvent XKeyPressedEvent; -typedef XKeyEvent XKeyReleasedEvent; +alias XKeyEvent XKeyPressedEvent; +alias XKeyEvent XKeyReleasedEvent; struct XButtonEvent { @@ -1473,8 +1478,8 @@ struct XButtonEvent uint button; /* detail */ Bool same_screen; /* same screen flag */ } -typedef XButtonEvent XButtonPressedEvent; -typedef XButtonEvent XButtonReleasedEvent; +alias XButtonEvent XButtonPressedEvent; +alias XButtonEvent XButtonReleasedEvent; struct XMotionEvent{ int type; /* of event */ @@ -1491,7 +1496,7 @@ struct XMotionEvent{ byte is_hint; /* detail */ Bool same_screen; /* same screen flag */ } -typedef XMotionEvent XPointerMovedEvent; +alias XMotionEvent XPointerMovedEvent; struct XCrossingEvent{ int type; /* of event */ @@ -1507,15 +1512,15 @@ struct XCrossingEvent{ NotifyModes mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */ NotifyDetail detail; /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, + * NotifyAncestor, NotifyVirtual, NotifyInferior, * NotifyNonlinear,NotifyNonlinearVirtual */ Bool same_screen; /* same screen flag */ Bool focus; /* Boolean focus */ KeyOrButtonMask state; /* key or button mask */ } -typedef XCrossingEvent XEnterWindowEvent; -typedef XCrossingEvent XLeaveWindowEvent; +alias XCrossingEvent XEnterWindowEvent; +alias XCrossingEvent XLeaveWindowEvent; struct XFocusChangeEvent{ int type; /* FocusIn or FocusOut */ @@ -1527,13 +1532,13 @@ struct XFocusChangeEvent{ NotifyGrab, NotifyUngrab */ NotifyDetail detail; /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, + * NotifyAncestor, NotifyVirtual, NotifyInferior, * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, - * NotifyPointerRoot, NotifyDetailNone + * NotifyPointerRoot, NotifyDetailNone */ } -typedef XFocusChangeEvent XFocusInEvent; -typedef XFocusChangeEvent XFocusOutEvent; +alias XFocusChangeEvent XFocusInEvent; +alias XFocusChangeEvent XFocusOutEvent; Window XCreateSimpleWindow( Display* /* display */, Window /* parent */, @@ -1562,17 +1567,17 @@ XImage *XCreateImage( Atom XInternAtom( Display* /* display */, const char* /* atom_name */, - Bool /* only_if_exists */ + Bool /* only_if_exists */ ); -typedef int Status; +alias int Status; + - enum EventMask:int -{ +{ NoEventMask =0, KeyPressMask =1<<0, - KeyReleaseMask =1<<1, + KeyReleaseMask =1<<1, ButtonPressMask =1<<2, ButtonReleaseMask =1<<3, EnterWindowMask =1<<4, @@ -1608,7 +1613,7 @@ int XPutImage( int /* dest_x */, int /* dest_y */, uint /* width */, - uint /* height */ + uint /* height */ ); int XDestroyWindow( @@ -1688,7 +1693,7 @@ struct XKeymapEvent Display *display; /* Display the event was read from */ Window window; byte key_vector[32]; -} +} struct XExposeEvent { @@ -1747,7 +1752,7 @@ struct XCreateWindowEvent{ Bool override_redirect; /* creation should be overridden */ } -struct XDestroyWindowEvent +struct XDestroyWindowEvent { int type; uint serial; /* # of last request processed by server */ @@ -1978,7 +1983,7 @@ struct XErrorEvent ubyte minor_code; /* Minor op-code of failed request */ } -struct XAnyEvent +struct XAnyEvent { int type; ubyte serial; /* # of last request processed by server */ @@ -2079,10 +2084,10 @@ struct Depth Visual *visuals; /* list of visuals possible at this depth */ } -typedef void* GC; +alias void* GC; alias int VisualID; -typedef XID Colormap; -typedef XID KeySym; +alias XID Colormap; +alias XID KeySym; alias uint KeyCode; struct Screen{ @@ -2101,7 +2106,7 @@ struct Screen{ uint black_pixel; /* White and Black pixel values */ int max_maps, min_maps; /* max and min color maps */ int backing_store; /* Never, WhenMapped, Always */ - bool save_unders; + bool save_unders; int root_input_mask; /* initial root input mask */ } diff --git a/web.d b/web.d index 7813808..0e04b31 100644 --- a/web.d +++ b/web.d @@ -1532,7 +1532,7 @@ Form createAutomaticForm(Document document, string action, in Parameter[] parame } count++; - }; + } auto fmt = Element.make("select"); fmt.name = "format"; @@ -2175,7 +2175,6 @@ string formatAs(T, R)(T ret, string format, R api = null, JSONValue* returnValue else goto badType; +/ goto badType; // FIXME - break; case "json": assert(returnValue !is null); *returnValue = toJsonValue!(typeof(ret), R)(ret, formatJsonToStringAs, api); @@ -2731,13 +2730,12 @@ immutable(string[]) weekdayNames = [ // this might be temporary struct TemplateFilters { string date(string replacement, string[], in Element, string) { - auto date = to!long(replacement); - - import std.date; - - auto day = dateFromTime(date); - auto year = yearFromTime(date); - auto month = monthNames[monthFromTime(date)]; + auto dateTicks = to!time_t(replacement); + auto date = SysTime( unixTimeToStdTime(dateTicks/1_000) ); + + auto day = date.day; + auto year = date.year; + auto month = monthNames[date.month]; replacement = format("%s %d, %d", month, day, year); return replacement;