Merge branch 'master' of github.com:adamdruppe/misc-stuff-including-D-programming-language-web-stuff

This commit is contained in:
Adam D. Ruppe 2012-06-30 22:52:31 -04:00
commit ca50fc2016
2 changed files with 54 additions and 51 deletions

View File

@ -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)
@ -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 */
@ -1514,8 +1519,8 @@ struct XCrossingEvent{
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 */
@ -1532,8 +1537,8 @@ struct XFocusChangeEvent{
* 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 */,
@ -1565,7 +1570,7 @@ Atom XInternAtom(
Bool /* only_if_exists */ Bool /* only_if_exists */
); );
typedef int Status; alias int Status;
enum EventMask:int enum EventMask:int
@ -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{

14
web.d
View File

@ -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 year = date.year;
auto day = dateFromTime(date); auto month = monthNames[date.month];
auto year = yearFromTime(date);
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;