29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/xiki/color.rb', line 29
def self.colorize char=nil
char ||= Keys.input(:chars=>1, :prompt=>'Enter first letter of color: ')
char = char.to_s
case char
when "l"
overlays = $el.overlays_in(View.top, View.bottom)
overlays.to_a.reverse.each do |o|
if $el.overlay_get(o, :face).to_s == "color-rb-light"
$el.delete_overlay(o)
end
end
when "s"
prefix = Keys.prefix
if prefix.nil?
light = $el.overlays_in(View.top, View.bottom).to_a.find{|o| $el.overlay_get(o, :face).to_s == "color-rb-light"}
return View.to($el.overlay_start(light)) if light
end
return Launcher.open("- Color.search/") if Keys.prefix == 8
Launcher.open("- Color.search 'light'/")
return
when "o"
res = self.get_marked_lines
res.gsub! /^/, " | "
file = View.file
path = file ?
"- #{File.expand_path(file).sub(/(.+)\//, "\\1/\n - ")}\n" :
"- buffer #{View.name}/\n"
View.to_buffer("*outline of marked in #{path}")
View.clear; Notes.mode
View.insert path
if res == " | "
return View.insert " - Nothing was marked in this file!"
end
View.insert res
Keys.clear_prefix
View.to_line 3
Line.to_beginning
Tree.search :left=> Line.left, :number_means_enter=>true
return
when "c"
res = self.get_marked_lines
Clipboard['0'] = res
when "h"
prefix = Keys.prefix :clear=>1
ignore, left, right = View.txt_per_prefix prefix, :just_positions=>1, :default_is_line=>1
prefix == :u ?
Effects.glow(:color=>:rainbow, :times=>4) :
Effects.glow(:what=>[left, right], :times=>4)
when "n"
pos = $el.next_overlay_change(View.cursor)
pos = $el.next_overlay_change(pos) unless $el.overlays_at(pos)
return View.to(pos)
when "p"
pos = $el.previous_overlay_change(View.cursor)
pos = $el.previous_overlay_change(pos-2) if $el.overlays_at(pos-2)
return View.to pos
when "d"
overlays = $el.overlays_at($el.next_overlay_change($el.point_at_bol - 1))
return View.beep "- No highlights after cursor!" if ! overlays
return $el.delete_overlay(overlays[0])
when "k"
if Keys.prefix_u
return $el.remove_overlays
end
overlays = $el.overlays_in(View.top, View.bottom)
overlays.to_a.reverse.each do |o|
if $el.overlay_get(o, :face).to_s != "color-rb-light"
$el.delete_overlay(o)
end
end
return
when "a"
return self.alternating
end
case Keys.prefix
when :u
left, right = View.range
when nil
left, right = Line.left, Line.right+1
else
txt, left, right = View.txt_per_prefix
end
if ! @@colors[char]
return View.message "No char color for '#{char}'"
end
over = $el.make_overlay(left, right)
$el.overlay_put over, :face, @@colors[char]
end
|