about summary refs log tree commit diff stats
path: root/source.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-09-17 10:49:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-09-17 10:49:27 -0700
commit2a36ce3c060d4b6ee634421f2a792f450b910ad4 (patch)
treeda4b11a8c1d4295f69b3594e27fbab633758060c /source.lua
parentf2c8f06819658084ec2f585d0721af345fb9af7d (diff)
parent287050d598184943209b564657cb1e29ff641fd7 (diff)
downloadview.love-2a36ce3c060d4b6ee634421f2a792f450b910ad4.tar.gz
Merge lines.love
Diffstat (limited to 'source.lua')
-rw-r--r--source.lua25
1 files changed, 14 insertions, 11 deletions
diff --git a/source.lua b/source.lua
index 843a244..611cc05 100644
--- a/source.lua
+++ b/source.lua
@@ -45,7 +45,7 @@ function source.initialize_globals()
     index = 1,
   }
 
-  Menu_status_bar_height = nil  -- initialized below
+  Menu_status_bar_height = 5 + --[[line height in tests]] 15 + 5
 
   -- a few text objects we can avoid recomputing unless the font changes
   Text_cache = {}
@@ -116,15 +116,15 @@ function source.load_settings()
   local settings = Settings.source
   love.graphics.setFont(love.graphics.newFont(settings.font_height))
   -- maximize window to determine maximum allowable dimensions
-  love.window.setMode(0, 0)  -- maximize
-  Display_width, Display_height, App.screen.flags = love.window.getMode()
+  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)
-  love.window.setMode(App.screen.width, App.screen.height, App.screen.flags)
+  App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
 --?   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
@@ -156,19 +156,19 @@ end
 
 function source.initialize_window_geometry(em_width)
   -- maximize window
-  love.window.setMode(0, 0)  -- maximize
-  Display_width, Display_height, App.screen.flags = love.window.getMode()
+  App.screen.resize(0, 0)  -- maximize
+  Display_width, Display_height, App.screen.flags = App.screen.size()
   -- shrink height slightly to account for window decoration
   App.screen.height = Display_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.width, 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)
   print('initializing source position')
   if Settings == nil then Settings = {} end
   if Settings.source == nil then Settings.source = {} end
-  Settings.source.x, Settings.source.y, Settings.source.displayindex = love.window.getPosition()
+  Settings.source.x, Settings.source.y, Settings.source.displayindex = App.screen.position()
 end
 
 function source.resize(w, h)
@@ -254,7 +254,7 @@ end
 function source.settings()
   if Current_app == 'source' then
 --?     print('reading source window position')
-    Settings.source.x, Settings.source.y, Settings.source.displayindex = love.window.getPosition()
+    Settings.source.x, Settings.source.y, Settings.source.displayindex = App.screen.position()
   end
   local filename = Editor_state.filename
   if is_relative_path(filename) then
@@ -322,12 +322,15 @@ function source.keychord_pressed(chord, key)
 --?     print('C-l')
     Show_log_browser_side = not Show_log_browser_side
     if Show_log_browser_side then
-      App.screen.width = Log_browser_state.right + Margin_right
+      App.screen.width = math.min(Display_width, App.screen.width*2)
+      Editor_state.right = App.screen.width/2 - Margin_right
+      Log_browser_state.left = App.screen.width/2 + Margin_left
+      Log_browser_state.right = App.screen.width - Margin_right
     else
       App.screen.width = Editor_state.right + Margin_right
     end
 --?     print('setting window:', App.screen.width, App.screen.height)
-    love.window.setMode(App.screen.width, App.screen.height, App.screen.flags)
+    App.screen.resize(App.screen.width, App.screen.height, App.screen.flags)
 --?     print('done setting window')
     -- try to restore position if possible
     -- if the window gets wider the window manager may not respect this