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.
This commit is contained in:
parent
e68d235c5f
commit
3dccd7f81a
|
@ -1,7 +1,5 @@
|
||||||
-- primitives for editing drawings
|
-- primitives for editing drawings
|
||||||
Drawing = {}
|
Drawing = {}
|
||||||
geom = require 'geom'
|
|
||||||
|
|
||||||
require 'drawing_tests'
|
require 'drawing_tests'
|
||||||
|
|
||||||
-- All drawings span 100% of some conceptual 'page width' and divide it up
|
-- 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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return Drawing
|
|
||||||
|
|
2
file.lua
2
file.lua
|
@ -1,6 +1,4 @@
|
||||||
-- primitives for saving to file and loading from file
|
-- primitives for saving to file and loading from file
|
||||||
Drawing = require 'drawing'
|
|
||||||
|
|
||||||
function load_from_disk(filename)
|
function load_from_disk(filename)
|
||||||
local infile = App.open_for_reading(filename)
|
local infile = App.open_for_reading(filename)
|
||||||
local result = load_from_file(infile)
|
local result = load_from_file(infile)
|
||||||
|
|
4
geom.lua
4
geom.lua
|
@ -1,4 +1,4 @@
|
||||||
local geom = {}
|
geom = {}
|
||||||
|
|
||||||
function geom.on_shape(x,y, drawing, shape)
|
function geom.on_shape(x,y, drawing, shape)
|
||||||
if shape.mode == 'freehand' then
|
if shape.mode == 'freehand' then
|
||||||
|
@ -166,5 +166,3 @@ function geom.angle_between(ox,oy, x,y, s,e)
|
||||||
end
|
end
|
||||||
|
|
||||||
function geom.dist(x1,y1, x2,y2) return ((x2-x1)^2+(y2-y1)^2)^0.5 end
|
function geom.dist(x1,y1, x2,y2) return ((x2-x1)^2+(y2-y1)^2)^0.5 end
|
||||||
|
|
||||||
return geom
|
|
||||||
|
|
8
main.lua
8
main.lua
|
@ -1,4 +1,4 @@
|
||||||
local utf8 = require 'utf8'
|
utf8 = require 'utf8'
|
||||||
|
|
||||||
require 'app'
|
require 'app'
|
||||||
require 'test'
|
require 'test'
|
||||||
|
@ -6,9 +6,9 @@ require 'test'
|
||||||
require 'keychord'
|
require 'keychord'
|
||||||
require 'file'
|
require 'file'
|
||||||
require 'button'
|
require 'button'
|
||||||
local Text = require 'text'
|
require 'text'
|
||||||
local Drawing = require 'drawing'
|
require 'drawing'
|
||||||
local geom = require 'geom'
|
require 'geom'
|
||||||
require 'help'
|
require 'help'
|
||||||
require 'icons'
|
require 'icons'
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
-- helpers for selecting portions of text
|
-- helpers for selecting portions of text
|
||||||
|
|
||||||
local utf8 = require 'utf8'
|
|
||||||
|
|
||||||
-- Return any intersection of the region from Selection1 to Cursor1 (or
|
-- 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
|
-- 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}
|
-- currently over a drawing) with the region between {line=line_index, pos=apos}
|
||||||
|
|
4
text.lua
4
text.lua
|
@ -1,8 +1,6 @@
|
||||||
-- text editor, particularly text drawing, horizontal wrap, vertical scrolling
|
-- text editor, particularly text drawing, horizontal wrap, vertical scrolling
|
||||||
Text = {}
|
Text = {}
|
||||||
|
|
||||||
local utf8 = require 'utf8'
|
|
||||||
|
|
||||||
require 'search'
|
require 'search'
|
||||||
require 'select'
|
require 'select'
|
||||||
require 'undo'
|
require 'undo'
|
||||||
|
@ -1010,5 +1008,3 @@ function Text.clear_cache(line)
|
||||||
line.fragments = nil
|
line.fragments = nil
|
||||||
line.screen_line_starting_pos = nil
|
line.screen_line_starting_pos = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
return Text
|
|
||||||
|
|
Loading…
Reference in New Issue