Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example for numbered_prompt #58

Open
hyrodium opened this issue Apr 10, 2023 · 2 comments
Open

Add example for numbered_prompt #58

hyrodium opened this issue Apr 10, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@hyrodium
Copy link
Collaborator

I am planning to add an example with ipython-mode (JuliaLang/julia#46474) after Julia v1.9.0 release.

@terasakisatoshi
Copy link
Member

Sounds great.

What should I do before doing that?

From my understanding I have to update the code below in replay function:

Replay.jl/src/Replay.jl

Lines 142 to 196 in 86c3f4a

if current_mode_name == :julian
mode = if startswith(cell, ';')
ghost_script = cell[begin+1:end] # remove ';'
# shell mode
name = :shell
prompt = "shell> "
prompt_prefix = Base.text_colors[:bold] * Base.text_colors[:red]
prompt_suffix = Base.color_normal
current_mode_name = name
(; name, prompt, prompt_prefix, prompt_suffix)
elseif startswith(cell, ']')
ghost_script = cell[begin+1:end] # remove ']'
# pkg repl
name = :repl
prompt_prefix = Base.text_colors[:bold] * Base.text_colors[:blue]
active_project_dir, _ =
splitext(Base.active_project() |> dirname |> basename)
if occursin(r"v[0-9].[0-9]", active_project_dir)
prompt = "(@v$(VERSION.major).$(VERSION.minor)) pkg> "
else
prompt = "($(active_project_dir)) pkg> "
end
prompt_suffix = Base.color_normal
current_mode_name = name
(; name, prompt, prompt_prefix, prompt_suffix)
elseif startswith(cell, '?')
ghost_script = cell[begin+1:end] # remove '?'
# help mode
name = :help
prompt = "help?> "
prompt_prefix = Base.text_colors[:bold] * Base.text_colors[:yellow]
prompt_suffix = Base.color_normal
# help mode should back to julian mode
current_mode_name = :julian
(; name, prompt, prompt_prefix, prompt_suffix)
else
# julian mode
name = :julian
prompt = "julia> "
prompt_prefix = Base.text_colors[:bold] * Base.text_colors[:green]
prompt_suffix = Base.color_normal
current_mode_name = :julian
(; name, prompt, prompt_prefix, prompt_suffix)
end
else
if endswith(cell, CTRL_C)
# julian mode
name = :julian
prompt = "julia> "
prompt_prefix = Base.text_colors[:bold] * Base.text_colors[:green]
prompt_suffix = Base.color_normal
current_mode_name = :julian
mode = (; name, prompt, prompt_prefix, prompt_suffix)
end
end

This code (I wrote this one year ago) displays a hard-coded prompt that users could change. I need to read code in julia/stdlib/REPL module to figure out what Julia's REPL does.

@hyrodium hyrodium changed the title Add example for ipython-mode Add example for numbered_prompt Apr 16, 2023
@hyrodium
Copy link
Collaborator Author

The feature is renamed to numbered_prompt.
JuliaLang/julia#49314

@hyrodium hyrodium added the documentation Improvements or additions to documentation label Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants