rip out notion of Line_width

This commit is contained in:
Kartik K. Agaram 2022-06-30 19:50:27 -07:00
parent 08a50b7fff
commit 8c7bea8f76
6 changed files with 67 additions and 163 deletions

View File

@ -8,13 +8,13 @@ require 'drawing_tests'
-- into 256 parts. -- into 256 parts.
function Drawing.draw(line) function Drawing.draw(line)
local pmx,pmy = App.mouse_x(), App.mouse_y() local pmx,pmy = App.mouse_x(), App.mouse_y()
if pmx < Line_width and pmy > line.y and pmy < line.y+Drawing.pixels(line.h) then if pmx < App.screen.width and pmy > line.y and pmy < line.y+Drawing.pixels(line.h) then
love.graphics.setColor(0.75,0.75,0.75) love.graphics.setColor(0.75,0.75,0.75)
love.graphics.rectangle('line', Margin_left,line.y, Line_width-Margin_left,Drawing.pixels(line.h)) love.graphics.rectangle('line', Margin_left,line.y, App.screen.width-Margin_left,Drawing.pixels(line.h))
if icon[Current_drawing_mode] then if icon[Current_drawing_mode] then
icon[Current_drawing_mode](Line_width-22, line.y+4) icon[Current_drawing_mode](App.screen.width-22, line.y+4)
else else
icon[Previous_drawing_mode](Line_width-22, line.y+4) icon[Previous_drawing_mode](App.screen.width-22, line.y+4)
end end
if App.mouse_down(1) and love.keyboard.isDown('h') then if App.mouse_down(1) and love.keyboard.isDown('h') then
@ -204,7 +204,7 @@ end
function Drawing.in_drawing(drawing, x,y) function Drawing.in_drawing(drawing, x,y)
if drawing.y == nil then return false end -- outside current page if drawing.y == nil then return false end -- outside current page
return y >= drawing.y and y < drawing.y + Drawing.pixels(drawing.h) and x >= Margin_left and x < Line_width return y >= drawing.y and y < drawing.y + Drawing.pixels(drawing.h) and x >= Margin_left and x < App.screen.width
end end
function Drawing.mouse_pressed(drawing, x,y, button) function Drawing.mouse_pressed(drawing, x,y, button)
@ -685,10 +685,10 @@ function Drawing.near(point, x,y)
end end
function Drawing.pixels(n) -- parts to pixels function Drawing.pixels(n) -- parts to pixels
return math.floor(n*(Line_width-Margin_left)/256) return math.floor(n*(App.screen.width-Margin_left)/256)
end end
function Drawing.coord(n) -- pixels to parts function Drawing.coord(n) -- pixels to parts
return math.floor(n*256/(Line_width-Margin_left)) return math.floor(n*256/(App.screen.width-Margin_left))
end end
function table.find(h, x) function table.find(h, x)

View File

