summaryrefslogtreecommitdiff
path: root/lib/irb/color.rb
AgeCommit message (Collapse)Author
2020-08-18[ruby/irb] Directly check if the method is available instead of versionNobuyoshi Nakada
https://github.com/ruby/irb/commit/3ea9fd9ed0
2020-07-22Add require 'irb/ruby-lex' to use RubyLexaycabta
2020-07-22[ruby/irb] Simplify RubyLex.compile_with_errors_suppressedaycabta
nobu-san reviewed, https://github.com/ruby/irb/pull/106#pullrequestreview-423400033 > How about lexer = Ripper::Lexer.new(";\n#{code}", nil, 0)? > Encoding pragma is effective only at the beginning. > And the semicolon and newline will be skipped because the position is before > the initial pos. I employ the way. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> https://github.com/ruby/irb/commit/e593cc65b7
2020-07-22[ruby/irb] Suppress incomplete coding magic comment erroraycabta
https://github.com/ruby/irb/commit/6a457edbd1
2019-11-13Suppress warnings except for when last evaluationaycabta
Co-authored-by: Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
2019-11-10qsymbols and symbols should be colored as SymbolTakashi Kokubun
2019-11-10Colorize on_symbols_beg (%I)Takashi Kokubun
2019-11-10Colorize string quotes as boldTakashi Kokubun
like pry
2019-10-15Fixed the key to delete [Bug #16250]Nobuyoshi Nakada
https://github.com/ruby/ruby/commit/f94202fcc228d0348ca050a7b18a8f8a538a7305#commitcomment-35505076 Co-Authored-By: Ary Borenszweig <asterite@gmail.com>
2019-10-15Use compare_by_identity hash [Bug #16250]Nobuyoshi Nakada
2019-10-14Simplify circular reference check of IRB::ColorTakashi Kokubun
2019-10-14IRB colorize: take into account recursive arrays and hashes (#2555)Ary Borenszweig
[Bug #16250]
2019-06-13make sync-default-gems GEM=irbTakashi Kokubun
Upgrade IRB to https://github.com/ruby/irb/commit/41ea43a4a732e094acfa1b0fc1473fdcda9e6227 Mostly backport changes.
2019-06-12Ripper::Lexer: fallback parse error token to the previous oneNobuyoshi Nakada
2019-06-04Reflect behavior changes to argument nameTakashi Kokubun
0c459af7c233adb5f44022350bfe8fa132d8053e changed the meaning of `detect_compile_error`, and this commit lets it follow the change.
2019-06-04colorize_code must return escaped textTakashi Kokubun
This was needed before 0c459af7c233adb5f44022350bfe8fa132d8053e but it could be actually useless now. But I added this anyway just in case.
2019-06-04Colorize error charactersNobuyoshi Nakada
* lib/irb/color.rb (IRB::Color.scan): ignore "incomplete end of input" error only, to colorize invalid characters, e.g., control characters, and invalid symbols, as errors.
2019-05-31Fix typo :bug: [ci skip]Takashi Kokubun
2019-05-31Warn compile_error only when input is finishedTakashi Kokubun
Let's say we are in progress to write `"foo"`: ``` irb> "fo ``` at this moment, nothing is wrong. It would be just a normal way to write `"foo"`. Prior to this commit, the `fo` part was warned because of 5b64d7ac6e7cbf759b859428f125539e58bac0bd. But I think warning such a normal input is not valuable for users. However, we'd like to warn `:@1` or `@@1` which is also a syntax error. Then this commit switches the syntax highlight based on whether the input text is finished or not. When it's not finished yet, it does not warn compile_error.
2019-05-31Abstract away Ripper::Lexer#scan in IRB::Color#scanTakashi Kokubun
because 5b64d7ac6e7cbf759b859428f125539e58bac0bd made it hard to understand #colorize_code for me and this change is needed for my next commit.
2019-05-29Colorize errors moreNobuyoshi Nakada
* lib/irb/color.rb (IRB::Color.colorize_code): colorize `compile_error` part as same as `on_parse_error`.
2019-05-29Get rid of nested string interpolationsNobuyoshi Nakada
* lib/irb/color.rb (IRB::Color.colorize): get rid of nesting string interpolations not to confuse ruby-mode.el
2019-05-29ripper: Ripper::Lexer#scanNobuyoshi Nakada
* ext/ripper/lib/ripper/lexer.rb (Ripper::Lexer#scan): parses the code and returns the result elements including errors. [EXPERIMENTAL]
2019-05-29Colorize compile_error as same as on_parse_errorNobuyoshi Nakada
2019-05-29parse.y: flush invalid charNobuyoshi Nakada
2019-05-29Revert "Colorize error part more"Koichi Sasada
This reverts commit c7f3c222c9b82736c993419daa6bfb643e5c0793.
2019-05-29Colorize error part moreNobuyoshi Nakada
Colorize `compile_error` parts as well as `on_parse_error` parts.
2019-05-27Colorize error partNobuyoshi Nakada
2019-05-26Highlight global variable on IRBTakashi Kokubun
2019-05-26Simplify lexer state matching in #dispatch_seqTakashi Kokubun
for improving readability of the condition. It may be slightly faster, or may not.
2019-05-26Refactor IRB color dispatchTakashi Kokubun
The reason why we were checking lexer state in addition to token was that we do not want to colorize local variable, method call, etc., while they share the :on_ident token with a name of method definition which should be colored as blue. It means that we're concerned about the lexer state only for :on_ident. Thus we can skip checking lexer state for non-:on_ident tokens. This refactoring is based on that idea. Also, now we manage Ripper's lexer state as Integer (use `|` if you need to check multiple states). It should be faster than using Array of Integer because #any? block call is not needed.
2019-05-27Support :@@cvar and : on colorizeaycabta
2019-05-26Make the imaginary color on IRB close to pryTakashi Kokubun
and sorted the token names alphabetically.
2019-05-26Colorize imaginary and rational literalsNobuyoshi Nakada
2019-05-25Handle keyword symbol in IRB::Color::SymbolStateTakashi Kokubun
2019-05-25Deal with more syntax highlight edge casesTakashi Kokubun
Please refer to the tests again.
2019-05-25Fix more unintended syntax highlightsTakashi Kokubun
See tests for what kind of things are fixed.
2019-05-25Always color Symbol as Yellow on IRB::ColorTakashi Kokubun
Symbol color was made blue as a workaround because it was hard to distinguish `foo`s in `:foo` and `def foo; end` (both are :on_ident). But I wanted to make it yellow like pry. `:Struct` had the same problem in :on_const. Because the :on_const was also blue (but underlined and bold), it was not a big issue. While they're not so problematic since we got a workaround, we also had a more serious issue for highlighting a symbol like `:"a#{b}c"`. The first half was considered as Symbol and the last half was considered as String, because the colorizer did not have a state like a parser. To approach the last issue, I introduced `IRB::Color::SymbolState` which is a thin state manager knowing only "the token is Symbol or not". Having this module magically solves the first two problems as well. So now we can highlight Symbol as yellow in the perfect manner.
2019-05-25Colorize empty embexpr more on IRB::ColorTakashi Kokubun
2019-05-25Support some unhandled syntax highlightTakashi Kokubun
Heredoc, %i, :Foo, { 'a': ... }, ... :'a' is still half-broken.
2019-05-25Clear IRB::Color escape sequence before newlineTakashi Kokubun
because otherwise prompt and other things could be polluted.
2019-05-25Add and use Reline::Unicode.escape_for_printTakashi Kokubun
2019-05-24Incremental syntax highlight for IRB source linesTakashi Kokubun
Closes: https://github.com/ruby/ruby/pull/2202
2019-05-23Use colorized IRB on Windows without checking `TERM`NAKAMURA Usaku
2019-04-28make sync-default-gems GEM=irbTakashi Kokubun
from https://github.com/ruby/irb/commit/e8e79d569ed59fe4ed4fbca968917ce799f02a5e. This colorizes Range object on IRB inspect.
2019-04-28make sync-default-gems GEM=irbTakashi Kokubun
from https://github.com/ruby/irb/commit/44301d382794d91e2caa16dd4efe62439e0041d8. This includes some fixes for string interpolation highlight fixes.
2019-04-28make sync-default-gems GEM=irbTakashi Kokubun
from https://github.com/ruby/irb/commit/89e9add06da3fd5f9ce91a2f5fa0b0190aa5d42f. This adds syntax highlight support for Module on inspect. In addition to that, I'm adding a trailing space in test_color.rb for testing ruby-commit-hook's auto-style.
2019-04-27make sync-default-gems GEM=irbTakashi Kokubun
Synced from https://github.com/ruby/irb/commit/5feb361ed80736efa5b2c2b629837ec2a5fc2cdb. This includes a support to colorize named Class instance on IRB inspect.
2019-04-26Revert "Class instance should be also colorable on IRB"Takashi Kokubun
This reverts commit 6669c966d2744f21315047d1725ad4494d15b8ba. It seems to make tests fail... let me fix this later.
2019-04-26Class instance should be also colorable on IRBTakashi Kokubun
inspect. Change is made with: `$ make -C .ruby sync-default-gems GEM=irb`