Class: WR::RbTextColor

Inherits:
Ripper::Filter
  • Object
show all
Defined in:
lib/wrb/documents/samples/sample_richedit.rb

Constant Summary collapse

ClrDef =
0
ClrCmt =
0x007f00
ClrTxt =
0x00007f
ClrKwd =
0xff0000
ClrSym =
0x007f7f

Instance Method Summary collapse

Instance Method Details

#on_default(event, token, rt) ⇒ Object

Comment



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/wrb/documents/samples/sample_richedit.rb', line 11

def on_default(event, token, rt) # Comment
  rt.selection.format.facename = 'Consolas'
  case event
  when :on_kw
    rt.selection.color = ClrKwd
    rt[rt.textlength, 0] = token
    rt.selection.color = ClrDef
    return rt
  when :on_comment
    rt.selection.color = ClrCmt
    rt[rt.textlength, 0] = token
    rt.selection.color = ClrDef
    return rt
  when :on_tstring_beg
    rt.selection.color = ClrTxt
  when :on_tstring_end
    rt.selection.color = ClrDef
  when :on_symbeg
    rt.selection.color = ClrSym
    @symbeg = true
  when :on_ident
    if @symbeg
      rt[rt.textlength, 0] = token
      rt.selection.color = ClrDef
      @symbeg = nil
      return rt
    end
    rt.selection.color = ClrDef
  else
  end
  rt[rt.textlength, 0] = token
  rt
end