@ -24,9 +24,8 @@ function test_draw_line()
io.write('\ntest_draw_line') io.write('\ntest_draw_line')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
Filename = 'foo' Filename = 'foo'
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
check_eq(#Lines, 2, 'F - test_draw_line/baseline/#lines') check_eq(#Lines, 2, 'F - test_draw_line/baseline/#lines')
@ -68,9 +67,8 @@ end
function test_draw_horizontal_line() function test_draw_horizontal_line()
io.write('\ntest_draw_horizontal_line') io.write('\ntest_draw_horizontal_line')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'manhattan' Current_drawing_mode = 'manhattan'
App.draw() App.draw()
check_eq(#Lines, 2, 'F - test_draw_horizontal_line/baseline/#lines') check_eq(#Lines, 2, 'F - test_draw_horizontal_line/baseline/#lines')
@ -96,9 +94,8 @@ end
function test_draw_circle() function test_draw_circle()
io.write('\ntest_draw_circle') io.write('\ntest_draw_circle')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
check_eq(#Lines, 2, 'F - test_draw_circle/baseline/#lines') check_eq(#Lines, 2, 'F - test_draw_circle/baseline/#lines')
@ -124,9 +121,8 @@ end
function test_keys_do_not_affect_shape_when_mouse_up() function test_keys_do_not_affect_shape_when_mouse_up()
io.write('\ntest_keys_do_not_affect_shape_when_mouse_up') io.write('\ntest_keys_do_not_affect_shape_when_mouse_up')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
-- hover over drawing and press 'o' without holding mouse -- hover over drawing and press 'o' without holding mouse
@ -140,9 +136,8 @@ end
function test_draw_circle_mid_stroke() function test_draw_circle_mid_stroke()
io.write('\ntest_draw_circle_mid_stroke') io.write('\ntest_draw_circle_mid_stroke')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
check_eq(#Lines, 2, 'F - test_draw_circle_mid_stroke/baseline/#lines') check_eq(#Lines, 2, 'F - test_draw_circle_mid_stroke/baseline/#lines')
@ -168,9 +163,8 @@ end
function test_draw_arc() function test_draw_arc()
io.write('\ntest_draw_arc') io.write('\ntest_draw_arc')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'circle' Current_drawing_mode = 'circle'
App.draw() App.draw()
check_eq(#Lines, 2, 'F - test_draw_arc/baseline/#lines') check_eq(#Lines, 2, 'F - test_draw_arc/baseline/#lines')
@ -199,9 +193,8 @@ end
function test_draw_polygon() function test_draw_polygon()
io.write('\ntest_draw_polygon') io.write('\ntest_draw_polygon')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
App.draw() App.draw()
check_eq(Current_drawing_mode, 'line', 'F - test_draw_polygon/baseline/drawing_mode') check_eq(Current_drawing_mode, 'line', 'F - test_draw_polygon/baseline/drawing_mode')
check_eq(#Lines, 2, 'F - test_draw_polygon/baseline/#lines') check_eq(#Lines, 2, 'F - test_draw_polygon/baseline/#lines')
@ -237,9 +230,8 @@ end
function test_draw_rectangle() function test_draw_rectangle()
io.write('\ntest_draw_rectangle') io.write('\ntest_draw_rectangle')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
App.draw() App.draw()
check_eq(Current_drawing_mode, 'line', 'F - test_draw_rectangle/baseline/drawing_mode') check_eq(Current_drawing_mode, 'line', 'F - test_draw_rectangle/baseline/drawing_mode')
check_eq(#Lines, 2, 'F - test_draw_rectangle/baseline/#lines') check_eq(#Lines, 2, 'F - test_draw_rectangle/baseline/#lines')
@ -281,9 +273,8 @@ end
function test_draw_rectangle_intermediate() function test_draw_rectangle_intermediate()
io.write('\ntest_draw_rectangle_intermediate') io.write('\ntest_draw_rectangle_intermediate')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
App.draw() App.draw()
check_eq(Current_drawing_mode, 'line', 'F - test_draw_rectangle_intermediate/baseline/drawing_mode') check_eq(Current_drawing_mode, 'line', 'F - test_draw_rectangle_intermediate/baseline/drawing_mode')
check_eq(#Lines, 2, 'F - test_draw_rectangle_intermediate/baseline/#lines') check_eq(#Lines, 2, 'F - test_draw_rectangle_intermediate/baseline/#lines')
@ -317,9 +308,8 @@ end
function test_draw_square() function test_draw_square()
io.write('\ntest_draw_square') io.write('\ntest_draw_square')
-- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end)
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
App.draw() App.draw()
check_eq(Current_drawing_mode, 'line', 'F - test_draw_square/baseline/drawing_mode') check_eq(Current_drawing_mode, 'line', 'F - test_draw_square/baseline/drawing_mode')
check_eq(#Lines, 2, 'F - test_draw_square/baseline/#lines') check_eq(#Lines, 2, 'F - test_draw_square/baseline/#lines')
@ -361,9 +351,8 @@ function test_name_point()
io.write('\ntest_name_point') io.write('\ntest_name_point')
-- create a drawing with a line -- create a drawing with a line
Filename = 'foo' Filename = 'foo'
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
-- draw a line -- draw a line
@ -404,9 +393,8 @@ function test_move_point()
io.write('\ntest_move_point') io.write('\ntest_move_point')
-- create a drawing with a line -- create a drawing with a line
Filename = 'foo' Filename = 'foo'
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)
@ -461,9 +449,8 @@ function test_move_point_on_manhattan_line()
io.write('\ntest_move_point_on_manhattan_line') io.write('\ntest_move_point_on_manhattan_line')
-- create a drawing with a manhattan line -- create a drawing with a manhattan line
Filename = 'foo' Filename = 'foo'
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'manhattan' Current_drawing_mode = 'manhattan'
App.draw() App.draw()
App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)
@ -487,9 +474,8 @@ function test_delete_lines_at_point()
io.write('\ntest_delete_lines_at_point') io.write('\ntest_delete_lines_at_point')
-- create a drawing with two lines connected at a point -- create a drawing with two lines connected at a point
Filename = 'foo' Filename = 'foo'
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)
@ -516,9 +502,8 @@ end
function test_delete_line_under_mouse_pointer() function test_delete_line_under_mouse_pointer()
io.write('\ntest_delete_line_under_mouse_pointer') io.write('\ntest_delete_line_under_mouse_pointer')
-- create a drawing with two lines connected at a point -- create a drawing with two lines connected at a point
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)
@ -540,9 +525,8 @@ end
function test_delete_point_from_polygon() function test_delete_point_from_polygon()
io.write('\ntest_delete_point_from_polygon') io.write('\ntest_delete_point_from_polygon')
-- create a drawing with two lines connected at a point -- create a drawing with two lines connected at a point
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
-- first point -- first point
@ -571,9 +555,8 @@ end
function test_delete_point_from_polygon() function test_delete_point_from_polygon()
io.write('\ntest_delete_point_from_polygon') io.write('\ntest_delete_point_from_polygon')
-- create a drawing with two lines connected at a point -- create a drawing with two lines connected at a point
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
-- first point -- first point
@ -599,9 +582,8 @@ function test_undo_name_point()
io.write('\ntest_undo_name_point') io.write('\ntest_undo_name_point')
-- create a drawing with a line -- create a drawing with a line
Filename = 'foo' Filename = 'foo'
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
-- draw a line -- draw a line
@ -645,9 +627,8 @@ function test_undo_move_point()
io.write('\ntest_undo_move_point') io.write('\ntest_undo_move_point')
-- create a drawing with a line -- create a drawing with a line
Filename = 'foo' Filename = 'foo'
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)
@ -695,9 +676,8 @@ function test_undo_delete_point()
io.write('\ntest_undo_delete_point') io.write('\ntest_undo_delete_point')
-- create a drawing with two lines connected at a point -- create a drawing with two lines connected at a point
Filename = 'foo' Filename = 'foo'
App.screen.init{width=Margin_left+300, height=300} App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels
Lines = load_array{'```lines', '```', ''} Lines = load_array{'```lines', '```', ''}
Line_width = Margin_left+256 -- drawing coordinates 1:1 with pixels
Current_drawing_mode = 'line' Current_drawing_mode = 'line'
App.draw() App.draw()
App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1) App.run_after_mouse_press(Margin_left+5, Margin_top+Drawing_padding_top+6, 1)

View File

@ -46,7 +46,7 @@ function draw_help_without_mouse_pressed(drawing)
love.graphics.print("Press 'esc' now to hide this message", Margin_left+30,y) love.graphics.print("Press 'esc' now to hide this message", Margin_left+30,y)
y = y + Line_height y = y + Line_height
love.graphics.setColor(0,0.5,0, 0.1) love.graphics.setColor(0,0.5,0, 0.1)
love.graphics.rectangle('fill', Margin_left,drawing.y, Line_width, math.max(Drawing.pixels(drawing.h),y-drawing.y)) love.graphics.rectangle('fill', Margin_left,drawing.y, App.screen.width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
end end
function draw_help_with_mouse_pressed(drawing) function draw_help_with_mouse_pressed(drawing)
@ -125,7 +125,7 @@ function draw_help_with_mouse_pressed(drawing)
y = y + Line_height y = y + Line_height
end end
love.graphics.setColor(0,0.5,0, 0.1) love.graphics.setColor(0,0.5,0, 0.1)
love.graphics.rectangle('fill', Margin_left,drawing.y, Line_width, math.max(Drawing.pixels(drawing.h),y-drawing.y)) love.graphics.rectangle('fill', Margin_left,drawing.y, App.screen.width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
end end
function current_shape(shape) function current_shape(shape)

View File

@ -111,7 +111,6 @@ function App.initialize(arg)
end end
initialize_font_settings(20) initialize_font_settings(20)
--? Line_width = 80
if #arg > 0 then if #arg > 0 then
Filename = arg[1] Filename = arg[1]
@ -170,7 +169,6 @@ end
function App.resize(w, h) function App.resize(w, h)
--? print(("Window resized to width: %d and height: %d."):format(w, h)) --? print(("Window resized to width: %d and height: %d."):format(w, h))
App.screen.width, App.screen.height = w, h App.screen.width, App.screen.height = w, h
Line_width = math.min(40*App.width(Em), App.screen.width-50)
Text.redraw_all() Text.redraw_all()
Last_resize_time = App.getTime() Last_resize_time = App.getTime()
end end
@ -181,10 +179,6 @@ function initialize_font_settings(font_height)
Line_height = math.floor(font_height*1.3) Line_height = math.floor(font_height*1.3)
Em = App.newText(love.graphics.getFont(), 'm') Em = App.newText(love.graphics.getFont(), 'm')
-- maximum width available to either text or drawings, in pixels
-- readable text width is 50-75 chars
Line_width = math.min(40*App.width(Em), App.screen.width-50)
end end
function App.filedropped(file) function App.filedropped(file)
@ -211,8 +205,6 @@ function App.draw()
Button_handlers = {} Button_handlers = {}
love.graphics.setColor(1, 1, 1) love.graphics.setColor(1, 1, 1)
love.graphics.rectangle('fill', 0, 0, App.screen.width-1, App.screen.height-1) love.graphics.rectangle('fill', 0, 0, App.screen.width-1, App.screen.height-1)
--? love.graphics.setColor(0, 1, 0)
--? love.graphics.line(Line_width,0, Line_width,App.screen.height)
love.graphics.setColor(0, 0, 0) love.graphics.setColor(0, 0, 0)
-- some hysteresis while resizing -- some hysteresis while resizing
@ -268,7 +260,7 @@ function App.draw()
if line_index == Screen_top1.line then if line_index == Screen_top1.line then
line.startpos = Screen_top1.pos line.startpos = Screen_top1.pos
end end
y, Screen_bottom1.pos = Text.draw(line, Line_width, line_index) y, Screen_bottom1.pos = Text.draw(line, line_index)
y = y + Line_height y = y + Line_height
--? print('=> y', y) --? print('=> y', y)
end end

View File

@ -11,17 +11,16 @@ require 'text_tests'
-- return values: -- return values:
-- y coordinate drawn until in px -- y coordinate drawn until in px
-- position of start of final screen line drawn -- position of start of final screen line drawn
function Text.draw(line, line_width, line_index) function Text.draw(line, line_index)
--? print('text.draw', line_index) --? print('text.draw', line_index)
love.graphics.setColor(0,0,0) love.graphics.setColor(0,0,0)
--? love.graphics.line(Line_width,0, Line_width,App.screen.height)
-- wrap long lines -- wrap long lines
local x = Margin_left local x = Margin_left
local y = line.starty local y = line.starty
local pos = 1 local pos = 1
local screen_line_starting_pos = 1 local screen_line_starting_pos = 1
if line.fragments == nil then if line.fragments == nil then
Text.compute_fragments(line, line_width) Text.compute_fragments(line)
end end
Text.populate_screen_line_starting_pos(line_index) Text.populate_screen_line_starting_pos(line_index)
--? print('--') --? print('--')
@ -31,8 +30,8 @@ function Text.draw(line, line_width, line_index)
local frag_width = App.width(frag_text) local frag_width = App.width(frag_text)
local frag_len = utf8.len(frag) local frag_len = utf8.len(frag)
--? local s=tostring --? local s=tostring
--? print('('..s(x)..','..s(y)..') '..frag..'('..s(frag_width)..' vs '..s(line_width)..') '..s(line_index)..' vs '..s(Screen_top1.line)..'; '..s(pos)..' vs '..s(Screen_top1.pos)..'; bottom: '..s(Screen_bottom1.line)..'/'..s(Screen_bottom1.pos)) --? print('('..s(x)..','..s(y)..') '..frag..'('..s(frag_width)..' vs '..s(App.screen.width)..') '..s(line_index)..' vs '..s(Screen_top1.line)..'; '..s(pos)..' vs '..s(Screen_top1.pos)..'; bottom: '..s(Screen_bottom1.line)..'/'..s(Screen_bottom1.pos))
if x + frag_width > line_width then if x + frag_width > App.screen.width then
assert(x > Margin_left) -- no overfull lines assert(x > Margin_left) -- no overfull lines
-- update y only after drawing the first screen line of screen top -- update y only after drawing the first screen line of screen top
if Text.lt1(Screen_top1, {line=line_index, pos=pos}) then if Text.lt1(Screen_top1, {line=line_index, pos=pos}) then
@ -81,7 +80,7 @@ function Text.draw(line, line_width, line_index)
return y, screen_line_starting_pos return y, screen_line_starting_pos
end end
-- manual tests: -- manual tests:
-- draw with small line_width of 100 -- draw with small screen width of 100
function Text.draw_cursor(x, y) function Text.draw_cursor(x, y)
-- blink every 0.5s -- blink every 0.5s
@ -94,32 +93,32 @@ function Text.draw_cursor(x, y)
Cursor_y = y+Line_height Cursor_y = y+Line_height
end end
function Text.compute_fragments(line, line_width) function Text.compute_fragments(line)
--? print('compute_fragments', line_width) --? print('compute_fragments', App.screen.width)
line.fragments = {} line.fragments = {}
local x = Margin_left local x = Margin_left
-- try to wrap at word boundaries -- try to wrap at word boundaries
for frag in line.data:gmatch('%S*%s*') do for frag in line.data:gmatch('%S*%s*') do
local frag_text = App.newText(love.graphics.getFont(), frag) local frag_text = App.newText(love.graphics.getFont(), frag)
local frag_width = App.width(frag_text) local frag_width = App.width(frag_text)
--? print('x: '..tostring(x)..'; '..tostring(line_width-x)..'px to go') --? print('x: '..tostring(x)..'; '..tostring(App.screen.width-x)..'px to go')
--? print('frag: ^'..frag..'$ is '..tostring(frag_width)..'px wide') --? print('frag: ^'..frag..'$ is '..tostring(frag_width)..'px wide')
if x + frag_width > line_width then if x + frag_width > App.screen.width then
while x + frag_width > line_width do while x + frag_width > App.screen.width do
--? print(x, frag, frag_width, line_width) --? print(x, frag, frag_width, App.screen.width)
if x < 0.8*line_width then if x < 0.8*App.screen.width then
--? print(frag, x, frag_width, line_width) --? print(frag, x, frag_width, App.screen.width)
-- long word; chop it at some letter -- long word; chop it at some letter
-- We're not going to reimplement TeX here. -- We're not going to reimplement TeX here.
local bpos = Text.nearest_pos_less_than(frag, line_width - x) local bpos = Text.nearest_pos_less_than(frag, App.screen.width - x)
assert(bpos > 0) -- avoid infinite loop when window is too narrow assert(bpos > 0) -- avoid infinite loop when window is too narrow
local boffset = Text.offset(frag, bpos+1) -- byte _after_ bpos local boffset = Text.offset(frag, bpos+1) -- byte _after_ bpos
--? print('space for '..tostring(bpos)..' graphemes, '..tostring(boffset)..' bytes') --? print('space for '..tostring(bpos)..' graphemes, '..tostring(boffset)..' bytes')
local frag1 = string.sub(frag, 1, boffset-1) local frag1 = string.sub(frag, 1, boffset-1)
local frag1_text = App.newText(love.graphics.getFont(), frag1) local frag1_text = App.newText(love.graphics.getFont(), frag1)
local frag1_width = App.width(frag1_text) local frag1_width = App.width(frag1_text)
--? print(frag, x, frag1_width, line_width) --? print(frag, x, frag1_width, App.screen.width)
assert(x + frag1_width <= line_width) assert(x + frag1_width <= App.screen.width)
--? print('inserting '..frag1..' of width '..tostring(frag1_width)..'px') --? print('inserting '..frag1..' of width '..tostring(frag1_width)..'px')
table.insert(line.fragments, {data=frag1, text=frag1_text}) table.insert(line.fragments, {data=frag1, text=frag1_text})
frag = string.sub(frag, boffset) frag = string.sub(frag, boffset)
@ -668,9 +667,9 @@ end
-- convert mx,my in pixels to schema-1 coordinates -- convert mx,my in pixels to schema-1 coordinates
function Text.to_pos_on_line(line, mx, my) function Text.to_pos_on_line(line, mx, my)
--? print('Text.to_pos_on_line', mx, my, 'width', Line_width) --? print('Text.to_pos_on_line', mx, my, 'width', App.screen.width)
if line.fragments == nil then if line.fragments == nil then
Text.compute_fragments(line, Line_width) Text.compute_fragments(line)
end end
assert(my >= line.starty) assert(my >= line.starty)
-- duplicate some logic from Text.draw -- duplicate some logic from Text.draw
@ -895,7 +894,7 @@ function Text.populate_screen_line_starting_pos(line_index)
end end
-- duplicate some logic from Text.draw -- duplicate some logic from Text.draw
if line.fragments == nil then if line.fragments == nil then
Text.compute_fragments(line, Line_width) Text.compute_fragments(line)
end end
line.screen_line_starting_pos = {1} line.screen_line_starting_pos = {1}
local x = Margin_left local x = Margin_left
@ -905,7 +904,7 @@ function Text.populate_screen_line_starting_pos(line_index)
-- render fragment -- render fragment
local frag_width = App.width(frag_text) local frag_width = App.width(frag_text)
--? print(x, pos, frag, frag_width) --? print(x, pos, frag, frag_width)
if x + frag_width > Line_width then if x + frag_width > App.screen.width then
x = Margin_left x = Margin_left
table.insert(line.screen_line_starting_pos, pos) table.insert(line.screen_line_starting_pos, pos)
--? print('new screen line:', #line.screen_line_starting_pos, pos) --? print('new screen line:', #line.screen_line_starting_pos, pos)

View File

@ -51,7 +51,6 @@ function test_press_ctrl()
-- press ctrl while the cursor is on text -- press ctrl while the cursor is on text
App.screen.init{width=50, height=80} App.screen.init{width=50, height=80}
Lines = load_array{''} Lines = load_array{''}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -63,7 +62,6 @@ function test_click_with_mouse()
-- display two lines with cursor on one of them -- display two lines with cursor on one of them
App.screen.init{width=50, height=80} App.screen.init{width=50, height=80}
Lines = load_array{'abc', 'def'} Lines = load_array{'abc', 'def'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -78,7 +76,6 @@ function test_draw_text()
io.write('\ntest_draw_text') io.write('\ntest_draw_text')
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'abc', 'def', 'ghi'} Lines = load_array{'abc', 'def', 'ghi'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -95,7 +92,6 @@ function test_draw_wrapping_text()
io.write('\ntest_draw_wrapping_text') io.write('\ntest_draw_wrapping_text')
App.screen.init{width=50, height=60} App.screen.init{width=50, height=60}
Lines = load_array{'abc', 'defgh', 'xyz'} Lines = load_array{'abc', 'defgh', 'xyz'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -112,7 +108,6 @@ function test_draw_word_wrapping_text()
io.write('\ntest_draw_word_wrapping_text') io.write('\ntest_draw_word_wrapping_text')
App.screen.init{width=60, height=60} App.screen.init{width=60, height=60}
Lines = load_array{'abc def ghi', 'jkl'} Lines = load_array{'abc def ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -130,7 +125,6 @@ function test_draw_text_wrapping_within_word()
io.write('\ntest_draw_text_wrapping_within_word') io.write('\ntest_draw_text_wrapping_within_word')
App.screen.init{width=60, height=60} App.screen.init{width=60, height=60}
Lines = load_array{'abcd e fghijk', 'xyz'} Lines = load_array{'abcd e fghijk', 'xyz'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -148,7 +142,6 @@ function test_draw_wrapping_text_containing_non_ascii()
io.write('\ntest_draw_wrapping_text_containing_non_ascii') io.write('\ntest_draw_wrapping_text_containing_non_ascii')
App.screen.init{width=60, height=60} App.screen.init{width=60, height=60}
Lines = load_array{'madam Im adam', 'xyz'} -- notice the non-ASCII apostrophe Lines = load_array{'madam Im adam', 'xyz'} -- notice the non-ASCII apostrophe
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -164,10 +157,9 @@ end
function test_click_on_wrapping_line() function test_click_on_wrapping_line()
io.write('\ntest_click_on_wrapping_line') io.write('\ntest_click_on_wrapping_line')
-- display a wrapping line -- display a wrapping line
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
-- 12345678901234 -- 12345678901234
Lines = load_array{"madam I'm adam"} Lines = load_array{"madam I'm adam"}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -187,10 +179,9 @@ end
function test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen() function test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen()
io.write('\ntest_click_on_wrapping_line_rendered_from_partway_at_top_of_screen') io.write('\ntest_click_on_wrapping_line_rendered_from_partway_at_top_of_screen')
-- display a wrapping line from its second screen line -- display a wrapping line from its second screen line
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
-- 12345678901234 -- 12345678901234
Lines = load_array{"madam I'm adam"} Lines = load_array{"madam I'm adam"}
Line_width = 75
Cursor1 = {line=1, pos=8} Cursor1 = {line=1, pos=8}
Screen_top1 = {line=1, pos=7} Screen_top1 = {line=1, pos=7}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -208,10 +199,9 @@ end
function test_click_past_end_of_wrapping_line() function test_click_past_end_of_wrapping_line()
io.write('\ntest_click_past_end_of_wrapping_line') io.write('\ntest_click_past_end_of_wrapping_line')
-- display a wrapping line -- display a wrapping line
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
-- 12345678901234 -- 12345678901234
Lines = load_array{"madam I'm adam"} Lines = load_array{"madam I'm adam"}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -232,10 +222,9 @@ end
function test_click_on_wrapping_line_containing_non_ascii() function test_click_on_wrapping_line_containing_non_ascii()
io.write('\ntest_click_on_wrapping_line_containing_non_ascii') io.write('\ntest_click_on_wrapping_line_containing_non_ascii')
-- display a wrapping line containing non-ASCII -- display a wrapping line containing non-ASCII
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
-- 12345678901234 -- 12345678901234
Lines = load_array{'madam Im adam'} -- notice the non-ASCII apostrophe Lines = load_array{'madam Im adam'} -- notice the non-ASCII apostrophe
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -256,11 +245,10 @@ end
function test_click_past_end_of_word_wrapping_line() function test_click_past_end_of_word_wrapping_line()
io.write('\ntest_click_past_end_of_word_wrapping_line') io.write('\ntest_click_past_end_of_word_wrapping_line')
-- display a long line wrapping at a word boundary on a screen of more realistic length -- display a long line wrapping at a word boundary on a screen of more realistic length
App.screen.init{width=200, height=80} App.screen.init{width=160, height=80}
-- 0 1 2 -- 0 1 2
-- 123456789012345678901 -- 123456789012345678901
Lines = load_array{'the quick brown fox jumped over the lazy dog'} Lines = load_array{'the quick brown fox jumped over the lazy dog'}
Line_width = 160
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -268,8 +256,8 @@ function test_click_past_end_of_word_wrapping_line()
local y = Margin_top local y = Margin_top
App.screen.check(y, 'the quick brown fox ', 'F - test_click_past_end_of_word_wrapping_line/baseline/screen:1') App.screen.check(y, 'the quick brown fox ', 'F - test_click_past_end_of_word_wrapping_line/baseline/screen:1')
y = y + Line_height y = y + Line_height
-- click past the end of the screen line but within Line_width -- click past the end of the screen line
App.run_after_mouse_click(Line_width-2,y-2, 1) App.run_after_mouse_click(App.screen.width-2,y-2, 1)
-- cursor moves to end of screen line -- cursor moves to end of screen line
check_eq(Cursor1.pos, 20, 'F - test_click_past_end_of_word_wrapping_line/cursor') check_eq(Cursor1.pos, 20, 'F - test_click_past_end_of_word_wrapping_line/cursor')
end end
@ -277,9 +265,8 @@ end
function test_select_text() function test_select_text()
io.write('\ntest_select_text') io.write('\ntest_select_text')
-- display a line of text -- display a line of text
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
Lines = load_array{'abc def'} Lines = load_array{'abc def'}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -299,9 +286,8 @@ end
function test_cursor_movement_without_shift_resets_selection() function test_cursor_movement_without_shift_resets_selection()
io.write('\ntest_cursor_movement_without_shift_resets_selection') io.write('\ntest_cursor_movement_without_shift_resets_selection')
-- display a line of text with some part selected -- display a line of text with some part selected
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
Lines = load_array{'abc'} Lines = load_array{'abc'}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Selection1 = {line=1, pos=2} Selection1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
@ -317,9 +303,8 @@ end
function test_edit_after_click_resets_selection() function test_edit_after_click_resets_selection()
io.write('\ntest_edit_after_click_resets_selection') io.write('\ntest_edit_after_click_resets_selection')
-- display a line of text -- display a line of text
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
Lines = load_array{'abc'} Lines = load_array{'abc'}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -335,9 +320,8 @@ end
function test_edit_deletes_selection() function test_edit_deletes_selection()
io.write('\ntest_edit_deletes_selection') io.write('\ntest_edit_deletes_selection')
-- display a line of text with some part selected -- display a line of text with some part selected
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
Lines = load_array{'abc'} Lines = load_array{'abc'}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Selection1 = {line=1, pos=2} Selection1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
@ -352,9 +336,8 @@ end
function test_edit_with_shift_key_deletes_selection() function test_edit_with_shift_key_deletes_selection()
io.write('\ntest_edit_with_shift_key_deletes_selection') io.write('\ntest_edit_with_shift_key_deletes_selection')
-- display a line of text with some part selected -- display a line of text with some part selected
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
Lines = load_array{'abc'} Lines = load_array{'abc'}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Selection1 = {line=1, pos=2} Selection1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
@ -374,9 +357,8 @@ end
function test_copy_does_not_reset_selection() function test_copy_does_not_reset_selection()
io.write('\ntest_copy_does_not_reset_selection') io.write('\ntest_copy_does_not_reset_selection')
-- display a line of text with a selection -- display a line of text with a selection
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
Lines = load_array{'abc'} Lines = load_array{'abc'}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Selection1 = {line=1, pos=2} Selection1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
@ -392,9 +374,8 @@ end
function test_cut() function test_cut()
io.write('\ntest_cut') io.write('\ntest_cut')
-- display a line of text with some part selected -- display a line of text with some part selected
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
Lines = load_array{'abc'} Lines = load_array{'abc'}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Selection1 = {line=1, pos=2} Selection1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
@ -410,9 +391,8 @@ end
function test_paste_replaces_selection() function test_paste_replaces_selection()
io.write('\ntest_paste_replaces_selection') io.write('\ntest_paste_replaces_selection')
-- display a line of text with a selection -- display a line of text with a selection
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
Lines = load_array{'abc', 'def'} Lines = load_array{'abc', 'def'}
Line_width = 75
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Selection1 = {line=1, pos=1} Selection1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
@ -432,7 +412,6 @@ function test_deleting_selection_may_scroll()
-- display lines 2/3/4 -- display lines 2/3/4
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=3, pos=2} Cursor1 = {line=3, pos=2}
Screen_top1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -456,7 +435,6 @@ function test_edit_wrapping_text()
io.write('\ntest_edit_wrapping_text') io.write('\ntest_edit_wrapping_text')
App.screen.init{width=50, height=60} App.screen.init{width=50, height=60}
Lines = load_array{'abc', 'def', 'xyz'} Lines = load_array{'abc', 'def', 'xyz'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=4} Cursor1 = {line=2, pos=4}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -478,7 +456,6 @@ function test_insert_newline()
-- display a few lines -- display a few lines
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=2} Cursor1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -507,7 +484,6 @@ function test_insert_newline_at_start_of_line()
-- display a line -- display a line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc'} Lines = load_array{'abc'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -524,7 +500,6 @@ function test_insert_from_clipboard()
-- display a few lines -- display a few lines
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=2} Cursor1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -553,7 +528,6 @@ function test_move_cursor_using_mouse()
io.write('\ntest_move_cursor_using_mouse') io.write('\ntest_move_cursor_using_mouse')
App.screen.init{width=50, height=60} App.screen.init{width=50, height=60}
Lines = load_array{'abc', 'def', 'xyz'} Lines = load_array{'abc', 'def', 'xyz'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -570,7 +544,6 @@ function test_select_text_using_mouse()
io.write('\ntest_select_text_using_mouse') io.write('\ntest_select_text_using_mouse')
App.screen.init{width=50, height=60} App.screen.init{width=50, height=60}
Lines = load_array{'abc', 'def', 'xyz'} Lines = load_array{'abc', 'def', 'xyz'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -590,7 +563,6 @@ function test_select_text_using_mouse_and_shift()
io.write('\ntest_select_text_using_mouse_and_shift') io.write('\ntest_select_text_using_mouse_and_shift')
App.screen.init{width=50, height=60} App.screen.init{width=50, height=60}
Lines = load_array{'abc', 'def', 'xyz'} Lines = load_array{'abc', 'def', 'xyz'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -614,7 +586,6 @@ function test_select_text_repeatedly_using_mouse_and_shift()
io.write('\ntest_select_text_repeatedly_using_mouse_and_shift') io.write('\ntest_select_text_repeatedly_using_mouse_and_shift')
App.screen.init{width=50, height=60} App.screen.init{width=50, height=60}
Lines = load_array{'abc', 'def', 'xyz'} Lines = load_array{'abc', 'def', 'xyz'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -644,7 +615,6 @@ function test_cut_without_selection()
-- display a few lines -- display a few lines
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=2} Cursor1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -660,7 +630,6 @@ function test_pagedown()
io.write('\ntest_pagedown') io.write('\ntest_pagedown')
App.screen.init{width=120, height=45} App.screen.init{width=120, height=45}
Lines = load_array{'abc', 'def', 'ghi'} Lines = load_array{'abc', 'def', 'ghi'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -690,7 +659,6 @@ function test_pagedown_skips_drawings()
'def', -- height 15 'def', -- height 15
'ghi'} -- height 15 'ghi'} -- height 15
check_eq(Lines[2].mode, 'drawing', 'F - test_pagedown_skips_drawings/baseline/lines') check_eq(Lines[2].mode, 'drawing', 'F - test_pagedown_skips_drawings/baseline/lines')
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -714,7 +682,6 @@ function test_pagedown_often_shows_start_of_wrapping_line()
-- draw a few lines ending in part of a wrapping line -- draw a few lines ending in part of a wrapping line
App.screen.init{width=50, height=60} App.screen.init{width=50, height=60}
Lines = load_array{'abc', 'def ghi jkl', 'mno'} Lines = load_array{'abc', 'def ghi jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -744,7 +711,6 @@ function test_pagedown_can_start_from_middle_of_long_wrapping_line()
-- draw a few lines starting from a very long wrapping line -- draw a few lines starting from a very long wrapping line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc def ghi jkl mno pqr stu vwx yza bcd efg hij', 'XYZ'} Lines = load_array{'abc def ghi jkl mno pqr stu vwx yza bcd efg hij', 'XYZ'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=2} Cursor1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -771,7 +737,6 @@ function test_down_arrow_moves_cursor()
io.write('\ntest_down_arrow_moves_cursor') io.write('\ntest_down_arrow_moves_cursor')
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -801,7 +766,6 @@ function test_down_arrow_scrolls_down_by_one_line()
-- display the first three lines with the cursor on the bottom line -- display the first three lines with the cursor on the bottom line
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=3, pos=1} Cursor1 = {line=3, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -829,7 +793,6 @@ function test_down_arrow_scrolls_down_by_one_screen_line()
-- display the first three lines with the cursor on the bottom line -- display the first three lines with the cursor on the bottom line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=3, pos=1} Cursor1 = {line=3, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -858,7 +821,6 @@ function test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_
-- display the first three lines with the cursor on the bottom line -- display the first three lines with the cursor on the bottom line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghijkl', 'mno'} Lines = load_array{'abc', 'def', 'ghijkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=3, pos=1} Cursor1 = {line=3, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -886,7 +848,6 @@ function test_page_down_followed_by_down_arrow_does_not_scroll_screen_up()
io.write('\ntest_page_down_followed_by_down_arrow_does_not_scroll_screen_up') io.write('\ntest_page_down_followed_by_down_arrow_does_not_scroll_screen_up')
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghijkl', 'mno'} Lines = load_array{'abc', 'def', 'ghijkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=3, pos=1} Cursor1 = {line=3, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -920,7 +881,6 @@ function test_up_arrow_moves_cursor()
-- display the first 3 lines with the cursor on the bottom line -- display the first 3 lines with the cursor on the bottom line
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = 120
Cursor1 = {line=3, pos=1} Cursor1 = {line=3, pos=1}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -949,7 +909,6 @@ function test_up_arrow_scrolls_up_by_one_line()
-- display the lines 2/3/4 with the cursor on line 2 -- display the lines 2/3/4 with the cursor on line 2
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = 120
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Screen_top1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -977,7 +936,6 @@ function test_up_arrow_scrolls_up_by_one_screen_line()
-- display lines starting from second screen line of a line -- display lines starting from second screen line of a line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=3, pos=6} Cursor1 = {line=3, pos=6}
Screen_top1 = {line=3, pos=5} Screen_top1 = {line=3, pos=5}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1005,7 +963,6 @@ function test_up_arrow_scrolls_up_to_final_screen_line()
-- display lines starting just after a long line -- display lines starting just after a long line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'} Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Screen_top1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1035,7 +992,6 @@ function test_up_arrow_scrolls_up_to_empty_line()
-- display a screenful of text with an empty line just above it outside the screen -- display a screenful of text with an empty line just above it outside the screen
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'', 'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'', 'abc', 'def', 'ghi', 'jkl'}
Line_width = 120
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Screen_top1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1062,7 +1018,6 @@ function test_pageup()
io.write('\ntest_pageup') io.write('\ntest_pageup')
App.screen.init{width=120, height=45} App.screen.init{width=120, height=45}
Lines = load_array{'abc', 'def', 'ghi'} Lines = load_array{'abc', 'def', 'ghi'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Screen_top1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1087,7 +1042,6 @@ function test_pageup_scrolls_up_by_screen_line()
-- display the first three lines with the cursor on the bottom line -- display the first three lines with the cursor on the bottom line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'} Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Screen_top1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1116,7 +1070,6 @@ function test_pageup_scrolls_up_from_middle_screen_line()
-- display a few lines starting from the middle of a line (Cursor1.pos > 1) -- display a few lines starting from the middle of a line (Cursor1.pos > 1)
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc def', 'ghi jkl', 'mno'} Lines = load_array{'abc def', 'ghi jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=5} Cursor1 = {line=2, pos=5}
Screen_top1 = {line=2, pos=5} Screen_top1 = {line=2, pos=5}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1143,7 +1096,6 @@ function test_enter_on_bottom_line_scrolls_down()
-- display a few lines with cursor on bottom line -- display a few lines with cursor on bottom line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=3, pos=2} Cursor1 = {line=3, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1172,7 +1124,6 @@ function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom()
-- display just the bottom line on screen -- display just the bottom line on screen
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=4, pos=2} Cursor1 = {line=4, pos=2}
Screen_top1 = {line=4, pos=1} Screen_top1 = {line=4, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1195,7 +1146,6 @@ function test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bot
-- display just an empty bottom line on screen -- display just an empty bottom line on screen
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', ''} Lines = load_array{'abc', ''}
Line_width = App.screen.width
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Screen_top1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1214,7 +1164,6 @@ function test_typing_on_bottom_line_scrolls_down()
-- display a few lines with cursor on bottom line -- display a few lines with cursor on bottom line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = App.screen.width
Cursor1 = {line=3, pos=4} Cursor1 = {line=3, pos=4}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1245,7 +1194,6 @@ function test_left_arrow_scrolls_up_in_wrapped_line()
-- display lines starting from second screen line of a line -- display lines starting from second screen line of a line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
Line_width = App.screen.width
Screen_top1 = {line=3, pos=5} Screen_top1 = {line=3, pos=5}
Screen_bottom1 = {} Screen_bottom1 = {}
-- cursor is at top of screen -- cursor is at top of screen
@ -1274,7 +1222,6 @@ function test_right_arrow_scrolls_down_in_wrapped_line()
-- display the first three lines with the cursor on the bottom line -- display the first three lines with the cursor on the bottom line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
Line_width = App.screen.width
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
-- cursor is at bottom right of screen -- cursor is at bottom right of screen
@ -1304,7 +1251,6 @@ function test_home_scrolls_up_in_wrapped_line()
-- display lines starting from second screen line of a line -- display lines starting from second screen line of a line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
Line_width = App.screen.width
Screen_top1 = {line=3, pos=5} Screen_top1 = {line=3, pos=5}
Screen_bottom1 = {} Screen_bottom1 = {}
-- cursor is at top of screen -- cursor is at top of screen
@ -1333,7 +1279,6 @@ function test_end_scrolls_down_in_wrapped_line()
-- display the first three lines with the cursor on the bottom line -- display the first three lines with the cursor on the bottom line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
Line_width = App.screen.width
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
-- cursor is at bottom right of screen -- cursor is at bottom right of screen
@ -1361,9 +1306,8 @@ end
function test_position_cursor_on_recently_edited_wrapping_line() function test_position_cursor_on_recently_edited_wrapping_line()
-- draw a line wrapping over 2 screen lines -- draw a line wrapping over 2 screen lines
io.write('\ntest_position_cursor_on_recently_edited_wrapping_line') io.write('\ntest_position_cursor_on_recently_edited_wrapping_line')
App.screen.init{width=120, height=200} App.screen.init{width=100, height=200}
Lines = load_array{'abc def ghi jkl mno pqr ', 'xyz'} Lines = load_array{'abc def ghi jkl mno pqr ', 'xyz'}
Line_width = 100
Cursor1 = {line=1, pos=25} Cursor1 = {line=1, pos=25}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1397,7 +1341,6 @@ function test_backspace_can_scroll_up()
-- display the lines 2/3/4 with the cursor on line 2 -- display the lines 2/3/4 with the cursor on line 2
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Lines = load_array{'abc', 'def', 'ghi', 'jkl'}
Line_width = 120
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Screen_top1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1425,7 +1368,6 @@ function test_backspace_can_scroll_up_screen_line()
-- display lines starting from second screen line of a line -- display lines starting from second screen line of a line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=3, pos=5} Cursor1 = {line=3, pos=5}
Screen_top1 = {line=3, pos=5} Screen_top1 = {line=3, pos=5}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1453,7 +1395,6 @@ function test_backspace_past_line_boundary()
-- position cursor at start of a (non-first) line -- position cursor at start of a (non-first) line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def'} Lines = load_array{'abc', 'def'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
-- backspace joins with previous line -- backspace joins with previous line
App.run_after_keychord('backspace') App.run_after_keychord('backspace')
@ -1468,7 +1409,6 @@ function test_backspace_over_selection()
-- select just one character within a line with cursor before selection -- select just one character within a line with cursor before selection
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Selection1 = {line=1, pos=2} Selection1 = {line=1, pos=2}
-- backspace deletes the selected character, even though it's after the cursor -- backspace deletes the selected character, even though it's after the cursor
@ -1486,7 +1426,6 @@ function test_backspace_over_selection_reverse()
-- select just one character within a line with cursor after selection -- select just one character within a line with cursor after selection
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=2} Cursor1 = {line=1, pos=2}
Selection1 = {line=1, pos=1} Selection1 = {line=1, pos=1}
-- backspace deletes the selected character -- backspace deletes the selected character
@ -1504,7 +1443,6 @@ function test_backspace_over_multiple_lines()
-- select just one character within a line with cursor after selection -- select just one character within a line with cursor after selection
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=2} Cursor1 = {line=1, pos=2}
Selection1 = {line=4, pos=2} Selection1 = {line=4, pos=2}
-- backspace deletes the region and joins the remaining portions of lines on either side -- backspace deletes the region and joins the remaining portions of lines on either side
@ -1523,7 +1461,6 @@ function test_backspace_to_end_of_line()
-- select region from cursor to end of line -- select region from cursor to end of line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=1, pos=2} Cursor1 = {line=1, pos=2}
Selection1 = {line=1, pos=4} Selection1 = {line=1, pos=4}
-- backspace deletes rest of line without joining to any other line -- backspace deletes rest of line without joining to any other line
@ -1542,7 +1479,6 @@ function test_backspace_to_start_of_line()
-- select region from cursor to start of line -- select region from cursor to start of line
App.screen.init{width=Margin_left+30, height=60} App.screen.init{width=Margin_left+30, height=60}
Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=1} Cursor1 = {line=2, pos=1}
Selection1 = {line=2, pos=3} Selection1 = {line=2, pos=3}
-- backspace deletes beginning of line without joining to any other line -- backspace deletes beginning of line without joining to any other line
@ -1560,7 +1496,6 @@ function test_undo_insert_text()
io.write('\ntest_undo_insert_text') io.write('\ntest_undo_insert_text')
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'abc', 'def', 'xyz'} Lines = load_array{'abc', 'def', 'xyz'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=4} Cursor1 = {line=2, pos=4}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1595,7 +1530,6 @@ function test_undo_delete_text()
io.write('\ntest_undo_delete_text') io.write('\ntest_undo_delete_text')
App.screen.init{width=120, height=60} App.screen.init{width=120, height=60}
Lines = load_array{'abc', 'defg', 'xyz'} Lines = load_array{'abc', 'defg', 'xyz'}
Line_width = App.screen.width
Cursor1 = {line=2, pos=5} Cursor1 = {line=2, pos=5}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}
Screen_bottom1 = {} Screen_bottom1 = {}
@ -1631,9 +1565,8 @@ end
function test_undo_restores_selection() function test_undo_restores_selection()
io.write('\ntest_undo_restores_selection') io.write('\ntest_undo_restores_selection')
-- display a line of text with some part selected -- display a line of text with some part selected
App.screen.init{width=80, height=80} App.screen.init{width=75, height=80}
Lines = load_array{'abc'} Lines = load_array{'abc'}
Line_width = 75
Cursor1 = {line=1, pos=1} Cursor1 = {line=1, pos=1}
Selection1 = {line=1, pos=2} Selection1 = {line=1, pos=2}
Screen_top1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1}