6 attr_accessor :list, :regexp
7 attr_reader :cursor, :start, :marked
12 @busy_array = %w(/ - \\ |)
13 # @busy_array = ("!".."~").to_a.shuffle
33 CLI.cursor(Color.terminal_cursor)
35 when :console, :search, :searchback
36 CLI.cursor(Color.console.terminal_cursor)
37 Console.main_loop(Info.where)
52 CLI.movi UI.cursor - UI.start, 0
59 if Info.request_filter
62 if Info.request_reoccur or
63 ((next_reoccur = Opt.next_reoccur.to_i) and
65 $now.to_i > next_reoccur)
73 def key_combination?(str)
74 # log("#{str} =~ #{@regexp} => #{str =~ @regexp}")
78 ## Returns the line, where the console is drawn.
83 ## Get the key from user input
97 Info.request_draw = true
103 if key_combination?(@keybuffer).nil?
104 command = Cache.map[@keybuffer]
106 Command.run(command, @keybuffer)
112 ## Set or remove the sign at the bottom right that work is in progress.
113 ## Also, each time this method is called with true, that sign is rotated.
114 ## Use this in time-expensive processes to entertain the user :)
116 return unless Opt.busy
119 if @busy_pos == @busy_array.size
122 puti(-1, -1, @busy_array[@busy_pos])
125 # if Info.where == :main
137 cursor_color = Opt.cursor_color
138 cursor_color = [6, 0] unless cursor_color.is_a?(Array) and cursor_color[0].is_a?(Integer) and cursor_color[1].is_a?(Integer)
140 Info.request_draw = true ##temporary
141 if Info.request_draw or @old_start != @start or (@cursor != @old_cursor and !@list[@old_cursor])
142 Info.request_draw = false
145 expand = false unless expand == false or expand == true
146 expand_max = Opt.expand_max
147 expand_max = 10 unless expand_max.is_a? Integer
148 expand = false if expand_max < 1
154 while line_ix + 1 < lines
157 attr_set(*Color[:normal].base)
158 puti(line_ix, " " * cols)
161 cell = @list[list_ix+@start]
167 if @cursor - @start == line_ix
169 elsif @marked.include? cell
171 elsif cell.tags.include? 'k'
177 attr_set(*Color[mode].content)
178 puti(line_ix, cell.to_s(width))
179 attr_set(*Color[:normal].content)
180 # log "cell.lines = #{cell.lines}"
181 if expand and mode == :selected and cell.lines > 1
182 # log("expand and cell.lines > 1")
183 for line in 1..[cell.lines - 1, expand_max].min
184 puti(line_ix+jump, cell.line(line).rjust(cols))
185 # attr_at(0, line_ix+jump, -1, *Color[:selected].content)
186 attr_at(0, line_ix+jump, -1, *Color[:normal].content)
189 if (cell.lines > expand_max + 1)
194 puti(line_ix+jump, stringy.ljust(cols))
195 attr_at(0, line_ix+jump, -1, *Color[:normal].content)
198 # if mode == :selected
199 # attr_set(-1, -1, 0)
202 if cell.bold_on_the_left > 0
203 # logpp Color[mode].map
204 clr = Color[mode].send(cell.type) #rescue Color.default_color
205 attr_at(0, line_ix, cell.bold_on_the_left, *clr)
208 botr = cell.bold_on_the_right
211 clr = Color[mode].priority_negative
213 clr = Color[mode].priority_positive
215 attr_at(cols-botr, line_ix, botr, *clr)
218 if not cell.tags.empty?
219 # botr += 1 if botr > 0
220 sz = cell.tagstring.size
221 clr = Color[mode].tags
222 attr_at(cols-botr-sz, line_ix, sz, *clr)
232 if @cursor != @old_cursor
233 old = @old_cursor - @start
234 cur = @cursor - @start
235 attr_at(0, cur, -1, *Color[:selected].content)
236 # color_reverse_at(cur, 0, -1, *cursor_color)
237 attr_at(0, old, -1, *Color[:normal].content)
238 # color_at(old, 0, -1, -1, -1)
239 cell = @list[@old_cursor]
240 # color_bold_at(old, 0, cell.bold_on_the_left, -1, -1) if cell.bold_on_the_left > 0
241 # color_at(old, cols-cell.bold_on_the_right, -1, 2, -1) if cell.bold_on_the_right > 0
242 ## color_bold_at(old, cols-cell.bold_on_the_right, -1, -1, -1) if cell.bold_on_the_right > 0
243 ## color_at(cur, 0, 13, 4, 6)
249 @old_cursor = @cursor
255 @start, @old_start = val, @start
261 @cursor, @old_cursor = val, @cursor