about summary refs log tree commit diff stats
path: root/text_tests.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-07-12 14:41:16 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-07-12 15:29:22 -0700
commite95b4fec122f7e5bd2512bb03a4b6ebce98f1c01 (patch)
tree96aea7f051f55e315364662cd6b6a45ad0195ea4 /text_tests.lua
parent8bbc1ffe349a78ed2130e24e0356276ddbb22955 (diff)
downloadlines.love-e95b4fec122f7e5bd2512bb03a4b6ebce98f1c01.tar.gz
initialize contains test state
Diffstat (limited to 'text_tests.lua')
-rw-r--r--text_tests.lua87
1 files changed, 0 insertions, 87 deletions
diff --git a/text_tests.lua b/text_tests.lua
index 29d59ae..229dd82 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -4,7 +4,6 @@ function test_initial_state()
   io.write('\ntest_initial_state')
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   check_eq(#Editor_state.lines, 1, 'F - test_initial_state/#lines')
   check_eq(Editor_state.cursor1.line, 1, 'F - test_initial_state/cursor:line')
@@ -17,7 +16,6 @@ function test_click_to_create_drawing()
   io.write('\ntest_click_to_create_drawing')
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_mouse_click(8,Editor_state.margin_top+8, 1)
   -- cursor skips drawing to always remain on text
@@ -30,7 +28,6 @@ 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}
   Editor_state.lines = load_array{'```lines', '```', ''}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   -- cursor is on text as always (outside tests this will get initialized correctly)
   Editor_state.cursor1.line = 2
   -- backspacing deletes the drawing
@@ -43,7 +40,6 @@ function test_insert_first_character()
   io.write('\ntest_insert_first_character')
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_textinput('a')
   local y = Editor_state.margin_top
@@ -55,7 +51,6 @@ function test_press_ctrl()
   -- press ctrl while the cursor is on text
   App.screen.init{width=50, height=80}
   Editor_state.lines = load_array{''}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -64,10 +59,8 @@ end
 
 function test_move_left()
   io.write('\ntest_move_left')
-  App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'a'}
   Editor_state.cursor1 = {line=1, pos=2}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('left')
   check_eq(Editor_state.cursor1.pos, 1, 'F - test_move_left')
@@ -78,7 +71,6 @@ function test_move_right()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'a'}
   Editor_state.cursor1 = {line=1, pos=1}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('right')
   check_eq(Editor_state.cursor1.pos, 2, 'F - test_move_right')
@@ -89,7 +81,6 @@ function test_move_left_to_previous_line()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc', 'def'}
   Editor_state.cursor1 = {line=2, pos=1}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('left')
   check_eq(Editor_state.cursor1.line, 1, 'F - test_move_left_to_previous_line/line')
@@ -101,7 +92,6 @@ function test_move_right_to_next_line()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc', 'def'}
   Editor_state.cursor1 = {line=1, pos=4}  -- past end of line
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('right')
   check_eq(Editor_state.cursor1.line, 2, 'F - test_move_right_to_next_line/line')
@@ -113,7 +103,6 @@ function test_move_to_start_of_word()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc'}
   Editor_state.cursor1 = {line=1, pos=3}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-left')
   check_eq(Editor_state.cursor1.pos, 1, 'F - test_move_to_start_of_word')
@@ -124,7 +113,6 @@ function test_move_to_start_of_previous_word()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc def'}
   Editor_state.cursor1 = {line=1, pos=4}  -- at the space between words
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-left')
   check_eq(Editor_state.cursor1.pos, 1, 'F - test_move_to_start_of_previous_word')
@@ -135,7 +123,6 @@ function test_skip_to_previous_word()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc def'}
   Editor_state.cursor1 = {line=1, pos=5}  -- at the start of second word
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-left')
   check_eq(Editor_state.cursor1.pos, 1, 'F - test_skip_to_previous_word')
@@ -146,7 +133,6 @@ function test_skip_past_tab_to_previous_word()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc def\tghi'}
   Editor_state.cursor1 = {line=1, pos=10}  -- within third word
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-left')
   check_eq(Editor_state.cursor1.pos, 9, 'F - test_skip_past_tab_to_previous_word')
@@ -157,7 +143,6 @@ function test_skip_multiple_spaces_to_previous_word()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc  def'}
   Editor_state.cursor1 = {line=1, pos=6}  -- at the start of second word
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-left')
   check_eq(Editor_state.cursor1.pos, 1, 'F - test_skip_multiple_spaces_to_previous_word')
