diff options
-rw-r--r-- | drawing.lua | 60 | ||||
-rw-r--r-- | main.lua | 3 | ||||
-rw-r--r-- | text.lua | 22 | ||||
-rw-r--r-- | text_tests.lua | 82 |
4 files changed, 81 insertions, 86 deletions
diff --git a/drawing.lua b/drawing.lua index 4a9d77d..1790953 100644 --- a/drawing.lua +++ b/drawing.lua @@ -6,13 +6,13 @@ geom = require 'geom' -- into 256 parts. function Drawing.draw(line) local pmx,pmy = App.mouse_x(), App.mouse_y() - if pmx < 16+Line_width and pmy > line.y and pmy < line.y+Drawing.pixels(line.h) then + if pmx < Margin_left+Line_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.rectangle('line', 16,line.y, Line_width,Drawing.pixels(line.h)) + love.graphics.rectangle('line', Margin_left,line.y, Line_width,Drawing.pixels(line.h)) if icon[Current_drawing_mode] then - icon[Current_drawing_mode](16+Line_width-20, line.y+4) + icon[Current_drawing_mode](Margin_left+Line_width-20, line.y+4) else - icon[Previous_drawing_mode](16+Line_width-20, line.y+4) + icon[Previous_drawing_mode](Margin_left+Line_width-20, line.y+4) end if App.mouse_down(1) and love.keyboard.isDown('h') then @@ -26,7 +26,7 @@ function Drawing.draw(line) return end - local mx,my = Drawing.coord(pmx-16), Drawing.coord(pmy-line.y) + local mx,my = Drawing.coord(pmx-Margin_left), Drawing.coord(pmy-line.y) for _,shape in ipairs(line.shapes) do assert(shape) @@ -35,20 +35,20 @@ function Drawing.draw(line) else love.graphics.setColor(0,0,0) end - Drawing.draw_shape(16,line.y, line, shape) + Drawing.draw_shape(Margin_left,line.y, line, shape) end for i,p in ipairs(line.points) do if p.deleted == nil then if Drawing.near(p, mx,my) then love.graphics.setColor(1,0,0) - love.graphics.circle('line', Drawing.pixels(p.x)+16,Drawing.pixels(p.y)+line.y, 4) + love.graphics.circle('line', Drawing.pixels(p.x)+Margin_left,Drawing.pixels(p.y)+line.y, 4) else love.graphics.setColor(0,0,0) - love.graphics.circle('fill', Drawing.pixels(p.x)+16,Drawing.pixels(p.y)+line.y, 2) + love.graphics.circle('fill', Drawing.pixels(p.x)+Margin_left,Drawing.pixels(p.y)+line.y, 2) end if p.name then -- todo: clip - local x,y = Drawing.pixels(p.x)+16+5, Drawing.pixels(p.y)+line.y+5 + local x,y = Drawing.pixels(p.x)+Margin_left+5, Drawing.pixels(p.y)+line.y+5 love.graphics.print(p.name, x,y) if Current_drawing_mode == 'name' and i == line.pending.target_point then -- create a faint red box for the name @@ -66,7 +66,7 @@ function Drawing.draw(line) end end love.graphics.setColor(0.75,0.75,0.75) - Drawing.draw_pending_shape(16,line.y, line) + Drawing.draw_pending_shape(Margin_left,line.y, line) end function Drawing.draw_shape(left,top, drawing, shape) @@ -207,15 +207,15 @@ end function Drawing.mouse_pressed(drawing, x,y, button) if Current_drawing_mode == 'freehand' then - drawing.pending = {mode=Current_drawing_mode, points={{x=Drawing.coord(x-16), y=Drawing.coord(y-drawing.y)}}} + drawing.pending = {mode=Current_drawing_mode, points={{x=Drawing.coord(x-Margin_left), y=Drawing.coord(y-drawing.y)}}} elseif Current_drawing_mode == 'line' or Current_drawing_mode == 'manhattan' then - local j = Drawing.insert_point(drawing.points, Drawing.coord(x-16), Drawing.coord(y-drawing.y)) + local j = Drawing.insert_point(drawing.points, Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y)) drawing.pending = {mode=Current_drawing_mode, p1=j} elseif Current_drawing_mode == 'polygon' or Current_drawing_mode == 'rectangle' or Current_drawing_mode == 'square' then - local j = Drawing.insert_point(drawing.points, Drawing.coord(x-16), Drawing.coord(y-drawing.y)) + local j = Drawing.insert_point(drawing.points, Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y)) drawing.pending = {mode=Current_drawing_mode, vertices={j}} elseif Current_drawing_mode == 'circle' then - local j = Drawing.insert_point(drawing.points, Drawing.coord(x-16), Drawing.coord(y-drawing.y)) + local j = Drawing.insert_point(drawing.points, Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y)) drawing.pending = {mode=Current_drawing_mode, center=j} elseif Current_drawing_mode == 'move' then -- all the action is in mouse_released @@ -236,16 +236,16 @@ function Drawing.update() if App.mouse_down(1) then if Drawing.in_drawing(drawing, x,y) then if drawing.pending.mode == 'freehand' then - table.insert(drawing.pending.points, {x=Drawing.coord(App.mouse_x()-16), y=Drawing.coord(App.mouse_y()-drawing.y)}) + table.insert(drawing.pending.points, {x=Drawing.coord(App.mouse_x()-Margin_left), y=Drawing.coord(App.mouse_y()-drawing.y)}) elseif drawing.pending.mode == 'move' then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) drawing.pending.target_point.x = mx drawing.pending.target_point.y = my end end elseif Current_drawing_mode == 'move' then if Drawing.in_drawing(drawing, x, y) then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) drawing.pending.target_point.x = mx drawing.pending.target_point.y = my end @@ -265,7 +265,7 @@ function Drawing.mouse_released(x,y, button) -- the last point added during update is good enough table.insert(drawing.shapes, drawing.pending) elseif drawing.pending.mode == 'line' then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) if mx >= 0 and mx < 256 and my >= 0 and my < drawing.h then local j = Drawing.insert_point(drawing.points, mx,my) drawing.pending.p2 = j @@ -273,7 +273,7 @@ function Drawing.mouse_released(x,y, button) end elseif drawing.pending.mode == 'manhattan' then local p1 = drawing.points[drawing.pending.p1] - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) if mx >= 0 and mx < 256 and my >= 0 and my < drawing.h then if math.abs(mx-p1.x) > math.abs(my-p1.y) then local j = Drawing.insert_point(drawing.points, mx, p1.y) @@ -283,11 +283,11 @@ function Drawing.mouse_released(x,y, button) drawing.pending.p2 = j end local p2 = drawing.points[drawing.pending.p2] - App.mouse_move(16+Drawing.pixels(p2.x), drawing.y+Drawing.pixels(p2.y)) + App.mouse_move(Margin_left+Drawing.pixels(p2.x), drawing.y+Drawing.pixels(p2.y)) table.insert(drawing.shapes, drawing.pending) end elseif drawing.pending.mode == 'polygon' then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) if mx >= 0 and mx < 256 and my >= 0 and my < drawing.h then table.insert(drawing.pending.vertices, Drawing.insert_point(drawing.points, mx,my)) table.insert(drawing.shapes, drawing.pending) @@ -295,7 +295,7 @@ function Drawing.mouse_released(x,y, button) elseif drawing.pending.mode == 'rectangle' then assert(#drawing.pending.vertices <= 2) if #drawing.pending.vertices == 2 then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) if mx >= 0 and mx < 256 and my >= 0 and my < drawing.h then local first = drawing.points[drawing.pending.vertices[1]] local second = drawing.points[drawing.pending.vertices[2]] @@ -310,7 +310,7 @@ function Drawing.mouse_released(x,y, button) elseif drawing.pending.mode == 'square' then assert(#drawing.pending.vertices <= 2) if #drawing.pending.vertices == 2 then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) if mx >= 0 and mx < 256 and my >= 0 and my < drawing.h then local first = drawing.points[drawing.pending.vertices[1]] local second = drawing.points[drawing.pending.vertices[2]] @@ -321,14 +321,14 @@ function Drawing.mouse_released(x,y, button) end end elseif drawing.pending.mode == 'circle' then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) if mx >= 0 and mx < 256 and my >= 0 and my < drawing.h then local center = drawing.points[drawing.pending.center] drawing.pending.radius = geom.dist(center.x,center.y, mx,my) table.insert(drawing.shapes, drawing.pending) end elseif drawing.pending.mode == 'arc' then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) if mx >= 0 and mx < 256 and my >= 0 and my < drawing.h then local center = drawing.points[drawing.pending.center] drawing.pending.end_angle = geom.angle_with_hint(center.x,center.y, mx,my, drawing.pending.end_angle) @@ -408,7 +408,7 @@ function Drawing.keychord_pressed(chord) drawing.pending.mode = 'square' elseif App.mouse_down(1) and chord == 'p' and (Current_drawing_mode == 'polygon' or Current_drawing_mode == 'rectangle' or Current_drawing_mode == 'square') then local _,drawing = Drawing.current_drawing() - local mx,my = Drawing.coord(App.mouse_x()-16), Drawing.coord(App.mouse_y()-drawing.y) + local mx,my = Drawing.coord(App.mouse_x()-Margin_left), Drawing.coord(App.mouse_y()-drawing.y) local j = Drawing.insert_point(drawing.points, mx,my) table.insert(drawing.pending.vertices, j) elseif chord == 'C-o' and not App.mouse_down(1) then @@ -416,7 +416,7 @@ function Drawing.keychord_pressed(chord) elseif App.mouse_down(1) and chord == 'a' and Current_drawing_mode == 'circle' then local _,drawing = Drawing.current_drawing() drawing.pending.mode = 'arc' - local mx,my = Drawing.coord(App.mouse_x()-16), Drawing.coord(App.mouse_y()-drawing.y) + local mx,my = Drawing.coord(App.mouse_x()-Margin_left), Drawing.coord(App.mouse_y()-drawing.y) local j = Drawing.insert_point(drawing.points, mx,my) local center = drawing.points[drawing.pending.center] drawing.pending.radius = geom.dist(center.x,center.y, mx,my) @@ -596,7 +596,7 @@ function Drawing.select_shape_at_mouse() if drawing.mode == 'drawing' then local x, y = App.mouse_x(), App.mouse_y() if Drawing.in_drawing(drawing, x,y) then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) for i,shape in ipairs(drawing.shapes) do assert(shape) if geom.on_shape(mx,my, drawing, shape) then @@ -613,7 +613,7 @@ function Drawing.select_point_at_mouse() if drawing.mode == 'drawing' then local x, y = App.mouse_x(), App.mouse_y() if Drawing.in_drawing(drawing, x,y) then - local mx,my = Drawing.coord(x-16), Drawing.coord(y-drawing.y) + local mx,my = Drawing.coord(x-Margin_left), Drawing.coord(y-drawing.y) for i,point in ipairs(drawing.points) do assert(point) if Drawing.near(point, mx,my) then @@ -709,7 +709,7 @@ end function Drawing.near(point, x,y) local px,py = Drawing.pixels(x),Drawing.pixels(y) local cx,cy = Drawing.pixels(point.x), Drawing.pixels(point.y) - return (cx-px)*(cx-px) + (cy-py)*(cy-py) < 16 + return (cx-px)*(cx-px) + (cy-py)*(cy-py) < Margin_left end function Drawing.pixels(n) -- parts to pixels diff --git a/main.lua b/main.lua index db5d1ba..e7f7aa4 100644 --- a/main.lua +++ b/main.lua @@ -68,6 +68,7 @@ Font_height = 14 Line_height = 15 Margin_top = 15 +Margin_left = 25 Filename = love.filesystem.getUserDirectory()..'/lines.txt' @@ -233,7 +234,7 @@ function App.draw() end}) if Search_term == nil then if line_index == Cursor1.line then - Text.draw_cursor(25, y) + Text.draw_cursor(Margin_left, y) end end Screen_bottom1.pos = Screen_top1.pos diff --git a/text.lua b/text.lua index 0940776..a85a490 100644 --- a/text.lua +++ b/text.lua @@ -15,7 +15,7 @@ function Text.draw(line, line_width, line_index) --? print('text.draw', line_index) love.graphics.setColor(0,0,0) -- wrap long lines - local x = 25 + local x = Margin_left local y = line.y local pos = 1 local screen_line_starting_pos = 1 @@ -32,7 +32,7 @@ function Text.draw(line, line_width, line_index) --? 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)) if x + frag_width > line_width then - assert(x > 25) -- no overfull lines + assert(x > Margin_left) -- no overfull lines -- update y only after drawing the first screen line of screen top if Text.lt1(Screen_top1, {line=line_index, pos=pos}) then y = y + Line_height @@ -43,7 +43,7 @@ function Text.draw(line, line_width, line_index) screen_line_starting_pos = pos --? print('text: new screen line', y, App.screen.height, screen_line_starting_pos) end - x = 25 + x = Margin_left end --? print('checking to draw', pos, Screen_top1.pos) -- don't draw text above screen top @@ -96,7 +96,7 @@ end function Text.compute_fragments(line, line_width) --? print('compute_fragments', line_width) line.fragments = {} - local x = 25 + local x = Margin_left -- try to wrap at word boundaries for frag in line.data:gmatch('%S*%s*') do local frag_text = App.newText(love.graphics.getFont(), frag) @@ -126,7 +126,7 @@ function Text.compute_fragments(line, line_width) frag_text = App.newText(love.graphics.getFont(), frag) frag_width = App.width(frag_text) end - x = 25 -- new line + x = Margin_left -- new line end end if #frag > 0 then @@ -679,7 +679,7 @@ end function Text.in_line(line_index,line, x,y) if line.y == nil then return false end -- outside current page - if x < 25 then return false end + if x < Margin_left then return false end if y < line.y then return false end Text.populate_screen_line_starting_pos(line_index) return y < line.y + #line.screen_line_starting_pos * Line_height @@ -735,7 +735,7 @@ function Text.nearest_cursor_pos(line, x) -- x includes left margin return 1 end local len = utf8.len(line) - local max_x = 25+Text.x(line, len+1) + local max_x = Margin_left+Text.x(line, len+1) if x > max_x then return len+1 end @@ -747,8 +747,8 @@ function Text.nearest_cursor_pos(line, x) -- x includes left margin return left end local curr = math.floor((left+right)/2) - local currxmin = 25+Text.x(line, curr) - local currxmax = 25+Text.x(line, curr+1) + local currxmin = Margin_left+Text.x(line, curr) + local currxmax = Margin_left+Text.x(line, curr+1) --? print('nearest', x, left, right, curr, currxmin, currxmax) if currxmin <= x and x < currxmax then if x-currxmin < currxmax-x then @@ -883,7 +883,7 @@ function Text.populate_screen_line_starting_pos(line_index) Text.compute_fragments(line, Line_width) end line.screen_line_starting_pos = {1} - local x = 25 + local x = Margin_left local pos = 1 for _, f in ipairs(line.fragments) do local frag, frag_text = f.data, f.text @@ -891,7 +891,7 @@ function Text.populate_screen_line_starting_pos(line_index) local frag_width = App.width(frag_text) --? print(x, pos, frag, frag_width) if x + frag_width > Line_width then - x = 25 + x = Margin_left table.insert(line.screen_line_starting_pos, pos) --? print('new screen line:', #line.screen_line_starting_pos, pos) end diff --git a/text_tests.lua b/text_tests.lua index c1aa4ca..4398252 100644 --- a/text_tests.lua +++ b/text_tests.lua @@ -68,9 +68,8 @@ function test_click_with_mouse() Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} -- click on the other line - local screen_left_margin = 25 -- pixels App.draw() - App.run_after_mouse_click(screen_left_margin+8,Margin_top+5, 1) + App.run_after_mouse_click(Margin_left+8,Margin_top+5, 1) -- cursor moves check_eq(Cursor1.line, 1, 'F - test_click_with_mouse/cursor') end @@ -211,7 +210,7 @@ end function test_insert_newline() io.write('\ntest_insert_newline') -- display a few lines - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Line_width = App.screen.width Cursor1 = {line=1, pos=2} @@ -240,7 +239,7 @@ end function test_insert_newline_at_start_of_line() io.write('\ntest_insert_newline_at_start_of_line') -- display a line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc'} Line_width = App.screen.width Cursor1 = {line=1, pos=1} @@ -257,7 +256,7 @@ end function test_insert_from_clipboard() io.write('\ntest_insert_from_clipboard') -- display a few lines - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Line_width = App.screen.width Cursor1 = {line=1, pos=2} @@ -294,8 +293,7 @@ function test_move_cursor_using_mouse() Screen_bottom1 = {} Selection1 = {} App.draw() -- populate line.y for each line in Lines - local screen_left_margin = 25 -- pixels - App.run_after_mouse_release(screen_left_margin+8,Margin_top+5, 1) + App.run_after_mouse_release(Margin_left+8,Margin_top+5, 1) check_eq(Cursor1.line, 1, 'F - test_move_cursor_using_mouse/cursor:line') check_eq(Cursor1.pos, 2, 'F - test_move_cursor_using_mouse/cursor:pos') check_nil(Selection1.line, 'F - test_move_cursor_using_mouse/selection:line') @@ -312,11 +310,10 @@ function test_select_text_using_mouse() Screen_bottom1 = {} Selection1 = {} App.draw() -- populate line.y for each line in Lines - local screen_left_margin = 25 -- pixels -- press and hold on first location - App.run_after_mouse_press(screen_left_margin+8,Margin_top+5, 1) + App.run_after_mouse_press(Margin_left+8,Margin_top+5, 1) -- drag and release somewhere else - App.run_after_mouse_release(screen_left_margin+20,Margin_top+Line_height+5, 1) + App.run_after_mouse_release(Margin_left+20,Margin_top+Line_height+5, 1) check_eq(Selection1.line, 1, 'F - test_select_text_using_mouse/selection:line') check_eq(Selection1.pos, 2, 'F - test_select_text_using_mouse/selection:pos') check_eq(Cursor1.line, 2, 'F - test_select_text_using_mouse/cursor:line') @@ -333,14 +330,13 @@ function test_select_text_using_mouse_and_shift() Screen_bottom1 = {} Selection1 = {} App.draw() -- populate line.y for each line in Lines - local screen_left_margin = 25 -- pixels -- click on first location - App.run_after_mouse_press(screen_left_margin+8,Margin_top+5, 1) - App.run_after_mouse_release(screen_left_margin+8,Margin_top+5, 1) + App.run_after_mouse_press(Margin_left+8,Margin_top+5, 1) + App.run_after_mouse_release(Margin_left+8,Margin_top+5, 1) -- hold down shift and click somewhere else App.fake_key_press('lshift') - App.run_after_mouse_press(screen_left_margin+20,Margin_top+5, 1) - App.run_after_mouse_release(screen_left_margin+20,Margin_top+Line_height+5, 1) + App.run_after_mouse_press(Margin_left+20,Margin_top+5, 1) + App.run_after_mouse_release(Margin_left+20,Margin_top+Line_height+5, 1) App.fake_key_release('lshift') check_eq(Selection1.line, 1, 'F - test_select_text_using_mouse_and_shift/selection:line') check_eq(Selection1.pos, 2, 'F - test_select_text_using_mouse_and_shift/selection:pos') @@ -358,18 +354,17 @@ function test_select_text_repeatedly_using_mouse_and_shift() Screen_bottom1 = {} Selection1 = {} App.draw() -- populate line.y for each line in Lines - local screen_left_margin = 25 -- pixels -- click on first location - App.run_after_mouse_press(screen_left_margin+8,Margin_top+5, 1) - App.run_after_mouse_release(screen_left_margin+8,Margin_top+5, 1) + App.run_after_mouse_press(Margin_left+8,Margin_top+5, 1) + App.run_after_mouse_release(Margin_left+8,Margin_top+5, 1) -- hold down shift and click on a second location App.fake_key_press('lshift') - App.run_after_mouse_press(screen_left_margin+20,Margin_top+5, 1) - App.run_after_mouse_release(screen_left_margin+20,Margin_top+Line_height+5, 1) + App.run_after_mouse_press(Margin_left+20,Margin_top+5, 1) + App.run_after_mouse_release(Margin_left+20,Margin_top+Line_height+5, 1) -- hold down shift and click at a third location App.fake_key_press('lshift') - App.run_after_mouse_press(screen_left_margin+20,Margin_top+5, 1) - App.run_after_mouse_release(screen_left_margin+8,Margin_top+Line_height+5, 1) + App.run_after_mouse_press(Margin_left+20,Margin_top+5, 1) + App.run_after_mouse_release(Margin_left+8,Margin_top+Line_height+5, 1) App.fake_key_release('lshift') -- selection is between first and third location. forget the second location, not the first. check_eq(Selection1.line, 1, 'F - test_select_text_repeatedly_using_mouse_and_shift/selection:line') @@ -381,7 +376,7 @@ end function test_cut_without_selection() io.write('\ntest_cut_without_selection') -- display a few lines - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Line_width = App.screen.width Cursor1 = {line=1, pos=2} @@ -480,7 +475,7 @@ end function test_pagedown_can_start_from_middle_of_long_wrapping_line() io.write('\ntest_pagedown_can_start_from_middle_of_long_wrapping_line') -- draw a few lines starting from a very long wrapping line - App.screen.init{width=25+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'} Line_width = App.screen.width Cursor1 = {line=1, pos=2} @@ -565,7 +560,7 @@ end function test_down_arrow_scrolls_down_by_one_screen_line() io.write('\ntest_down_arrow_scrolls_down_by_one_screen_line') -- display the first three lines with the cursor on the bottom line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=3, pos=1} @@ -594,7 +589,7 @@ end function test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word() io.write('\ntest_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_word') -- display the first three lines with the cursor on the bottom line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghijkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=3, pos=1} @@ -622,7 +617,7 @@ end 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') - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghijkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=3, pos=1} @@ -713,7 +708,7 @@ end function test_up_arrow_scrolls_up_by_one_screen_line() io.write('\ntest_up_arrow_scrolls_up_by_one_screen_line') -- display lines starting from second screen line of a line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=3, pos=6} @@ -741,7 +736,7 @@ end function test_up_arrow_scrolls_up_to_final_screen_line() io.write('\ntest_up_arrow_scrolls_up_to_final_screen_line') -- display lines starting just after a long line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=2, pos=1} @@ -823,7 +818,7 @@ end function test_pageup_scrolls_up_by_screen_line() io.write('\ntest_pageup_scrolls_up_by_screen_line') -- display the first three lines with the cursor on the bottom line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=2, pos=1} @@ -852,7 +847,7 @@ end function test_pageup_scrolls_up_from_middle_screen_line() io.write('\ntest_pageup_scrolls_up_from_middle_screen_line') -- display a few lines starting from the middle of a line (Cursor1.pos > 1) - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc def', 'ghi jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=2, pos=5} @@ -879,7 +874,7 @@ end function test_enter_on_bottom_line_scrolls_down() io.write('\ntest_enter_on_bottom_line_scrolls_down') -- display a few lines with cursor on bottom line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Line_width = App.screen.width Cursor1 = {line=3, pos=2} @@ -908,7 +903,7 @@ end function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom() io.write('\ntest_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom') -- display just the bottom line on screen - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Line_width = App.screen.width Cursor1 = {line=4, pos=2} @@ -931,7 +926,7 @@ end function test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bottom() io.write('\ntest_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bottom') -- display just an empty bottom line on screen - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', ''} Line_width = App.screen.width Cursor1 = {line=2, pos=1} @@ -950,7 +945,7 @@ end function test_typing_on_bottom_line_scrolls_down() io.write('\ntest_typing_on_bottom_line_scrolls_down') -- display a few lines with cursor on bottom line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} Line_width = App.screen.width Cursor1 = {line=3, pos=4} @@ -1006,8 +1001,7 @@ function test_position_cursor_on_recently_edited_wrapping_line() y = y + Line_height App.screen.check(y, 'stu', 'F - test_position_cursor_on_recently_edited_wrapping_line/baseline2/screen:3') -- try to move the cursor earlier in the third screen line by clicking the mouse - local screen_left_margin = 25 -- pixels - App.run_after_mouse_release(screen_left_margin+8,Margin_top+Line_height*2+5, 1) + App.run_after_mouse_release(Margin_left+8,Margin_top+Line_height*2+5, 1) -- cursor should move check_eq(Cursor1.line, 1, 'F - test_move_cursor_using_mouse/cursor:line') check_eq(Cursor1.pos, 26, 'F - test_move_cursor_using_mouse/cursor:pos') @@ -1044,7 +1038,7 @@ end function test_backspace_can_scroll_up_screen_line() io.write('\ntest_backspace_can_scroll_up_screen_line') -- display lines starting from second screen line of a line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=3, pos=5} @@ -1072,7 +1066,7 @@ end function test_backspace_past_line_boundary() io.write('\ntest_backspace_past_line_boundary') -- position cursor at start of a (non-first) line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def'} Line_width = App.screen.width Cursor1 = {line=2, pos=1} @@ -1087,7 +1081,7 @@ end function test_backspace_over_selection() io.write('\ntest_backspace_over_selection') -- select just one character within a line with cursor before selection - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=1, pos=1} @@ -1105,7 +1099,7 @@ end function test_backspace_over_selection_reverse() io.write('\ntest_backspace_over_selection_reverse') -- select just one character within a line with cursor after selection - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=1, pos=2} @@ -1123,7 +1117,7 @@ end function test_backspace_over_multiple_lines() io.write('\ntest_backspace_over_multiple_lines') -- select just one character within a line with cursor after selection - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=1, pos=2} @@ -1142,7 +1136,7 @@ end function test_backspace_to_end_of_line() io.write('\ntest_backspace_to_end_of_line') -- select region from cursor to end of line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=1, pos=2} @@ -1161,7 +1155,7 @@ end function test_backspace_to_start_of_line() io.write('\ntest_backspace_to_start_of_line') -- select region from cursor to start of line - App.screen.init{width=25+30, height=60} + App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} Line_width = App.screen.width Cursor1 = {line=2, pos=1} |