Skip to content

Rmk185 tedit window and process glitches#2604

Merged
rmkaplan merged 17 commits into
masterfrom
rmk185--Tedit-window-and-process-glitches
May 21, 2026
Merged

Rmk185 tedit window and process glitches#2604
rmkaplan merged 17 commits into
masterfrom
rmk185--Tedit-window-and-process-glitches

Conversation

@rmkaplan
Copy link
Copy Markdown
Contributor

Very few files for a Tedit PR...

TEDIT-FILE just fixes a bug in TEDIT.FORMATTEDFILEP for the earliest Tedit format version (version 0, early 1985). This showed up in the HCFILES tests #2598.

Trivial change for the initial window size, as requested by @nbriggs #2517. It now calls GETREGION instead of GETBOXREGION, passing the earlier parameters as minimum sizes. So it allows the user to drag out a region larger than the one that is heuristically suggested.

Of more subtlety, I noticed that if you have two formatting menus (e.g. charlooks and paralooks) above a main Tedit window and you close the one closest to the main, the one above it wasn't moving down to close the space. That had to do with the order of evaluate of closing the window and deactivating it, which this now hopefully gets right.

But I also noticed another oddity: If you have a menu open above the main, the PSW shows a process for the main and a process for the menu, as expected. If you close the main while the menu is open, both windows close, but only the menu's process disappears. The main's process still shows up in the PSW. If you close a main window when there is no menu, then the PSW is cleared.

The logic of deactivating was to close the window and then give the TTY back to the command loop of the main process, which was supposed to then return and presumably allow the process to go away. That apparently wasn't happening, for reasons unknown to me.

