Skip to content

Commit 689544c

Browse files
authored
[0827] 插件 I/O 协议统一为 UTF-8 (#3924)
1 parent bcbadd5 commit 689544c

18 files changed

Lines changed: 212 additions & 64 deletions

File tree

.github/workflows/ci-julia.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Julia Plugin CI
1+
name: CI for Julia Plugin
22

33
on:
44
push:

TeXmacs/plugins/goldfish/goldfish/goldfish/repl.scm

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050

5151
(define (goldfish-print obj)
5252
(if (eq? obj #<unspecified>)
53-
(flush-scheme-u8 "")
54-
(flush-scheme-u8 (build-goldfish-result obj))
53+
(flush-scheme "")
54+
(flush-scheme (build-goldfish-result obj))
5555
) ;if
5656
) ;define
5757

@@ -60,15 +60,15 @@
6060
(lambda () (goldfish-print (eval-string code (rootlet))))
6161
(lambda args
6262
(begin
63-
(flush-scheme-u8 (string-append "(errput (document "
64-
(goldfish-quote (symbol->string (car args)))
65-
(if (and (>= (length args) 2) (not (null? (cadr args))))
66-
(goldfish-quote (object->string (cadr args)))
67-
""
68-
) ;if
69-
"))"
70-
) ;string-append
71-
) ;flush-scheme-u8
63+
(flush-scheme (string-append "(errput (document "
64+
(goldfish-quote (symbol->string (car args)))
65+
(if (and (>= (length args) 2) (not (null? (cadr args))))
66+
(goldfish-quote (object->string (cadr args)))
67+
""
68+
) ;if
69+
"))"
70+
) ;string-append
71+
) ;flush-scheme
7272
) ;begin
7373
) ;lambda
7474
) ;catch

TeXmacs/plugins/goldfish/goldfish/texmacs/protocol.scm

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
flush-verbatim
1111
flush-prompt
1212
flush-scheme
13-
flush-scheme-u8
1413
flush-file
1514
flush-markdown
1615
flush-latex
@@ -44,7 +43,7 @@
4443
) ;define
4544

4645
(define (flush-verbatim msg)
47-
(flush-any (string-append "verbatim:" msg))
46+
(flush-any (string-append "utf8:" msg))
4847
) ;define
4948

5049
(define (flush-scheme msg)
@@ -54,13 +53,6 @@
5453
) ;if
5554
) ;define
5655

57-
(define (flush-scheme-u8 msg)
58-
(if (string? msg)
59-
(flush-any (string-append "scheme_u8:" msg))
60-
(flush-any (string-append "scheme_u8:" (object->string msg)))
61-
) ;if
62-
) ;define
63-
6456
(define (flush-prompt msg)
6557
(flush-any (string-append "prompt#" msg))
6658
) ;define

TeXmacs/plugins/julia/bin/tmjl/capture.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Base.flush(io::TMJuliaStdio) = begin
6262
filtered_lines = filter(line -> !occursin("GKS: glyph missing from current font", line), lines)
6363
filtered_buf = join(filtered_lines, '\n')
6464
if filtered_buf != ""
65-
tm_err(VERBATIM, filtered_buf)
65+
tm_err(U8_TEXT, filtered_buf)
6666
end
6767
end
6868
end

