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
|
# File 'lib/author_engine/views/code_editor.rb', line 67
def draw
super
Gosu.clip_to(0, window.container., window.width, window.height - window.container.) do
Gosu.draw_rect(0, window.container., @line_numbers_width, @height, dark_gray)
Gosu.translate(0, @y_offset) do
min_width = @font.text_width("0")+@x_padding
(@text.message.lines.map(&:chomp)).each_with_index do |line, index|
min_width = @font.text_width("#{index+1}") if @font.text_width("#{index+1}") > min_width
@font.draw_text("#{index+1}", 1, window.container. + (@font.height * index), 0)
end
@line_numbers_width = min_width
@text.x = @line_numbers_width+@x_padding
end
end
Gosu.clip_to(@line_numbers_width, window.container., window.width, @height) do
Gosu.translate(@x_offset, @y_offset) do
@text.draw_markup
@cursor.draw
end
end
end
|