Commit graph

509 commits

Author SHA1 Message Date
Bill Currie
75f38f456b [qwaq] Fix a linker warning that had been hiding 2020-03-22 13:49:42 +09:00
Bill Currie
fc44582726 [qwaq] Parse function keys
While the key escape sequences are xterm-specific, they are only the
default and preliminary provision has been made for overriding them.
However, no override mechanism has been implemented beyond using dynamic
table lookup.
2020-03-22 13:47:44 +09:00
Bill Currie
275ed22362 [qwaq] Actually ensure tv_nsec is valid
While typing the previous message I thought to check my "carry" logic.
Sure enough, it was wrong... out by 1. I guess I won the threading
lottery :P
2020-03-22 08:40:51 +09:00
Bill Currie
486728a4bd [qwaq] Be a little paranoid about cond wait timeouts
I'd left qwaq-curses running overnight and found it locked up: both
threads were looping because pthread_cond_timedwait was returning
EINVAL. Thus bail if anything other than 0 is returned, and try to
ensure tv_nsec is in the range 0..999999999
2020-03-22 08:35:37 +09:00
Bill Currie
243840daa7 [qwaq] Support sgr mouse reports
Now buttons 12+ work (in theory, I have only 12 so can't test higher),
and button release is no longer ambiguous.
2020-03-22 02:46:15 +09:00
Bill Currie
d352749666 [qwaq] Bypass ncurses for input handling
For now, only 1003 mouse mode is supported, and function keys are not
yet supported, but the mouse is much more reliable: no lost events.
2020-03-22 01:00:05 +09:00
Bill Currie
88b4046632 [util] Pass a data pointer to shutdown functions
And clean up the mess.
2020-03-22 00:57:54 +09:00
Bill Currie
176cc7b9c1 [qwaq] Make some improvements to mouse handling
This doesn't fix the problem of lost events: that seems to be inside
ncurses. I've done some investigations, and it seems xterm sends
separate events for motion and pre/release (which have current coords),
in both 1003 and 1006 modes. No idea what ncurses is doing (does it even
handle 1003 properly?), and it requires the use of xterm-1006 for it to
use 1006 mode (which is nice in that it disambiguates button releases
and allows for huge terminals (not that I would use such normally)).
Guess I've got some side-work cut out for me :P
2020-03-21 21:05:34 +09:00
Bill Currie
fb6883851d [qwaq] Actually unlock the event queue mutex
And now everything works as well threaded as it did unthreaded.
2020-03-21 12:58:07 +09:00
Bill Currie
fb17f8093d [qwaq] Correct some queue test logic
This fixes the wedge during initial setup and drawing, but the program
deadlocks when processing input and there's an event.
2020-03-21 12:58:07 +09:00
Bill Currie
abedb465af [qwaq] Use separate conditions for queue read/write
While writing the code I suspected this would be necessary, but it's
nice to know. Now the window seems to be correctly fetched, but
get_event locks up.
2020-03-21 12:58:07 +09:00
Bill Currie
af137937bd [qwaq] Add missing mutex unlock 2020-03-21 12:58:07 +09:00
Bill Currie
5f887c4773 [qwaq] Fix missed logic conversion 2020-03-21 12:58:07 +09:00
Bill Currie
7beaa567e6 [qwaq] Pass resource data into the thread
Things have come crashing down, but no fire (ie, no deadlocks so far).
2020-03-21 12:58:07 +09:00
Bill Currie
ac3fef6dd8 [qwaq] Fix a harmless typo
Amusing, though... it was cursed (segaulted).
2020-03-21 12:58:07 +09:00
Bill Currie
cf9455293b [qwaq] Start threads for progs and curses
No idea if anything works, probably come crashing down in a flaming pile
of debris.
2020-03-21 12:58:07 +09:00
Bill Currie
6c1a026bf1 [qwaq] Change thread data array to pointers
I realized that with dynamic thread creation the arrays resizing could
cause them to move around in memory which would be bad for anything
holding a pointer to the data, and even using indices wouldn't help that
much as the array would need to be mutex protected.
2020-03-21 12:58:07 +09:00
Bill Currie
f14f2f518a [qwaq] Rename thread_args to thread_data 2020-03-21 12:58:07 +09:00
Bill Currie
93886d6cd7 [qwaq] Use main args non-options as progs files
If none are specified, default to qwaq-app.dat (for now, anyway). For
each progs file, an optional args set can be specified in the same order
(separated by --). Missing sets default to empty, excess sets are
ignored.
2020-03-21 12:58:07 +09:00
Bill Currie
0cc28c8641 [qwaq] Run main thread
And only thread, still, so things lock up still, but they're coming
together.
2020-03-21 12:58:07 +09:00
Bill Currie
a5f57a8a4c [qwaq] Parse arguments into sets
The sets are separated by --, and the first set is passed to
getopt_long which currently recognizes only --qargs and non-options. The
--qargs options parses out a set (to -- or end of args) that is passed
to the qargs sub-system for standard qf command line parsing. Set 0 is
for the main qwaq application. Any additional sets (excluding --qargs)
will be used to spawn additional threads when that's working.
2020-03-21 12:58:07 +09:00
Bill Currie
52a46f5d5c [qwaq] Use allocate progs instead of static 2020-03-21 12:58:07 +09:00
Bill Currie
74ed057a5f [qwaq] Begin move over to threading
Of course, it currently locks up, but there aren't any other threads as
of yet so the queues starve.
2020-03-21 12:58:07 +09:00
Bill Currie
ec12941fcb Move the ring buffer macros to their own header
They seem to have proven themselves to be robust.
2020-03-19 23:53:54 +09:00
Bill Currie
65538104bf [qwaq] Tweak listener message names
I didn't like the message:message bit
2020-03-19 23:18:01 +09:00
Bill Currie
ac23156ecd [qwaq] Clamp window motion to owner's bounds 2020-03-19 21:28:55 +09:00
Bill Currie
f329ca83b6 [qwaq] Ensure background color clearing works
Even with 0 for the character, colors should get into the buffer.
2020-03-19 20:41:29 +09:00
Bill Currie
3a28d84c3f [qwaq] Implement window dragging
Other than the stray panel_free, that was surprisingly easy. However, do
need to check that the window can be moved otherwise window pos and
panel pos will get out of sync.
2020-03-19 20:31:59 +09:00
Bill Currie
fe4f831512 [qwaq] Remove a pile of stray panel_free calls
C&P programming FTW :P
2020-03-19 20:31:01 +09:00
Bill Currie
f027a42e72 [qwaq] Treat 0 as transparent character 2020-03-19 19:53:32 +09:00
Bill Currie
14fbdc7df9 [qwaq] Clean up debug in TextContext 2020-03-19 19:35:19 +09:00
Bill Currie
e8d947ed8a [qwaq] Get click and drag reporting working 2020-03-19 19:25:57 +09:00
Bill Currie
95d20d67c7 [qwaq] Implement mouse grabbing
Button will need it for dragging.
2020-03-19 19:00:03 +09:00
Bill Currie
2c20a031e4 [qwaq] Do up a little button test "scene"
Hmm... "scene"... too much Unity?
2020-03-19 18:41:53 +09:00
Bill Currie
cce6837fe8 [qwaq] Offset event mouse coordinates
Each level of the object hierarchy has its own offset relative to the
level above, but mouse coordinates are absolute.
2020-03-19 18:40:21 +09:00
Bill Currie
28a9e041e6 [qwaq] Implement Group redraw 2020-03-19 18:39:11 +09:00
Bill Currie
8bd702ab1a [qwaq] Fetch View origin and size separately 2020-03-19 18:38:24 +09:00
Bill Currie
e49ba896aa [qwaq] Support background and clearing in DrawBuffer 2020-03-19 18:37:25 +09:00
Bill Currie
490f1ad4b8 [qwaq] Add wrappers for werase 2020-03-19 18:37:05 +09:00
Bill Currie
ec2409ceba [qwaq] Mention that Window knows addView 2020-03-19 17:34:29 +09:00
Bill Currie
1306d9fcdd [qwaq] Fix some issues in Listener* 2020-03-19 17:33:47 +09:00
Bill Currie
19161ea80a [qwaq] Clean things up in prep for button testing 2020-03-19 16:27:30 +09:00
Bill Currie
23e6b49845 [qwaq] Implement mouse enter/leave events 2020-03-19 15:55:57 +09:00
Bill Currie
3e9977c272 [qwaq] Give up on pass-by-reference for now
It's too much hassle to ensure the passed variable isn't a local. It's
just not worth the grief right now.
2020-03-19 15:54:10 +09:00
Bill Currie
db39f7ed3e [qwaq] Add hover listener to button
Forgot about this (very useful for tooltips etc).
2020-03-19 13:57:10 +09:00
Bill Currie
bd3884f6fa [qwaq] Add a button class
It may or may not work just yet, but I think it's the right direction.
2020-03-19 13:52:14 +09:00
Bill Currie
6a18b1dd55 [qwaq] Add function to merge extents
It's pretty much the union of two rectangles with the same origin.
2020-03-19 13:51:14 +09:00
Bill Currie
03f87d6f27 [qwaq] Add pos Point alias 2020-03-19 13:50:35 +09:00
Bill Currie
8c3cf83f02 [qwaq] Add Listener and ListenerGroup delegates
Simple single parameter (caller) direct messages.
2020-03-19 13:49:27 +09:00
Bill Currie
01835cbd94 [qwaq] Add blitFromBuffer to TextContext protocol 2020-03-19 13:48:48 +09:00
Bill Currie
2f3ca9d9e4 [qwaq] Clean up the hierarchy
I think I've finally figured out what I want the core hierarchy to be.
Right now, it's just the two classes: View and Window (derived from
View). Window has a Group, and Group is just a collection of Views that
it manages. QwaqApplication is just an object but like a Window, it has
a Group of views.

    View
      Window has a Group
    Group contains Views
    QwaqApplication has a group

