Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
651 changes: 349 additions & 302 deletions library/tedit/TEDIT

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions library/tedit/TEDIT-CHAT
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)

(FILECREATED "23-Dec-2023 09:24:21" {WMEDLEY}<library>TEDIT>TEDIT-CHAT.;14 12223
(FILECREATED " 2-May-2024 18:09:26" {WMEDLEY}<library>tedit>TEDIT-CHAT.;15 12254

:EDIT-BY rmk

:CHANGES-TO (VARS TEDIT-CHATCOMS)
(FNS TEDITSTREAM.INIT TEDIT.DISPLAYTEXT TEDITCHAT.CHARFN)
:CHANGES-TO (FNS TEDITCHAT.CHARFN)

:PREVIOUS-DATE " 6-Apr-2023 21:40:07" {WMEDLEY}<library>tedit>TEDIT-CHAT.;9)
:PREVIOUS-DATE "23-Dec-2023 09:24:21" {WMEDLEY}<library>tedit>TEDIT-CHAT.;14)


(PRETTYCOMPRINT TEDIT-CHATCOMS)
Expand Down Expand Up @@ -71,16 +70,17 @@
(replace (CHAT.STATE HELD) of STATE with NIL])

(TEDITCHAT.CHARFN
[LAMBDA (CH CHAT.STATE) (* ; "Edited 22-Dec-2023 23:57 by rmk")
[LAMBDA (CH CHAT.STATE) (* ; "Edited 2-May-2024 18:09 by rmk")
(* ; "Edited 22-Dec-2023 23:57 by rmk")
(* ; "Edited 18-Mar-2023 20:08 by rmk")
(* ; "Edited 12-Jun-90 18:00 by mitani")
(LET [(TEXTOBJ (TEXTOBJ (fetch (CHAT.STATE TEXTSTREAM) of CHAT.STATE]
(\CARET.DOWN (FGETTOBJ TEXTOBJ DS))
(SELCHARQ CH
(BS (\TEDIT.CHARDELETE TEXTOBJ (FGETTOBJ TEXTOBJ SEL)))
(LF NIL)
(BOUT (FGETTOBJ TEXTOBJ STREAMHINT)
CH])
(LET* ((TSTREAM (fetch (CHAT.STATE TEXTSTREAM) of CHAT.STATE))
(TEXTOBJ (TEXTOBJ TSTREAM)))
(\CARET.DOWN (FGETTOBJ TEXTOBJ DS))
(SELCHARQ CH
(BS (\TEDIT.CHARDELETE TEXTOBJ (FGETTOBJ TEXTOBJ SEL)))
(LF NIL)
(BOUT TSTREAM CH])
)


Expand Down Expand Up @@ -212,6 +212,6 @@
CHATDECLS)
)
(DECLARE%: DONTCOPY
(FILEMAP (NIL (960 4404 (TEDITSTREAM.INIT 970 . 1897) (TEDITCHAT.MENUFN 1899 . 3735) (TEDITCHAT.CHARFN
3737 . 4402)) (4451 11335 (TEDIT.DISPLAYTEXT 4461 . 11333)))))
(FILEMAP (NIL (886 4435 (TEDITSTREAM.INIT 896 . 1823) (TEDITCHAT.MENUFN 1825 . 3661) (TEDITCHAT.CHARFN
3663 . 4433)) (4482 11366 (TEDIT.DISPLAYTEXT 4492 . 11364)))))
STOP
Binary file modified library/tedit/TEDIT-CHAT.LCOM
Binary file not shown.
283 changes: 131 additions & 152 deletions library/tedit/TEDIT-COMMAND

Large diffs are not rendered by default.

Binary file modified library/tedit/TEDIT-COMMAND.LCOM
Binary file not shown.
141 changes: 73 additions & 68 deletions library/tedit/TEDIT-FILE

Large diffs are not rendered by default.

Binary file modified library/tedit/TEDIT-FILE.LCOM
Binary file not shown.
99 changes: 56 additions & 43 deletions library/tedit/TEDIT-FIND
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)

(FILECREATED "17-Mar-2024 12:06:12" {WMEDLEY}<library>tedit>TEDIT-FIND.;102 30083
(FILECREATED " 3-May-2024 07:34:03" {WMEDLEY}<library>tedit>TEDIT-FIND.;108 31239

:EDIT-BY rmk

:CHANGES-TO (FNS \TEDIT.BASICFIND \TEDIT.BASICFIND.BACKWARD \TEDIT.WCFIND.BACKWARD)
:CHANGES-TO (FNS \TEDIT.BASICFIND.BACKWARD \TEDIT.WCFIND.BACKWARD)

:PREVIOUS-DATE "15-Mar-2024 14:10:05" {WMEDLEY}<library>tedit>TEDIT-FIND.;98)
:PREVIOUS-DATE " 2-May-2024 21:42:19" {WMEDLEY}<library>tedit>TEDIT-FIND.;107)


(PRETTYCOMPRINT TEDIT-FINDCOMS)
Expand All @@ -28,7 +28,8 @@
(DEFINEQ

(TEDIT.FIND
[LAMBDA (TEXTOBJ TARGETSTRING START END WILDCARDS?) (* ; "Edited 19-Jun-2023 22:27 by rmk")
[LAMBDA (TSTREAM TARGETSTRING START END WILDCARDS?) (* ; "Edited 24-Apr-2024 23:47 by rmk")
(* ; "Edited 19-Jun-2023 22:27 by rmk")
(* ; "Edited 6-May-2018 17:34 by rmk:")
(* ; "Edited 30-May-91 20:56 by jds")

Expand All @@ -38,26 +39,26 @@

(* ;; "RMK: FIND isn't undoable, FIND-AGAIN is armed on meta-g. No point in hiding a previous actual edit and then having to undo a find in order to undo the intended previous event. Or maybe undoing FIND would put you back where you started?")

(SETQ TEXTOBJ (TEXTOBJ TEXTOBJ))
(SETQ TSTREAM (TEXTSTREAM TSTREAM))
(CL:WHEN TARGETSTRING
(SETQ TARGETSTRING (MKSTRING TARGETSTRING))
(CL:UNLESS END
(SETQ END (TEXTLEN TEXTOBJ)))
(SETQ END (FGETTOBJ (fetch (TEXTSTREAM TEXTOBJ) of TSTREAM)
TEXTLEN)))
(CL:UNLESS START
(SETQ START (TEDIT.GETPOINT TEXTOBJ)))
(SETQ START (TEDIT.GETPOINT TSTREAM)))

(* ;; "* and # are implicitly quoted if not WILDCARDS? This could be handled simply by calling CONS instead of \TEDIT.PARSE.SEARCHSTRING")

(CL:WHEN (ILEQ START END)
(CL:IF WILDCARDS?
(\TEDIT.WCFIND (ffetch (TEXTOBJ STREAMHINT) of TEXTOBJ)
(\TEDIT.PARSE.SEARCHSTRING TARGETSTRING)
(\TEDIT.WCFIND TSTREAM (\TEDIT.PARSE.SEARCHSTRING TARGETSTRING)
START END)
(CAR (\TEDIT.BASICFIND (ffetch (TEXTOBJ STREAMHINT) of TEXTOBJ)
TARGETSTRING START END)))))])
(CAR (\TEDIT.BASICFIND TSTREAM TARGETSTRING START END)))))])

