diff options
-rw-r--r-- | drawing.lua | 14 | ||||
-rw-r--r-- | drawing_tests.lua | 40 | ||||
-rw-r--r-- | main.lua | 2 | ||||
-rw-r--r-- | text.lua | 28 | ||||
-rw-r--r-- | text_tests.lua | 71 |
5 files changed, 114 insertions, 41 deletions
diff --git a/drawing.lua b/drawing.lua index 7583da7..04bf1d2 100644 --- a/drawing.lua +++ b/drawing.lua @@ -8,13 +8,13 @@ require 'drawing_tests' -- into 256 parts. function Drawing.draw(line) local pmx,pmy = App.mouse_x(), App.mouse_y() - if pmx < App.screen.width and pmy > line.y and pmy < line.y+Drawing.pixels(line.h) then + if pmx < App.screen.width-Margin_right 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', Margin_left,line.y, App.screen.width-Margin_left,Drawing.pixels(line.h)) + love.graphics.rectangle('line', Margin_left,line.y, App.screen.width-Margin_width,Drawing.pixels(line.h)) if icon[Current_drawing_mode] then - icon[Current_drawing_mode](App.screen.width-22, line.y+4) + icon[Current_drawing_mode](App.screen.width-Margin_right-22, line.y+4) else - icon[Previous_drawing_mode](App.screen.width-22, line.y+4) + icon[Previous_drawing_mode](App.screen.width-Margin_right-22, line.y+4) end if App.mouse_down(1) and love.keyboard.isDown('h') then @@ -204,7 +204,7 @@ end function Drawing.in_drawing(drawing, x,y) 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 < App.screen.width + return y >= drawing.y and y < drawing.y + Drawing.pixels(drawing.h) and x >= Margin_left and x < App.screen.width-Margin_right end function Drawing.mouse_pressed(drawing, x,y, button) @@ -685,10 +685,10 @@ function Drawing.near(point, x,y) end function Drawing.pixels(n) -- parts to pixels - return math.floor(n*(App.screen.width-Margin_left)/256) + return math.floor(n*(App.screen.width-Margin_width)/256) end function Drawing.coord(n) -- pixels to parts - return math.floor(n*256/(App.screen.width-Margin_left)) + return math.floor(n*256/(App.screen.width-Margin_width)) end function table.find(h, x) diff --git a/drawing_tests.lua b/drawing_tests.lua index fc59e4f..0b34c94 100644 --- a/drawing_tests.lua +++ b/drawing_tests.lua @@ -24,7 +24,7 @@ function test_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) Filename = 'foo' - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -67,7 +67,7 @@ end function test_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) - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'manhattan' App.draw() @@ -94,7 +94,7 @@ end function test_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) - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -121,7 +121,7 @@ end function test_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) - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -136,7 +136,7 @@ end function test_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) - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -163,7 +163,7 @@ end function test_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) - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'circle' App.draw() @@ -193,7 +193,7 @@ end function test_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) - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} App.draw() check_eq(Current_drawing_mode, 'line', 'F - test_draw_polygon/baseline/drawing_mode') @@ -230,7 +230,7 @@ end function test_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) - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} App.draw() check_eq(Current_drawing_mode, 'line', 'F - test_draw_rectangle/baseline/drawing_mode') @@ -273,7 +273,7 @@ end function test_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) - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} App.draw() check_eq(Current_drawing_mode, 'line', 'F - test_draw_rectangle_intermediate/baseline/drawing_mode') @@ -308,7 +308,7 @@ end function test_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) - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} App.draw() check_eq(Current_drawing_mode, 'line', 'F - test_draw_square/baseline/drawing_mode') @@ -351,7 +351,7 @@ function test_name_point() io.write('\ntest_name_point') -- create a drawing with a line Filename = 'foo' - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -393,7 +393,7 @@ function test_move_point() io.write('\ntest_move_point') -- create a drawing with a line Filename = 'foo' - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -449,7 +449,7 @@ function test_move_point_on_manhattan_line() io.write('\ntest_move_point_on_manhattan_line') -- create a drawing with a manhattan line Filename = 'foo' - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'manhattan' App.draw() @@ -474,7 +474,7 @@ function test_delete_lines_at_point() io.write('\ntest_delete_lines_at_point') -- create a drawing with two lines connected at a point Filename = 'foo' - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -502,7 +502,7 @@ end function test_delete_line_under_mouse_pointer() io.write('\ntest_delete_line_under_mouse_pointer') -- create a drawing with two lines connected at a point - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -525,7 +525,7 @@ end function test_delete_point_from_polygon() io.write('\ntest_delete_point_from_polygon') -- create a drawing with two lines connected at a point - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -555,7 +555,7 @@ end function test_delete_point_from_polygon() io.write('\ntest_delete_point_from_polygon') -- create a drawing with two lines connected at a point - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -582,7 +582,7 @@ function test_undo_name_point() io.write('\ntest_undo_name_point') -- create a drawing with a line Filename = 'foo' - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -627,7 +627,7 @@ function test_undo_move_point() io.write('\ntest_undo_move_point') -- create a drawing with a line Filename = 'foo' - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() @@ -676,7 +676,7 @@ function test_undo_delete_point() io.write('\ntest_undo_delete_point') -- create a drawing with two lines connected at a point Filename = 'foo' - App.screen.init{width=Margin_left+256, height=300} -- drawing coordinates 1:1 with pixels + App.screen.init{width=Margin_width+256, height=300} -- drawing coordinates 1:1 with pixels Lines = load_array{'```lines', '```', ''} Current_drawing_mode = 'line' App.draw() diff --git a/main.lua b/main.lua index bdaaf39..ca8b725 100644 --- a/main.lua +++ b/main.lua @@ -73,6 +73,8 @@ Em = App.newText(love.graphics.getFont(), 'm') Margin_top = 15 Margin_left = 25 +Margin_right = 25 +Margin_width = Margin_left + Margin_right Drawing_padding_top = 10 Drawing_padding_bottom = 10 diff --git a/text.lua b/text.lua index 6c75b01..8765798 100644 --- a/text.lua +++ b/text.lua @@ -30,8 +30,8 @@ function Text.draw(line, line_index) local frag_width = App.width(frag_text) local frag_len = utf8.len(frag) --? local s=tostring ---? 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 > App.screen.width then +--? print('('..s(x)..','..s(y)..') '..frag..'('..s(frag_width)..' vs '..s(App.screen.width-Margin_right)..') '..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 > App.screen.width-Margin_right then 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 @@ -94,31 +94,31 @@ function Text.draw_cursor(x, y) end function Text.compute_fragments(line) ---? print('compute_fragments', App.screen.width) +--? print('compute_fragments', App.screen.width-Margin_right) line.fragments = {} 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) local frag_width = App.width(frag_text) ---? print('x: '..tostring(x)..'; '..tostring(App.screen.width-x)..'px to go') +--? print('x: '..tostring(x)..'; '..tostring(App.screen.width-Margin_right-x)..'px to go') --? print('frag: ^'..frag..'$ is '..tostring(frag_width)..'px wide') - if x + frag_width > App.screen.width then - while x + frag_width > App.screen.width do ---? print(x, frag, frag_width, App.screen.width) - if x < 0.8*App.screen.width then ---? print(frag, x, frag_width, App.screen.width) + if x + frag_width > App.screen.width-Margin_right then + while x + frag_width > App.screen.width-Margin_right do +--? print(x, frag, frag_width, App.screen.width-Margin_right) + if x < 0.8*(App.screen.width-Margin_right) then +--? print(frag, x, frag_width, App.screen.width-Margin_right) -- long word; chop it at some letter -- We're not going to reimplement TeX here. - local bpos = Text.nearest_pos_less_than(frag, App.screen.width - x) + local bpos = Text.nearest_pos_less_than(frag, App.screen.width-Margin_right - x) assert(bpos > 0) -- avoid infinite loop when window is too narrow local boffset = Text.offset(frag, bpos+1) -- byte _after_ bpos --? print('space for '..tostring(bpos)..' graphemes, '..tostring(boffset)..' bytes') local frag1 = string.sub(frag, 1, boffset-1) local frag1_text = App.newText(love.graphics.getFont(), frag1) local frag1_width = App.width(frag1_text) ---? print(frag, x, frag1_width, App.screen.width) - assert(x + frag1_width <= App.screen.width) +--? print(frag, x, frag1_width, App.screen.width-Margin_right) + assert(x + frag1_width <= App.screen.width-Margin_right) --? print('inserting '..frag1..' of width '..tostring(frag1_width)..'px') table.insert(line.fragments, {data=frag1, text=frag1_text}) frag = string.sub(frag, boffset) @@ -667,7 +667,7 @@ end -- convert mx,my in pixels to schema-1 coordinates function Text.to_pos_on_line(line, mx, my) ---? print('Text.to_pos_on_line', mx, my, 'width', App.screen.width) +--? print('Text.to_pos_on_line', mx, my, 'width', App.screen.width-Margin_right) if line.fragments == nil then Text.compute_fragments(line) end @@ -904,7 +904,7 @@ function Text.populate_screen_line_starting_pos(line_index) -- render fragment local frag_width = App.width(frag_text) --? print(x, pos, frag, frag_width) - if x + frag_width > App.screen.width then + if x + frag_width > App.screen.width-Margin_right then x = Margin_left table.insert(line.screen_line_starting_pos, pos) --? print('new screen line:', #line.screen_line_starting_pos, pos) diff --git a/text_tests.lua b/text_tests.lua index b16012f..162f391 100644 --- a/text_tests.lua +++ b/text_tests.lua @@ -4,6 +4,7 @@ function test_initial_state() io.write('\ntest_initial_state') App.screen.init{width=120, height=60} Lines = load_array{} + Margin_right = 0; Margin_width = Margin_left App.draw() check_eq(#Lines, 1, 'F - test_initial_state/#lines') check_eq(Cursor1.line, 1, 'F - test_initial_state/cursor:line') @@ -16,6 +17,7 @@ function test_click_to_create_drawing() io.write('\ntest_click_to_create_drawing') App.screen.init{width=120, height=60} Lines = load_array{} + Margin_right = 0; Margin_width = Margin_left App.draw() App.run_after_mouse_click(8,Margin_top+8, 1) -- cursor skips drawing to always remain on text @@ -28,6 +30,7 @@ function test_backspace_to_delete_drawing() -- display a drawing followed by a line of text (you shouldn't ever have a drawing right at the end) App.screen.init{width=120, height=60} Lines = load_array{'```lines', '```', ''} + Margin_right = 0; Margin_width = Margin_left -- cursor is on text as always (outside tests this will get initialized correctly) Cursor1.line = 2 -- backspacing deletes the drawing @@ -40,6 +43,7 @@ function test_insert_first_character() io.write('\ntest_insert_first_character') App.screen.init{width=120, height=60} Lines = load_array{} + Margin_right = 0; Margin_width = Margin_left App.draw() App.run_after_textinput('a') local y = Margin_top @@ -51,6 +55,7 @@ function test_press_ctrl() -- press ctrl while the cursor is on text App.screen.init{width=50, height=80} Lines = load_array{''} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -62,6 +67,7 @@ function test_click_with_mouse() -- display two lines with cursor on one of them App.screen.init{width=50, height=80} Lines = load_array{'abc', 'def'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -76,6 +82,7 @@ function test_draw_text() io.write('\ntest_draw_text') App.screen.init{width=120, height=60} Lines = load_array{'abc', 'def', 'ghi'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -92,6 +99,7 @@ function test_draw_wrapping_text() io.write('\ntest_draw_wrapping_text') App.screen.init{width=50, height=60} Lines = load_array{'abc', 'defgh', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -108,6 +116,7 @@ function test_draw_word_wrapping_text() io.write('\ntest_draw_word_wrapping_text') App.screen.init{width=60, height=60} Lines = load_array{'abc def ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -125,6 +134,7 @@ function test_draw_text_wrapping_within_word() io.write('\ntest_draw_text_wrapping_within_word') App.screen.init{width=60, height=60} Lines = load_array{'abcd e fghijk', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -142,6 +152,7 @@ function test_draw_wrapping_text_containing_non_ascii() io.write('\ntest_draw_wrapping_text_containing_non_ascii') App.screen.init{width=60, height=60} Lines = load_array{'madam I’m adam', 'xyz'} -- notice the non-ASCII apostrophe + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -160,6 +171,7 @@ function test_click_on_wrapping_line() App.screen.init{width=75, height=80} -- 12345678901234 Lines = load_array{"madam I'm adam"} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -182,6 +194,7 @@ function test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen() App.screen.init{width=75, height=80} -- 12345678901234 Lines = load_array{"madam I'm adam"} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=8} Screen_top1 = {line=1, pos=7} Screen_bottom1 = {} @@ -202,6 +215,7 @@ function test_click_past_end_of_wrapping_line() App.screen.init{width=75, height=80} -- 12345678901234 Lines = load_array{"madam I'm adam"} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -225,6 +239,7 @@ function test_click_on_wrapping_line_containing_non_ascii() App.screen.init{width=75, height=80} -- 12345678901234 Lines = load_array{'madam I’m adam'} -- notice the non-ASCII apostrophe + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -249,6 +264,7 @@ function test_click_past_end_of_word_wrapping_line() -- 0 1 2 -- 123456789012345678901 Lines = load_array{'the quick brown fox jumped over the lazy dog'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -267,6 +283,7 @@ function test_select_text() -- display a line of text App.screen.init{width=75, height=80} Lines = load_array{'abc def'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -288,6 +305,7 @@ function test_cursor_movement_without_shift_resets_selection() -- display a line of text with some part selected App.screen.init{width=75, height=80} Lines = load_array{'abc'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} @@ -305,6 +323,7 @@ function test_edit_after_click_resets_selection() -- display a line of text App.screen.init{width=75, height=80} Lines = load_array{'abc'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -322,6 +341,7 @@ function test_edit_deletes_selection() -- display a line of text with some part selected App.screen.init{width=75, height=80} Lines = load_array{'abc'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} @@ -338,6 +358,7 @@ function test_edit_with_shift_key_deletes_selection() -- display a line of text with some part selected App.screen.init{width=75, height=80} Lines = load_array{'abc'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} @@ -359,6 +380,7 @@ function test_copy_does_not_reset_selection() -- display a line of text with a selection App.screen.init{width=75, height=80} Lines = load_array{'abc'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} @@ -376,6 +398,7 @@ function test_cut() -- display a line of text with some part selected App.screen.init{width=75, height=80} Lines = load_array{'abc'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} @@ -393,6 +416,7 @@ function test_paste_replaces_selection() -- display a line of text with a selection App.screen.init{width=75, height=80} Lines = load_array{'abc', 'def'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Selection1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} @@ -412,6 +436,7 @@ function test_deleting_selection_may_scroll() -- display lines 2/3/4 App.screen.init{width=120, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=2} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} @@ -435,6 +460,7 @@ function test_edit_wrapping_text() io.write('\ntest_edit_wrapping_text') App.screen.init{width=50, height=60} Lines = load_array{'abc', 'def', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=4} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -456,6 +482,7 @@ function test_insert_newline() -- display a few lines App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -484,6 +511,7 @@ function test_insert_newline_at_start_of_line() -- display a line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -500,6 +528,7 @@ function test_insert_from_clipboard() -- display a few lines App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -528,6 +557,7 @@ function test_move_cursor_using_mouse() io.write('\ntest_move_cursor_using_mouse') App.screen.init{width=50, height=60} Lines = load_array{'abc', 'def', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -544,6 +574,7 @@ function test_select_text_using_mouse() io.write('\ntest_select_text_using_mouse') App.screen.init{width=50, height=60} Lines = load_array{'abc', 'def', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -563,6 +594,7 @@ function test_select_text_using_mouse_and_shift() io.write('\ntest_select_text_using_mouse_and_shift') App.screen.init{width=50, height=60} Lines = load_array{'abc', 'def', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -586,6 +618,7 @@ function test_select_text_repeatedly_using_mouse_and_shift() io.write('\ntest_select_text_repeatedly_using_mouse_and_shift') App.screen.init{width=50, height=60} Lines = load_array{'abc', 'def', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -615,6 +648,7 @@ function test_cut_without_selection() -- display a few lines App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -630,6 +664,7 @@ function test_pagedown() io.write('\ntest_pagedown') App.screen.init{width=120, height=45} Lines = load_array{'abc', 'def', 'ghi'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -658,6 +693,7 @@ function test_pagedown_skips_drawings() '```lines', '```', -- height 25 'def', -- height 15 'ghi'} -- height 15 + Margin_right = 0; Margin_width = Margin_left check_eq(Lines[2].mode, 'drawing', 'F - test_pagedown_skips_drawings/baseline/lines') Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} @@ -682,6 +718,7 @@ function test_pagedown_often_shows_start_of_wrapping_line() -- draw a few lines ending in part of a wrapping line App.screen.init{width=50, height=60} Lines = load_array{'abc', 'def ghi jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -711,6 +748,7 @@ function test_pagedown_can_start_from_middle_of_long_wrapping_line() -- draw a few lines starting from a very long wrapping line 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'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -737,6 +775,7 @@ function test_down_arrow_moves_cursor() io.write('\ntest_down_arrow_moves_cursor') App.screen.init{width=120, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -766,6 +805,7 @@ function test_down_arrow_scrolls_down_by_one_line() -- display the first three lines with the cursor on the bottom line App.screen.init{width=120, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -793,6 +833,7 @@ function test_down_arrow_scrolls_down_by_one_screen_line() -- display the first three lines with the cursor on the bottom line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -821,6 +862,7 @@ 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 App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghijkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -848,6 +890,7 @@ 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=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghijkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -881,6 +924,7 @@ function test_up_arrow_moves_cursor() -- display the first 3 lines with the cursor on the bottom line App.screen.init{width=120, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=1} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -909,6 +953,7 @@ function test_up_arrow_scrolls_up_by_one_line() -- display the lines 2/3/4 with the cursor on line 2 App.screen.init{width=120, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} @@ -936,6 +981,7 @@ function test_up_arrow_scrolls_up_by_one_screen_line() -- display lines starting from second screen line of a line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=6} Screen_top1 = {line=3, pos=5} Screen_bottom1 = {} @@ -963,6 +1009,7 @@ function test_up_arrow_scrolls_up_to_final_screen_line() -- display lines starting just after a long line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} @@ -992,6 +1039,7 @@ function test_up_arrow_scrolls_up_to_empty_line() -- display a screenful of text with an empty line just above it outside the screen App.screen.init{width=120, height=60} Lines = load_array{'', 'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} @@ -1018,6 +1066,7 @@ function test_pageup() io.write('\ntest_pageup') App.screen.init{width=120, height=45} Lines = load_array{'abc', 'def', 'ghi'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} @@ -1042,6 +1091,7 @@ function test_pageup_scrolls_up_by_screen_line() -- display the first three lines with the cursor on the bottom line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc def', 'ghi', 'jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} @@ -1070,6 +1120,7 @@ function test_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=Margin_left+30, height=60} Lines = load_array{'abc def', 'ghi jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=5} Screen_top1 = {line=2, pos=5} Screen_bottom1 = {} @@ -1096,6 +1147,7 @@ function test_enter_on_bottom_line_scrolls_down() -- display a few lines with cursor on bottom line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=2} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -1124,6 +1176,7 @@ function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom() -- display just the bottom line on screen App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=4, pos=2} Screen_top1 = {line=4, pos=1} Screen_bottom1 = {} @@ -1146,6 +1199,7 @@ function test_inserting_text_on_final_line_avoids_scrolling_down_when_not_at_bot -- display just an empty bottom line on screen App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', ''} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} @@ -1164,6 +1218,7 @@ function test_typing_on_bottom_line_scrolls_down() -- display a few lines with cursor on bottom line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=4} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -1194,6 +1249,7 @@ function test_left_arrow_scrolls_up_in_wrapped_line() -- display lines starting from second screen line of a line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Screen_top1 = {line=3, pos=5} Screen_bottom1 = {} -- cursor is at top of screen @@ -1222,6 +1278,7 @@ function test_right_arrow_scrolls_down_in_wrapped_line() -- display the first three lines with the cursor on the bottom line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} -- cursor is at bottom right of screen @@ -1251,6 +1308,7 @@ function test_home_scrolls_up_in_wrapped_line() -- display lines starting from second screen line of a line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Screen_top1 = {line=3, pos=5} Screen_bottom1 = {} -- cursor is at top of screen @@ -1279,6 +1337,7 @@ function test_end_scrolls_down_in_wrapped_line() -- display the first three lines with the cursor on the bottom line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} -- cursor is at bottom right of screen @@ -1308,6 +1367,7 @@ function test_position_cursor_on_recently_edited_wrapping_line() io.write('\ntest_position_cursor_on_recently_edited_wrapping_line') App.screen.init{width=100, height=200} Lines = load_array{'abc def ghi jkl mno pqr ', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=25} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -1341,6 +1401,7 @@ function test_backspace_can_scroll_up() -- display the lines 2/3/4 with the cursor on line 2 App.screen.init{width=120, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Screen_top1 = {line=2, pos=1} Screen_bottom1 = {} @@ -1368,6 +1429,7 @@ function test_backspace_can_scroll_up_screen_line() -- display lines starting from second screen line of a line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=3, pos=5} Screen_top1 = {line=3, pos=5} Screen_bottom1 = {} @@ -1395,6 +1457,7 @@ function test_backspace_past_line_boundary() -- position cursor at start of a (non-first) line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} -- backspace joins with previous line App.run_after_keychord('backspace') @@ -1409,6 +1472,7 @@ function test_backspace_over_selection() -- select just one character within a line with cursor before selection App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Selection1 = {line=1, pos=2} -- backspace deletes the selected character, even though it's after the cursor @@ -1426,6 +1490,7 @@ function test_backspace_over_selection_reverse() -- select just one character within a line with cursor after selection App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=2} Selection1 = {line=1, pos=1} -- backspace deletes the selected character @@ -1443,6 +1508,7 @@ function test_backspace_over_multiple_lines() -- select just one character within a line with cursor after selection App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=2} Selection1 = {line=4, pos=2} -- backspace deletes the region and joins the remaining portions of lines on either side @@ -1461,6 +1527,7 @@ function test_backspace_to_end_of_line() -- select region from cursor to end of line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=2} Selection1 = {line=1, pos=4} -- backspace deletes rest of line without joining to any other line @@ -1479,6 +1546,7 @@ function test_backspace_to_start_of_line() -- select region from cursor to start of line App.screen.init{width=Margin_left+30, height=60} Lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=1} Selection1 = {line=2, pos=3} -- backspace deletes beginning of line without joining to any other line @@ -1496,6 +1564,7 @@ function test_undo_insert_text() io.write('\ntest_undo_insert_text') App.screen.init{width=120, height=60} Lines = load_array{'abc', 'def', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=4} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -1530,6 +1599,7 @@ function test_undo_delete_text() io.write('\ntest_undo_delete_text') App.screen.init{width=120, height=60} Lines = load_array{'abc', 'defg', 'xyz'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=2, pos=5} Screen_top1 = {line=1, pos=1} Screen_bottom1 = {} @@ -1567,6 +1637,7 @@ function test_undo_restores_selection() -- display a line of text with some part selected App.screen.init{width=75, height=80} Lines = load_array{'abc'} + Margin_right = 0; Margin_width = Margin_left Cursor1 = {line=1, pos=1} Selection1 = {line=1, pos=2} Screen_top1 = {line=1, pos=1} |