I changed the deactivation code (TEDIT.DEACTIVATE.WINDOW so that it kills the process immediately, by calling TEDIT.KILL which calls DEL.PROCESS directly. That seems to have cleaned things up.

This may also clean up something else that I have noticed: in my mode of running is to bring up a lot of transitory Tedit windows via the tf and ts commands in TEDIT-PF-SEE. I look at something, then close the window, expecting the process to go away. But after quite awhile I end up with a mysterious stack overflow. If I reset out of that, all of the old , closed windows pop back up with an "inactive" label. They are not useful--clicking on them blows them away. I surmise--correct me if I'm wrong--that the prior closing sequence was somehow taking those processes out of the PSW but they were still there and still holding on to stack space. (Perhaps there was a secret circular backlink between the stream, window, and process?)

I'm hoping that expliciting deleting the process will solve this problem (even if there is a backlink).

@pamoroso
Copy link
Copy Markdown
Member

It works as intended on Linux Mint 22.1 Cinnamon. The new default TEdit window works well but I'd appreciate a slightly taller initial window.

@pamoroso
Copy link
Copy Markdown
Member

To elaborate on my suggestion, the same default height TEdit uses for loading a supplied document (20 lines?) would be fine.

@pamoroso
Copy link
Copy Markdown
Member

Still looking good at commit 44d9da0.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

This PR is still hanging out there, so I added some files. This is trying to keep the secondary selection consistent when the mouse leaves, perhaps to scroll, and comes back, issue #2434 .

Wheelscroll is stil problematic when the mode keys are down for a secondary. I'm not altogether clear, but I think the issue is that the wheelscroll comes through the keyboard but the secondary selection is runnning in the mouse.

@pamoroso
Copy link
Copy Markdown
Member

It still works with no issues at commit be6a6d0.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

@nbriggs you might want to try various interactions of mousing in and out with secondary mode keys to see if this improves on the issues in #2434

@nbriggs
Copy link
Copy Markdown
Contributor

nbriggs commented May 14, 2026

If anything, it's worse on mouse interactions now. I started with

  • open a TEDIT on any file
  • click in the line select area to set selection at beginning of any line
  • shift-hold-click to select copy source as a whole line
  • let the shift up -- it copies correctly duplicating the line
  • Do the same thing but while the shift is held down move the mouse outside the TEdit window to the left and then back into the TEdit window
  • release the shift -- no copy happens.
  • The shift-select source underline stays after releasing the shift, but disappears if another selection is made

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 14, 2026 via email

@rmkaplan
Copy link
Copy Markdown
Contributor Author

The new function \TEDIT.CURSORINFN is now applied when the mouse crosses over a Tedit window. If the window's process has the TTY, and if the stream has a secondary selection whose mode keys match the current keyboard modekeys, then without a new click this reenters the mouse-tracking function \TEDIT.BUTTONEVENTFN. The idea is to get back into the tracking loop with the state as it was when the mouse left the window and the loop gave up control. If the mode keys come up, the secondary selection should be applied, as if the mouse had never left.

On this attempt, if the TTY/secondary selection conditions are not satisfied when the mouse comes back in, the secondary selection is turned off. Not sure about that--that perhaps should happen only if the window still has the TTY but the modekeys are different.

I hope this eliminates the dangling secondary selections we have been seeing, and that the behavior is at least somewhat more intuitive.

@pamoroso
Copy link
Copy Markdown
Member

Nothing unexpected to report at commit 7e87f58.

@pamoroso
Copy link
Copy Markdown
Member

@nbriggs I'm not sure what to do in step 3 of your test.

@nbriggs
Copy link
Copy Markdown
Contributor

nbriggs commented May 15, 2026

@pamoroso

shift-hold-click to select copy source as a whole line

hold the (left) shift key down, and while holding it down move the mouse/cursor (always keeping it within the TEdit window) to the left margin of the document (where the cursor changes from NW pointing to NE pointing) and left-click with the mouse to select a whole line, all the while keeping the shift key down, then continue to step 4.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 15, 2026 via email

@pamoroso
Copy link
Copy Markdown
Member

@nbriggs Thanks, this way I confirm the issue.

@nbriggs
Copy link
Copy Markdown
Contributor

nbriggs commented May 15, 2026

New version works a little bit better. If you cross the scroll bar quickly it's OK, if you pause and let the scroll bar appear and then move back in to the window it doesn't.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 15, 2026 via email

@nbriggs
Copy link
Copy Markdown
Contributor

nbriggs commented May 15, 2026

@rmkaplan - correct. It neither clears the secondary selection nor does the copy when the shift key is released. I don't think that whether the scroll bar activated or not should have any effect.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

Tedit was keeping control when the mouse went into its scroll bar, only giving up control when the mouse truly went outside. I removed that complexity in Tedit, the polling gives up control whenever the mouse leaves the window, the general window system seems to then notice whether it is hanging out in the control bar.

That means that coming back from the scroll bar is the same as coming back from anywhere else. That seems to work, although sometimes it is sporadic in both cases for reasons I don't understand--maybe just my local coding environment. Let me know if it is inconsistent or unreliable.

I also pushed a change to the way the line/paragraph selection works. Instead of being able to switch the line/text region in the middle of the tracking loop, it sets the region on entry, outside of tracking. The cursor changes when you move through the line-select region, but you have to click there to change the selection. Otherwise you would just pass through to the scroll bar and beyond.

@pamoroso
Copy link
Copy Markdown
Member

At commit 2485ddb I did a few shift-copy tests in a document and crossing the scroll bar worked better, i.e. the copy did occur when releasing the copy key.

However, after executing the Quit command of the middle-click title bar menu TEdit forze for a few seconds and then this break window showed up (the TEdit window shows some duplicate text as a consequence of my tests; the document is a copy of lispusers/BITMAPFNS.TEDIT):

INTERLISP-ERROR
In ERROR:
ARG NOT TEXTOBJ
NIL
tedit-error

At that point Medley was unresponsive and didn't accept any mouse or keyboard input but still continued GCing every few seconds.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 16, 2026 via email

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 16, 2026 via email

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 16, 2026 via email

@pamoroso
Copy link
Copy Markdown
Member

The value of (WINDOWPROP (WHICHW) 'CLOSEFN):

tedit1

Tracing TEDIT.DEACTIVATE.WINDOW and Quitting:

tedit2

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 16, 2026 via email

@pamoroso
Copy link
Copy Markdown
Member

Yes, same bahavior in a fresh full sysout launched with medley -v -r -: the TEdit window doesn't close when quitting.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 16, 2026 via email

@pamoroso
Copy link
Copy Markdown
Member

With the advice the window stays open indefinitely after quitting and nothing happens.

tedit-advised

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 16, 2026 via email

@pamoroso
Copy link
Copy Markdown
Member

Here is some more data from inspecting the TEdit process and window after quitting:

tedit-inspect

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 16, 2026 via email

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 17, 2026 via email

@pamoroso
Copy link
Copy Markdown
Member

Another clue is whatever holds onto the window is not in master.

@pamoroso
Copy link
Copy Markdown
Member

Commit 1f56a56 fixes the quit issue and the window closes as expected.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

I don't entirely understand it, but it appears there was a race condition in the interaction between the session closing down and the mouse seeing the button in the window. In part the change that provoked this had to do with trying to work around the mismatch of arguments between the defined version of \TEDIT.BUTTONEVENTFN and the version that is created when that function is MODERNIZEd.

For me, it now seems to behave as expected.

@pamoroso
Copy link
Copy Markdown
Member

At commit 3cf6234 it's still working as expected, including quitting.

@pamoroso
Copy link
Copy Markdown
Member

Still looking good at commit d5607d7.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

It would be good to get this merged before I open it up for some of the other selection issues that were discussed int he 5/17 meeting. I think this is an improvement over what's there, and this would establish a platform for the further changes.

There is stuff in the Tedit code and documentation that I don't understand, and which make the implementation a little complicated...and I would like to remove. The documentation (Section 8) specifies that the last selection of various types are to be stored in global variables (e.g. TEDIT.SELECTION, TEDIT.SHIFTEDSELECTION, TEDIT.MOVESELECTION). What would these be used for?

Also, the function TEDIT.SETSEL is documented as taking an OPERATION, which can be NORMAL, MOVE, COPY, PENDINGDEL, or DELETE. What would it mean to say that a selection is a MOVE or COPY selection? The documentation says that it would affect the highlighting of the selection (broken underline, maybe black...) but I don't see when or how the actual operation would be executed, since the target isn't specified. The screen may be consistent with the selection, but it is misleading about what might actually happen. And there are separate entries TEDIT.MOVE and TEDIT.COPY that take source and target selections and do the operation. (PENDINGDEL makes more sense--the selection itself would be the target for deletion on the next insertion).

@nbriggs
Copy link
Copy Markdown
Contributor

nbriggs commented May 19, 2026

Those global variables are used by TEXEC - I haven't read the code, just noted that they're used there.
It appears to change things in the globals, and then uses \\COPYSEL to perform an operation using one of the selections as source or destination.

@rmkaplan
Copy link
Copy Markdown
Contributor Author

rmkaplan commented May 19, 2026 via email

@pamoroso
Copy link
Copy Markdown
Member

Still no issues at commit a8b8f3f.

Copy link
Copy Markdown
Contributor

@nbriggs nbriggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - working better than it was. Still things to fix... in another PR.

@rmkaplan rmkaplan merged commit 406b509 into master May 21, 2026
@rmkaplan rmkaplan deleted the rmk185--Tedit-window-and-process-glitches branch May 21, 2026 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants