Commit Graph

122 Commits

Author SHA1 Message Date
Bill Currie 8707ac0d57 [qwaq] Add a guard to formatLine
I got really weird error (invalid panel passed to top_panel) when there
was no such call, so I guess there was some memory corruption.
formatLine is the only suspect, but when I put in the guard, the error
wasn't reproduced (just scrolling through qwaq's makefile in a big
window).
2020-03-23 23:18:02 +09:00
Bill Currie 52722b73c1 [qwaq] Adjust edge window control lengths
I'd forgotten them when adjusting the corner control sizes
2020-03-23 23:03:35 +09:00
Bill Currie 622b5f4c45 [qwaq] Fix the handling of overlapping views
This even simplifies the logic for mouse enter/leave handling, a nice
bonus.
2020-03-23 22:35:30 +09:00
Bill Currie 8b193c6b6c [qwaq] Remove some debug prints 2020-03-23 22:28:18 +09:00
Bill Currie ba3efca8e5 [qwaq] Make the corner window controls 2x2
This makes them a little easier to grab but exposes a bug in Group
handleEvent when views partially overlap.
2020-03-23 22:27:08 +09:00
Bill Currie 1479880954 [qwaq] Add window control buttons
With this, windows can be resized using any of the corners or the three
sides other than top (top side is move-only, otherwise moving a window
without resizing would be impossible).
2020-03-23 22:10:03 +09:00
Bill Currie 467115429e [qwaq] Add gfGrowNone and a grow mode setter
gfGrowNone is just to allow not growing with the owner to be explicitly
stated.
2020-03-23 22:08:30 +09:00
Bill Currie 731a123b79 [qwaq] Add a title bar
The title bar is special in that it is always centered at the top of its
owner, thus it takes no rect.
2020-03-23 22:01:13 +09:00
Bill Currie 19a4efed16 [qwaq] Add support for invisible buttons
Useful for window controls.
2020-03-23 22:00:05 +09:00
Bill Currie afda214487 Adjust some whitespace 2020-03-23 20:18:12 +09:00
Bill Currie 9bc91cd7d1 [qwaq] Implement resizing
Terminal resize is detected and the views adjust appropriately (well,
those for which I've set grow flags: the window title bar doesn't adjust
yet).
2020-03-23 20:14:32 +09:00
Bill Currie 1dd05a8ac9 [qwaq] Fix an uninitialized var warning 2020-03-22 23:58:58 +09:00
Bill Currie bde3124533 [qwaq] Fix some more formatLine cases
I think this is all of them. Scrolling around in a file, including
having the end of file visible in the window, seems to work well.
2020-03-22 23:50:27 +09:00
Bill Currie 16c60655e7 [qwaq] Implement scrolling via mouse wheel
Line formatting segs when scrolling horizontally through a tab, but...
things ware working nicely.
2020-03-22 22:42:56 +09:00
Bill Currie 8694798943 [qwaq] Fix line formatting for the simple case
That is, known to be working for the simple case (no tabs, no horizontal
scroll).
2020-03-22 22:13:35 +09:00
Bill Currie 10adb116ef [qwaq] Start working on the source view/editor
Line formatting is a bit messed up, but other than non-virtual text
being double-counted, things seem to be ok (view only).
2020-03-22 22:03:34 +09:00
Bill Currie ee9d3a36ab [qwaq] Add an editor buffer
It's a fairly high-level wrapper for TextBuffer in that it implements
file ops (load/save), searching, navigation, and formatting (simple
line-oriented with tab stops (currently at 4 spaces)).
2020-03-22 21:31:30 +09:00
Bill Currie 63a2204fa5 [qwaq] Fix incorrect mouse wheel bits
I thought I fixed that already (mistreating mouse 3 as part of the wheel
group).
2020-03-22 14:24:12 +09:00
Bill Currie f3c68eaada Implement mouse auto events
These are for when a button is held down: good for scroll bar arrows
etc.
2020-03-22 14:06:27 +09:00
Bill Currie 5cdd1931b7 [qwaq] Remove some debug 2020-03-22 13:56:31 +09:00
Bill Currie 50290baf04 [qwaq] Add missing part of commit 2020-03-22 13:54:54 +09:00
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