Merge carousel.love
This commit is contained in:
commit
4c454ec07b
|
@ -1,7 +1,11 @@
|
|||
on.initialize = function()
|
||||
App.mkdir(Directory)
|
||||
populate_missing_handlers()
|
||||
Font = love.graphics.newFont(Font_height)
|
||||
if Font_filename == nil then
|
||||
Font = love.graphics.newFont(Font_height)
|
||||
else
|
||||
Font = love.graphics.newFont(Font_filename, Font_height)
|
||||
end
|
||||
love.graphics.setFont(Font)
|
||||
Line_height = math.floor(Font_height*1.3)
|
||||
Line_number_padding = Line_number_width*Font:getWidth('m')
|
||||
|
@ -21,4 +25,4 @@ on.initialize = function()
|
|||
end
|
||||
Output_editor_state = output_editor_state(Current_pane.editor_state)
|
||||
run_app()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
update_font_settings = function(font_height)
|
||||
Font_height = font_height
|
||||
Line_height = math.floor(Font_height*1.3)
|
||||
Font = love.graphics.newFont(Font_height)
|
||||
if Font_filename == nil then
|
||||
Font = love.graphics.newFont(Font_height)
|
||||
else
|
||||
Font = love.graphics.newFont(Font_filename, Font_height)
|
||||
end
|
||||
love.graphics.setFont(Font)
|
||||
Line_number_padding = Line_number_width*Font:getWidth('m')
|
||||
Menu_height = 5 + Line_height + 5
|
||||
|
@ -19,4 +23,4 @@ update_font_settings = function(font_height)
|
|||
end
|
||||
edit.update_font_settings(Output_editor_state, Font_height, Font)
|
||||
update_output_editor()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
-- put in a .ttf or .otf filename here to switch the font
|
||||
-- the filename must live somewhere Carousel can access: either in the source dir or the save dir
|
||||
-- A nil filename => use LÖVE's default font
|
||||
Font_filename = nil
|
2
text.lua
2
text.lua
|
@ -697,7 +697,7 @@ function Text.to_pos_on_line(State, line_index, mx, my)
|
|||
-- (The final screen line positions past end of screen line as always.)
|
||||
if screen_line_index < #line_cache.screen_line_starting_pos and mx > State.left + Text.screen_line_width(State, line_index, screen_line_index) then
|
||||
--? print('past end of non-final line; return')
|
||||
return line_cache.screen_line_starting_pos[screen_line_index+1]-1
|
||||
return line_cache.screen_line_starting_pos[screen_line_index+1]
|
||||
end
|
||||
local s = string.sub(line.data, screen_line_starting_byte_offset)
|
||||
--? print('return', mx, Text.nearest_cursor_pos(State.font, s, mx, State.left), '=>', screen_line_starting_pos + Text.nearest_cursor_pos(State.font, s, mx, State.left) - 1)
|
||||
|
|
|
@ -459,9 +459,9 @@ function test_click_past_end_of_screen_line()
|
|||
y = y + Editor_state.line_height
|
||||
-- click past end of second screen line
|
||||
edit.run_after_mouse_click(Editor_state, App.screen.width-2,y-2, 1)
|
||||
-- cursor moves to end of screen line
|
||||
-- cursor moves to end of screen line (one more than final character shown)
|
||||
check_eq(Editor_state.cursor1.line, 1, 'cursor:line')
|
||||
check_eq(Editor_state.cursor1.pos, 12, 'cursor:pos')
|
||||
check_eq(Editor_state.cursor1.pos, 13, 'cursor:pos')
|
||||
end
|
||||
|
||||
function test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen()
|
||||
|
@ -480,9 +480,9 @@ function test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen()
|
|||
y = y + Editor_state.line_height
|
||||
-- click past end of second screen line
|
||||
edit.run_after_mouse_click(Editor_state, App.screen.width-2,y-2, 1)
|
||||
-- cursor moves to end of screen line
|
||||
-- cursor moves to end of screen line (one more than final character shown)
|
||||
check_eq(Editor_state.cursor1.line, 1, 'cursor:line')
|
||||
check_eq(Editor_state.cursor1.pos, 12, 'cursor:pos')
|
||||
check_eq(Editor_state.cursor1.pos, 13, 'cursor:pos')
|
||||
end
|
||||
|
||||
function test_click_past_end_of_wrapping_line()
|
||||
|
@ -550,8 +550,8 @@ function test_click_past_end_of_word_wrapping_line()
|
|||
y = y + Editor_state.line_height
|
||||
-- click past the end of the screen line
|
||||
edit.run_after_mouse_click(Editor_state, App.screen.width-2,y-2, 1)
|
||||
-- cursor moves to end of screen line
|
||||
check_eq(Editor_state.cursor1.pos, 20, 'cursor')
|
||||
-- cursor moves to end of screen line (one more than final character shown)
|
||||
check_eq(Editor_state.cursor1.pos, 21, 'cursor')
|
||||
end
|
||||
|
||||
function test_select_text()
|
||||
|
|
Loading…
Reference in New Issue