TeXmacs/plugins/julia/bin/tmjl/protocol.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const DATA_BEGIN = Char(2)
1313
const DATA_END = Char(5)
1414
const DATA_ESCAPE = Char(27)
1515
const DATA_COMMAND = Char(16)
16-
const VERBATIM = "verbatim:"
16+
const U8_TEXT = "utf8:"
1717
const SCHEME = "scheme:"
1818
const COMMAND = "command:"
1919
const PROMPT = "prompt#"
@@ -25,7 +25,7 @@ mogan_escape(data) = replace(replace(replace(data,
2525

2626
# Mogan expects all output to be bracketed in a DATA_BEGIN and DATA_END
2727
# so that it can determine when the plugin ended the interaction
28-
tm_begin() = write(orig_stdout[], DATA_BEGIN, VERBATIM)
28+
tm_begin() = write(orig_stdout[], DATA_BEGIN, U8_TEXT)
2929
tm_end() = begin
3030
write(orig_stdout[], DATA_END)
3131
flush(orig_stdout[])

TeXmacs/plugins/julia/tests/runtests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ end
7171

7272
# Test tm_begin
7373
tm_begin()
74-
@test String(take!(buf_out)) == string(DATA_BEGIN, VERBATIM)
74+
@test String(take!(buf_out)) == string(DATA_BEGIN, U8_TEXT)
7575

7676
# Test tm_end
7777
tm_end()
@@ -86,8 +86,8 @@ end
8686
@test String(take!(buf_out)) == string(DATA_BEGIN, "latex:", "x^2", DATA_END)
8787

8888
# Test tm_err with header
89-
tm_err("verbatim:", "load-error")
90-
@test String(take!(buf_err)) == string(DATA_BEGIN, "verbatim:", "load-error", DATA_END)
89+
tm_err("utf8:", "load-error")
90+
@test String(take!(buf_err)) == string(DATA_BEGIN, "utf8:", "load-error", DATA_END)
9191

9292
# Restore original IO streams
9393
orig_stdout[] = stdout
@@ -204,7 +204,7 @@ end
204204
flush(stdio_err)
205205
err_data = String(take!(buf_err))
206206
@test occursin("stderr-line", err_data)
207-
@test occursin(VERBATIM, err_data)
207+
@test occursin(U8_TEXT, err_data)
208208
finally
209209
redirect_stderr(old_stderr)
210210
end

TeXmacs/plugins/llm/goldfish/tm-llm.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
(define (eval-and-print data)
4141
(if (> (string-length data) *large-data-threshold*)
4242
(flush-verbatim (llm-write-temp-file data))
43-
(flush-scheme-u8 data)
43+
(flush-scheme data)
4444
) ;if
4545
) ;define
4646

TeXmacs/plugins/maxima/lisp/texmacs-maxima.lisp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
(setf *prompt-prefix* "channel:promptlatex:\\red ")
1515
(setf *prompt-suffix* "\\black")
1616
;(setf *general-display-prefix* "verbatim:")
17-
(setf *maxima-prolog* "verbatim:")
17+
(setf *maxima-prolog* "utf8:")
1818
(setf *maxima-epilog* "latex:\\red The end\\black")
1919
#-gcl(setf *debug-io* (make-two-way-stream *standard-input* *standard-output*))
2020
#+(or cmu sbcl scl)

TeXmacs/plugins/python/bin/python.pex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ from tmpy.protocol import (
2828
flush_prompt,
2929
flush_ps,
3030
flush_scheme,
31-
flush_scheme_u8,
3231
flush_verbatim,
3332
flush_latex,
3433
)
@@ -100,7 +99,7 @@ def flush_output(data):
10099
flush_matplotlib_figure(fig)
101100
elif is_dataframe_object(data):
102101
dfstr = convert_dataframe_to_scheme_str(data)
103-
flush_scheme_u8(dfstr)
102+
flush_scheme(dfstr)
104103
elif is_sympy_object(data):
105104
flush_latex("\\rmfamily{" + latex(data) + "}")
106105
elif is_pil_object(data):

TeXmacs/plugins/python/bin/tmpy/protocol.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ def flush_command(command):
6969
def flush_scheme(scheme):
7070
flush_any("scheme:" + scheme)
7171

72-
def flush_scheme_u8(scheme):
73-
flush_any("scheme_u8:" + scheme)
74-
7572
def flush_latex(latex):
7673
flush_any("latex:$" + latex + "$")
7774

0 commit comments

Comments
 (0)