Skip to content

Conversation

@rmkaplan
Copy link
Contributor

@rmkaplan rmkaplan commented Nov 7, 2025

Updated Sketch to use the more general font interface, should make it work for HTML when that gets installed. It also now sits on top of the more general font coercion, so that, for example, it might simulate a larger set of sizes (e.g. TERMINAL actually only has up to size 12, but it now should roll over to MODERN for 14 and up.)

I added a general cache for the results of FONTSAVAILABLE file lookups, eliminating some of the special performance-caching in Sketch.

The generic algorithms should also cover a few cases that the original algorithms seem to be missing.

@rmkaplan rmkaplan marked this pull request as draft November 7, 2025 06:18
@pamoroso
Copy link
Contributor

pamoroso commented Nov 7, 2025

On Linux Mint 22.1 Cinnamon I launched Sketch, set the font to Terminal 12, clicked on the canvas, typed ABC, and then pressed Bkackspace three times. This is what I got after clicking the mouse pointer elsewhere for a clearer view of the text:

sketch-terminal12

Is this the expected behavior? It's the same with Medley Online.

By the way, I haven't found a way to set the Terminal size to anything more than 12.

@masinter
Copy link
Member

masinter commented Nov 7, 2025

A cache of values computed by examining the file system is invalid if the file system changes.
FONTSAVAILABLE looks to see what fonts are in the file system -- if you move to a different configuration or change the files in then FONTSAVAILABLE cache is no longer valid.

@pamoroso
Copy link
Contributor

pamoroso commented Nov 7, 2025

Text in Sketch otherwise seems to be working fine. Concerning Terminal larger than 12, do I understand correctly that it's supposed to be coerced to Modern for 14 and up?

@rmkaplan
Copy link
Contributor Author

rmkaplan commented Nov 7, 2025 via email

@rmkaplan
Copy link
Contributor Author

rmkaplan commented Nov 7, 2025 via email

@nbriggs
Copy link
Contributor

nbriggs commented Nov 7, 2025

I believe it is an error to coerce a fixed-pitch font such as Terminal into a variable-pitch font such as Modern. If the creator of the sketch wants a size that is not available then they should choose an alternative font that has the size.

@rmkaplan
Copy link
Contributor Author

rmkaplan commented Nov 7, 2025 via email

@rmkaplan
Copy link
Contributor Author

rmkaplan commented Nov 7, 2025

On Linux Mint 22.1 Cinnamon I launched Sketch, set the font to Terminal 12, clicked on the canvas, typed ABC, and then pressed Bkackspace three times. This is what I got after clicking the mouse pointer elsewhere for a clearer view of the text:

sketch-terminal12 Is this the expected behavior? It's the same with Medley Online.

I see a slightly different behavior in the release sysout (before these Sketch changes) on my Mac, but still not good. Instead of the bad ^H echo, typing Delete just moves the caret to the right. If you type backspace at the end of the string, it looks like it is inserting spaces. The Venue sysout has the right behavior, so something somewhere along the way went wrong.

@rmkaplan
Copy link
Contributor Author

rmkaplan commented Nov 7, 2025

Yes, it's a variable that has to be set to NIL in the event functions. The FONTEXISTS cache also has to be set back, only \FONTSINCORE is persistent. (There may still be some Sketch caches that should revert, I'm still learning)