@@ -168,7 +153,6 @@ function test_move_to_start_of_word_on_previous_line()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc def', 'ghi'}
   Editor_state.cursor1 = {line=2, pos=1}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-left')
   check_eq(Editor_state.cursor1.line, 1, 'F - test_move_to_start_of_word_on_previous_line/line')
@@ -180,7 +164,6 @@ function test_move_past_end_of_word()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc def'}
   Editor_state.cursor1 = {line=1, pos=1}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-right')
   check_eq(Editor_state.cursor1.pos, 4, 'F - test_move_past_end_of_word')
@@ -191,7 +174,6 @@ function test_skip_to_next_word()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc def'}
   Editor_state.cursor1 = {line=1, pos=4}  -- at the space between words
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-right')
   check_eq(Editor_state.cursor1.pos, 8, 'F - test_skip_to_next_word')
@@ -202,7 +184,6 @@ function test_skip_past_tab_to_next_word()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc\tdef'}
   Editor_state.cursor1 = {line=1, pos=1}  -- at the space between words
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-right')
   check_eq(Editor_state.cursor1.pos, 4, 'F - test_skip_past_tab_to_next_word')
@@ -213,7 +194,6 @@ function test_skip_multiple_spaces_to_next_word()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc  def'}
   Editor_state.cursor1 = {line=1, pos=4}  -- at the start of second word
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-right')
   check_eq(Editor_state.cursor1.pos, 9, 'F - test_skip_multiple_spaces_to_next_word')
@@ -224,7 +204,6 @@ function test_move_past_end_of_word_on_next_line()
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc def', 'ghi'}
   Editor_state.cursor1 = {line=1, pos=8}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   edit.draw()
   App.run_after_keychord('M-right')
   check_eq(Editor_state.cursor1.line, 2, 'F - test_move_past_end_of_word_on_next_line/line')
