#18 move to event-driven main loop
[fanfix.git] / docs / worklog.md
CommitLineData
55d2b2c2
KL
1Jexer Work Log
2==============
3
be72cb5c
KL
4August 16, 2017
5
6Holy balls this has gotten so much faster! It is FINALLY visibly
7identical in speed to the original d-tui: on xterm it is glass
8smooth. CPU load is about +/- 10%, idling around 5%.
9
10I had to dramatically rework the event processing order, but now it
11makes much more sense. TApplication.run()'s sole job is to listen for
12backend I/O, push it into drainEventQueue, and wake up the consumer
13thread. The consumer thread's run() has the job of dealing with the
14event, AND THEN calling doIdles and updating the screen. That was the
15big breakthrough: why bother having main thread do screen updates? It
16just leads to contention everywhere as it tries to tell the consumer
17thread to lay off its data structures, when in reality the consumer
18thread should have been the real owner of those structures in the
19first place! This was mainly an artifact of the d-tui fiber threading
20design.
21
22So now we have nice flow of events:
23
24* I/O enters the backend, backend wakes up main thread.
25
26* Main thread grabs events, wakes up consumer thread.
27
28* Consumer thread does work, updates screen.
29
30* Anyone can call doRepaint() to get a screen update shortly
31 thereafter.
32
33* Same flow for TTerminalWindow: ECMA48 gets remote I/O, calls back
34 into TTerminalWindow, which then calls doRepaint(). So in this case
35 we have a completely external thread asking for a screen update, and
36 it is working.
37
38Along the way I also eliminated the Screen.dirty flag and cut out
39calls to CellAttribute checks. Overall we now have about 80% less CPU
40being burned and way less latency. Both HPROF samples and times puts
41my code at roughly 5% of the total, all the rest is the
42sleeping/locking infrastructure.
43
f6d90207
KL
44August 15, 2017
45
46I cut 0.0.5 just now, and also applied for a Sonatype repository.
47It was a reasonable spot: TEditor was working albeit buggy, and a bug
48had just come in on the main TApplication run loop. So we are about
49to embark upon some performance work again, it's been probably version
500.0.2 or so since the last cycle.
51
52Code size: 40446 lines.
53
54Now switching head to 0.0.6 and taking a small break.
55
df602ccf
KL
56August 14, 2017
57
58TEditor is basically done. Mouse movement, keyboard movement,
59backspace / delete / enter / etc. are all in. Things are starting to
60look pretty good.
61
62I'm going to prep for a final cut and release tag tomorrow or the next
63evening. I need to take a break and get some meatspace life dealt
64with.
65
e8a11f98
KL
66August 12, 2017
67
68TEditor is stubbed in about 50% complete now. I have a Highlighter
69class that provides different colors based on Word text values, but it
70is a lot too simple to do true syntax highlighting. I am noodling on
71the right design that would let TEditor be both a programmer's editor
72(so Highlighter needs to have state and do a lexical scan) and a word
73processor (where Word needs to tokenize on whitespace). I estimate
74probably a good 2-4 weeks left to get the editor behavior where I want
75it, and then after that will be the 0.0.5 release.
76
77Finding more minor paper cuts and fixing them: the mouse cursor being
78ahead of a window drag event, SwingTerminal resetting blink on new
79input, prevent TWindow from resizing down into the status bar.
80
3e074355
KL
81August 8, 2017
82
83Multiscreen is looking really cool! Demo6 now brings up three
84screens, including one that is inside a TWindow of a different
85application.
86
42873e30
KL
87August 7, 2017
88
89Had trouble sleeping, what with a bunch of imaginative thoughts for
90this release. jexer.backend will be the ultimate destination for
91jexer.session and most of jexer.io. TerminalReader will be the
92interface for keyboard and mouse events. cmScreenConnected and
93cmScreenDisconnected will be new events to represent a screen
94appearing/disappearing, and MultiBackend will be a new backend
95multiplexer that goes full XRandR. Several new demos demonstrating
96multi-screen support will be coming along.
97
98August 6, 2017
99
100Time to clean up more API, particularly between Backend and Screen.
101Both of these will be interfaces soon, so that one could easily
102subclass JComponent and implement both Screen and Backend. The
103original code evolved out of Qodem, where screen.c and input.c were
104two different things leading to ECMA48Screen and ECMA48Terminal, but
105now there is really no need to keep them separate. It also
106complicates the constructors, as these are basically friend classes
107that have used package private access to get around their artificial
108separation.
109
110When I get this done it should be a lot easier to do any of:
111
112* Pass a JFrame or JComponent to SwingBackend and have it add itself,
113 like any other Swing widget.
114
115* Construct a SwingBackend and add it to any regular JComponent.
116
117* Have multiple TApplications running inside the same Swing
118 application, including having actions affect each other. (Will also
119 need to ensure that TWidgets/TWindows are not in different
120 TApplication collections.)
121
122* Build a Backend/Screen multiplexer, so that one could have a ECMA48
123 TApplication listening on a port and a local Swing monitor for it.
124
125* Build a Backend/Screen manager, so that one could have multiple
126 ECMA48 screens acting as a single large screen (e.g. XRandR).
127
128Now I need to decide which package will collect Backend, SessionInfo,
129and Screen. jexer.io has some java.io stuff, so it stays anyway.
130
2fef9c6e
KL
131July 28, 2017
132
133Got very busy with my meatspace life, now getting a chance to come
134back around.
135
136I gave up on TEditor knowing about graphemes, instead pulling back to
137simple Cells. This will be better anyway in the long run, as getting
138grapheme support in Screen someday will also get it for me in TEditor
139for free. But it does mean that TEditor will chew through much more
140RAM than it needs to for a text file. Performance optimization will
141come someday. But this means I can also go back to gcj, because I
142really like its warnings about unused imports.
143
144I've got a POM stubbed in, and created an account over at sonatype.
145If it isn't too hard, I will try to get 0.0.5 released into the maven
146universe. But that is still a bit away, I need TEditor running with
147syntax highlighting first.
148
149July 17, 2017
150
151Focus-follows-mouse is in, as is NOCLOSEBOX.
152
8c236a98
KL
153July 15, 2017
154
155I think I have cleaned up most of the window show/hide/activate mess
156in TApplication. Demo4 has some cool interactions between a
157background TDesktop and several foreground TWindows, which helped
158expose bugs.
159
160July 9, 2017
161
162While working on TWindow.hide/show I decided that I am sick of
163TApplication's active window handling. TApplication makes lots of
164assumptions, things are too fragile between modal and not, and one
165cannot easily say window.activate(). So I will also be changing that
166too. ... Code is still a bit of a mess, but hooks are in place at
167least for show/hide/activate.
168
169July 8, 2017
170
171Qodem 1.0.0 released last month, I had a vacation, and a Jexer user
172(nikiroo) started opening up pull requests. :-) So back unto the
173breach we go!
174
175TButton is now animated so that there is some feedback when selected
176via keyboard. StringJustifier was written which permits TText's to
177have left/centered/right and full justification. TDesktop is now in
178too which can act as a permanent max-sized window without borders.
179
180Next up is Viewport, an interface to collect scrollbar API, and then a
181cleaner API for scrollable widgets and windows. After that is more
182window API: hide/show/maximize/restore, and unclosable windows. I am
183cherry-picking bits from @nikiroo's PRs, which will likely break them
184before it fixes things, but I will find some way to get Niki credited
185with those pieces.
186
e685a47d
KL
187March 21, 2017
188
189I am starting to gear up for making Jexer a serious project now. I've
190created its SourceForge project, linked it back to GitHub, have most
191of its web page set up (looks like Qodem's), and released 0.0.4. And
192then this morning saw an out-of-bounds exception if you kill the main
193demo window. Glad I marked it Alpha on SourceForge...
194
195Yesterday I was digging around the other Turbo Vision derived projects
196while populating the about page, and made a sad/happy-ish realization:
197Embarcadero could probably get all of them shut down if it really
198wanted to, including Free Vision. I uncovered some hidden history in
199Free Vision, such that it appears that Graphics Vision had some
200licensed Borland code in it, so there might be enough mud in the air
201that Free Vision could be shut down the same way RHTVision was. But
202even worse is the SCOTUS ruling on Oracle vs Google: if APIs are
203copyrighted (regardless of their thoughts on fair use), then any
204software that matches the API of a proprietary project might find
205itself subject to an infringement case. So that too could shut down
206the other API-compatible TV clones.
207
208Fortunately, Jexer (and D-TUI) is completely new, and has no API
209compatibility with Turbo Vision. Jexer could be a new root to a whole
210generation of TUI applications.
211
a7986f7b
KL
212March 18, 2017
213
214TStatusBar is working, as is "smart" window placement. Overall this
215is looking quite nice. Found a lot of other small paper cut items and
216fixed them. It looks absolutely gorgeous on Mac now.
217
218Tomorrow I will get to the public wifi and get this uploaded.
219
220Time to call this 0.0.4 now though. We are up to 32,123 lines of
221code.
222
55d2b2c2
KL
223March 17, 2017
224
225Jexer is coming back to active development status. I had a lot of
226other projects ahead of it in the queue, mostly Qodem but also Jermit
227and of course lots of actual day job work keeping me too tired for
228afterhours stuff. But here we are now, and I want to get Jexer to its
2291.0.0 release before the end of 2018. After that it will be a
230critical bit of function for IWP and NIB, if I ever get those going.
231I need to re-organize the demo app a bit so that it fits within 80x25,
232and then get to TStatusBar.
233
234A status bar will be an optional part of TWindow. If it exists, then
235it will be drawn last by TApplication and get events routed to it from
236TWindow's event handlers. This will have the nice effect that the
237status bar can change depending on which window is active, without any
238real extra work on TApplication's part.
239
240Putting together a proper TODO now, with release and regression
241checklists. I think I will see if jexer is available at SourceForge,
242and if so grab it. Perhaps I can put together some good Turbo Vision
243resources too. At the very least direct people to the Borland-derived
244C++ releases and Free Vision.