On Nov 7, 2025, at 8:02 AM, Larry Masinter @.***> wrote: masinter left a comment (Interlisp/medley#2358) <#2358 (comment)> A cache of values computed by examining the file system is invalid if the file system changes. FONTSAVAILABLE looks to see what fonts are in the file system -- if you move to a different configuration or change the files in then FONTSAVAILABLE cache is no longer valid. — Reply to this email directly, view it on GitHub <#2358 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSTUJPLE4F2EUNKTZZWXVD33S7BHAVCNFSM6AAAAACLNC66ZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMBTGM4DOOJUG4. You are receiving this because you authored the thread.

I thought it would be sufficient for FONT to ADDVARS those cache variables to MEDLEY-INIT-VARS, but that doesn't work. The file MEDLEYDIR comes at the beginning of the Lisp loadup, it has a VARS command that smashes any previous value of MEDLEY-INIT-VARS (that might have been set during the INIT phase). Is there any reason for MEDLEYDIR not to use an ADDVARS command instead of VARS ?

@masinter
Copy link
Member

masinter commented Nov 8, 2025

i don't think there would be a problem with using ADDVARS ... this all was done when the loadup process was not scripted. The difficulties come when cross-compiling for a different maiko/opcodes where you don't want to mix the directories for things to run in this environment vs things to run in the future -- if they are being set in an ADDVARS when you're adding future values to the current values?

@pamoroso
Copy link
Contributor

pamoroso commented Nov 8, 2025

In the release sysout I also get the same behavior with Del, i.e. it moves the caret to the right.

@rmkaplan
Copy link
Contributor Author

rmkaplan commented Nov 8, 2025

On @pamoroso 's observation that backspace doesn't work...

It turns out that Sketch has a peculiar relationship to Tedit. Loading SKETCH doesn't actually insure that TEDIT has been loaded (no (FILES TEDIT)) command. But the way a single sketch is put to a file is to create an image object around that sketch, insert it in a tedit stream created by a call to OPENTEXTSTREAM, and then do a Tedit Put. Reading from a "sketch" file inverts that process: return the embedded sketch if the Tedit file has a single image object "character" of type Sketch.

Thus, at least with respect to getting and putting, Sketch assumes that Tedit is always there, won't work without it. On the other hand, there is a function SK.GETSYNTAX that has a runtime test to see if the function TEDIT.GETSYNTAX exists, in which case it uses that to decode the meaning of characters like backspace, undo, etc. If it doesn't exist (but then you couldn't put or get), it uses the system level GETSYNTAX to get the syntax class. (It has a similar test and dependency on Tedit when it is trying to determine the word-bounding characters for middle-button select.)

The reasonable motivation for these Tedit dependencies, I presume, was so that Sketch and Tedit would always have the same key-binding behavior, even if the user moved the Tedit bindings away from the system defaults.

The bad behavior comes from the fact that I changed the values returned by TEDIT.GETSYNTAX when I simplified the Tedit process command loop and extended the interface for a larger set of Tedit command characters, as described in the Tedit release notes. Instead of having explicit dispatches in the Tedit command loop for the already defined syntax classes, I made the class of all of them uniformly be of type function-call, with each of them having their own separate implementation function. That's what provides the behavior of the extended set of keyboard actions (and also the Tedit buttons). (The command-loop simplification was also in preparation for a move to a single Tedit process.)

But I didn't realize that Sedit was also calling that function and expecting all/only the previously defined class names (CHARDELETE instead of FUNCTIONCALL). So it broke. (I also didn't check the Tedit documentation, where I would have seen the explicit list of class names defined for its value).

The simplification inside Tedit is below the level of the TEDIT.GETSYNTAX interface function, so I will try to restore the standard character class names in its output. I will also put in a (FILES TEDIT) command in SKETCH, to be clear.

But this raises another possibility: If Sketch were to dispatch in the same way but to its own set of implementation functions, then we might get uniform keyboard operations for bold, italic, etc. that Sketch doesn't now provide, and the Tedit formatting buttons would also act on Sketch selections (the buttons just transmit the triggering characters). Using Tedit's tables for uniformity, we would just need a mapping from the names of the individual Tedit implementation functions to corresponding Sketch functions (e.g. \TEDIT.ONECHAR.FORWARD would map to SKETCH.ONECHAR.FORWARD).

@rmkaplan
Copy link
Contributor Author

rmkaplan commented Nov 8, 2025

The backspace should now work

@pamoroso
Copy link
Contributor

pamoroso commented Nov 9, 2025

With the latest commits up to f9a3ea6 Backspace works as expected but Del still moves the caret to the right.

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.

5 participants