quakeforge/ruamoko/qwaq/qwaq-app.r
Bill Currie 6d5ffa9f8e [build] Move to non-recursive make
There's still some cleanup to do, but everything seems to be working
nicely: `make -j` works, `make distcheck` passes. There is probably
plenty of bitrot in the package directories (RPM, debian), though.

The vc project files have been removed since those versions are way out
of date and quakeforge is pretty much dependent on gcc now anyway.

Most of the old Makefile.am files  are now Makemodule.am.  This should
allow for new Makefile.am files that allow local building (to be added
on an as-needed bases).  The current remaining Makefile.am files are for
standalone sub-projects.a

The installable bins are currently built in the top-level build
directory. This may change if the clutter gets to be too much.

While this does make a noticeable difference in build times, the main
reason for the switch was to take care of the growing dependency issues:
now it's possible to build tools for code generation (eg, using qfcc and
ruamoko programs for code-gen).
2020-06-25 11:35:37 +09:00

166 lines
2.9 KiB
R

int fence;
#include <AutoreleasePool.h>
#include <key.h>
#include "ruamoko/qwaq/ui/color.h"
#include "ruamoko/qwaq/ui/curses.h"
#include "ruamoko/qwaq/ui/group.h"
#include "ruamoko/qwaq/ui/view.h"
#include "ruamoko/qwaq/debugger/debugger.h"
#include "ruamoko/qwaq/qwaq-app.h"
int color_palette[64];
static AutoreleasePool *autorelease_pool;
static void
arp_start (void)
{
autorelease_pool = [[AutoreleasePool alloc] init];
}
static void
arp_end (void)
{
[autorelease_pool release];
autorelease_pool = nil;
}
@implementation QwaqApplication
+app
{
return [[[self alloc] init] autorelease];
}
-init
{
if (!(self = [super init])) {
return nil;
}
initialize ();
for (int i = 1; i < 64; i++) {
init_pair (i, i & 0x7, i >> 3);
color_palette[i] = COLOR_PAIR (i);
}
screen = [TextContext screen];
screenSize = [screen size];
objects = [[Group withContext: screen owner: nil] retain];
[screen bkgd: color_palette[047]];
[screen scrollok: 1];
[screen clear];
wrefresh (stdscr);//FIXME
debuggers = [[Array array] retain];
return self;
}
-(Extent)size
{
return screenSize;
}
-(TextContext *)screen
{
return screen;
}
-draw
{
[objects draw];
[TextContext refresh];
return self;
}
-(Debugger *)find_debugger:(qdb_target_t) target
{
Debugger *debugger;
for (int i = [debuggers count]; i-- > 0; ) {
debugger = [debuggers objectAtIndex: i];
if ([debugger target].handle == target.handle) {
return debugger;
}
}
debugger = [Debugger withTarget: target];
[debuggers addObject: debugger];
return debugger;
}
-handleEvent: (qwaq_event_t *) event
{
switch (event.what) {
case qe_resize:
Extent delta;
delta.width = event.resize.width - screenSize.width;
delta.height = event.resize.height - screenSize.height;
resizeterm (event.resize.width, event.resize.height);
[screen resizeTo: {event.resize.width, event.resize.height}];
screenSize = [screen size];
[objects resize: delta];
[screen refresh];
event.what = qe_none;
break;
case qe_key:
if (event.key.code == '\x18' || event.key.code == '\x11') {
endState = event.message.int_val;
event.what = qe_none;
}
break;
case qe_debug_event:
[[self find_debugger:{event.message.int_val}] handleDebugEvent];
event.what = qe_none;
break;
}
if (event.what != qe_none) {
[objects handleEvent: event];
}
return self;
}
-run
{
[objects takeFocus];
[self draw];
do {
arp_start ();
get_event (&event);
if (event.what != qe_none) {
[self handleEvent: &event];
}
arp_end ();
} while (!endState);
return self;
}
-addView:(View *)view
{
[objects insertSelected: view];
[screen refresh];
return self;
}
@end
QwaqApplication *application;
int main (int argc, string *argv)
{
fence = 0;
//while (!fence) {}
arp_start ();
application = [[QwaqApplication app] retain];
arp_end ();
[application run];
[application release];
qwaq_event_t event;
get_event (&event); // XXX need a "wait for queue idle"
return 0;
}