gpt4 book ai didi

sublimetext - Julia REPL 在 sublime text 中

转载 作者:行者123 更新时间:2023-12-02 03:28:51 31 4
gpt4 key购买 nike

我正在尝试让 Julia REPL 在 sublime text 中运行。但是,在尝试执行此操作时,我在 julia 方面遇到了一些问题。基本上,我的嵌入式 julia REPL 可以工作,但没有显示交互元素(例如提示)。由于各种原因,我对使用 Sublime-IJulia 不感兴趣。

当我从 xterm 运行时,我的 REPL 确实工作正常。

据我所知,当我从 sublime 运行它时,我需要找到一种方法让 Julia 使用基本的 REPL,但是,我不确定我应该怎么做。

从 xterm 运行 Base.active_repl 得到以下输出:

LineEditREPL(
TTYTerminal("xterm-256color",TTY(open, 0 bytes waiting),TTY(open, 0 bytes waiting),TTY(open, 0 bytes waiting)),
true,
"\e[1m\e[32m",
"\e[1m","\e[1m",
"\e[1m\e[31m",
"\e[1m\e[33m",
false,
false,
false,
true,
false,
nothing,
ModalInterface(TextInterface["Prompt(\"julia> \",...)","Prompt(\"shell> \",...)","Prompt(\"help?> \",...)",HistoryPrompt{REPLHistoryProvider}(REPLHistoryProvider(String["5","exit","exit()","Pkg.status()","Pkg.add(\"ZMQ\")","Pkg.add(\"IJulia\")","Pkg.status()","Pkg.remove(\"IJulia\")","Pkg.rm(\"IJulia\")","Pkg.status()" … "import REPL","import Base..REPL","Base.BasicRepl","Base.BasicREPL","Base.REPL","Base.REPL.BasicREPL","Base.active_repl = Base.REPL.BasicREPL()","Base.active_repl","exit()","Base.active_repl"],IOStream(<file .julia_history>),62,-1,IOBuffer(data=Uint8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1),"Prompt(\"julia> \",...)",[:help=>"Prompt(\"help?> \",...)",:shell=>"Prompt(\"shell> \",...)",:julia=>"Prompt(\"julia> \",...)"],[:julia,:julia,:julia,:julia,:julia,:julia,:julia,:julia,:julia,:julia … :julia,:julia,:julia,:julia,:julia,:julia,:julia,:julia,:julia,:julia]),LatexCompletions(),(anonymous function))]),
REPLBackendRef(RemoteRef(1,1,0),RemoteRef(1,1,1)))

从 SublimeRepl 运行它会返回以下错误:ERROR: active_repl not defined

简而言之,有没有什么方法可以让我编辑 julia 从 sublime 运行时启动的 REPL 类型?如果可能的话,我需要使用哪种类型的 REPL?

最佳答案

我不久前在 reddit 上发现了一个解决方法:https://www.reddit.com/r/SublimeText/comments/5jtnj7/sublimerepl_is_it_possible_to_mimic_commandline/

特别是:

Found a (really) hacky solution to see the julia> prompts!

In Preferences > Browse Packages > SublimeREPL/sublimerepl.py, add these two lines under the else: statement of handle_repl_packet():

if self.repl.name() == 'julia' :
self.write_prompt('julia>')

For reassurance, the method in its entirety will look like this:

def handle_repl_packet(self, packet):
if self.repl.apiv2:
for opcode, data in packet:
if opcode == 'output':
self.write(data)
elif opcode == 'prompt':
self.write_prompt(data)
elif opcode == 'highlight':
a, b = data
regions = self._view.get_regions('sublimerepl')
regions.append(sublime.Region(a, b))
self._view.add_regions('sublimerepl', regions, 'invalid',
'', sublime.DRAW_EMPTY | sublime.DRAW_OUTLINED)
else:
print('SublimeREPL: unknown REPL opcode: ' + opcode)
else:
if self.repl.name() == 'julia' :
self.write_prompt('julia>')
self.write(packet)

This does fail on the first line - I'll see if I can fix that.

EDIT: I failed to mention that I have previously changed sublimerepl.py as described here: SublimeREPL's Slow Printing/Freezing - A Solution. In my experience, it makes SublimeREPL's printing much faster... and is needed to make this julia> fix work as is.

从那以后我就再也没有找到更可靠的解决方案。

关于sublimetext - Julia REPL 在 sublime text 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28720398/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com