2020-03-04 13:09:40 +00:00
|
|
|
int fence;
|
2020-02-29 15:40:55 +00:00
|
|
|
#include <AutoreleasePool.h>
|
|
|
|
|
2020-02-29 05:48:18 +00:00
|
|
|
#include "color.h"
|
2020-02-29 15:40:55 +00:00
|
|
|
#include "qwaq-app.h"
|
|
|
|
#include "qwaq-curses.h"
|
|
|
|
#include "qwaq-window.h"
|
2020-03-01 09:25:02 +00:00
|
|
|
#include "qwaq-screen.h"
|
|
|
|
#include "qwaq-view.h"
|
2020-02-29 15:40:55 +00:00
|
|
|
|
|
|
|
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 ();
|
|
|
|
init_pair (1, COLOR_WHITE, COLOR_BLUE);
|
|
|
|
init_pair (2, COLOR_WHITE, COLOR_BLACK);
|
2020-03-01 09:25:02 +00:00
|
|
|
screen = [[Screen screen] retain];
|
|
|
|
[screen setBackground: COLOR_PAIR (1)];
|
2020-03-03 12:30:47 +00:00
|
|
|
Rect r = *[screen getRect];
|
2020-03-05 06:44:53 +00:00
|
|
|
[screen printf:"%d %d %d %d\n",
|
|
|
|
r.offset.x, r.offset.y, r.extent.width, r.extent.height];
|
|
|
|
r.offset.x = r.extent.width / 4;
|
|
|
|
r.offset.y = r.extent.height / 4;
|
|
|
|
r.extent.width /= 2;
|
|
|
|
r.extent.height /= 2;
|
|
|
|
[screen printf:"%d %d %d %d\n",
|
|
|
|
r.offset.x, r.offset.y, r.extent.width, r.extent.height];
|
2020-03-03 12:30:47 +00:00
|
|
|
[screen printf:"%d\n", acs_char(ACS_HLINE)];
|
|
|
|
[screen addch: acs_char(ACS_HLINE) atX:4 Y:4];
|
2020-02-29 15:40:55 +00:00
|
|
|
Window *w;
|
2020-03-04 13:09:40 +00:00
|
|
|
//[screen add: w=[[Window windowWithRect: r] setBackground: COLOR_PAIR (2)]];
|
2020-03-05 06:44:53 +00:00
|
|
|
//wprintf (w.window, "%d %d %d %d\n", r.offset.x, r.offset.y, r.extent.width, r.ylen);
|
2020-03-04 13:09:40 +00:00
|
|
|
[screen redraw];
|
2020-02-29 15:40:55 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-run
|
|
|
|
{
|
2020-03-02 09:29:31 +00:00
|
|
|
[screen draw];
|
2020-02-29 15:40:55 +00:00
|
|
|
do {
|
|
|
|
arp_start ();
|
|
|
|
|
|
|
|
get_event (&event);
|
2020-03-04 13:09:40 +00:00
|
|
|
if (event.what != qe_none) {
|
2020-02-29 15:40:55 +00:00
|
|
|
[self handleEvent: &event];
|
|
|
|
}
|
2020-02-27 12:01:09 +00:00
|
|
|
|
2020-02-29 15:40:55 +00:00
|
|
|
arp_end ();
|
|
|
|
} while (!endState);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-handleEvent: (qwaq_event_t *) event
|
|
|
|
{
|
2020-03-01 09:25:02 +00:00
|
|
|
[screen handleEvent: event];
|
2020-03-04 13:09:40 +00:00
|
|
|
if (event.what == qe_key && event.key == '\x18') {
|
|
|
|
event.what = qe_command;
|
2020-03-04 10:10:09 +00:00
|
|
|
event.message.command = qc_exit;
|
2020-02-29 15:40:55 +00:00
|
|
|
}
|
2020-03-04 13:09:40 +00:00
|
|
|
if (event.what == qe_command
|
2020-03-04 10:10:09 +00:00
|
|
|
&& (event.message.command == qc_exit
|
|
|
|
|| event.message.command == qc_error)) {
|
|
|
|
endState = event.message.command;
|
2020-02-29 15:40:55 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
int main (int argc, string *argv)
|
|
|
|
{
|
2020-03-04 13:09:40 +00:00
|
|
|
fence = 0;
|
|
|
|
//while (!fence) {}
|
|
|
|
|
2020-02-29 15:40:55 +00:00
|
|
|
id app = [[QwaqApplication app] retain];
|
|
|
|
|
|
|
|
[app run];
|
|
|
|
[app release];
|
|
|
|
qwaq_event_t event;
|
|
|
|
get_event (&event); // XXX need a "wait for queue idle"
|
|
|
|
return 0;
|
|
|
|
}
|
2020-02-26 16:18:38 +00:00
|
|
|
|
2020-02-29 05:38:54 +00:00
|
|
|
window_t stdscr = (window_t) 1;
|
|
|
|
|
2020-02-26 16:18:38 +00:00
|
|
|
void initialize (void) = #0;
|
|
|
|
window_t create_window (int xpos, int ypos, int xlen, int ylen) = #0;
|
|
|
|
void destroy_window (window_t win) = #0;
|
2020-02-27 12:22:10 +00:00
|
|
|
void mvwprintf (window_t win, int x, int y, string fmt, ...) = #0;
|
2020-02-29 15:40:55 +00:00
|
|
|
void wprintf (window_t win, string fmt, ...) = #0;
|
2020-03-03 12:30:47 +00:00
|
|
|
void wvprintf (window_t win, string fmt, @va_list args) = #0;
|
2020-02-29 05:43:08 +00:00
|
|
|
void wrefresh (window_t win) = #0;
|
2020-03-02 09:24:45 +00:00
|
|
|
void mvwaddch (window_t win, int x, int y, int ch) = #0;
|
2020-02-27 12:01:09 +00:00
|
|
|
int get_event (qwaq_event_t *event) = #0;
|
2020-02-29 05:48:18 +00:00
|
|
|
int max_colors (void) = #0;
|
|
|
|
int max_color_pairs (void) = #0;
|
|
|
|
int init_pair (int pair, int f, int b) = #0;
|
|
|
|
void wbkgd (window_t win, int ch) = #0;
|
2020-03-03 12:30:47 +00:00
|
|
|
void scrollok (window_t win, int flag) = #0;
|
2020-03-02 09:24:45 +00:00
|
|
|
int acs_char (int acs) = #0;
|
2020-02-27 12:01:09 +00:00
|
|
|
|
2020-02-29 15:40:55 +00:00
|
|
|
panel_t create_panel (window_t window) = #0;
|
|
|
|
void destroy_panel (panel_t panel) = #0;
|
|
|
|
void hide_panel (panel_t panel) = #0;
|
|
|
|
void show_panel (panel_t panel) = #0;
|
|
|
|
void top_panel (panel_t panel) = #0;
|
|
|
|
void bottom_panel (panel_t panel) = #0;
|
|
|
|
void move_panel (panel_t panel, int x, int y) = #0;
|
|
|
|
window_t panel_window (panel_t panel) = #0;
|
|
|
|
void update_panels (void) = #0;
|
|
|
|
void doupdate (void) = #0;
|
2020-03-05 06:44:53 +00:00
|
|
|
int curs_set (int visibility) = #0;
|
|
|
|
int move (int x, int y) = #0;
|