Replies: 20 comments 7 replies
-
You should load TEDIT-DCL in current releaseTedit, TEDIT-EXPORTS.ALL (in new Tedit = unmerged 4th round)). Code that you write should have (DECLARE: DONTCOPY ***@***.*** (FILES …))).
But I would like to discourage direct access to internal fields, unless there is no functional interface to support a new capability. It creates dependencies on the internals of the implementation some of which are subject to change, making that new capability essentially part of the Tedit implementation that needs to be tracked as declarations and macros get updated.
… On Feb 29, 2024, at 5:01 AM, Paolo Amoroso ***@***.***> wrote:
How do I access the TEXTOBJ of a TEXTSTREAM?
Suppose I create this TEXTSTREAM:
(SETQ TS (OPENTEXTSTREAM))
Inspecting TS:
textstream.png (view on web) <https://github.com/Interlisp/medley/assets/10342479/2d558399-1562-4faa-8425-6dbc6a0e923e>
reveals that the F3 field holds a TEXTOBJ. So I would expect to retrieve F3 with:
(fetch (TEXTSTREAM F3) of TS)
but I get this error:
no such record path
at ... (TEXTSTREAM F3) of TS)
in (fetch (TEXTSTREAM F3) of TS)
In CLISPEXPANSION:
Can't CLISP expand expression (fetch (TEXTSTREAM F3) of TS).
textstream-error.png (view on web) <https://github.com/Interlisp/medley/assets/10342479/d87bf269-4cbf-4b0b-88cd-a2bab59b91b9>
(TYPENAME TS) returns STREAM and not TEXTSTREAM, which adds to my confusion. What am I doing wrong? What's the correct field path? I found no clues in the TEdit code.
By the way, isn't the F3 field supposed to be called TEXTOBJ? Should I load any definitions files?
—
Reply to this email directly, view it on GitHub <#1564>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJJRMTAQ332H4M4NYQTYV4TCHAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZWGI4TEMBTG4>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
-
That returns the TEXTOBJ for a TEXTSTREAM (or a Tedit window, process, etc.) but then you have to know how to access its fields. In 4th round, TEXTOBJ also has a NOERROR flag, so it can be used as a test.
… On Feb 29, 2024, at 8:30 AM, Nick Briggs ***@***.***> wrote:
I think calling (TEXTOBJ TS) is the approved method.
—
Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJNZUOE2LLPY5HI25DLYV5LQVAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZTGI2TQ>.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
Oh, you're right, my misread. But it is the same issue: the fields that tedit uses to record information in the stream datatype are internal. And once you get a TEXTOBJ from a text stream, those fields also should be considered as internal.
Before 4th round, some functions were specified as taking a TEXTSTREAM, some as taking a TEXTOBJ, and callers had to make that distinction. I have tried to put in back-and-forth coercions whenever I have run across them.
… On Feb 29, 2024, at 8:41 AM, Nick Briggs ***@***.***> wrote:
Wasn't that the question Paolo asked? It would be helpful to know what Paolo needed to do with the TEXTOBJ (I'm guessing most TEdit things will operate on either the TEXTSTREAM or the TEXTOBJ ?)
—
Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJOFBXPGI4OPV3Z6WFDYV5M3TAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZTGQYDA>.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
And BTW, you need the declaration files in either case.
… On Feb 29, 2024, at 8:47 AM, Ron Kaplan ***@***.***> wrote:
Oh, you're right, my misread. But it is the same issue: the fields that tedit uses to record information in the stream datatype are internal. And once you get a TEXTOBJ from a text stream, those fields also should be considered as internal.
Before 4th round, some functions were specified as taking a TEXTSTREAM, some as taking a TEXTOBJ, and callers had to make that distinction. I have tried to put in back-and-forth coercions whenever I have run across them.
> On Feb 29, 2024, at 8:41 AM, Nick Briggs ***@***.***> wrote:
>
>
> Wasn't that the question Paolo asked? It would be helpful to know what Paolo needed to do with the TEXTOBJ (I'm guessing most TEdit things will operate on either the TEXTSTREAM or the TEXTOBJ ?)
>
> —
> Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJOFBXPGI4OPV3Z6WFDYV5M3TAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZTGQYDA>.
> You are receiving this because you commented.
>
|
Beta Was this translation helpful? Give feedback.
-
I would actually prefer not to access the internals but in the documentation of the programmer's interface to TEdit I can't find what I need. In a program-controlled TEdit window containing some text I'd like to replace all the text with some other text. I thought of doing this by selecting the text with |
Beta Was this translation helpful? Give feedback.
-
Do you really mean all the text, complete, from beginning to end? If so, select from 1 to |
Beta Was this translation helpful? Give feedback.
-
PL TEDIT-DCL would show you the propety list of that atom. If it’s already loaded, you should see some properties about the file (date, how it was loaded).
I don’t use online, maybe the online file system doesn’t have that file? should be in library/tedit.
… On Feb 29, 2024, at 9:07 AM, Paolo Amoroso ***@***.***> wrote:
In Medley Online (FILESLOAD TEDIT-DCL) returns NIL. Does this mean the file is already loaded?
—
Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJNHLZTCNW3IA6UJMZDYV5P4BAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZTG4ZDK>.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
I don’t think there is a TEDIT.REPLACE (although there could be). But you should be able to get that effect by a combination of TEDIT.SETSEL, TEDIT.DELETE, TEDIT.INSERT. After the delete, the selection should reduce to a point selection where you want the insertion to go.
… On Feb 29, 2024, at 9:06 AM, Paolo Amoroso ***@***.***> wrote:
I would actually prefer not to access the internals but in the documentation of the programmer's interface to TEdit I can't find what I need. In a program-controlled TEdit window containing some text I'd like to replace all the text with some other text.
I thought of doing this by selecting the text with TEDIT.SETSEL and then calling TEDIT.DELETE on the selection. But both function require the length of the text, which is the TEXTLEN field of TEXTOBJ. Hence the need to access the TEXTOBJ of a TEXTSTREAM.
—
Reply to this email directly, view it on GitHub <#1564 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJN6SUPBIDSAKI2BIATYV5PYBAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZTG4YDK>.
You are receiving this because you commented.
|
Beta Was this translation helpful? Give feedback.
-
If he knows what he’s looking for, he can use TEDIT.FIND, although the way it is defined and documented and implemented, it returns the character position of the start instead of a selection for the whole thing. Or a pair of first and last characters for a wildcard search. So it requires a little fooling around. Woulld have been better if it always returned a selection.
… On Feb 29, 2024, at 10:31 AM, Nick Briggs ***@***.***> wrote:
@rmkaplan <https://github.com/rmkaplan> -- yeah, but what he subsequently asked was how to find the length to pass to TEDIT.SETSEL, and since he proposed looking at the length in the TEXTOBJ I assume the desired length was the length of all the text, hence the suggestion to use GETEOFPTR on the stream.
—
Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJJPCWGK6SLQLFARHKDYV5ZXDAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZUGQ2TA>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
This is from a Masterscope (the newsletter) submission from Fred Brundick. It replaces all “hard” carriage returns with a “soft” carriage return. Replace the bits that are the HardReturn/SoftReturn with what you want to swap out. It uses a combination of TEDIT.FIND, TEDIT.DELETE, and TEDIT.INSERT.
(DEFINEQ
(FREDIT.SOFT.RETURNS
(LAMBDA (Stream Object Selection) ; Edited 3-Feb-88 09:28 by FSBRN
;; This function converts all "hard" carriage returns in a
;; selection to "soft" or "meta" carriage returns.
;; The intended use is for formatting normal ASCII files that end
;; each line with a hard carriage return.
;; The TEdit substitute command may not be used because the find
;; and substitute commands strip meta bits.
;; This function should be called from the keyboard.
;; Install it with
;; (TEDIT.SETFUNCTION (CHARCODE xxx) 'FREDIT.SOFT.RETURNS)
;; Known bug: TEDIT.FIND ignores meta bits, so this function
will
;; treat all soft carriage returns as if they were hard ret
urns.
;; This does not hurt anything, but the function may make mo
re
;; changes than are really required.
(PROG* ((First# (fetch CH# of Selection))
(End# (SUB1 (fetch CHLIM of Selection)))
(SelLength (fetch DCH of Selection))
(PromptWin (fetch PROMPTWINDOW of Object))
(Start# First#)
(NumChanges 0)
(Find#)
(HardReturn (ALLOCSTRING 1 13))
(SoftReturn (ALLOCSTRING 1 (PLUS \KEYBOARD.META 13))
))
;; make sure a selection has been made
(if (ZEROP SelLength) then
(CLEARW PromptWin)
(PRIN1 "Make a selection first." PromptWin)
(RETURN))
;; search for carriage return and replace with
;; meta-charriage return until no more CRs are found
;; in selection
(while (SETQ Find# (TEDIT.FIND Stream HardReturn Star
t# End#))
do
(TEDIT.DELETE Stream Find# 1)
(TEDIT.INSERT Stream SoftReturn Find#)
(SETQ Start# (ADD1 Find#))
(SETQ NumChanges (ADD1 NumChanges)))
;; re-select original selection
(TEDIT.SETSEL Stream First# SelLength 'LEFT)
;; tell user how many changes were made
(CLEARW PromptWin)
(printout PromptWin NumChanges " Carriage return"
(if (EQ NumChanges 1)
then " "
else "s ")
"converted.")
(RETURN NumChanges))
)))
… On Feb 29, 2024, at 12:45 PM, rmkaplan ***@***.***> wrote:
If he knows what he’s looking for, he can use TEDIT.FIND, although the way it is defined and documented and implemented, it returns the character position of the start instead of a selection for the whole thing. Or a pair of first and last characters for a wildcard search. So it requires a little fooling around. Woulld have been better if it always returned a selection.
> On Feb 29, 2024, at 10:31 AM, Nick Briggs ***@***.***> wrote:
>
>
> @rmkaplan <https://github.com/rmkaplan> -- yeah, but what he subsequently asked was how to find the length to pass to TEDIT.SETSEL, and since he proposed looking at the length in the TEXTOBJ I assume the desired length was the length of all the text, hence the suggestion to use GETEOFPTR on the stream.
>
> —
> Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJJPCWGK6SLQLFARHKDYV5ZXDAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZUGQ2TA>.
> You are receiving this because you were mentioned.
>
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
This is a good illustration of how to put these together, although probably it could be cleaned up a bit.
But for this particular scenario, what is a “soft” carriage return? The Tedit line formatter treats Meta,EOL as a character that ends a line but doesn’t end a paragraph, so that e.g. you only see line-leading and not also pre-paragraph leading. Is that it?
I have wanted a different transformation, one that reduces double file EOL’s into single (paragraph-marking) Tedit EOLs and then reduces the remaining EOL’s into spaces So that paragraph-internal lines would flow according to the margins.
I don’t know that TEDIT.SUBSTITUTE (or any of the other functions) do anything special with the meta bit, once you get them into a string (at least not in 4th round). It’s hard to get them literally when you try to type them, though. Another issues with TTYINPROMPTFORWORD: how to escape a meta character.
… On Feb 29, 2024, at 1:33 PM, Arun Welch ***@***.***> wrote:
This is from a Masterscope (the newsletter) submission from Fred Brundick. It replaces all “hard” carriage returns with a “soft” carriage return. Replace the bits that are the HardReturn/SoftReturn with what you want to swap out. It uses a combination of TEDIT.FIND, TEDIT.DELETE, and TEDIT.INSERT.
(DEFINEQ
(FREDIT.SOFT.RETURNS
(LAMBDA (Stream Object Selection) ; Edited 3-Feb-88 09:28 by FSBRN
;; This function converts all "hard" carriage returns in a
;; selection to "soft" or "meta" carriage returns.
;; The intended use is for formatting normal ASCII files that end
;; each line with a hard carriage return.
;; The TEdit substitute command may not be used because the find
;; and substitute commands strip meta bits.
;; This function should be called from the keyboard.
;; Install it with
;; (TEDIT.SETFUNCTION (CHARCODE xxx) 'FREDIT.SOFT.RETURNS)
;; Known bug: TEDIT.FIND ignores meta bits, so this function
will
;; treat all soft carriage returns as if they were hard ret
urns.
;; This does not hurt anything, but the function may make mo
re
;; changes than are really required.
(PROG* ((First# (fetch CH# of Selection))
(End# (SUB1 (fetch CHLIM of Selection)))
(SelLength (fetch DCH of Selection))
(PromptWin (fetch PROMPTWINDOW of Object))
(Start# First#)
(NumChanges 0)
(Find#)
(HardReturn (ALLOCSTRING 1 13))
(SoftReturn (ALLOCSTRING 1 (PLUS \KEYBOARD.META 13))
))
;; make sure a selection has been made
(if (ZEROP SelLength) then
(CLEARW PromptWin)
(PRIN1 "Make a selection first." PromptWin)
(RETURN))
;; search for carriage return and replace with
;; meta-charriage return until no more CRs are found
;; in selection
(while (SETQ Find# (TEDIT.FIND Stream HardReturn Star
t# End#))
do
(TEDIT.DELETE Stream Find# 1)
(TEDIT.INSERT Stream SoftReturn Find#)
(SETQ Start# (ADD1 Find#))
(SETQ NumChanges (ADD1 NumChanges)))
;; re-select original selection
(TEDIT.SETSEL Stream First# SelLength 'LEFT)
;; tell user how many changes were made
(CLEARW PromptWin)
(printout PromptWin NumChanges " Carriage return"
(if (EQ NumChanges 1)
then " "
else "s ")
"converted.")
(RETURN NumChanges))
)))
> On Feb 29, 2024, at 12:45 PM, rmkaplan ***@***.***> wrote:
>
>
> If he knows what he’s looking for, he can use TEDIT.FIND, although the way it is defined and documented and implemented, it returns the character position of the start instead of a selection for the whole thing. Or a pair of first and last characters for a wildcard search. So it requires a little fooling around. Woulld have been better if it always returned a selection.
>
> > On Feb 29, 2024, at 10:31 AM, Nick Briggs ***@***.***> wrote:
> >
> >
> > @rmkaplan <https://github.com/rmkaplan> -- yeah, but what he subsequently asked was how to find the length to pass to TEDIT.SETSEL, and since he proposed looking at the length in the TEXTOBJ I assume the desired length was the length of all the text, hence the suggestion to use GETEOFPTR on the stream.
> >
> > —
> > Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJJPCWGK6SLQLFARHKDYV5ZXDAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZUGQ2TA>.
> > You are receiving this because you were mentioned.
> >
>
> —
> Reply to this email directly, view it on GitHub, or unsubscribe.
> You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
—
Reply to this email directly, view it on GitHub <#1564 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJPTQHBTMUYKMTGGP3TYV6PB7AVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZVHE3DC>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
Fred’s reason for writing this:
Recently I downloaded a couple of report drafts from a UN*X machine to
my 1109 so I could use TEdit to format and print the reports. Since
the reports were ASCII files each line ended with a carriage return,
which I easily deleted with TEdit's "substitute" command. However,
there were several sections where I wanted to keep the original line
breaks but at the same time treat the entire section like a single
paragraph. The TEdit manual says you can do this by entering a
meta-return (Open + Return) instead of a "normal" return; what the
manual doesn't tell you is that the "find" and "substitute" commands
ignore the meta bits in a character.
The following Interlisp function is my solution to the problem. It
will be called when you press a certain key while you are editing a
file. I chose meta-equals but any available meta or control key may
be used. First select the text that contains carriage returns you
want to change, then press meta-equals. The text will move around as
the returns are deleted and replaced with meta-returns. When the
function is done the original text will be re-selected and the TEdit
prompt window will tell you how many changes were made.
… On Feb 29, 2024, at 4:13 PM, rmkaplan ***@***.***> wrote:
This is a good illustration of how to put these together, although probably it could be cleaned up a bit.
But for this particular scenario, what is a “soft” carriage return? The Tedit line formatter treats Meta,EOL as a character that ends a line but doesn’t end a paragraph, so that e.g. you only see line-leading and not also pre-paragraph leading. Is that it?
I have wanted a different transformation, one that reduces double file EOL’s into single (paragraph-marking) Tedit EOLs and then reduces the remaining EOL’s into spaces So that paragraph-internal lines would flow according to the margins.
I don’t know that TEDIT.SUBSTITUTE (or any of the other functions) do anything special with the meta bit, once you get them into a string (at least not in 4th round). It’s hard to get them literally when you try to type them, though. Another issues with TTYINPROMPTFORWORD: how to escape a meta character.
> On Feb 29, 2024, at 1:33 PM, Arun Welch ***@***.***> wrote:
>
>
> This is from a Masterscope (the newsletter) submission from Fred Brundick. It replaces all “hard” carriage returns with a “soft” carriage return. Replace the bits that are the HardReturn/SoftReturn with what you want to swap out. It uses a combination of TEDIT.FIND, TEDIT.DELETE, and TEDIT.INSERT.
>
> (DEFINEQ
> (FREDIT.SOFT.RETURNS
> (LAMBDA (Stream Object Selection) ; Edited 3-Feb-88 09:28 by FSBRN
>
> ;; This function converts all "hard" carriage returns in a
> ;; selection to "soft" or "meta" carriage returns.
> ;; The intended use is for formatting normal ASCII files that end
> ;; each line with a hard carriage return.
> ;; The TEdit substitute command may not be used because the find
> ;; and substitute commands strip meta bits.
>
> ;; This function should be called from the keyboard.
> ;; Install it with
> ;; (TEDIT.SETFUNCTION (CHARCODE xxx) 'FREDIT.SOFT.RETURNS)
>
> ;; Known bug: TEDIT.FIND ignores meta bits, so this function
> will
> ;; treat all soft carriage returns as if they were hard ret
> urns.
> ;; This does not hurt anything, but the function may make mo
> re
> ;; changes than are really required.
>
> (PROG* ((First# (fetch CH# of Selection))
> (End# (SUB1 (fetch CHLIM of Selection)))
> (SelLength (fetch DCH of Selection))
> (PromptWin (fetch PROMPTWINDOW of Object))
> (Start# First#)
> (NumChanges 0)
> (Find#)
> (HardReturn (ALLOCSTRING 1 13))
> (SoftReturn (ALLOCSTRING 1 (PLUS \KEYBOARD.META 13))
> ))
>
> ;; make sure a selection has been made
> (if (ZEROP SelLength) then
> (CLEARW PromptWin)
> (PRIN1 "Make a selection first." PromptWin)
> (RETURN))
>
> ;; search for carriage return and replace with
> ;; meta-charriage return until no more CRs are found
> ;; in selection
> (while (SETQ Find# (TEDIT.FIND Stream HardReturn Star
> t# End#))
> do
> (TEDIT.DELETE Stream Find# 1)
> (TEDIT.INSERT Stream SoftReturn Find#)
> (SETQ Start# (ADD1 Find#))
> (SETQ NumChanges (ADD1 NumChanges)))
>
> ;; re-select original selection
> (TEDIT.SETSEL Stream First# SelLength 'LEFT)
>
> ;; tell user how many changes were made
> (CLEARW PromptWin)
> (printout PromptWin NumChanges " Carriage return"
> (if (EQ NumChanges 1)
> then " "
> else "s ")
> "converted.")
> (RETURN NumChanges))
> )))
>
> > On Feb 29, 2024, at 12:45 PM, rmkaplan ***@***.***> wrote:
> >
> >
> > If he knows what he’s looking for, he can use TEDIT.FIND, although the way it is defined and documented and implemented, it returns the character position of the start instead of a selection for the whole thing. Or a pair of first and last characters for a wildcard search. So it requires a little fooling around. Woulld have been better if it always returned a selection.
> >
> > > On Feb 29, 2024, at 10:31 AM, Nick Briggs ***@***.***> wrote:
> > >
> > >
> > > @rmkaplan <https://github.com/rmkaplan> -- yeah, but what he subsequently asked was how to find the length to pass to TEDIT.SETSEL, and since he proposed looking at the length in the TEXTOBJ I assume the desired length was the length of all the text, hence the suggestion to use GETEOFPTR on the stream.
> > >
> > > —
> > > Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJJPCWGK6SLQLFARHKDYV5ZXDAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZUGQ2TA>.
> > > You are receiving this because you were mentioned.
> > >
> >
> > —
> > Reply to this email directly, view it on GitHub, or unsubscribe.
> > You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
>
> —
> Reply to this email directly, view it on GitHub <#1564 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJPTQHBTMUYKMTGGP3TYV6PB7AVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZVHE3DC>.
> You are receiving this because you were mentioned.
>
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
He probably had a misleading explanation for why it didn’t work in the obvious way—I think the problem was/is the type-in of metachars, not the interpretation of them once they make it into a search or substitue string. The internal functions don’t “ignore” the meta bits, they never see them.
A more general solution might be to arm a character that slaps the meta bit on to whatever is typed after it, a form of Tedit’s abbreviation expansion. But that takes us back to the fact that the UI interface for find and substitute goes through TTYINPROMPTFORWORD, which as far as we know doesn’t give that kind of control.
But I’m also wondering whether we could create a TEdit stream and process for promptwindow requests (search strings, filenames) instead of TTYIN. Might be easier than understanding how to modify TTYIN for this purpose without screwing up the way it behaves in Exec windows.
… On Feb 29, 2024, at 2:19 PM, Arun Welch ***@***.***> wrote:
Fred’s reason for writing this:
Recently I downloaded a couple of report drafts from a UN*X machine to
my 1109 so I could use TEdit to format and print the reports. Since
the reports were ASCII files each line ended with a carriage return,
which I easily deleted with TEdit's "substitute" command. However,
there were several sections where I wanted to keep the original line
breaks but at the same time treat the entire section like a single
paragraph. The TEdit manual says you can do this by entering a
meta-return (Open + Return) instead of a "normal" return; what the
manual doesn't tell you is that the "find" and "substitute" commands
ignore the meta bits in a character.
The following Interlisp function is my solution to the problem. It
will be called when you press a certain key while you are editing a
file. I chose meta-equals but any available meta or control key may
be used. First select the text that contains carriage returns you
want to change, then press meta-equals. The text will move around as
the returns are deleted and replaced with meta-returns. When the
function is done the original text will be re-selected and the TEdit
prompt window will tell you how many changes were made.
> On Feb 29, 2024, at 4:13 PM, rmkaplan ***@***.***> wrote:
>
>
> This is a good illustration of how to put these together, although probably it could be cleaned up a bit.
>
> But for this particular scenario, what is a “soft” carriage return? The Tedit line formatter treats Meta,EOL as a character that ends a line but doesn’t end a paragraph, so that e.g. you only see line-leading and not also pre-paragraph leading. Is that it?
>
> I have wanted a different transformation, one that reduces double file EOL’s into single (paragraph-marking) Tedit EOLs and then reduces the remaining EOL’s into spaces So that paragraph-internal lines would flow according to the margins.
>
> I don’t know that TEDIT.SUBSTITUTE (or any of the other functions) do anything special with the meta bit, once you get them into a string (at least not in 4th round). It’s hard to get them literally when you try to type them, though. Another issues with TTYINPROMPTFORWORD: how to escape a meta character.
>
> > On Feb 29, 2024, at 1:33 PM, Arun Welch ***@***.***> wrote:
> >
> >
> > This is from a Masterscope (the newsletter) submission from Fred Brundick. It replaces all “hard” carriage returns with a “soft” carriage return. Replace the bits that are the HardReturn/SoftReturn with what you want to swap out. It uses a combination of TEDIT.FIND, TEDIT.DELETE, and TEDIT.INSERT.
> >
> > (DEFINEQ
> > (FREDIT.SOFT.RETURNS
> > (LAMBDA (Stream Object Selection) ; Edited 3-Feb-88 09:28 by FSBRN
> >
> > ;; This function converts all "hard" carriage returns in a
> > ;; selection to "soft" or "meta" carriage returns.
> > ;; The intended use is for formatting normal ASCII files that end
> > ;; each line with a hard carriage return.
> > ;; The TEdit substitute command may not be used because the find
> > ;; and substitute commands strip meta bits.
> >
> > ;; This function should be called from the keyboard.
> > ;; Install it with
> > ;; (TEDIT.SETFUNCTION (CHARCODE xxx) 'FREDIT.SOFT.RETURNS)
> >
> > ;; Known bug: TEDIT.FIND ignores meta bits, so this function
> > will
> > ;; treat all soft carriage returns as if they were hard ret
> > urns.
> > ;; This does not hurt anything, but the function may make mo
> > re
> > ;; changes than are really required.
> >
> > (PROG* ((First# (fetch CH# of Selection))
> > (End# (SUB1 (fetch CHLIM of Selection)))
> > (SelLength (fetch DCH of Selection))
> > (PromptWin (fetch PROMPTWINDOW of Object))
> > (Start# First#)
> > (NumChanges 0)
> > (Find#)
> > (HardReturn (ALLOCSTRING 1 13))
> > (SoftReturn (ALLOCSTRING 1 (PLUS \KEYBOARD.META 13))
> > ))
> >
> > ;; make sure a selection has been made
> > (if (ZEROP SelLength) then
> > (CLEARW PromptWin)
> > (PRIN1 "Make a selection first." PromptWin)
> > (RETURN))
> >
> > ;; search for carriage return and replace with
> > ;; meta-charriage return until no more CRs are found
> > ;; in selection
> > (while (SETQ Find# (TEDIT.FIND Stream HardReturn Star
> > t# End#))
> > do
> > (TEDIT.DELETE Stream Find# 1)
> > (TEDIT.INSERT Stream SoftReturn Find#)
> > (SETQ Start# (ADD1 Find#))
> > (SETQ NumChanges (ADD1 NumChanges)))
> >
> > ;; re-select original selection
> > (TEDIT.SETSEL Stream First# SelLength 'LEFT)
> >
> > ;; tell user how many changes were made
> > (CLEARW PromptWin)
> > (printout PromptWin NumChanges " Carriage return"
> > (if (EQ NumChanges 1)
> > then " "
> > else "s ")
> > "converted.")
> > (RETURN NumChanges))
> > )))
> >
> > > On Feb 29, 2024, at 12:45 PM, rmkaplan ***@***.***> wrote:
> > >
> > >
> > > If he knows what he’s looking for, he can use TEDIT.FIND, although the way it is defined and documented and implemented, it returns the character position of the start instead of a selection for the whole thing. Or a pair of first and last characters for a wildcard search. So it requires a little fooling around. Woulld have been better if it always returned a selection.
> > >
> > > > On Feb 29, 2024, at 10:31 AM, Nick Briggs ***@***.***> wrote:
> > > >
> > > >
> > > > @rmkaplan <https://github.com/rmkaplan> -- yeah, but what he subsequently asked was how to find the length to pass to TEDIT.SETSEL, and since he proposed looking at the length in the TEXTOBJ I assume the desired length was the length of all the text, hence the suggestion to use GETEOFPTR on the stream.
> > > >
> > > > —
> > > > Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJJPCWGK6SLQLFARHKDYV5ZXDAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZUGQ2TA>.
> > > > You are receiving this because you were mentioned.
> > > >
> > >
> > > —
> > > Reply to this email directly, view it on GitHub, or unsubscribe.
> > > You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
> >
> > —
> > Reply to this email directly, view it on GitHub <#1564 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJPTQHBTMUYKMTGGP3TYV6PB7AVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZVHE3DC>.
> > You are receiving this because you were mentioned.
> >
>
> —
> Reply to this email directly, view it on GitHub, or unsubscribe.
> You are receiving this because you commented.Message ID: ***@***.***>
—
Reply to this email directly, view it on GitHub <#1564 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJKJ54RG5MSXTYR2NTLYV6UPFAVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMZWGMYTA>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
This is only tangentially related, but if you do (in an Interlisp exec), you see...
So if |
Beta Was this translation helpful? Give feedback.
-
Thanks all! I indeed want to delete the whole text, so The only subtle detail to remember is to add 1 to the value |
Beta Was this translation helpful? Give feedback.
-
I’m afraid not. That was from a submission that didn’t make it into a newsletter, XAIS closed before the issue it was going to go into and Envos didn’t have the resources to keep publishing it.
… On Mar 1, 2024, at 7:50 AM, Paolo Amoroso ***@***.***> wrote:
@Anzus The code you shared is not in any of the only threee issues of the MASTERSCOPE newsletter available at Bitsavers. Do you have more issues?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
It is 1, in all versions of Tedit.
This is the original and unfortunate confusion between Tedit’s simulation of file pointers (starting at 0) when it treats the text as a stream, and character numbers (starting at 1) for most Tedit operations. Tedit is basically 1-origin, like Interlisp strings and arrays.
That’s why you have to worry about adding or subtracting 1 when you are moving between SETFILEPTR/GETFILEPTR and Tedit selections and character numbers.
Thus, TEDIT.DELETE, TEDIT.INSERT, TEDIT.SETSEL,... take character numbers. But most interface functions do an internal coercion of anything less than 1 to 1, so you wouldn’t notice the difference in this case.
They currently also coerce numbers larger than the length down to the actual length.
(It might be more conventient and consistent with NCHARS and other Interlisp character functions if negative numbers were treated always as offsets from the length. In your case you could then do (TEDIT.DELETE TSTREAM 1 -1). In 4th round the new functions TEDIT.RPLCHARCODE and TEDIT.NTHCHARCODE interpret negative numbers in that way, on the model of RPLCHARCODE and NTHCHARCODE. But it might be dangerous to propagate that new convention through all preexisting interface functions.)
… On Mar 2, 2024, at 9:46 AM, Paolo Amoroso ***@***.***> wrote:
In TEdit round 4 is the second argument of TEDIT.DELETE 1? What about the current TEdit? I would have thought 0 instead of 1.
—
Reply to this email directly, view it on GitHub <#1564 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQSTUJL7CAKLQ2UMAJ4DMW3YWIF57AVCNFSM6AAAAABD74VFYGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMNJTGIYTO>.
You are receiving this because you were mentioned.
|
Beta Was this translation helpful? Give feedback.
-
On finding the length of a TEXTSTREAM: In 4th round TEdit there is also the function TEDIT.NCHARS (as well as TEDIT.NTHCHARCIODE). I think TEDIT.CHARS, GETEOFPTR and (TEXTPROP TSTREAM 'LENGTH) are functionally equivalent. As part of getting Notecards out of the internals of TEdit, I converted all of Notecards to use TEDIT.NCHARS - seeing as it seems like TEDIT.NCHARS assumes the least about the internals of TEdit. |
Beta Was this translation helpful? Give feedback.
-
Apparently I lied. I just found:
Volume 2, number 1
Volume 3, numbers 1, 2 and 3
One issue of Venue’s “News for Medley Users”.
I’ll scan them in.
… On Mar 1, 2024, at 10:56 AM, Arun Welch ***@***.***> wrote:
I’m afraid not. That was from a submission that didn’t make it into a newsletter, XAIS closed before the issue it was going to go into and Envos didn’t have the resources to keep publishing it.
> On Mar 1, 2024, at 7:50 AM, Paolo Amoroso ***@***.***> wrote:
>
>
> @Anzus The code you shared is not in any of the only threee issues of the MASTERSCOPE newsletter available at Bitsavers. Do you have more issues?
> —
> Reply to this email directly, view it on GitHub, or unsubscribe.
> You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
On Tue, Sep 24, 2024 at 12:30 AM Arun Welch ***@***.***> wrote:
I’ll scan them in.
That's great, thanks.
Paolo
--
Paolo Amoroso <https://paoloamoroso.com> | Blog
<https://journal.paoloamoroso.com> | Mastodon
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
How do I access the
TEXTOBJ
of aTEXTSTREAM
?Suppose I create this
TEXTSTREAM
:Inspecting
TS
:reveals that the
F3
field holds aTEXTOBJ
. So I would expect to retrieveF3
with:but I get this error:
(TYPENAME TS)
returnsSTREAM
and notTEXTSTREAM
, which adds to my confusion. What am I doing wrong? What's the correct field path? I found no clues in the TEdit code.By the way, isn't the
F3
field supposed to be calledTEXTOBJ
? Should I load any definitions files?Beta Was this translation helpful? Give feedback.
All reactions