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

WIP: use GarishPrint for REPL output #243

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

Roger-luo
Copy link

@Roger-luo Roger-luo commented Jun 23, 2021

This is a draft PR since the package GarishPrint still has one day until registered. (oops, I forgot to change it to draft, I don't know how to change it after submitting a PR)

I can't think of if there is a non-hacking of doing this, since I'm not sure how to make the display get dispatched to pprint instead of Base.show if Base.show is not overloaded for a given object, because we don't have a reflection mechanism of detecting that IIUC. I find a way of doing this. now if only dispatch to pprint when Base.show is not overloaded for the given object for MIME"text/plain" or Base.show(::IO, x).

so I just replace the default REPL multi-line print with Base.show(io::IO, ::MIME"text/plain", x), I think under the context of OhMyREPL this is probably fine.

check the effect

image

The color scheme is not consistent with OhMyREPL and doesn't support changing theme in this PR yet, but GarishPrint supports changing color preference, I need to read up how OhMyREPL store the color themes first.

@Roger-luo Roger-luo changed the title use GarishPrint use GarishPrint for REPL output Jun 23, 2021
@Roger-luo Roger-luo changed the title use GarishPrint for REPL output WIP: use GarishPrint for REPL output Jun 23, 2021
@KristofferC
Copy link
Owner

Looks cool.

Needs a dedicated doc page for it, and ideally the syntax highlighting would agree with the one you picked in OMR.

@Roger-luo
Copy link
Author

Roger-luo commented Oct 10, 2021

I just had more chance to look into the color scheme for syntax highlighting, I realize the most elegant way of doing it would be letting GarishPrint and OhMyREPL share the same ColorScheme type so that we can understand each other, so I'm wondering if @KristofferC mind me stealing your ColorScheme in a new package and then integrate these two packages with it? Persumably I also want to make it work with the new preference system thus part of it can be considered as an exploration of JuliaLang/julia#41435

however, then I find using Crayons in GarishPrint is causing me not respecting the :color option in IO, I think for now if KristofferC/Crayons.jl#53 is merged, I can just not use any string interpolation as a workaround

Actually I just figured out a workaround to do this, now it respects the color scheme in OMR

@KristofferC
Copy link
Owner

I've disabled the output overwrite function on 1.9+ and I am not so keen to put it back. For this feature, wouldn't it make sense to have a field in the REPL that allows one to give a function that overrides the standard printing or something along those lines?

@Roger-luo
Copy link
Author

You mean a function like show_fancy? and let the package author to overload that function themselves in an extension and OMR will pick it if it gets loaded?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants