-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDANDEGUI
More file actions
138 lines (105 loc) · 6.65 KB
/
Copy pathDANDEGUI
File metadata and controls
138 lines (105 loc) · 6.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
(DEFINE-FILE-INFO PACKAGE (DEFPACKAGE "DANDEGUI" (USE "LISP" "XCL") (NICKNAMES "GUI")) READTABLE
"XCL" BASE 10)
(IL:FILECREATED "26-Apr-2025 20:37:29" IL:|{DSK}<home>paolo>il>dandegui>DANDEGUI.;9| 6475
:EDIT-BY "PA"
:CHANGES-TO (IL:FUNCTIONS CLEAR-WINDOW PRINT-MESSAGE)
:PREVIOUS-DATE "26-Apr-2025 20:27:06" IL:|{DSK}<home>paolo>il>dandegui>DANDEGUI.;8|)
(IL:PRETTYCOMPRINT IL:DANDEGUICOMS)
(IL:RPAQQ IL:DANDEGUICOMS
((IL:* IL:A IL:GUI IL:|library| IL:|for| IL:|simple| IL:|text| IL:|and| IL:|graphics|
IL:|output.|)
(FILE-ENVIRONMENTS IL:DANDEGUI)
(IL:P (DEFPACKAGE "DANDEGUI" (:USE "LISP" "XCL")
(:NICKNAMES "GUI")
(:EXPORT OPEN-WINDOW-STREAM CLEAR-WINDOW PRINT-MESSAGE WINDOW-TITLE
WITH-WINDOW-STREAM WITH-OUTPUT-TO-WINDOW)))
(IL:FUNCTIONS CLEAR-WINDOW OPEN-WINDOW-STREAM PRINT-MESSAGE WINDOW-TITLE
WITH-OUTPUT-TO-WINDOW WITH-WINDOW-STREAM WITH-WRITE-ENABLED)
(IL:SEDIT-FORMATS WITH-OUTPUT-TO-WINDOW WITH-WINDOW-STREAM)
(IL:SETFS WINDOW-TITLE)))
(IL:* IL:A IL:GUI IL:|library| IL:|for| IL:|simple| IL:|text| IL:|and| IL:|graphics| IL:|output.|)
(DEFINE-FILE-ENVIRONMENT IL:DANDEGUI :PACKAGE (DEFPACKAGE "DANDEGUI" (:USE "LISP" "XCL")
(:NICKNAMES "GUI"))
:READTABLE "XCL"
:COMPILER :COMPILE-FILE)
(DEFPACKAGE "DANDEGUI" (:USE "LISP" "XCL")
(:NICKNAMES "GUI")
(:EXPORT OPEN-WINDOW-STREAM CLEAR-WINDOW PRINT-MESSAGE WINDOW-TITLE WITH-WINDOW-STREAM
WITH-OUTPUT-TO-WINDOW))
(DEFUN CLEAR-WINDOW (STREAM) (IL:* IL:\; "Edited 26-Apr-2025 20:32 by PA")
"Delete all the text of the window associated with STREAM. Returns STREAM"
(WITH-WRITE-ENABLED (STR STREAM)
(IL:TEDIT.DELETE STR 1 (IL:TEDIT.NCHARS STR)))
STREAM)
(DEFUN OPEN-WINDOW-STREAM (&KEY (TITLE "Untitled")) (IL:* IL:\; "Edited 13-Apr-2025 17:38 by PA")
"Open a new window and return a text stream to send output to."
(IL:* IL:\; "Edited 12-Apr-2025 18:28 by PA")
(LET ((STREAM (IL:TEXTSTREAM (IL:TEDIT
NIL NIL NIL
`(IL:FONT (IL:TERMINAL 10)
IL:HISTORY IL:OFF IL:READONLY IL:QUIET
(IL:* IL:|;;|
"A dummy function to suppress TEdit's left/middle button title menu")
IL:TITLEMENUFN
,#'(LAMBDA (WINDOW)
(DECLARE (IGNORE WINDOW))
T))))))
(IL:WINDOWPROP (IL:WFROMDS STREAM)
'IL:TITLE TITLE)
STREAM))
(DEFUN PRINT-MESSAGE (STREAM MESSAGE &OPTIONAL DONT-CLEAR-P)
(IL:* IL:\; "Edited 26-Apr-2025 20:36 by PA")
"Print MESSAGE to the prompt area of the window associated with STREAM. If DONT-CLEAR-P is non NIL the area will be cleared first. Returns STREAM."
(IL:TEDIT.PROMPTPRINT STREAM MESSAGE (NOT DONT-CLEAR-P))
STREAM)
(DEFUN WINDOW-TITLE (STREAM) (IL:* IL:\; "Edited 20-Apr-2025 13:02 by PA")
"Return the title of the window associated with STREAM."
(IL:WINDOWPROP (IL:WFROMDS STREAM)
'IL:TITLE))
(DEFMACRO WITH-OUTPUT-TO-WINDOW ((VAR &KEY TITLE)
&BODY BODY) (IL:* IL:\; "Edited 16-Apr-2025 14:17 by PA")
"WITH-OUTPUT-TO-WINDOW (VAR &KEY TITLE) BODY
Perform the operations in BODY with VAR bound to a new window stream.
Opens a new window with title TITLE, binds VAR to the TEXTSTREAM associated with the window, and executes BODY in this context. Returns the value of the last form of BODY."
`(WITH-WINDOW-STREAM
(IL:* IL:|;;|
"If :TITLE is NIL the title bar disappear, so we must pass something non NIL to OPEN-WINDOW-STREAM")
(,VAR (OPEN-WINDOW-STREAM :TITLE (OR ,TITLE "Untitled")))
,@BODY))
(DEFMACRO WITH-WINDOW-STREAM ((VAR STREAM)
&BODY BODY) (IL:* IL:\; "Edited 16-Apr-2025 13:25 by PA")
"Perform the operations in BODY with VAR bound to a window STREAM.
Evaluates the forms in BODY in a context in which VAR is bound to STREAM which must already exist, then returns the value of the last form of BODY."
`(WITH-WRITE-ENABLED (,VAR ,STREAM)
,@BODY))
(DEFMACRO WITH-WRITE-ENABLED ((VAR STREAM)
&BODY BODY) (IL:* IL:\; "Edited 26-Apr-2025 16:44 by PA")
(IL:* IL:\; "Edited 15-Apr-2025 19:34 by PA")
"Perform the operations in BODY on STREAM after enabling write access, then set it to readonly.
Evaluates the forms in BODY in a context in which STREAM is bound to VAR and write access is enabled for STREAM, then sets STREAM back to readonly and returns the value of the last form of BODY."
(ONCE-ONLY (STREAM)
`(UNWIND-PROTECT
(LET ((,VAR ,STREAM))
(IL:TEXTPROP ,STREAM 'IL:READONLY NIL)
(IL:* IL:|;;|
"Ensure new text is appended to the end by setting the stream pointer to EOF=-1")
(IL:SETFILEPTR ,STREAM -1)
,@BODY)
(IL:* IL:|;;|
"Mark buffer as not changed so the user is not prompted when to save when quitting TEdit")
(IL:TEDIT.STREAMCHANGEDP ,STREAM T)
(IL:TEXTPROP ,STREAM 'IL:READONLY 'IL:QUIET))))
(SEDIT:DEF-LIST-FORMAT WITH-OUTPUT-TO-WINDOW WITH-OPEN-STREAM)
(SEDIT:DEF-LIST-FORMAT WITH-WINDOW-STREAM WITH-OPEN-STREAM)
(DEFSETF WINDOW-TITLE (STREAM) (TITLE)
"Set to TITLE the title of the window associated with STREAM."
(IL:* IL:|;;| "TITLE must not be NIL otherwise the title bar of the window gets hidden")
`(IL:WINDOWPROP (IL:WFROMDS ,STREAM)
'IL:TITLE
(OR ,TITLE "Untitled")))
(IL:DECLARE\: IL:DONTCOPY
(IL:FILEMAP (NIL (1701 1999 (CLEAR-WINDOW 1701 . 1999)) (2001 3035 (OPEN-WINDOW-STREAM 2001 . 3035)) (
3037 3432 (PRINT-MESSAGE 3037 . 3432)) (3434 3666 (WINDOW-TITLE 3434 . 3666)) (3668 4382 (
WITH-OUTPUT-TO-WINDOW 3668 . 4382)) (4384 4821 (WITH-WINDOW-STREAM 4384 . 4821)) (4823 6007 (
WITH-WRITE-ENABLED 4823 . 6007)))))
IL:STOP