@@ -236,7 +215,6 @@ function test_click_with_mouse()
   -- display two lines with cursor on one of them
   App.screen.init{width=50, height=80}
   Editor_state.lines = load_array{'abc', 'def'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -253,7 +231,6 @@ function test_click_with_mouse_on_empty_line()
   -- display two lines with the first one empty
   App.screen.init{width=50, height=80}
   Editor_state.lines = load_array{'', 'def'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -268,7 +245,6 @@ function test_draw_text()
   io.write('\ntest_draw_text')
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -285,7 +261,6 @@ function test_draw_wrapping_text()
   io.write('\ntest_draw_wrapping_text')
   App.screen.init{width=50, height=60}
   Editor_state.lines = load_array{'abc', 'defgh', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -302,7 +277,6 @@ function test_draw_word_wrapping_text()
   io.write('\ntest_draw_word_wrapping_text')
   App.screen.init{width=60, height=60}
   Editor_state.lines = load_array{'abc def ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -320,7 +294,6 @@ function test_draw_text_wrapping_within_word()
   io.write('\ntest_draw_text_wrapping_within_word')
   App.screen.init{width=60, height=60}
   Editor_state.lines = load_array{'abcd e fghijk', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -338,7 +311,6 @@ function test_draw_wrapping_text_containing_non_ascii()
   io.write('\ntest_draw_wrapping_text_containing_non_ascii')
   App.screen.init{width=60, height=60}
   Editor_state.lines = load_array{'madam I’m adam', 'xyz'}  -- notice the non-ASCII apostrophe
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -357,7 +329,6 @@ function test_click_on_wrapping_line()
   App.screen.init{width=75, height=80}
                   --  12345678901234
   Editor_state.lines = load_array{"madam I'm adam"}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -380,7 +351,6 @@ function test_click_on_wrapping_line_rendered_from_partway_at_top_of_screen()
   App.screen.init{width=75, height=80}
                   --  12345678901234
   Editor_state.lines = load_array{"madam I'm adam"}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=8}
   Editor_state.screen_top1 = {line=1, pos=7}
   Editor_state.screen_bottom1 = {}
@@ -401,7 +371,6 @@ function test_click_past_end_of_wrapping_line()
   App.screen.init{width=75, height=80}
                   --  12345678901234
   Editor_state.lines = load_array{"madam I'm adam"}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -425,7 +394,6 @@ function test_click_on_wrapping_line_containing_non_ascii()
   App.screen.init{width=75, height=80}
                   --  12345678901234
   Editor_state.lines = load_array{'madam I’m adam'}  -- notice the non-ASCII apostrophe
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -450,7 +418,6 @@ function test_click_past_end_of_word_wrapping_line()
                    -- 0        1         2
                    -- 123456789012345678901
   Editor_state.lines = load_array{'the quick brown fox jumped over the lazy dog'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -469,7 +436,6 @@ function test_select_text()
   -- display a line of text
   App.screen.init{width=75, height=80}
   Editor_state.lines = load_array{'abc def'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -491,7 +457,6 @@ function test_cursor_movement_without_shift_resets_selection()
   -- display a line of text with some part selected
   App.screen.init{width=75, height=80}
   Editor_state.lines = load_array{'abc'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.selection1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
@@ -509,7 +474,6 @@ function test_edit_deletes_selection()
   -- display a line of text with some part selected
   App.screen.init{width=75, height=80}
   Editor_state.lines = load_array{'abc'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.selection1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
@@ -526,7 +490,6 @@ function test_edit_with_shift_key_deletes_selection()
   -- display a line of text with some part selected
   App.screen.init{width=75, height=80}
   Editor_state.lines = load_array{'abc'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.selection1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
@@ -548,7 +511,6 @@ function test_copy_does_not_reset_selection()
   -- display a line of text with a selection
   App.screen.init{width=75, height=80}
   Editor_state.lines = load_array{'abc'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.selection1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
@@ -566,7 +528,6 @@ function test_cut()
   -- display a line of text with some part selected
   App.screen.init{width=75, height=80}
   Editor_state.lines = load_array{'abc'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.selection1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
@@ -584,7 +545,6 @@ function test_paste_replaces_selection()
   -- display a line of text with a selection
   App.screen.init{width=75, height=80}
   Editor_state.lines = load_array{'abc', 'def'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.selection1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
@@ -604,7 +564,6 @@ function test_deleting_selection_may_scroll()
   -- display lines 2/3/4
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=2}
   Editor_state.screen_top1 = {line=2, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -628,7 +587,6 @@ function test_edit_wrapping_text()
   io.write('\ntest_edit_wrapping_text')
   App.screen.init{width=50, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=4}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -650,7 +608,6 @@ function test_insert_newline()
   -- display a few lines
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -679,7 +636,6 @@ function test_insert_newline_at_start_of_line()
   -- display a line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -696,7 +652,6 @@ function test_insert_from_clipboard()
   -- display a few lines
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -725,7 +680,6 @@ function test_move_cursor_using_mouse()
   io.write('\ntest_move_cursor_using_mouse')
   App.screen.init{width=50, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -742,7 +696,6 @@ function test_select_text_using_mouse()
   io.write('\ntest_select_text_using_mouse')
   App.screen.init{width=50, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -762,7 +715,6 @@ function test_select_text_using_mouse_and_shift()
   io.write('\ntest_select_text_using_mouse_and_shift')
   App.screen.init{width=50, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -786,7 +738,6 @@ 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}
   Editor_state.lines = load_array{'abc', 'def', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -816,7 +767,6 @@ function test_cut_without_selection()
   -- display a few lines
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -832,7 +782,6 @@ function test_pagedown()
   io.write('\ntest_pagedown')
   App.screen.init{width=120, height=45}
   Editor_state.lines = load_array{'abc', 'def', 'ghi'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -861,7 +810,6 @@ function test_pagedown_skips_drawings()
                      '```lines', '```',   -- height 25
                      'def',               -- height 15
                      'ghi'}               -- height 15
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   check_eq(Editor_state.lines[2].mode, 'drawing', 'F - test_pagedown_skips_drawings/baseline/lines')
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
@@ -886,7 +834,6 @@ 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}
   Editor_state.lines = load_array{'abc', 'def ghi jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -916,7 +863,6 @@ 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=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc def ghi jkl mno pqr stu vwx yza bcd efg hij', 'XYZ'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -943,7 +889,6 @@ function test_down_arrow_moves_cursor()
   io.write('\ntest_down_arrow_moves_cursor')
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -973,7 +918,6 @@ 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}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1001,7 +945,6 @@ 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=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1030,7 +973,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
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghijkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1058,7 +1000,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')
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghijkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1092,7 +1033,6 @@ 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}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1121,7 +1061,6 @@ 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}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=2, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1149,7 +1088,6 @@ function test_up_arrow_scrolls_up_by_one_screen_line()
   -- display lines starting from second screen line of a line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=6}
   Editor_state.screen_top1 = {line=3, pos=5}
   Editor_state.screen_bottom1 = {}
@@ -1177,7 +1115,6 @@ function test_up_arrow_scrolls_up_to_final_screen_line()
   -- display lines starting just after a long line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc def', 'ghi', 'jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=2, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1207,7 +1144,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
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'', 'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=2, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1234,7 +1170,6 @@ function test_pageup()
   io.write('\ntest_pageup')
   App.screen.init{width=120, height=45}
   Editor_state.lines = load_array{'abc', 'def', 'ghi'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=2, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1259,7 +1194,6 @@ function test_pageup_scrolls_up_by_screen_line()
   -- display the first three lines with the cursor on the bottom line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc def', 'ghi', 'jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=2, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1288,7 +1222,6 @@ function test_pageup_scrolls_up_from_middle_screen_line()
   -- display a few lines starting from the middle of a line (Editor_state.cursor1.pos > 1)
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc def', 'ghi jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=5}
   Editor_state.screen_top1 = {line=2, pos=5}
   Editor_state.screen_bottom1 = {}
@@ -1315,7 +1248,6 @@ function test_enter_on_bottom_line_scrolls_down()
   -- display a few lines with cursor on bottom line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1344,7 +1276,6 @@ function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom()
   -- display just the bottom line on screen
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=4, pos=2}
   Editor_state.screen_top1 = {line=4, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1367,7 +1298,6 @@ 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=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', ''}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=2, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1386,7 +1316,6 @@ function test_typing_on_bottom_line_scrolls_down()
   -- display a few lines with cursor on bottom line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=4}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1417,7 +1346,6 @@ function test_left_arrow_scrolls_up_in_wrapped_line()
   -- display lines starting from second screen line of a line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.screen_top1 = {line=3, pos=5}
   Editor_state.screen_bottom1 = {}
   -- cursor is at top of screen
@@ -1446,7 +1374,6 @@ 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=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
   -- cursor is at bottom right of screen
@@ -1476,7 +1403,6 @@ function test_home_scrolls_up_in_wrapped_line()
   -- display lines starting from second screen line of a line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.screen_top1 = {line=3, pos=5}
   Editor_state.screen_bottom1 = {}
   -- cursor is at top of screen
@@ -1505,7 +1431,6 @@ function test_end_scrolls_down_in_wrapped_line()
   -- display the first three lines with the cursor on the bottom line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
   -- cursor is at bottom right of screen
@@ -1535,7 +1460,6 @@ 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}
   Editor_state.lines = load_array{'abc def ghi jkl mno pqr ', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=25}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1569,7 +1493,6 @@ 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}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.screen_top1 = {line=2, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1597,7 +1520,6 @@ function test_backspace_can_scroll_up_screen_line()
   -- display lines starting from second screen line of a line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=3, pos=5}
   Editor_state.screen_top1 = {line=3, pos=5}
   Editor_state.screen_bottom1 = {}
@@ -1625,7 +1547,6 @@ function test_backspace_past_line_boundary()
   -- position cursor at start of a (non-first) line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   -- backspace joins with previous line
   App.run_after_keychord('backspace')
@@ -1640,7 +1561,6 @@ function test_backspace_over_selection()
   -- select just one character within a line with cursor before selection
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.selection1 = {line=1, pos=2}
   -- backspace deletes the selected character, even though it's after the cursor
@@ -1658,7 +1578,6 @@ function test_backspace_over_selection_reverse()
   -- select just one character within a line with cursor after selection
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.selection1 = {line=1, pos=1}
   -- backspace deletes the selected character
@@ -1676,7 +1595,6 @@ function test_backspace_over_multiple_lines()
   -- select just one character within a line with cursor after selection
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.selection1 = {line=4, pos=2}
   -- backspace deletes the region and joins the remaining portions of lines on either side
@@ -1695,7 +1613,6 @@ function test_backspace_to_end_of_line()
   -- select region from cursor to end of line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.selection1 = {line=1, pos=4}
   -- backspace deletes rest of line without joining to any other line
@@ -1714,7 +1631,6 @@ function test_backspace_to_start_of_line()
   -- select region from cursor to start of line
   App.screen.init{width=Editor_state.margin_left+30, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'ghi', 'jkl', 'mno'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.selection1 = {line=2, pos=3}
   -- backspace deletes beginning of line without joining to any other line
@@ -1732,7 +1648,6 @@ function test_undo_insert_text()
   io.write('\ntest_undo_insert_text')
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc', 'def', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=4}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1767,7 +1682,6 @@ function test_undo_delete_text()
   io.write('\ntest_undo_delete_text')
   App.screen.init{width=120, height=60}
   Editor_state.lines = load_array{'abc', 'defg', 'xyz'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=2, pos=5}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
@@ -1805,7 +1719,6 @@ function test_undo_restores_selection()
   -- display a line of text with some part selected
   App.screen.init{width=75, height=80}
   Editor_state.lines = load_array{'abc'}
-  Editor_state.margin_right = 0; Editor_state.margin_width = Editor_state.margin_left
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.selection1 = {line=1, pos=2}
   Editor_state.screen_top1 = {line=1, pos=1}