106
106
(cider-repl--emit-output (current-buffer ) " [30ma[0m\n " 'cider-repl-stdout-face )
107
107
(cider-repl--emit-output (current-buffer ) " b\n " 'cider-repl-stdout-face )
108
108
(cider-repl--emit-output (current-buffer ) " [31mc\n " 'cider-repl-stdout-face )
109
- (cider-repl--emit-output (current-buffer ) " d[0m\n " 'cider-repl-stdout-face )
109
+ ; ; split at ESC
110
+ (cider-repl--emit-output (current-buffer ) " " 'cider-repl-stdout-face )
111
+ (cider-repl--emit-output (current-buffer ) " [32md\n " 'cider-repl-stdout-face )
112
+ ; ; split at ESC [
113
+ (cider-repl--emit-output (current-buffer ) " [" 'cider-repl-stdout-face )
114
+ (cider-repl--emit-output (current-buffer ) " 33me\n " 'cider-repl-stdout-face )
110
115
111
- (expect (buffer-string ) :to-equal " a\n b\n c\n d\n " )
116
+ ; ; split at ESC [n
117
+ (cider-repl--emit-output (current-buffer ) " [3" 'cider-repl-stdout-face )
118
+ (cider-repl--emit-output (current-buffer ) " 1mf\n " 'cider-repl-stdout-face )
119
+
120
+ ; ; split at ESC [nm
121
+ (cider-repl--emit-output (current-buffer ) " [32m" 'cider-repl-stdout-face )
122
+ (cider-repl--emit-output (current-buffer ) " g\n " 'cider-repl-stdout-face )
123
+
124
+ ; ; split at ESC [n;
125
+ (cider-repl--emit-output (current-buffer ) " [1;" 'cider-repl-stdout-face )
126
+ (cider-repl--emit-output (current-buffer ) " 33mh\n " 'cider-repl-stdout-face )
127
+
128
+ ; ; split at ESC [n;n
129
+ (cider-repl--emit-output (current-buffer ) " [0;31" 'cider-repl-stdout-face )
130
+ (cider-repl--emit-output (current-buffer ) " mi\n " 'cider-repl-stdout-face )
131
+
132
+ ; ; split at ESC [n;nm
133
+ (cider-repl--emit-output (current-buffer ) " [3;32m" 'cider-repl-stdout-face )
134
+ (cider-repl--emit-output (current-buffer ) " j[0m\n " 'cider-repl-stdout-face )
135
+
136
+ (expect (buffer-substring-no-properties (point-min ) (point-max ))
137
+ :to-equal " a\n b\n c\n d\n e\n f\n g\n h\n i\n j\n " )
112
138
(expect (get-text-property 1 'font-lock-face )
113
139
:to-equal '(foreground-color . " black" ))
114
140
(expect (get-text-property 3 'font-lock-face )
115
141
:to-equal 'cider-repl-stdout-face )
116
142
(expect (get-text-property 5 'font-lock-face )
117
143
:to-equal '(foreground-color . " red3" ))
118
144
(expect (get-text-property 7 'font-lock-face )
119
- :to-equal '(foreground-color . " red3" ))))))
145
+ :to-equal '(foreground-color . " green3" ))
146
+ (expect (get-text-property 9 'font-lock-face )
147
+ :to-equal '(foreground-color . " yellow3" ))
148
+ (expect (get-text-property 11 'font-lock-face )
149
+ :to-equal '(foreground-color . " red3" ))
150
+ (expect (get-text-property 13 'font-lock-face )
151
+ :to-equal '(foreground-color . " green3" ))
152
+ (expect (get-text-property 15 'font-lock-face )
153
+ :to-equal '((foreground-color . " yellow3" ) bold ))
154
+ (expect (get-text-property 17 'font-lock-face )
155
+ :to-equal '(foreground-color . " red3" ))
156
+ (expect (get-text-property 19 'font-lock-face )
157
+ :to-equal '((foreground-color . " green3" ) italic ))
158
+ ))))
120
159
121
160
(defun simulate-cider-output (s property )
122
161
" Return properties from `cider-repl--emit-output' .
123
162
PROPERTY should be a symbol of either 'text, 'ansi-context or
124
163
'properties."
125
- (with-temp-buffer
126
- (with-testing-ansi-table cider-testing-ansi-colors-vector
127
- (cider-repl-reset-markers)
128
- (cider-repl--emit-output (current-buffer ) s nil ))
129
- (pcase property
130
- (`text (substring-no-properties (buffer-string )))
131
- (`ansi-context ansi-color-context)
132
- (`properties (substring (buffer-string ))))))
164
+ (let ((strings (if (listp s) s (list s))))
165
+ (with-temp-buffer
166
+ (with-testing-ansi-table cider-testing-ansi-colors-vector
167
+ (cider-repl-reset-markers)
168
+ (dolist (s strings)
169
+ (cider-repl--emit-output (current-buffer ) s nil )))
170
+ (pcase property
171
+ (`text (substring-no-properties (buffer-string )))
172
+ (`ansi-context ansi-color-context)
173
+ (`properties (substring (buffer-string )))))))
133
174
134
175
(describe " cider-repl--emit-output"
135
176
(it " prints simple strings"
@@ -142,7 +183,21 @@ PROPERTY should be a symbol of either 'text, 'ansi-context or
142
183
(expect (simulate-cider-output " \0 33hi" 'text )
143
184
:to-equal " \0 33hi\n " )
144
185
(expect (simulate-cider-output " \0 33hi" 'ansi-context )
145
- :to-equal nil )))
186
+ :to-equal nil )
187
+
188
+ ; ; Informational: Ideally, we would have liked any non-SGR
189
+ ; ; sequence to appear on the output verbatim, but as per the
190
+ ; ; `ansi-color-apply' doc string, they are removed
191
+ ; ;
192
+ ; ; """Translates SGR control sequences into text properties.
193
+ ; ; Delete all other control sequences without processing them."""
194
+ ; ;
195
+ ; ; e.g.:
196
+ (expect (simulate-cider-output
197
+ " \0 33[hi" 'text ) :to-equal " i\n " )
198
+ (expect (simulate-cider-output
199
+ '(" \0 33[" " hi" ) 'text ) :to-equal " i\n " )
200
+ ))
146
201
147
202
(describe " when the escape code is valid"
148
203
(it " preserves the context"
0 commit comments