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