From 3dccd7f81abff050a37b5a65eb5e3cc6756a4b7f Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Mon, 11 Jul 2022 22:11:48 -0700 Subject: [PATCH] stop pretending globals are local One advantage of this approach: we don't end up with multiple lexical scopes containing duplicates of the same modules. --- drawing.lua | 4 ---- file.lua | 2 -- geom.lua | 4 +--- main.lua | 8 ++++---- select.lua | 2 -- text.lua | 4 ---- 6 files changed, 5 insertions(+), 19 deletions(-) diff --git a/drawing.lua b/drawing.lua index 3ed1b3f..8668915 100644 --- a/drawing.lua +++ b/drawing.lua @@ -1,7 +1,5 @@ -- primitives for editing drawings Drawing = {} -geom = require 'geom' - require 'drawing_tests' -- All drawings span 100% of some conceptual 'page width' and divide it up @@ -719,5 +717,3 @@ function table.find(h, x) end end end - -return Drawing diff --git a/file.lua b/file.lua index 92561bd..c5946d6 100644 --- a/file.lua +++ b/file.lua @@ -1,6 +1,4 @@ -- primitives for saving to file and loading from file -Drawing = require 'drawing' - function load_from_disk(filename) local infile = App.open_for_reading(filename) local result = load_from_file(infile) diff --git a/geom.lua b/geom.lua index ef3cbcf..891e98d 100644 --- a/geom.lua +++ b/geom.lua @@ -1,4 +1,4 @@ -local geom = {} +geom = {} function geom.on_shape(x,y, drawing, shape) if shape.mode == 'freehand' then @@ -166,5 +166,3 @@ function geom.angle_between(ox,oy, x,y, s,e) end function geom.dist(x1,y1, x2,y2) return ((x2-x1)^2+(y2-y1)^2)^0.5 end - -return geom diff --git a/main.lua b/main.lua index 3cb822e..72b6834 100644 --- a/main.lua +++ b/main.lua @@ -1,4 +1,4 @@ -local utf8 = require 'utf8' +utf8 = require 'utf8' require 'app' require 'test' @@ -6,9 +6,9 @@ require 'test' require 'keychord' require 'file' require 'button' -local Text = require 'text' -local Drawing = require 'drawing' -local geom = require 'geom' +require 'text' +require 'drawing' +require 'geom' require 'help' require 'icons' diff --git a/select.lua b/select.lua index da3f99d..adf4739 100644 --- a/select.lua +++ b/select.lua @@ -1,7 +1,5 @@ -- helpers for selecting portions of text -local utf8 = require 'utf8' - -- Return any intersection of the region from Selection1 to Cursor1 (or -- current mouse, if mouse is pressed; or recent mouse if mouse is pressed and -- currently over a drawing) with the region between {line=line_index, pos=apos} diff --git a/text.lua b/text.lua index 6661fd8..9926269 100644 --- a/text.lua +++ b/text.lua @@ -1,8 +1,6 @@ -- text editor, particularly text drawing, horizontal wrap, vertical scrolling Text = {} -local utf8 = require 'utf8' - require 'search' require 'select' require 'undo' @@ -1010,5 +1008,3 @@ function Text.clear_cache(line) line.fragments = nil line.screen_line_starting_pos = nil end - -return Text