about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-07-11 22:11:48 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-07-11 22:11:58 -0700
commit3dccd7f81abff050a37b5a65eb5e3cc6756a4b7f (patch)
tree55bfdeca3143b269616f348efa29869f74db3cef
parente68d235c5fd455c6629f14b7219d376049c61481 (diff)
downloadtext.love-3dccd7f81abff050a37b5a65eb5e3cc6756a4b7f.tar.gz
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.
-rw-r--r--drawing.lua4
-rw-r--r--file.lua2
-rw-r--r--geom.lua4
-rw-r--r--main.lua8
-rw-r--r--select.lua2
-rw-r--r--text.lua4
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