History

console.lua: factor the bottom margin in line calculations

This is more important now that the margin is bigger due to the scaling with the window.

Guido Cella committed 2 years ago

Commit ce4a8041 parent 10789fa1 file · +2 −3Browse files

Showing the changes to player/lua/console.lua (1 of 1 file). Show all

Unified · Split

player/lua/console.lua+2−3
@@ -79,6 +79,7 @@ local line = '' · 78 unmodified lines
79local cursor = 179local cursor = 1
80local default_prompt = '>'80local default_prompt = '>'
81local prompt = default_prompt81local prompt = default_prompt
82local bottom_left_margin = 6
82local default_id = 'default'83local default_id = 'default'
83local id = default_id84local id = default_id
84local histories = {[id] = {}}85local histories = {[id] = {}}
@@ -275,7 +276,7 @@ local function calculate_max_log_lines() · 190 unmodified lines
275 select(2, mp.get_property('term-status-msg'):gsub('\\n', ''))276 select(2, mp.get_property('term-status-msg'):gsub('\\n', ''))
276 end277 end
277 278
278 return math.floor(select(2, get_scaled_osd_dimensions())279 return math.floor((select(2, get_scaled_osd_dimensions()) - bottom_left_margin)
279 * (1 - global_margins.t - global_margins.b)280 * (1 - global_margins.t - global_margins.b)
280 / opts.font_size281 / opts.font_size
281 -- Subtract 1 for the input line and 0.5 for the empty282 -- Subtract 1 for the input line and 0.5 for the empty
@@ -513,8 +514,6 @@ local function update() · 231 unmodified lines
513 514
514 local screenx, screeny = get_scaled_osd_dimensions()515 local screenx, screeny = get_scaled_osd_dimensions()
515 516
516 local bottom_left_margin = 6
517
518 local coordinate_top = math.floor(global_margins.t * screeny + 0.5)517 local coordinate_top = math.floor(global_margins.t * screeny + 0.5)
519 local clipping_coordinates = '0,' .. coordinate_top .. ',' ..518 local clipping_coordinates = '0,' .. coordinate_top .. ',' ..
520 screenx .. ',' .. screeny519 screenx .. ',' .. screeny

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t