(TEDIT.FIND.BACKWARD
[LAMBDA (TEXTOBJ TARGETSTRING START END WILDCARDS? AGAIN) (* ; "Edited 12-Jul-2023 08:24 by rmk")
[LAMBDA (TSTREAM TARGETSTRING START END WILDCARDS? AGAIN) (* ; "Edited 24-Apr-2024 23:43 by rmk")
(* ; "Edited 12-Jul-2023 08:24 by rmk")
(* ; "Edited 20-Jun-2023 12:12 by rmk")
(* ; "Edited 18-Jun-2023 23:43 by rmk")
(* ; "Edited 30-May-91 19:17 by jds")
Expand All @@ -66,23 +67,22 @@

(* ;; "If WILDCARDS?, the value is the pair (MATCHSTART MATCHEND) for that match, since the caller doesn't know the length. But if not WILDCARDS?, just the match-start, since the caller knows the match is (NCHARS TARGETSTRING) long. This is quirky, but that's the way it is documented.")

(SETQ TEXTOBJ (TEXTOBJ TEXTOBJ))
(SETQ TSTREAM (TEXTSTREAM TSTREAM))
(CL:WHEN [AND TARGETSTRING (NEQ 0 (NCHARS (SETQ TARGETSTRING (MKSTRING TARGETSTRING]
(SETQ START (IMAX 1 (OR START 1)))
(SETQ END (IMIN (OR END (SUB1 (TEDIT.GETPOINT TEXTOBJ)))
(TEXTLEN TEXTOBJ)))
(SETQ END (IMIN (OR END (SUB1 (TEDIT.GETPOINT TSTREAM)))
(FGETTOBJ (fetch (TEXTSTREAM TEXTOBJ) of TSTREAM)
TEXTLEN)))
(CL:WHEN AGAIN

(* ;; "Assume that we aren't interested in another match at the current position.")

(ADD END -1))
(CL:WHEN (ILEQ START END)
(CL:IF WILDCARDS?
(\TEDIT.WCFIND.BACKWARD (ffetch (TEXTOBJ STREAMHINT) of TEXTOBJ)
(DREVERSE (\TEDIT.PARSE.SEARCHSTRING TARGETSTRING))
(\TEDIT.WCFIND.BACKWARD TSTREAM (DREVERSE (\TEDIT.PARSE.SEARCHSTRING TARGETSTRING))
START END)
(CAR (\TEDIT.BASICFIND.BACKWARD (ffetch (TEXTOBJ STREAMHINT) of TEXTOBJ)
TARGETSTRING START END)))))])
(CAR (\TEDIT.BASICFIND.BACKWARD TSTREAM TARGETSTRING START END)))))])

(TEDIT.SUBSTITUTE
[LAMBDA (TEXTSTREAM PATTERN REPLACEMENT CONFIRM?) (* ; "Edited 15-Mar-2024 14:09 by rmk")
Expand Down Expand Up @@ -307,16 +307,15 @@
(DEFINEQ

(\TEDIT.WCFIND
[LAMBDA (TSTREAM TARGETLIST START END HITSTART ANCHORED) (* ; "Edited 19-Jun-2023 23:50 by rmk")
[LAMBDA (TSTREAM TARGETLIST START END HITSTART ANCHORED) (* ; "Edited 2-May-2024 21:41 by rmk")
(* ; "Edited 29-Apr-2024 20:15 by rmk")
(* ; "Edited 19-Jun-2023 23:50 by rmk")

(* ;; "Returns the (start end) pair of a match possibly with wild cards, where HITSTART is the first character of such a match")

(CL:UNLESS (IGREATERP START END)
[LET (RESULT)
(COND
((NULL TARGETLIST) (* ; "Final match")
(LIST (OR HITSTART (SUB1 START))
(SUB1 START)))
[(EQ '%# (CAR TARGETLIST)) (* ;
 "Single-char wildcard, next segment is anchored ")
(OR (\TEDIT.WCFIND TSTREAM (CDR TARGETLIST)
Expand All @@ -338,10 +337,17 @@
((SETQ RESULT (\TEDIT.BASICFIND TSTREAM (CAR TARGETLIST)
START END ANCHORED)) (* ;
 "Matched a string segment, keep going")
(\TEDIT.WCFIND TSTREAM (CDR TARGETLIST)
(ADD1 (CADR RESULT))
END
(OR HITSTART (CAR RESULT])])
(if (CDR TARGETLIST)
then (\TEDIT.WCFIND TSTREAM (CDR TARGETLIST)
(ADD1 (CADR RESULT))
END
(OR HITSTART (CAR RESULT)))
elseif (IEQP END (CADR RESULT))
then (* ; "Final match")
(LIST (OR (CAR RESULT)
(SUB1 START))
(CADR RESULT))
else RESULT])])

(\TEDIT.BASICFIND
[LAMBDA (TSTREAM TARGETSTRING START END ANCHORED) (* ; "Edited 17-Mar-2024 12:06 by rmk")
Expand All @@ -367,16 +373,15 @@
do (RETURN (LIST ANCHOR (IPLUS ANCHOR (SUB1 NCHARS])

(\TEDIT.WCFIND.BACKWARD
[LAMBDA (TSTREAM TARGETLIST START END HITEND ANCHORED) (* ; "Edited 17-Mar-2024 11:59 by rmk")
[LAMBDA (TSTREAM TARGETLIST START END HITEND ANCHORED) (* ; "Edited 3-May-2024 07:11 by rmk")
(* ; "Edited 29-Apr-2024 20:45 by rmk")
(* ; "Edited 17-Mar-2024 11:59 by rmk")
(* ; "Edited 20-Jun-2023 13:52 by rmk")

(* ;; "Returns the (start end) pair of a match possibly with wild cards, where HITEND is the last character of such a match")

(LET (RESULT)
(COND
((NULL TARGETLIST) (* ; "Final match")
(LIST (ADD1 (\TEDIT.TEXTGETFILEPTR TSTREAM))
(OR HITEND END)))
[(EQ '%# (CAR TARGETLIST)) (* ;
 "Single-char wildcard, next segment is anchored ")
(OR (\TEDIT.WCFIND.BACKWARD TSTREAM (CDR TARGETLIST)
Expand All @@ -398,13 +403,20 @@
((SETQ RESULT (\TEDIT.BASICFIND.BACKWARD TSTREAM (CAR TARGETLIST)
START END ANCHORED)) (* ;
 "Matched a string segment, keep going")
(\TEDIT.WCFIND.BACKWARD TSTREAM (CDR TARGETLIST)
START
(SUB1 (CAR RESULT))
(OR HITEND (CADR RESULT])
(if (CDR TARGETLIST)
then (\TEDIT.WCFIND.BACKWARD TSTREAM (CDR TARGETLIST)
START
(SUB1 (CAR RESULT))
(OR HITEND (CADR RESULT)))
elseif (IEQP END (CADR RESULT))
then (* ; "Final match")
(LIST (ADD1 (\TEDIT.TEXTGETFILEPTR TSTREAM))
(OR HITEND (CADR RESULT)))
else RESULT])

(\TEDIT.BASICFIND.BACKWARD
[LAMBDA (TSTREAM TARGETSTRING START END ANCHORED) (* ; "Edited 17-Mar-2024 12:06 by rmk")
[LAMBDA (TSTREAM TARGETSTRING START END ANCHORED) (* ; "Edited 3-May-2024 07:33 by rmk")
(* ; "Edited 17-Mar-2024 12:06 by rmk")
(* ; "Edited 12-Jul-2023 08:14 by rmk")
(* ; "Edited 23-Apr-2023 12:42 by rmk")

Expand Down Expand Up @@ -439,18 +451,19 @@
(CL:WHEN ANCHORED (* ; "Anchored at END, didn't match")
(RETURN NIL))
(SETQ ANCHOR (SUB1 END))
(SETQ LASTANCHOR (IPLUS START NCHARS1)) eachtime (\TEDIT.TEXTSETFILEPTR TSTREAM ANCHOR)
(SETQ LASTANCHOR (IPLUS START NCHARS1 -1)) eachtime (\TEDIT.TEXTSETFILEPTR TSTREAM
ANCHOR)
(* ;
 "The filepos one before the last CHARN match")
(ADD ANCHOR -1)
(add ANCHOR -1)
(* ; "For next attempt")
while (find old ANCHOR from ANCHOR to LASTANCHOR by -1 suchthat (EQ CHARN (
\TEDIT.TEXTBACKFILEPTR
TSTREAM)))
when [OR (EQ NCHARS1 0)
(for I from NCHARS1 to 1 by -1 always (EQ (NTHCHARCODE TARGETSTRING I)
(\TEDIT.TEXTBACKFILEPTR TSTREAM]
do (ADD ANCHOR 1)
do (add ANCHOR 1)
(RETURN (LIST (IDIFFERENCE ANCHOR NCHARS1)
ANCHOR])

Expand Down Expand Up @@ -491,8 +504,8 @@
TARGETSTRING)])
)
(DECLARE%: DONTCOPY
(FILEMAP (NIL (832 18922 (TEDIT.FIND 842 . 2482) (TEDIT.FIND.BACKWARD 2484 . 4297) (TEDIT.SUBSTITUTE
4299 . 14915) (TEDIT.NEXT 14917 . 18920)) (18955 30060 (\TEDIT.WCFIND 18965 . 20966) (\TEDIT.BASICFIND
20968 . 22446) (\TEDIT.WCFIND.BACKWARD 22448 . 24507) (\TEDIT.BASICFIND.BACKWARD 24509 . 28037) (
\TEDIT.PARSE.SEARCHSTRING 28039 . 30058)))))
(FILEMAP (NIL (816 19022 (TEDIT.FIND 826 . 2523) (TEDIT.FIND.BACKWARD 2525 . 4397) (TEDIT.SUBSTITUTE
4399 . 15015) (TEDIT.NEXT 15017 . 19020)) (19055 31216 (\TEDIT.WCFIND 19065 . 21521) (\TEDIT.BASICFIND
21523 . 23001) (\TEDIT.WCFIND.BACKWARD 23003 . 25474) (\TEDIT.BASICFIND.BACKWARD 25476 . 29193) (
\TEDIT.PARSE.SEARCHSTRING 29195 . 31214)))))
STOP
Binary file modified library/tedit/TEDIT-FIND.LCOM
Binary file not shown.
Loading