Author Topic: Color coding an arithmetic operator method  (Read 2943 times)

kayakerjess

  • Junior Community Member
  • Posts: 3
  • Hero Points: 0
Color coding an arithmetic operator method
« on: May 24, 2007, 05:26:01 pm »
Hello,

I have a Ruby class where I am defining methods for arithmetic operators.  This class contains implementations for the standard math operators (+ - * /), unary operators (& | ^), etc.  I want these methods to be colored like a function, not like an operator.  Is that possible?  Here's an example:



  def initialize( value, bits )
    @bits = bits
    # Assign @value.  Ensure we didn't overflow the allowed number of bits
    # Do not allow negative values for unsigned numbers
    @value = (value & ((2**@bits)-1)) unless value < 0
    if value < 0
      raise ArgumentError, "Unsigned cannot be negative"
    end
  end


  def +( other )
    self.class.new( @value + other, @bits )
  end



In the example, I want the "+" in the method definition to be colored like a function name (green), not like an operator (blue).  I have added the appropriate characters (+*&^, etc) into the "ID start characters" text box, but the lexer is seeing them as operators.  If you follow the operator with some other character, it is no longer an operator and gets colored like a function (e.g. "+a" would appear green).  Other than removing these items as operators (which I may end up doing - don't really need operators to be colored), is there a way to force slick edit to see them as a function?  I'm thinking something like, "if the operator follows the 'def' keyword, do not consider it as an operator", or something.  Am I up the creek?

By the way, I'm using SlickEdit version 11.0.0

Thanks.