[qwaq] Clean up QwaqApplication

It doesn't need to be fun little tests any more.
This commit is contained in:
Bill Currie 2020-03-25 01:06:20 +09:00
parent 1e56a8efbc
commit e69c430abc
3 changed files with 37 additions and 34 deletions

View file

@ -20,9 +20,11 @@
Extent screenSize;
int autocount;
}
-(Extent)size;
-(TextContext *)screen;
-run;
-draw;
-handleEvent: (qwaq_event_t *) event;
@end
@extern QwaqApplication *application;
#endif//__qwaq_app_h

View file

@ -5,13 +5,8 @@ int fence;
#include "color.h"
#include "qwaq-app.h"
#include "qwaq-button.h"
#include "qwaq-curses.h"
#include "qwaq-editor.h"
#include "qwaq-group.h"
#include "qwaq-listener.h"
#include "qwaq-window.h"
#include "qwaq-screen.h"
#include "qwaq-view.h"
static AutoreleasePool *autorelease_pool;
@ -52,33 +47,19 @@ arp_end (void)
[screen bkgd: COLOR_PAIR (1)];
[screen scrollok: 1];
Rect r = {nil, screenSize};
r.offset.x = r.extent.width / 4;
r.offset.y = r.extent.height / 4;
r.extent.width /= 2;
r.extent.height /= 2;
Window *w;
[objects insertSelected: w = [[Window windowWithRect: r] setBackground: COLOR_PAIR (2)]];
r = {{1, 1}, {r.extent.width - 2, r.extent.height - 2}};
[w insertSelected: [[Editor alloc] initWithRect: r file: "Makefile"]];
[screen clear];
wrefresh (stdscr);//FIXME
return self;
}
-run
-(Extent)size
{
[objects takeFocus];
[self draw];
do {
arp_start ();
get_event (&event);
if (event.what != qe_none) {
[self handleEvent: &event];
return screenSize;
}
arp_end ();
} while (!endState);
return self;
-(TextContext *)screen
{
return screen;
}
-draw
@ -116,17 +97,36 @@ arp_end (void)
[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;
}
@end
QwaqApplication *application;
int main (int argc, string *argv)
{
fence = 0;
//while (!fence) {}
id app = [[QwaqApplication app] retain];
application = [[QwaqApplication app] retain];
[app run];
[app release];
[application run];
[application release];
qwaq_event_t event;
get_event (&event); // XXX need a "wait for queue idle"
return 0;

View file

@ -1731,8 +1731,9 @@ bi_i_TextContext__bkgd_ (progs_t *pr)
static void
bi_i_TextContext__clear (progs_t *pr)
{
int window_id = P_STRUCT (pr, qwaq_textcontext_t, 0).window;
int ch = P_INT (pr, 2);
__auto_type self = &P_STRUCT (pr, qwaq_textcontext_t, 0);
int window_id = self->window;
int ch = self->background;
qwaq_werase (pr, window_id, ch);
}