-
Notifications
You must be signed in to change notification settings - Fork 40
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
Implement syntax highlight #70
Implement syntax highlight #70
Conversation
makenowjust
commented
Nov 2, 2017
ae1e846
to
b22b61d
Compare
b22b61d
to
99c696d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very cool, thanks!
I've got to take a deeper look a little later
src/icr/highlighter.cr
Outdated
:lib, :fun, :type, :struct, :union, :enum, :macro, :out, :require, | ||
:case, :when, :then, :of, :abstract, :rescue, :ensure, :is_a?, | ||
:alias, :pointerof, :sizeof, :instance_sizeof, :as, :typeof, :for, :in, | ||
:undef, :with, :self, :super, :private, :protected, "new", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't :new
be also a symbol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No because "new" is not keyword really, it is just ident.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may missed few keywords: nil
, uninitialized
as?
etc. Found the list here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is nil
in SPECIAL_VALUES
because it should be highlighted as value, not keyword. However uninitialized
and as?
is missing. Thank you!
io << 36 | ||
when :white | ||
io << 37 | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a possibility to reuse standard library colorize
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm colorize
expert (see crystal-lang/crystal#3925) ;-) But I don't use colorize
for this due to some reason.
One of the biggest reasons is colorize
doesn't support outputting escape sequence without content.
I mean, really, what is there to say when @makenowjust submits a PR other than "Sweet!"? lol. I guess one comment would be, can we make this optional? In a previous PR we added a config file. Maybe this is an option that's on by default, but allows the user to turn it off? |
:"+", :"-", :"*", :"/", | ||
:"=", :"==", :"<", :"<=", :">", :">=", :"!", :"!=", :"=~", :"!~", | ||
:"&", :"|", :"^", :"~", :"**", :">>", :"<<", :"%", | ||
:"[]", :"[]?", :"[]=", :"<=>", :"===", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know there is !~
op. Nice 👍
src/icr/highlighter.cr
Outdated
end_highlight_class io | ||
break | ||
when :EOF | ||
raise "Unterminated symbol array literal" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please explain when this will be raised? I can't catch this exception in ICR.
I have played with it locally and started to love it. Nice job 👍
Maybe just introducing a cli flag |
@veelenga I introduced a new flag |
Looks very cool 👍 But, when I go back to history with the up key, the layout seems to collapse.
|
It is hard to fix this because the reason of this bug is macOS's libeditline bug. (And I should wrap I think that to disable highlight of prompt is better than broken history. I'll fix this. Don't be afraid, Thank you @at-grandpa. |
@makenowjust |
ping 🏓 |
This looks good to me. I'd kind of like to use that video up top as our new gif on the README, but with the message, and all the highlighting and stuff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is awesome!
@jwoertink Would you like to take care of making the new gif?:) |
@veelenga It feels like this nice feature deserves it's own minor release (0.4.0), what do you think? |
@greyblake right, will prepare it soon ;) |