More work needs to be done on drawing and event handling, but things are
working again.
2020-03-19 11:32:44 +09:00
Bill Currie
b16093a533 [qwaq] Split out Array(Group) interface 2020-03-19 11:04:02 +09:00
Bill Currie
f6f6b2cba3 [qwaq] Doc the issue number for blit slug 2020-03-18 01:40:58 +09:00
Bill Currie
affadc3d25 [qwaq] Create protocols for DrawBuffer and TextContext
Plenty of flaws at the moment (casts to id :/), but the basic idea seems
to be ok.
2020-03-18 01:40:41 +09:00
Bill Currie
e5bc6dd8b6 [qwaq] Split Array(Group) into its own file 2020-03-18 01:12:23 +09:00
Bill Currie
28a8c1fda7 [qwaq] Implement more curses wrappers 2020-03-17 14:05:31 +09:00
Bill Currie
877ad35a82 [qwaq] Rework the hierarchy again
It doesn't work right now because View unconditionally sends refresh to
its textContext, but textContext can be a draw buffer which does not
respond to refresh. Still, these changes (notably the assignment chain
in qwaq-group.r really pushed qfcc).
2020-03-14 19:45:07 +09:00
Bill Currie
6001abbfdb [qwaq] Use the now working compound init more 2020-03-13 10:00:05 +09:00
Bill Currie
45acbddb79 [qwaq] Make DrawBuffer and TextContext sizes available 2020-03-13 03:09:42 +09:00
Bill Currie
1d3c8d8a6c [qwaq] Sort out mess around placement of getwrect 2020-03-13 03:09:42 +09:00
Bill Currie
d0f21ec2b4 [qwaq] Add -refresh to TextContext
This does the right thing in the presence of panels and dealing with
stdscr.
2020-03-13 03:09:42 +09:00
Bill Currie
3defe50be6 [qwaq] Add printf builtin to ease debugging 2020-03-13 02:41:08 +09:00
Bill Currie
7f9a415cbc [qwaq] Get DrawBuffer and TextContext working
Especially blitting whole regions. Partial regions not tested yet.
2020-03-13 02:36:53 +09:00
Bill Currie
0d4c7ba10f [cl_menu] Update plist usage of obj_msg_sendv
Wonder if there's anywhere else...
2020-03-12 00:52:42 +09:00
Bill Currie
ce67d9b202 [qwaq] Flesh out DrawBuffer's methods 2020-03-10 19:27:26 +09:00
Bill Currie
b3850bbc69 [qwaq] Implement blitting from draw buffer to text
Sending the data out to curses.
2020-03-10 19:23:51 +09:00
Bill Currie
f91fb4f840 [qwaq] Add an mvwblit_line builtin
I had to do my own thing with curses as the function I had planned to
use turned out to be quite different from what I wanted (misread the man
page).
2020-03-10 18:21:06 +09:00
Bill Currie
694ad2e840 [ruamoko] Add str_char builtin
This returns the character (as an int) at the index. Equivalent to
string[index], but qc code doesn't have char-level access and not having
it means that strings can internally change to wchar without too much
fuss (maybe).
2020-03-10 18:16:55 +09:00
Bill Currie
1b1249bdb0 [ruamoko] Add vsprintf builtin 2020-03-10 18:16:07 +09:00
Bill Currie
b517b95e45 [libr] Add -performv:: 2020-03-10 14:29:43 +09:00
Bill Currie
fb92ee12d6 [qwaq] Set event type to none when no events
Fixes the endless looping on the last event.
2020-03-10 03:11:21 +09:00
Bill Currie
f9d798c314 [qwaq] Use forwarding for some text methods
refresh won't be in the drawing buffer protocol, and the move commands
need to be offset by the view's position in its window, but it works as
intended.
2020-03-10 02:58:30 +09:00
Bill Currie
e9eab68366 [qwaq] Begin work on local drawing buffers 2020-03-10 02:39:18 +09:00
Bill Currie
4978713dee [libr] Add __obj_responds_to proto and definition 2020-03-10 00:09:46 +09:00
Bill Currie
a487595149 [ruamoko,libr] Begin implementation of __obj_forward
libr supplies an __obj_forward definition that links to a builtin, but
as it is the only def in its object file, it is readily replaceable by
an alternative Ruamoko implementation.

The builtin version currently simply errors out (rather facetiously),
but only as a stub to allow progs to load.
2020-03-09 19:09:08 +09:00
Bill Currie
0780cca496 [qwaq] Fixed swapped method implementations
That was fun
2020-03-08 22:21:15 +09:00
Bill Currie
8fc007648c [qwaq] Add missed command enum string 2020-03-08 22:20:46 +09:00
Bill Currie
89cf9f9523 [qwaq] Use Sys_Printf for load error messages
It gets them into the log file.
2020-03-08 22:19:37 +09:00
Bill Currie
bb0e65e9d4 [cl_menu] Silence some debug output 2020-03-08 21:45:51 +09:00
Bill Currie
f0ecf7b30a [qwaq] Clean out log file with make clean 2020-03-06 20:43:38 +09:00
Bill Currie
1250fe7446 [qwaq] Use a log file instead of stderr
Now I don't have to worry about remembering to redirect the output, but
debugging is still easy.
2020-03-06 18:29:16 +09:00
Bill Currie
b8b74fc074 [qwaq] Implement missing addch
I either forgot about it, or just didn't need it at the time, but I'm
sure it will be useful later when more stuff is implemented.
2020-03-06 17:57:33 +09:00
Bill Currie
9a96a9b2c9 [qwaq] Use own version of positional drawing in Window
Double offsetting the prints doesn't quite look right ;)
2020-03-06 17:46:36 +09:00
Bill Currie
d0a249590c [qwaq] Use self where possible for drawing in Window 2020-03-06 17:45:58 +09:00
Bill Currie
bea64838cc [qwaq] Use new TextContext
Not quite right yet, but it worked first try (once I got another
compiler bug sorted).
2020-03-06 17:38:27 +09:00
Bill Currie
ba9c43d2d3 [qwaq] Create a TextContext class
It is essentially just a wrapper around the window versions of ncurses
functions.
2020-03-06 13:54:46 +09:00
Bill Currie
40ae7a7f19 [qwaq] Implement ofDontDraw
The conditional selector performance seems to work nicely, but I've
found a mistake with View.window (partly, realizing why my old lib (and
probably TV in the first place) had separate textContext and buffers
between views and groups).
2020-03-06 11:53:40 +09:00
Bill Currie
6bf2fd546d [qwaq] Extend Array makeObjectsPerform methods
Added conditional message sending and reversed traversal of the array.
2020-03-06 11:27:31 +09:00
Bill Currie
ad4cde15b5 [qwaq] Get Window working
It even draws a border around itself.
2020-03-06 00:32:09 +09:00
Bill Currie
f18e3c3ad7 [qwaq] Add wborder command 2020-03-06 00:31:29 +09:00
Bill Currie
971caf553d [qwaq] Add debug output to the command queue
Be sure to redirect stderr or the screen will get messed up
2020-03-06 00:30:11 +09:00
Bill Currie
c377b324a1 [qwaq] Add Group and clean up lots of mess
Things are finally doing something again, and getting closer to having a
moveable window.
2020-03-05 15:44:53 +09:00
Bill Currie
a4582e526d [cl_menu,scheme] Clean up after tightened pointer checks 2020-03-05 15:02:40 +09:00
Bill Currie
2ddfe2ef07 [libr] Accept void * for performSelector:withObject:
It's up to the receiver what the object should be.
2020-03-05 15:00:42 +09:00
Bill Currie
f3236410d0 [qwaq] Make the event system more informative
Doesn't have timestamps at this stage, but otherwise it reflects the
event system I had in my old text UI which was heavily based on
TurboVision. TV is pretty good (after looking at things a bit closer I
found it wasn't as deep as I thought), and better yet, Borland released
it to the public domain 23 years ago! (wish I'd known that).

Anyway, this commit gets something happening on the screen, even though
the current hierarchy is still a mess.
2020-03-04 22:09:40 +09:00
Bill Currie
815ae02121 [qwaq] Allocate enough bytes for the args list
d'oh
2020-03-04 21:17:17 +09:00
Bill Currie
d57e05258c [qwaq] Remove now unnecessary union field name
\o/
2020-03-04 19:10:09 +09:00
Bill Currie
c58cf2c2d0 [qwaq] Fail at object oriented design 101
This is horrible, doesn't work, isn't really the direction I want to go
(that became apparent while implementing Screen's handleEvent) and
crashes anyway (Array and not-id...)

*sigh*

Still, this does have some good stuff in it, and it pushed qfcc along
some more.
2020-03-03 21:32:19 +09:00
Bill Currie
7976eec2ce [scheme] Clean up a pile of rotten bits 2020-03-03 17:35:14 +09:00
Bill Currie
051a572bcc [build] Dependency checking for all ruamoko code
Including dependency on qfcc itself. Getting automake to chooch the way
I want it to chooch can be a pain in the... see AvE
2020-03-03 17:24:53 +09:00