about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2023-03-18 23:59:42 -0700
committerKartik K. Agaram <vc@akkartik.com>2023-03-18 23:59:42 -0700
commitab09ec638767358e8314ab75593ae5e07df40200 (patch)
tree559589135b1975469822273bd476a9c5adadaad3
parentf1537d66d78d2e50cedd28edc67eae166f365e70 (diff)
parent30e75991ce3430550d7565c8141fc8ed68c67290 (diff)
downloadtext.love-ab09ec638767358e8314ab75593ae5e07df40200.tar.gz
Merge lines.love
-rw-r--r--edit.lua2
-rw-r--r--run.lua21
-rw-r--r--source.lua42
3 files changed, 45 insertions, 20 deletions
diff --git a/edit.lua b/edit.lua
index 722eddb..3f7ec34 100644
--- a/edit.lua
+++ b/edit.lua
@@ -59,7 +59,7 @@ function edit.initialize_state(top, left, right, font_height, line_height)  -- c
     right = math.floor(right),
     width = right-left,
 
-    filename = love.filesystem.getUserDirectory()..'/lines.txt',  -- '/' should work even on Windows
+    filename = love.filesystem.getSourceBaseDirectory()..'/lines.txt',  -- '/' should work even on Windows
     next_save = nil,
 
     -- undo
diff --git a/run.lua b/run.lua
index bf21c5a..9af9604 100644
--- a/run.lua
+++ b/run.lua
@@ -48,14 +48,14 @@ end
 function run.load_settings()
   love.graphics.setFont(love.graphics.newFont(Settings.font_height))
   -- determine default dimensions and flags
-  App.screen.width, App.screen.height, App.screen.flags = love.window.getMode()
+  App.screen.width, App.screen.height, App.screen.flags = App.screen.size()
   -- set up desired window dimensions
   App.screen.flags.resizable = true
   App.screen.flags.minwidth = math.min(App.screen.width, 200)
   App.screen.flags.minheight = math.min(App.screen.height, 200)
   App.screen.width, App.screen.height = Settings.width, Settings.height
-  love.window.setMode(App.screen.width, App.screen.height, App.screen.flags)
-  love.window.setPosition(Settings.x, Settings.y, Settings.displayindex)
+  App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
+  App.screen.move(Settings.x, Settings.y, Settings.displayindex)
   Editor_state = edit.initialize_state(Margin_top, Margin_left, App.screen.width-Margin_right, Settings.font_height, math.floor(Settings.font_height*1.3))
   Editor_state.filename = Settings.filename
   Editor_state.screen_top1 = Settings.screen_top
@@ -75,16 +75,23 @@ function run.initialize_default_settings()
 end
 
 function run.initialize_window_geometry(em_width)
+  local os = love.system.getOS()
+  if os == 'Android' or os == 'iOS' then
+    -- maximizing on iOS breaks text rendering: https://github.com/deltadaedalus/vudu/issues/7
+    -- no point second-guessing window dimensions on mobile
+    App.screen.width, App.screen.height, App.screen.flags = App.screen.size()
+    return
+  end
   -- maximize window
-  love.window.setMode(0, 0)  -- maximize
-  App.screen.width, App.screen.height, App.screen.flags = love.window.getMode()
+  App.screen.resize(0, 0)  -- maximize
+  App.screen.width, App.screen.height, App.screen.flags = App.screen.size()
   -- shrink height slightly to account for window decoration
   App.screen.height = App.screen.height-100
   App.screen.width = 40*em_width
   App.screen.flags.resizable = true
   App.screen.flags.minwidth = math.min(App.screen.width, 200)
   App.screen.flags.minheight = math.min(App.screen.height, 200)
-  love.window.setMode(App.screen.width, App.screen.height, App.screen.flags)
+  App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
 end
 
 function run.resize(w, h)
@@ -131,7 +138,7 @@ function run.settings()
     Settings = {}
   end
   if Current_app == 'run' then
-    Settings.x, Settings.y, Settings.displayindex = love.window.getPosition()
+    Settings.x, Settings.y, Settings.displayindex = App.screen.position()
   end
   local filename = Editor_state.filename
   if is_relative_path(filename) then
diff --git a/source.lua b/source.lua
index da168f4..a390ed3 100644
--- a/source.lua
+++ b/source.lua
@@ -105,16 +105,7 @@ end
 function source.load_settings()
   local settings = Settings.source
   love.graphics.setFont(love.graphics.newFont(settings.font_height))
-  -- maximize window to determine maximum allowable dimensions
-  App.screen.resize(0, 0)  -- maximize
-  Display_width, Display_height, App.screen.flags = App.screen.size()
-  -- set up desired window dimensions
-  App.screen.flags.resizable = true
-  App.screen.flags.minwidth = math.min(Display_width, 200)
-  App.screen.flags.minheight = math.min(Display_height, 200)
-  App.screen.width, App.screen.height = settings.width, settings.height
---?   print('setting window from settings:', App.screen.width, App.screen.height)
-  App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
+  source.resize_window_from_settings(settings)
 --?   print('loading source position', settings.x, settings.y, settings.displayindex)
   source.set_window_position_from_settings(settings)
   Show_log_browser_side = settings.show_log_browser_side
@@ -136,9 +127,29 @@ function source.load_settings()
   end
 end
 
+function source.resize_window_from_settings(settings)
+  local os = love.system.getOS()
+  if os == 'Android' or os == 'iOS' then
+    -- maximizing on iOS breaks text rendering: https://github.com/deltadaedalus/vudu/issues/7
+    -- no point second-guessing window dimensions on mobile
+    App.screen.width, App.screen.height, App.screen.flags = App.screen.size()
+    return
+  end
+  -- maximize window to determine maximum allowable dimensions
+  App.screen.resize(0, 0)  -- maximize
+  Display_width, Display_height, App.screen.flags = App.screen.size()
+  -- set up desired window dimensions
+  App.screen.flags.resizable = true
+  App.screen.flags.minwidth = math.min(Display_width, 200)
+  App.screen.flags.minheight = math.min(Display_height, 200)
+  App.screen.width, App.screen.height = settings.width, settings.height
+--?   print('setting window from settings:', App.screen.width, App.screen.height)
+  App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
+end
+
 function source.set_window_position_from_settings(settings)
-  -- setPosition doesn't quite seem to do what is asked of it on Linux.
-  love.window.setPosition(settings.x, settings.y-37, settings.displayindex)
+  -- love.window.setPosition doesn't quite seem to do what is asked of it on Linux.
+  App.screen.move(settings.x, settings.y-37, settings.displayindex)
 end
 
 function source.initialize_default_settings()
@@ -154,6 +165,13 @@ function source.initialize_default_settings()
 end
 
 function source.initialize_window_geometry(em_width)
+  local os = love.system.getOS()
+  if os == 'Android' or os == 'iOS' then
+    -- maximizing on iOS breaks text rendering: https://github.com/deltadaedalus/vudu/issues/7
+    -- no point second-guessing window dimensions on mobile
+    App.screen.width, App.screen.height, App.screen.flags = App.screen.size()
+    return
+  end
   -- maximize window
   App.screen.resize(0, 0)  -- maximize
   Display_width, Display_height, App.screen.flags = App.screen.size()