|
1 |
| -import REPL |
2 |
| -import REPL.LineEdit |
| 1 | + |
3 | 2 | using Crayons
|
4 | 3 | import Markdown
|
5 | 4 |
|
6 |
| -function _refresh_line(s::REPL.LineEdit.BufferLike) |
7 |
| - LineEdit.refresh_multi_line(s) |
8 |
| - OhMyREPL.Prompt.rewrite_with_ANSI(s) |
9 |
| -end |
10 |
| - |
11 |
| -function _REPL_display(d::REPL.REPLDisplay, mime::MIME"text/plain", @nospecialize(x)) |
12 |
| - x = Ref{Any}(x) |
13 |
| - REPL.with_repl_linfo(d.repl) do io |
14 |
| - if isdefined(REPL, :active_module) |
15 |
| - mod = REPL.active_module(d)::Module |
16 |
| - else |
17 |
| - mod = Main |
18 |
| - end |
19 |
| - io = IOContext(io, :limit => true, :module => mod) |
20 |
| - if OUTPUT_PROMPT !== nothing |
21 |
| - output_prompt = OUTPUT_PROMPT isa String ? OUTPUT_PROMPT : OUTPUT_PROMPT() |
22 |
| - write(io, OUTPUT_PROMPT_PREFIX) |
23 |
| - write(io, output_prompt, "\e[0m") |
24 |
| - end |
25 |
| - get(io, :color, false) && write(io, REPL.answer_color(d.repl)) |
26 |
| - if isdefined(d.repl, :options) && isdefined(d.repl.options, :iocontext) |
27 |
| - # this can override the :limit property set initially |
28 |
| - io = foldl(IOContext, d.repl.options.iocontext, init=io) |
29 |
| - end |
30 |
| - show(io, mime, x[]) |
31 |
| - println(io) |
32 |
| - end |
33 |
| - return nothing |
34 |
| -end |
| 5 | +import .OhMyREPL.Passes.SyntaxHighlighter.SYNTAX_HIGHLIGHTER_SETTINGS |
| 6 | +import .OhMyREPL.HIGHLIGHT_MARKDOWN |
35 | 7 |
|
36 | 8 | split_lines(s::AbstractString) = isdefined(Markdown, :lines) ? Markdown.lines(s) : split(s, '\n')
|
37 | 9 |
|
38 |
| -function _Markdown_term(io::IO, md::Markdown.Code, columns) |
| 10 | +function Markdown.term(io::IO, md::Markdown.Code, columns) |
39 | 11 | code = md.code
|
40 | 12 | # Want to remove potential.
|
41 | 13 | lang = md.language == "" ? "" : first(split(md.language))
|
@@ -65,11 +37,11 @@ function _Markdown_term(io::IO, md::Markdown.Code, columns)
|
65 | 37 | push!(outputs, "")
|
66 | 38 | end
|
67 | 39 |
|
68 |
| - if do_syntax && OhMyREPL.HIGHLIGHT_MARKDOWN[] |
| 40 | + if do_syntax && HIGHLIGHT_MARKDOWN[] |
69 | 41 | for (i, (sourcecode, output)) in enumerate(zip(sourcecodes, outputs))
|
70 | 42 | tokens = collect(tokenize(sourcecode))
|
71 | 43 | crayons = fill(Crayon(), length(tokens))
|
72 |
| - OhMyREPL.Passes.SyntaxHighlighter.SYNTAX_HIGHLIGHTER_SETTINGS(crayons, tokens, 0, sourcecode) |
| 44 | + SYNTAX_HIGHLIGHTER_SETTINGS(crayons, tokens, 0, sourcecode) |
73 | 45 | buff = IOBuffer()
|
74 | 46 | if lang == "jldoctest" || lang == "julia-repl"
|
75 | 47 | print(buff, Crayon(foreground = :red, bold = true), "julia> ", Crayon(reset = true))
|
@@ -100,18 +72,3 @@ function _Markdown_term(io::IO, md::Markdown.Code, columns)
|
100 | 72 | end
|
101 | 73 | end
|
102 | 74 | end
|
103 |
| - |
104 |
| -_refresh_line_hook = _refresh_line |
105 |
| - |
106 |
| -function activate_hooks() |
107 |
| - @eval begin |
108 |
| - LineEdit.refresh_line(s::REPL.LineEdit.BufferLike) = |
109 |
| - _refresh_line_hook(s) |
110 |
| - Markdown.term(io::IO, md::Markdown.Code, columns) = |
111 |
| - _Markdown_term(io, md, columns) |
112 |
| - end |
113 |
| - if !isdefined(REPL, :IPython) |
114 |
| - @eval REPL.display(d::REPL.REPLDisplay, mime::MIME"text/plain", x) = |
115 |
| - _REPL_display(d, mime, x) |
116 |
| - end |
117 |
| -end |
0 commit comments