300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
# File 'lib/author_engine/code_editor/cursor.rb', line 300
def move(direction)
pos = @text_input.caret_pos
line = nil
if direction == :up
return if @active_line == 0
line = @newline_data.dig(@active_line-1)
return unless line
above_offset = column_at(@x, (@active_line-1), true)
right_offset = above_offset
pos = (line[:position_end_of_line] - line[:text_length]) + right_offset
elsif direction == :down
return if @text_input.caret_pos == @text_input.text.size
return unless @newline_data[@active_line+1]
line = @newline_data.dig(@active_line+1)
return unless line
below_offset = column_at(@x, (@active_line+1), true)
right_offset = below_offset
pos = (line[:position_end_of_line] - line[:text_length]) + right_offset
else
raise ":up or :down please."
end
set_position(pos)
end
|